akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
#include <cstdio>

using namespace std;

int main() {
	int n;
	while (cin >> n) {
		if (n == -1) {
			break;
		}
		double x = 1.0;
		double y = 0.0;
		for (int i = 1; i < n; i++) {
			if (fabs(x) <= 0.01) {
				if (y >= 0) {
					x += 1.0;
				} else {
					x -= 1.0;
				}
			} else {
				double kaku = atan(y/x);
				if (x < 0.0) {
					kaku += acos(-1.0);
				}
				double x1, y1;
				x1 = cos(-kaku)*x-sin(-kaku)*y;
				y1 = sin(-kaku)*x+cos(-kaku)*y;
				y1 += 1.0;
				x = cos(kaku)*x1-sin(kaku)*y1;
				y = sin(kaku)*x1+cos(kaku)*y1;
			}
		}
		printf("%.2f\n%.2f\n", x, y);
	}
	return 0;
}

Measured memory_bytes: 1288
sx,sy,tx,ty=map(int,input().split())
def pans(l,c):
    for i in range(l):
        print(c,end="")
H=ty-sy
W=tx-sx
pans(H,"U")
pans(W,"R")
pans(H,"D")
pans(W+1,"L")
pans(H+1,"U")
pans(W+1,"R")
pans(1,"D")
pans(1,"R")
pans(H+1,"D")
pans(W+1,"L")
pans(1,"U")


Measured memory_bytes: 4468
S = input()
sum1 = 0
sum2 = 0
for i in range(len(S)):
	if i % 2 == 0 and S[i] == '0':
		sum1 += 1
	elif i % 2 == 0 and S[i] == '1':
		sum2 += 1
	elif i % 2 == 1 and S[i] == '0':
		sum2 += 1
	elif i % 2 == 1 and S[i] == '1':
		sum1 += 1
print(min(sum1, sum2))

Measured memory_bytes: 39920
#include<bits/stdc++.h>
using namespace std;
int n;
long long mx=-1,val=0,a[200010];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i) {
		scanf("%lld",&a[i]);
		if(a[i]<mx) val+=(mx-a[i]);
		mx=max(mx,a[i]);
	}
	printf("%lld\n",val);
	return 0;
}

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

int main() {
    int a, b, c;
    int i = 0;
    scanf("%d %d %d", &a, &b, &c);
    
    for (int x = a; x <= b; x++) {
        if (c % x ==  0) i++;
    }
    
    printf("%d\n", i);
}


Measured memory_bytes: 2704
//in progress
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define fr(i,a,b) for(int i = (int)(a); i <= (int)(b); i++)
#define forn(i,n) for(int i =0; i < (int)(n); i++)
#define rfr(i,a,b) for(int i = (int)(a); i >= (int)(b); i--)
#define PI 3.14159265
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  //freopen("a.in", "r", stdin);
  //freopen("a.out", "w", stdout);
  ll n,k;
  char str[3005],s[3005];
  cin>>s;
  cin>>str;
  n=strlen(s);k=strlen(str);
  ll lcs[3005][3005];
  for(int i=0;i<3005;i++)
  lcs[0][i]=lcs[i][0]=0;
  string res="";
  for(int i=1;i<=n;i++)
  {
    for(int j=1;j<=k;j++)
    {
      lcs[i][j]=max(lcs[i-1][j],lcs[i][j-1]);
      if(s[i-1]==str[j-1])
      lcs[i][j]=max(lcs[i][j],lcs[i-1][j-1]+1);
    }
  }
//   for(int i=0;i<=n;i++)
//   {
//     for(int j=0;j<=k;j++)
//     cout<<lcs[i][j]<<" ";
//     cout<<"\n";
//   }
ll i=n,j=k;
  while(i>0 && j>0)
  {
      if(lcs[i][j]>lcs[i-1][j] && lcs[i][j]>lcs[i][j-1])
      {res+=str[j-1];i--;j--;}
      else if(lcs[i-1][j]<=lcs[i][j-1])
      j--;
      else
      i--;
  }
  reverse(res.begin(),res.end());
  cout<<res<<"\n";
  return 0;
}


Measured memory_bytes: 70784
N, K = map(int, input().split())
h = list(map(int,input().split()))

dp = [float('inf')]*N

dp[0] = 0

for i in range(1,N):
    k = 1
    while(i-k >= 0):
        dp[i] = min(dp[i], dp[i-k]+abs(h[i]-h[i-k]))
        if k == K:
            break
        if k < K:
            k += 1

print(dp[N-1])

Measured memory_bytes: 85364
import sys, math
def input():
    return sys.stdin.readline()[:-1]
from itertools import permutations, combinations
from collections import defaultdict, Counter

sys.setrecursionlimit(10**7)
N = int(input())

if N%2:
    ki = N//2 + 1
    gu = N//2
    print(ki*gu)
else:
    ki = N//2
    gu = N//2
    print(ki*gu)



Measured memory_bytes: 3316
import math
a,b,c=map(int,input().split())
s=a*b*math.sin(math.radians(c))*0.5
x=pow(a**2+b**2-2*a*b*math.cos(math.radians(c)),0.5)
l=a+b+x
h=2*s/a
print(s,l,h)


Measured memory_bytes: 5724
A, B = list(map(int,input().split()))
list_i = []
for i in range(1100):
    if A <= i * 8 / 100 < A + 1:
        list_i.append(i)
    else:
        pass
            
        
list_j = []
for j in range(1100):
    if B <= j * 10 / 100 < B + 1:
        list_j.append(j)
    else:
        pass
            
    
s_i = set(list_i)
s_j = set(list_j)
list_w = s_j & s_i
if not list_w :
    print(-1)   
else:
     print(min(list_w))
    

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		sc.close();

		String num = Integer.toString(n);
		String[] line = num.split("");
		for(int i = 0; i < num.length(); i++) {
			if(line[i].equals("1")) {
				 System.out.print("9");
            } else {
              System.out.print("1");
			}
		}

	}
}

Measured memory_bytes: 25172
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin>>n;
	cout<<(n+1)/2<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
using namespace std;
int main()
{
  int n;
  cin >> n;
  int dp[n+1],ar[n+1];  
  
  for(int i=0;i<n;++i)
    cin >> ar[i];
  
  dp[0]=0;
  dp[1] = abs(ar[1]-ar[0]);
  for(int i=2;i<n;++i)
  {
    dp[i] = min(dp[i-2] + abs(ar[i]-ar[i-2]), dp[i-1] + abs(ar[i]-ar[i-1]));
  }
  cout<<dp[n-1];
  
  return 0;
  
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin(), v.end()
#define ITR(v, i) for(auto ite = v.begin(); ite != v.end(); ite++)
const ll INF = 999999999999999;
const ll MOD = 1000000007;
const ll MAX_N = 500010;
ll a, b, c, d, e, f, p, t, x, y, z, q, m, n, r, h, k, w, l, ans;
#include <cstdint>
template <std::uint_fast64_t Modulus> class modint {
    using u64 = std::uint_fast64_t;

  public:
    u64 a;
    constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
    constexpr u64 &value() noexcept { return a; }
    constexpr const u64 &value() const noexcept { return a; }
    constexpr modint operator+(const modint rhs) const noexcept { return modint(*this) += rhs; }
    constexpr modint operator-(const modint rhs) const noexcept { return modint(*this) -= rhs; }
    constexpr modint operator*(const modint rhs) const noexcept { return modint(*this) *= rhs; }
    constexpr modint operator/(const modint rhs) const noexcept { return modint(*this) /= rhs; }
    constexpr modint &operator+=(const modint rhs) noexcept {
        a += rhs.a;
        if(a >= Modulus) {
            a -= Modulus;
        }
        return *this;
    }
    constexpr modint &operator-=(const modint rhs) noexcept {
        if(a < rhs.a) {
            a += Modulus;
        }
        a -= rhs.a;
        return *this;
    }
    constexpr modint &operator*=(const modint rhs) noexcept {
        a = a * rhs.a % Modulus;
        return *this;
    }
    constexpr modint &operator/=(modint rhs) noexcept {
        u64 exp = Modulus - 2;
        while(exp) {
            if(exp % 2) {
                *this *= rhs;
            }
            rhs *= rhs;
            exp /= 2;
        }
        return *this;
    }
};
using mint = modint<MOD>;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> k;
    mint ans = 0;
    for(ll i = k; i <= n + 1; i++) {
        ans += i * n + 1 - i * (i - 1);
    }

    cout << ans.a << endl;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define all(v) ((v).begin()),((v).end())
#define ll long long
#define fastIO cout << fixed << setprecision(9), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
double const EPS = 1e-9, PI = acos(-1);
const int N = 1e5 + 9, M = 5e2 + 9, OO = 2e9 + 7, MOD = 1e9 + 7;
const ll inf = 1e18;

typedef vector<ll> row;
typedef vector<row> matrix;

matrix zero(int n, int m) {
  return matrix(n, row(m, 0));
}

matrix idenity(int n) {
  matrix ret = zero(n, n);
  for (int i = 0; i < n; ++i)
    ret[i][i] = 1;
  return ret;
}

matrix multiply(const matrix& a, const matrix & b) {
  matrix ret = zero(a.size(), b[0].size());
  int aSZ = a.size(), bSZ = a[0].size(), cSZ = b[0].size();
  for (int i = 0; i < aSZ; ++i) {
    for (int k = 0; k < bSZ; ++k) {
      for (int j = 0; j < cSZ; ++j) {
        ret[i][j] = ((ret[i][j] % MOD) + (a[i][k] * b[k][j]) % MOD) % MOD;
      }
    }
  }
  return ret;
}

matrix pow(const matrix &a, ll k) {
  if(k == 0)
    return idenity(a.size());
  if(k % 2 == 1)
    return multiply(a, pow(a, k - 1));
  return pow(multiply(a, a), k / 2);
}

bool arr[M][M];
ll dp[M][M];

ll fastPower(ll x, ll b) {
  ll ret = 1;
  while(b) {
    if(b & 1)
      ret = (ret * x);
    b /= 2;
    x = (x * x);
  }
  return ret;
}

int main() {
  fastIO;
#ifdef LOCAL
  freopen("input.in", "rt", stdin);
#endif
  int n;
  ll k;
  cin >> n >> k;
  matrix ret = zero(n, n);
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      cin >> ret[i][j];
    }
  }
  ret = pow(ret, k);
  ll answer = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      answer += ret[i][j];
      answer %= MOD;
    }
  }
  cout << answer;
//  for (int i = 0; i < n; ++i)
//    dp[0][i] = 1;
//  for (int steps = 1; steps <= k; ++steps) {
//    for (int i = 0; i < n; ++i)
//      for (int j = 0; j < n; ++j)
//        if(arr[i][j])
//          dp[steps][j] += dp[steps-1][i];
//  }
//  ll answer = 0;
//  for (int i = 0; i < n; ++i) {
//    answer += dp[k][i];
//    answer %= MOD;
//  }
//  cout << answer;
  return 0;
}


Measured memory_bytes: 1664
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

template<int Modulo = MOD> struct Mint {
	Int val;
	constexpr Mint(Int v = 0) noexcept : val(v% Modulo) {
		if (val < 0) v += Modulo;
	}
	constexpr int getmod() { return Modulo; }
	constexpr Mint operator - () const noexcept { return val ? Modulo - val : 0; }
	constexpr Mint operator + (const Mint& r) const noexcept { return Mint(*this) += r; }
	constexpr Mint operator - (const Mint& r) const noexcept { return Mint(*this) -= r; }
	constexpr Mint operator * (const Mint& r) const noexcept { return Mint(*this) *= r; }
	constexpr Mint operator / (const Mint& r) const noexcept { return Mint(*this) /= r; }
	constexpr Mint& operator += (const Mint& r) noexcept {
		val += r.val;
		if (val >= Modulo) val -= Modulo;
		return *this;
	}
	constexpr Mint& operator -= (const Mint& r) noexcept {
		val -= r.val;
		if (val < 0) val += Modulo;
		return *this;
	}
	constexpr Mint& operator *= (const Mint& r) noexcept {
		val = val * r.val % Modulo;
		return *this;
	}
	constexpr Mint& operator /= (const Mint& r) noexcept {
		Int a = r.val, b = Modulo, u = 1, v = 0;
		while (b) {
			Int t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		val = val * u % Modulo;
		if (val < 0) val += Modulo;
		return *this;
	}
	constexpr bool operator == (const Mint& r) const noexcept {
		return this->val == r.val;
	}
	constexpr bool operator != (const Mint& r) const noexcept {
		return this->val != r.val;
	}
	friend ostream& operator << (ostream& os, const Mint<Modulo>& x) noexcept {
		return os << x.val;
	}
	friend istream& operator >> (istream& is, Mint<Modulo>& x) noexcept {
		Int tmp; is >> tmp;
		x = Mint<Modulo>(tmp);
		return is;
	}
	friend constexpr Mint<Modulo> modpow(const Mint<Modulo>& a, Int n) noexcept {
		Mint res(1), tmp = a;
		while (n > 0) {
			if (n & 1) res *= tmp;
			tmp *= tmp;
			n >>= 1;
		}
		return res;
	}
};

using mint = Mint<>;

int main() {

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

	Int ab, bc, ca;
	cin >> ab >> bc >> ca;

	cout << ab * bc / 2 << endl;


}

Measured memory_bytes: 256
IDENTIFICATION                   DIVISION.
PROGRAM-ID.                      ABC_068_A.
ENVIRONMENT                      DIVISION.
DATA                             DIVISION.
WORKING-STORAGE                  SECTION.
    01 N      PIC X(3).
    01 ans    PIC X(18).
PROCEDURE                        DIVISION.
MAIN.
    ACCEPT N.

    DISPLAY "ABC" N.
    STOP RUN.


Measured memory_bytes: 384
#include<iostream>
#include<bits/stdc++.h>
#include<iomanip>
#include<math.h>
#include<vector>
#include<cctype>
#include<string>
#include<set>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::string line;
typedef long long ll;

int main(){

   string s;
   cin >> s;
   if(s[0]== s[2]) cout << "Yes" << endl;
   else cout << "No" << endl;

   return 0;
}

Measured memory_bytes: 256
mod=10**9+7
import math
import sys
from collections import deque
import heapq
import copy
import itertools
from itertools import permutations
from itertools import combinations
import bisect
def mi() : return map(int,sys.stdin.readline().split())
def ii() : return int(sys.stdin.readline().rstrip())
def i() : return sys.stdin.readline().rstrip()
a=i()
b=i()
c=0
for i in range(len(a)):
  if a[i]!=b[i]:
    c+=1
print(c)

Measured memory_bytes: 74840
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <math.h>
#include <numeric>

using namespace std;

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

int main() {
	int N;
	string S;
	string next_S = "";
	int count_zero = 0;
	int count_one = 0;


	cin >> S;

	N = S.size();

	for(int i = 0; i < N; i++){
		if(S[i] == '0'){
			count_zero++;
		}
		else{
			count_one++;
		}
	}

	cout << N - abs(count_zero - count_one) << endl;


//	while(S.size() != next_S.size()) {
//		for (int i = 0; i < N; i++) {
//			if ((i == N) || (i == N - 1)) {
//				break;
//			}
//
//			if ((S[i]- '\0' + S[i + 1] - '\0') == 1) {
//				i++;
//			} else {
//				next_S += S[i];
//			}
//		}
//
//		S = next_S;
//		next_S = "";
//	}
//
//	cout << N - S.size() << endl;
}


Measured memory_bytes: 512
class dice():
    def __init__(self,labels):
        self.l=labels
    def check(self,d2):
        l1=self.l
        for a in range(4):
            l1[1],l1[2],l1[3],l1[4]=l1[2],l1[4],l1[1],l1[3]
            for b in range(4):
                l1[0],l1[3],l1[2],l1[5]=l1[2],l1[0],l1[5],l1[3]
                for c in range(4):
                    l1[0],l1[1],l1[5],l1[4]=l1[4],l1[0],l1[1],l1[5]
                    if l1==d2.l:
                        return True
                        break
a=dice([int(i) for i in input().split()])
b=dice([int(i) for i in input().split()])
print("Yes" if a.check(b) else "No")


Measured memory_bytes: 5608
def _print(s, i, j)
  puts s[(i.to_i)..(j.to_i)]
end

def replace(s, i, j, r)
  s[(i.to_i)..(j.to_i)] = r
end

def reverse(s, i, j)
  p = s[(i.to_i)..(j.to_i)].reverse
  s[(i.to_i)..(j.to_i)] = p
end

s = gets.chomp
q = gets.chomp.to_i
q.times do
  f, *args = gets.chomp.split
  args.unshift s
  case f
  when "replace" then replace(*args)
  when "reverse" then reverse(*args)
  when "print" then _print(*args)
  end
end



Measured memory_bytes: 6952
#include<iostream>
 using namespace std;
 int main(){
     int n,i;
     cin>>n;
     int num_list[n];
     for (i=0;i<n;i++){
         cin>>num_list[i];
     }
     for (i=n-1;i>0;i--){
         cout<<num_list[i]<<" ";
     }
     cout<<num_list[0]<<endl;
     return 0;
     
 }


Measured memory_bytes: 3116
#include<iostream>
#include<cmath>
#include<numeric>
#include<functional>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>
#include<queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n;i++)
#define ll long long
#define INF 2147483647
using namespace std;
using Graph=vector<vector<int>>;

int main(){
  string s,t=""; cin>>s;
  ll n=s.length(),ans=0,cons=0;
  rep(i,s.length()){
    if(s[i]=='A'){
      cons++;
    }else if(i<n-1 && s[i]=='B' && s[i+1]=='C'){
      ans+=cons;
      i++;
    }else{
      cons=0;
    }
  }
  cout<<ans;
}


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

int main() {
    int N;
    cin >> N;
    vector<ll> A(N), B(N), S(N), T(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i] >> B[i];
        S[i] = A[i];
        T[i] = B[i];
    }
    sort(S.begin(), S.end());
    sort(T.begin(), T.end());
    
    if (N%2 == 1) {
        ll ma = T[(N-1)/2];
        ll mi = S[(N-1)/2];
        cout << ma-mi+1 << endl;
        return 0;
    }
    else {
        ll ma = T[N/2-1]+T[N/2];
        ll mi = S[N/2-1]+S[N/2];
        cout << ma-mi+1 << endl;
        return 0;
    }
    return 0;
}


Measured memory_bytes: 9596
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using bint = boost::multiprecision::cpp_int;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repSE(i,s,n) for (int i = (s); i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int col[3][4000]; //RGB
int oCol[3][4000]; //RGB

int main()
{
    int N;
    cin >> N;
    string S, rgb = "RGB";
    cin >> S;
    vector<int> iRGB(3, 0);
    rep(i,N) {
        if (S[i] == 'R') {
            col[0][iRGB[0]] = i;
            iRGB[0]++;
        }
        else if (S[i] == 'G') {
            col[1][iRGB[1]] = i;
            iRGB[1]++;
        }
        else if (S[i] == 'B') {
            col[2][iRGB[2]] = i;
            iRGB[2]++;
        }
    }
    int oR = 0, oG = 0, oB = 0;
    for (int i = N-1; i>=0; i--) {
        oCol[0][i] = oR;
        oCol[1][i] = oG;
        oCol[2][i] = oB;
        if (S[i] == 'R') {
            oR++;
        }
        else if (S[i] == 'G') {
            oG++;
        }
        else if (S[i] == 'B') {
            oB++;
        }
    }

    vector<int> ijk = {0, 1, 2};
    ll cnt = 0;
    do {
        // cout << "ijk: " << ijk[0] << ", " << ijk[1] << ", " << ijk[2] << endl;
        int Si = iRGB[ijk[0]], Sj = iRGB[ijk[1]], Sk = iRGB[ijk[2]];
        rep(i, Si) {
            int _i = col[ijk[0]][i];
            int Soj = oCol[ijk[1]][_i];
            rep (j, Sj) {
                int _j = col[ijk[1]][j];
                if (_j > _i) {
                    cnt += oCol[ijk[2]][_j];
                    // cout << "cnt: " << cnt << endl;
                    int _k = 2 * _j - _i;
                    // cout << "_k: " << _k << ", S[_k]: " << S[_k] << ", rgb[ijk[2]]: " << rgb[ijk[2]] << endl;
                    if (S[_k] == rgb[ijk[2]]) {
                        cnt --;
                        // cout << "cnt-- " << cnt << endl;
                    }
                }
            }
        }
    } while (next_permutation(ijk.begin(), ijk.end()));
    // if (S[0] == rgb[0]) cout << "hoge" << endl;
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3656
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	var ans = 0
  input = input.trim().split("\n");
	const [N] = input[0].split(" ").map((n) => parseInt(n));
	for (i = 0; i <= N; i++) {
		if (!(i % 5 == 0 || i % 3 == 0)) {
			ans = BigInt(ans) + BigInt(i)
		}
	}

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


Measured memory_bytes: 35168
def ed(l1,l2):
    dp=[[0 for x in range(len(l2)+1)] for y in range(len(l1)+1)]
    
    for i in range(1,len(l1)+1):
        dp[i][0]=i
    for i in range(1,len(l2)+1):
        dp[0][i]=i


    for i in range(1,len(l1)+1):
        for j in range(1,len(l2)+1):
            if l1[i-1]==l2[j-1]:
                cost=0
            else:
                cost=1
            dp[i][j]=min(dp[i-1][j]+1,dp[i][j-1]+1,dp[i-1][j-1]+cost)
 
    return dp[len(l1)][len(l2)]


l1=list(input())
l2=list(input())
print(ed(l1,l2))



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

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;

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

const ll mod=(1e+9)+7;
const ll inf=1e+16; 

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m;i>=n;i--)
#define all(x) x.begin(),x.end()



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

 ll n;
  cin >> n;
  vpll x(n);
  rep(i,0,n) cin >> x[i].first >> x[i].second;
  sort(all(x));
  map<pll,ll> mp;
  rep(i,0,n-1){
   rep(j,i+1,n) mp[make_pair(x[j].first-x[i].first,x[j].second-x[i].second)]++;
  }

  ll res=0;
  for(auto p:mp) chmax(res,p.second);  

  cout << n-res << endl;  
  
  
}

Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void) {
    char buf[100];
    int N;
    int a;
    int Odd = 0;

   scanf("%d", &N);
  for(int i=0;i<N;i++){
    scanf("%d ",&a);
    if(a%2)
      Odd++;
  }
  if(Odd%2)
    printf("NO");
  else
    printf("YES");
    return 0;
}

Measured memory_bytes: 1708
#include <bits/stdc++.h>
using namespace std;
#define MAXN 10000010
char s[MAXN];
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	int a,b,c,d,n,i,j,k=0;
	cin>>n>>a>>b>>c>>d;
	for(i=1;i<=n;i++) cin>>s[i];
	for(i=a+1;i<c;i++)
		if(s[i]=='#' && s[i+1]=='#') { cout<<"No"<<endl; return 0; }
	for(i=b+1;i<d;i++)
		if(s[i]=='#' && s[i+1]=='#') { cout<<"No"<<endl; return 0; }
	for(i=b-1 ; i<d ; i++)
		if((s[i]=='.' && s[i+1]=='.' && s[i+2]=='.') && i-1!=d) k=1;
	if(d>c) k=1;
	if(k==1) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
#include<limits.h>

int main(void){
  int num,i,j;
  int A[100][100];
  int a[100],b[100],c;
  int weight,minimum,moku,t;

  scanf("%d",&num);
  for(i=0;i<num;i++){
    a[i]=1;
    b[i]=0;
    for(j=0;j<num;j++){
      scanf("%d", &A[i][j]);
	    }
    }

    b[0] = 1;
    a[0] = 0;
    c = num - 1;
    weight = 0;

    while (c--){
      minimum = INT_MAX;

      for(j=0;j<num;j++){
	if(!b[j])continue;

	for(i=0;i<num;i++){
	  if(!a[i])continue;

	  t=A[j][i];
	  if(0<=t&&t<minimum){
	    moku = i;
	    minimum = t;
	  }
	}
      }
      b[moku]=1;
      a[moku]=0;
      weight+=minimum;
    }
    printf("%d\n",weight);
    return 0;
  }

	    
	  
	   



Measured memory_bytes: 2040
#include <iostream>
using namespace std;
int main(void){
  int HP,Atack,nokori,kas;
  cin >> HP >> Atack;
  nokori = HP % Atack;
  kas = HP / Atack;
  if(nokori > 0){
  	cout << kas +1;
  }else{
    cout << kas;
  }
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
    static int W,n;
    static int[] w,v;
    static int[][] dp;
    static int MAX_N = 10000;
    static int MAX_W = 1000;

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

	W = sc.nextInt();
	int count = 1;

	while(W!=0){
	    n = sc.nextInt();
	    w = new int[n];
	    v = new int[n];
	    for(int i=0; i<n; i++){
		String[] line = sc.next().split(",");
		v[i] = Integer.parseInt(line[0]);
		w[i] = Integer.parseInt(line[1]);
	    }

	    dp = new int[n+1][W+1];

	    solve();
	    System.out.println("Case "+count+":");
	    System.out.println(dp[0][W]);
	    System.out.println(getMin());

	    count++;
	    W = sc.nextInt();
	}
    }

    public static void solve(){
	for(int i=n-1; i>=0; i--){
	    for(int j=0; j<=W; j++){
		if(j<w[i]){
		    dp[i][j] = dp[i+1][j];
		}else{
		    dp[i][j] = Math.max(dp[i+1][j], dp[i+1][j-w[i]]+v[i]);
		}
	    }
	}
    }

    public static int getMin(){
	int min = 1000;
	for(int j=0; j<=W; j++){
	    if(dp[0][j]==dp[0][W] && j<min){
		min = j;
	    }
	}
	return min;
    }
}

Measured memory_bytes: 16000
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;
typedef long long ll;

bool isok(ll num, ll s, ll c) {
  if(s < num) {
    ll rem = num - s;
    c -= 2LL * rem;
  }
  return c >= num * 2LL;
}

ll f(ll N, ll M) {
  ll ans = 0;
  ll left = 0, right = N + M * 2LL;
  while(left + 1 < right) {
    ll mid = (left + right) / 2LL;
    if(isok(mid, N, M)) {
      left = mid;
    } else {
      right = mid;
    }
    //    cout << left << " " << right << endl;
  }
  return left;
}
int main() {
  ll N, M;
  cin>>N>>M;
  ll ans = f(N, M);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
from heapq import heappush, heappop
N, M, X = map(int, input().split())
T = [int(input()) for i in range(N)]
G = [[] for i in range(N)]
for i in range(M):
    A, B, D = map(int, input().split())
    G[A-1].append((B-1, D))
    G[B-1].append((A-1, D))
INF = 10**9
dist = [[INF]*(2*X+1) for i in range(N)]
dist[0][-X] = 0

que = [(0, 0, -X)]
while que:
    cost, u, t = heappop(que)
    if dist[u][t] < cost:
        continue
    for v, d in G[u]:
        t1 = max(0, t - d) if t > 0 else min(0, t + d)
        if (t1 < 0 and T[v] == 2) or (t1 > 0 and T[v] == 0):
            continue
        t1 = [-X, t1, X][T[v]]
        if cost + d < dist[v][t1]:
            dist[v][t1] = cost + d
            heappush(que, (cost + d, v, t1))
print(min(dist[N-1]))

Measured memory_bytes: 47080
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main () {
   string s;
   cin>>s;
   for(ll i=0; i < 3;i++){
    if(s[i]==s[i+1]){
        cout<<"Bad";
        return 0;
    }
   }
   cout<<"Good";
   return 0;
}


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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

    int A,B,K;
    Scd3(K,A,B);

    bool ans = false;
    Repe(i,B+1,A){
        if( i%K == 0 ) ans = true;
    }


    printf ("%s\n", ans?"OK":"NG" );

    return 0;
}



Measured memory_bytes: 3760
# -*- coding: utf-8 -*-
import sys
from decimal import *
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

N=int(input())
div=[[0]*19 for _ in range(19)]
ans=0
for _ in range(N):
    x=int(Decimal(input())*10**9)
    two,five=0,0
    while x%2==0 and two<18:
        two+=1
        x//=2
    while x%5==0 and five<18:
        five+=1
        x//=5
    ans+=div[18-two][18-five]
    for i in range(two+1):
        for j in range(five+1):
            div[i][j]+=1
print(ans)

Measured memory_bytes: 285644
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
typedef long long ll;
typedef long long unsigned int llu;
ll MOD = 1000000007;
ll INF = 1000000009;

ll m[10010];
ll a[10010];
ll b[10010];

void solve(){
  ll h,n;
  cin >> h >> n;
  vector<pair<int,int>> v;
  rep(i,n){
      cin >> a[i] >> b[i];
  }
  m[0]=0;
  for(ll i=1; i<=h; i++){
      m[i]= (i>=a[0]? m[i-a[0]]+b[0]: b[0]);
      for(ll j=1; j<n; j++){
          m[i]=min(m[i], (i>=a[j]? m[i-a[j]]+b[j]: b[j]));
      }
  }

  rep(i,h){
      //cout << m[i] << endl;
  }

  cout << m[h] << endl;
}

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


Measured memory_bytes: 384
N=int(input())
S=input()
r,g,b=0,0,0
for i in range(N):
    if S[i]=="R":
        r+=1
    elif S[i]=="G":
        g+=1
    elif S[i]=="B":
        b+=1
# j-i=k-j  2j-i-k=0 k=i-2j について調べるもしRGBなら、それをrgbからマイナスする
tmp=0
for i in range(N):
    for j in range(i+1,N):
        k=2*j-i
        if k<N and k>=0:
            if S[i]!=S[j] and S[i]!=S[k] and S[j]!=S[k]:
                tmp+=1
# print("rgb",r*g*b)
# print("tmp",tmp)
print(r*g*b-tmp)

Measured memory_bytes: 9180
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<utility>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

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

int main(){
  ll a, b;
  cin >> a >> b;
  b++;
  ll ans1=0;
  for(int i=0; (ll)1<<i<=b; i++){
    ll block=(ll)1<<(i+1);
    ll res1=b/block*(block/2), res2=max(b%block-(block/2),(ll)0);
    if((res1+res2)%2){
      ans1|=(ll)1<<i;
    }
  }
  ll ans2=0;
  for(int i=0; (ll)1<<i<=a; i++){
    ll block=(ll)1<<(i+1);
    ll res1=a/(block)*(block/2), res2=max(a%block-(block/2),(ll)0);
    if((res1+res2)%2){
      ans2|=(ll)1<<i;
    }
  }
  ll ans=ans1^ans2;
  cout << ans << endl;
  return 0;
}

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

ll a,b,n;

ll floor(ll N){
  ll fl1 = a*N/b;
  ll fl2 = N/b;
  ll sum = fl1 + a*fl2;
  return sum;
}

int main(){
  cin >>a >>b >>n;
  cout << floor(min(b-1,n)) << endl;
  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main() {
	string s, w;
	cin >> s;
	int size = s.size();
	for (int i = 0; i < size; i++) {
		if (i % 2 == 0) {
			w += s[i];
		}
	}
	cout << w << endl;
	return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <queue>

using namespace std;

int main(void) {
	int height[10];
	priority_queue<int,vector<int> > que;
	
	for(int i=0;i<10;i++){
		scanf("%d",&height[i]);
		que.push(height[i]);
	}
	for(int i=0; i<3; i++){
		printf("%d\n",que.top());
		que.pop();
	}
	
	return 0;
}

Measured memory_bytes: 1052
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <map>
#include <bitset>
#include <cmath>
#include <set>
#include <utility>
#include <sstream>

#define INF 1000000000000
#define MOD 1000000007 //10^9+7:合同式の法

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) x.begin(),x.end()
#define chmax(x,y) (x = max(x,y))
#define chmin(x,y) (x = min(x,y))

int main(){ 
    int A,B;
    cin >> A >> B;

    if(A + B >= A - B and (A + B) >= (A * B))
        cout << A + B << endl;
    else if((A - B) >= (A + B) and (A-B) >= (A*B))
        cout << A - B << endl;
    else 
        cout << A * B << endl;
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
int N;
vector<int> L;
int  main(){
  cin >> N; L.resize(2*N);
  for( int &a : L ) cin >> a;
  sort( L.begin(), L.end() );
  int res = 0;
  for(int i=0;i<2*N;i+=2){
    res += L[i];
  }
  cout << res << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<set>
#include<unordered_set>
#include<string>
#include<stack>
#include<algorithm>
#include<limits.h>
#include<stdlib.h>
#include<string.h>

using namespace std;
typedef long long ll;
const ll MAXN = 1e6+1;
ll factor[MAXN];

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

    memset(factor,0,sizeof(factor));
    for(ll i = 2; i <= MAXN; ++i){
        if(factor[i] != 0) continue;
        factor[i] = i;
        for(ll j = i*i; j < MAXN; j += i){
            if(factor[j] == 0) factor[j] = i;
        }
    }// 求所有的数的最小质因子

    unordered_set<int> exists;
    bool pairwise = true;
    ll setwise = 0;
    for(int i = 0; i < n; ++i){
        vector<ll> curFact;
        ll now = arr[i];
        while (now > 1) {
            ll sml = factor[now];
            if (curFact.empty() || curFact.back() != sml) curFact.push_back(sml);
            now /= sml;
        }//求出该数的所有不同的质因子。
        
        for (auto f: curFact) {
            if (exists.count(f)) pairwise = false;
            exists.insert(f);
        }//如果该数所有的质因子与现有的质因子集合存在交集。
        setwise = __gcd(setwise,arr[i]);
    }
    
    if(pairwise){
        cout << "pairwise coprime\n";
    }else if(setwise == 1){
        cout << "setwise coprime\n";
    }else{
        cout << "not coprime\n";
    }

}
int main(){
    slove();
}


Measured memory_bytes: 22340
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        char[] S = Console.ReadLine().ToCharArray();
        int forward = (S[0]-'0')*10+S[1]-'0';
        int backward = (S[2] - '0') * 10 + S[3] - '0';
        if (1 <= forward && forward <= 12)
        {
            if (1 <= backward && backward <= 12)
            {
                Console.WriteLine("AMBIGUOUS");
            }
            else
            {
                Console.WriteLine("MMYY");
            }
        }
        else
        {
            if (1 <= backward && backward <= 12)
            {
                Console.WriteLine("YYMM");
            }
            else
            {
                Console.WriteLine("NA");
            }
        }
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
#define REP(i, m, n) for(ll i = (ll)m; i < (ll)n; i++)
#define PER(i, m, n) for(ll i = (ll)m; i > (ll)n; i--)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
#define _GLIBCXX_DEBUG

template <uint MD> struct ModInt {
    using M = ModInt;
    const static M G;
    uint v;
    ModInt(ll _v = 0) { set_v(uint(_v % MD + MD)); }
    M& set_v(uint _v) {
        v = (_v < MD) ? _v : _v - MD;
        return *this;
    }
    explicit operator bool() const { return v != 0; }
    M operator-() const { return M() - *this; }
    M operator+(const M& r) const { return M().set_v(v + r.v); }
    M operator-(const M& r) const { return M().set_v(v + MD - r.v); }
    M operator*(const M& r) const { return M().set_v(uint(ull(v) * r.v % MD)); }
    M operator/(const M& r) const { return *this * r.inv(); }
    M& operator+=(const M& r) { return *this = *this + r; }
    M& operator-=(const M& r) { return *this = *this - r; }
    M& operator*=(const M& r) { return *this = *this * r; }
    M& operator/=(const M& r) { return *this = *this / r; }
    bool operator==(const M& r) const { return v == r.v; }
    M pow(ll n) const {
        M x = *this, r = 1;
        while (n) {
            if (n & 1) r *= x;
            x *= x;
            n >>= 1;
        }
        return r;
    }
    M inv() const { return pow(MD - 2); }
    friend ostream& operator<<(ostream& os, const M& r) { return os << r.v; }
};
using Mint = ModInt<1000000007>;

const double PI = 3.14159265358979323846;

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

bool is_prime(long long N) {
    if (N == 1) return false;
    for (long long i = 2; i * i <= N; ++i) {
        if (N % i == 0) return false;
    }
    return true;
}

int main(){
    ll n, x, t;
    cin >> n >> x >> t;
    ll ans = 0;
    ll sum = 0;

    while(n > sum || (sum+x > n && n > sum)){
        ans += t;
        sum += x;
    }

    cout << ans << endl;
}


Measured memory_bytes: 3636
#include <iostream>
#include <map>
#include <math.h>
#include <vector>
using namespace std;

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

int main(){
    int N,M;
    cin >> N >> M;
    int r= 2;
    int count=0;//素因数の数
    map<long long  ,int  > insuu;
    vector<int > prime;
    COMinit();
    //因数分解部
    int pM=M;
    while(M>1){
        if(M%r!=0){//割り切れないなら次の因数を検索
            while(true){
                if(r==2){
                    r++;
                }else{
                    r+=2;
                }
                if(M%r==0){
                    break;
                }
                if(r>sqrt(pM)){
                    prime.push_back(M);
                    insuu[M]++;
                    M=1;
                    break;
                }
            }
        }else{
            M=M/r;
            if(insuu[r]<1){
                prime.push_back(r);
            }
            count++;
            insuu[r]++;
        }   
    }
    //出力計算部
    long long ans=1;
    for(auto v :prime){
        ans*=fac[N+insuu[v]-1]*((finv[insuu[v]])*finv[N-1]%MOD)%MOD;
        ans=ans%MOD;
    }
    cout << ans << endl;
    return 0;
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define sumvec(v) accumulate(all(v),0)
#define mapmax(v) v.rbegin()->first
#define mapmin(v) v.begin()->first
#define pb push_back
#define pf push_front
#define mod 1000000007
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK puts("OK")
#define OK1 puts("OK1")
#define OK2 puts("OK2")
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n

typedef long long ll;

typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<double> vd;
typedef vector<char> vc;
typedef vector<string> vs;

typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

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

template<class T>
inline bool chmin(T& a, T b){if(a>b){a=b;return true;} return false;}

ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

struct UnionFind {
	vector<long long> par;
	UnionFind(long long size):par(size+1,-1){}
	bool unite(long long x,long long y){	//集合の連結
		x=root(x);
        y=root(y);
		if (x!=y){
			if(par[y]<par[x]) swap(x,y);
			par[x]+=par[y];
            par[y]=x;
		}
		return x!=y;
	}
	bool same(long long x,long long y){	//同集合内かの判定
		return root(x)==root(y);
	}
	int root(long long x){	//根を求める
		return par[x]<0?x:par[x]=root(par[x]);
	}
	int size(long long x){	//集合の大きさ
		return -par[root(x)];
	}
};

int main()
{
	ll n,m,ans=0;
	cin >> n >> m;
	vll a(m),b(m);
	rep(i,m) cin >> a[i] >> b[i];
	rep(i,m){
		UnionFind tree(n);
		rep(j,m){
			if(i==j) continue;
			tree.unite(a[j],b[j]);
		}
		if(tree.size(1)!=n) ans++;
	}
	cout << ans << endl;
	return 0;
}

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

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

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

int main(){
    int n, m;
    cin >> n >> m;
    vector<bool> ac(n, false);
    vector<int> cnt(n, false);
    int p;
    string s;
    for (int i = 0; i < m; i++){
        cin >> p >> s;
        p--;
        if (!ac[p]){
            if (s == "WA") cnt[p]++;
            else ac[p] = 1;
        }
    }
    long long tmp = 0;
    for (int i = 0; i < n; i++) if (ac[i]) tmp++;
    long long ans = 0;
    for (int i = 0; i < n; i++){
        if (ac[i]) ans += cnt[i];
    }
    cout << tmp << " " << ans << endl;
}

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

int main(){
    int N,K;
    int ans = 0 ;
    cin >> N >> K;
    vector<int> l(N);
    for(int i =0 ; i < N; i++){
        cin >> l[i];
    }
    sort(l.begin(),l.end(),greater<int>());

    for(int i = 0 ; i < K; i++){
        ans += l[i];
        // cout << l[i] << "\n";
    }

    cout << ans;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

	public static void main (String[] args) {

		Scanner sc = new java.util.Scanner (System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		if (a+b+c>=22) {
			System.out.println("bust");
		} else {
			System.out.println("win");
		}

	}
}

Measured memory_bytes: 21716
#include <iostream>
#include <algorithm>
#include <string>
#include <set>
#include <map>
using namespace std;
typedef long long ll;

int a, b, c, d;
int main(void) {
	
	cin >> a >> b >> c >> d;

	int cnt = min(b, d) - max(a, c);
	int ans = max(0, cnt);
	cout << ans << endl;
}

Measured memory_bytes: 256
import sys

input = sys.stdin.readline


def main():
    N = int(input())
    A = list(map(int, input().split()))

    A = [0] + A + [0]
    B = [abs(A[i + 1] - A[i]) for i in range(N + 1)]

    sum_B = sum(B)
    ans = [0] * N
    for i in range(N):
        ans[i] = sum_B - (B[i] + B[i + 1]) + abs(A[i + 2] - A[i])

    print(*ans, sep="\n")


if __name__ == "__main__":
    main()


Measured memory_bytes: 17568
import sys
input=sys.stdin.readline
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
cnt=Counter(a)
#print(cnt)

ans=0
for i in cnt.values():
    ans=ans+i*(i-1)//2

for i in a:
    print(ans-cnt[i]+1)

Measured memory_bytes: 82764
#include<bits/stdc++.h>
using namespace std;
int main(){
	int X,n,mi=10000,ans;
	cin>>X>>n;
	int p[n+1],flag[111];
	for(int i=0;i<=110;i++)flag[i]=true;
	for(int i=1;i<=n;i++){
		cin>>p[i];
		flag[p[i]]=false;
	}
	for(int i=0;i<=110;i++){
		if(!flag[i])continue;
		if(abs(i-X)<mi){
			mi=abs(i-X);
			ans=i;
		}
	} 
	cout<<ans<<endl;
	return 0;
} 

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

int main()
{
    size_t N;
    cin >> N;

    vector<long long> A(N);
    for (long long &a : A)
    {
        cin >> a;
    }

    priority_queue<pair<long long, size_t>> q;
    for (size_t i = 0; i < N; i++)
    {
        q.push(make_pair(A[i], i));
    }

    vector<vector<long long>> dp(N + 1, vector<long long>(N + 1, 0));
    for (size_t i = 0; !q.empty(); i++)
    {
        for (size_t j = 0; j <= i; j++)
        {
            dp[j + 1][i - j] = max(dp[j + 1][i - j], dp[j][i - j] + q.top().first * (long long)(q.top().second - j));
            dp[j][i - j + 1] = max(dp[j][i - j + 1], dp[j][i - j] + q.top().first * (long long)(N - 1 - (i - j) - q.top().second));
        }
        q.pop();
    }

    long long ans = 0;
    for (size_t i = 0; i <= N; i++)
    {
        ans = max(ans, dp[i][N - i]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 34652
#include <cmath>

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

#include <queue>

using namespace std;

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

int n;
int x;
int y;

vector<vi> g;
vi used;
vi d;

void bfs(int v) {
  used[v] = true;

  queue<int> q;

  q.push(v);

  while (!q.empty()) {
    int cur = q.front();

    q.pop();

    for (auto&& i : g[cur]) {
      if (!used[i]) {
        used[i] = true;

        d[i] = d[cur] + 1;

        q.push(i);
      }
    }
  }
}

void solve() {
  cin >> n >> x >> y;

  g = vector<vi>(n);
  used = vi(n);

  for (int i = 0; i < n - 1; ++i) {
    g[i].push_back(i + 1);
    g[i + 1].push_back(i);
  }

  --x;
  --y;

  g[x].push_back(y);
  g[y].push_back(x);

  for (auto&& i : g) {
    sort(i.begin(), i.end());
    i.erase(unique(i.begin(), i.end()), i.end());
  }

  vi ans(n);

  for (int i = 0; i < n - 1; ++i) {
    d = vi(n);
    used = vi(n);

    bfs(i);

    for (int j = i + 1; j < n; ++j)
      ans[d[j]]++;
  }

  for (int i = 1; i < n; ++i)
    cout << ans[i] << '\n';

  cout << '\n';
}

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

  int t = 1;

#ifdef _DEBUG
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);

  t = 4;
#endif

  while (t--)
    solve();
}

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

int root(int *u,int x){
  if(u[x]==x) return x;
  return u[x]=root(u,u[x]);
}

int same(int *u,int x,int y){
  return root(u,x)==root(u,y);
}

void unite(int *u,int x,int y){
  x=root(u,x);
  y=root(u,y);
  if(x==y) return;
  u[x]=y;
}

void run(void){
  int n,m;
  scanf("%d%d",&n,&m);
  int *u=(int *)calloc(n+m,sizeof(int));
  int i;
  for(i=0;i<n+m;i++) u[i]=i;
  for(i=0;i<n;i++){
    int k;
    scanf("%d",&k);
    while(k--){
      int l;
      scanf("%d",&l);
      unite(u,i,n+l-1);
    }
  }
  for(i=0;i+1<n;i++) if(!same(u,i,i+1)) break;
  printf("%s\n",i+1<n?"NO":"YES");
}

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


Measured memory_bytes: 1280