akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class D { public static void Main() => (new Solver()).Solve(); }

public class Solver
{
	public void Solve()
	{
		long N = GetLong();
		for(long i = 0; i < N - 1; i++)
		{
			var buf = new List<long>();
			for(long j = i + 1; j < N; j++)
			{
				for(long k = 0; ; k++)
				{
					if(contains(i ^ j, k))
					{
						buf.Add(k + 1);
						break;
					}
				}
			}
			WriteLine(string.Join(" ", buf));
		}
	}
}

public static class MyIO
{
	private static string[] args = new string[0];
	private static int cnt = 0;
	private static IEnumerable<string> getArgs(long N) => Range(0, N).Select(_ => getArg());
	private static string getArg()
	{
		if(cnt == args.Length) { args = Console.ReadLine().Split(); cnt = 0; }
		return args[cnt++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static decimal GetDecimal() => decimal.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(long N) => getArgs(N).Select(int.Parse).ToArray();
	public static long[] GetLongs(long N) => getArgs(N).Select(long.Parse).ToArray();
	public static double[] GetDoubles(long N) => getArgs(N).Select(double.Parse).ToArray();
	public static decimal[] GetDecimals(long N) => getArgs(N).Select(decimal.Parse).ToArray();
	public static string[] GetStrings(long N) => getArgs(N).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) < 0) x = y; }
	public static void chmin<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) > 0)	x = y; }
	public static void swap<T>(ref T x, ref T y) { T tmp = x; x = y; y = tmp; }
	public static long rightShift(long x, long y) => (x >> (int)y);
	public static long leftShift(long x, long y) => (x << (int)y);
	public static bool contains(long s, long x) => (rightShift(s, x) & 1L) == 1L;
	public static long gcd(long x, long y) => (y == 0) ? x : gcd(y, x % y);
	public static long lcm(long x, long y) => (x / gcd(x,y)) * y;	
	public static IEnumerable<int> Range(long start, long count) => Enumerable.Range((int)start, (int)count);
	public static void Sort(this List<string> source) => source.Sort(StringComparer.Ordinal);
}


Measured memory_bytes: 31960
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>
#include <bitset>
#include <cstdint>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

int main() {
  string s;
  cin >> s;
  bool f = true;
  for (i64 i = 0; i < 3; ++i) {
    if (s[i] == s[i + 1]) f = false;
  }
  cout << (f ? "Good" : "Bad") << '\n';
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,d;
    int f=0;
    cin>>a>>b>>c>>d;
    while(1){
        if(f==0){
            c=c-b;
            f=1;
            if(c<=0){
                cout<<"Yes";
                break;
            }
        }
        if(f==1){
            a=a-d;
            f=0;
            if(a<=0){
                cout<<"No";
                break;
            }
        }
    }
}

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

int main() {
    int N;
    cin >> N;
    int y = 0;
    while (N - 7*y >= 0) {
        if ((N - 7*y) % 4 == 0) {
            cout << "Yes" << endl;
            return 0;
        }
        y += 1;
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define rep(X, Y) for (int(X) = 0; (X) < (Y); ++(X))
#define rrep(X, Y) for (int(X) = (Y)-1; (X) >= 0; --(X))
#define all(X) (X).begin(), (X).end()
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define print(x) cout << x << endl

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

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

const string strings[]{"dream", "dreamer", "erase", "eraser"};

bool canMake(string str, ull sp) {
  if (sp >= str.size()) {
    return true;
  }

  bool can = false;
  for (string sq : strings) {
    if (sp + sq.size() > str.size()) {
      continue;
    }

    if (sq.compare(0, sq.size(), str, sp, sq.size()) == 0) {
      can |= canMake(str, sp + sq.size());
    }
  }

  return can;
}

void solve(std::string S) {
  if (canMake(S, 0)) {
    print(YES);
  } else {
    print(NO);
  }
}

int main() {
  std::string S;
  std::cin >> S;
  solve(S);
  return 0;
}


Measured memory_bytes: 2688
/*************************************************************************
    > File Name: test.cpp
    > Author: Akira 
    > Mail: qaq.febr2.qaq@gmail.com 
 ************************************************************************/

#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <cmath>
#include <vector>
#include <set>
#include <list>
#include <ctime>
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
#define MST(a,b) memset(a,b,sizeof(a))
#define CLR(a) MST(a,0)
#define Sqr(a) ((a)*(a))
using namespace std;

#define MaxN 101010
#define MaxM MaxN*10
#define INF 0x3f3f3f3f
#define bug cout<<88888888<<endl;
#define MIN(x,y) (x<y?x:y)
#define MAX(x,y) (x>y?x:y)

LL N;
LL A[MaxN];
//a2-a1 - num / N
int main()
{
    LL sum = 0;
    scanf("%lld", &N);
    for(int i=0;i<N;i++)
    {
        scanf("%lld", &A[i]);
        sum+=A[i];
    }
    LL tmp = (1+N)*N/2;
    if(sum%tmp) printf("NO\n");
    else
    {
        int flag = 0;
        LL num = sum/tmp;
        for(int i=0;i<N;i++)
        {
            LL d = A[i] - A[(i+1)%N] + num;
            if(d<0 || d%N) 
            {
                flag = 1;
                break;
            }
            
        }
        if(flag) printf("NO\n");
        else
        {
            printf("YES\n");
        }
    }
    //system("pause");
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define FOR(I,X,Y) for(int (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(int (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define INF 1000000007
#define LINF 1000000000000000007
typedef long long ll;
using namespace std;

int p[] = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997};

int main(){
  ll ans = 1,N;
  cin >> N;
  for(auto x:p){
    if(x > N)break;
    int yay = 1;
    for(int i = x;i <= N;i*=x)yay += N/i;
    ans *= yay;
    ans %= INF;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
  val inputs = readLine()!!.split(" ").map { it.toInt() }
  val a = inputs[0]
  val b = inputs[1]
  val c = inputs[2]
  val d = inputs[3]
  val e = inputs[4]
  val f = inputs[5]

  var maxRatio = -1.0
  var ansW = 0
  var ansS = 0
  for (aCount in 0..(f / (100 * a))) {
    for (bCount in 0..(f / (100 * b))) {
      val w = 100 * a * aCount + 100 * b * bCount
      if (w > f) continue
      for (cCount in 0..(f / c)) {
        for (dCount in 0..(f / d)) {
          val s = c * cCount + d * dCount
          if (s * 100 > e * w) continue
          if (w + s > f) continue
          val ratio = s.toDouble() / (w.toDouble() + s.toDouble())
          if (ratio > maxRatio) {
            maxRatio = ratio
            ansW = w
            ansS = s
          }
        }
      }
    }
  }

  println("${ansW + ansS} $ansS")
}


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

#pragma region modint
template <uint32_t mod>
class modint{
    uint64_t value;
public:
    constexpr modint(const int64_t x=0) noexcept: value(x % mod + (x < 0 ? mod : 0)){ }
    constexpr explicit operator uint64_t() const noexcept{ return value; }
    constexpr modint inverse() const noexcept{ return pow(*this, mod-2); }
    constexpr bool operator==(const modint &rhs) const noexcept{ return value == rhs.value; }
    constexpr bool operator!=(const modint &rhs) const noexcept{ return value != rhs.value; }
    constexpr modint operator+() const noexcept{ return modint(*this); }
    constexpr modint operator-() const noexcept{ return modint(mod - value); }
    constexpr modint operator+(const modint &rhs) const noexcept{ return modint(*this) += rhs; }
    constexpr modint operator-(const modint &rhs) const noexcept{ return modint(*this) -= rhs; }
    constexpr modint operator*(const modint &rhs) const noexcept{ return modint(*this) *= rhs; }
    constexpr modint operator/(const modint &rhs) const noexcept{ return modint(*this) /= rhs; }
    constexpr modint &operator+=(const modint &rhs) noexcept{
        if((value += rhs.value) >= mod) value -= mod;
        return *this;
    }
    constexpr modint &operator-=(const modint &rhs) noexcept{ return *this += mod - rhs.value; }
    constexpr modint &operator*=(const modint &rhs) noexcept{
        if((value *= rhs.value) >= mod) value %= mod;
        return *this;
    }
    constexpr modint &operator/=(const modint &rhs) noexcept{ return *this *= rhs.inverse(); }
    constexpr modint operator++(int) noexcept{
        modint ret(*this);
        if((++value) >= mod) value -= mod;
        return ret;
    }
    constexpr modint operator--(int) noexcept{
        modint ret(*this);
        if((value += mod - 1) >= mod) value -= mod;
        return ret;
    }
    constexpr modint &operator++() noexcept{ return *this += 1; }
    constexpr modint &operator--() noexcept{ return *this -= 1; }
    friend std::ostream &operator<<(std::ostream &os, const modint<mod> &x){ return os << x.value; }
    friend std::istream &operator>>(std::istream &is, modint<mod> &x){
        int64_t i;
        is >> i;
        x = modint<mod>(i);
        return is;
    }
    friend constexpr modint<mod> pow(const modint<mod> &x, uint64_t y){
        modint<mod> ret{1}, m{x};
        while(y > 0){
            if(y & 1) ret *= m;
            m *= m;
            y >>= 1;
        }
        return ret;
    }
};
#pragma endregion
constexpr int64_t mod = 1'000'000'007; //'

int main(){
    int n, k;
    string s;
    cin >> k >> s;
    n = s.size();

    static modint<mod> fact[2000001], finv[2000001];
    fact[0] = 1;
    for(int i=0;i<2000000;++i) fact[i+1] = fact[i] * (i+1);
    finv[2000000] = fact[2000000].inverse();
    for(int i=2000000;i>0;--i) finv[i-1] = finv[i] * i;
    auto comb = [&](int n, int r){ return fact[n] * finv[r] * finv[n-r]; };
    modint<mod> ans = 0;
    for(int x=n;x<=n+k;++x) ans += comb(n+k, x) * pow(modint<mod>{25}, n+k-x);
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 35640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string a, b;
  cin >> a >> b;
  
  int c = 0;
  
   for(int i = 0; i < 3; i++){
    if(a[i] == b[i]){
      c++;
    }
  }
  cout << c << endl;
       
}

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

using namespace std;

char c[55][55];
int H, W, cnt;

int main() {
  cin >> H >> W;
  for (int i = 1; i <= H; i++) {
    for (int j = 1; j <= H; j++) {
      cin >> c[i][j];
    }
  }

  for (int i = 1; i <= H; i++) {
    for (int j = 1; j <= H; j++) {
      if (c[i][j] == '#' && c[i][j - 1] != '#' && c[i][j + 1] != '#' && c[i - 1][j] != '#' && c[i + 1][j] != '#') {
        cnt++;
      }
    }
  }
  if (cnt == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
 
int euclidean(int i, int j){
    int a, b, r;
 
    if(i >= j){
        a = i;
        b = j;
    }
    else{
        a = j;
        b = i;
    }
    
    while(1){
        if(a % b == 0) break;
        r = a % b;
        a = b;
        b = r;
    }
    
    return b;
}
 
int main(void){
    int K, e;
    long sum;
    
    cin >> K;
    
    sum = 0;
    for(int i = 1; i <= K; i++){
        for(int j = 1; j <= K; j++){
            e = euclidean(i, j);
            for(int k = 1; k <= K; k++){
                sum += euclidean(k, e);
            }
        }
    }
    
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define sz(x) int(x.size())
using ll = long long;
using P = pair<int,int>;
const ll LLINF = numeric_limits<long long>::max();
const int mod = 1000000007;
const int INF = 1001001001;

int main()
{
    string S,T;
    cin >> S >> T;

    for(int i=0;i<S.size();i++){
        if(S[i]!= T[i]){
            cout << "No";
            return 0;
        }

    }
    if(T.size() == S.size()+1){
        cout << "Yes";
    }
    else cout << "No";
    return 0;
}

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


int solve(vector<int>& v, int pos, vector<int>& memo, int k){

    if(pos==v.size()-1)return 0;
    if(memo[pos]!=-1)return memo[pos];



    // if(pos==v.size()-2){
    //    return memo[pos]= abs(v[pos]-v[pos+1])+solve(v,pos+1,memo);
    // }else{

    //        return  memo[pos]= min(
    //                 abs(v[pos]-v[pos+1])+solve(v,pos+1,memo),
    //                 abs(v[pos]-v[pos+2])+solve(v,pos+2,memo)
    //                 );
    // }
   
   int poso=pos;
   int temp=INT_MAX;

     if(pos+k<=v.size()-1){
            for(int i=1;i<=k;i++){
                temp= min(
                               temp,
                               abs(v[pos]-v[pos+i])+solve(v,pos+i,memo,k)
                               );
            }
            return memo[pos]=temp;

     }
   
     else{
         int i=1;
            while(pos<=v.size()-2 && i<=k){

                temp= min(
                               temp,
                               abs(v[poso]-v[poso+i])+solve(v,poso+i,memo,k)
                               );

                pos=poso+i;
                i++;
            }
            return memo[poso]=temp;
            
     }

}

int main(){

   int n,k;
   cin>>n>>k;

   vector<int> v;
   for(int i=0;i<n;i++){
       int temp;
       cin>>temp;

   v.push_back(temp);
   }


   vector<int> memo;

   for(int i=0;i<100001;i++){
   memo.push_back(-1);
   }

   int pos=0;
   int sum=0;

   cout<< solve(v,pos,memo,k) <<endl;
//    cout<<memo[0]<<endl;

    return 0;
}

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

int main() {
	
	string x, y, z; cin >> x >> y >> z;
	string s = "";
	s += x[0];
	s += y[1];
	s += z[2];
	cout << s << endl;
    return 0;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
  ll n,k;
  cin>>n>>k;
  ll arr[n];
  for(int i=0;i<n;i++)
	cin>>arr[i];
  ll dp[n];
  for(int i=1;i<n;i++)
  {
  	dp[i] = 100000000000000000;
  }
  dp[0]=0;
  for(int i=1;i<n;i++)
  {
  	for(int j=1;j<=k;j++)
  	{
  		if(i-j>=0)
		{
  			dp[i] = min(dp[i],dp[i-j]+abs(arr[i-j]-arr[i]));	
		}
	}
  }
  cout<<dp[n-1]<<endl;
}


Measured memory_bytes: 1792
import java.util.*;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
 
   int N = sc.nextInt();
   
   int sum = 0 ;
   int tmp = N ;
   for(int i=0;i<10;i++)
   {
     sum+=tmp%10;
     tmp/=10;
	 if(tmp==0) break;
   }
   if(N%sum==0)System.out.println("Yes");
   else System.out.println("No");
 }
}

Measured memory_bytes: 21844
local n, z, w = io.read("*n", "*n", "*n")
local a = {}
for i = 1, n do a[i] = io.read("*n") end
if n == 1 then
  print(math.abs(w - a[1]))
else
  print(math.max(math.abs(w - a[n]), math.abs(a[n - 1] - a[n])))
end


Measured memory_bytes: 508
// template version 1.15
using namespace std;
#include <bits/stdc++.h>

// varibable settings
#define int long long
const int INF=1e18;

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(a, b, c) make_tuple(a, b, c)
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

#define divceil(a,b) ((a)+(b)-1)/(b)
#define is_in(x, a, b) ((a)<=(x) && (x)<(b))
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define slice(l, r) substr(l, r-l)

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
  #include "lib/dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
  #define cerrendl 42
#endif
//}}}

signed main() {
  string s;cin>>s;
  int n = sz(s);
  reverse(all(s));

  vvi dp(2, vi(n+1,INF));
  dp[0][0] = 0;

  rep(i, 1, n+1){
    int v = s[i-1] - '0';
    chmin(dp[0][i], dp[0][i-1]+v);
    chmin(dp[1][i], dp[0][i-1]+1+(10-v));

    if (v<9) chmin(dp[0][i], dp[1][i-1]+v);
    chmin(dp[1][i], dp[1][i-1]+(9-v));
  }
  dump_2d(dp, 2, n+1);


  int ans = INF;
  ans = min(dp[0][n], dp[1][n]);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 24860
#include <bits/stdc++.h>
#define rep(i, n) for (ll(i) = 0; (i) < (n); (i)++)
#define all(x) (x).begin(), (x).end()
#define print(x) cout << (x) << endl;

typedef long long ll;
const ll INF = 99999999999999;
const ll MOD = 1000000007;

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
ll lcm(ll number1, ll number2)
{
    return number1 * number2 / gcd(number1, number2);
}
template <class T>
bool contain(const std::string &s, const T &v)
{
    // contain(to_string(N), '3')
    return s.find(v) != std::string::npos;
}

int ctoi(char c)
{
    if (c >= '0' && c <= '9')
        return c - '0';
    return 0;
}
using namespace std;

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

    cin >> n;
    vector<ll> h(n);
    vector<ll> ans;
    rep(i, n)
    {
        cin >> h[i];
    }
    vector<ll> diff(n - 1);
    rep(i, n - 1)
    {
        diff[i] = h[i + 1] - h[i];
    }
    ll count = 0;
    rep(i, n - 1)
    {
        if (diff[i] <= 0)
        {
            count++;
        }
        else
        {
            ans.push_back(count);
            count = 0;
        }
    }
    ans.push_back(count);

    sort(all(ans), greater<int>());
    cout << ans[0] << endl;

    return 0;
}

Measured memory_bytes: 2936
#include <stdio.h>
 
int main(void){
   int x,y;
   int s1,s2,s3;
  
   scanf("%d%d",&x,&y);
   if(x==1){s1 = 300000;}
   else if(x==2){s1 = 200000;}
   else if(x==3){s1 = 100000;}
   else{s1 = 0;}
  
   if(y==1){s2=300000;}
   else if(y==2){s2=200000;}
   else if(y==3){s2=100000;}
   else{s2 = 0;}
  
   if(x==1&&y==1){s3=400000;}
   else{s3 = 0;}
   
   printf("%d",s1+s2+s3);
 
   return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <cmath>
#include <utility>
#include <queue>
#include <map>
#include <list>
#include <set>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;

int count(int n) {
  if (n < 2) return 0;
  return n * (n - 1) / 2;
}

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  cout << count(n) + count(m) << endl;
  return 0;
}




Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <cstdint>

constexpr int kNumAlphabets = 'z' - 'a' + 1;

struct Node {
  Node() : counts(kNumAlphabets), children(kNumAlphabets) {}
  std::vector<int> counts;
  std::vector<Node*> children;
};

int main() {
  Node* root = new Node;
  int N;
  std::cin >> N;
  std::vector<std::string> S(N);
  for (int i = 0; i < N; ++i) {
    std::cin >> S[i];
    std::reverse(S[i].begin(), S[i].end());
    std::vector<int> counts(kNumAlphabets);
    for (const auto c : S[i]) {
      ++counts[c - 'a'];
    }
    auto node = root;
    for (int j = 0; j < kNumAlphabets; ++j) {
      root->counts[j] += counts[j] > 0;
    }
    for (const auto c : S[i]) {
      const auto index = c - 'a';
      --counts[index];
      auto& child = node->children[index];
      if (!child) {
        child = new Node;
      }
      for (int j = 0; j < kNumAlphabets; ++j) {
        child->counts[j] += counts[j] > 0;
      }
      node = child;
    }
  }
  std::int64_t count = 0;
  for (const auto& s : S) {
    auto node = root;
    for (std::size_t j = 0; j < s.size() - 1; ++j) {
      node = node->children[s[j] - 'a'];
    }
    count += node->counts[s.back() - 'a'] - 1;
  }
  std::cout << count << std::endl;
  return 0;
}


Measured memory_bytes: 395064
#include<stdio.h>
int main() {
	int hideo = 0, ruio = 0, masatoy = 0, nagase = 0, a[101] = { 0 }, p[101] = { 0 };
	int temp = 0, max[101] = { 0 }, sum = 1, text = 0;
	scanf("%d", &hideo);
	for (int i = 1; i <= hideo*(hideo - 1) / 2; i++) {
		scanf("%d %d %d %d", &a[1], &a[2], &a[3], &a[4]);
		if (a[3] > a[4]) {
			p[a[1]] += 3;
		}
		else if (a[4] > a[3]) {
			p[a[2]] += 3;
		}
		else {
			p[a[1]]++;
			p[a[2]]++;
		}
	}
	for (int i = 1; i <= hideo; i++) {
		for (int i = 1; i <= hideo; i++) {
			if (temp < p[i]) {
				temp = p[i];
			}
		}
		for (int i = 1; i <= hideo; i++) {
			if (temp == p[i]) {
				max[i] = sum;
				text++;
				p[i] = -1;
			}
		}
		sum += text;
		temp = 0;
		text = 0;
	}
	for (int i = 1; i <= hideo; i++) {
		printf("%d\n", max[i]);
	}
}

Measured memory_bytes: 2752
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int N;
   cin >> N;
   vector<int> tako(N);
   for (int i=0; i<N; i++){
       cin >> tako.at(i);
   }
   int sum=0;
   for (int i=0; i<N; i++){
       for (int j=i+1; j<N; j++){
           sum += tako.at(i)*tako.at(j);
       }
   }
   cout << sum << endl;
    return 0;
}

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

#define REP(i, x) REPI(i, 0, x)
#define REPI(i, a, b) for (int i = int(a); i < int(b); ++i)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

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

  int A, B, C;
  cin >> A >> B >> C;
  cout << max(C - (A - B), 0) << endl;

  return 0;
}


Measured memory_bytes: 256
import math

a, b, c, d = map(int, input().split())
a = a - 1

cd = c * d // math.gcd(c, d)

b_n = b // c + b // d - b // cd
a_n = a // c + a // d - a // cd
print((b - b_n) - (a - a_n))

Measured memory_bytes: 61960
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <queue>
using namespace std;

double solve(int n, int s, int t, int b)
{
  vector<double> probs(9, 0.0);
  probs[s] = 1.0;

  for (int i = 0; i < n; i++) {
    vector<double> next(9, 0.0);
    for (int j = 0; j < 9; j++) {
      for (int d = 0; d < 4; d++) {
        static const int di[] = {-1, 1, 0, 0};
        static const int dj[] = {0, 0, 1, -1};
        const int k = (j / 3) + di[d];
        const int l = (j % 3) + dj[d];
        if (k < 0 || 3 <= k || l < 0 || 3 <= l || 3*k+l == b) {
          next[j] += probs[j] * 0.25;
        } else {
          next[3*k+l] += probs[j] * 0.25;
        }
      }
    }
    probs = next;
  }

  return probs[t];
}

int main()
{
  int n;
  while (cin >> n && n != 0) {
    char s, t, b;
    cin >> s >> t >> b;
    printf("%.8f\n",  solve(n, s-'A', t-'A', b-'A'));
  }
  return 0;
}

Measured memory_bytes: 0
#!/usr/bin/env python3
import sys


def solve(N: int, S: str):
    E = [0] * (N+1)
    W = [0] * (N+1)
    for i, s in enumerate(S):
        E[i+1] = E[i] + (1 if s == 'W' else 0)
    for i, s in enumerate(reversed(S)):
        W[N-i-1] = W[N-i] + (1 if s == 'E' else 0)
    return min(e+w for e, w in zip(E, W))


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    print(solve(N, S))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()


Measured memory_bytes: 33052
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _0219
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                int n = RInt();
                if (n == 0) break;

                int[] vs = new int[10];
                for (int i = 0; i < n; i++) vs[RInt()]++;
                for (int i = 0; i < vs.Length; i++) Console.WriteLine(vs[i] == 0 ? "-" : new string('*', vs[i]));
            }
        }
        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RArSt(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RArInt(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RArLong(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RArDouble(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }
}



Measured memory_bytes: 13852
#include<stdio.h>
#include<iostream>
using namespace std;
int main(void){
	int D,L,ans;
	cin >> D >> L;
	ans = D / L;
	if(D%L == 0){
		cout << ans << endl;
	}else{
		cout << ans+D%L << endl;
	}
	return 0;
}

Measured memory_bytes: 3120
#include <iostream>
#include <vector>
#include <cmath>
#include <string>

using namespace std;

void func_A() {

    string s;
    cin >> s;

    if (s == "ABC") cout << "ARC";
    else cout << "ABC";
}

void func_B() {

    int n, k;
    cin >> n >> k;

    int d, a;
    vector<int> sunuke(n, 0);

    for (int i = 0; i < k; ++i) {
        cin >> d;
        for (int j = 0; j < d; ++j) {
            cin >> a;
            ++sunuke[a - 1];
        }
    }

    int count = 0;
    for (int i = 0; i < n; ++i) {
        if (sunuke[i] == 0) ++count;
    }

    cout << count;
}

void func_C() {

    int n, m;
    cin >> n >> m;
    vector<long long> h(n);
    for (int i = 0; i < n; ++i) cin >> h[i];

    //道がつながってるか。0で初期化
    vector<vector<int>> load(n, vector<int>(n, 0));

    //道についての情報を格納
    int temp1, temp2;
    for (int i = 0; i < m; ++i) {
        cin >> temp1 >> temp2;
        load[temp1 - 1][temp2 - 1] = 1;
        load[temp2 - 1][temp1 - 1] = 1;
    }


    /*入力できてるかデバッグ
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            cout << load[i][j] << " ";
        }
        cout << "\n";
    }
    */
    

    //実行時間超過の予感するけど書く
    //やっぱりした
    int count = 0; //良い展望台を数える
    for (int i = 0; i < n; ++i) {
        long long tower = h[i];
        for (int j = 0; j < n; ++j) {
            if (load[i][j] == 1 && h[j] >= h[i]) break;
            if (j == n - 1) ++count;
        }
    }
    

    cout << count;
}


void func_Cfix(){

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

    vector<long long> h(n);
    for (int i = 0; i < n; ++i) cin >> h[i];

    vector<int> judge(n, 1);
    int tower1, tower2;

    for (int i = 0; i < m; ++i) {
        cin >> tower1 >> tower2;
        if (h[tower1 - 1] == h[tower2 - 1]) {
            judge[tower1 - 1] = 0;
            judge[tower2 - 1] = 0;
        }
        else if (h[tower1 - 1] > h[tower2 - 1]) {
            judge[tower2 - 1] = 0;
        }
        else {
            judge[tower1 - 1] = 0;
        }
    }

    int count = 0;
    for (int i = 0; i < n; ++i) {
        //cout << judge[i];
        if (judge[i] == 1) ++count;
    }

    cout << count;
}
int main() {

    //func_A();
    //func_B();
    //func_C();
    func_Cfix();

    return 0;

}

Measured memory_bytes: 4244
#include <bits/stdc++.h>
using intl = long long;
using itnl = long long;
using itn = int;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n); i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a); i >= (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, alength(a))cin >> a[i]
#define ccin(i, j, a) rep(i, alength(a))rep(j, alength(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl
#define sqrt sqrtl
#define itn int
#define double ld
#define pb push_back
#define mp make_pair
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld eps = 1.0e-14;//-9
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl gcd(intl a, intl b){
    if(!b)return a;
    return gcd(b, a % b);
}
intl lcm(intl a,intl b){
    return a / gcd(a, b) * b;
}
intl digit10(intl a){
    intl b = 0;
    do{
        a /= 10;
        b++;
    }while(a);
    return b;
}
signed main(){
    cout << fixed << setprecision(10);
    intl n,m;
    cin >> n;
    intl cnt = 0;
    repi(i,1,n+1){
        repi(j,1,n+1){
            repi(k,1,n+1){
                cnt += gcd(i,gcd(j,k));
            }
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3640
#include <iostream>
 
using namespace std;
 
int N;
int P[2 * 100000];
int Q[2 * 100000];
 
int main() {
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> P[i];
    }
    for (int i = 0; i < N; i++) {
        Q[P[i]-1] = i;
    }
    int cnt = 1;
    int m = 1;
    for (int i = 1; i < N; i++) {
        if (Q[i] < Q[i-1]) {
            cnt = 1;
        } else {
            cnt += 1;
        }
        if (cnt > m) {
            m = cnt;
        }
    }
    cout << N - m << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define pll pair<ll,ll>
#define all(v) v.begin(),v.end()
#define mod 1000000007
#define mx 1000002
mt19937 myrand(time(0));

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(),cout.tie();
    ll a;
    cin>>a;
    ll ans=a+(a*a)+(a*a*a);
    cout<<ans<<endl;
}


Measured memory_bytes: 3656
// Problem : F - Silver Fox vs Monster
// Contest : AtCoder Beginner Contest 153
// URL : https://atcoder.jp/contests/abc153/tasks/abc153_f
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/coder3101/cp-editor)
const long long int inf=1e18l+5;
#include<bits/stdc++.h>
using namespace std;
int main()
{
        long long int n,w,sum=0;
        cin >> n >> w;
        vector<long long int> value(n),weight(n);
        for(int i=0;i<n;i++)
        {cin >> weight[i] >> value[i];sum+=value[i];}
        vector<long long int> dp(sum+1,inf);
        dp[0]=0;
        for(int i=0;i<n;i++)
        {
                for(int j=sum-value[i];j>=0;--j)
                {
                        dp[j+value[i]]=min(dp[j]+weight[i],dp[j+value[i]]);
                }
        }
        long long int ans=0;
        for(int i=0;i<=sum;++i)
        {
                if(dp[i]<=w)
                ans=max(ans,(long long int)i);
        }
        cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(9), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
int main() {
    string S; cin >> S;
    deque<char> D(begin(S), end(S));
    bool rev = false;
    int Q; cin >> Q;
    while (Q--) {
        int T; cin >> T;
        if (T == 1) {
            rev = !rev;
        } else {
            int F; char C; cin >> F >> C;
            if ((F == 1) ^ rev) {
                D.push_front(C);
            } else {
                D.push_back(C);
            }
        }
    }
    if (rev) reverse(begin(D), end(D));
    for (auto c : D) cout << c;
    cout << endl;
    return 0;
}

Measured memory_bytes: 976
mutable struct UnionFind{T <: Integer}
    parent:: Vector{T}  # parent[root] is the negative of the size

    function UnionFind{T}(nodes::T) where T<:Integer
        if nodes <= 0
            throw(ArgumentError("invalid argument for nodes: $nodes"))
        end

        parent = -ones(T, nodes)
        new{T}(parent)
    end
end

UnionFind(nodes::Integer) = UnionFind{typeof(nodes)}(nodes)

function root(uf::UnionFind{T}, x::T)::T where T<:Integer
    if uf.parent[x] < 0
        return x
    else
        # uf.parent[x] = root{T}(uf, uf.parent[x])
        # return uf.parent[x]
        return uf.parent[x] = root(uf, uf.parent[x])
    end
end

function issame(uf::UnionFind{T}, x::T, y::T)::Bool where T<:Integer
    return root(uf, x) == root(uf, y)
end

function size(uf::UnionFind{T}, x::T)::T where T<:Integer
    return -uf.parent[root(uf, x)]
end

function unite!(uf::UnionFind{T}, x::T, y::T)::Bool where T<:Integer
    x = root(uf, x)
    y = root(uf, y)
    if x == y
        return false
    end
    if uf.parent[x] > uf.parent[y]
        x, y = y, x
    end
    # unite smaller tree(y) to bigger one(x)
    uf.parent[x] += uf.parent[y]
    uf.parent[y] = x
    return true
end

function main()
    N, M = parse.(Int, split(readline()))
    uf = UnionFind(N)
    ng=N
    for _ in 1:M
        Ai,Bi = parse.(Int, split(readline()))
        if !issame(uf,Ai,Bi)
            ng-=1
        end
        unite!(uf, Ai, Bi)
    end
    println(ng-1)
end

main()

Measured memory_bytes: 206908
import java.util.*;

public class Main {
	
    	static int n,q;
        static ArrayList<Integer> A = new ArrayList<Integer>(),
                                  M = new ArrayList<Integer>();
        static ArrayList<Boolean> R = new ArrayList<Boolean>();
        
    public static void main(String[] args) {
        
    	//Input
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        for(int i = 0; i < n; i++){
        	A.add(sc.nextInt());
        }
        q = sc.nextInt();
        for(int i = 0; i < q; i++){
        	M.add(sc.nextInt());
        }
        
        //Calculation
        for (int i = 0; i < q; i++){
        	R.add(solve(0,M.get(i)));
        }
        
        //Output
        print(R);
    }

    private static boolean solve(int p,int t){
    	if(p == n){
    		if(t == 0){
    			return true;
    		} else {
    			return false;
    		}
    	}
    	if (solve(p + 1,t - A.get(p)) || solve(p + 1,t)){
    		return true;
    	} else {
    		return false;
    	}
    }
    
    private static void print(ArrayList<Boolean> R){
    	for (Boolean b:R){
			if (b == true) {
				System.out.println("yes");
			} else {
				System.out.println("no");
			}
		}
    }
}

Measured memory_bytes: 20876
// 九九を出すだけ
package main
import (
	"fmt"
	"os"
	"bufio"
	"strconv"
	"sort"
)

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main(){
	sc.Split(bufio.ScanWords)
	defer out.Flush()
	n := nextInt()
	for i:=0; i<n; i++{
	    data := nextInts(3)
	    sort.Ints(data)
	    if data[0]*data[0]+data[1]*data[1] == data[2]*data[2]{
	        fmt.Fprintln(out, "YES")
	    }else{
	        fmt.Fprintln(out, "NO")
	    }
	}
}

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

func nextInt() int{
	a, _ := strconv.Atoi(next())
	return a
}

func nextInts(n int) []int{
    a := make([]int, n)
    for i:=0; i<n; i++{
        a[i] = nextInt()
    }
    return a
}


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

int main() {
  int A, B;
  cin >> A >> B;
  
  int min8 = 0;
  int min10 = 0;
  
  if(int(int(A / 0.08) * 0.08) != A) min8 = int(A / 0.08) + 1;
  else min8 = int(A / 0.08);
  int max8 = min8;
  for (int i = 1; int((min8 + i) * 0.08) < (A + 1); i++) max8++;
  
  if(int(int(B / 0.1) * 0.1) != B) min10 = int(B / 0.1) + 1;
  else min10 = int(B / 0.1);
  int max10 = min10;
  for (int i = 1; int((min10 + i) * 0.1) < (B + 1); i++) max10++;
  
  if((min8 >= min10) && (min8 <= max10)) cout << min8 << endl;
  else if((min10 >= min8) && (min10 <= max8)) cout << min10 << endl;
  else cout << -1 << endl;

}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<map> 
#include<iostream>
#include<time.h>
using namespace std;
typedef long long ll;
const double pi=acos(-1.0);
const ll mod=1e9+7;
const int inf=0x3f3f3f3f;
//ll begin_time=clock();
//ll end_time=clock();printf("time=%lldms\n",end_time-begin_time);
/****************************************************************************/ 
int main()
{
	char z[10];
	scanf("%s",z);
	if(z[1]=='B')printf("ARC\n");
	else printf("ABC\n");
}




Measured memory_bytes: 3760
//inlclude before define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
#include<assert.h>
#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef pair<int, int> P1;
typedef long long int ll;

//define
#define INF 1e9
#define NUM 1000000007
#define all(x) begin(x),end(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,a,b) for(int i=int(a);i<int(b);i++)
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))

//function

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

/*ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a * (b / g);
}*/

/*int dig(int a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}*/

int main () {
	int n;
	cin >> n;
	VI a (n);
	int ju = 0;
	rep (i, n) {
		cin >> a[i];
	}

	ll sum=0,ans1=0,ans2=0;
	//cout << "a"<< endl;
	rep (i, n) {
	sum += a[i];
		//cout << sum << endl;
		if (sum <= 0 && i%2==0) {
			ans1 += abs( 1 - sum );
			sum = 1;
		} else if(sum>=0 && i%2==1){
			ans1 += abs (-1 - sum);
			sum = -1;
		}
		//cout << sum << " " << ans << endl;
	}
	sum = 0;
	//cout << "b" << endl;
	rep (i, n) {
		sum += a[i];
		//cout << sum << " ";
		if (sum >= 0 && i % 2 == 0) {
			ans2 += abs (-1 - sum);
			sum = -1;
		} else if (sum <= 0 && i % 2 == 1) {
			ans2 += abs (1 - sum);
			sum = 1;
		}
		//cout << sum <<" "<<ans<< endl;
	}
	cout << min (ans1, ans2) << endl;
	

}



Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
using namespace std;
int main()
{    
	string a;
	cin>>a;
	for(int i=0;i<a.size()-1;i++)
	{
		for(int j=i+1;j<a.size();j++)
		{
			if(a[i]=='C'&&a[j]=='F')
			{
				cout<<"Yes"<<endl;
				return 0;
			}
		}
	}
	cout<<"No";
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);


int[] A=new int[3];
A[0]=Integer.parseInt(sc.next());
A[1]=Integer.parseInt(sc.next());
A[2]=Integer.parseInt(sc.next());
int a=Math.abs(A[1]-A[0])+Math.abs(A[2]-A[1]);
int b=Math.abs(A[2]-A[0])+Math.abs(A[1]-A[2]);
int ans=Math.min(a, b);
int c=Math.abs(A[2]-A[1])+Math.abs(A[0]-A[2]);
ans=Math.min(ans,c);
int d=Math.abs(A[0]-A[1])+Math.abs(A[2]-A[0]);
ans=Math.min(ans, d);
int e=Math.abs(A[1]-A[2])+Math.abs(A[0]-A[1]);
ans=Math.min(ans, e);
int f=Math.abs(A[0]-A[2])+Math.abs(A[1]-A[0]);
ans=Math.min(ans,f);
System.out.println(ans);


}}

Measured memory_bytes: 23764
#include<iostream>
#include<vector>
#include<stdlib.h>
using namespace std;
int main()
{
	int N,L,min,pos,sum;
	cin>>N>>L;
	
	for(int i=0;i<N;i++)
	{	
		if(i==0)
		{
			min = (abs(L+i));
			pos = 1;
			sum = 0;
		}
		else
		{
			if(min > (abs(L+i)))
			{
				
				sum += L+pos-1; 
				min = (abs(L+i));
				pos = i+1;
			}
			else
			sum+=(L+i);
		}
	}
	
	cout<<sum;
	
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#define M 1046527
#define L 14
char H[M][L];

//?°?????¬??????¬??¢?????°???
int getChar(char c) {
  switch (c) {
    case 'A': return 1;
    case 'C': return 2;
    case 'G': return 3;
    case 'T': return 4;
    default: return 0;
  }
}
//?°?????¬??????¬??¢?????°?????¶??????key
long long getKey(char str[]) {
  long long ret = 0, p = 1;
  int i;
  for(i = 0; str[i] != '\0'; i++) {
    ret += p * getChar(str[i]);
    p *= 5;
  }
  return ret;
}
int h1(int key){return key%M;}
int h2(int key){return 1+(key%(M-1));}
int find(char str[]) {
  long long key, h, i;
  key = getKey(str);
  for(i = 0; ; i++) {
    h = (h1(key) + i * h2(key)) % M;
    if(strcmp(H[h], str) == 0) {
      return 1;
    } else if(strlen(H[h]) == 0) {
      return 0;
    }
  }
  return 0;
}
int Insert(char str[]) {
  long long key, h, i;
  key = getKey(str);
  for(i = 0; ; i++) {
    h = (h1(key) + i * h2(key)) % M;
    if(strcmp(H[h], str) == 0) {
      return 1;
    } else if(strlen(H[h]) == 0) {
      strcpy(H[h], str);
      return 0;
    }
  }
  return 0;
}


int main() {
  int i, n;
  char str[L], cmd[9];
  for(i = 0; i < M; i++) {
    /* initialize hash */
    H[i][0] = '\0';
  }
 
  scanf("%d", &n);
  for(i = 0; i < n; i++) {
    scanf("%s %s", cmd, str);
 
    if(cmd[0] == 'i') {
      Insert(str);
    } else {
      if(find(str)) {
        printf("yes\n");
      } else {
        printf("no\n");
      }
    }
  }
  return 0;
}

Measured memory_bytes: 16972
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		long min = (long) 1e18;
		for(long x=1;x*x<=N;x++){
			if(N % x != 0) continue;
			long y = N / x;
			min = Math.Min(min, y - 1 + x - 1);
		}
		Console.WriteLine(min);
		
		
	}
	long N;
	public Sol(){
		N = rl();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 13140
#!/usr/bin/env python3
import sys

YES = "YES"  # type: str
NO = "NO"  # type: str


def solve(S: str):
    S = S.replace('eraser', '')
    S = S.replace('erase', '')
    S = S.replace('dreamer', '')
    S = S.replace('dream', '')
    print(YES if S == '' else NO)
    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#include <stdio.h>

int main(){
    int n,mod;
    
    scanf("%d",&n);
    
    mod = n%2;
    
    if(mod==1){
        printf("%d\n",n/2 + 1);
    }
    
    else{
        printf("%d\n",n/2);
    }
    
    
    return 0;
    
}

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

int n,k;
int a[200005];
int b[200005];

void print(){
    for(int i=0;i<n;i++)cout<<a[i]<<' ';
    cout<<endl;
    exit(0);
}

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin>>n>>k;
    for(int i=0;i<n;i++){
        cin>>a[i];
        b[max(0,i-a[i])]++;
        if(i+a[i]+1<n)b[i+a[i]+1]--;
    }
    for(int t=0;t<k;t++){
        bool ed=1;
        for(int i=0;i<n;i++){
            a[i]=b[i]+=b[i-1];
            if(a[i]!=n)ed=0;
        }
        if(ed){
            print();
        }
        memset(b,0,sizeof(b));
        for(int i=0;i<n;i++){
            b[max(0,i-a[i])]++;
            if(i+a[i]+1<n)b[i+a[i]+1]--;
        }
        
    }
    print();

    return 0;
}

Measured memory_bytes: 5160