akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
ld d(ld x,ld xx,ld y,ld yy) {
  ld xy = (x - xx) * (x - xx) + (y - yy) * (y - yy);
  ld Left = 0;
  ld Right = xy;
  ld xxyy;
  while(true) {
    ld pivot = Left + (Right - Left) / 2;
    if (pivot * pivot < xy) Left = pivot;
    else if (pivot * pivot > xy) Right = pivot;
    else {
      xxyy = pivot;
      break;
    }
    
    if (abs(pivot * pivot - xy) < 0.00000000001) {
      xxyy = pivot;
      break;
    }
  }
  return xxyy;
  
  
}
  

int main() {
  int N;
  cin >> N;
  vector<ld> x(N),y(N);
  for (int i = 0; i < N; i++) cin >> x.at(i) >> y.at(i);
  
  ld L = 0;
  for (int i = 0; i < N-1; i++) for (int j = i+1; j < N; j++) L += d(x.at(i),x.at(j),y.at(i),y.at(j));
  
  ld ans =2.0 * L;
  ans /= N;
  
  cout << fixed << setprecision(10) << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 1000000000
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  string ans = "No";
  cin >>N;
  for(int i=0;i<=25;i++){
    if(i*4>100) break;
    for(int j = 0;j<=14;j++){
      int sum = i*4 + j*7;
      if(sum >100) break;
      if(N == sum) ans = "Yes";
    }
  }
  
  cout <<ans<<endl;
}


Measured memory_bytes: 256
x,n=map(int,input().split())
if n is 0:
    print(x)   
else:
    l=list(map(int,input().split()))
    if x not in l:
        print(x)
    else:
        for i in range(1,len(l)+1):
            if x-i not in l:
                print(x-i)
                break
            elif x+i not in l:
                print(x+i)
                break

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

typedef long long ll;

const int Maxl = 26;

string s, t;
vector <int> seq[Maxl];

int main()
{
    cin >> s;
    cin >> t;
    for (int i = 0; i < s.length(); i++)
        seq[s[i] - 'a'].push_back(i);
    int lst = -1, tims = 0;
    for (int i = 0; i < t.length(); i++) {
        int let = t[i] - 'a';
        int ind = upper_bound(seq[let].begin(), seq[let].end(), lst) - seq[let].begin();
        if (ind < seq[let].size()) lst = seq[let][ind];
        else if (seq[let].empty()) { printf("-1\n"); return 0; }
             else { tims++; lst = seq[let][0]; }
    }
    cout << ll(s.length()) * tims + ll(lst + 1) << endl;
    return 0;
}


Measured memory_bytes: 1216
#include <cstdio>
#include <iostream>
#include <vector>
#include <queue>
#include <cstring>
#include <algorithm>
#include <set>
#include <string>
using namespace std;
int l,r,d,n,k,t,m,t1,f[100000+10],x[100000+10];bool le;
int getfather(int u)
{
    int t;
    if (f[u]==u) return(u);
    t=getfather(f[u]);
    x[u]=x[u]+x[f[u]];
    f[u]=t;
    return f[u];
}
void jia(int x2,int y2,int d)
{int i,j;
    i=getfather(x2);
    j=getfather(y2);
    if(i==j)
    {
        if(x[y2]-x[x2]!=d)
        {
            le=0;
            return;
        }
    }
        f[j]=i;
        x[j]=d+x[x2]-x[y2];
}
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;++i)
        f[i]=i;
    le=1;
    for(int i=1;i<=m;++i)
    {
        scanf("%d%d%d",&l,&r,&d);
        jia(l,r,d);
        if(!le)
        {
            printf("No\n");
            return 0;
        }
    }
    printf("Yes\n");
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include<bits/stdc++.h>
#include<utility>
#include<vector>
#define ll long long 
#define fast    ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;

int main(void) {
	ll t=0,n;
	string s;
	cin>>s;
	if(s[2]==s[3]&&s[4]==s[5])
	cout<<"Yes";
	else
	cout<<"No";
	return 0;
}



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

typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(auto i=0;i<(n);i++)

using namespace std;


int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    ll n, k;
    cin >> n >> k;

    ll t = 0;
    for(ll x = k; x <= n; x += k) t++;
    ll tsum = t*t*t;
    
    ll s = 0;
    ll ssum = 0;
    if(k%2 == 0){
        ll d = k/2;
        for(ll x = d; x <= n; x += k) s++;
        ssum = s*s*s;
    }

    cout << tsum + ssum << endl;


    return 0;
}



Measured memory_bytes: 256
#define NDEBUG

#include <unordered_map>
#include <functional>
#include <algorithm>
#include <iostream>
#include <cassert>
#include <cstring>
#include <iomanip>
#include <utility>
#include <numeric>
#include <string>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <tuple>
#include <set>
#include <map>

// [0, max)
#define FOR0(var, max) for (sl (var) = 0; (var) < (max); ++(var))
// [min, max)
#define FORi(var, min, max) for (sl (var) = (min); (var) < (max); ++(var))
// [min, max)
#define FORi_INV(var, min, max) for (sl (var) = (max) - 1; (var) + 1 > (min); --(var))

#define FORITER(var, iter) for (auto (iter) = (var).begin(); (iter) != (var).end(); (iter)++)
#define FORITER_INV(var, iter) for (auto (iter) = (var).rbegin(); (iter) != (var).rend(); (iter)++)

// a < b < c
#define LTLT(a, b, c) (((a) < (b)) && ((b) < (c)))
// a <= b < c
#define LELT(a, b, c) (((a) <= (b)) && ((b) < (c)))
// a < b <= c
#define LTLE(a, b, c) (((a) < (b)) && ((b) <= (c)))
// a <= b <= c
#define LELE(a, b, c) (((a) <= (b)) && ((b) <= (c)))

#ifndef NDEBUG
#  define MASSERT(cond) m_assert(cond, __LINE__, #cond);
#else
#  define MASSERT(...)
#endif

using namespace std;

using uc = unsigned char;
using ui = unsigned int;
using ul = unsigned long long int;

using sc = signed char;
using si = signed int;
using sl = signed long long int;

using ld = long double;

void m_assert(const bool& cond, const sl& line, const char *condstr) {
  if (!cond) {
    cerr << "Assertion Failed: " << condstr << " at line " << line << endl;
    exit(1);
  }
}

static sl N;

sl traing_zeroes(sl n) {
  sl res = 0;
  for (sl i = 5; n / i >= 1; i *= 5) {
    res += n / i; // floor
  }
  return res;
}

void solve(void) {
  if (N % 2 == 1) {
    cout << 0 << endl;
    return;
  }
  cout << traing_zeroes(N / 2) << endl;
}

int main(void) {
  cin >> N;
  solve();
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

// modの最大値
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int res = 0;
        for(int i = 0; i < N; i++) {
            res += sc.nextInt();
        }
        System.out.println(res - N);
    }
}


Measured memory_bytes: 25360
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)

int main(){
  int N;
  string S, T;
  cin >> N >> S >> T;
  string A="";
  rep(i, N){
    A += S.at(i);
    A += T.at(i);
  }
  cout << A << endl;
}

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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
#define ld long double
#define ll long long

const int MOD =  1000000007;
const int IINF = INT_MAX;
const ll INF = 1LL << 60;


int main() {
    int n; cin >> n;
    V<int> x(n), y(n), h(n);
    int p = 0;
    for(int i = 0; i < n; i++){
        cin >> x[i] >> y[i] >> h[i];
        if(p == 0 && h[i]) p = i;
    }

    for(int i = 0; i <= 100; i++){
        for(int j = 0; j <= 100; j++){
            ll tmp1 = h[p] + abs(x[p] - i) + abs(y[p] - j);
            bool ok = true;
            for(int k = 0; k < n; k++){
                ll tmp2 = max(tmp1 - abs(x[k] - i) - abs(y[k] - j), 0LL);
                if (tmp2 != h[k]) {
                    ok = false;
                    break;
                }
            }
            if(ok){
                cout << i << ' ' << j << ' ' << tmp1 << endl;
                return 0;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 3636
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt"
int main() {
	int N; cin >> N;
	int K; cin >> K;
	for (int i = 0; i < K; ++i) {
		int x, y; cin >> x >> y; x--; y--;
		int dx = min(x, N -1- x);
		int dy = min(y, N - 1 - y);
		int aa = min(dx, dy);
		int ans = (aa + 1) % 3;
		if (!ans)ans += 3;
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3104
def main(s)
  max_count = 0
  s.size.times do |idx|
    pre = s[(0..idx)].split('').uniq
    suf = s[((idx + 1)..-1)].split('').uniq
    count = (pre & suf).size
    max_count = count if count > max_count
  end
  max_count
end

_ = gets.to_i
s = gets.chomp
puts main(s)

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i, a, b) for(int i = (a); i<(b); ++i)
#define rep(i, n) for (int i=0; i<(n); ++i)
#define out(x) cout << x << endl

int main(){
    int x, y, z;
    cin >> x >> y >> z;
    printf("%d %d %d", z, x, y);
}


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

int main()
{
	string s;
	cin>>s;
	int t=0;
	for(int i=0;i<s.size();i++)
	{
		int f=s[i]-'0';
		if (f==1) t++;
	}
	cout<<t<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  
  int i, n;
  
  scanf("%d", &i);
  
  n = i % 10;
  
  if(n==2 || n==4 || n==5 || n==7 || n==9){
    printf("hon\n");
  }else if(n==0 || n==1 || n==6 || n==8){
    printf("pon\n");
  }else if(n==3){
    printf("bon\n");
  }
  
  return 0;
}

Measured memory_bytes: 2088
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
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;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> l_l;
typedef pair<int,int> i_i;
const ll mod=1e9+7;
const int inf=1<<30;

ll dp[100005][13];

ll rui(ll a,ll n){
  ll ans=1;
  while(n>0){
    if(n&1) ans=ans*a%13;
    a=a*a%13;
    n/=2;
  }
  return ans;
}

int main() {
  string s; cin >> s;
  int n=s.size();
  dp[0][0]=1ll;
  rep(i,n)rep(j,13){
    if(s[i]=='?'){
      rep(d,10){
        int ni=i+1,nj=j;
        nj+=d*rui(10,n-1-i); nj%=13;
        dp[ni][nj]+=dp[i][j];
        dp[ni][nj]%=mod;
      }
    }
    else{
      int ni=i+1,nj=j;
      nj+=(s[i]-'0')*rui(10,n-1-i); nj%=13;
      dp[ni][nj]+=dp[i][j];
      dp[ni][nj]%=mod;
    }
  }
  cout << dp[n][5] << endl;
}


Measured memory_bytes: 10624
import java.util.Scanner;
 
public class Main {
	public void solve() {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		String[] strs = new String[N];
		for (int i=0; i<N; i++) {
			strs[i] = in.next();
		}
		in.close();
		
		int endACount = 0;
		int startBCount = 0;
		int doubleCount = 0;
		int middleABCount = 0;
		
		for (int i=0; i<N; i++) {
			boolean isStartB = false;
			if (strs[i].startsWith("B")) {
				startBCount++;
				isStartB = true;
			}
			if (strs[i].endsWith("A")) {
				endACount++;
				if (isStartB) {
					doubleCount++;
				}
			}
			int len = strs[i].length();
			middleABCount += (len - strs[i].replace("AB", "").length()) / 2;
		}
		
		long ret = 0;
		if (endACount == 0 || startBCount == 0) {
			
		} else if (endACount == startBCount) {
			if (doubleCount == endACount) {
				ret = endACount - 1;
			} else {
				ret = Math.min(endACount, startBCount);
			}
		} else {
			ret = Math.min(endACount, startBCount);
		}
		ret += middleABCount;
		
		System.out.println(ret);
	}
	
	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
	}
 
}


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

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; ++i) cin >> a[i];
  int q;
  cin >> q;
  while(q--) {
    int com, b, e;
    cin >> com >> b >> e;
    if(com == 0) {
      cout << *min_element(a.begin()+b, a.begin()+e) << endl;
    } else if(com == 1) {
      cout << *max_element(a.begin()+b, a.begin()+e) << endl;
    } else {
      assert(false);
    }
  }
  return 0;
}



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

////////////// Prewritten code follows. Look down for solution. ////////////////
#define x first
#define y second
#define len(x) ((int)(x).size())
using pii = pair<int, int>;
using ll = long long;
using llu = long long unsigned;
using ld = long double;

const ld EPS = 1e-9;
inline int cmp(ld x, ld y = 0, ld tol = EPS) {
	return (x <= y + tol) ? (x + tol < y) ? -1 : 0 : 1;
}

const int MOD = 1;
inline int mod (ll x, int m = MOD) {
	return (int)(((x%m) + m)%m);
}

////////////////////////// Solution starts below. //////////////////////////////

const int N = 1e5+10;

int n, m;
vector<int> adj[N];
int dp[N];

int solve (int v) {
	int &r = dp[v];
	if (r != -1) return r;
	r = 0;
	for (int u : adj[v])
		r = max (r, solve (u) + 1);
	
	return r;
}

int main () {
	memset (dp, -1, sizeof dp);
	scanf ("%d %d", &n, &m);
	while (m--) {
		int x, y;
		scanf ("%d %d", &x, &y);
		adj[x].push_back (y);
	}
	
	int ans = -1;
	for (int i = 1; i <= n; i++)
		ans = max (ans, solve (i));
	printf ("%d\n", ans);

	return 0;
}


Measured memory_bytes: 7424
def d_we_love_abc(S):
    MOD = 10**9 + 7
    dp = [[0] * 4 for _ in range(len(S)+1)]
    dp[len(S)][3] = 1  # 文字に3つ丸をつけて文字列の最後に到達した後は何もしない

    for i in range(len(S)-1, -1, -1):
        # 解説pdfにおける「1つ目の漸化式」
        m = 3 if S[i] == '?' else 1
        dp[i][3] = (m * dp[i + 1][3]) % MOD

        # 解説pdfにおける「2つ目の漸化式」
        m_1 = 3 if S[i] == '?' else 1
        m_2 = [0, 0, 0]
        for j in range(3):
            m_2[j] = 1 if S[i] == '?' or S[i] == 'ABC'[j] else 0
        for j in range(3):
            dp[i][j] = (m_1 * dp[i + 1][j] + m_2[j] * dp[i + 1][j + 1]) % MOD

    ans = dp[0][0]
    return ans

S = input().strip()
print(d_we_love_abc(S))

Measured memory_bytes: 27600
N, M = gets.split.map &:to_i
p = gets.split.map &:to_i
$array = (0...N).to_a

def proc(i)
  return i if $array[i] == i
  $array[i] = proc($array[i])
end

def procy(i, j)
  q1 = proc(i)
  q2 = proc(j)
  return if q1 == q2
  $array[q1] = q2
end

(0...M).each { i, j = gets.split.map &:to_i; procy i-1,j-1 }
count = 0
(0...N).each { |i| count += 1 if proc($array[i]) == proc($array[p[i]-1]) }

puts count

Measured memory_bytes: 11404
#pragma warning(disable: 4996)

#include <iostream>
#include <iomanip>
#include <random>
#include <unordered_map>
#include <functional>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <algorithm>
#include <vector>
#include <bitset>
#include <numeric>
#include <string>
#include <set>
#include <tuple>
#include <utility>
#include <regex>
using namespace std;

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int N, K, R, S, P;
	string T;
	cin >> N >> K >> R >> S >> P >> T;

	int ans = 0;
	for (int i = 0; i < K; ++i) {
		int sum = 0;
		char prev = 'a';
		for (int j = i; j < T.size(); j += K) {
			if (prev != T[j]) {
				if (T[j] == 'r') sum += P;
				else if (T[j] == 's') sum += R;
				else if (T[j] == 'p') sum += S;
				prev = T[j];
			}
			else {
				prev = 'a';
			}
		}
		ans += sum;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 512
<?php
list($n) = ints();
$p = [1, 1];
for ($i = 0; $i < $n; ++$i) {
    $a = ints();
    if ($a[0] >= $p[0] && $a[1] >= $p[1]) {
        $p = $a;
        continue;
    }
    $m = max(intdivceil($p[0], $a[0]), intdivceil($p[1], $a[1]));
    $p = [$a[0] * $m, $a[1] * $m];
}
echo array_sum($p);
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}
function intdivceil($a, $b)
{
    return $a % $b ? intdiv($a, $b) + 1 : intdiv($a, $b);
}


Measured memory_bytes: 5112
from heapq import*
(N,M),*t=[map(int,s.split())for s in open(0)]
q=[0]*10**5
v=[[]for _ in q]
z=0
for a,b in t:v[a-1]+=[b]
for i in v[:M]:
	for j in i:heappush(q,-j)
	z-=heappop(q)
print(z)


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

int main(){
    bool origin[50][50],copy[50][50];
    int n,m;
    cin>>n>>m;
    for(int x=0;x<n;++x){
        for(int y=0;y<n;++y){
            char ch;
            cin>>ch;
            if(ch=='#'){
             origin[y][x]=true;   
            }else{
             origin[y][x]=false;   
            }
        }
    }
    for(int x=0;x<m;++x){
        for(int y=0;y<m;++y){
            char ch;
            cin>>ch;
            if(ch=='#'){
             copy[y][x]=true;   
            }else{
             copy[y][x]=false;   
            }
        }
    }
    
    for(int x=0;x==0||x<n-m;++x){
        for(int y=0;y==0||y<n-m;++y){
            bool flag=false;
            for(int xx=0;xx<m;++xx){
                  for(int yy=0;yy<m;++yy){
                      if(origin[y+yy][x+xx]!=copy[yy][xx]){
                        flag=true;   
                      }
                      if(flag)break;
                  }
                if(flag)break;
            }
            if(!flag){
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<math.h>
#include<map>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<list>
#include<string>
#include<climits>
#define ll long long
#define mem(x) memset(x,0,sizeof(x)) 
#define inf 0x7f7f7f7f
#define io ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define pi 3.14159265358979323846
const double eps=1e-6;
using namespace std;
typedef pair<int,int> pii;
const ll mod=1e9+7;
int main()
{
	int n;
	cin>>n;
	int a[101];
	int f=0;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		if(a[i]%2==0)
		{
			if(a[i]%3&&a[i]%5)
			f=1;
		}
	}
	if(f==0)
	cout<<"APPROVED"<<endl;
	else
	cout<<"DENIED"<<endl;
} 

Measured memory_bytes: 256
N, M = map(int, input().split())

# AC = 0
# WA = 0
# PS = {}
# for i in range(M):
#     # print(PS)
#     p, S = input().split()
#     tmp = PS.get(p)
#     # if tmp != None:
#         # print("\t" + tmp)

#     if tmp != "AC":
#         if S == "AC":
#             AC += 1
#         elif S == "WA":
#             WA += 1
#         PS[p] = S

AC = [False] * N
WA = [0] * N

# print((AC))
# print(WA)

for _ in range(M):
    p, S = input().split()
    p = int(p)

    if AC[p-1] == False:
        if S == "AC":
            AC[p-1] = True
        else:
            WA[p-1] += 1
# print((AC))
# print(WA)
a = 0
w = 0
for i in range(N):
    if AC[i]:
        a += 1
        w += WA[i]

print(a, w)
    

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

using namespace std;

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

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

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

	int diffGCD = x[1] - x[0];
	for (int i = 1; i < N; i++) {
		diffGCD = __gcd(diffGCD, x[i + 1] - x[i]);
	}

	cout << diffGCD << endl;

	return 0;
}


Measured memory_bytes: 640
function main(input) {
  const args = input.split('\n');
  const [N, X] = args[0].split(' ');
  const L = args[1].split(' ');
  const n = Number(N);
  let count = 0;
  for (let i = 0; i < n + 1; i++) {
    if (X < count) {
      console.log(i)
      return;
    }
    count += Number(L[i]);
   }
  console.log(101)
  return; 
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29628
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

int main() {
  ll n;
  string s;
  cin >> n >> s;
  ll r=0,w=0;
  ll f=0;
  for(ll i=0;i<n;i++) {
    if(s[i]=='R') r++;
  }
  w=n-r;
  ll rcnt=0;
  for(ll i=0;i<r;i++) {
    if(s[i]=='W') rcnt++;
  }
  ll wcnt=0;
  for(ll i=r;i<n;i++) {
    if(s[i]=='R') wcnt++;
  }
  cout << min(wcnt,rcnt) << endl;
}

Measured memory_bytes: 3716
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;

int main(){
  int n;
  cin >> n;
  
  int nc=n, sn=0;
  for(int i=9;i>=0;i--){
    int d = nc / pow(10,i);
    nc = nc - d*pow(10,i);
    sn += d;
  }
  
  if(n%sn==0) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}

Measured memory_bytes: 384
macro_rules! read_line {
    () => {{
        let mut input = String::new();
        std::io::stdin().read_line(&mut input).unwrap();
        input
    }};
}

fn read_parse<T: std::str::FromStr>() -> T {
    read_line!().trim().parse().ok().unwrap()
}

fn main() {
    let a: i32 = read_parse();
    let b: i32 = read_parse();
    let h: i32 = read_parse();

    println!("{}", (a + b) * h / 2)
}

Measured memory_bytes: 4352
N = int(input())
mod = 10 ** 9 + 7
memo = [{} for _ in range(N + 1)]

def ok(last4):
    for i in range(4):
        t = list(last4)
        if i >= 1:
            t[i - 1], t[i] = t[i], t[i - 1]
        if ''.join(t).count("AGC") >= 1:
            return False
    return True


def dfs(cur, last3):
    if last3 in memo[cur]:
        return memo[cur][last3]
    if cur == N:
        return 1
    ret = 0
    for c in 'ACGT':
        if ok(last3 + c):
            ret = (ret + dfs(cur + 1, last3[1:] + c)) % mod
    memo[cur][last3] = ret
    return ret

print(dfs(0, 'TTT'))

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

int main () {
  int a , b ;
  cin >> a >> b ;
  
  vector<int> line(13) ;
  line = {0,1,3,1,2,1,2,1,1,2,1,2,1} ;
  
  if ( line.at(a) == line.at(b) ) {
    cout << "Yes" << endl ;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ld;
#define f0(i,a,b) for(int i=a;i<b;i++)
#define f1(i,a,b) for(int i=a;i<=b;i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define mod 1000000007

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

    int n,m;
    cin>>n>>m;

    if(m==n) cout<<"Yes";
    else cout<<"No";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (ll)(n); i++)
#define fs first
#define sc second

const ll inf = 1000000000000ll;

// 1次元vectorの出力
template <class S>
void print(vector<S> &v) {
  for (ll i = 0; i < (ll)v.size(); i++) {
    cerr << v[i] << ' ';
  }
  cerr << endl;
}

// 2次元vectorの出力
template <class S>
void print(vector<vector<S>> &v) {
  for (ll i = 0; i < (ll)v.size(); i++) {
    for (ll j = 0; j < (ll)v[i].size(); j++) {
      cerr << v[i][j] << ' ';
    }
    cerr << endl;
  }
}

int v2n(vector<int> &v){
	int res = 0;
	for(int i : v){
		res |= (1 << i);
	}
	return res;
}

int main(void) {
	int n,m;
	cin >>  n >> m;
	vector<pair<int, int>> keys;
	int a,b,c;
	rep(i,m){
		cin >> a >> b;
		vector<int> tmp(b);
		rep(j,b){
			cin >> c;
			tmp[j] = c-1;
		}
		keys.push_back(make_pair(a, v2n(tmp)));
	}
	vector<vector<ll>> dp(m+1, vector<ll>(1<<n, inf));
	dp[0][0] = 0;
	// dp[i][j] = i番目までの鍵を使ってjの宝箱を開けるのに必要な最小費用
	
	rep(i, m){
		rep(j, 1 << n){
			dp[i+1][j] = min(dp[i][(~keys[i].sc) & j] + keys[i].fs, dp[i][j]);
		}
	}
	if(dp[m][(1 << n)-1] == inf) cout << "-1\n";
	else cout << dp[m][(1 << n)-1] << endl;
	//print(dp);
}

Measured memory_bytes: 32384
void main()
{
    long n, m, k;
    rdVals(n, m, k);

    auto uf = UnionFind(n);
    long[] a = new long[m], b = new long[m];
    foreach (i; 0 .. m)
    {
        rdVals(a[i], b[i]);
        --a[i], --b[i];
        uf.unite(a[i], b[i]);
    }

    long[] c = new long[k], d = new long[k];
    foreach (i; 0 .. k)
    {
        rdVals(c[i], d[i]);
        --c[i], --d[i];
    }

    long[] result = new long[n];
    foreach (i; 0 .. n)
    {
        result[i] = uf.size(uf.root(i)) - 1;
    }
    foreach (x, y; zip(a, b))
    {
        if (uf.same(x, y))
        {
            --result[x], --result[y];
        }
    }
    foreach (x, y; zip(c, d))
    {
        if (uf.same(x, y))
        {
            --result[x], --result[y];
        }
    }

    foreach (i, x; result)
    {
        x.write;
        if (i == n - 1) writeln;
        else " ".write;
    }
}

struct UnionFind
{
    long[] par, cnt;

    this(long n)
    {
        par.length = n, cnt.length = n;
        foreach (i; 0 .. n)
        {
            par[i] = i;
        }
        cnt[] = 1L;
    }

    long root(long x)
    {
        if (par[x] == x) return x;
        else return par[x] = root(par[x]);
    }

    bool same(long x, long y)
    {
        return root(x) == root(y);
    }

    void unite(long x, long y)
    {
        x = root(x), y = root(y);
        if (x == y) return;
        if (cnt[x] > cnt[y]) swap(x, y);
        cnt[y] += cnt[x];
        par[x] = y;
    }

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

enum long mod = 10^^9 + 7;
enum long inf = 1L << 60;

T rdElem(T = long)()
if (!is(T == struct))
{
    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);

T rdElem(T)()
if (is(T == struct))
{
    T result;
    string[] input = rdRow!string;
    assert(T.tupleof.length == input.length);
    foreach (i, ref x; result.tupleof)
    {
        x = input[i].to!(typeof(x));
    }
    return result;
}

T[] rdRow(T = long)()
{
    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    return iota(col).map!(x => rdRow!T).array;
}

void rdVals(T...)(ref T data)
{
    string[] input = rdRow!string;
    assert(data.length == input.length);
    foreach (i, ref x; data)
    {
        x = input[i].to!(typeof(x));
    }
}

void wrMat(T = long)(T[][] mat)
{
    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.traits;
import std.container;
import std.functional;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 8444
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>
#include <cstring>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
signed main() {
    int N, A, B;
    cin >> N >> A >> B;
    cout << min(A * N, B) << endl;
    return 0;
}

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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef pair<int, int> pi;

int n;

const int maxn = 1e5 + 5;

int L[maxn], R[maxn], tot;
int sz[maxn];

vector<pi> G[maxn];

int edge[maxn];

void dfs(int u, int fa){
    sz[u] = 1;
    L[u] = ++tot;
    for(auto p : G[u]){
        if(p.fi == fa){
            edge[u] = p.se;  
            continue;
        }
        dfs(p.fi, u);
        sz[u] += sz[p.fi];
    }
    R[u] = tot;
}

ll pre[maxn];

int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    memset(edge, -1, sizeof(edge));
    cin >> n;
    for(int i = 1;i < n;i++){
        int a, b, c;
        cin >> a >> b >> c;
        G[a].eb(b, c);
        G[b].eb(a, c);
    }
    dfs(1, 1);
    ll sum = 0;
    for(int i = 2;i <= n;i++){
        int sz1 = n - sz[i];
        if(sz[i] == sz1){
            sum += (2LL * sz[i] - 1) * edge[i];
        }
        if(sz[i] < sz1){
            sum += 2LL * sz[i] * edge[i];
            pre[L[i]] += -edge[i];
            pre[R[i] + 1] += edge[i];
        }
        if(sz[i] > sz1){
            sum += 2LL * sz1 * edge[i];
            pre[1] += -edge[i];
            pre[L[i]] += edge[i];
            pre[R[i] + 1] += -edge[i];
            pre[n + 1] += edge[i];
        }
    }
    priority_queue<ll> pq;
    ll cur = 0;
    for(int i = 1;i <= n;i++){
        cur += pre[i];
        pq.push(cur);
    }
    //cout << sum << endl;
    sum += pq.top();
    pq.pop();
    sum += pq.top();
    cout << sum << endl;
    return 0;
}


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


using namespace std;

#define ll long long

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

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

#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define for1(i, n) for (int i = 1; i <= int(n); ++i)
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
#define pb push_back

using namespace std;
using ll=long long;
using pii= pair<int, int>;
mt19937 gen(chrono::steady_clock::now().time_since_epoch().count());
template<typename... T> void rd(T&... args) {((cin>>args), ...);}
template<typename... T> void wr(T... args) {((cout<<args<<" "), ...);cout<<endl;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int x;
    cin>>x;
    cout<<(x+999)/1000*1000-x;
    return 0;
}



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

int h, w, mn = INF, mx = 0, a[2000][2000];
bool ok(int t) {
	int prv = 0;
	rep(i, h) {
		int j;
		for (j = w - 1; j >= prv && a[i][j] <= mn + t; j--); j++;
		for (int k = 0; k < j; k++) {
			if (a[i][k] < mx - t)return false;
		}
		prv = j;
	}
	return true;
}
int main() {
	scanf("%d%d", &h, &w);
	rep(i, h)rep(j, w) {
		scanf("%d", &a[i][j]);
		mn = min(mn, a[i][j]); mx = max(mx, a[i][j]);
	}
	int l = 0, r = INF;
	while (l != r) {
		int t = (l + r) / 2;
		rep(k, 4) {
			if (k & 1)rep(i, h)rep(j,w/2)swap(a[i][j], a[i][w - j - 1]);
			else rep(i, w)rep(j,h/2)swap(a[j][i], a[h - j - 1][i]);
			if (ok(t)) {
				r = t; goto g;
			}
		}
		l = t + 1;
		g:;
	}
	printf("%d\n", l);
}

Measured memory_bytes: 18836
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 2019
#define INF 10000000000000LL

int main(){
  ll l,r;
  cin>>l>>r;
  ll ans=INF;
  for(ll i=l;i<=min(r,l+mod);i++){
    for(ll j=i+1;j<=min(r,i+1+mod);j++){
      ans=min(ans,(i*j)%mod);
    }
  }
  cout<<ans<<endl;
  return(0);
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <string>
#include <math.h>
#include <iomanip>


#define rep(i,n) for(int i=0; i< (n); ++i)

using namespace std;

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

  int sum = 0;
  vector<int> A(N), C(N - 1);
  for (int i = 0; i < N; ++i) cin >> A[i];
  for (int i = 0; i < N; ++i)
  {
    int B;
    cin >> B;
    sum += B;
  }
  for (int i = 0; i < N - 1; ++i) cin >> C[i];

  for (int i = 0; i < N - 1; ++i)
  {
    if (A[i + 1] == A[i] + 1)
    {
      sum += C[A[i]-1];
    }
  }

  cout << sum << endl;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll a, b, c;
  cin >> a >> b >> c;
  cout << a * b / 2 << endl;
}

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

using namespace std;
#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__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

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

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

int n;
string s;

ll solve(int k){

  ll cnt_d = 0;
  ll cnt_m = 0;
  ll cnt_dm = 0;
  ll ret = 0;
  rep(i, n){
    
    // 1
    if(i - k >= 0){
      if(s[i-k]=='D'){
        cnt_d--;
        cnt_dm -= cnt_m;
      }
      if(s[i-k]=='M'){
        cnt_m--;
      }
    }

    // 2
    if(s[i] == 'D'){
      cnt_d++;
    }
    if(s[i]=='M'){
      cnt_m++;
      cnt_dm += cnt_d;
    }

    if(s[i]=='C'){
      ret += cnt_dm;
    }
  }

  return ret;

}

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

  cin >> n >> s;

  int Q;
  cin >> Q;
  vector<ll> ans(Q);

  rep(q, Q){
    int k;
    cin >> k;
    ans[q] = solve(k);

  }

  rep(q, Q){
    cout << ans[q] << endl;
  }

  return 0;
}


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


int main(){
  int n,k;
  cin >> n >> k;
  string s;
  cin >> s;
  vector<int> num;
  if(s[0]=='0') num.push_back(0);
  for(int i=0;i<n;){
    int ren=i;
    while(ren<n && s[i]==s[ren]) ++ren;
    num.push_back(ren-i);
    i=ren;
  }
  if(s.back()=='0') num.push_back(0);

  vector<int> ruisekiwa((int)num.size()+1,0);
  for(int i=0;i<(int)num.size();i++){
    ruisekiwa[i+1]=ruisekiwa[i]+num[i];
  }
  int ans=0;
  for(int i=0;i<(int)ruisekiwa.size();i+=2){
    int j=i+k*2+1;
    if(j>=(int)ruisekiwa.size()) j=(int)ruisekiwa.size()-1;
    ans=max(ans,ruisekiwa[j]-ruisekiwa[i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4224
#include<iostream>
#include<string>
#include<utility>
#include<cctype>
#include<algorithm>

using namespace std;

pair<int, int> parse(const string& s, int& idx, int lower, int upper) {
    int endIdx = s.size();
    if (isdigit(s[idx])) {
        int v = s[idx]-'0';
        ++idx;
        int l = v;
        int r = (v==0 ? 0 : 10*v+9);
        if (r <= lower || upper <= l) {
            endIdx = idx;
        }
        if (isdigit(s[idx])) {
            v = v*10 + (s[idx++]-'0');
            endIdx = min(endIdx, idx);
            ++idx;
        } else {
            ++idx;
            endIdx = min(endIdx, idx);
        }
        return make_pair(v, endIdx);
    }
    bool isMin = (s[idx] == '_');
    idx += 2;
    pair<int, int> vl = parse(s, idx, lower, upper);
    if (isMin) upper = min(upper, vl.first);
    else lower = max(lower, vl.first);
    if (upper <= lower) endIdx = vl.second;
    while (!isdigit(s[idx]) && s[idx] != '_' && s[idx] != '^')
        ++idx;
    pair<int, int> vr = parse(s, idx, lower, upper);
    endIdx = min(endIdx, vr.second);
    if (isMin) return make_pair(min(vl.first, vr.first), endIdx);
    else return make_pair(max(vl.first, vr.first), endIdx);
}

int main() {
    int T;
    cin >> T;
    while (T--) {
        string s;
        cin >> s;
        int idx = 0;
        auto ret = parse(s, idx, 0, 99);
        cout << ret.first << " " << ret.second << endl;
    }
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = System.Console.ReadLine().Split(' ');
            int A = int.Parse(input[0]), B = int.Parse(input[1]), AB = int.Parse(input[2]), _A = int.Parse(input[3]), _B = int.Parse(input[4]);
            int min;
            if (_A < _B) {
                min = _A;
                }
            else {
                min = _B;
            }
            int ary = 0;
            if (A + B >= 2 * AB) ary += (2 * AB) * min;
            else ary += ( A  + B) * min ;
            if (_A > _B)
            {
                if (A < 2 * AB) ary += A * (_A - min);
                else ary += (2 * AB) * (_A - min);
            }
            else
            {
                if (B < 2 * AB) ary += B * (_B - min);
                else ary += (2 * AB) * (_B - min);
            }
            System.Console.WriteLine(ary);
        }
    }
}

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

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

  ll N; cin >> N;
  ll ans = 0;
  vector<ll> A(N);
  vector<ll> cnt(100005, 0);
  for (ll i = 0; i < N; i++) {
    cin >> A[i];
    ans += A[i];
    cnt[A[i]]++;
  }

  ll Q; cin >> Q;
  for (ll i = 0; i < Q; i++) {
    ll b, c;
    cin >> b >> c;

    ll temp = cnt[b];
    ans += (c - b) * temp;
    cout << ans << '\n';
    cnt[b] = 0;
    cnt[c] += temp;
  }
  return 0;
}

Measured memory_bytes: 4704
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())


int n;
int a[16][16];
long long dp[1 << 16];



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

	cin >> n;
	rep(i, n)rep(j, n)cin >> a[i][j];

	rep(i, 1 << 16)dp[i] = -(1LL << 60);
	dp[0] = 0;

	for (int i = 1; i < (1 << n); i++) {
		long long s = 0;
		rep(j, n)rep(k, n)if ((i >> j & 1) && (i >> k & 1)) {
			s += a[j][k];
		}
		dp[i] = s / 2;

		for (int j = i;; j = (j - 1)&i) {
			dp[i] = max(dp[i], dp[i&~j] + dp[j]);
			if (j == 0)break;
		}
	}
	cout << dp[(1 << n) - 1] << endl;



	return 0;
}


Measured memory_bytes: 768
N, M, C = map(int, input().split())
B = list(map(int, input().split()))

ans = 0
for i in range(N):
    A = list(map(int, input().split()))
    if sum(map(lambda x: x[0]*x[1], zip(A, B))) + C > 0:
        ans += 1
print(ans)


Measured memory_bytes: 3060
import math
a, b, x = map(int, input().split())

if a*a*b == x:
    print(0)
elif a*a*b <= 2*x:
    print(90-math.degrees(math.atan(a*a*a/(2*a*a*b-2*x))))
else:
    print(90-math.degrees(math.atan(2*x/(a*b*b))))


Measured memory_bytes: 38256
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MP make_pair
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define PLI pair<ll, int>
#define PIL pair<int, ll>
#define STR string
#define Fst first
#define Snd second
#define SHN 1e9
#define LSHN 1e18
using namespace std;
string s;
int main()
{
	cin >>s;
	for (int i=0;i<s.size();i++) cout <<"x";
	return 0;
}

Measured memory_bytes: 384
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define ll long long
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
const int N = 1e5 + 5, M = 2 * N + 5;


int main(){
    ll a, b;
    scanf("%lld%lld", &a, &b);
    ll g = __gcd(a, b);
    int ans = 1;
    for(ll i = 2 ; i * i <= g ; ++i){
        if(g % i)continue;
        int cnt = 0;
        while(g % i == 0)g /= i;
        ++ans;
    }
    if(g > 1)++ans;
    printf("%d\n", ans);
}

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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

int main()
{
    int n, k; cin >> n >> k;
    vector<int> p(n);
    rep(i,n) cin >> p[i];
    sort(p.begin(), p.end());

    int sum = 0;
    rep(i,k){
        sum += p[i];
    }

    cout << sum << endl;
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;
#include "atcoder/all"

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

template<class T, class F>
struct SegmentTree {
    F f;
    T ti;
    vector<T> dat;
    int sz;

    SegmentTree(const F &f, const T &ti) : f(f), ti(ti) {}

    void build(const vector<T> &v) {
        assert(v.size());
        sz = 1;
        while (sz < v.size())sz <<= 1;
        dat.resize(sz << 1, ti);
        for (int i = 0; i < v.size(); i++)dat[sz - 1 + i] = v[i];
        for (int i = sz - 2; i >= 0; i--)dat[i] = f(dat[i * 2 + 1], dat[i * 2 + 2]);
    }

    inline void update(int k, T x) {
        k += sz - 1;
        dat[k] = x;
        while (k) {
            k = (k - 1) / 2;
            dat[k] = f(dat[k * 2 + 1], dat[k * 2 + 2]);
        }
    }

    inline void add(int k, int x) {
        k += sz - 1;
        dat[k] = f(dat[k], x);
        while (k) {
            k = (k - 1) / 2;
            dat[k] = f(dat[k * 2 + 1], dat[k * 2 + 2]);
        }
    }

    inline T query(int a, int b) {
        return query(a, b, 0, 0, sz);
    }

    T query(int a, int b, int k, int l, int r) {
        if (r <= a || b <= l)return ti;
        if (a <= l && r <= b)return dat[k];
        return f(query(a, b, k * 2 + 1, l, (l + r) / 2), query(a, b, k * 2 + 2, (l + r) / 2, r));
    }
};

int MAX = 300000 + 100;

int main() {

    auto f = [](ll i, ll j) { return max(i, j); };
    SegmentTree<ll, decltype(f)> segmentTree(f, -INF);
    segmentTree.build(vector<ll>(MAX, -INF));

    int n, k;
    cin >> n >> k;
    vector<ll> v(n);
    rep(i, n) cin >> v[i];

    vector<ll> dp(n);

    rep(i, n) {
        ll c = v[i];
        ll d = max<ll>(c - k, 0);
        ll u = min<ll>(c + k, MAX);
        ll ma = segmentTree.query(d, u + 1);
        if (ma == -INF) dp[i] = 1;
        else {
            dp[i] = ma + 1;
        }

        segmentTree.update(v[i], dp[i]);
    }

    ll ans = *max_element(dp.begin(), dp.end());
    cout << ans << endl;

}


Measured memory_bytes: 16120
#include<bits/stdc++.h>
using namespace std;
long long int a[4],uc;
int main(){
    cin>>a[0]>>a[1]>>a[2];
    
    while(a[0]!=a[1]||a[0]!=a[2]){
        sort(a,a+3);
        if(a[0]<a[2]-1){a[0]+=2;}
        else if(a[1]==a[2]){a[1]++;a[2]++;}
        else if(a[0]==a[1]){a[0]++;a[1]++;}
        uc++;
        if(a[0]==a[1]&&a[0]==a[2])break;
    }
    cout<<uc;

}


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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define fst first
#define snd second
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define EPS (1e-9)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }

const string YES = "";
const string NO  = "";

typedef long long ll;



long long extgcd(long long a,long long b,long long& x,long long& y)
{
  long long d = a;
  if(b != 0){
    d = extgcd(b,a%b,y,x);
    y -= (a/b)*x;
  }
  else
    x = 1,y = 0;
  return d;
}

long long mod_inv(long long a,long long m)
{
  long long x,y;
  extgcd(a,m,x,y);
  return (m+x%m)%m;
}

ll modmultiply(ll a,ll b,ll c) {
  ll x = 0,y = a%c; 
  while(b > 0) {
    if(b%2 == 1) x = (x+y)%c; 
    y = (y*2)%c;
    b /= 2; 
  }
  return x%c;
}

ll modpow(ll x, ll y, ll mod) {
  ll ret = 1;// ret = x^y%mod;
  while(y) {
    if(y&1)
      //ret = (ret*x)%mod;
      ret = modmultiply(ret, x, mod);
    //x = (x*x)%mod;
    x = modmultiply(x, x, mod);
    y >>= 1;
  }
  return ret;
}

const ll mod = 1000000007LL;

const int MAXnCk = 400001;
ll fact[MAXnCk+1], fact_inv[MAXnCk+1];
void init_nCk(){
  fact[0] = fact_inv[0] = 1;
  REP(i,1,MAXnCk+1) {
    fact[i] = fact[i-1] * (ll)i % mod;
    fact_inv[i] = mod_inv(fact[i],mod);
  }
}

ll nCk(ll n,ll k){
  if( n < 0 || k < 0 || k > n ) return 0LL;
  if( n-k < k ) k = n-k;
  return fact_inv[k] * fact[n] % mod * fact_inv[n-k] % mod;
}

ll mynCk(ll n,ll k) {
  ll ret = 1;
  rep(i,k) {
    ll v = n - i;
    ret = ( ret * v ) % mod;
  }
  REP(i,1,k+1) {
    ret = ( ret * mod_inv(i,mod) ) % mod;
  }  
  return ret;
}

int main() {
  init_nCk();
  ll n,a,b;
  cin >> n >> a >> b;
  ll ans = modpow(2,n, mod) - 1LL;
  //cout << nCk(n,2) << " = " << mynCk(n,2) << endl;
  while( ans < 0 ) ans += mod;
  ans %= mod;
  ans -= mynCk(n,a);
  while( ans < 0 ) ans += mod;
  ans %= mod;
  ans -= mynCk(n,b);
  while( ans < 0 ) ans += mod;
  ans %= mod;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 6528
// package app;

import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.Stream;

public class Main {

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

        // final String N = sc.next();

        final int N = sc.nextInt();
        final int t = sc.nextInt();
        // final int N = sc.nextInt();
        // final int D = sc.nextInt();
        // System.out.println();

        System.out.println(Math.max(N - t, 0));

        // System.out.println(A <= X && A + B >= X ? "YES" : "NO");

    }
}

Measured memory_bytes: 21844
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
int main() {
  int a,b;
  cin >> a >> b;
  int b2 = b*2;
  int ans = 0;
  if(a>b2){
    ans = a-b2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
from fractions import gcd

n=int(input())
a=list(map(int,input().split()))
mod=10**9+7

'''
lcm=1
for i in a:
 lcm=(lcm*i)//gcd(lcm,i)
'''

'''
ans=0
mod=10**9+7
for i in a:
 ans+=lcm//i
 ans%=mod
print(ans)

'''
'''
from functools import reduce
lcm=reduce(lambda x,y :(x*y)//gcd(x,y),a)
'''
from functools import reduce
lcm=reduce(lambda x,y :x*(y//gcd(x,y)),a)

'''
ans=0
mod=10**9+7
for i in a:
 ans+=lcm//i
 ans%=mod
'''
ans=sum(lcm//i for i in a)
ans%=mod
print(ans)

Measured memory_bytes: 6140