akhauriyash/Code-Regression huggingface dataset:
//by yjz
#include<bits/stdc++.h>
using namespace std;
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
#define foreach(it,s) for(__typeof((s).begin()) it=(s).begin();it!=(s).end();it++)
#ifndef LOCAL
#define cerr if(0)cout
#endif
typedef long long ll;
const int mod=1e9+7;
//My i/o stream
struct fastio
{
	char s[100000];
	int it,len;
	fastio(){it=len=0;}
	inline char get()
	{
		if(it<len)return s[it++];it=0;
		len=fread(s,1,100000,stdin);
		if(len==0)return EOF;else return s[it++];
	}
	bool notend()
	{
		char c=get();
		while(c==' '||c=='\n')c=get();
		if(it>0)it--;
		return c!=EOF;
	}
}_buff;
#define geti(x) x=getnum()
#define getii(x,y) geti(x),geti(y)
#define getiii(x,y,z) getii(x,y),geti(z)
#define puti(x) putnum(x),putchar(' ')
#define putii(x,y) puti(x),puti(y)
#define putiii(x,y,z) putii(x,y),puti(z)
#define putsi(x) putnum(x),putchar('\n')
#define putsii(x,y) puti(x),putsi(y)
#define putsiii(x,y,z) putii(x,y),putsi(z)
inline ll getnum()
{
	ll r=0;bool ng=0;char c;c=_buff.get();
	while(c!='-'&&(c<'0'||c>'9'))c=_buff.get();
	if(c=='-')ng=1,c=_buff.get();
	while(c>='0'&&c<='9')r=r*10+c-'0',c=_buff.get();
	return ng?-r:r;
}
template<class T> inline void putnum(T x)
{
	if(x<0)putchar('-'),x=-x;
	register short a[20]={},sz=0;
	while(x)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1;i>=0;i--)putchar('0'+a[i]);
}
inline char getreal(){char c=_buff.get();while(c<=32)c=_buff.get();return c;}
ll qpow(ll x,ll k){return k==0?1:1ll*qpow(1ll*x*x%mod,k>>1)*(k&1?x:1)%mod;}
const int maxn=300111;
int n;
ll a[maxn],X;
ll getans(int x)
{
	ll ret=0;
	for(int i=n;i>=1;i--)
	{
		int id=max((n-i)/x,1);
		ret+=1ll*(id*2+3)*a[i];
	}
	return ret;
}
int main()
{
	getii(n,X);
	for(int i=1;i<=n;i++)
	{
		geti(a[i]);
	}
	ll ans=8e18;
	int l=1,r=n-1;
	while(l<=r)
	{
		int mid=l+r>>1;
		ll dlt=getans(mid)-getans(mid+1)-X;
		if(dlt<0)r=mid-1;else l=mid+1;
	}
	ans=getans(l)+X*l;
	cout<<ans+X*n<<endl;
	return 0;
}


Measured memory_bytes: 1920
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>
#include <utility>
#include <numeric>
#include <iomanip>
#include <locale>
#include <map>
#include <set>
#include <queue>
#include <cstdlib>
#include <cmath>

using namespace std;

pair< int, vector<int> > read();
long think(pair< int, vector<int> > *);
void write(long);

int main(int argc, char* argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);

  auto input = read();
  auto output = think(&input);
  write(output);

  return 0;
}

pair< int, vector<int> > read() {
  int n, m, a;
  auto input = vector<int>();

  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a);
    input.push_back(a);
  }
  return make_pair(m, input);
}

long think(pair< int, vector<int> > *input) {
  auto m = input->first;
  auto values = input->second;
  auto q = priority_queue<int>();

  for (auto e : values) {
    q.push(e);
  }
  for (int i = 0; i < m; i++) {
    auto d = q.top();
    q.pop();
    q.push(d / 2);
  }

  long sum = 0;
  while (!q.empty()) {
    sum += q.top();
    q.pop();
  }
  return sum;
}

void write(long output) {
  cout << output << endl;
}


Measured memory_bytes: 1904
import java.util.Scanner
import scala.collection.Searching._

import scala.annotation.tailrec

class IUnionFind(val size: Int) {

  private case class Node(var parent: Option[Int], var treeSize: Int)

  private val nodes = Array.fill[Node](size)(new Node(None, 1))

  def union(t1: Int, t2: Int): IUnionFind = {
    if (t1 == t2) return this

    val root1 = root(t1)
    val root2 = root(t2)
    if (root1 == root2) return this

    val node1 = nodes(root1)
    val node2 = nodes(root2)

    if (node1.treeSize < node2.treeSize) {
      node1.parent = Some(t2)
      node2.treeSize += node1.treeSize
    } else {
      node2.parent = Some(t1)
      node1.treeSize += node2.treeSize
    }
    this
  }

  def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)

  @tailrec
  private def root(t: Int): Int = nodes(t).parent match {
    case None => t
    case Some(p) => root(p)
  }
}


object Main {
  def solve(sc: => Scanner): Unit = {
    val A = Array.fill(sc.nextInt)(sc.nextInt)
    var ans = -1
    for (i <- 0 until A.size) {
      for (j <- i + 1 until A.size) {
        if (check(A(i) * A(j))) ans = math.max(ans, A(i) * A(j))
      }
    }
    println(ans)
  }

  def check(x: Int): Boolean = {
    
    var now = x
    var now1 = x % 10
    var f = true
    while (now >= 10) {
      val now2 = (now % 100 / 10): Int
      //println(now1, now2)
      if (now1 != now2 + 1) (f = false)
      now1 = now2
      now = (now / 10): Int
    }
    f

  }

  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)

    solve(sc)
  }
}

Measured memory_bytes: 50016
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstdlib>
#include<vector>
#include<queue>
#include<map>
#include<functional>
#include<cstring>
using namespace std;
int main() {
	char str[10001] = {0};
	while(scanf("%s",str) != EOF){
		int joi = 0,ioi = 0;
		for(int i = 0; i < strlen(str) - 2; i++){
			if(str[i+1] == 'O' && str[i+2] == 'I'){
				if(str[i] == 'J')joi++;
				if(str[i] == 'I')ioi++;
			}
		}
		printf("%d\n%d\n",joi,ioi);
	}
    return 0;
}

Measured memory_bytes: 1156
from sys import stdin
n = int(stdin.readline().rstrip())
#l = list(map(int, stdin.readline().rstrip().split()))
#A, B, C = map(int, stdin.readline().rstrip().split())
#S = [list(map(int, stdin.readline().rstrip().split())) for _ in range(h)]#hの定義を忘れずに

print(n**2)

Measured memory_bytes: 2940
def main():
    MOD = 10 ** 9 + 7
    N, M = map(int, input().split())
    S = tuple(map(int, input().split()))
    T = tuple(map(int, input().split()))
    l = [[0] * (M + 1) for _ in range(N + 1)]
    l[0] = [1] * (M + 1)
    for i in range(N + 1):
        l[i][0] = 1
    r = 1
    for i in range(1, N+1):
        for j in range(1, M+1):
            if S[i-1] == T[j-1]:
                r += l[i-1][j-1]
                l[i][j] = l[i][j-1] + l[i-1][j]
                l[i][j] %= MOD
            else:
                l[i][j] = l[i][j-1] + l[i-1][j] - l[i-1][j-1]
        r %= MOD
    print(r % MOD)
main()


Measured memory_bytes: 327296
#include<stdio.h>
main(){
  int a=100000,n,i;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    a=a+a*0.05;
    if(a%1000!=0){
      a=a/1000;
      a=a+1;
      a=a*1000;
    }
  }
  printf("%d\n",a);
  return 0;
}

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

using namespace std;

using ll = long long;

const long long MOD = 1e9 + 7;
const int INF = 1e9 + 7;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K, Q;
    cin >> N >> K >> Q;
    vector<int> person(N, 0);
    for (int i = 0; i < Q; ++i) {
        int A;
        cin >> A;
        person[A - 1]++;
    }
    for (int i = 0; i < N; ++i) {
        person[i] += K - Q;
    }
    for (int i = 0; i < N; ++i) {
        if (person[i] > 0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}

Measured memory_bytes: 1024
import java.util.Scanner;

/**
 *
 * @author cl18413
 */
class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner console =new Scanner(System.in);
        int a= console.nextInt();
        int b= console.nextInt();
        esCuadrado(a,b);
    }
    
    public static void esCuadrado(int a, int b){
        Double f=Math.sqrt(Integer.parseInt(""+a+b));
        if(f==f.intValue()){
            System.out.println("Yes");            
        }else{
            System.out.println("No");
        }            
    }
    
}

Measured memory_bytes: 21972
#include<iostream>
using namespace std;
int main() {
    int n, a;
    cin >> n >> a;
    while (n >= 500) {
        n -= 500;
    }
    if (n <= a) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
s = input()

ans = 0

for l in range (len(s)):

  for r in range(l+1, len(s)+1):

    cnt = 0

    for str in s[l:r]:

      if str not in ['A','C','G','T']:

        cnt = 0 

        break

      else:

        cnt += 1

    ans = max(ans, cnt)

print(ans)

      


Measured memory_bytes: 9008
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0, -1, 1, 0 };
const ll dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
///////////////////////////////////////
bool d[55];//立てに置かれているならtrue
int main() {
	int N; cin >> N;
	string s1, s2;
	cin >> s1 >> s2;
	for (int i = 0; i < N; ++i) {
		if (s1[i] != s2[i]) {
			d[i] = false;
		}
		else {
			d[i] = true;
		}
	}
	ll ans;
	if (d[0]) {
		ans = 3;
		for (int i = 1; i < N;) {
			if (!d[i - 1] && !d[i]) {
				ans *= 3;
				ans %= INF;
				i += 2;
			}
			else if (!d[i - 1] && d[i]) {
				i++;
			}
			else if (d[i - 1] && !d[i]) {
				ans *= 2;
				ans %= INF;
				i += 2;
			}
			else {
				ans *= 2;
				ans %= INF;
				i++;
			}
		}
	}
	else {
		ans = 6;
		for (int i = 2; i < N;) {
			if (!d[i - 1] && !d[i]) {
				ans *= 3;
				ans %= INF;
				i += 2;
			}
			else if (!d[i - 1] && d[i]) {
				i++;
			}
			else if (d[i - 1] && !d[i]) {
				ans *= 2;
				ans %= INF;
				i += 2;
			}
			else {
				ans *= 2;
				ans %= INF;
				i++;
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
N = int(input())
S = list(map(lambda x: ord(x) - ord("a"), list(input())[: -1]))

class BIT:
  def __init__(self, n):
    self.n = n
    self.data = [0] * (n + 1)
    self.el = [0] * (n + 1)
  def sum(self, i):
    s = 0
    while i > 0:
      s += self.data[i]
      i -= i & -i
    return s
  def add(self, i, x):
    self.el[i] += x
    while i <= self.n:
      self.data[i] += x
      i += i & -i
  def get(self, i, j = None):
    if j is None:
      return self.el[i]
    return self.sum(j) - self.sum(i)
  def lowerbound(self, s):
    x = 0
    y = 0
    for i in range(self.n.bit_length(), -1, -1):
      k = x + (1 << i)
      if k <= self.n and (y + self.data[k] < s):
        y += self.data[k]
        x += 1 << i
    return x + 1

fwk = [BIT(N) for _ in range(26)]
for i in range(N): fwk[S[i]].add(i + 1, 1)
for _ in range(int(input())):
  q, x, y = input().split()
  if q == "1":
    x = int(x)
    y = ord(y) - ord("a")
    fwk[S[x - 1]].add(x, -1)
    fwk[y].add(x, 1)
    S[x - 1] = y
  else:
    x = int(x)
    y = int(y)
    res = 0
    for i in range(26): res += fwk[i].get(x - 1, y) > 0
    print(res)

Measured memory_bytes: 284348
#include<stdio.h>
int main(void)
{
  int x,i,j,f;
  scanf("%d",&x);
  if(x==2){
    printf("2\n");
  }else{
  for(i=0;i<=1000;i++){
    f=0;
    for(j=2;j<=x/2+1;j++){
      if((x+i)%j!=0){
        f++;
      }else{
        break;
      }
    }
    /* printf("%d\t",f);*/
    if(f==x/2){
      printf("%d\n",x+i);
      break;
    }
  }
  }
  return 0;
}

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


int main() {
int N;
int K;
int M = 1;
  cin >> N >> K;
  for(int i =0; i < N; ++i){
    if(M + K >= 2 * M){
      M *= 2;
    }
    else{
      M += K;
    }
  }
  cout << M << endl;
    
}
  


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
#define PI 3.14159265359
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define SIZE_OF_ARRAY(array) (sizeof(array) / sizeof(array[0]))

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (b - a == c - b) {
    cout << "YES" << endl;
  } else
    cout << "NO" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lli=long long int;
using vi=vector<int>;  using vs=vector<string>; using gi=greater<int>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define soao(c) sort((c).begin(),(c).end()) //昇順
#define sodo(c) sort((c).begin(),(c).end(),gi()) //降順
#define rev(c) reverse((c).begin(), (c).end())


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


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c,d; cin>>a>>b>>c>>d;
    int x = (c+b-1)/b;
    int y = (a+d-1)/d;
    if (x<=y){
        cout<<"Yes\n";
    }else{
        cout<<"No\n";
    }
    return 0;
}


Measured memory_bytes: 3648
/* be name khoda */

//#define stream_enable
#define long_enable
#include <iostream>
#include <algorithm>
#include <cstring>
#include <numeric>
#include <iomanip>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;

#ifdef stream_enable
#define cin sss
#endif
#ifdef long_enable
typedef long long int ll;
#else
typedef int ll;
#endif

typedef pair<ll, ll> pii;
typedef pair<pii, ll> ppi;
typedef pair<ll, pii> pip;
typedef vector<ll> vi;
typedef vector<pii> vpii;

const ll MOD = 1000000007;
const long long BIG = 1446803456761533460;
const int Big = 336860180;

#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()

#define debug(x) cout << #x << " -> " << (x) << endl
#define debug2(x, y) cout << #x << ' ' << #y << " -> " << (x) << ' ' << (y) << endl
#define debug3(x, y, z) cout << #x << ' ' << #y << ' ' << #z << " -> " << (x) << ' ' << (y) << ' ' << (z) << endl
#define debug4(x, y, z, t) cout << #x << ' ' << #y << ' ' << #z << ' ' << #t << " -> " << (x) << ' ' << (y) << ' ' << (z) << ' ' << (t) << endl
#define debugp(x) cout << #x << " -> " << "(" << (x).F << ", " << (x).S << ")" << endl
#define debuga(x, n) cout << #x << " -> "; fori (i1_da, n) { cout << (x)[i1_da] << ' '; } cout << endl
#define debugap(x, n) cout << #x << " ->\n"; fori (i1_dap, n) { cout << "(" << (x)[i1_dap].F << ", " << (x)[i1_dap].S << ")\n"; } cout << endl
#define debugaa(x, n, m) cout << #x << " ->\n"; fori (i1_daa, n) { fori (i2_daa, m) { cout << (x)[i1_daa][i2_daa] << ' '; } cout << '\n'; } cout << endl
#define debugav(x, n) cout << #x << " ->\n"; fori (i1_dav, n) { fori (i2_dav, (x)[i1_dav].size()) { cout << (x)[i1_dav][i2_dav] << ' '; } cout << '\n'; } cout << endl
#define debugia(x, n) cout << #x << " ->\n"; fori (i1_dia, n) { cout << i1_dia << " : " << (x)[i1_dia] << '\n'; } cout << endl

#define forifrom(i, s, n) for(ll i = (s); i < (n); ++i)
#define forirto(i, n, e) for(ll i = (n) - 1; i >= (e); --i)
#define fori(i, n) forifrom (i, 0, n)
#define forir(i, n) forirto (i, n, 0)

#define smin(a, b) a = min(a, (b))
#define smax(a, b) a = max(a, (b))

#define Add(a, b) a = ((a) + (b)) % MOD
#define Mul(a, b) a = (1LL * (a) * (b)) % MOD

stringstream sss;

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

const ll maxn = 100010;

ll n;
vi g[maxn];
ll cnt[maxn];

void dfs(ll x, ll par) {

    for (auto y : g[x]) if (y != par) {
        dfs(y, x);
        if (cnt[y] == 0) ++cnt[x];
    }
    if (cnt[x] >= 2) {
        cout << "First\n";
        exit(0);
    }

}

void MAIN() {

   cin >> n;
   fori (i, n - 1) {
       ll a, b; cin >> a >> b; --a, --b;
       g[a].eb(b), g[b].eb(a);
   }
   dfs(0, 0);
   if (cnt[0] == 0) cout << "First\n";
   else cout << "Second\n";

}

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

int main() {
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cout << fixed << setprecision(10);
    sss << R"(

    )";
    MAIN();
    return 0;
}



Measured memory_bytes: 6912
#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n, a, b;
  cin >> n;
  int count = 0;
  for(int i = 0; i < n; i++) {
    cin >> a >> b;
    if (a == b) count++;
    else {
      if (count >= 3) {
        cout << "Yes";
        return 0;
      }
      else {
        count = 0;
      }
    }
  }
  if (count >= 3) cout << "Yes";
  else cout << "No";

}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
      using namespace std;
      #define ll long long
      #define pb push_back
      #define pll  pair <long long,long long>
      #define mp make_pair
      #define ss second
      #define ff first
      #define maa 1000000007
      #define endl '\n'
      #define ld long double
      #define all(x) x.begin(),x.end()
      ll  power(ll  i,ll  j)
      {
        if(j==0)
        return 1 ;
        ll t=power(i,j/2)%maa ;
        if(j%2==0)
        return (t%maa*t%maa)%maa ;
        else
        return ((t%maa*t%maa)%maa*(i%maa)%maa)%maa ;
      }
      bool is(ll  i)
      {
        if(i==1)
            return 0 ;
        ll  f=0 ;
        for(ll  j=2;j<=sqrt(i);j++)
        {
            if(i%j==0)
            {
                f=1 ;
                break ;
            }
        }
        return !f ;
      }
      int main()
      {

        /// 50-4
        /// freopen("input.txt","r",stdin);
        /// freopen("output.txt","w",stdout);
       ll n,m  ;
       cin>>n>>m ;
       char r[n+1][m+1] ;
       ll dp[n+1][m+1] ;
       for(ll i=1;i<=n;i++)
       {
           for(ll j=1;j<=m;j++)
           cin>>r[i][j] ;
       }
       dp[1][1]=1 ;
       for(ll i=1;i<=n;i++)
       {
           for(ll j=1;j<=m;j++)
           {
               
               if(i!=1||j!=1)
               dp[i][j]=0 ;
               if(r[i][j]=='.'&&r[i-1][j]=='.')
               dp[i][j]+=dp[i-1][j] ;
               
               if(r[i][j]=='.'&&r[i][j-1]=='.')
               dp[i][j]+=dp[i][j-1] ;
               
               dp[i][j]%=maa ;
           }
       }
       cout<<dp[n][m] ;
        
        
      }








Measured memory_bytes: 9088
#include <cstdio>
#include <algorithm>
using namespace std;
int n,i,j;
long long x,y,s,a[54];
bool ok;
int main()
{
    scanf ("%d", &n);
    for (i=1;i<=n;i++)
        scanf ("%lld", &a[i]);
    sort (a+1,a+n+1);
    s=0LL;
    for (i=1;i<=(n-1);i++)
    {
        x=(0LL)+a[i+1]-a[i];
        x=(1LL)*x/(n+1);
        s=(0LL)+s+(1LL)*x*(n-i);
        for (j=1;j<=i;j++)
            a[j]=(0LL)+a[j]+(1LL)*x*(n-i);
        for (j=(i+1);j<=n;j++)
            a[j]=(0LL)+a[j]-(1LL)*x*(i+1);
    }
    y=(0LL)+a[1]-n;
    if (y>0)
    {
        s=(0LL)+s+(1LL)*y*n;
        for (i=1;i<=n;i++)
            a[i]=(0LL)+a[i]-y;
    }
    ok=true;
    while (ok==true)
    {
        ok=false;
        for (i=1;i<=n;i++)
        {
            if (a[i]>=n)
            {
                ok=true;
                break;
            }
        }
        if (ok==false)
            break;
        else
        {
            s=(0LL)+s+1;
            for (j=1;j<i;j++)
                a[j]=(0LL)+a[j]+1;
            for (j=(i+1);j<=n;j++)
                a[j]=(0LL)+a[j]+1;
            a[i]=(0LL)+a[i]-n;
        }
    }
    printf ("%lld", s);
    return 0;
}


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

class Program
{
    static void Main(string[] args)
    {
        // 入力
        ulong[] hw = Console.ReadLine().Split().Select(ulong.Parse).ToArray();
        ulong h = hw[0];
        ulong w = hw[1];


        ulong tmp = (w + 1) / 2;
        ulong ans = 0;

        if (h == 1 || w == 1)
        {
            ans = 1;
        }
        else
        {


            //奇数列目
            ans += tmp * ((h + 1) / 2);

            //偶数列目
            if (w % 2 == 0)
            {
                ans += tmp * (h / 2);
            }
            else
            {
                ans += (tmp - 1) * (h / 2);
            }
        }



        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 11220
#include <bits/stdc++.h>
using namespace std;
#define rep(i, l, r) for(int i=(l); i<(r); ++i)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
    詰まった時に、別の分野の問題として考え直す（これdpでは？、グラフとしてみればいいのでは？）
    多くの問題はパターンマッチだが、パターンに落とし込むまでが難しく、そのための訓練としてわからない問題をあれこれ色々な角度から考察してみるのではないか
    cin.tie(0);
    ios::sync_with_stdio(false);<- これら、printfとかと併用しない方が良さそう

*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

/* <--------------------------------------------> */


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

    string s; cin >> s;
    int n=s.length();

    int ans=n;
    rep(i, 0, n-1){
        if(s[i]!=s[i+1]) chmin(ans, max(i+1, n-1-i));
    }
    cout << ans << '\n';
    
    return 0;
}

Measured memory_bytes: 512
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 30;
const int MOD = 1e9 + 7;

int main() {
  int n, m;
  scanf("%d", &n);
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
  }
  scanf("%d", &m);
  vector<int> b(m);
  for (int i = 0; i < m; ++i) {
    scanf("%d", &b[i]);
  }
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  bool found = false;
  for (int i = 0, j = 0; j < m; ++j) {
    while (a[i] < b[j]) ++i;
    if (a[i] > b[j]) {
      found = true;
      break;
    }
    ++i;
  }
  puts(found ? "NO" : "YES");
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int N, K;
    cin >> N >> K;
    map<int, int> mp;
    rep(i, N) {
        int A;
        cin >> A;
        mp[A]++;;
    }

    int cnt = max(0, (int)mp.size() - K);
    vector<int> num;
    int ans = 0;
    for (auto itr : mp) {
        num.push_back(itr.second);
    }

    sort(all(num));
    rep(i, cnt) ans += num[i];

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

Measured memory_bytes: 10748
n,m = map(int, input().split(' '))
List = [i+1 for i in range(m)]

i = 0
while i < n:
    k_list = list(map(int, input().split(' ')))
    lcopy = List[:]
    for l in lcopy:
        if l not in k_list[1:]:
            List.remove(l)
            #print(l,List)
    i += 1
print(len(List))

Measured memory_bytes: 3060
n=int(input())
arr=list(map(int, input().split()))
cost=[0 for _ in range(n+1)]
cost[2]=abs(arr[1]-arr[0])
for stone in range(3, n+1):
    cost[stone]=min(cost[stone-1]+abs(arr[stone-1]-arr[stone-2]), cost[stone-2]+abs(arr[stone-1]-arr[stone-3]))
print(cost[n])

Measured memory_bytes: 90304
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long  n,x,tmp;
	cin>>n>>x;
	tmp=x;
	for(int i=0;i<4;i++){
		cin>>x;
		tmp=min(tmp,x);
	}
	cout<<(n-1)/tmp+5<<endl;	return 0;
}


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

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

int gcd(int a,int b){return b?gcd(b,a%b):a;}

ll modpow(ll n,ll k){
  if(k == 1){
    return n;
  }else if(k == 0){
    return 1;
  }else if(k%2==0){
    ll memo = modpow(n,k/2)%MOD;
    return memo*memo%MOD;
  }else{
    return n * modpow(n,k-1)%MOD;
  }
}

int main(){

  int n,m;cin>>n>>m;
  int satan = 1;
  int utan = n;

  REP(i,m){
    int l,r;
    cin>>l>>r;

    satan = max(satan,l);
    utan = min(utan,r);
  }
  cout<<max(utan-satan+1,0)<<endl;
 

  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 N = sc.nextInt();
		Set<Integer> set = new HashSet<Integer>();//HashSetで空の箱を作る
		for(int  i=0; i<N; i++) {
			int a= sc.nextInt();
			set.add(Integer.valueOf(a));//set.addで空の箱に重複を除いたaを追加する
		}
		//元の配列の要素数と異なればNO、変化していなければYES
		if(set.size()!=N){
			System.out.println("NO");
		}else {
			System.out.println("YES");
		}
	}
		
}

Measured memory_bytes: 98548
/**
**	author : Raghav
**	codechef:raghav_456
**	codeforces:raghavramola7
**/
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define endl            "\n"
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define deb(x)          cout<<#x<<" "<<x<<endl
#define ar 				array
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;


void Raghav()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
int32_t main()
{
	Raghav();
	int n;
	cin >> n;
	n >= 30 ? cout << "Yes" : cout << "No";
	cout << endl;
	return 0;
}

Measured memory_bytes: 3652
#include<iostream>
#include<math.h>
#include<string.h>

using namespace std;

int main() {

	int n;
	cin >> n;
	int min = 10000;
	for (int i = 1; i < n; i++) {
		int a = i;
		int b = n - i;

		int sumA =0;//= a % 10 + a / 10;
		while (a) {
			int dig = a % 10;
			sumA += dig;
			a /= 10;
		}
		int sumB=0; //= b % 10 + b / 10;
		while (b) {
			int dig = b % 10;
			sumB += dig;
			b /= 10;
		}
		int sum = sumA + sumB;
		//if (sum == 0)min = sum;
		if (min > sum)min = sum;
	}
	cout << min << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FAST_INPUT ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
 
using namespace std;
 
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
using ll= long long;
const int mxN = 500;
const ll INF = 0x3f3f3f3f3f3f3f3fL;
// ll dist[mxN][mxN];
 
void dfs(ll u, vector<vector<ll>>& graph, vector<bool>& visited){
    if(visited[u])
        return;
    visited[u] = true;
    for(ll v: graph[u]){
        dfs(v, graph, visited);
    }
}

bool relax(vector<ll>& dist, vector<vector<ll>>& edges, vector<bool>& visited){
    bool changed = false;
    for(vector<ll>& edge: edges){
        ll u = edge[0];
        ll v = edge[1];
        ll w = edge[2];

        if(visited[u] && visited[v] && dist[u] != INF){
            if(dist[v] > dist[u] + w){
                dist[v] = dist[u] + w;
                // if(v ==  visited.size() - 1)
                    changed = true;
                // cout << u + 1 << " " << v + 1<< " " << dist[u] << " " << dist[v] << endl;
            }
        }
    }
    return changed;
}

void dijkstra(ll s, vector<ll>& dist, vector<vector<pair<ll,ll>>>& graph){
    priority_queue<pair<ll, int>, vector<pair<ll,int>>, greater<pair<ll,int>>> pq;
    pq.push({0,s});
    dist[s] = 0;
    while(!pq.empty()){
        pair<ll,int> top = pq.top(); pq.pop();
        ll u = top.second;
        ll d = top.first;
        if(d > dist[u])
            continue;

        for(pair<ll,ll>& next: graph[u]){
            ll v = next.first;
            ll w = next.second;
            if(dist[v] > d + w){
                dist[v] = d + w;
                pq.push({dist[v], v});
            }            
        }
    }
}

void solve() {
    int n; cin >> n;
    cout << (n >= 30 ? "Yes" : "No") << endl;
}
 
int main() {
    FAST_INPUT;
    
    solve();
    return 0;
}

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

int main(int argc, char *argv[])
{
    int r;
    cin >> r;
    if (r < 1200) {
        cout << "ABC" << endl;
    } else if (r < 2800) {
        cout << "ARC" << endl;
    } else {
        cout << "AGC" << endl;
    }
    return 0;
}


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

using namespace std;
int n;

long long valor[105];
long long peso [105];
long long dp [105][1060000];
int p;

long long pd(long long id, long long aguenta)
{
    if (dp[id][aguenta]!=-1){return dp[id][aguenta];}
    if (id==n or !aguenta) {return dp[id][aguenta]=0;}

    long long nao_pega=pd(id+1,aguenta);

    if(peso[id]<=aguenta){
       long long pega=valor[id]+pd(id+1, aguenta - peso[id]);
        return dp[id][aguenta]=max(pega,nao_pega);
    }


return dp[id][aguenta]=nao_pega;

}





int main ()
{
    cin>>n;
    cin>>p;
for (int i=0;i<n;i++){
    cin>>peso[i];
    cin>>valor[i];


}
memset(dp,-1,sizeof(dp));
cout<<pd(0,p);


    return 0;
}


Measured memory_bytes: 869760
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
 
int main() {
	long X,Y,Z,K;
	vector<long> A;
	vector<long> B;
	vector<long> C;

	vector<long> ans;

	cin >> X >> Y >> Z >> K;

	for (int i = 0; i < X; i++)
	{
		long num;
		cin >> num;
		A.push_back(num);
	}

	for (int i = 0; i < Y; i++)
	{
		long num;
		cin >> num;
		B.push_back(num);
	}

	for (int i = 0; i < Z; i++)
	{
		long num;
		cin >> num;
		C.push_back(num);
	}

	vector<long> AB;

	for(long a : A)
	{
		for(long b : B)	
		{
			AB.push_back(a + b);
		}
	}

	sort(AB.begin(), AB.end(), std::greater<long>());

	long abcount = min(K, (long)AB.size());
	for (long i = 0; i < abcount; i++)
	{
		for (long j = 0; j < C.size(); j++)
		{
			ans.push_back(AB[i] + C[j]);
		}
	}

	sort(ans.begin(), ans.end(), std::greater<long>());

	long count = min(K, (long)ans.size());

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

	/*
	sort(A.begin(), A.end(), std::greater<long>());
	sort(B.begin(), B.end(), std::greater<long>());
	sort(C.begin(), C.end(), std::greater<long>());

	for(long a : A)
	{
		for(long b : B)	
		{
			for(long c : C)
			{
				ans.push_back(a + b + c);
			}
		}
	}

	sort(ans.begin(), ans.end(), std::greater<long>());

	long count = 0;

	if (K >= ans.size())
	{
		count = ans.size();
	}
	else
	{
		count = K;
	}

	for(long i= 0; i < count; i++)
	{
		cout << ans[i] << endl;
	}
*/
	return 0;
}


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

vector<vector<int>> G;
vector<int> dis_a, dis_t;

void dfs(int who, int cur, int prev, int d) {
  for (auto nx : G.at(cur)) {
    if (nx == prev) continue;
    if (who == 0) {
      dis_a.at(nx) = d + 1;
      dfs(0, nx, cur, d+1);
    }
    else {
      dis_t.at(nx) = d + 1;
      dfs(1, nx, cur, d+1);
    }
  }
}

int main() {
  int N, u, v; cin >> N >> u >> v;
  u--; v--;
  G.resize(N);
  for (int i = 0; i < N-1; i++) {
    int A, B; cin >> A >> B;
    A--; B--;
    G.at(A).push_back(B);
    G.at(B).push_back(A);
  }
  dis_a.assign(N, -1);
  dis_t.assign(N, -1);
  dis_a.at(v) = 0;
  dis_t.at(u) = 0;
  dfs(0, v, -1, 0);
  dfs(1, u, -1, 0);
  int ans = 0;
  for (int i = 0; i < N; i++) {
    if (dis_a.at(i) > dis_t.at(i)) ans = max(ans, dis_a.at(i));
  }
  cout << ans - 1 << endl;
}

Measured memory_bytes: 11648
#include <stack>
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;
int gcd(int a, int b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}
int mod = 1000000000 + 7;
int main(){
    //std::stack<int> stack;
    
    int n,q;
    cin >> n;
    vector<int> t(n);
    for(int i = 0; i < n; i++){
        cin >> t[i];
    }
    cin >> q;
    int ans = 0;
    for(int i = 0; i < q; i++){
        int tmp;
        cin >> tmp;
        for(int j = 0; j < n; j++){
            if(tmp == t[j]){
                ans ++;
                break;
            }
        }
    }
    cout << ans << endl;
}






Measured memory_bytes: 3108
// </> : towhid1zaman

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair< int, int > pii;
typedef pair< pii, int > ppi;
#define fill(a,b) memset(a,b,sizeof(a))
#define all(v) (v).begin(),(v).end()
#define sp(k) cout<<setprecision(k)<<fixed;
#define rep(i,a) for(int i=0;i<a;i++)
#define rep1(i,a,b) for(int i=(a);i<=(b);++i)
#define irep(i,b,a) for(int i=(b);i>=(a);--i)
#define minv(v) *min_element(all(v))
#define maxv(v) *max_element(all(v))
#define unq(v) sort(all(v)),(v).erase(unique(all(v)),(v).end())
#define _ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"
#define sqr(a) ((a)*(a))
#define sz(a) int(a.size())
#define ff first
#define ss second
#define pb push_back

const double pi = acos(-1.0);
const int mod = 1000000007; // (int)1e9+7
const int inf = 0x3f3f3f3f;// (int)3e18;
const int maxn = 2000100;



int main(){
        _
        string s; cin >> s;
        ll n=0 ;
        ll ans = 0;
        rep(i,sz(s)){
            if(s[i]=='B')n++;
            else ans+=n;
        }
        cout<<ans<<endl;

return 0;
}



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

using namespace std;

#define LL long long
#define DD double
#define Pb push_back
#define Bp pop_back
#define Pf push_front
#define Fp pop_front
#define Ub upper_bound
#define Lb lower_bound
#define In insert
#define All(x) x.begin(), x.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define fast ios_base::sync_with_stdio(0);cin.tie(0)
#define X first
#define Y second
#define mx1 10
#define mx2 110
#define mx3 1010
#define mx4 10010
#define mx5 100010
#define mx6 1000010

typedef vector<LL> Vl;
typedef vector<DD> Vd;
typedef vector<bool> Vb;
typedef vector<Vl> VVl;
typedef pair<LL, LL> Pll;
typedef pair<DD, DD> Pdd;
typedef vector<Pll> Vpl;
typedef vector<Pdd> Vpd;
typedef queue<LL> Ql;
typedef stack<LL> Sl;
typedef deque<LL> Dl;

LL _set(LL N, LL pos) {return N = N | (1 << pos);}
LL _reset(LL N, LL pos) {return N = N & ~(1 << pos);}
bool _check(LL N, LL pos) {return (bool)(N & (1 << pos));}
bool _upper(char a) {return a >= 'A' && a <= 'Z';}
bool _lower(char a) {return a >= 'a' && a <= 'z';}
bool _digit(char a) {return a >= '0' && a <= '9';}

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

///**************************DONE****************************///

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

    cout << c - min(c, a - b) << '\n';
    return 0;
}

Measured memory_bytes: 256
/*
 *
 */
#include <cstdio>
#include <iostream>
#include <algorithm>

using namespace std;

int N, M;
int D[200005], T[200005];


int main(){
    //freopen("b4.in", "r", stdin);
    scanf("%d", &N);
    for (int i = 0; i < N; ++i) {
        scanf("%d", &D[i]);
    }
    scanf("%d", &M);
    for (int i = 0; i < M; ++i) {
        scanf("%d", &T[i]);
    }

    sort(D, D+N); // ascending sort of array
    sort(T, T+M); // ascending sort of array
    int i = 0, j = 0;

    bool success = true;
    while (j != M) {
        if (T[j] == D[i]) {
            i++;
            j++;
        } else {
            i++;
        }
        if (i == N) {
            success = (j == M);
            break;
        }
    }
    if (success) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}


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

int main() {
	int N;
	int A[210];

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

	int res = 0;

	while (true) {
		bool flg = false;
		for (int j = 0; j < N; j++) {
			if (A[j] % 2 != 0)flg = true;
		}
		
		if (flg) break;

		for (int j = 0; j < N; j++) {
			A[j] /= 2;
		}
		res++;
	}

	cout << res << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <math.h>
#include <deque>
using ll = long long;
using namespace std;

int main(){
    int n, a, cnt = 0;
    cin >> n;
    vector<int> A;
    for (int i = 0; i < n; i++) {
        cin >> a;
        if(a<0) {
            cnt++;
            A.push_back(-a);
        }
        else A.push_back(a);
    }
    sort(A.begin(), A.end());
    cnt %= 2;
    ll ans = 0;
    if(cnt==1){
        for (int i = 0; i < n; i++) {
            if(!i) ans -= A[i];
            else ans += A[i];
        }
    }
    else{
        for (int i = 0; i < n; i++) {
            ans += A[i];
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 892
/* Generated by powerful Codeforces Tool
 * You can download the binary file in here https://github.com/xalanq/cf-tool (win, osx, linux)
 * Author: step_by_step
 * Time: 2020-03-19 17:35:03
**/

//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
  
#include <iostream>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <assert.h>
#include <memory.h>
#include <time.h>
#include <bitset>

#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = (l); i < (r); i++)
#define repb(i, r, l) for (int i = (r); i > (l); i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define mp(a, b) make_pair(a, b)
#define rank qwertyuio
#define next dfghjk
#define prev fhsgfhjf
#define plus fsghsf
#define minus ytryr
  
using namespace std;
  
inline bool setmin(int &x, int y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(int &x, int y) { return (y > x) ? x = y, 1 : 0; }
inline bool setmin(ll &x, ll y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(ll &x, ll y) { return (y > x) ? x = y, 1 : 0; }
  
const int N = 100000;
const int inf = (int)1e9 + 1;
const ll big = (ll)1e18 + 1;
const int P = 239;
const int P1 = 31;
const int P2 = 57;
const int MOD = (int)1e9 + 7;
const int MOD1 = (int)1e9 + 9;
const int MOD2 = 998244353;
const ld eps = 1e-9;
const double pi = atan2(0, -1);
const int ABC = 26;

int main()
{
    //freopen("circus.in", "r", stdin);
    //freopen("circus.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.precision(20);
    cout << fixed;
    //ll TL = 10.95 * CLOCKS_PER_SEC;
    //clock_t time = clock();
    string s;
    cin >> s;
    int l = 0, r = sz(s), mid;
    while (r - l > 1) {
    	mid = (l + r) / 2;
    	bool ok = false;
    	rep(j, 0, 2) {
    		int a = j, b = mid;
    		if (b % 2 != j) {
    			b--;
    		}
    		rep(i, 0, sz(s)) {
	    		if (s[i] == '0') {
	    			a--;
	    			b--;
	    			if (a < 0) {
	    				a += 2;
	    			}
	    			if (b < a) {
	    				break;
	    			}
	    		} else if (s[i] == '1') {
	    			a++;
	    			b++;
	    			if (b > mid) {
	    				b -= 2;
	    			}
	    			if (b < a) {
	    				break;
	    			}
	    		} else {
	    			a--;
	    			if (a < 0) {
	    				a += 2;
	    			}
	    			b++;
	    			if (b > mid) {
	    				b -= 2;
	    			}
	    			if (b < a) {
	    				break;
	    			}
	    		}
	    	}
	    	if (a <= b) {
	    		ok = true;
	    		break;
	    	}
    	}
    	ok ? r = mid : l = mid;
    }
    cout << r << "\n";
    return 0;
}



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

int main(){
	int a,b; cin>>a>>b;
	int k=a+b+1;
	string s; cin>>s;
	int cnt=0;
	rep(i,k){
		if(s[i]=='-') cnt++;
	}
	if(cnt==1&&s[a]=='-') cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

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

int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(a+b+c>=22){
    cout<<"bust"<<endl;
  }
  else{
    cout<<"win"<<endl;
  }

  return 0;
}

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

int main ( void ) {

  int N, n, i, j;
  int cnt = 0;

  scanf("%d", &N);
  for ( i = 0; i < N; i++ ) {
    scanf("%d", &n);
    for ( j = 2; j <= sqrt ( n ); j++ ) {
      if ( n == 2 ) {
        break;
      }
      if ( n % j == 0 ) {
        cnt++;
        break;
      }
    }
  }
  printf ( "%d\n", N - cnt);
}



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

inline int read(){int x=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}return x*f;}
using namespace std;

int main( int argc , char * argv[] ){
	//freopen( "in.txt" , "r" , stdin );
	int n ;
	cin >> n;
	int sum = 0 , t = 1;
	while( sum < n )
		sum += t,
		t++;
	cout << t - 1 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
#define ff first
#define ss second
#define pb push_back
#define debug(val) cerr << "The value of " << #val << " is = " << val << '\n';
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 922337203685477;
const ll mininf = -922337203685477;
const ll nax = 1e5 + 5;
ll h, kedalaman=0, ans=1;

ll solve(ll x){
		if(x==1){
			return 1;
		}
		else{
			return solve(x/2)*2+1;
		}
	}

int main(){
	IOS
	cin >> h;
	cout << solve(h) << '\n';
}




Measured memory_bytes: 3620
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List
import qualified Data.Vector.Unboxed as VU

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    [l, r] <- getIntList
    let r' = min r (l + 2018)
    let lr = VU.fromList $ map (`mod` 2019) [l..r']
    print $ minimum [ mod2019 (lr VU.! i) (lr VU.! j)|i <- [0..(VU.length lr - 2)], j <- [i+1..(VU.length lr - 1)]]

mod2019 n m = fm $ (fm n) * (fm m)
    where fm x = x `mod` 2019

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

const int64_t MOD = 998244353;
void add(int64_t& a, int64_t b){
    a = (a+b) % MOD;
}
void mul(int64_t& a, int64_t b){
    a = a*b % MOD;
}

int main(){
    string str;
    cin >> str;
    int N = str.size();
    vector<int> S(N);
    for(int i=0; i<N; i++) S[i] = str[i] - '0';
    int K;
    cin >> K;
    int One = accumulate(S.begin(), S.end(), 0);
    int Zero = N-One;
    K = min(K, One);

    // 0 で区切った時の各エリアの1の個数
    vector<int> one;
    int len = 0;
    for(int i=0; i<N; i++){
        if(S[i]){
            len++;
        }else{
            one.push_back(len);
            len = 0;
        }
    }
    one.push_back(len);
    // 各エリアより後に1がいくつあるか
    vector<int> aft(Zero+1);
    for(int i=Zero-1; i>=0; i--) aft[i] = aft[i+1] + one[i+1];

    // エリアiまで見て、操作をj回使って、1をk回使った
    static int64_t dp[310][310][310];
    dp[0][0][0] = 1;
    for(int i=0; i<=Zero; i++){
        // 元々あった one[i] 個の1を全部は使わないパターン
        // 0～(one[i]-1) 個使って合計k個になるような遷移元を累積和で処理
        for(int j=0; j<=K; j++){
            int64_t s = 0;
            for(int k=0; k<=One; k++){
                add(s, dp[i][j][k]);
                if(k >= one[i]) add(s, MOD - dp[i][j][k-one[i]]);
                // 残っている1の個数が aft[i] 個以下なら遷移
                if(One-k <= aft[i]) add(dp[i+1][j][k], s);
            }
        }
        // 元々あった one[i] 個の1を全部使って、さらに移動してきた1を0個以上使うパターン
        for(int j=0; j<=K; j++) for(int k=0; k<=One; k++){
            // 移動してきた1を1個使って同じiに遷移
            add(dp[i][j+1][k+1], dp[i][j][k]);
            // one[i] 個の1を使い、残っている1の個数が aft[i] 個以下ならi+1に遷移
            if(One-(k+one[i]) <= aft[i]) add(dp[i+1][j][k+one[i]], dp[i][j][k]);

        }
    }

    int64_t ans = 0;
    for(int j=0; j<=K; j++) add(ans, dp[Zero+1][j][One]);
    cout << ans << endl;
    return 0;
}


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


int main() {
  int n, x;
  cin >> n >> x;
  vector<int> m(n);
  rep(i,n) cin >> m[i];
  rep(i,n){
    x -= m[i];
  }
  int mn = 1000;
  rep(i,n){
    if(m[i] < mn) mn = m[i];
  }
  int d = x/mn;
  cout << n+d << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,a[100];
int main()
{
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    cout<<(a[n-1]-a[0]);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define eoi ios::sync_with_stdio(0),ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
int main()
{
    eoi;
int a;
string s;
cin>>a>>s;
int sum=1;
for(int i=1;i<s.length();i++){
    if(s[i]!=s[i-1]){sum+=1;}
}
cout<<sum;


}


Measured memory_bytes: 512