akhauriyash/Code-Regression huggingface dataset:
N,M = map(int,input().split())
X = list(map(int,input().split()))
Y = list(map(int,input().split()))
MOD = 10**9+7

w_sum = 0
for i in range(N//2):
    times = N-1 - i*2
    w = X[-1-i] - X[i]
    w_sum += (w*times)%MOD
    w_sum %= MOD

h_sum = 0
for i in range(M//2):
    times = M-1 - i*2
    h = Y[-1-i] - Y[i]
    h_sum += (h*times)%MOD
    h_sum %= MOD

print((w_sum * h_sum) % MOD)

Measured memory_bytes: 18556
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
using P = pair<int,int>;
ll GetDigit(ll num){
  return to_string(num).length();
}
int main()
{
  ll N,M;
  cin >> N >> M;
  vector<vector<ll>> A(M,vector<ll>(3));
  REP(i, M){
      cin >> A.at(i).at(0) >> A.at(i).at(1);
      A.at(i).at(2)=i;
  }
  sort(ALL(A));
  vector<string> B(M);
  int cnt = 1;
  REP(i,M){
    if(i!=0&&A.at(i).at(0)==A.at(i-1).at(0)){
      cnt++;
    }else if(i!=0&&A.at(i).at(0)!=A.at(i-1).at(0)){
      cnt=1;
    }
    string x;
    int y = 6-GetDigit(A.at(i).at(0));
    REP(j,y){
      x.push_back('0');
    }
    x+=to_string(A.at(i).at(0));
    int z = 6-GetDigit(cnt);
    REP(j,z){
      x.push_back('0');
    }
    x+=to_string(cnt);
    B[A.at(i).at(2)]=x;
  }

  REP(i,M){
    cout << B[i] << endl;
  }
}

Measured memory_bytes: 14080
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <map>
#include <stack>
#include <bitset>
#include <numeric> //lcm
#include <iomanip> //double精度 setprecision

using namespace std;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = n-1; i >= 0; --i)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)
#define rrep1(i,n) for(int i = (n); i >= 1; --i)
#define REP(i,n,m) for(int i = (n); i < (m); ++i)
#define all(vec) (vec).begin(),(vec).end()

#define debug(vec) for(auto v : vec) cerr << v << " "; cerr << endl;
#define debug2D(vec2D) for(auto vec : vec2D) { for (auto v : vec) cerr << v << " "; cerr << endl; } 
#define debugP(vec) for(auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl;
#define debug2DP(vec2D) for(auto vec : vec2D) { for (auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl; } 

const char en = '\n';

typedef long long ll;

constexpr ll INF = 1000000000; //10^10
//const ll MOD = 998244353;
constexpr ll MOD = 1000000007;

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

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

  ll n; cin >> n;
	vector<ll> a(n+1);
	rep(i,n+1) cin >> a[i];

  bool isZero = true;
	rep(i, n + 1) {
		if (a[i] != 0) {isZero = false; break;}
	}

	if (isZero || a[0] > 1) {
		cout << -1 << endl;
		return 0;
	}

	vector<ll> sum(n+1);
	sum[n] = a[n];
	rrep(i, n) {
		sum[i] += sum[i+1] + a[i];
	}

	vector<ll> dep(n + 1, -1);
	dep[0] = 1;
	rep(d, n) {
	  if ((dep[d] - a[d])*2 < a[d+1]) {cout << -1 << endl; return 0;}
	  dep[d+1] = min(sum[d+1], (dep[d] - a[d])*2);
	}

	//debug(sum);
	//debug(dep);

	ll ans = 0;
	rep(d,n+1) ans += dep[d];
	cout << ans << endl;
}


Measured memory_bytes: 5580
N = int(input())
As = list(map(int, input().split()))

Bs = [0]*N

Bs[0] = sum(As[::2]) - sum(As[1::2])

for i in range(1,N):
  Bs[i] = 2*As[i-1] - Bs[i-1]
  
Bs = map(str, Bs)
print(" ".join(Bs))

Measured memory_bytes: 84324
# ABC 105: B – Cakes and Donuts
n = int(input())

can_buy = 'No'

for i in range(n // 4 + 1):
    
    for j in range(n // 7 + 1):

        if 4 * i + 7 * j == n:
            can_buy = 'Yes'
            break
    
    if can_buy == 'Yes':
        break

print(can_buy)

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

int main(){
    char c;
    cin >> c;
    if(c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o'){
        cout << "vowel" << endl;
    }else{
        cout << "consonant" << endl;
    }
    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
double score(vector<ll> &x, vector<ll> &y, vector<char> &d, int n, double t) {
  double tmp = 10000000000000000.0;
  double xma = -tmp, xmi = tmp, yma = -tmp, ymi = tmp;
  double res = 0;
  for(int i=0;i<n;++i) {
    double nowx = x[i], nowy = y[i];
    switch(d[i]) {
      case 'U':
        nowy += t;
      break;
      case 'D':
        nowy -= t;
      break;
      case 'L':
        nowx -= t;
      break;
      case 'R':
        nowx += t;
      break;
      default:
      assert(false);
      break;
    }
    xma = max(xma, nowx);
    xmi = min(xmi, nowx);
    yma = max(yma, nowy);
    ymi = min(ymi, nowy);
  }
  res = (xma - xmi) * (yma - ymi);
  return res;
}
int main() {
  cin.tie(0);
  cout << fixed << setprecision(10);
  int n; cin >> n;
  vector<ll> x(n), y(n);
  vector<char> d(n);
  for(int i=0;i<n;++i) {
    cin >> x[i] >> y[i] >> d[i];
  }
  int l = 0, r = 2 * INF;
  double mi = score(x, y, d, n, 0);
  mi = min(mi, score(x, y, d, n, 0.5));
  while(r - l > 1) {
    ll mid = (l + r) / 2;
    double tmp1 = score(x, y, d, n, mid);
    double tmp2 = score(x, y, d, n, mid+1);
    double tmp3 = score(x, y, d, n, mid+0.5);
    mi = min(mi, (double)(min(tmp1, tmp2)));
    if(tmp3 < tmp1 && tmp3 < tmp2) {
      mi = min(mi, tmp3);
      break;
    } else if(tmp1 > tmp2) {
      l = mid;
    } else {
      r = mid;
    }
  }
  cout << mi << endl;
}


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

using Graph = vector<vector<int>>;

int main(void){
  int n,m; cin >> n >> m;
  Graph g(n);
  rep(i,m){
    int a,b; cin >> a >> b;
    a--;b--;
    g.at(a).push_back(b); g.at(b).push_back(a);
  }

  int INF = 1001001;
  vector<int> dist(n,INF);
  queue<int> q;

  dist[0]=0;
  q.push(0);
  while(!q.empty()){
    int count=0;
    int v = q.front();q.pop();
    for(auto nv : g[v]){
      if(dist[nv]!=INF) continue;

      dist[nv]=dist[v]+1;
      q.push(nv);
    }
  }
  if(dist[n-1]==2) cout << "POSSIBLE" << endl;
  else cout << "IMPOSSIBLE" << endl;
  
  return 0;
}


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

#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(obj) obj.begin(), obj.end()
#define fcout cout << setprecision(10)

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

const int iINF = 1e9;
const long long llINF = 1e18;
const int MOD = 1e9 + 7;

using namespace std;

int main() { 
    long long N;
    cin >> N;
    if (N % 2 == 1 || N == 0) {
        cout << 0 << endl;
    } else {
        long long res = 0;
        N /= 2;
        while(N) {
            res += N / 5;
            N /= 5;
        }
        cout << res << endl;
    }
    return 0; 
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define INF 0x6fffffff
#define INFL 0x6fffffffffffffffLL

int main() {
	ll		a,b,c,i,j,k,n,m,x,y,ans = 0;
	string	s;

	cin >> k >> a >> b;
	ll K = k;
	while(K<a) {
		K += k; 
	}
	if (K<=b) {
		cout << "OK" << endl;
	} else {
		cout << "NG" << endl;

	}

}


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

int main(void){
    int n;
    cin >> n;
    string s;
    if(n > 999){
        s = "ABD";
    }else{
        s = "ABC";
    }
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 256
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
b=Counter(a).most_common()
ans=0
for i in range(len(b)):
    if b[i][0]>b[i][1]:
        ans +=b[i][1]
    else:
        ans +=b[i][1]-b[i][0]
print(ans)

Measured memory_bytes: 21224
#include <iostream>
#include <string>
#include <math.h> 
#include <algorithm>
using namespace std;

//素数判定
bool isPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
    return true;
}

int main() {
  long X;
  
  cin >> X;

  int i = X;
  while(!isPrime(i)){
    i++;
  }
  cout << i <<endl;
  return 0;
}


Measured memory_bytes: 256
/*
A2766
title:Hamming Distance
@kankichi573
*/
#include <stdio.h>
#include <string.h>

int N,d;
char X[1001],R[1001];

int main()
{
  int i,j;

  scanf("%d",&N);
  scanf("%s",X);
  scanf("%d",&d);

  memcpy(R,X,sizeof(R));
  for(i=0;i<N && d>0;i++)
    {
      if(R[i]=='0')
	{
	  R[i]='1';
	  d--;
	}
    }
  if(d>0)
    for(i=N-1;i>=0 && d>0;i--)
      if(X[i]=='1')
	{
	  R[i]='0';
	  d--;
	}
  for(i=0;i<N;i++)
    printf("%c",R[i]);
  printf("\n");
  return(0);
}

Measured memory_bytes: 572
#include <iostream>
using namespace std;
int main(void){
    double high,max=0,min=1000000;
    for(int i=0; i<50; i++){
        cin >> high;
        if(max<high)        max=high;
        else if(high<min)   min=high;
    }
    cout << max-min << endl;
}


Measured memory_bytes: 3196
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


int main() {
    double r;
    cin >> r;
  cout << fixed << setprecision(10);
    cout << 2 * 3.14 * r << endl;
    return 0;
}


Measured memory_bytes: 3788
import java.util.Scanner;

public class Main {
	/**
	 * Thin
	 * @param 1 ≦ H,W ≦ 100
	 * @param Cij . or *
	 */
	public static void main(String... args) {
		try (Scanner sc = new Scanner(System.in)) {
			int H = sc.nextInt();
			int W = sc.nextInt();
			String c[] = new String[H];
			for (int i = 0; i < H; i++) {
				c[i] = sc.next();
			}
			for (int i = 0; i < H; i++) {
				System.out.println(c[i]);
				System.out.println(c[i]);
			}
		}
	}
}


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

using namespace std;

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

int main() {
    int A, B;
    scanf("%d%d", &A, &B);
    int ans[3] = {A * B, A + B, A - B};
    printf("%d\n", *max_element(ans, ans + 3));
}



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

int main() {
  int n;
  cin >> n;
  
  int x = 0, y = 0, z = 0;
  for (int i = 1; i <= n; ++i) {
    int p;
    cin >> p;
    if (p != i) {
      x++;
      if (x > 2) {
        puts("NO");
        return 0;
      }
    }
  }
  puts("YES");
  return 0;
}

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

const int mod = 1e9 + 7;

template <const int32_t MOD>
struct modint {
    int32_t value;
    modint() = default;
    modint(int32_t value_) : value(value_) {}
    inline modint<MOD> operator + (modint<MOD> other) const { int32_t c = this->value + other.value; return modint<MOD>(c >= MOD ? c - MOD : c); }
    inline modint<MOD> operator - (modint<MOD> other) const { int32_t c = this->value - other.value; return modint<MOD>(c <    0 ? c + MOD : c); }
    inline modint<MOD> operator * (modint<MOD> other) const { int32_t c = (int64_t)this->value * other.value % MOD; return modint<MOD>(c < 0 ? c + MOD : c); }
    inline modint<MOD> & operator += (modint<MOD> other) { this->value += other.value; if (this->value >= MOD) this->value -= MOD; return *this; }
    inline modint<MOD> & operator -= (modint<MOD> other) { this->value -= other.value; if (this->value <    0) this->value += MOD; return *this; }
    inline modint<MOD> & operator *= (modint<MOD> other) { this->value = (int64_t)this->value * other.value % MOD; if (this->value < 0) this->value += MOD; return *this; }
    inline modint<MOD> operator - () const { return modint<MOD>(this->value ? MOD - this->value : 0); }
    modint<MOD> pow(uint64_t k) const { modint<MOD> x = *this, y = 1; for (; k; k >>= 1) { if (k & 1) y *= x; x *= x; } return y; }
    modint<MOD> inv() const { return pow(MOD - 2); }  // MOD must be a prime
    inline modint<MOD> operator /  (modint<MOD> other) const { return *this *  other.inv(); }
    inline modint<MOD> operator /= (modint<MOD> other)       { return *this *= other.inv(); }
    inline bool operator == (modint<MOD> other) const { return value == other.value; }
    inline bool operator != (modint<MOD> other) const { return value != other.value; }
    inline bool operator < (modint<MOD> other) const { return value < other.value; }
    inline bool operator > (modint<MOD> other) const { return value > other.value; }
};
template <int32_t MOD> modint<MOD> operator * (int64_t value, modint<MOD> n) { return modint<MOD>(value) * n; }
template <int32_t MOD> modint<MOD> operator * (int32_t value, modint<MOD> n) { return modint<MOD>(value % MOD) * n; }
template <int32_t MOD> istream & operator >> (istream & in, modint<MOD> &n) { return in >> n.value; }
template <int32_t MOD> ostream & operator << (ostream & out, modint<MOD> n) { return out << n.value; }

using mint = modint<mod>;

const int N = 2020;
mint dp[N];
int32_t main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	dp[0] = 1;
	for (int i = 3; i <= n; i++) {
		for (int j = 3; j <= i; j++) {
			dp[i] += dp[i - j];
		}
	}
	cout << dp[n] << '\n';
    return 0;
}

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

#ifdef _PRINTDEBUG
  #include "lib/printdebug.hpp"
#else
  #define printdebug(...) 1
#endif
#define I1000000007 (1000000007)
#define I998244353   (998244353)
#define IINF             (1<<28)
#define LINF           (1LL<<60)
#define ALL(a)         (a).begin(), (a).end()
#define rep(i, n)      REP(i, 0, (n))
#define repc(i, n)     REPC(i, 0, (n))
#define REP(i, n, m)   for (int i = (int)(n); i <  (int)(m); i++)
#define REPC(i, n, m)  for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
#define yesno(cond)       YESNO((cond), "Yes", "No")
#define YESNO(cond, a, b) cout << ((cond) ? (a) : (b)) << "\n"
template<class T> inline bool chmin(T& a, const T& b) {
  if (a > b) { a = b; return true; } else return false;
}
template<class T> inline bool chmax(T& a, const T& b) {
  if (a < b) { a = b; return true; } else return false;
}

namespace solver {
  using namespace std;
  using ll = long long;

  ll S;

  void init() {
    cin >> S;
  }

  void solve() {
    ll i10_9 = 1000000000;
    ll X = S % i10_9;
    ll Y = (S - X) / i10_9;
    if(X>0) X = abs(X-i10_9), Y += 1;
    cout << 0 << " " << 0 << " " << i10_9 << " " << 1 << " " << X << " " << Y << "\n";
  }
}

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

Measured memory_bytes: 256
import Control.Applicative
import Control.Monad
import Control.Monad.ST
import qualified Data.ByteString as BS
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
import qualified Data.Set as Set
--import qualified Data.Sequence as Sequence
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
--import Data.Array
--import Data.Array.Unboxed
import Data.Array.IArray
import Data.Array.MArray
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
-- import System.IO.Unsafe

-- templete
readInt = read :: String -> Int
readInteger = read :: String -> Integer
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getInteger = readLn :: IO Integer
getIntegers = map readInteger . words <$> getLine
getDouble = readLn :: IO Double
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
binMap :: (a -> a -> b) -> [a] -> [b]
binMap f (x:xs@(y:_)) = f x y : binMap f xs
binMap _ _ = []
splitRec :: Int -> [a] -> [[a]]
splitRec _ [] = []
splitRec n xs = let (y,ys) = splitAt n xs in y : splitRec n ys
infixl 7 `divCeil`
divCeil :: Integral a => a -> a -> a
x `divCeil` y = (x+y-1) `div` y
coverC :: Ord a => (a, a) -> a -> Bool
coverC (l,r) x = l<=x && x<=r
coverH :: Ord a => (a, a) -> a -> Bool
coverH (l,r) x = l<=x && x<r
-- templete

f n = minimum [as x + bs y + cs z | z <- [0..n`div`500], y <- [0..(n-500*z)`div`300], let (x, r) = divMod (n-500*z-300*y) 200, r==0]
  where
    as x = let (q,r) = divMod x 5 in 1520 * q + 380 * r
    bs x = let (q,r) = divMod x 4 in 1870 * q + 550 * r
    cs x = let (q,r) = divMod x 3 in 2244 * q + 850 * r

main = takeWhile (/=0) . map readInt . lines <$> getContents >>= mapM_ (print . f)


Measured memory_bytes: 4060
fun main(args: Array<String>) = println(run {
    val (x1, y1, x2, y2) = readLine()!!.split(" ").map { it.toInt() }
    val vec12 = Pair(x2-x1, y2-y1)
    val vec23 = Pair(-vec12.second, vec12.first)
    "${x2 + vec23.first} ${y2 + vec23.second} ${x1 + vec23.first} ${y1 + vec23.second} "
})


Measured memory_bytes: 37820
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int h = scan.nextInt();
		int a = scan.nextInt();
		
		if(h%a !=0) {
			System.out.println(h/a+1);
		}else {
			System.out.println(h/a);
		}
	}
}





Measured memory_bytes: 21844
import bisect
n=int(input())
s= list(input())

# それぞれのインデック格納
r=[]
b=[]
g=[]

for i in range(n):
    if s[i]=='R':
        r.append(i)
    elif s[i]=='B':
        b.append(i)
    else:
        g.append(i)

ans=0
q=len(g)
if q==0:
    print(0)
    exit()

for i in range(len(r)):
    for j in range(len(b)):
        if r[i]<b[j]:
            x=b[j]+b[j]-r[i]
            y=r[i]-(b[j]-r[i])
        else:
            x=r[i]+r[i]-b[j]
            y=b[j]-(r[i]-b[j])

        if 0<=x and x<=n-1:
            z=bisect.bisect_right(g,x)-1
            if g[z]==x:
                ans-=1
        if 0<=y and y<=n-1:
            z=bisect.bisect_right(g,y)-1
            if g[z]==y:
                ans-=1
        if (r[i]+b[j])%2==0 and 0<=(r[i]+b[j])//2 and (r[i]+b[j])//2<=n-1:
            w=(r[i]+b[j])//2
            z=bisect.bisect_right(g,w)-1
            if g[z]==w:
                ans-=1
        ans+=q
print(ans)

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

int main()
{
    int n;
    cin >> n;
    int h[n];
    int i, j, k; 
    for(i = 1; i <= n; i++ ){
        cin >> h[i];
    }

    for( i=n-1; i>0; i-- )
    {
        if ( h[i+1] - h[i] >= 0 )
        {
        }
        else if ( h[i+1] - h[i] == -1 )
        {
            h[i] --;
        }
        else
        {
            cout << "No" << endl;
            return 0;
        }
    }

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


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

typedef long long ll;

int main() {
  int n;
  cin >> n;
  vector<vector<int>> F(n, vector<int>(10));
  vector<vector<int>> P(n, vector<int>(11));
  rep(i,n) rep(j,10) cin >> F[i][j];
  rep(i,n) rep(j,11) cin >> P[i][j];

  ll mx=-1e18;
  for ( int mask=1; mask<(1<<10); mask++ ) {
    ll res=0;
    for ( int i=0; i<n; i++ ) {
      int c=0;
      for ( int j=0; j<10; j++ ) {
        if ( (mask>>j&1)&&F[i][j] ) c++; 
      }
      res+=P[i][c];
    }
    mx=max(mx,res);
  }
  cout << mx << '\n';
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
///...................................*****.................................................///
///        Author :  MD. Rakibul Islam ( mmdrakibul2912@gmail.com )                         ///
///                  Department of Computer Science                                         ///
///                  & Engineering,                                                         ///
///                  Comilla University , Bangladesh.                                       ///
///...................................*****.................................................///
using namespace std;
int main()
{
    int n, m, i, j, k, l;
    cin>>n;
    int a[n+2];
    double b[n+2]={0};
    for(i=0; i<n; i++)
    {
        cin>>a[i];
        b[i]=1/(a[i]*1.0);
    }
    double sum=0.00;
    for(i=0; i<n; i++)
    {
        sum+=b[i];
    }
    cout<<1/sum<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int MAX(int a,int b){return a<b?b:a;}
int main(){
  int a,b,c,i,j,max;
  while(scanf("%d %d %d",&a,&b,&c),a){
    for(i=max=1;i<c;i++){
      for(j=1;j<c;j++){
	if((i*(100+a)/100)+(j*(100+a)/100)-c)continue;
	max=MAX(max,i*(100+b)/100+j*(100+b)/100);
      }
    }
    printf("%d\n",max);
  }
  return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
typedef long long ll;
#define MOD 1000000007
#define INF -99999999 
using namespace std;
 
int main()
{
    ll A,B,C; cin >> A >> B >> C;
    int ans = 0;
    if(A==B and B==C){
        if(A%2==0) cout << -1 << endl;
        else cout << 0 << endl;
        return 0;
    }
    else{
        while(true){
            if(A%2 != 0 or B%2 != 0 or C%2 != 0){
                cout << ans << endl;
                return 0;
            }
            else{
                ll tempA,tempB,tempC;
                tempA = (B+C)/2;
                tempB = (C+A)/2;
                tempC = (A+B)/2;
                A = tempA;
                B = tempB;
                C = tempC;
                ans++;
            }
            
        }
    }
}

Measured memory_bytes: 256
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

typedef long double ld;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const long long infll = (long long) 1.01e18;
const ld eps = 1e-9;
const ld pi = acos((ld) -1);

#ifdef DEBUG
mt19937 mrand(300); 
#else
mt19937 mrand(chrono::steady_clock::now().time_since_epoch().count()); 
#endif

int rnd(int x) {
  return mrand() % x;
}

void precalc() {
}

const int maxn = (int) 1e5 + 5;
int n;
int ls[maxn], rs[maxn];

bool read() {
  if (scanf("%d", &n) < 1) {
    return false;
  }
  for (int i = 0; i < n; i++) {
    scanf("%d%d", &ls[i], &rs[i]);
    ls[i]--;
  }
  return true;
}

pair<int, int> ps[maxn];

void solve() {
  int rr = inf, ll = 0;
  for (int i = 0; i < n; i++) {
    rr = min(rr, rs[i]);
    ll = max(ll, ls[i]);
  }
  for (int i = 0; i < n; i++) {
    ps[i] = make_pair(max(0, rr - ls[i]), max(0, rs[i] - ll));
  }
  sort(ps, ps + n);
  int mn = inf;
  int res = 0;
  for (int i = 0; i + 1 < n; i++) {
    mn = min(mn, ps[i].second);
    res = max(res, ps[i + 1].first + mn);
  }
  for (int i = 0; i < n; i++) {
    res = max(res, ps[0].first + ps[i].second);
  }
  for (int i = 0; i < n; i++) {
    res = max(res, (rs[i] - ls[i]) + max(0, rr - ll));
  }
  printf("%d\n", res);
}

int main() {
  precalc();
#ifdef DEBUG
  assert(freopen(TASK ".in", "r", stdin));
  assert(freopen(TASK ".out", "w", stdout));
#endif
  while (read()) {
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


Measured memory_bytes: 1792
N,L = map(int,input().split())
A = 0
cnt = 0
M = []

for i in range(1,N+1):
    A = L+i-1
    M.append(A)
    if A == 0:
        cnt += 1

B = sum(M)

if cnt == 1:
    print(B)
elif B > 0:
    print(B - min(M))
else:
    print(B - max(M))

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

#define FOR(a,b,c) for(int a=(b),a##_end__=(c);a<a##_end__;a++)
#define chkmin(a,b) (a)=min((a),(b))
#define chkmax(a,b) (a)=max((a),(b))
#define x first
#define t second
#define ll long long 
#define db double
#define pb push_back
#define SZ(x) ((int)x.size())
#define M 3

void Rd(int &res){
    char c;res=0;
    while(c=getchar(),c<48);
    do res=(res<<3)+(res<<1)+(c^48);
    while(c=getchar(),c>47);
}

int a[M];
int n=3;

int main(){
    Rd(a[0]);Rd(a[1]);Rd(a[2]);
    sort(a,a+n);
    printf("%d",a[0]+a[1]);
    return 0;
}

Measured memory_bytes: 256
void main()
{
    import std.array, std.stdio, std.string, std.conv;
    auto buf = readln.chomp.split.to!(int[]);
    auto window = buf[0];
    auto curtain = buf[1] << 1;
    if (window > curtain)
        (window - curtain).writeln;
    else
        0.writeln;
}


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

public static class Prg{
    public static Scanner sc = new Scanner();
    public static void Main(){
        var n = sc.NextDouble();
        var r = (int)Math.Sqrt(n);
        Console.WriteLine(r*r);
    }
}

public static class Extension{
    public static IEnumerable<int> To(this int from, int to){
        return Enumerable.Range(from, to);
    }

    public static void Times(this int times, Action<int> action){
        0.To(times).ToList().ForEach(x => action(x));
    }
}
public class Scanner{
    private string line;
    private string[] token;
    private int cursole = 0;
    
    public string ReadLine(){
        line = Console.ReadLine();
        token = line.Split(' ');
        cursole = 0;
        return line;    
    }
    
    public string Next(){
        if(token == null) ReadLine();
        if(token.Length <= cursole) ReadLine();
        var ret = token[cursole];
        ++cursole;
        return ret;
    }

    public IEnumerable<double> NextDoubleList(){
        return NextList().Select(s => Double.Parse(s));
    }

    public int NextInt(){return Int32.Parse(Next());}
    
    public long NextLong(){return Int64.Parse(Next());}

    public double NextDouble(){return Double.Parse(Next());}

    public IEnumerable<string> NextList(){
        ReadLine();
        cursole = Int32.MaxValue;
        return token;
    }
    
    public IEnumerable<int> NextIntList(){
        return NextList().Select(s => Int32.Parse(s));
    }
}

Measured memory_bytes: 11220
x, y = map(int, input().split())


def calc(xx, yy):
    if yy >= xx:
        return yy - xx
    else:
        return float('inf')


x1, y1 = x, y
x2, y2 = -x, y
x3, y3 = x, -y
x4, y4 = -x, -y

ans1 = calc(x1, y1)
ans2 = calc(x2, y2)+1
ans3 = calc(x3, y3)+1
ans4 = calc(x4, y4)+2

print(min(ans1, ans2, ans3, ans4))

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

const int AMAX = 100000;
int cnt[AMAX + 10];

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

    rep(i, AMAX + 2) cnt[i] = 0;
    int a;
    rep(i, N) {
        cin >> a;
        if (a > 0) cnt[a-1]++;
        cnt[a]++, cnt[a+1]++;
    }

    int ans = 0;
    rep(i, AMAX+2) ans = max(ans, cnt[i]);

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



Measured memory_bytes: 768
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <climits>
using namespace std;

int count(vector<long long> &v){
    int cnt = 0;
    int N = v.size();
    while(true){
        long long mx = -1;
        for(int i=0; i<N; i++)
            mx = max(mx, v[i]);
        if(mx <= N-1) break;

        mx = -1;
        int j;
        for(int i=0; i<N; i++){
            if(v[i] > mx){
                mx = v[i];
                j = i;
            }
        }
        v[j] -= N+1;
        for(int i=0; i<N; i++) v[i]++;

        cnt++;
    }
    return cnt;
}

long long solve(vector<long long> a){
    int N = a.size();
    long long K = 0;
    while(true){
        sort(a.begin(), a.end(), greater<long long>());
        long long cnt = a[0] / N;
        if(cnt == 0) break;
        K += cnt;
        a[0] -= N * cnt;
        for(int i=1; i<N; i++) a[i] += cnt;
    }
    return K;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<long long> a(N);
    for(int i=0; i<N; i++) cin >> a[i];

    cout << solve(a) << endl;

    return 0;
}

Measured memory_bytes: 256
//#include"pch.h"
//#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
#include<cmath>
#include<math.h>
#include<string.h>
#include<algorithm>

int main() {

	int A, B, K;
	int cnt = 0;

	scanf("%d %d %d", &A, &B, &K);

	for (int i = A; i > 0; i--) {
		if (A%i == 0 && B%i == 0)cnt++;
		if (cnt == K) {
			printf("%d", i);
			break;
		}
	}




	return(0);
}

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

// @@ !! LIM()

int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll N; cin >> N;
  ll ans = 0;
  for (ll i = 1; i <= N; i++) {
    ll a; cin >> a;
    if (i % 2 == 0) continue;
    if (a % 2 == 1) ans++;
  }
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 3644
#include<iostream>
using namespace std;
int main()
{
  while(true){
    int K;
    cin >> K;
    if( K == 0 ) break;
    int sum = 0;
    for(int i = 0; i < K*(K-1)/2; ++i){
      int t; cin >> t; sum += t;
    }
    sum /= (K-1);
    cout << sum << endl;
  }
  return 0;
}

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

typedef long long int ll;
typedef long double ld;

//****************************************************                
#define lp(var,start,end) for (ll var = start; var <end ; ++var)
#define rlp(var,start,end) for(ll var = start; var>=end ; var--)
#define pb push_back
#define mp make_pair
#define pf push_front
#define ff first
#define ss second
#define vll vector<ll>
#define pll pair<ll,ll> 
#define vpll vector<pll>
#define all(X) X.begin(),X.end()
#define endl "\n" //comment it for interactive questions
#define trace1(a) cerr << #a << ": " << a << endl;
#define trace2(a,b) cerr << #a << ": " << a << " " << #b << ": " << b << endl;
#define trace3(a,b,c) cerr << #a << ": " << a << " " << #b << ": " << b << " " << #c << ": " << c << endl;
#define trace4(a,b,c,d) cerr << #a << ": " << a << " " << #b << ": " << b << " " << #c << ": " << c << #d << ": " << d << endl;
#define OC   
#define FAST_IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
        //*******************************************************
//Some Functions

const ll MOD = (ll)1e9+7; //change it for other mods

ll powmod(ll a,ll b)
{
   ll res = 1;
   while(b > 0) {
      if(b & 1) res = (res * a) % MOD;
      a = (a*a)%MOD;
      b = b >> 1; 
  }
  return res % MOD;
}

void solve(ll testnum)
{
    ll n;
    cin >> n;
    vll a(n);
    vll bz(100001, 0);
    ll sum = 0;
    for(ll i=0;i<n;i++) {
    	cin >> a[i];
    	bz[a[i]]++;
    	sum += a[i];
    }
    ll q;
    cin >> q;
    while(q--) {
    	ll b,c;
    	cin >> b >> c;
    	sum -= b*bz[b];
    	sum += c*bz[b];
    	bz[c] += bz[b];
    	bz[b] = 0;
    	cout << sum << "\n";
    }
}

int main()
{
    FAST_IO;
    #ifdef STIO 
      freopen("input.txt" , "r", stdin);
      freopen("output.txt" , "w", stdout);
    #endif
    ll t = 1;
    // cin >> t;
    for (ll i = 1; i <= t; i++) {
        solve(i);
    }
}

Measured memory_bytes: 4780
//店舗→家→店舗→家→本店.Ak<x<Ak+1となるkをlog(N)で求める.
#include<iostream>
#include<algorithm>
#include<math.h>
using namespace std;
int d,n,m;
int mise[100000];

//重複無数列の場合はこれでOK!
int sandnum(int num,int start,int last){
	int medi = (start+last)/2;
	if(mise[start] >= mise[last])
		return medi;
	if(num == mise[medi]){
		return medi;
	}
	else if(num < mise[medi]){
		sandnum(num,start,medi-1);
	}
	else{
		//At<…<numとなる…が存在するか
		if(mise[medi+1] >= num)
			return medi;
		else
			sandnum(num,medi+1,last);
	}
}
int minest(int a1,int a2,int a3,int a4){
	int num = a1;
	if(num > a2)
		num = a2;
	if(num > a3)
		num = a3;
	if(num > a4)
		num = a4;
	return num;
}
int main(){
	int i,x;
	int num;
	int sum[200] = {0};
	int count = 0;
	while(1){
		cin >> d;
		if(d == 0)
			break;
		cin >> n >> m;
		for(i = 1;i < n;i++){
			cin >> mise[i];
		}
		sort(mise,mise+n);
		for(i = 0;i < m;i++){
			cin >> x;
			num = sandnum(x,0,n-1);
			if(num+1 == n){
				//本店と時計回りに最も遠い支店との距離を比べる
				sum[count] += minest(abs(mise[0]-x),d-abs(mise[0]-x),abs(mise[num]-x),d-abs(mise[num]-x));
			}
			else{
				sum[count] += minest(abs(mise[num]-x),d-abs(mise[num]-x),abs(mise[num+1]-x),d-abs(mise[num+1]-x));
			}
		}
		count++;
	}
	for(i = 0;i < count;i++){
		cout << sum[i] << endl;
	}
	return 0;
}

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

vector<int>A(10);
vector<vector<int>>L(50,vector<int>(4));
int N,M,Q,ans,point;

int dfs(int cn){
    int i,j;
        for(i=A[cn-1];i<=M;i++){
            A[cn]=i;
            if(cn==N-1){
                point=0;
                for(j=0;j<Q;j++){
                    if(A[L[j][1]-1]-A[L[j][0]-1]==L[j][2])point+=L[j][3];
                }
                ans=max(ans,point);
                //return 0;
            }else{
                dfs(cn+1);
            }
        }
    return 0;
}

int main(){
    int i,j;
    cin>>N>>M>>Q;
    ans=0;
    point=0;
    for(i=0;i<Q;i++)for(j=0;j<4;j++)cin>>L[i][j];
    A[0]=1;
    dfs(1);
    cout<<ans<<endl;
}

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

using namespace std;
typedef long long ll;
const int N = 100010;
int _w;

int n, x[N], m, a[N], p[N];
ll k, d[N];

template<typename T>
void mul( T *a, int *b, T *_c ) {
	static T c[N];
	for( int i = 1; i < n; ++i )
		c[i] = a[b[i]];
	for( int i = 1; i < n; ++i )
		_c[i] = c[i];
}

void fpow( int *_a, ll b, int *_c ) {
	static int a[N], c[N];
	for( int i = 1; i < n; ++i ) {
		a[i] = _a[i];
		c[i] = i;
	}
	while(b) {
		if( b & 1 ) mul(c, a, c);
		mul(a, a, a);
		b >>= 1;
	}
	for( int i = 1; i < n; ++i )
		_c[i] = c[i];
}

int main() {
	_w = scanf( "%d", &n );
	for( int i = 1; i <= n; ++i )
		_w = scanf( "%d", x+i );
	_w = scanf( "%d%lld", &m, &k );
	for( int i = 1; i <= m; ++i )
		_w = scanf( "%d", a+i );
	for( int i = 1; i < n; ++i )
		d[i] = x[i+1] - x[i];
	for( int i = 1; i < n; ++i )
		p[i] = i;
	for( int i = 1; i <= m; ++i ) {
		int u = a[i];
		swap(p[u], p[u-1]);
	}
	fpow(p, k, p), mul(d, p, d);
	d[0] = x[1];
	for( int i = 1; i < n; ++i )
		d[i] += d[i-1];
	for( int i = 0; i < n; ++i )
		printf( "%lld\n", d[i] );
	return 0;
}


Measured memory_bytes: 5120
#include<iostream>
using namespace std;
int n,k,s=1;
int mxin(int a,int b){
	return a<b?a:b;
}
int main(){
	cin>>n>>k;
	for(int i=1;i<=n;i++){
		s+=mxin(s,k);
	}	
	cout<<s<<endl;
	return 0;
}

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

int main(){
  ll n; cin >> n;
  vector<ll> a(n);
  for(ll i=0; i<n; ++i) cin >> a[i];
  vector<ll> buf(n, 0);
  for(ll i=0; i<n; ++i) ++buf[a[i]-1];
  
  ll res = 0;
  for(ll i=0; i<n; ++i) res += buf[i]*(buf[i]-1)/2;
  for(ll i=0; i<n; ++i){
    ll x = a[i];
    ll a = buf[x-1]*(buf[x-1]-1)/2;
    ll b = (buf[x-1]-1)*(buf[x-1]-2)/2;
    cout << res - a + b << endl;
  }
  
  return 0;
}


Measured memory_bytes: 5760
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define LB(c, x) lower_bound(c.begin(), c.end(), x)
#define UB(c, x) upper_bound(c.begin(), c.end(), x)
#define LI(c, x) distance(c.begin(), LB(c, x))
#define UI(c, x) distance(c.begin(), UB(c, x))

// functions
template <class T> T ceil(T a, T b) {
    return (a + b - 1) / b;
}
template <class T> T round(T a, T b) {
    return (a + b / 2) / b;
}
template <class T> T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}
template <class T> T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}
template <class T> bool amax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

int dp[101][4][4][4];

bool is_valid(int c3, int c2, int c1, int c0) {
    if (c2 == 0 && c1 == 2 && c0 == 1) {
        return false;
    } else if (c2 == 2 && c1 == 0 && c0 == 1) {
        return false;
    } else if (c2 == 0 && c1 == 1 && c0 == 2) {
        return false;
    } else if (c3 == 0 && c2 == 2 && c0 == 1) {
        return false;
    } else if (c3 == 0 && c1 == 2 && c0 == 1) {
        return false;
    }
    return true;
}

// main
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    const int MOD = 1e9 + 7;
    int N;
    cin >> N;
    dp[0][3][3][3] = 1;
    REP(i, N) {
        REP(c3, 4) {
            REP(c2, 4) {
                REP(c1, 4) {
                    if (dp[i][c3][c2][c1] == 0) {
                        continue;
                    }
                    REP(c0, 4) {
                        if (!is_valid(c3, c2, c1, c0)) {
                            continue;
                        }
                        dp[i + 1][c2][c1][c0] += dp[i][c3][c2][c1];
                        dp[i + 1][c2][c1][c0] %= MOD;
                    }
                }
            }
        }
    }
    int res = 0;
    REP(c3, 4) {
        REP(c2, 4) {
            REP(c1, 4) {
                res += dp[N][c3][c2][c1];
                res %= MOD;
            }
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
s = input()
animals = ['SS', 'SW', 'WS', 'WW']
for i, animal in enumerate(animals):
  for j in range(N):
    a = 1 if animals[i][-1] == 'S' else -1
    b = 1 if animals[i][-2] == 'S' else -1
    c = 1 if s[(j + 1) % N] == 'o' else -1
    animals[i] += 'S' if a * b * c > 0 else 'W'
ans = -1
for animal in animals:
  if animal[:2] == animal[-2:]:
    ans = animal[:N]
print(ans)

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

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }



int main() {
    ll n; cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];

    //ll ans = 0;
    ll ptn1 = 0; // -+-+
    ll ptn2 = 0; // +-+-
    ll now1 = 0;
    ll now2 = 0;
    rep(i, n) {
        now1 += a[i];
        now2 += a[i];
        if(i%2 == 0) {
            if(now1 <= 0) {
                ptn1 += abs(now1) + 1;
                now1 = 1;
            }
            if(now2 >= 0) {
                ptn2 += abs(now2) + 1;
                now2 = -1;
            }
        } else {
            if(now2 <= 0) {
                ptn2 += abs(now2) + 1;
                now2 = 1;
            }
            if(now1 >= 0) {
                ptn1 += abs(now1) + 1;
                now1 = -1;
            }
        }
    }

    cout << min(ptn1, ptn2) << endl;
    return 0;
}


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

#define LL long long
#define fi first
#define se second
#define mp make_pair
#define pb push_back

using namespace std;

LL gcd(LL a,LL b){return b?gcd(b,a%b):a;}
LL lcm(LL a,LL b){return a/gcd(a,b)*b;}
LL powmod(LL a,LL b,LL MOD){LL ans=1;while(b){if(b%2)ans=ans*a%MOD;a=a*a%MOD;b/=2;}return ans;}
const int N = 2e5 +11;
char a[N];
int main(){
	ios::sync_with_stdio(false);
	
	cin>>a+1;
	int cnt=0;
	int len=strlen(a+1);
	for(int i=1;i<=len;i++)cnt+=a[i]=='o';
	if(cnt+(15-len)>=8)cout<<"YES";
	else cout<<"NO";	
	return 0;
}

Measured memory_bytes: 256
H, W  = map(int, input().split())
f = []
INF = 10**10
dist = [[INF] * W for _ in range(H)]
cnt = 0
for i in range(H):
    S = list(input())
    for j,s in enumerate(S):
        if s == "#": dist[i][j] = -1
    cnt += S.count("#")
    f.append(s)
# print(cnt)

# 最短路以外を消す？
mvs = [(0,1),(0,-1),(1,0),(-1,0)]
from collections import deque
s = (0,0)
g = (H-1,W-1)
dist[0][0] = 0
q = deque()
q.append(s)
while q:
    h,w = q.popleft()
    # print(h,w)
    for dh, dw in mvs:
        if 0 <= h+dh < H and 0 <= w+dw < W: 
            # print("checked",h+dh,w+dw)
            if dist[h+dh][w+dw] == -1:
                continue
            elif dist[h+dh][w+dw] > dist[h][w] + 1:
                q.append((h+dh,w+dw))
                dist[h+dh][w+dw] = dist[h][w] + 1
# print(H*W)
# print(cnt)
# print(dist[H-1][W-1])
if dist[H-1][W-1] == INF or dist[H-1][W-1]==-1:
    print(-1)
    exit()
ans = H*W - dist[H-1][W-1] - 1 - cnt
print(ans)



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

int main(){
    int n;
    cin>>n;
    vector<vector<int>> v(n, vector<int>(3)), dp(n, vector<int>(3, 0));
    rep(i, n)
        cin>>v[i][0]>>v[i][1]>>v[i][2];
    rep(i, 3)
        dp[0][i] = v[0][i];
    rep1(i, 1, n)
        rep(j, 3){
            dp[i][j] = 0;
            rep(k, 3)
                if(j!=k) dp[i][j] = max(dp[i][j], dp[i-1][k]);
            dp[i][j] += v[i][j];
        }
    cout<<max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2]))<<endl;
}

Measured memory_bytes: 11136
using System;

public class Hello
{
    public static int MAXC = 0;
    public static int[] dx = new int[] { 0, 1, 0, -1 };
    public static int[] dy = new int[] { 1, 0, -1, 0 };
    public static void Main()
    {
        while (true)
        {
            MAXC = 0;
            var w = int.Parse(Console.ReadLine().Trim());
            var h = int.Parse(Console.ReadLine().Trim());
            if (w == 0 && h == 0) break;
            var map = new int[h, w];
            for (int i = 0; i < h; i++)
            {
                string[] line = Console.ReadLine().Trim().Split(' ');
                for (int j = 0; j < w; j++) map[i, j] = int.Parse(line[j]);
            }
            for (int i = 0; i < h; i++)
                for (int j = 0; j < w; j++)
                    if (map[i, j] == 1) goDfs(map, i, j, 1, h, w);
            Console.WriteLine(MAXC);
        }
    }
    public static void goDfs(int[,] map, int x, int y, int via, int h, int w)
    {
        MAXC = Math.Max(MAXC, via);
        map[x, y] = 0;
        for (int i = 0; i < 4; i++)
        {
            var nx = x + dx[i];
            var ny = y + dy[i];
            if (nx >= 0 && nx < h && ny >= 0 && ny < w && map[nx, ny] == 1)
                goDfs(map, nx, ny, via + 1, h, w);
        }
        map[x, y] = 1;
    }
}


Measured memory_bytes: 9336
#include<bits/stdc++.h>
using namespace std;
const int N =100;
int main()
{
    int A[N],B[N],C[N],n;

    while(~scanf("%d",&n))
    {
        for(int i=1;i<=n;i++)
            scanf("%d",&A[i]);
        for(int i=1;i<=n;i++)
            scanf("%d",&B[i]);
        for(int i=1;i<n;i++)
            scanf("%d",&C[i]);
        int ans =0;
        for(int i=1;i<=n;i++)
        {
            ans +=B[A[i]];
            if(A[i]==A[i+1]-1)
                ans +=C[A[i]];
        }
        printf("%d\n",ans);
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T,class U> using P = pair<T,U>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
 
int main(){
    int n, m;
    cin >> n >> m;
    int s[m], c[m];
    rep(i, m) {
        int ss, cc; cin >> ss >> cc;
        s[i] = ss-1;
        c[i] = cc;
    }
    int designated[n];
    rep(i, n) designated[i] = -1;
    int ans = 0;
    rep(i, m) {
        if (designated[s[i]]!=-1 && designated[s[i]]!=c[i]) {
            cout << -1 << endl;
            return 0;
        }
        designated[s[i]] = c[i];
    }
    if (designated[0]==0 && n>1) {
        cout << -1 << endl;
        return 0;
    }
    if (n==1 && m==0) {
        cout << 0 << endl;
        return 0;
    }
    rep(i, n) {
        if (designated[i] == -1 && i == 0) cout << 1;
        else if (designated[i] == -1 && i > 0) cout << 0;
        else cout << designated[i];
    }
    cout << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    ll ans = 0;
    int N; cin >> N;
    for (int i = 1; i<= N; i++) {
        if (i % 3 && i % 5) {
            ans += i; 
        }
    }
    cout << ans << nl;

	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343



Measured memory_bytes: 3656