akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const int MOD = 1000000007;
ll gcd(ll x, ll y){
  if(y==0)return x;
  else return gcd(y,x%y);
}
int main() {
  int n;
  cin >> n;
  vector<ll>A(n);
  vector<ll>L(n+1);
  vector<ll>R(n+1);
  L[0]=0;
  R[n]=0;
  rep(i,n){
    cin >> A[i];
    L[i+1]=gcd(L[i],A[i]);
  }
  rep(i,n){
    R[n-1-i]=gcd(R[n-i],A[n-1-i]);
  }
  vector<ll>ans;
  rep(i,n){
    ans.push_back(gcd(L[i],R[i+1]));
  }
  sort(ans.begin(),ans.end(),greater<ll>());
  cout << ans[0] << endl;
  
}

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


long long N, K;
vector<long long> p;

int main(){
	cin >> N >> K;
	for(long long i = 0; i < N; i++){
		long long tmp;
		cin >> tmp;
		p.push_back(tmp);
	}
	sort(p.begin(), p.end());

	long long ans = 0;
	for(long long i = 0; i < K; i++){
		ans += p[i];
	}
	cout << ans << endl;

}


Measured memory_bytes: 3576
#include <iostream>

using namespace std;

long long solve(long long t){
    if(t <= 0) return 0;
    long long s = (t/4)*4;
    long long res = 0;
    for(auto i=s;i<=t;i++) res ^= i;
    return res;
}

int main(){
    long long A, B;
    while(cin >> A >> B){
        cout << (solve(B)^solve(A-1)) << endl;
    }
}

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

int main() {
  int N;
  cin >> N;
  vector <long long> L(N+1);
  L[0] = 2;
  L[1] = 1;
  for (int i = 2;i <= N; i++)
  L[i] = L[i-1]+ L[i-2];
  cout << L[N] << endl;
}

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

int main() {
    int n;
    cin >> n;
    vector<ll> a(n);for(int i=0;i<n;i++) cin >> a[i];
    ll ans=0;
    ll top=a[0];
    for(int i = 1; i < n; i++) {
        if(a[i]<top){
            ans += top-a[i];
        }
        else{
            top=a[i];
        }
    }
    cout << ans << endl;


    return 0;
}

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

int main() {
    ll h, w; cin >> h >> w;
    vector<string> a(h);
    rep (i, h) {
        cin >> a[i];
    }
    vector<vector<int>> dist(h, vector<int>(w, -1));
    vector<pair<int, int>> que;

    rep (i, h) {
        rep (j, w) {
            if (a[i][j] == '#') {
                que.emplace_back(i, j);
                dist[i][j] = 0;
            }
        }
    }
    int dx[] = {0, -1, 1, 0};
    int dy[] = {-1, 0, 0, 1};
    int ans = 0;
    rep (i, que.size()) {
        rep (j, 4) {
            int nx = que[i].first + dx[j];
            int ny = que[i].second + dy[j];

            if (nx >= 0 && ny >= 0  && nx < h && ny < w && dist[nx][ny] == -1) {
                que.emplace_back(nx, ny);
                // 進んだ分に1足す
                dist[nx][ny] = dist[que[i].first][que[i].second] + 1;
            }
        }
    }

    cout << dist[que.back().first][que.back().second] << endl;
}


Measured memory_bytes: 15340
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b;
  cin>>a>>b;
  vector<int>v1(a);
  for(int i=0;i<b;i++){
    int d;
    cin>>d;
    for(int j=0;j<d;j++){
      int k;
      cin>>k;
      if(v1.at(k-1)==0){
        v1.at(k-1)++;
      }
    }
  }
    int count=0;
    for(int l=0;l<a;l++){
      count+=v1.at(l);
    }
    cout<<a-count<<endl;
  }
      

Measured memory_bytes: 3632
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-12;

//int N, M, K, T, H, W, L, R;
long long int N, M, K, T, H, W, L, R;



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

	cin >> N;
	string s;
	cin >> s;
	int l = -1, r = -1;
	for (int i = 0; i < N; i++) {
		if (s[i] == '>') {
			l = i;
			break;
		}
	}
	for (int i = 0; i < N; i++) {
		if (s[i] == '<') {
			r = i;
		}
	}
	if (l == -1 || r == -1) {
		cout << N << endl;
	}
	else if (l == 0 && r + 1 == N) {
		cout << N << endl;
	}
	else {
		cout << r - l + 1 + max(l, (int)N - 1 - r) << endl;
	}
}


Measured memory_bytes: 3364
def divG(n) -> list:
    if n == 0:
        return [0]
    i = 1
    table = set()
    while i * i <= n:
        if n % i == 0:
            table |= {(n // i - 1) * (i < n // i - 1)}
        i += 1
    return table
print(sum(divG(int(input()))))

Measured memory_bytes: 65320
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
long long a[1001][4];
bool cmp(long long p,long long q) {
    return p > q;
}
int main() {
    int n,m,i,j,k;
    scanf("%d%d",&n,&m);
    for (i = 0;i < n;i ++) {
        for (j = 0;j < 3;j ++)
            cin>>a[i][j];
    }
    long long ans = -1;
    for (i = 0;i < 8;i ++) {
        long long f[100010];
        for (j = 0;j < n;j ++) {
            long long sum = 0;
            for (k = 0;k < 3;k ++) {
                if(i >> k & 1)sum += a[j][k];
                else sum -= a[j][k];
            }
            f[j] = sum;
        }
        sort(f,f + n,cmp);
        long long s = 0;
        for (j = 0;j < m;j ++)s += f[j];
        ans = max(s,ans);
    }
    cout<<ans;
    return 0;
}


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

using namespace std;

int main(void)
{
	int n;
	float ans=0;

	cin>>n;
	float x[n];
	string u[n];

	for(int i=0;i<n;i++){
		cin>>x[i];
		cin>>u[i];
		if(u[i]=="JPY") ans+=x[i];
		else if(u[i]=="BTC") ans+=(x[i]*380000.0);
	}

	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll d1[4] = {1, -1, 0, 0};
ll d2[4] = {0, 0, 1, -1};

int main(){
    ll n;
    cin >> n;
    string ans;
    while(n > 0){
        n--;
        ans.push_back('a'+(n%26));
        n /= 26;
    }
    reverse(ALL(ans));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3496
def main():
    n = [int(i) for i in input().split()]
    bridge = set()
    counter = 0
    reqs = [[int(j) for j in input().split()] for i in range(n[1])]
    reqs.sort(key=lambda x:(x[0],x[1]))
    
    preset = 0
    for i in range(1, n[0]+1):
        if i in bridge:
            bridge.clear()
            counter += 1
        for j in range(preset, len(reqs)):
            if reqs[j][0] == i:
                bridge.add(reqs[j][1])
            else:
                preset = j
                break
    
    print(counter)

main()


Measured memory_bytes: 69976
from heapq import heappush, heappop
import sys
input = sys.stdin.readline

h, w, k = map(int, input().split())
x1, y1, x2, y2 = map(int, input().split())
x1 -= 1
y1 -= 1
x2 -= 1
y2 -= 1
c_ = [tuple(input()) for _ in range(h)]
c = [[False] * w for _ in range(h)]
for i in range(h):
    for j in range(w):
        if c_[i][j] == '@':
            c[i][j] = True
# print(x1, y1)
# print(x2, y2)

dx = [+1, 0, -1, 0]
dy = [0, +1, 0, -1]
MAX = 10**7


def convert(x, y, d):
    return (x * w + y) * 4 + d


# dp = [[[(MAX, MAX)] * 4 for _ in range(w)] for _ in range(h)]
dp = [MAX * (k + 1) + k] * (h * w * 4)

# q = [((1, 0, x1, y1, i)) for i in range(4)]
q = [((k + 1, convert(x1, y1, i))) for i in range(4)]

while q:
    c0, xyd = heappop(q)
    c1 = c0 // (k + 1)
    c2 = c0 % (k + 1)
    # print(x, y, d, c1, c2)
    d = xyd % 4
    y = (xyd // 4) % w
    x = (xyd // 4) // w
    if c1 > dp[xyd] // (k + 1):
        continue
    for i in range(4):
        nx = x + dx[i]
        ny = y + dy[i]
        nxyi = convert(nx, ny, i)
        if nx < 0 or nx >= h or ny < 0 or ny >= w:
            continue
        if c[nx][ny]:
            continue
        if i == d and c2 < k:
            if dp[nxyi] > c1 * (k + 1) + c2 + 1:
                dp[nxyi] = c1 * (k + 1) + c2 + 1
                heappush(q, (dp[nxyi], nxyi))
        else:
            if dp[nxyi] > (c1 + 1) * (k + 1) + 1:
                dp[nxyi] = (c1 + 1) * (k + 1) + 1
                heappush(q, (dp[nxyi], nxyi))

ans = min(dp[convert(x2, y2, i)] // (k + 1) for i in range(4))
if ans == MAX:
    ans = -1
print(ans)


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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};



int main()
{
    string a,b,c;
    cin>>a>>b>>c;
    if(a[a.size()-1]==b[0] && b[b.size()-1]==c[0])
    {
        cout<<"YES"<<endl;
    }
    else cout<<"NO"<<endl;

    return 0;
}

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

int main() {
  
  int64_t x, y; cin >> x >> y;
  
  if (0 < x && 0 < y) {
    if (x < y) cout << y - x << endl;
    else cout << abs(y - x) + 2 << endl;
  }
  
  if (x == 0) {
    if (x < y) cout << y << endl;
    else cout << abs(y) + 1 << endl;
  }
  
  if (y == 0) {
    if (x < y) cout << abs(x) << endl;
    else cout << x + 1 << endl;
  }
  
  if (x < 0 && y < 0) {
    if (x < y) cout << y - x << endl;
    else cout << abs(y) - abs(x) + 2 << endl;
  }
  
  if (x < 0 && 0 < y) {
    cout << min(abs(x) + abs(y), abs(abs(y) - abs(x)) + 1) << endl;
  }
  
  if (y < 0 && 0 < x) {
    cout << abs(abs(y) - abs(x)) + 1 << endl;
  }
  
}

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

int main() {
    int64_t n, p;
    cin >> n >> p;
    string s;
    cin >> s;
    if(p == 2 || p == 5){
        int64_t ans = 0;
        for(int i = 0; i < n; i++){
            int x = s[n-1-i] - '0';
            if(x % p == 0) ans += (n - i);
        }
        cout << ans << endl;
        return 0;
    }
    vector<int64_t> d(n+1), r(p);
    r[0] = 1;
    int64_t ten = 1;
    for(int64_t i = 0; i < n; i++){
        int64_t x = s[n-1-i] - '0';
        d[i+1] = (d[i] + ten * x) % p;
        ten = ten * 10 % p;
        r[d[i+1]]++;
    }
    int64_t ans = 0;
    for(int i = 0; i < p; i++){
        int64_t cnt = r[i];
        ans += cnt * (cnt - 1) / 2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2180
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  int N, K; 
  cin >> N >> K;

  int ans = 0;
  FOR(i, 1, N+1){
    int cnt = max(0ll, i-K);
    ans += cnt*(N/i)+max(0ll, N%i-(i-cnt)+1);
  }
  if(K == 0) ans -= N;

  cout << ans << "\n";

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;
template<typename T>
using pque = priority_queue<T, vector<T>, greater<T>>;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

char s[5];
int main(){
	scanf("%s", s);
	if(s[1] == 'B') s[1] = 'R';
	else s[1] = 'B';
	printf("%s\n", s);
}


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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second

#define DUMP(x) cout<<#x<<":"<<(x)<<endl
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class T>
istream& operator>>(istream& is, vector<T>& xs){
  for(auto& x: xs)
	is >> x;
  return is;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
ostream& operator<<(ostream& os, const vector<T>& xs){
  for(unsigned int i=0;i<xs.size();++i)
	os << (i?" ":"") << xs[i];
  return os;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  string S;
  cin >> S;
  int K;
  cin >> K;

  int N = SZ(S);
  VS vs;
  for(int l=1;l<=K&&l<=N;++l){
	REP(i,N-l+1){
	  vs.EB(S.substr(i, l));
	}
  }
  SORT(vs);
  UNIQ(vs);
  cout << vs[K-1] << endl;
	

  return 0;
}


Measured memory_bytes: 1660
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <functional>
#include <utility>
#include <queue>
#include <vector>
#include <string>
#include <stack>
#include <ctime>
#include <random>
#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;
typedef long long int ll;
const ll  MOD = 1000000007;
typedef pair<ll,ll> P;
const ll INF = 100100100100100100;

ll N;
ll A[100100], B[100100];
P diff[100100];
ll Asum;
int main() {
  cin >> N;
  rep(i,N) {
    cin >> A[i] >> B[i];
    diff[i] = make_pair(A[i] + B[i],i);
    Asum += A[i];
  }
  sort(diff, diff + N);
  
  ll left = 0;
  ll right = N-1;
  ll sum1 = 0;
  ll sum2 = 0;
  rep(i,N){
    ll a = diff[left].first;
    ll b = diff[right].first;
    ll aIndex = diff[left].second;
    ll bIndex = diff[right].second;
    
    if (i%2 == 0){
      sum1 += A[bIndex];
    }
    else {
      sum2 += B[bIndex];
    }
    right--;
    /*
    if(abs(a) >= abs(b)) {
      if (i%2 == 0) {
        cerr << "sum1 += " << A[aIndex] << endl;
        sum1 += A[aIndex];
      }
      else {
        cerr << "sum2 += " << B[aIndex] << endl;
        sum2 += B[aIndex];
      }
      left++;
    }
    else {
      if (i%2 == 0) {
        cerr << "sum1 += " << A[bIndex] << endl;
        sum1 += A[bIndex];
      }
      else {
         cerr << "sum2 += " << B[bIndex] << endl;
        sum2 += B[bIndex];
      }
      right--;
    }
    */
  }
  cout << sum1 - sum2 << endl;
}

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

typedef long long ll;
#define rep(i,x) for(int i=0;i<x;i++)
#define put(ans)    cout << ans << endl;

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

    if(a==b && b==c){
        cout << "No" << endl;
    }else if(a!=b && b!=c && c!=a){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }

    return 0;
}

Measured memory_bytes: 3628
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;
 
using namespace std;


void solve()
{
	int n;
	scanf("%d", &n);
	vector<int> x(n), y(n);
	int i, j;
	for (i = 0; i < n; i++) {
		scanf("%d%d", &x[i], &y[i]);
	}
	double sum = 0;
	for (i = 0; i < n; i++) {
		for (j = i+1; j < n; j++) {
			sum += sqrt((double)(x[i] - x[j])*(x[i] - x[j]) + (double)(y[i] - y[j])*(y[i] - y[j]));
		}
	}
	sum /= ((double)n*(n - 1) / 2);
	sum *= (n - 1);
	printf("%.10lf\n", sum);

    return;
}


int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T; scanf("%d", &T);
    while(T--) {
        solve();
    }
#endif
    return 0;
}


Measured memory_bytes: 256
n,d=map(int,input().split())
X=[[]*d for i in range(n)]
for i in range(n):
  X[i]=list(map(int,input().split()))
b=0
for i in range(n-1):
  for j in range(i+1,n):
    a=0
    for k in range(d):
      a=a+(X[i][k]-X[j][k])**2
      a=float(a)
    if a**(1/2)==int(a**(1/2)):
      b=b+1
print(b)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
static ll dp[3030][3030];
const ll mod=998244353;
int main(void){
    ll n,s;
    cin>>n>>s;
    ll a[n];
    rep(0,i,n)cin>>a[i];
    rep(0,i,3030)rep(0,j,3030)dp[i][j]=0;
    dp[0][0]=1;
    rep(0,i,n){
        rep(0,j,s+1){
            if(j-a[i]>=0)dp[i+1][j]=(2*dp[i][j]%mod+dp[i][j-a[i]]%mod)%mod;
            else dp[i+1][j]=2*dp[i][j]%mod;
            //cout<<dp[i+1][j]<<endl;
        }
    }
    cout<<dp[n][s];
}

Measured memory_bytes: 75368
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]

    R,C,K = LI()

    m = [[0] * (C+1) for _ in range(R+1)]
    dp = [[0] * 4 for _ in range(C+1)]
    for _ in range(K):
        r,c,v = LI()
        m[r][c] = v

    for i in range(1,R+1):
        for j in range(1,C+1):
            b_max = max(dp[j])
            dp[j][0] = max(dp[j-1][0],b_max)
            if m[i][j] > 0:
                for k in range(1,4):
                    dp[j][k] = max(dp[j-1][k],dp[j-1][k-1]+m[i][j])
                dp[j][1] = max(dp[j][1],b_max+m[i][j])
            else:
                for k in range(1,4):
                    dp[j][k] = dp[j-1][k]
    print(max(dp[-1]))

if __name__ == '__main__':
    main()

Measured memory_bytes: 148180
n, *L = map(int, open(0).read().split())
L.sort()
c = 0
for i in range(n-2):
  li = L[i]
  for j in range(i+1, n-1):
    lj = L[j]
    if li == lj:
      continue
    for k in range(j+1, n):
      lk = L[k]
      if lj == lk or li + lj <= lk:
        continue
      c += 1
print(c)

Measured memory_bytes: 9008
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
pair<int,int>f[510];
int n,mod,dp[510][260],r[510],ans;
inline void add(int &x,int y){(x+=y)>=mod?x-=mod:0;}
bool cmp(pair<int,int>x,pair<int,int>y)
{
	return x.first==y.first?x.second>y.second:x.first<y.first;
}
int main()
{
	scanf("%d %d",&n,&mod);
	for(int i=0;i<2*n;++i)r[i]=min((int)floor(sqrt(4*n*n-i*i)),2*n-1);
	for(int i=0;i<n;++i)f[i+1]={(int)ceil(sqrt(n*n-i*i))-1,i};
	for(int i=n;i<2*n;++i)f[i+1]={r[i],i};
	sort(f+1,f+2*n+1,cmp);
//	for(int i=1;i<=2*n;++i)printf("%d ",f[i].second);printf("\n");
	for(int k=0;k<=n;++k)
	{
		memset(dp,0,sizeof(dp));
		dp[0][0]=1;
		int cnt=0;
		for(int i=1;i<=2*n;++i)
			if(f[i].second>=n)
			{
				for(int j=0;j<=k;++j)dp[i][j]=1ll*dp[i-1][j]*(f[i].first+1-(i-1-(cnt-j)))%mod;
			}
			else
			{
				for(int j=0;j<=k;++j)dp[i][j]=(dp[i][j]+1ll*dp[i-1][j]*(r[f[i].second]+1-(2*n-1-f[i].second+k-j)))%mod;
				for(int j=0;j<k;++j)dp[i][j+1]=(dp[i][j+1]+1ll*dp[i-1][j]*(f[i].first+1-(i-1-(cnt-j))))%mod;
				++cnt;
			}
		if(k&1)add(ans,mod-dp[2*n][k]);
		else add(ans,dp[2*n][k]);
	}
	printf("%d",ans);
	return 0;
}


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

int main() {
  int N;
  cin >> N ;
  int sum=0;
  int S=N;

  for (int i = 1;N>0; i++) {
 
  sum += N%10;
  N=N/10;
 }

  if( S%sum==0){
    cout<< "Yes" <<endl;
  }
  else{
     cout<< "No" <<endl;
  }

}


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

using namespace std;

int main () {
  int n;

  cin >> n;
  for( int i = 0; i < n; i++ ) {
    string commands, mes;
    cin >> commands >> mes;
    int len = commands.length();
    int meslen = mes.length();
    for( int j = len - 1; j >= 0; j-- ) {
      switch( commands[ j ] ) {
        case 'C':
          mes = mes.substr( 1 ) + mes[ 0 ];
          break;
        case 'J':
          mes = mes[ meslen - 1 ] + mes.substr( 0, meslen - 1 );
          break;
        case 'E':
          if( meslen % 2 == 1 ) {
            mes = 
              mes.substr( meslen / 2 + 1 ) + 
              mes[ meslen / 2 ] +
              mes.substr( 0, meslen / 2 );
          }else{
            mes = 
              mes.substr( meslen / 2 ) +
              mes.substr( 0, meslen / 2 ); 
          }
          break;
        case 'A':
          reverse( mes.begin(), mes.end() );
          break;
        case 'M':
          for( int k = 0; k < meslen; k++ ) {
            if( '0' <= mes[ k ] && mes[ k ] <= '8' ){
              mes[ k ]++;
            }else if( mes[ k ] == '9' ){
              mes[ k ] = '0';
            }
          }
          break;
        case 'P':
          for( int k = 0; k < meslen; k++ ) {
            if( '1' <= mes[ k ] && mes[ k ] <= '9' ){
              mes[ k ]--;
            }else if( mes[ k ] == '0' ){
              mes[ k ] = '9';
            }
          }
          break;
      }
    }
    cout << mes << endl;
  }

  return EXIT_SUCCESS;
}

Measured memory_bytes: 1208
package main

import (
	"bufio"
	"os"
	"strconv"
	"fmt"
)

func main() {
	sc.Split(bufio.ScanWords)
	X := nextInt()
	Y := nextInt() / 1000

	prices := []int{10, 5, 1}
	dp := make([][][]int, 2)
	for i := 0; i < 2; i++ {
		dp[i] = make([][]int, Y + 1)
		for j := 0; j <= Y; j++ {
			dp[i][j] = make([]int, 3)
			for k := 0; k < 3; k++ {
				dp[i][j][k] = -1
			}
		}
	}

	for k := 0; k < 3; k++ {
		dp[0][0][k] = 0
	}
	cur := 0
	for i := 0; i < X; i++ {
		ncur := cur ^ 1
		for j := 0; j <= Y; j++ {
			for k := 0; k < 3; k++ {
				dp[ncur][j][k] = -1
			}
		}
		for j := 0; j < Y; j++ {
			if dp[cur][j][0] == -1 {
				continue
			}
			for k, p := range prices {
				if j + p <= Y {
					dp[ncur][j+p][0] = dp[cur][j][0]
					dp[ncur][j+p][1] = dp[cur][j][1]
					dp[ncur][j+p][2] = dp[cur][j][2]
					dp[ncur][j+p][k]++
				}
			}
		}
		cur = ncur
	}
	fmt.Println(dp[cur][Y][0], dp[cur][Y][1], dp[cur][Y][2])
}


// -------- Library --------
var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	v, err := strconv.Atoi(next())
	if err != nil {
		fmt.Println("Failed to read int", err)
		os.Exit(1)
	}
	return v
}

func nextIntArray(size int) []int {
	res := make([]int, size)
	for i := 0; i < size; i++ {
		res[i] = nextInt()
	}
	return res
}

Measured memory_bytes: 2944
//#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<cstdio>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<utility>
#include<algorithm>
#include<cstring>
#include<sstream>
#include <iomanip>

using namespace std;

typedef long long ll ;
typedef double db;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector< pair<int,int> > vii;
const double pi = 2*acos(0) ;

#define pf		  	printf
#define sf			  scanf
#define pb(a)         push_back(a)
#define mp			make_pair
#define fi			 first
#define se			 second
#define for0(i,n)        for(int i=0;i<n;i++)
#define for1(i,n)        for(int i=1;i<=n;i++)
#define forab(i,a,b)       for(int i=a;i<=b;i++)
#define lcm(a, b)     ((a)*((b)/gcd(a,b)))
#define sq(a)		   (a)*(a)
#define nw				"\n"
#define abs(x)		fabs(x)
#define pcase(z,x)    cout<<"Case "<<z<<": "<<x<<"\n"

int main()
{
	int i,j,n,s=0;
	cin>>n;
	vi a(n);
	for0(i,n) cin>>a[i];
	for0(i,n){
		forab(j,i+1,n-1){
			s += a[i]*a[j];
			}
		}
	cout<<s<<nw;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define day 3

int main() {
	char S[day];
	char T[day];

	int i;
	int ans = 0;

	scanf("%s", &S);
	scanf("%s", &T);

	for (i = 0; i < day; i++) {
		if (S[i] == T[i]) ans++;
	}

	printf("%d", ans);

	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <utility>
#include <vector>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <stack>
#include <queue>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
using ll = long long;
using ld = long double;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(void)
{
    ll N, M, i, judge=0;

    cin >> N >> M;

    for(i=1; i<=sqrt(M); i++){
        if(M%i==0 && N*(M/i)<=M){
            cout << M/i << endl;
            judge = 1;
            break;
        }
    }

    if(judge==0){
        for(i=sqrt(M); i>=1; i--){
            if(M%i==0 && N*i<=M){
                cout << i << endl;
                break;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 256
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};
#define yes cout<<"Yes\n"
#define no cout<<"No\n"

//nCr mod m
#define MOD 998244353
#define M 2200000
vector<ll> fact;
bool h=false;
void init(){
	h=true;
	fact=vector<ll>(M);
	fact[0]=fact[1]=1;
	loop(i,2,M)fact[i]=fact[i-1]*i%MOD;
}
// a^b mod MOD
ll powmod(ll a,ll b,ll m=MOD){
	ll out=1;
	ll p=a%m;
	while(b){
		if(b&1)out=out*p%m;
		p=p*p%m;
		b>>=1;
	}
	return out;
}
//nCr
ll nCr(ll n,ll r,ll m=MOD){
	if(!h)init();
	if(n<0||r<0||n<r)return 1;//??????
	ll out=fact[n]*powmod(fact[r]*fact[n-r]%m,m-2,m)%m;
	return out;
}
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}

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

	int n,m;
	cin>>n>>m;
	if(n%2){
		rep(i,m){
			cout<<i+1<<" "<<n-1-i<<endl;
		}
	}else{
		vi t;
		rep(i,m/2+(m%2))t.pb(i*2+1);
		rep(i,m/2)t.pb(n-2-i*2);
		sort(all(t));
		rep(i,m)cout<<i+1<<" "<<i+1+t[m-1-i]<<endl;
	}

}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()
 
using namespace std;
using ll = long long;
 
struct edge { int to, cost; };
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int MOD = 1e9+7;
const double EPS = 1.0e-10;
const double PI = acos(-1.0);
 
const int mx4[] = {0,1,0,-1};
const int my4[] = {1,0,-1,0};
const int mx8[] = {0,1,1,1,0,-1,-1,-1};
const int my8[] = {1,1,0,-1,-1,-1,0,1};

ll dfs(ll h,int i){
	if(h==1) return pow(2,i);
	else return pow(2,i)+dfs(h/2,i+1);
}

int main(){
	ll h;
	cin >> h;
	cout << dfs(h,0) << endl;
	return 0;
}


Measured memory_bytes: 256
n, k = map(int, input().split( ))
mod = 10**9+7

def chs(s,t,mod):
    nume =  1
    for i in range(s-t+1,s+1):
        nume *= i
        nume %= mod
    deno = 1
    for i in range(1,t+1):
        deno *= i
        deno %= mod
    deno = pow(deno,mod-2,mod)
    
    return (nume*deno%mod)

ans = chs(n-1,n-k,mod)
if n >=k:
    print(ans)
else:
    print(0)


Measured memory_bytes: 5600
/* C++14(GCC5.4.1) */
#include <bits/stdc++.h>
using namespace std;
using ll=long long;

int main(void){
    // 入力
    int n,k; cin >> n >> k;
    int height[n];
    for(int i=0; i<n; i++){
        cin >> height[i];
    }
    int ans = 0;
    for(int i=0; i<n; i++){
        if(height[i] >= k) ans++;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main(){
  int mo,n,k=0;
  string ans="Yes";
  cin>>mo>>n;
  int a[n];
  for(int i=0;i<n;i++)cin>>a[i];
  for(int i=0;i<n;i++)
    k+=a[i];
  if(mo>k)ans="No";
  cout<<ans<<endl;
  return 0;
}

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

using namespace std;
int n,m;
int v[110],w[110];
int dp[110][10010];

int main(){
  cin>>n>>m;
  for(int i=0;i<n;i++){
    cin>>v[i]>>w[i];
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<=m;j++){
      if(j-w[i]>=0)dp[i+1][j]=max(dp[i][j],dp[i][j-w[i]]+v[i]);
      else dp[i+1][j]=dp[i][j];
    }
  }
  cout<<dp[n][m]<<endl;
}


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

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

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

    // start
    int res = 0;
    char c[16] = {'C',
                  'O',
                  'D',
                  'E',
                  'F',
                  'E',
                  'S',
                  'T',
                  'I',
                  'V',
                  'A',
                  'L',
                  '2',
                  '0',
                  '1',
                  '6'};
    rep(i, 16)
    {
        char s;
        cin >> s;
        if (s != c[i])
            res++;
    }
    cout << res << endl;
    // end

    return 0;
}


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

using namespace std;

int n, k, a[200005];

long long check(int v) {
    long long tot = 0;
    for (int i = 0; i < n; i++) {
        tot += (a[i] - 1) / v;
    }

    return tot;
}

int main() {
    scanf("%d%d", &n, &k);

    for (int i = 0; i < n; i++) scanf("%d", &a[i]);

    int lb = 0;
    int ub = 1e9;

    while (ub - lb > 1) {
        int mid = (lb + ub) / 2;

        if (check(mid) <= k) ub = mid;
        else lb = mid;
    }

    printf("%d\n", ub);
}


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

using namespace std;

const int N = 2e5 + 5;
const int MAXN = 1e6 + 5;
int n, arr[N], cnt[MAXN];
set<int> st;


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

    cin >> n;
    int cnt1 = 0;
    for(int i = 1; i <= n; i++){
        cin >> arr[i];
        st.insert(arr[i]);
        cnt[arr[i]]++;
    }
    int ans = 0;
    for(int k = 1; k <= n; k++){
        if(cnt[arr[k]] == 1){
            bool ada = false;
            for(int i = 1; i * i <= arr[k]; i++){
                if(arr[k] % i == 0){
                    int j = arr[k] / i;
                    if(i < arr[k] && st.count(i)){
                        ada = true;
                    }
                    if(j < arr[k] && st.count(j)){
                        ada = true;
                    }
                }
            }
            if(ada){
                ans++;
            }
        } else {
            ans++;
        }
    }
    cout << n - ans << '\n';

    return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<double> x(N);
  vector<string> u(N);
  for (int i = 0; i < N; ++i) {
    cin >> x.at(i) >> u.at(i);
  }
  double ans = 0;
  for (int i = 0; i < N; ++i) {
    if (u.at(i) == "JPY") {
      ans += x.at(i);
    } else {
      ans += x.at(i) * 380000;
    }
  }
  cout << fixed << setprecision(12) << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int a, b;
	scanf("%d\n", &a);
	scanf("%d", &b);
	if(a==1&&b==2)
	printf("3");
	else if(a==2&&b==3)
	printf("1");
	else if (a==1&&b==3)
	printf("2");
	else if (a==2&&b==1)
	printf("3");
	else if (a==3&&b==2)
	printf("1");
	else if (a==3&&b==1)
	printf("2");
	return 0;
		
}

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

l = [0]*n
s = set()
x = 0

for i in range(n):
    machi = a[x]
    if machi in s:
        hajime = l.index(machi)
        repeat = l[hajime:i]
        break
    x = machi-1
    l[i] = machi
    s.add(machi)
else:
    amari = k%n
    print(l[amari-1])
    exit()

if k < hajime:
    print(l[k-1])
else:
    amari = (k-hajime)%len(repeat)
    print(repeat[amari-1])


Measured memory_bytes: 33552
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: usize,
        v: [usize; n]
    }
    let s = v.iter().cloned().fold(0, |ac, x| ac ^ x);
    let mut w: Vec<usize> = v.iter().cloned().map(|x| x & !s).collect();
    let mut wt = vec![];
    for _ in 0..60 {
        let p = w.iter().cloned().max().unwrap();
        if p == 0 {
            break;
        }
        wt.push(p);
        let mut d = 0;
        while 1 << d <= p {
            d += 1;
        }
        d -= 1;
        for j in 0..n {
            if w[j] & 1 << d != 0 {
                w[j] ^= p;
            }
        }
    }
    let mut ans = 0;
    for &x in &wt {
        ans = max(ans, ans ^ x);
    }
    println!("{}", ans * 2 + s);
}


Measured memory_bytes: 6396
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}

int N;
int t = 0;

void dfs(string s, int c) {
    if(s.size()==N) {
        cout << s << endl;
        return;
    } else {
        for(int i = 0; i <= c; i++) {
            dfs(s+char(i+'a'), ((i==c) ? (i+1) : c));
        }
    }
}

signed main() {
    cin >> N;

    dfs("", 0);

    return 0;
}

Measured memory_bytes: 1536
using System;

class MyClass
{
    static void Main(string[] args)
    {
        string[] str = Console.ReadLine().Split(' ');
        int a = int.Parse(str[0]);
        int b = int.Parse(str[1]);
        do
        {
            if (a < b)
            {
                int t = b;
                b = a;
                a = t;
            }
            else
            {
                a = a % b;
            }
        } while (b != 0);
        Console.WriteLine(a);
    }
}


Measured memory_bytes: 5612
a,b,m = gets.chomp.split(/ /).map(&:to_i)
as = gets.chomp.split(/ /).map(&:to_i)
bs = gets.chomp.split(/ /).map(&:to_i)
min = as.min + bs.min

m.times do
    x,y,c = gets.chomp.split(/ /).map(&:to_i)
    price = as[x - 1] + bs[y - 1] - c
    min = price if min > price
end
puts min

Measured memory_bytes: 23796
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>

using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
  vector<int> a(3);
  REP(i,3) cin>>a[i];
  sort(a.begin(), a.end());
  int d	= a[1]-a[0];
  int ans = d /	2;
  a[0] += d / 2	* 2;
  if(d % 2 != 0) {
    ans ++;
  }
  a[1] = a[0];
  d = a[2] - a[1];
  ans += d / 2 * 2;
  if (d	% 2 != 0) {
    ans	++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int a,b;
	while(1){
		scanf("%d %d",&a,&b);
		if(a==b && a==0){
			break;
		}else if(a>b){
			printf("%d %d\n",b,a);
		}else{
			printf("%d %d\n",a,b);
		}
	}
}


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

int main()
{
    string s;
    cin>>s;

    int a=0,b=0;

    for(int i=0;i<s.size();i++){
        if(s[i]=='A')
            a++;
        else b++;
    }

    if(a&&b)
        cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    return 0;
}



Measured memory_bytes: 256
n = list(map(int,input()))[::-1]
n.append(0)

for i in range(len(n)):
    if n[i] >= 6 or (n[i] == 5 and n[i+1] >= 5):
        n[i] = 10 - n[i]
        n[i+1] += 1

print(sum(n))

Measured memory_bytes: 20336
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>

using namespace std;

const long long int INF=1e14;
vector<pair<pair<int, long long int>, int> > E;

int main() {
    int N, M;
    cin >> N >> M;
    E.resize(M);
    
    for(int m=0; m<M; m++) {
        int a, b;
        long long int c;
        cin >> a >> b >> c;
        
        E[m]=make_pair(make_pair(a-1, b-1), -c);
    }

    vector<long long int> score(N, INF);
    score[0]=0;

    for(int n=0; n<N; n++) {
        for(int m=0; m<M; m++) {
            int from = E[m].first.first;
            int target = E[m].first.second;
            long long int cost = E[m].second;
            if(score[from]!=INF && score[target]>score[from]+cost) {
                if(n==N-1 && target==N-1) {
                    cout << "inf" << endl;
                    return 0;
                }
                // if(n==N-1 && score[target]==INF) {
                //     cout << "inf" << endl;
                //     return 0;
                // }
                score[target] = score[from]+cost;
                // if(n==N-1) {
                //     cout << "inf" << endl;
                //     return 0;
                // }
            }
        }
    }

    cout << -score[N-1] << endl;
    
    return 0;
    
}

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

const int INF = 1001001001;

int main(void) {
  int n, k;
  cin >> n >> k;
  int h[n + 1];
  rep (i, n) cin >> h[i + 1];

  vector<int> dp(n + 1, INF);

  dp[n] = 0;
  

  for (int i = n; i >= 1; i--) {
    for (int j = 1; j <= k; j++) {
      if (i - j <= 0) break;

      dp[i - j] = min(dp[i - j], dp[i] + abs(h[i] - h[i - j]));
    }
  }

  cout << dp[1] << endl;
  return 0;
}

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

int main(){
	ll n;
	cin >> n;
	ll ans = 0;
	for (ll i = 1; i <= n; ++i) {
		if(i % 3 != 0 && i % 5 != 0) ans += i;
	}
	cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3632
#include "bits/stdc++.h"

using namespace std;

int main() {
	string s;
	string t;
	cin >> s >> t;

	int ans = 0;
	for (int i = 0; i < 3; i++)
	{
		if (s[i] == t[i])ans++;
	}

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
int main() {
  ll a,b;
  cin >> a >> b;
  vector<ll>ans(10,0);
  if(a>b){
    for(ll i=0;i<a;i++){
      ans[i]=b;
    }
  }
  else {
    for(ll i=0;i<b;i++){
      ans[i]=a;
    }
  }
  for(ll i=0;i<10;i++){
    if(ans[i]==0) break;
    cout << ans[i];
  }
  cout << endl;
}

Measured memory_bytes: 3604
def rek(erg, rest):
    if not rest:
        return erg

    p = []

    for i in erg:
        p.append(i+"+"+rest[0])
        p.append(i+rest[0])

    return rek(p, rest[1:])


a = input()

erg = 0
comb = rek([a[0]], a[1:])

for i in comb:
    erg += eval(i)

print(erg)

Measured memory_bytes: 3064
#include "bits/stdc++.h"
#include <set>

using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
#define INF 10e10
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}
template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}

signed main(void) {
	string s;
	cin >> s;
	if (s[0] == 'R' && s[1] == 'R' && s[2] == 'R') {
		print("3");
	}
	else if ((s[0] == 'R' && s[1] == 'R') || ( s[1] == 'R'&& s[2] == 'R')) {
		print("2");
	}
	else if (s[0] == 'R' || s[1] == 'R' || s[2] == 'R') {
		print("1");
	}
	else print("0");
}

Measured memory_bytes: 3616
module WeightedGraph
  (Vertex : sig
    type t
    val compare : t -> t -> int
  end)
  (Weight : sig
    type t
    val compare : t -> t -> int
  end) :
sig
  val prim :
    (* 隣接リスト *)
    (Vertex.t -> (Vertex.t * Weight.t) list) ->
    (* 始点 *)
    Vertex.t ->
    (* 最小全域木に含まれる辺のリスト *)
    (Vertex.t * Vertex.t * Weight.t) list
end =
struct
  module VSet = Set.Make (Vertex)
  module WMap = Map.Make (Weight)

  (*
   * プリム法のメインループ
   * es : 隣接リスト
   * vs : 訪れた頂点の集合
   * q : 訪れた頂点から伸びる辺が重み順に入ったヒープ
   * acc : 最小全域木に使うのが確定した辺を入れるやつ
   *)
  let rec prim_aux es acc vs q =
    match WMap.min_binding q with
    | exception Not_found -> acc
    | (w, uvs) ->
        let rec inner = function
          | [] -> prim_aux es acc vs (WMap.remove w q)
          | (u, v) :: uvs ->
              if VSet.mem v vs
              (* vは既に訪れていた *)
              then inner uvs
              (* vはまだ訪れていなかった *)
              else prim_aux es ((u, v, w) :: acc) (VSet.add v vs) @@
                (* vから伸びる辺をキューに追加 *)
                List.fold_left (fun q (u, w) ->
                  (* 現時点で既に訪れている頂点への辺は追加しない *)
                  if VSet.mem u vs
                  then q
                  else WMap.add w ((v, u) :: try WMap.find w q with Not_found -> []) q)
                (match uvs with [] -> WMap.remove w q | _ :: _ -> WMap.add w uvs q) (es v) in
        inner uvs
                
  let prim es s =
    prim_aux es [] (VSet.singleton s) @@
      (* 始点から伸びる辺をキューに入れておく *)
      List.fold_left (fun q (v, w) ->
        WMap.add w ((s, v) :: try WMap.find w q with Not_found -> []) q) WMap.empty (es s)
end

module Int = struct
  type t = int
  let compare = compare
end

module G = WeightedGraph (Int) (Int)

let () = Scanf.scanf "%d\n" (fun n ->
  let xys = Array.to_list @@ Array.init n (fun i -> Scanf.scanf "%d %d\n" (fun x y -> x, y, i)) in
  let es = Array.make n [] in
  begin match List.sort (fun (x, _, _) (x', _, _) -> compare x x') xys with
  | [] -> ()
  | (x, y, i) :: rest ->
      ignore @@ List.fold_left (fun (x, y, i) (x', y', j) ->
        es.(i) <- (j, min (abs (x - x')) (abs (y - y'))) :: es.(i);
        es.(j) <- (i, min (abs (x - x')) (abs (y - y'))) :: es.(j);
        (x', y', j)) (x, y, i) rest
  end;
  begin match List.sort (fun (_, y, _) (_, y', _) -> compare y y') xys with
  | [] -> ()
  | (x, y, i) :: rest ->
      ignore @@ List.fold_left (fun (x, y, i) (x', y', j) ->
        es.(i) <- (j, min (abs (x - x')) (abs (y - y'))) :: es.(i);
        es.(j) <- (i, min (abs (x - x')) (abs (y - y'))) :: es.(j);
        (x', y', j)) (x, y, i) rest
  end;
  G.prim (Array.get es) 0
  |> List.map (fun (_, _, w) -> w)
  |> List.fold_left ( + ) 0
  |> Printf.printf "%d\n")


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

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


int main(){
    ll n;
    cin >> n;
    vector<modint<1000000007>> data(n+1);
    for(ll i=3;i<=n;i++){
        data[i]+=1;
        for(ll j=3;j<=i-3;j++){
            data[i]+=data[j];
        }
    }
    cout << data[n].a;
}


Measured memory_bytes: 3632