akhauriyash/Code-Regression huggingface dataset:
use std::io;
use std::str::FromStr;

fn input_tuple() -> (u64, u64) {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    let vec: Vec<u64> = line.split_whitespace().map(|s| s.parse().unwrap()).collect();
    (vec[0], vec[1])
}

fn main() {
    let (mut a, mut b) = input_tuple();
    a -= 1;
    b -= 1;
    let k = 100;
    println!("{} {}", k, k);
    for i in 0..k/2 {
        for j in 0..k {
            if i % 2 == 0 && j % 2 == 0 && a > 0 {
                a -= 1;
                print!(".");
            } else {
                print!("#");
            }
        }
        println!();
    }
    for i in 0..k/2 {
        for j in 0..k {
            if i % 2 != 0 && j % 2 == 0 && b > 0 {
                b -= 1;
                print!("#");
            } else {
                print!(".");
            }
        }
        println!();
    }
}


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

#define lint long long
#define P pair<int, int>
#define LLP pair<long long, long long>
#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define repr(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())

const int IINF = (1 << 30) - 1;
const long long LLINF = 1LL << 61;
const long long MOD = 1000000007LL;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

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

    int n;
    cin >> n;

    string s;
    cin >> s;

    int r = 0, b = 0;
    rep(i, s.size()){
        if(s[i] == 'R'){
            ++r;
        }else{
            ++b;
        }
    }

    if(r > b){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
// #define int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;

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

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { return a * b / GCD(a, b); }

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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int a[20];
int x[20][20];
int y[20][20];

int counter(int x){
  if(x==0) return 0;
  return counter(x>>1)+(x&1);
}

signed main()
{
  int n;
  cin>>n;
  
  for(int i=1; i<=n; i++){
    cin>>a[i];
    for(int j=1; j<=a[i]; j++){
      cin>>x[i][j]>>y[i][j];
    }
  }
  int ans=0;
  for(int bits=1; bits<(1<<n); bits++){
    bool ok=true;
    for(int i=1; i<=n; i++){
      if(!(bits & (1<<(i-1)))) continue;
      for(int j=1; j<=a[i]; j++){
        if(((bits>>x[i][j]-1)&1) ^ y[i][j]) ok = false;
      }
    }
    if(ok) chmax(ans, counter(bits));
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>
#include <queue>
#include <stack>
#include <unordered_map>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
#define DBG(X) cout << #X << "=" << (X) << '\n';
#define SAY(X) cout << (X) << '\n';
#else
#define DBG(X)
#define SAY(X)
#endif

#define M_PI       3.14159265358979323846

using namespace std;

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

const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

ll solve()
{
    std::string s = fetch<std::string>();
    ll K = fetch<int>();

    if (s.empty() || K == 0)
        return 0;

    if (s.length() == 1)
        return K / 2;

    ll counter = 0;
    ll charCounter = 1;
    char prevChar = s[0];
    ll i = 0;

    while (i < s.length())
    {
        charCounter = 1;
        prevChar = s[i++];

        while (i < s.length() && s[i] == prevChar)
        {
            ++charCounter;
            ++i;
        }

        counter += charCounter / 2;
    }

    if (s.back() != s[0])
    {
        return counter * K;
    }
    else
    {
        ll frontCounter = 1;

        for (ll i = 1; i < s.length() && s[i] == s[0]; ++i)
            ++frontCounter;

        if (frontCounter == s.length())
            return (s.length() * K) / 2;

        ll backCounter = 1;

        for (ll i = s.length() - 2; i >= 0 && s[i] == s.back(); --i)
            ++backCounter;

        return counter * K - ((frontCounter / 2) + (backCounter / 2) - (frontCounter + backCounter) / 2) * (K - 1);
    }
}

int main() {
    fast_io();

    ll i = solve();

    std::cout << i << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <string>

using namespace std;
using i64 = std::int64_t;

int main() {
  string s{};
  cin >> s;
  i64 n{0};
  for (const char &c : s) {
    n += c - '0';
  }
  cout << ((n % 9 == 0) ? "Yes" : "No") << endl;

  return 0;
}


Measured memory_bytes: 3364
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 998244353
 
int main() {
 
	ll n,k;
	cin>>n>>k;

	vector<ll> A(n,0);
	ll sum = 0;

	for(ll i=0;i<n;i++) {
		cin>>A[i];
		sum = sum+A[i];
	}

	vector<ll> fact;

	for(ll i=1;i<=sqrt(sum);i++) {
		if(i*i==sum)
			fact.push_back(i);
		else if(sum%i==0){
			fact.push_back(i);
			fact.push_back(sum/i);
		}
	}

	sort(fact.begin(), fact.end());

	vector<pair<ll,ll> > diff(n);
	bool flag = 0;
	ll res = 1;
	for(ll i=fact.size()-1;i>=0;i--) {
		ll f = fact[i];

		for(ll j=0;j<n;j++) {
			ll a = A[j]%f;
			diff[j]={a,f-a};
		}

		sort(diff.begin(),diff.end());
		// for(ll i=0;i<n;i++)
		// 	cout<<diff[i].first<<" "<<diff[i].second<<endl;

		vector<ll> left(n,0);
		for(ll j=0;j<n;j++){
			left[j] = (j-1>=0?left[j-1]:0) + diff[j].first;
		}
		// for(ll j=0;j<n;j++)
		// 	cout<<left[j]<<" ";
		// cout<<endl;

		vector<ll> right(n,0);
		for(ll j=n-1;j>=0;j--){
			right[j] = (j+1<n ? right[j+1]:0) + diff[j].second;
		}
		// for(ll j=0;j<n;j++)
		// 	cout<<right[j]<<" ";
		// cout<<endl;

		for(ll j=0;j<n-1;j++) {
			if(left[j]==right[j+1]){
				if(left[j]<=k){
					res = f;
					flag=1;
					break;
				}
			}
		}
		if(flag) break;

	}

	cout<<res<<endl;

	return 0;
} 


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

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

int main() {
    int n;
    cin >> n;
    vector<int> h(n);
    rep(i,n){
        cin >> h[i];
    }
    int present = h[0] > 1 ? h[0] : 0;
    rep(i,n-1){
        if(h[i+1] < present){
            cout << "No" << endl;
            return 0;
        }
        if(h[i] < h[i+1]){
            present = h[i+1] - 1;
        }
    }
    cout << "Yes" << endl;
}


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

int main() {
  int n, k;
  cin >> n >> k;

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

  int d = 0;
  for (int i = 0; i < n; i++) {
    if (x[i] < k - x[i])
      d += 2 * x[i];
    else
      d += 2 * (k - x[i]);
  }

  cout << d << endl;
}

Measured memory_bytes: 256
//# define FLAG
///delet....................................
# include   <bits/stdc++.h>
using namespace std;
# define    pb                      push_back
# define    mp                      make_pair
# define    IOS                     ios::sync_with_stdio(false)
# define    mem(a,b)                memset(a,b,sizeof(a))
# define    FO(i,n,a)               for(int i=n; i>=a; --i)
# define    FOR(i,a,n)              for(int i=a; i<=n; ++i)
# define    pi                      acos(-1.0)
# define    MAX(a,b)                (a)>(b)?(a):(b)
# define    MIN(a,b)                (a)<(b)?(a):(b)
# define    LINF                    0xfcfcfcfcfcfcfcf
# define    INF                     0x3f3f3f3f
# define    MOD                     1000000007
# define    eps                     0.00000001
# define    hr                      putchar('\n')
# define    bug                     puts("H");
# pragma    comment(linker,"/STACK:1024000000,1024000000")
typedef     vector<int>             VI;
typedef     long long               LL;
typedef     unsigned long long      ULL;
inline char gtc() {
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
# define    Template                LL
inline Template read() {
    int flag=1;
    char ch=gtc();
    if(ch==EOF)return EOF;
    Template sum=0;
    while(!((ch>='0'&&ch<='9')||ch=='-'))ch=gtc();
    if(ch=='-')flag=-1,ch=gtc();
    while(ch>='0'&&ch<='9')sum=sum*10+ch-'0',ch=gtc();
    return sum*flag;
}
inline void out(Template x) {
    if(x<0)putchar('-'),x=-x;
    if(x>9)out(x/10);
    putchar(x%10+'0');
}
///coding...................................

int main() {
    IOS;
#ifdef FLAG
    freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
#endif
    int a,b,n,num=0;
    cin>>a>>b;
    FOR(i,1,a) {
        cin>>n;
        num+=min(n,b-n)*2;
    }
    cout<<num<<endl;
    return 0;
}










///delete FLAG..............................




Measured memory_bytes: 384
#define _USE_MATH_DEFINES

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
#include <climits>
#include <cmath>
#include <utility>
#include <iomanip>

using namespace std;



bool my_compare(pair<int, string> a, pair<int, string> b) {
	// 基本はfirstで比較
	if (a.first != b.first){
		// return a.first < b.first; // 昇順
		return a.first > b.first; // 降順
	}

	// それ以外はsecondで比較
	if (a.second != b.second){
		return a.second < b.second;
	}
	else{
		// どちらも同じ
		return true;
	}
}

int main(int argc, char *argv[])
{
	//input
	int n;
	cin >> n;

	map<string, int> s;
	for (int i = 0; i < n; i++){
		string si;
		cin >> si;

		s[si]++;
	}


	//calc
	vector<pair<int, string> > v;
	for (map<string, int>::iterator it = s.begin(); it != s.end(); ++it) {
		v.push_back(make_pair(it->second, it->first));
	}
	sort(v.begin(), v.end(), my_compare);



	//ans
	for (size_t i = 0; i < v.size(); i++){
		if (v[i].first == v[0].first){
			cout << v[i].second << endl;
		}
	}


	return 0;
}


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

int main()
{
  int N, num = 1, count = 0, tmp;
  vector<int> a(1000001);

  cin >> N;
  for (int i = 1; i <= N; i++)
    cin >> a[i];
  while (num != 2 && a[num] != 0)
  {
    tmp = num;
    num = a[num];
    a[tmp] = 0;
    count++;
  }
  if (num != 2)
    count = -1;
  cout << count << endl;
}

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

using namespace std;

map< pair<int,int> , int> mp;

int dx[]={0, 0, 0,-1,-2,-2,-2,-1,-1};
int dy[]={0,-1,-2, 0, 0,-1,-2,-2,-1};
int w,h,n;

bool in_range(int x,int y,int i)
{
     int lx,ly,rx,ry;

     lx = x + dx[i];
     ly = y + dy[i];
     rx = lx + 2;
     ry = ly + 2;
     //cout<<lx<<" "<<ly<<" "<<rx<<" "<<ry<<endl;
     if(lx>=1 && ly>=1 && rx<=h && ry<=w)return true;
     return false;
}

int main(void)
{
   cin>>h>>w>>n;
   while(n--)
   {
       int x,y;
       scanf("%d %d",&x,&y);

       for(int i=0;i<9;i++)
           if(in_range(x,y,i))
              mp[{x+dx[i],y+dy[i]}]++;

   }

   map< pair<int,int> ,int >::iterator it=mp.begin();

   long long res[10]={0};

   for(;it!=mp.end();it++)
      {
          int val = (*it).second;
          res[val]++;
      }

    long long tot = (long long)(w-2)*(h-2);

    for(int i=1;i<10;i++)tot-=res[i];
    res[0]=tot;

    for(int i=0;i<10;i++)cout<<res[i]<<endl;

}


Measured memory_bytes: 56448
from itertools import permutations
import sys

sys.setrecursionlimit(10 ** 6)
from bisect import *
from collections import *
from heapq import *

def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def SI(): return sys.stdin.readline()[:-1]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
int1 = lambda x: int(x) - 1
def MI1(): return map(int1, sys.stdin.readline().split())
def LI1(): return list(map(int1, sys.stdin.readline().split()))
p2D = lambda x: print(*x, sep="\n")
dij = [(1, 0), (0, 1), (-1, 0), (0, -1)]

def main():
    n=II()
    s=set()
    for _ in range(n):
        a=II()
        if a in s:s.remove(a)
        else:s.add(a)
    print(len(s))

main()


Measured memory_bytes: 12268
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include <map>
#include <fstream>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <assert.h>
#include <complex>
#include <omp.h>
using namespace std;
#define eps 0.000001
#define LONG_INF 10000000000000
#define GOLD 1.61803398874989484820458
#define seg_size 65536*4
#define REP(i,n) for(long long i = 0;i < n;++i)
unsigned long xor128() {
	static unsigned long x = time(NULL), y = 362436069, z = 521288629, w = 88675123;
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}
int bad[10000000] = {};
int main(){
#define int long long
	int n, k;
	cin >> n >> k;
	vector<int> aa;
	REP(i, n) {
		int a;
		cin >> a;
		aa.push_back(a);
	}
	vector<int> input;
	REP(i, n) {
		long long geko = 0;
		for (int q = i; q < n; ++q) {
			geko += aa[q];
			input.push_back(geko);
		}
	}
	long long geko = 1;
	for (int q = 1; q < 40; ++q) {
		geko *= 2LL;
	}
	long long ans = 0;
	while (geko != 0) {
		long long cnt = 0;
		for (int i = 0; i < input.size(); ++i) {
			if (bad[i] == false&&(geko & input[i]) != 0LL) {
				cnt++;
			}
		}
		if (cnt >= k) {
			ans += geko;
			for (int i = 0; i < input.size(); ++i) {
				if ((geko & input[i]) == 0LL) bad[i] = true;
			}
		}
		geko /= 2LL;
	}
	cout << ans << endl;
	return 0;
}


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

using namespace std;

int main() {
  char s[15];
  scanf("%s", s);
  int ans = INT_MAX;
  for (int i = 0; i < strlen(s) - 2; i++) {
    int x = s[i] - '0';
    x *= 10;
    x += s[i + 1] - '0';
    x *= 10;
    x += s[i + 2] - '0';
    ans = min(abs(753 - x), ans);
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 256
def f(x, y, z):
    return (x+y+z)**2 - x*y - y*z - z*x


N = int(input())
pattern = {i:0 for i in range(1,10001)}

for x in range(1, 101):
    for y in range(1, 101):
        for z in range(1, 101):
            result = f(x, y, z)
            try:
                pattern[result] += 1
            except KeyError:
                pass
for i in range(1, N+1):
    print(pattern[i])


Measured memory_bytes: 69068
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <iomanip>
#include <numeric>
#include <functional>
#include <queue>
#include <tuple>

using namespace std;

using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using ll = long long;
using vll = vector<ll>;
using pii = pair<int, int>;
using vb = vector<char>;
using vvb = vector<vb>;

#define REP(i, a, b) for (int i = a; i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(),(x).end()
#define iter(c) __typeof((c).begin())
#define tr(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++)
#define mp(a, b) make_pair(a,b)

#define fi first
#define sn second
#define decpii(p) p.fi--,p.sn--;


#ifdef LOCAL
#define dump(c) cerr << "> " << #c << " = " << (c) << endl;
#define dumpn(c) cerr << "> " << #c << " = " << (c) << ", ";
#else
#define dump(c) ;
#define dumpn(c) ;
#endif


template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
    return os << '(' << p.first << ',' << p.second << ')';
}

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &a) {
    os << '[';
    rep(i, (int) a.size())os << (i ? " " : "") << a[i];
    return os << ']';
}


int dxf[] = {1, 0, -1, 0};
int dyf[] = {0, -1, 0, 1};

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

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

inline vi uni(vi &vec) {
    sort(vec.begin(), vec.end());
    vec.erase(std::unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

inline ll fpow(ll x, ll p) {
    ll ans = 1;
    while (p > 0) {
        if ((p & 1) == 1) {
            ans *= x;
        }
        x *= x;
        p >>= 1;
    }
    return ans;
}

struct ____ {
    ____() {
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout << fixed << setprecision(20);
    };
} ________;

int solve() {
    int X;
    cin >> X;
    ll res = 1;
    REP(b, 1, 1000 + 1) {
        ll p = b;
        REP(i, 2, 1000 + 1) {
            p *= b;
            if(p <= X)
                chmax(res, p);
        }
    }
    return res;
}

int main() {
    cout << solve() << endl;
    return 0;
}


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


class Program
{
    static void Main(string[] args)
    {
        // 入力
        //var s = Console.ReadLine();
        //var n = long.Parse(Console.ReadLine());
        long[] input = Console.ReadLine().Split().Select(long.Parse).ToArray();
        long n = input[0];
        long k = input[1];
        long[] a = Console.ReadLine().Split().Select(long.Parse).ToArray();

        int[] visited = new int[n];
        var list = new List<long>();
        long i = 0;
        int count = 0;
        int loopstart = 0;
        int loopend = 0;
        while (true)
        {
            if (visited[i] == 2)
            {
                loopend = count + 1;
                break;
            }
            else if (visited[i] == 1 && loopstart == 0)
            {
                loopstart = count + 1;
                visited[i]++;
                list.Add(i);
                i = a[i] - 1;
            }
            else
            {
                visited[i]++;
                list.Add(i);
                i = a[i] - 1;
            }
            count++;
        }

        long ans = 0;
        if (k < list.Count)
        {
            ans = list[(int)(k)] + 1;
        }
        else
        {
            long tmp = k % (loopend - loopstart);
            long tmp2 = 0;
            for (int t = loopstart - 1; t < loopend - 1; t++)
            {
                if (tmp == t % (loopend - loopstart))
                {
                    tmp2 = t;
                    break;
                }
            }
            ans = list[(int)tmp2] + 1;
        }


        // 出力
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 51032
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  int k,n,ans=0,an;cin>>k>>n;
  int a[2*n];
  for(int i=0;i<n;i++){
    cin>>a[i];
    a[i+n]=k+a[i];
  }
  sort(a,a+2*n);
  for(int i=0;i<n-1;i++){
    ans+=a[i+1]-a[i];
  }
  an=ans;
  for(int i=0;i<n;i++){
    ans-=a[i+1]-a[i];
    ans+=a[i+n]-a[n+i-1];
    an=min(an,ans);
  }
  cout << an<<endl;
}

Measured memory_bytes: 1792
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <numeric>
#include <iomanip>
#define M_PI acos(-1)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1000000007;
const int MAX_V = 201;
int now = 0;

const int MAX = 200000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
struct edge {
	int t;
	ll cost;
	edge(int _t, ll _cost) : t(_t)
		, cost(_cost) {
	}
};
bool isPrime(int n) {

	if (n == 1) return false;
	for (ll i = 2; i * i <= n; i++)
	{
		if (n % i == 0) return false;
	}
	return true;
}
void Solve() {
	int n,a,b;
	cin >> n >> a >> b;
	string s;
	cin >> s;
	int ab = 0;
	int bs = 0;
	for (size_t i = 0; i < n; i++)
	{
		if (s[i] == 'a') {
			if (ab < (a + b)) {
				cout << "Yes" << endl;
				ab++;
				continue;
			}
		}
		else if (s[i] == 'b') {
			if (ab < (a + b) && bs < b) {
				cout << "Yes" << endl;
				ab++;
				bs++;
				continue;
			}
		}
		cout << "No" << endl;
	}
}
int main() {
	Solve();
	return 0;
}



Measured memory_bytes: 896
n = int(input())
s = list(input())
ans = ""

l = 0
for i in range(n):
    ans += s[i]
    if s[i] == ")":
        if l == 0:
            ans = "(" + ans
        else:
            l -= 1
    else:
        l += 1

ans += (")"*l)

print(ans)


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

int main(void){
    int a, b;
    cin>>a>>b;
    int k=(a+b)/2;
    if ((min(a, b)<k) and (k<max(a, b)) and ((a+b)%2==0)){
        cout<<k<<endl;
    }
    else{
        cout<<"IMPOSSIBLE"<<endl;
    }
}

Measured memory_bytes: 256
n, x, m = map(int, input().split())
a = x
s = 0
h = []
h.append(a)
i = 0
fl = 0
while i < n:
    s += a
    a = (a*a) % m
    if a == 0:
      break
    i += 1
    if fl == 0 and a in h:
      fl = 1
      po = h.index(a)
      ss = 0
      for j in range(po):
        ss += h[j]
      s2 = s - ss
      f = (n - po) // (i - po)
      s2 *= f
      s = s2 + ss
      i2 = i - po
      i2 *= f
      i = i2 + po
    else:
      h.append(a)
print(s)

Measured memory_bytes: 74184
#include <stdio.h>
#include <string.h>
int main(void){
int i,kai=0,kei=0;
char a[12000];
while(scanf("%s",a)!=EOF){


for(i=0;i<strlen(a)-2;i++){
    if(a[i]=='I'&&a[i+1]=='O'&&a[i+2]=='I'){kai++;}
    if(a[i]=='J'&&a[i+1]=='O'&&a[i+2]=='I'){kei++;}

}

printf("%d\n",kei);
printf("%d\n",kai);
kai=kei=0;
}
return (0);
}

Measured memory_bytes: 1740
n=int(input())
xyh=[]
for i in range(n):
	x,y,h=map(int,input().split())
	xyh.append((x,y,h))
def dis(a,b):
	return abs(a[0]-b[0])+abs(a[1]-b[1])
for i in range(101):
	for j in range(101):
		for k in range(n):
			if xyh[k][2]!=0:
				kari=dis(xyh[k],(i,j))+xyh[k][2]
				break
		f=1
		for k in range(n):
			if xyh[k][2]!=max(kari-dis(xyh[k],(i,j)),0):
				f=0
				break
		if f:
			print(i,j,kari)
			exit()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n, m;
  int a[10000];
  cin >> n >> m;
  for (int i = 0; i < m; i++) cin >> a[i];

  long long int s = 0;
  for (int i = 0; i < m; i++) s += a[i];

  if (s > n) cout << -1 << endl;
  else cout << n - s << endl;

  return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define len(x) (int) (x.size())
using namespace std;
typedef long long ll;
inline void FAST_IO(){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);}

int main() {
    FAST_IO();
    string s;
    int n;
    cin >> s >> n;
    deque<char> mydq(s.begin(), s.end());

    int ti, fi;
    char ci;
    bool reversed = false;
    for(int i = 0; i < n; i++) {
        cin >> ti;
        if (ti == 1) {
            reversed = !reversed;
        }
        else {
            cin >> fi >> ci;

            if (fi == 1 && reversed) {
                mydq.emplace_back(ci);
                // s += ci;
            }
            else if (fi == 1 && !reversed) {
                mydq.emplace_front(ci);
                // s = ci + s;
            }
            else if (fi == 2 && reversed) {
                mydq.emplace_front(ci);
                // s = ci + s;
            }
            else if (fi == 2 && !reversed) {
                mydq.emplace_back(ci);
                // s += ci;
            }
        }
    }

    if (reversed) {
        for(int i = len(mydq)-1; i >= 0; i--) {
            cout << mydq[i];
        }
    }
    else {
        for(int i = 0; i < len(mydq); i++) {
            cout << mydq[i];
        }
    }
    
    cout << '\n';
    
    return 0;
}

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

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

bool cmp(const pair<double,string> &a,const pair<double,string> &b){
	return a.first==b.first ? a.second < b.second : a.first > b.first;
}

int main(void){
	int n;
	while(cin >> n){

		if(n==0)
			break;

		vector<pair<double,string>> res;

		rep(i,n){
			string l;
			int p,a,b,c,d,e,f,s,m;
			cin >> l >> p >> a >> b >> c >> d >> e >> f >> s >> m;

			int sp=m*f*s-p;
			int ti=(a+b+c+d+e)+(d+e)*(m-1);
			res.pb(mp(1.0*sp/ti,l));
		}

		sort(res.begin(),res.end(),cmp);

		for(auto &i : res)
			cout << i.second << endl;
		cout << '#' << endl;
	}	
	return 0;
}

Measured memory_bytes: 1220
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        boolean[] b = new boolean[3];
        String s = sc.next();
        for (int i = 0;i < 3;++i){
            if(s.charAt(i) == 'a'){
                b[0] = true;
            }
            else if(s.charAt(i) == 'b'){
                b[1] = true;
            }
            else if(s.charAt(i) == 'c'){
                b[2] = true;
            }
        }
        if(b[0]&&b[1]&&b[2])System.out.println("Yes"); else System.out.println("No");
    }
}

Measured memory_bytes: 21716
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <array>
#include <tuple>
#include <random>

using namespace std;
typedef long long int ll;

#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 all(x) (x).begin(), (x).end()

#define inf 10000000000

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

    ll a1, a2, a3;
    cin >> a1 >> a2 >> a3;
    cout << min(min(abs(a2 - a1) + abs(a3 - a2), abs(a3 - a1) + abs(a2 - a3)), min(min(abs(a1 - a2) + abs(a3 - a1), abs(a3 - a2) + abs(a1 - a3)), min(abs(a2 - a3) + abs(a1 - a2), abs(a1 - a3) + abs(a2 - a1)))) << endl;
}

Measured memory_bytes: 256
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), ", ", cout) << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, string sep = " ", ostream &os = cout)
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p)
{
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), ", ", os) << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(ll, N);
    IN(string, c);
    ll ans = 0;
    ll i = 0;
    ll j = N - 1;
    while (i < j)
    {
        while (i < j and c[i] == 'R')
        {
            ++i;
        }
        while (j > i and c[j] == 'W')
        {
            --j;
        }
        if (i < j)
        {
            swap(c[i], c[j]);
            ++ans;
            ++i;
            --j;
        }
    }
    OUT(ans);
}

Measured memory_bytes: 3752
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=(a); i<(b); i++)
typedef unsigned long long ll;
using namespace std;

int main(){
	int n;
	cin>>n;
	int a[n];
	bool flag=1;
	For(i,0,n){
		cin>>a[i];
		if (a[i]%2==0)
			if (!((a[i]%5==0) || (a[i]%3==0)))
				flag=0;
	}
	cout<<((flag)?"APPROVED":"DENIED");
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<algorithm>
#include<cmath>
#define LL long long
#define N 1000001
#define NN 1001
using namespace std;
LL i,j,l1,l2,wz,sum,ans=N;
string a,b;
int main()
{
	getline(cin,a);
	getline(cin,b);
	l1=a.size();
	l2=b.size();
	for(i=0;i<l1-l2+1;i++)
	{
		wz=0,sum=0;
		for(j=i;j<i+l2;j++)
		{
			if(b[wz]!=a[j]) ++sum;
			++wz;
		}
		ans=min(ans,sum);
	}
	printf("%lld",ans);
	return 0;
}
/*
cabacc
abc
1
*/


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

using namespace std;

int main()
{
    int a,b,c,d,n;

    cin>>n;
    a=(n/1000)%10;
    b=(n/100)%10;
    c=(n/10)%10;
    d=n%10;
    if(a+b+c+d==7)
        cout<<a<<"+"<<b<<"+"<<c<<"+"<<d<<"=7";
    else
       if(a+b+c-d==7)
        cout<<a<<"+"<<b<<"+"<<c<<"-"<<d<<"=7";
       else
        if(a+b-c+d==7)
        cout<<a<<"+"<<b<<"-"<<c<<"+"<<d<<"=7";
       else if(a+b-c-d==7)
        cout<<a<<"+"<<b<<"-"<<c<<"-"<<d<<"=7";
        else
         if(a-b+c+d==7)
        cout<<a<<"-"<<b<<"+"<<c<<"+"<<d<<"=7";
         else
           if(a-b+c-d==7)
              cout<<a<<"-"<<b<<"+"<<c<<"-"<<d<<"=7";
            else
              if(a-b-c+d==7)
                 cout<<a<<"-"<<b<<"-"<<c<<"+"<<d<<"=7";
                  else
                    cout<<a<<"-"<<b<<"-"<<c<<"-"<<d<<"=7";
}



Measured memory_bytes: 256
#define  _CRT_SECURE_NO_WARNINGS
#pragma comment (linker, "/STACK:526000000")

#include "bits/stdc++.h"

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144 * 4LL
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

void init() {
	iostream::sync_with_stdio(false);
	cout << fixed << setprecision(20);
}

#define int ll
int grid[100][100] = {};
void solve() {
	int n, m;
	cin >> n >> m;
	vector<string> inputs;
	tuple<int, int, int> now;
	string c;
	REP(i, m + 2) {
		c.push_back('#');
	}
	inputs.push_back(c);
	REP(i, n) {
		string s;
		cin >> s;
		s.push_back('#');
		s.insert(s.begin(), '#');
		inputs.push_back(s);
	}
	inputs.push_back(c);
	m += 2;
	n += 2;

	int dx[4] = { -1,0,1,0 };
	int dy[4] = { 0,1,0,-1 };
	string nya = "^>v<";
	pair<int,int> goal;
	REP(i, n) {
		REP(q, m) {
			REP(j, 4) {
				if (nya[j] == inputs[i][q]) {
					now = make_tuple(i, q, j);
					inputs[i][q] = '.';
				}
			}
			if (inputs[i][q] == 'G') {
				inputs[i][q] = '.';
				goal = mp(i, q);
			}
		}
	}
	REP(tea, 1000000) {
		grid[get<0>(now)][get<1>(now)] = 1;
		if (mp(get<0>(now), get<1>(now)) == goal) {
			int ans = 0;
			REP(i, n) {
				REP(q, m) {
					ans += grid[i][q];
				}
			}
			cout << ans << endl;
			return;
		}
		get<2>(now)++;
		get<2>(now) %= 4;
		int next_x = get<0>(now) + dx[get<2>(now)];
		int next_y = get<1>(now) + dy[get<2>(now)];
		if (inputs[next_x][next_y] == '.') {
			get<0>(now) = next_x;
			get<1>(now) = next_y;
			continue;
		}
		REP(t,4) {
			get<2>(now) += 3;
			get<2>(now) %= 4;
			int next_x = get<0>(now) + dx[get<2>(now)];
			int next_y = get<1>(now) + dy[get<2>(now)];
			if (inputs[next_x][next_y] == '.') {
				get<0>(now) = next_x;
				get<1>(now) = next_y;
				break;
			}
		}
	}
	cout << -1 << endl;
}

#undef int
int main() {
	init();
	solve();
}


Measured memory_bytes: 3256
import java.util.Scanner;
import java.util.ArrayList;

public class Main {
    public static int top;
    public static int prev;
    public static int a;
    public static int b;
    public static int c;
    public static int d;
    public static int e;
    public static int f;
    public static boolean disc;
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        a = sc.nextInt();
        b = sc.nextInt();
        c = sc.nextInt();
        d = sc.nextInt();
        e = sc.nextInt();
        f = sc.nextInt();
        Dice dice = new Dice(a, b, c, d, e, f);
        
        int i = sc.nextInt();

        while (sc.hasNext()) {
            disc = false;
            top = sc.nextInt();
            prev = sc.nextInt();
            rotate(dice, 0);
        }
    }
    
    public static void rotate(Dice dice, int num) {
        num++;
        if (num > 5) return;
        String[] dir = {"N", "S", "E", "W"};
        for (int i = 0; i < dir.length; i++) {
            if (disc) break;
            dice.move(dir[i]);
            if (dice.ary[0] == top && dice.ary[1] == prev) {
                System.out.println(dice.ary[2]);
                dice.set(a,b,c,d,e,f);
                disc = true;
                return;
            } else {
                rotate(dice, num);
            }
        }
    }
}

class Dice {
    public int[] ary;
    public Point p;
    public Dice(int a, int b, int c, int d, int e, int f) {
        ary = new int[6];
        ary[0] = a;
        ary[1] = b;
        ary[2] = c;
        ary[3] = d;
        ary[4] = e;
        ary[5] = f;
        p = new Point();
    }
    
    public void set(int a, int b, int c, int d, int e, int f) {
        ary[0] = a;
        ary[1] = b;
        ary[2] = c;
        ary[3] = d;
        ary[4] = e;
        ary[5] = f;
    }
    
    public void move(String s) {
        int t;
        switch(s) {
        case "N":
            t = ary[0];
            ary[0] = ary[1];
            ary[1] = ary[5];
            ary[5] = ary[4];
            ary[4] = t;
            p.y++;
            break;
        case "S":
            t = ary[0];
            ary[0] = ary[4];
            ary[4] = ary[5];
            ary[5] = ary[1];
            ary[1] = t;
            p.y--;
            break;
        case "E":
            t = ary[0];
            ary[0] = ary[3];
            ary[3] = ary[5];
            ary[5] = ary[2];
            ary[2] = t;
            p.x++;
            break;
        case "W":
            t = ary[0];
            ary[0] = ary[2];
            ary[2] = ary[5];
            ary[5] = ary[3];
            ary[3] = t;
            p.x--;
            break;
        }
    }
    public void showTop() {
        System.out.println(ary[0]);
    }
    public void showRight() {
        System.out.println(ary[2]);
    }
}

class Point {
    public int x;
    public int y;

    public Point() {
        x = 0;
        y = 0;
    }
}

Measured memory_bytes: 26452
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
#include <complex>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <iomanip>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)),(v).end())
#define bitcnt(x) __builtin_popcount(x)
#define fst first
#define snd second
#define Pqaz(T) priority_queue<T,vector<T>,greater<T>>
#define Pqza(T) priority_queue<T>
#define put(x) cout << x;
#define putsp(x) cout << x << ' ';
#define putbd cout << "---------------------------------------------" << endl;
#define putln(x) cout << x << endl;
#define debug(x) cerr << #x << "=" << x << endl;
#define ENJYU std::ios::sync_with_stdio(false);std::cin.tie(0);
#define yuiyui 0

typedef long long ll;
typedef unsigned long long ul;
typedef pair<int, int> intP;
typedef pair<ll, ll> llP;
typedef pair<ul, ul> ulP;
typedef complex<double> comp;
typedef vector <int> vec;
typedef vector <ll> vecll;
typedef vector <ul> vecul;
typedef vector <double> vecd;
typedef vector <vec> mat;
typedef vector <vecll> matll;
typedef vector <vecul> matul;
typedef vector <vecd> matd;

//vector の中身を出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

const int MAX = 200020;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const ll INFL = 1e18;
const ll MOD = 1e9+7;

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

//********************************template END****************************************//

void solve(void){

	int N, m;
	cin >> N >> m;

	vec imos(N+1, 0);

	while(m--)
	{
		int c, d;
		cin >> c >> d;
		imos[--c]++;
		imos[--d]--;
	}

	rep(N, i)
	{
		imos[i+1] += imos[i];
	}

	int ans = N+1, pre = 0, f = 0;

	rep(N, i)
	{
		if (imos[i] && !f)
		{
			pre = i;
			f = 1;
		}
		if (!imos[i] && f)
		{
			ans += (i-pre)*2;
			f = 0;
		}
	}

	if (f) ans += (N-pre) * 2;

	cout << ans << endl;

}

int main(void)
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return yuiyui;
}



Measured memory_bytes: 3108
a = []
for i in range(5):
    a.append(int(input()))

b = []
c = []
for j in range(5):
    if a[j] % 10 == 0:
        b.append(a[j]-10)
        c.append(10)
    else:
        c.append(a[j] % 10)
        b.append(a[j] - c[j])
        

b_sum = sum(b)
c_min = min(c)
c_sum = c_min + 4*10

print(b_sum + c_sum)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
const long long LLINF = 1LL<<60;
const int INF = 1e9;
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; }
typedef long long ll;
#define pint pair<int,int>
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n, a, b;
    cin >> n >> a >> b;

    if((b-a)%2==0) {
        ll ans2 = (b-a)/2;
        cout << ans2 << endl;

        return 0;
    }
    else {
        if(n-b<=a-1) {
            a += n-b+1;
            ll k2 = (n-a)/2;
            cout << k2+n-b+1 << endl;

            return 0;
        }
        else {
            b -= a;
            ll m = b/2;
            cout << m+a << endl;

            return 0;
        }
    }

    return 0;
}

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

#define INF 1e9
using namespace std;

#define REPR(i, n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()

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

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

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

typedef long long ll;

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


int main() {
    int N;
    string S;
    cin >> N;
    cin >> S;
    int count = 0;
    REP(i, N - 2) {
        string mightA = {S[i]};
        string mightB = {S[i + 1]};
        string mightC = {S[i + 2]};
        string mightABC = mightA + mightB + mightC;
        if ( mightABC == "ABC" ) count++;
    }
    cout << count << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
#include <sstream>
#include <time.h>
#include <numeric>
using namespace std;
//#define int long long
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define l1 list[index]
#define l2 list[index - 1]
#define l3 list[index + 1]
#define iif(i,j) ((i<0 && j<0) || (i>0 && j>0)) ? true : false 
typedef long long ll;
typedef pair<int, int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint, int> P1;
typedef pair<int, pint> P2;
typedef pair<pint, pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD = 1000000007;
const ll INF = 1e18;
const double PI = 3.14159265359;
int ca[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };




signed main() {
	int n, y;

	cin >> n >> y;

	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= n - i; j++) {
			//for (int k = 0; k <= n - i - j; k++) {
				int k = n - i - j;
				int num = 10000 * i + j * 5000 + k * 1000;
				if (num == y) {
					cout << i << " " << j << " " << k << " " << endl;
					return 0;
				}
			//}
		}
	}


	cout << "-1 -1 -1" << endl;




	return 0;
}

Measured memory_bytes: 256
import sys
from collections import deque
input = sys.stdin.buffer.readline

h,w,k = map(int,input().split())
x1,y1,x2,y2 = map(int,input().split())
x1,y1,x2,y2 = x1-1,y1-1,x2-1,y2-1

#46 . 64 @
c = [list(input()) for i in range(h)]

pq = [0]*(h*w)


dp = [10**7]*(h*w)


pq[x1*w + y1] = 3
dp[x1*w + y1] = 0
tank = deque([x1*w+y1])



while tank:

    
    now = tank.popleft()
    cost = dp[now]
    
    for i in range(1,k+1):
        if (now+i)%w != 0 and dp[now+i] > cost and c[(now+i)//w][(now+i)%w] == 46 and pq[now+i] < 5:
            pq[now+i] += 1 
            dp[now+i] = cost+1
            tank.append(now+i)
        else:
            break
    for i in range(1,k+1):
        if (now-i)%w != w-1 and dp[now-i] > cost and c[(now-i)//w][(now-i)%w] == 46 and pq[now-i] < 5:
            pq[now-i] += 1
            dp[now-i] = cost+1
            tank.append(now-i)
        else:
            break

    for i in range(1,k+1):
        if (now+i*w) < h*w and dp[now+i*w] > cost and c[(now+i*w)//w][(now+i*w)%w] == 46 and pq[now+i*w] < 5:
            pq[now+i*w] += 1
            dp[now+i*w] = cost+1
            tank.append(now+i*w)
        else:
            break
    for i in range(1,k+1):
        if (now-i*w) >= 0 and dp[now-i*w] > cost and c[(now-i*w)//w][(now-i*w)%w] == 46 and pq[now-i*w] < 5:
            pq[now-i*w] += 1
            dp[now-i*w] = cost+1
            tank.append(now-i*w)
        else:
            break


if dp[x2*w+y2] == 10**7:
    print(-1)
else:
    print(dp[x2*w+y2])





Measured memory_bytes: 156540