akhauriyash/Code-Regression huggingface dataset:
n=int(input())
a=[int(j) for j in input().split()]
b=[int(j) for j in input().split()]
tmp=0
if tmp<0:
    print("No")
    exit()
for i,j in zip(a,b):
   if i>j:
       tmp+=j-i
   elif i<j:
       tmp+=(j-i)//2
if tmp>=0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 4596
#include<algorithm>
#include<iostream>
#include<cstring>
#include<string>
#include<vector>
#include<cstdio>
#include<cmath>
#include<map>
#include<set>
using namespace std;
int n,a[105];
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	    cin>>a[i];
	int cnt=0;
	for(int i=0;i<n;i++)
        for(int j=0;j<n-1;j++)
            if(a[j]>a[j+1])
            {
            	cnt++;
            	swap(a[j],a[j+1]);
			}
	for(int i=0;i<n;i++)
	{
		cout<<a[i];
		if(i!=n-1)
		    cout<<' ';
		else
		    cout<<endl<<cnt<<endl;
	}
	return 0;
}


Measured memory_bytes: 3124
#include <algorithm>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;

int N[3][3];

int main(int argc, char *argv[])
{
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> N[i][j];
    }
  }

  int mina1 = min(min(N[0][0], N[0][1]), N[0][2]);
  int mina2 = min(min(N[1][0], N[1][1]), N[1][2]);
  int mina3 = min(min(N[2][0], N[2][1]), N[2][2]);
  int minb1 = min(min(N[0][0], N[1][0]), N[2][0]);
  int minb2 = min(min(N[0][1], N[1][1]), N[2][1]);
  int minb3 = min(min(N[0][2], N[1][2]), N[2][2]);

  for (int ia1 = 0; ia1 <= mina1; ia1++) {
    for (int ia2 = 0; ia2 <= mina2; ia2++) {
      for (int ia3 = 0; ia3 <= mina3; ia3++) {
        // int maxb = max(max(ia1, ia2), ia3);
        for (int jb1 = 0; jb1 <= minb1; jb1++) {
          for (int jb2 = 0; jb2 <= minb2; jb2++) {
            for (int jb3 = 0; jb3 <= minb3; jb3++) {
              if ((N[0][0] == ia1 + jb1) &&
                  (N[0][1] == ia1 + jb2) &&
                  (N[0][2] == ia1 + jb3) &&
                  (N[1][0] == ia2 + jb1) &&
                  (N[1][1] == ia2 + jb2) &&
                  (N[1][2] == ia2 + jb3) &&
                  (N[2][0] == ia3 + jb1) &&
                  (N[2][1] == ia3 + jb2) &&
                  (N[2][2] == ia3 + jb3)) {
                puts("Yes");
                return 0;
              }
            }
          }
        }
      }
    }
  }

  puts("No");
}


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

int main(){
  ll n;
  cin >> n;
  vector<ll> a(n+1), b(n+1), c(n+1);
  for(int i=1; i<=n; i++) cin >> a[i];
  for(int i=1; i<=n; i++) cin >> b[i];
  for(int i=1; i<=n; i++) cin >> c[i];
  
  ll ans = b[a[1]];
  for(int i=2; i<=n; i++){
  	ans += b[a[i]];
    if(a[i] == a[i-1]+1) ans += c[a[i-1]];
  }
  cout << ans << endl;	
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long ll;
#define N 100050
int n;
ll C,f[N],g[N],s[N],sx[N],p[N],c[N],sc[N],f2[N],g2[N];
int main() {
	scanf("%d%lld",&n,&C);
	int i;
	ll ans=0;
	for(i=1;i<=n;i++) scanf("%lld%lld",&p[i],&c[i]),sx[i]=sx[i-1]+p[i],sc[i]=sc[i-1]+c[i];
	for(i=1;i<=n;i++) f[i]=sc[i]-p[i],g[i]=sc[n]-sc[i-1]-(C-p[i]),ans=max(ans,max(f[i],g[i]));
	for(i=1;i<=n;i++) f2[i]=max(f[i],f2[i-1]);
	for(i=n;i>=1;i--) g2[i]=max(g[i],g2[i+1]);
	for(i=1;i<=n;i++) ans=max(ans,f[i]+g2[i+1]-p[i]);
	for(i=1;i<=n;i++) ans=max(ans,g[i]+f2[i-1]-(C-p[i]));
	printf("%lld\n",ans);
}

Measured memory_bytes: 7168
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
#include<map>
#include<unordered_map>
#include <queue>
 
using namespace std;
using ll=long long;
#define rep(i,n)  for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

string s[410];
int h, w;
bool used[410][410] = {false};
ll black, white;
void dfs(int x, int y){
    // cout << "pos " << x << ", "  << y << endl;
    used[x][y]=true;
    if(s[x][y]=='#')black++;
    else white++;
    if(x+1<h&&s[x+1][y]!=s[x][y]&&!used[x+1][y])dfs(x+1, y);
    if(x>0&&s[x-1][y]!=s[x][y]&&!used[x-1][y])dfs(x-1, y);
    if(y+1<w&&s[x][y+1]!=s[x][y]&&!used[x][y+1])dfs(x, y+1);
    if(y>0&&s[x][y-1]!=s[x][y]&&!used[x][y-1])dfs(x, y-1);
}
 
int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n)cin >> a[i];
    sort(ALL(a));
    ll ans = 0;
    ll sum = 0;
    a.push_back(0);
    rep(i, n){
        sum += a[i];
        if(sum*2 >= a[i+1])ans++;
        else ans = 0;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
typedef long long ll;
const int inf = 1e9;
int main(){
    int n; cin >> n;
    vector<int> a(n), dp(n+1, 0);
    rep(i,n)cin >> a[i];
    dp[1] = abs(a[0] - a[1]);
    REP(i,2,n)
        dp[i] = min(dp[i-2] + abs(a[i] - a[i-2]), dp[i-1] + abs(a[i] - a[i-1]));

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

Measured memory_bytes: 1152
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll n, A, B; cin >> n >> A >> B;

    ll res = n / (A + B) * A + min(A, n % (A + B));

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct _I { _I() {cin.tie(0);ios::sync_with_stdio(false);}} __I;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define all(a) begin(a),end(a)
template<class F, class S> istream& operator >> (istream& s, pair<F, S>& p)
{ cin >> p.first >> p.second; return s;}
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> void cout_h(const vector<T>& c, int n=INT_MAX)
{ rep(i, min(n, (int)c.size())) cout << c[i] << (i==c.size()-1?"\n":" "); }
template<class T> inline bool chmin(T& a, T b) {return a>b?a=b,true:false;}
template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}
#define D1(a) cout<<#a<<":"<<a<<"\n"
#define D2(a,b) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<endl 
#define D3(a,b,c) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<","<<#c<<":"<<c <<endl
#define D4(a,b,c,d) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<","<<#c<<":"<<c<<","<<#d<<":"<<d<<endl 
#define MOD 1000000007

ll N, A;
vector<int> x;

ll dp[50][50+1][2500+1];

ll solve(ll p=0, ll chosen=0, ll sum = 0)
{
    if (p == N) {
        return (chosen >0 && sum==chosen*A) ? 1 : 0;
    }

    ll& res = dp[p][chosen][sum];
    if (~res) return dp[p][chosen][sum];
    res = 0;

    res += solve(p+1, chosen+1, sum+x[p]);
    res += solve(p+1, chosen, sum);

    return dp[p][chosen][sum] = res;
}

int main()
{
    cin >> N >> A;
    x.resize(N); cin >> x;

    memset(dp, -1, sizeof dp);

    cout << solve() << endl;
}


Measured memory_bytes: 50048
#include <iostream>
#include <string>
using namespace std;
int main(){
    string s; cin >> s;
    int cnt = 0;
    for(int i = 2; i < s.size()-1; i++){
        if(s[i] == 'C') {
            cnt++;
            if(cnt == 1) s[i] = 'c';
        }
    }
    if(cnt != 1){
        puts("WA");
        return 0;
    }
    for(int i = 0; i < s.size(); i++){
        if(i == 0) {
            if(s[i] != 'A'){
                puts("WA");
                return 0;
            }
        }
        else{
            if(s[i] - 'a' < 0){
                puts("WA");
                return 0;
            }
        }
    }
    puts("AC");
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main(void)
{
	double x1,x2,y1,y2;
	
	scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
	
	printf("%lf\n",hypot((x1-x2),(y1-y2)));
}


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

const int MAX_D = (int)(10 + 5);

int n;

map<int, int> even;
map<int, int> odd;

int ans;

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

  for (int i = 0; i < n; ++i) {
    int tmp;
    scanf("%d\n", &tmp);
    if (i % 2 == 0) even[tmp] += 1;
    else odd[tmp] += 1;
  }

  int max_even = -1;
  int max_even_elem;
  for (auto itr = even.begin(); itr != even.end(); ++itr) {
    if (max_even < itr->second) {
      max_even = itr->second;
      max_even_elem = itr->first;
    }
  }

  int max_odd = -1;
  int max_odd_elem;
  for (auto itr = odd.begin(); itr != odd.end(); ++itr) {
    if (max_odd < itr->second) {
      max_odd = itr->second;
      max_odd_elem = itr->first;
    }
  }

  if (max_odd_elem != max_even_elem) {
    ans = (n / 2) - max_even + (n / 2) - max_odd;

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

    return 0;
  }

  if (even.size() == 1 && odd.size() == 1) {
    ans = (n / 2);
  }
  else if (even.size() == 1 && odd.size() > 1) {
    int max_odd_true = -1;
    int max_odd_elem_true;
    for (auto itr = odd.begin(); itr != odd.end(); ++itr) {
      if (max_odd_true < itr->second && itr->first != max_odd_elem) {
        max_odd_true = itr->second;
        max_odd_elem_true = itr->first;
      }
    }

    ans = (n / 2) - max_odd_true;
  }
  else if (even.size() > 1 && odd.size() == 1) {
    int max_even_true = -1;
    int max_even_elem_true;
    for (auto itr = even.begin(); itr != even.end(); ++itr) {
      if (max_even_true < itr->second && itr->first != max_even_elem) {
        max_even_true = itr->second;
        max_even_elem_true = itr->first;
      }
    }

    ans = (n / 2) - max_even_true;
  }
  else {
    int max_odd_true = -1;
    int max_odd_elem_true;
    for (auto itr = odd.begin(); itr != odd.end(); ++itr) {
      if (max_odd_true < itr->second && itr->first != max_odd_elem) {
        max_odd_true = itr->second;
        max_odd_elem_true = itr->first;
      }
    }

    int max_even_true = -1;
    int max_even_elem_true;
    for (auto itr = even.begin(); itr != even.end(); ++itr) {
      if (max_even_true < itr->second && itr->first != max_even_elem) {
        max_even_true = itr->second;
        max_even_elem_true = itr->first;
      }
    }

    ans = min((n / 2) - max_even + (n / 2) - max_odd_true, (n / 2) - max_even_true + (n / 2) - max_odd);
  }

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

}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
#define M 200005
int a[M],mx1[M],mx2[M];
int main(){
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;++i)scanf("%d",&a[i]);
	for(int i=1;i<=n;++i)mx1[i]=max(mx1[i-1],a[i]);
	for(int i=n;i>=1;--i)mx2[i]=max(mx2[i+1],a[i]);
	for(int i=1;i<=n;++i)printf("%d\n",max(mx1[i-1],mx2[i+1]));
}

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

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

typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//定数
#define INF 1000000000 //10^9:極めて大きい値,∞
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second　//pairの二つ目の要素

int main(){
    int n,k;
    cin>>n>>k;
    vector<int> h(n);
    rep(i,n) cin>>h[i];
    vector<int> dp(n);
    dp[0]=0; //コスト
    rep(i,n){
        int cost=INF;
        for(int j=1;j<=k;j++){
            cost=min(dp[max(0,i-j)]+abs(h[i]-h[max(0,i-j)]),cost);
        }
        dp[i]=cost;
    }
    cout<<dp[n-1]<<endl;
    return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int x1 = in.nextInt();
		int y1 = in.nextInt();
		int x2 = in.nextInt();
		int y2 = in.nextInt();
		int x4 = y1-y2+x1;
		int y4 = x2-x1+y1;
		int x3 = y1-y2+x2;
		int y3 = x2-x1+y2;

		System.out.print(x3+" "+y3+" "+x4+" "+y4);

	}
}


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

#ifdef _DEBUG
#define debug(x) cerr << "line: " << __LINE__ << ", func: " << __func__ << " ->  " << #x << " = " << x << endl
#else
#define debug(x)
#endif

#define all(s) begin(s), end(s)
#define rall(s) rbegin(s), rend(s)
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = ((a)-1); i >= (b); i--)
#define pb push_back
#define sz(a) int((a).size())
#define put(a) ((cout) << (a) << (endl))
#define putf(a, n) ((cout) << (fixed) << (setprecision(n)) << (a) << (endl))
#define deg2rad(x) (((x)*PI) / (180.0))
#define rad2deg(x) (((x) * (180.0)) / PI)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using i_i = pair<int, int>;
using ll_ll = pair<ll, ll>;
using d_ll = pair<double, ll>;
using ll_d = pair<ll, double>;
using d_d = pair<double, double>;
template <class T> using vec = vector<T>;

static constexpr ll LL_INF = 1LL << 60;
static constexpr int I_INF = 1 << 28;
static constexpr double PI = static_cast<double>(3.14159265358979323846264338327950288);
static constexpr double EPS = numeric_limits<double>::epsilon();

static map<type_index, const char* const> scanType = {
    {typeid(int), "%d"}, {typeid(ll), "%lld"}, {typeid(double), "%lf"}, {typeid(char), "%c"}};

template <class T> static void scan(vector<T>& v);
[[maybe_unused]] static void scan(vector<string>& v, bool isWord = true);
template <class T> static inline bool chmax(T& a, T b);
template <class T> static inline bool chmin(T& a, T b);
template <class T> static inline T gcd(T a, T b);
template <class T> static inline T lcm(T a, T b);
template <class A, size_t N, class T> static void Fill(A (&arr)[N], const T& val);
template <class T> T mod(T a, T m);

int main(int argc, char* argv[]) {
  ll n;
  cin >> n;
  vec<ll> a(n);
  scan(a);

  map<ll, ll> c;
  rep(i, 0, n) { c[a[i]]++; }

  ll uniq = 0, two = 0;
  for (auto& p : c) {
    if (p.second % 2 == 0) two += 1;
    uniq += 1;
  }

  put(uniq - (two % 2));
  return 0;
}

template <class T> static void scan(vector<T>& v) {
  auto tFormat = scanType[typeid(T)];
  for (T& n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string>& v, bool isWord) {
  if (isWord) {
    for (auto& n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}

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

template <class T> inline T gcd(T a, T b) { return __gcd(a, b); }

template <class T> inline T lcm(T a, T b) {
  T c = min(a, b), d = max(a, b);
  return c * (d / gcd(c, d));
}

template <class A, size_t N, class T> void Fill(A (&arr)[N], const T& val) {
  std::fill((T*)arr, (T*)(arr + N), val);
}

template <class T> T mod(T a, T m) { return (a % m + m) % m; }


Measured memory_bytes: 7296
import numpy as np

val = input().split(' ')
k = int(val[0])
n = int(val[1])

alist = sorted([int(a) for a in input().split(' ')])

a2list = list(map(lambda a: a + k, alist))
alist.extend(a2list[:-1])
adiff = np.diff(alist)
before = sum(adiff[0: n-1])
result = before
for i in range(1, n):
    tmp = before - adiff[i - 1] + adiff[i - 2 + n]
    before = tmp
    if tmp < result:
        result = tmp
print(result)


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

int main(){
    int a, b;
    cin >> a >> b;
    if(a>=13){
        cout << b << endl;
    }
    else if(6<=a&&a<=12){
        cout << b/2 << endl;
    }
    else{
        cout << "0" << endl;
    }
    return 0;
}


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

#define lld long long int
#define llu unsigned long long

int main()
{
    //freopen("input.txt", "w", stdin);

    int test,i;
    scanf("%d %d", &test, &i);

    printf("%d\n", test-i+1);
    return 0;
}


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

int main() {
  // 1 <= (a, b) <= 100 ;
  int a, b;
  cin >> a;
  cin >> b;
  //int mod = ((a % 2) + (b % 2)) % 2;
  cout << ((a+b) % 2) + ((a + b) / 2)  << endl;
  
  // ここにプログラムを追記
}

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

using namespace std;

using i64 = int64_t;

const i64 MOD = 1e9+7;

const i64 INF = 1e18+7;


signed main(){
    int a, b, c, d, n, m, x, y;
    string s, t;


    auto Yes = [&](bool t){
        cout << (t ? "Yes" : "No") << endl;
    };
    auto YES = [&](bool t){
        cout << (t ? "YES" : "NO") << endl;
    };
    auto tri = [&](bool t, string a, string b){
        cout << (t ? a : b) << endl;
    };

    cin >> n;
    vector<int> v(n);
    for(auto& x : v)
        cin >> x;
    cin >> m;
    for(int i = 0; i < m; ++i){
        cin >> b >> c;
        --b;
        cout << accumulate(v.begin(), v.end(), 0) + c - v[b] << endl;
    }
}


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

struct Dice{
         int n[6];
         void move_n(int r){
             r=n[0];
             n[0]=n[1];
             n[1]=n[5];
             n[5]=n[4];
             n[4]=r;
         }
         void move_s(int r){
             r=n[0];
             n[0]=n[4];
             n[4]=n[5];
             n[5]=n[1];
             n[1]=r;
         }
         void move_w(int r){
             r=n[0];
             n[0]=n[2];
             n[2]=n[5];
             n[5]=n[3];
             n[3]=r;
         }
         void move_e(int r){
             r=n[0];
             n[0]=n[3];
             n[3]=n[5];
             n[5]=n[2];
             n[2]=r;
         }
         void move_m(int r){
             r=n[1];
             n[1]=n[2];
             n[2]=n[4];
             n[4]=n[3];
             n[3]=r;
         }
    };
    
int main(){
    Dice x;
    Dice y;
    for(int i=0;i<6;i++)cin>>x.n[i];
    for(int i=0;i<6;i++)cin>>y.n[i];
    
    for(int i=0; !(x.n[0]==y.n[0] && x.n[1]==y.n[1]);i++){
    if(x.n[3]==y.n[1] || x.n[2]==y.n[1]){
        int a=x.n[0];
        x.n[0]=x.n[3];
        x.n[3]=x.n[5];
        x.n[5]=x.n[2];
        x.n[2]=a;
        
    }
    for(int j=0;x.n[1]!=y.n[1];j++){
            x.move_n(j);
    }
    for(int k=0;x.n[0]!=y.n[0];k++){
            x.move_e(k);     
    }
    }
    if(x.n[2]==y.n[2]&&x.n[3]==y.n[3]&&x.n[4]==y.n[4])cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}



Measured memory_bytes: 3104
import std.algorithm;
import std.array;
import std.ascii;
import std.bigint;
import std.complex;
import std.container;
import std.conv;
import std.functional;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

auto readInts() {
	return array(map!(to!int)(readln().strip().split()));
}
auto readInt() {
	return readInts()[0];
}
auto readLongs() {
	return array(map!(to!long)(readln().strip().split()));
}
auto readLong() {
	return readLongs()[0];
}

void readlnTo(T...)(ref T t) {
    auto s = readln().split();
    assert(s.length == t.length);
    foreach(ref ti; t) {
        ti = s[0].to!(typeof(ti));
        s = s[1..$];
    }
}

const real eps = 1e-10;

const long p = 1_000_000_000 + 7;

void main(){
    foreach(i; iota(9)) {
        auto l = readln().chomp().split(" ");
        auto p = l[1].to!(long) + l[2].to!(long);
        auto c = l[1].to!(long) * 200 + l[2].to!(long) * 300;
        writeln(l[0], " ", p, " ", c);
    }
}

Measured memory_bytes: 2348
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define llu unsigned long long int
#define sa(a,n,t) for(int ii=0;ii<n;ii++) scanf("%"#t"",&(a)[ii])
#define rep(i,n) for(int i=0;i<n;i++) 
#define reps(i,a,n) for(int i=a;i<n;i++) 
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rreps(i,a,n) for(int i=n-1;i>=a;i--)
#define validl(i,a,b) ((i>=a)&&(i<=b))?1:0
#define validmat(x,y,a,b,c,d) (validl(x,a,b) && validl(y,a,b))?1:0
#define validmn(x,y,m,n) validmat(x,y,0,m,0,n)
#define valid(i,n) validl(i,0,n)
#define v(t) vector<t>
#define vv(t) vector<vector<t> >
#define mk make_pair
#define pb push_back
#define pa(a,n,t)  for(int i=0;i<n;i++) printf("%"#t"",a[i])
#define p2 pair<int,int>
#define p3 pair<p2,int>
#define fi first
#define se second
#define sd(a) scanf("%d",&a)
#define sl(a) scanf("%lld",&a)
#define pl(a) printf("%lld",a)
#define pd(a) printf("%d",a)
#define sf(a) scanf("%lf",&a)
#define pf(a) printf("%lf",a)
#define nline printf("\n")
#define ss(a) scanf("%s",a)
#define ps(a) printf("%s",a)
#define sc(a) scanf("%c",&a)
#define pc(a) printf("%c",&a)
#define mf(m,f) m.find(f)!=m.end()
#define pp3(m) cout<<m.fi.fi<<" "<<m.fi.se<<" "<<m.se<<" "
#define pp2(m) cout<<m.fi<<" "<<m.se<<" "
#define debug 0
/*v(int) adj[200001];
void dfs(int i,int p){
    rep(j,adj[i].size()){
        if(p!=adj[i][j])
            dfs(adj[i][j],i);
    }
}*/
int main()
{
  lli arr[200001],brr[200001];
  int n,m,k;
  cin>>n>>m>>k;
  sa(arr,n,lld);
  sa(brr,m,lld);
  //int i=0,j=0,c=0,t_s=0;
  reps(i,1,n) arr[i]+=arr[i-1];
  reps(i,1,m) brr[i]+=brr[i-1];
 int i=0,j=0,c=0;
 while(j<m &&brr[j]<=k) j++;
 j--;
 c= max(c,i+j+1);
 while(i<n && arr[i]<=k){
     //cout<<j<<" "<<endl;
     while(j>=0  && brr[j]>k-arr[i]) j--;
     c= max(c,i+1+j+1);
     i++;
 }
  cout<<c<<endl;
}


Measured memory_bytes: 6888
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String str = sc.next();
    int s = -1;
    for(int i = 0; i < str.length(); i++){
      if(str.charAt(i) == 'A'){
        s = i;
        break;
      }
    }
 
    int t = -1;
    for(int i = str.length() - 1; i >= 0; i--){
      if(str.charAt(i) == 'Z'){
        t = i;
        break;
      }
    }
 
    System.out.println((t - s) + 1);
    sc.close();
  }
}


Measured memory_bytes: 26756
#include<stdio.h>

int main()
{
    int n,i;
    int a[110]={0};
    int ans=0;

    scanf("%d",&n);

    for(i=0;i<n;i++)
    {
        scanf("%d",&(a[i]));
    }
    for(i=0;i<n;i++)
    {
        if(((i+1)%2==1)&&(a[i]%2==1))ans++;
    }
	printf("%d",ans);
}


Measured memory_bytes: 1732
#include <bits/stdc++.h>
#include <cstdlib>
using namespace std;
typedef std::bitset<6> bit;
 
int main(){
  int N,K,d,A;
  cin>>N>>K;
  int ans=N;
  map<int,string> Abuf;
  for(int i=0;i<K;i++){
    cin>>d;
    for(int j=0;j<d;j++){
      cin>>A;
      if(!Abuf.count(A)){
        ans--;
        Abuf[A]="okashi";
      } 
      
    }
  }
    cout<<ans;
  return 0;
}

Measured memory_bytes: 3632
use std::io::*;

mod disjoint_set {
    pub struct DisjointSet {
        parent: Vec<usize>,
        size: Vec<usize>,
    }
    impl DisjointSet {
        pub fn new(n: usize) -> DisjointSet {
            DisjointSet {
                parent: (0..n).collect(),
                size: vec![1; n],
            }
        }
        fn root(&mut self, x: usize) -> usize {
            if x == self.parent[x] {
                x
            } else {
                let tmp = self.parent[x];
                self.parent[x] = self.root(tmp);
                self.parent[x]
            }
        }
        pub fn merge(&mut self, x: usize, y: usize) {
            let x = self.root(x);
            let y = self.root(y);
            if x == y {
                return;
            }
            if self.size[x] > self.size[y] {
                self.size[x] += self.size[y];
                self.parent[y] = x;
            } else {
                self.size[y] += self.size[x];
                self.parent[x] = y;
            }
        }
        pub fn same(&mut self, x: usize, y: usize) -> bool {
            self.root(x) == self.root(y)
        }
        pub fn size(&mut self, x: usize) -> usize {
            let x = self.root(x);
            self.size[x]
        }
    }
}

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let m: usize = itr.next().unwrap().parse().unwrap();
    let a: Vec<(usize, usize)> = (0..m)
        .map(|_| {
            (
                itr.next().unwrap().parse().unwrap(),
                itr.next().unwrap().parse().unwrap(),
            )
        })
        .collect();

    let mut uf = disjoint_set::DisjointSet::new(n + 1);
    for i in 0..m {
        uf.merge(a[i].0, a[i].1);
    }
    let mut one_vert = uf.size(1);
    let mut two_vert = uf.size(2);
    let other_vert = n - one_vert - two_vert;
    let mut ans = 0;
    if one_vert < two_vert {
        std::mem::swap(&mut one_vert, &mut two_vert);
    }
    // 完全グラフの辺の数 - 今の辺
    ans += (one_vert + other_vert) * (one_vert + other_vert - 1) / 2;
    ans += two_vert * (two_vert - 1) / 2;
    println!("{}", ans - m);
}


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

int main()
{
	int n, in, a;
	while (cin >> in){
		n = 0;
		if (in > 2){
			for (int i = 2; i <= in; i++){
				if (i == 2) a = 4;
				else a += i;
			}
			n = n + a;
		}
		else n = in * 2;

		cout << n << endl;
	}
	return (0);
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main(){


	while(1){
		int n;
		cin >> n;
		if(n == 0)
			break;
		vector<int> A,B;
		for(int i = 0; i < n; i++){
			int a,b;
			cin >> a >> b;
			A.push_back(a);
			B.push_back(b);
		}

		int a_score = 0;
		int b_score = 0;
		for(int i = 0; i < A.size(); i++){
			if(A[i] > B[i]){
				a_score += A[i] + B[i];
			}
			else if(A[i] < B[i]){
				b_score += A[i] + B[i];
			}
			else{
				a_score += A[i];
				b_score += B[i];
			}
		}
		cout << a_score << " " << b_score << endl;
	}


	return 0;
}

Measured memory_bytes: 0
#include<cstdio>
#include<cstring>
using namespace std;
char str[100100];
int main(){
//	freopen("A.in","r",stdin);
	int n,m,k;
	scanf("%d%d%d",&n,&m,&k);
	for(int i=0;i<=n;i++)
	{
		for(int j=0;j<=m;j++)
			if((n-i)*j+i*(m-j)==k)
			{
				printf("Yes\n");
				return 0;
			}
	}
	printf("No\n");
	return 0;
}


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

int main() {
  int A,B;
  cin >>A>>B;
  bool pos = true;
  if(A>9||B>9){
    pos = false;
  }
  if(pos){
    cout<<A*B<<endl;
  }else{
    cout<<-1<<endl;
  }
  
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

#define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << endl;
#define debug(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << x << endl;

using namespace std;
typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    int x; cin >> x;
    cout << 1-x << endl;
}

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

int main(){
	int a,b,c;
	cin >> a >> b >> c;
	if(a==b){ cout << c << endl;
	}else if(a==c){ cout << b << endl;
	}else{ cout << a << endl;
	}
	return 0;
}



Measured memory_bytes: 3608
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000


int main(){
   unsigned short *A, *B;
   int C[VMAX+1];
  int n, i, j;

  scanf("%d", &n);

   A = malloc(sizeof(short)*n+1);
   B = malloc(sizeof(short)*n+1);



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

  for(i = 0; i < 10001; i++){
    C[i] = 0;
  }

  for(i = 0 ;i < n;i++){
    C[A[i]]++;
  }

  for(i = 1; i < 10001; i++){
    C[i] = C[i] + C[i-1];
  }

  for(i = n-1; i >= 0; i--){
    B[C[A[i]]-1] = A[i];
    C[A[i]]--;
  }


  
  for(i = 0; i < n ; i++){
 
    if(i == n-1){
      printf("%d\n",B[i]);
      break;
    }
    printf("%d ",B[i]);
  }

  return 0;
}



Measured memory_bytes: 9576
#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;
}
typedef long long int ll;

#define EPS (1e-7)
#define INF (1 << 30)
#define LLINF (1LL << 60)
#define PI (acos(-1))
#define MOD (1000000007)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m, s, t;
    cin >> n >> m;
    vector<vector<int>> g(n);
    for (int i = 0; i < m; i++)
    {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        g[a].push_back(b);
    }
    cin >> s >> t;
    s--;
    t--;
    vector<vector<int>> d(n, vector<int>(3, INF));
    queue<pair<int, int>> que;
    que.push(make_pair(s, 0));
    d[s][0] = 0;
    while (!que.empty())
    {
        auto p = que.front();
        que.pop();
        int r = (p.second + 1) % 3;
        for (auto v : g[p.first])
        {
            if (d[v][r] == INF)
            {
                chmin(d[v][r], d[p.first][p.second] + 1);
                que.push(make_pair(v, r));
            }
        }
    }
    cout << (d[t][0] == INF ? -1 : d[t][0] / 3) << endl;
}

Measured memory_bytes: 11264
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
const int INF = (int)1e9 + 7;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

vector<vector<int>> calc_next(const string &s) {
    int n = s.size();
    vector<vector<int>> nxt(n + 1, vector<int>(26, n));
    for (int i = n - 1; i >= 0; i--) {
        for (int j = 0; j < 26; j++) nxt[i][j] = nxt[i + 1][j];
        nxt[i][s[i] - 'a'] = i;
    }
    return nxt;
}

int main() {
    string s; cin >> s;
    int n = s.size();
    auto nxt = calc_next(s);
    vector<int> dp(n + 1, INF);
    vector<pair<char, int>> recon(n + 1, {'?', n});
    dp[n] = 1;
    for (int i = n - 1; i >= 0; i--) for (int j = 0; j < 26; j++) {
        if (nxt[i][j] == n) {
            if (dp[i] > 1) dp[i] = 1, recon[i] = {'a' + j, n};
        } else if (chmin(dp[i], dp[nxt[i][j] + 1] + 1)) {
            recon[i] = {'a' + j, nxt[i][j] + 1};
        }
    }
    string res = "";
    int idx = 0;
    while (idx < n) {
        auto p = recon[idx];
        res += p.first;
        idx = p.second;
    }
    cout << res << endl;
}

Measured memory_bytes: 29316
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;

int main(){
  
  ll n,x,m; cin>>n>>x>>m;
  
  vector<ll> a(m,-1);
  ll cnt{1};
  ll y = x;
  ll start,end;
  a.at(y) = 0;
  while(1){
    y *= y;
    y %= m;
    if(a.at(y)==-1) {
      a.at(y) = cnt;
      cnt++;
    }
    else{
      start = a.at(y);
      end = cnt-1;
      break;
    }
    
  }
  //cout << start <<' '<<end<< endl;
  y = x;
  ll ans{}, l;
  for(ll i=0; i<start; i++){
    ans += y;
    y *= y;
    y %= m;
  }
  for(ll i=start; i<=end; i++){
    l += y;
    y *= y;
    y %= m;
  }
  n -= start;
  ans += l * ( n/(end-start+1) );
  n %= (end-start+1);
  for(ll i=0; i<n; i++){
    ans += y;
    y *= y;
    y %= m; 
  }
  cout<<ans<<endl;
  
  
  
  
}


Measured memory_bytes: 3940
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

int N;
vector<int> A(3);
vector<char> S(200000), ans(100000);
bool searched = false;

void dfs(int n) {
    if (A[0] < 0 || A[1] < 0 || A[2] < 0) return;
    if (searched) return;
    if (n == N) {
        cout << "Yes" << "\n";
        rep(i, N) cout << ans[i] << "\n";
        searched = true;
        return;
    }
    
    ++A[S[2 * n] - 'A'];
    --A[S[2 * n + 1] - 'A'];
    ans[n] = S[2 * n];
    dfs(n + 1);
    --A[S[2 * n] - 'A'];
    ++A[S[2 * n + 1] - 'A'];
    
    if (searched) return;
    --A[S[2 * n] - 'A'];
    ++A[S[2 * n + 1] - 'A'];
    ans[n] = S[2 * n + 1];
    dfs(n + 1);
    ++A[S[2 * n] - 'A'];
    --A[S[2 * n + 1] - 'A'];
    return;
}

int main() {
    cin >> N >> A[0] >> A[1] >> A[2];
    rep(i, 2 * N) cin >> S[i];
    dfs(0);
    if (!searched) cout << "No" << "\n";
    return 0;
}


Measured memory_bytes: 9996
#include <bits/stdc++.h>
//#define DEBUG
#define REP(i, nn ) for(int i = 0 ; i < (int) nn; i++)
#define deb(x) std::cout << #x << " " << x << endl;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
template<typename... T>
void read(T& ... a){
    ((cin >> a),...);
}
template<typename... T>
void write(T... a){
    ((cout << a << "\n"),...);
}

template<typename... T>
void write_space(T... a){
    ((cout << a << " "),...);
}

constexpr int mxN = 2e5;
constexpr int MOD =998244353;
ll t[4*mxN];
ll dp[mxN];

void build(ll a[], int v, int tl, int tr) {
    if (tl == tr) {
        t[v] = a[tl];
    } else {
        int tm = (tl + tr) / 2;
        build(a, v*2, tl, tm);
        build(a, v*2+1, tm+1, tr);
        t[v] = t[v*2] + t[v*2+1];
    }
}

ll sum(int v, int tl, int tr, int l, int r) {
    if (l > r) 
        return 0;
    if (l == tl && r == tr) {
        return t[v];
    }
    int tm = (tl + tr) / 2;
    ll sum_left = sum(v*2, tl, tm, l, min(r, tm));
    ll sum_right = sum(v*2+1, tm+1, tr, max(l, tm+1), r); 
    ll ans = (sum_left + sum_right);
    ans = (ans >= MOD) ? ans % MOD : ans;
    return ans;
}

void update(int v, int tl, int tr, int pos, ll new_val) {
    if (tl == tr) {
        t[v] = new_val;
    } else {
        int tm = (tl + tr) / 2;
        if (pos <= tm)
            update(v*2, tl, tm, pos, new_val);
        else
            update(v*2+1, tm+1, tr, pos, new_val);
        t[v] = t[v*2] + t[v*2+1];
    }
}

void solve(){
    int n, k;
    read(n,k);
    dp[1] = 1;
    build(dp, 1, 0, n-1);
    vector<pair<int,int>> range(k);
    REP(i,k){
        int l, r;
        read(l, r);
        range[i] = make_pair(l,r);
    }
    for(int i = 2; i <= n ;i++){
        dp[i] = 0;
        for(int j = 0 ; j < k ; j++){
            int r = i - range[j].first;
            int l = i - range[j].second;
            if( l < 1 & r < 1){
                continue;
            }else if( l < 1){
                l = 1;
            }
            dp[i] += ( sum(1, 0, n-1, l, r) % MOD);
            if( dp[i] >= MOD){
                dp[i] = dp[i] % MOD;
            }
        }
        update(1, 0, n-1, i, dp[i]);
    }
    cout << dp[n] << endl;

}

int main()
{
    //making data IO Fast
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    /****************************/
    solve();
    return 0;
}



Measured memory_bytes: 9304
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1061109567
#define pb push_back
#define in(s) freopen(s,"r",stdin);
#define out(s) freopen(s,"w",stdout);
#define fi first
#define se second
#define bw(i,r,l) for (int i=r-1;i>=l;i--)
#define fw(i,l,r) for (int i=l;i<r;i++)
#define fa(i,x) for (auto i:x)
using namespace std;
const int N=1e5+5;
int n,L,q,x[N],sp[N][20];
int get(int x,int y) {
	int ans=1;
	bw (i,18,0) if (sp[x][i]!=-1&&sp[x][i]<y) x=sp[x][i],ans+=(1<<i);
	return ans;
}
signed main() {
	//in("aome.inp");
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin>>n;
	fw (i,0,n) cin>>x[i];
	cin>>L>>q;
	memset(sp,-1,sizeof(sp));
	fw (i,0,n) sp[i][0]=upper_bound(x,x+n,x[i]+L)-x-1;
	fw (j,1,18) fw (i,0,n) if (sp[i][j-1]!=-1) sp[i][j]=sp[sp[i][j-1]][j-1];
	while (q--) {
		int a,b; 
		cin>>a>>b;
		if (a>b) swap(a,b);
		cout<<get(a-1,b-1)<<"\n";
	}
	return 0;
}

Measured memory_bytes: 9088
#include<stdio.h>
#define N 100
#define INFTY 10000000

int main(){
  int n,i,j,k,l,p[N + 1],m[N + 1][N + 1],A;

  scanf("%d",&n);

  for(i = 1 ; i <= n ; i++){
    scanf("%d",&p[i - 1]);
    scanf("%d",&p[i]);
  }
  
  for(i = 1 ; i <= n ; i++){
    m[i][i] = 0;
  }
  for(l = 2 ; l <= n ; l++){
    for(i = 1 ; i <= n - l + 1 ; i++){
      j = i + l - 1;
      m[i][j] = (1 << 21);
      for(k = i ; k <= j - 1 ; k++){
	A = m[i][k] + m[k + 1][j] + p[i - 1]*p[k]*p[j];
	if(m[i][j] > A)m[i][j] = A;
      }
    }
  }
  printf("%d\n",m[1][n]);
  return 0;
}



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

const long long mod = 1E9 + 7;

int main() {
	int h, w;
	while ( cin >> h >> w ) {
		string grid[h];
		bool cont = true;
		
		for (int i = 0; i < h; ++i) cin >> grid[i];
		
		long long ways[ h+5 ][ w+5 ];
		
		for (int i = 0; i < h; ++i) if ( cont and grid[i][0] == '.' ) ways[i][0] = 1; else cont = false, ways[i][0] = 0; cont = true;
		for (int i = 0; i < w; ++i) if ( cont and grid[0][i] == '.' ) ways[0][i] = 1; else cont = false, ways[0][i] = 0; cont = true;
		
		for (int i = 1; i < h; ++i) {
			for (int j = 1; j < w; ++j) {
				if ( grid[i][j] == '#' ) ways[i][j] = 0;
				else ways[i][j] = ( ways[ i-1 ][j] + ways[i][ j-1 ] ) % mod;
			}
		}
		
//		for (int i = 0; i < h; ++i) { for (int j = 0; j < w; ++j) cout << ways[i][j] << ' '; cout << '\n'; }
		
		cout << ways[ h-1 ][ w-1 ] << '\n';
	}
	return 0;
}


Measured memory_bytes: 9216
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define INF 2e9
signed main(){
    cin.tie(0);
    ios::sync_with_stdio;
    string s,s2,s3;
    int a,b,x,count=0;
    cin>>s;
    rep(i,3){
        if(s[i]=='o')
        count++;
    }
    cout<<700+(count*100);
    return(0);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long int
mt19937 rng(std::chrono::duration_cast<std::chrono::nanoseconds>(chrono::high_resolution_clock::now().time_since_epoch()).count());
#define mp make_pair
#define pb push_back
#define F first
#define S second
const int N=400015;
#define M 1000000007
#define double long double
#define BINF 100000000000000
#define init(arr,val) memset(arr,val,sizeof(arr))
#define MAXN 15000001
#define deb(x) cout << #x << " " << x << "\n";
const int LG = 22;


#undef int
int main() {
#define int long long int
ios_base::sync_with_stdio(false); 
cin.tie(0); 
cout.tie(0);

	
	int a, b;
	cin >> a >> b;
	string s, r;
	for(int i = 0; i < b; i++)
		s += ('0' + a);
	for(int i = 0; i < a; i++)
		r += ('0' + b);
	cout << min(s, r);


	
 
return 0;
}

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vll = vector<ll>;
template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

string sn;
int N;
int p10[10];
int calc(int a, int b) {
    int cnt = 0;
    for (int i = 1; i <= (int)sn.size() - 2; i++) {
        for (int j = 0; j < p10[i]; j++) {
            string s = to_string(j);
            string t;
            while (s.size() + t.size() < i) t += '0';
            s = (char)(a + '0') + t + s + (char)(b + '0');
            int val = stoi(s);
            if (val > N) break;
            cnt++;
        }
    }
    return (cnt);
}

int main() {
    cin >> sn;
    N = stoi(sn);
    if (N <= 9) {
        cout << N << endl;
        return (0);
    }
    p10[0] = 1;
    for (int i = 1; i < 10; i++) p10[i] = p10[i - 1] * 10;

    int cnt = 9;
    for (int a = 1; a <= 9; a++) {
        cnt += 2 * calc(a, a);
        if (N >= a * 10 + a) cnt += 2;
        for (int b = 1; b <= 9; b++) {
            if (a * 10 + b <= N && b * 10 + a <= N) cnt++;
            int aa = calc(a, b);
            int bb = calc(b, a);
            cnt += aa * bb + aa + bb;
        }
    }
    cout << cnt << endl;
    return (0);
}


Measured memory_bytes: 256
N, K = map(int, input().split())
ary = [0] + list(map(int, input().split()))
ary.sort()
zero = ary.index(0)
a = [abs(i - zero) for i in range(N + 1)]
ary.pop(zero)
ans = float("Inf")
for i in range(N - K + 1):
    b = N - i - 1
    d = abs(ary[i])
    if a[i] >= K:
        ans = min(ans, d)
    ans = min(ans, d + abs(ary[i] - ary[i + K - 1]))
    d = abs(ary[b])
    if a[b] >= K:
        ans = min(ans, d)
    ans = min(ans, d + abs(ary[b] - ary[b - K + 1]))
print(ans)

Measured memory_bytes: 14564
#include <stdio.h>
#include <time.h>
#include <algorithm>
#include <cfloat>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
typedef long long int          ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

struct Point {
    Point(double arg_x, double arg_y) {
        x = arg_x;
        y = arg_y;
    }

    Point() { x = y = 0.0; }

    Point operator+(Point p) { return Point(x + p.x, y + p.y); }
    Point operator-(Point p) { return Point(x - p.x, y - p.y); }
    Point operator*(double a) { return Point(a * x, a * y); }
    Point operator/(double a) { return Point(x / a, y / a); }

    double abs() { return sqrt(norm()); }
    double norm() { return x * x + y * y; }

    bool operator<(const Point &p) const {
        return x != p.x ? x < p.x : y < p.y;
    }

    bool operator==(const Point &p) const {
        return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS;
    }

    double x, y;
};
typedef Point Vector;

struct Circle {
    Point  center;
    double r;
};

double arg(Vector p) { return atan2(p.y, p.x); }

Vector polar(double a, double r) { return Point(cos(r) * a, sin(r) * a); }

double norm(Vector a) { return a.x * a.x + a.y * a.y; }

double abs(Vector a) { return sqrt(norm(a)); }

vector<Point> getCrossPoints(Circle c1, Circle c2) {
    vector<Point> res;

    double d = abs(c1.center - c2.center);
    double a = acos((c1.r * c1.r + d * d - c2.r * c2.r) / (2 * c1.r * d));
    double t = arg(c2.center - c1.center);

    res.push_back(Point(c1.center + polar(c1.r, t + a)));
    res.push_back(Point(c1.center + polar(c1.r, t - a)));

    return res;
}

int main() {
    Circle c1, c2;

    scanf("%lf %lf %lf", &c1.center.x, &c1.center.y, &c1.r);
    scanf("%lf %lf %lf", &c2.center.x, &c2.center.y, &c2.r);

    vector<Point> ans = getCrossPoints(c1, c2);

    if ((ans[0].x > ans[1].x) ||
        (fabs(ans[0].x - ans[1].x) < EPS && ans[0].y > ans[1].y)) {
        swap(ans[0], ans[1]);
    }

    printf("%.10lf %.10lf %.10lf %.10lf\n", ans[0].x, ans[0].y, ans[1].x,
           ans[1].y);

    return 0;
}



Measured memory_bytes: 3636
#include <stdio.h>

int main(){

  int x, y, z;

  scanf("%d %d", &x, &y);

  if(x < y){
    z = x;
    x = y;
    y = z;
  }

  while(y > 0){
    z = x%y;
    x = y;
    y = z;
  }

  printf("%d\n", x);
   
  return 0;
}

    

Measured memory_bytes: 1848
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
using PP = pair<int,pair<int,int>>;
using T = tuple<string,int,int>;
const string EMP = " ";
const ll INF = 1LL<<60;
const ll MOD = 1000000007;

ll memo1[2020200],memo2[2020200];

ll B(ll x){
  ll res = 1, k = MOD - 2, y = x;
  while(k){
    if(k&1){
      res *= y;
      res %= MOD;
    }
    y *= y;
    y %= MOD;
    k >>= 1;
  }
  return res;
}

void init(){
  memo1[0] = 1;
  for(ll i = 1; i < 2020200; i++) memo1[i] = (memo1[i-1] * i) % MOD;
  for(ll i = 0; i < 2020200; i++) memo2[i] = B(memo1[i]);
}

ll C(ll n, ll r){
  ll a = memo1[n];
  ll b = memo2[r];
  ll c = memo2[n-r];
  ll res = a * b;
  res %= MOD;
  res *= c;
  res %= MOD;
  return res;
}

ll BB(ll x, ll y){
  ll res = 1;
  while(y){
    if(y&1){
      res *= x;
      res %= MOD;
    }
    x *= x;
    x %= MOD;
    y >>= 1;
  }
  return res;
}
int main(){
  ll k,n;
  string s;
  cin >> k >> s;
  n = s.size();
  init();
  ll ans = 0, now = 0;
  for(ll i = 0; i <= k; i++){
    now = BB(25,i);
    now %= MOD;
    now *= BB(26,k-i);
    now %= MOD;
    now *= C(i+n-1, n-1);
    now %= MOD;
    ans += now;
    ans %= MOD;
  }
  cout << ans << endl;
  return 0;
}


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

typedef int64_t ll;

template <class T1, class T2>
using dict = std::unordered_map<T1, T2>;

int main(){
    int N,A,B;
    cin >> N >> A >> B;
    ll ans = 0;
    int sum;
    for (int i=1; i<=N;i++){
        string s = to_string(i);
        sum = 0;
        for (int j=0;j<s.size();j++){
            sum += s.at(j) - '0';
        }
        if (A<= sum && sum<=B) ans+=i;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 256
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>
#include <string>
#include <cstring>
#include <sstream>
#include <functional>

using namespace std;

int N;
vector<int> A;

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

    cin >> N;
    A.resize(N);
    for (int i = 0; i < N; i++)
        cin >> A[i];

    vector<int> sol;

    for (int steps = 1; steps <= N; steps++) {
        int idx = -1;

        for (int i = 0; i < A.size(); i++) {
            if (A[i] == i + 1) {
                idx = i;
            }
        }

        if (idx == -1) {
            cout << -1 << "\n";
            return 0;
        }

        A.erase(A.begin() + idx);
        sol.push_back(idx + 1);
    }

    reverse(sol.begin(), sol.end());

    for (auto x : sol)
        cout << x << " ";
    cout << "\n";

    return 0;
}

Measured memory_bytes: 256