akhauriyash/Code-Regression huggingface dataset:
import std.stdio;
import std.algorithm;
import std.string;
import std.conv;
import std.math;

void main(){

    bool[3] a;
    a[0] = true;
    a[1] = false;
    a[2] = false;
    while(true){
	auto s = readln();
	if(stdin.eof()) break;
	s = chomp(s);
	swap(a[to!int(s[0]-'A')],a[to!int(s[2]-'A')]);
    }
    for(int i=0;i<3;i++){
	if(a[i]) writeln(to!char(i + to!int('A')));
    }
}

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

ostream& operator<<(ostream &out, string str) {
	for(char c : str) out << c;
	return out;
}
 
template<class L, class R> ostream& operator<<(ostream &out, pair<L, R> p) {
	return out << "(" << p.first << ", " << p.second << ")";
}
 
template<class T> auto operator<<(ostream &out, T a) -> decltype(a.begin(), out) {
	out << "{";
	for(auto it = a.begin(); it != a.end(); it = next(it))
		out << (it != a.begin() ? ", " : "") << *it;
	return out << "}";
}
 
void dump() { cerr << "\n"; }
template<class T, class... Ts> void dump(T a, Ts... x) {
	cerr << a << ", ";
	dump(x...);
}
 
#ifdef DEBUG
#  define debug(...) cerr << "[" #__VA_ARGS__ "]: ", dump(__VA_ARGS__)
#else
#  define debug(...) false
#endif
 
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define ST first
#define ND second
 
template<class T> int size(T && a) { return a.size(); }
 
using LL = long long;
using PII = pair<int, int>;

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

	string s;
	LL k;
	cin >> s >> k;

	string str = s;
	LL ret = 0;
	int n = size(str);
	FOR(i, 1, n - 1) {
		if(str[i - 1] == str[i]) {
			ret++;
			str[i] = '#';
		}
	}

	if(str[n - 1] == '#')
		cout << ret * k << "\n";
	else {
		string ftr = s;
		LL ret2 = 0;
		REP(i, n) {
			if(!i && ftr[i] == ftr[n - 1]) {
				ret2++;
				ftr[i] = '#';
			}
			else if(i && ftr[i] == ftr[i - 1]) 
				ret2++, ftr[i] = '#';
		}

		debug(str, ftr, ret, ret2);
		if(ftr[n - 1] == '#')
			cout << ret * (k + 1) / 2 + ret2 * LL(k / 2);
		else 
			cout << ret + ret2 * (k - 1);
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF            1e9
#define REP(i,n)       for(lint i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)      for(lint i=1,i##_len=(n);i<=i##_len;++i)
#define REPI(i,ini,n)  for(lint i=(ini),i##_len=(n);i<i##_len;++i)
#define REPR(i,n)      for(lint i=(n)-1;i>=0;--i)
#define REPR1(i,n)     for(lint i=(n);i>0;--i)
#define REPRI(i,ini,n) for(lint i=(ini)-1,i##_len=(n);i>=i##_len;--i)
#define REPC(i,obj)    for(auto i:obj)
#define R_UP(a,b)      (((a)+(b)-1)/(b))
#define ALL(obj)       (obj).begin(),(obj).end()
using namespace std;
using lint = long long;
template<typename T = lint>inline T in() { T x; cin >> x; return x; }
int binary_search_p(int first_w, int last_w, int k, int max_w, const vector<int>&w)
{
	auto get_minimum_k = [&w](int p_candidate)
	{
		int result = 1, temp = 0;
		REPC(i, w)
		{
			if (temp + i <= p_candidate)temp += i;
			else
			{
				result++;
				temp = i;
			}
		}
		return result;
	};
	int p_candidate = first_w + (last_w - first_w) / 2;
	if (first_w <= last_w)return get_minimum_k(p_candidate) <= k ? binary_search_p(first_w, p_candidate - 1, k, max_w, w) : binary_search_p(p_candidate + 1, last_w, k, max_w, w);
	else for (int i = max(p_candidate, max_w);; i++)if (get_minimum_k(i) <= k)return i;
}
signed main()
{
	int n = in(), k = in();
	vector<int>w(n);
	int min_w = 10001, max_w = -1, sum_w = 0;
	REPC(&i, w)
	{
		i = in();
		if (min_w > i)min_w = i;
		if (max_w < i)max_w = i;
		sum_w += i;
	}
	cout << binary_search_p(min_w, sum_w, k, max_w, w) << endl;
}


Measured memory_bytes: 3128
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<ll> x(N), y(N), z(N);
  rep(i, N) cin >> x[i] >> y[i] >> z[i];

  vector<vector<ll>> s(8, vector<ll>(N));
  rep(j, bit(3)) {
    rep(i, N) {
      ll xsign = ((j >> 0) & 1) ? 1 : -1;
      ll ysign = ((j >> 1) & 1) ? 1 : -1;
      ll zsign = ((j >> 2) & 1) ? 1 : -1;
      s[j][i] = x[i] * xsign + y[i] * ysign + z[i] * zsign;
    }
  }
  ll ans = -LINF;
  rep(j, 8) {
    sort(all(s[j]), greater<ll>());
    ll temp = 0;
    rep(i, M) {
      temp += s[j][i];
    }
    chmax(ans, temp);
  }
  cout << ans << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ifor(i,n) for(i=0;i<n;i++)
#define ll long long
///vector<int>vec;
///sort(s.begin(),s.endl());
///sort(ara,ara+n);
int main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
    ll int i,n,t,p=INT_MAX,j=0,x,a=1,b,l;
     string s,m;
     cin>>n>>p;
     while(a<=n){
        a*=p;
        j++;
     }
     cout<<j<<endl;

     return EXIT_SUCCESS;
}



Measured memory_bytes: 256
from collections import deque

def bfs():
    d = [[float("inf") for i in range(W)] for j in range(H)]
    dx = [1,-1,0,0]
    dy = [0,0,1,-1]
    que = deque([])
    que.append((0,0))
    d[0][0] = 0
    while que:
        p = que.popleft()
        if p[0] == W-1 and p[1] == H-1:
            break
        for i in range(4):
            nx = p[0] + dx[i]
            ny = p[1] + dy[i]
            if 0<=nx<W and 0<=ny<H and maze[ny][nx] != "#" and d[ny][nx] == float("inf"):
                que.append((nx,ny))
                d[ny][nx] = d[p[1]][p[0]] + 1
    return d[H-1][W-1]

H,W = map(int,input().split())
maze = [list(input()) for i in range(H)]

cnt = 1

for i in range(H):
    cnt += maze[i].count("#")

if bfs() == float("inf"):
    print(-1)
else:
    print(H*W-bfs()-cnt)


Measured memory_bytes: 3436
n,k=map(int,input().split())
l=list(map(int,input().split()))
a=len(format(max(l),"b"))
x=[None]*n
xl=[0]*a
for i in range(n):
  b=format(l[i],"b")
  x[i]=b.zfill(a)
for i in range(a):
  for j in range(n):
    if x[j][i]=="1":
      xl[i]+=1
c=format(k,"b")
if len(c)>a:
  c,d=c[:len(c)-a],c[len(c)-a:]
  ans=int("0b"+c,2)*(2**a)*n
  check=0
  for i in range(a):
    if check==0:
      if d[i]=="1":
        if xl[i]>=n-xl[i]:
          ans+=xl[i]*(2**(a-i-1))
          check=1
        else:ans+=(n-xl[i])*(2**(a-i-1))
      else:ans+=xl[i]*(2**(a-i-1))
    else:
      ans+=max(xl[i],n-xl[i])*(2**(a-i-1))
else:
  c=c.zfill(a)
  ans=0
  check=0
  for i in range(a):
    if check==0:
      if c[i]=="1":
        if xl[i]>=n-xl[i]:
          ans+=xl[i]*(2**(a-i-1))
          check=1
        else:ans+=(n-xl[i])*(2**(a-i-1))
      else:ans+=xl[i]*(2**(a-i-1))
    else:
      ans+=max(xl[i],n-xl[i])*(2**(a-i-1))
print(ans)


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

int main(){
  int A,B,C,D;
  cin>>A>>B>>C>>D;
  if(A+B>C+D)cout<<"Left"<<endl;
  if(A+B<C+D)cout<<"Right"<<endl;
  if(A+B==C+D)cout<<"Balanced"<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
using namespace std;
int main()
{
	string s;
	cin>>s;
	int l=s.size();
	
	for(int i=0;i<l;i++){
		if(s[i]=='C')
		
		for(int j=i+1;j<l;j++){
			
		    if(s[j]=='F'){
		        cout<<"Yes";
		        return 0;
		    }
		}
	}
	cout<<"No";
	return 0;
}

Measured memory_bytes: 256
a,b=map(int,input().split())

if b//100!=0:
    num=a*1000+b
elif b//10!=0:
    num=a*100+b
else:
    num=a*10+b

flag=False
for i in range(1,1000):
    if num//i==i and num%i==0:
        flag=True

if flag:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 2940
import java.util.*;

public class Main{
	public static void main(String[] args) {
	    Scanner sc=new Scanner(System.in);
	    int l=sc.nextInt();
	    int r=sc.nextInt();
	    int d=sc.nextInt();
	    
	    int ans=0;
	   
	    for(int i=l;i<=r;i++) {
	    	if(i%d==0)ans++;
	    }
	

	    System.out.println(ans);
	}
}


Measured memory_bytes: 35564
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n - 1; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define RFOR(i, start, end) for (int i = start - 1; 0 <= i; i--)
#define ALL(a) a.begin(), a.end()
using ll = long long;
using namespace std;
constexpr int INF32       = 1'050'000'000;
constexpr long long INF64 = 4'000'000'000'000'000'000;
constexpr int MOD7        = 1'000'000'007;
constexpr int MOD9        = 1'000'000'009;
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;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}
void debug() { std::cerr << '\n'; }
template <class H, class... T> void debug(H &&head, T &&... args) {
    std::cerr << head;
    sizeof...(args) == 0 ? std::cerr << "" : std::cerr << ' ';
    debug(std::forward<T>(args)...);
}
template <class T> void debug(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cerr << v[i];
        i == v.size() - 1 ? std::cerr << '\n' : std::cerr << ' ';
    }
}
template <class T> void debug(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cerr << v[i][j];
            j == v[i].size() - 1 ? std::cerr << '\n' : std::cerr << ' ';
        }
    }
}

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

    ll N, A, B;
    cin >> N >> A >> B;
    vector<ll> v(N);
    for (auto &&i : v) {
        cin >> i;
    }
    vector<ll> diff;
    ll ans = 0;
    FOR(i, 1, N) {
        int a = v[i] - v[i - 1];
        diff.emplace_back(a);
    }
    for (auto &&i : diff) {
        if (i * A < B) {
            ans += i * A;
        } else {
            ans += B;
        }
    }
    print(ans);

    return 0;
}

Measured memory_bytes: 2168
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
#define REP(i, a, n) for(int i=a; i<n; i++)
#define RREP(i, a, n) for(int i=n-1; i>=a; i--)

int main() {
	int money;
	int value[4] = { 10, 50, 100, 500 };
	int ret[4];

	bool flag = true;
	while (cin >> money, money) {
		if (!flag) cout << endl;
		flag = false;

		int sum = 0;
		int coin[4];
		REP(i, 0, 4) {
			cin >> coin[i];
			sum += value[i] * coin[i];
			ret[i] = 0;
		}

		sum -= money;
		RREP(i, 0, 4) {
			while (sum >= value[i]) {
				ret[i]++;
				sum -= value[i];
			}
		}

		REP(i, 0, 4) {
			int pay = coin[i] - ret[i];
			if (pay > 0) cout << value[i] << " " << pay << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3084
#include <iostream>
#include <stdio.h>
#include <vector>
#include <sstream>
#include <unordered_map>

using namespace std;

vector<string> split(const string &str, char delim){
    vector<string> v;
    string buffer;
    stringstream ss(str);
    while(getline(ss, buffer, delim)) v.push_back(buffer);
    return v;
}

string getLine(){
    string str;
    getline(cin, str);
    return str;
}

template<typename T, typename R>
vector<R> v_map(vector<T> xs, R(*fp)(T)){
    vector<R> ys;
    for(T x : xs) ys.push_back(fp(x));
    return ys;   
}

int compare(int a, int b){
    if(a == b)     return 0;
    else if(a < b) return -1;
    else           return 1;
}

int main(void){
    vector<int> v = v_map(split(getLine(), ' '), +[](string x){ return stoi(x); });
    unordered_map<int, string> mp = { {-1, "<"}, {0, "=="}, {1, ">"}, };
    cout << "a " + mp[compare(v[0], v[1])] + " b" << endl;
    return 0;
}

Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    int cnt;
    int a = 0,ans;
    int j = 0;
    for(int i = 1;i <= N;i++){
        j = i;
        while(j >= 0){
            if(j % 2 == 0){
                j = j / 2;
                cnt++;
            }else{
                break;
            }
        }
    if(cnt > a){
        a = cnt;
        ans = i;
    }
    cnt = 0;
    }
    if(ans == 0)
        ans = 1;
    cout << ans <<endl;

}

Measured memory_bytes: 256
sx,sy,tx,ty = [int(i) for i in raw_input().split(' ')]
x = tx-sx
y = ty-sy
print 'U'*y+'R'*x+'D'*y+'L'*x+'L'+'U'*(y+1)+'R'*(x+1)+'D'+'R'+'D'*(y+1)+'L'*(x+1)+'U'

Measured memory_bytes: 2568
#include<bits/stdc++.h>
using namespace std;
#define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int
#define endl '\n'
#define ld long double
#define FOR(i,a,n) for (ll i=(a);i<=(n);++i)
#define RFOR(i,a,n) for (ll i=(n);i>=(a);--i)
#define FI(i,n) for (ll i=0; i<(n); ++i)
#define ZERO(a) memset((a),0,sizeof((a)))
#define MINUS(a) memset((a),-1,sizeof((a)))
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define all(g) g.begin(),g.end()
int fastMax(int x, int y) { return (((y-x)>>(32-1))&(x^y))^y; }
int fastMin(int x, int y) { return (((y-x)>>(32-1))&(x^y))^x; }
 
/*
░░░░░░░░░░░░░░░░░░░░░░░░░
░░█▀▀▄░░░░░░░░░░░▄▀▀█░░░░
░░█░░░▀▄░▄▄▄▄▄░▄▀░░░█░░░░
░░░▀▄░░░▀░░░░░▀░░░▄▀░░░░░
░░░░░▌░▄▄░░░▄▄░▐▀▀░░░░░░░
░░░░▐░░█▄░░░▄█░░▌▄▄▀▀▀▀█░
░░░░▌▄▄▀▀░▄░▀▀▄▄▐░░░░░░█░
░▄▀▀▐▀▀░▄▄▄▄▄░▀▀▌▄▄▄░░░█░
░█░░░▀▄░█░░░█░▄▀░░░░█▀▀▀░
░░▀▄░░▀░░▀▀▀░░▀░░░▄█▀░░░░
░░░░█░░░░░░░░░░░▄▀▄░▀▄░░░
░░░░█░░░░░░░░░▄▀█░░█░░█░░
░░░░█░░░░░░░░░░░█▄█░░▄▀░░
░░░░█░░░░░░░░░░░████▀░░░░
░░░░▀▄▄▀▀▄▄▀▀▄▄▄█▀░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░
*/
 
// I want to be the very best, like no one ever was, I will battle everyday to claim my rightful place
// #include <ext/pb_ds/assoc_container.hpp> // Common file
// #include <ext/pb_ds/tree_policy.hpp>     // Including tree_order_statistics_node_updat
// using namespace __gnu_pbds;
// typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
 
// I am questioning life and universe and 
// everything else after looking at this

void solve(){
    ll n,k; cin>>n>>k;
    ll cnt = 0;
    FOR(i,1,n){
        ll x; cin>>x;
        if(x>=k) cnt++;
    }

    cout<<cnt<<endl;
}
 
signed main(){
 
   FastRead;    
 

    ll t;
    t = 1; 
    // cin>>t;
    FOR(i,1,t){
        // cout<<"Case #"<<i<<": ";
        solve();
    }
}

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

// syntax sugar: `for (int i = 0; i < N; ++i)`
#define rep(i, N) for (int i = 0; i < (int)(N); ++i)
#define rep2(i, startValue, N) for (int i = (int)(startValue); i < (int)(N); ++i)
// syntax sugar: `for (int i = 0; i < N; ++i)`
#define REP(type, name, beginValue, endCondValue) \
  for (type name = beginValue; name < endCondValue; ++name)
// syntax sugar: 多次元vector
#define VECTOR_DIM3(T, name, d1, d2, d3, initValue) \
    std::vector<std::vector<std::vector<T>>> name(d1, std::vector<std::vector<T>>(d2, std::vector<int>(d3, initValue)));
#define VECTOR_DIM2(T, name, d1, d2, initValue) \
    std::vector<std::vector<T>> name(d1, std::vector<T>(d2, initValue));
#define VECTOR_DIM1(T, name, d1, initValue) \
    std::vector<T> name(d1, initValue);
#define ll long long
#define ld long double
#define DUMP(v) "," #v ":" << v


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

  ll ans = 0;
  rep2(a,1,n) {
    if (n % a == 0) {
      ans += n / a - 1;
    } else {
      ans += n / a;
    }
  }
  cout << ans << endl;

  return 0;
}


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

int main() {
  int A, B, C, D ;
  cin >> A >> B >> C >> D ;
 
  if (A + B < C + D)
    cout << "Right" << endl;
  
  if (A + B > C + D)
    cout << "Left" << endl;
  
  if (A + B == C + D)
    cout << "Balanced" << endl;

}
  
  

    
  

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <bitset>
#include <stack>
#include <set>
using namespace std;

typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P2;
const int inf=1000000000;
int dp[101][101][301]={};
ll w1[101]={};
int v1[101]={};
ll km[101]={};
int main() {
	ll x,y;
	cin>>x>>y;
	if(abs(x-y)<=1){
		cout<<"Brown"<<endl;
	}else{
		cout<<"Alice"<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<cstdlib>
#include<cstdio>
#include<utility>
#include<list>
using namespace std;
int main(){
	string S;	cin>>S;
	string str;
	
	for(int i=0;i<S.size();i+=2){
		str += S[i];
	}

	cout<< str <<endl;

	return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    ll x,y,rslt=0;
    cin>>x>>y;
    swap(x,y);
    while(x>=y)
    {
        rslt++;
        x/=2;
    }
    cout<<rslt<<endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())

ne = [[] for _ in range(n+1)]
for i in range(n-1):
  a,b = list(map(int, input().split()))
  ne[a].append((i+1,b))
  ne[b].append((i+1,a))

maxp = 0
ce = [0] * n
cr = [0] * (n+1)
for i in range(1, n+1):
  ptr = 1
  while len(ne[i]) != 0:
    if ptr == cr[i]:
      ptr += 1
      continue
    else:
      cur,root = ne[i].pop()
      if ce[cur] == 0:
        ce[cur] = ptr
        cr[root] = ptr
        if ptr > maxp:
          maxp = ptr
        ptr += 1

print(maxp)
for i in range(1, n):
  print(ce[i])

Measured memory_bytes: 46380
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
#define mod 998244353
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pi pair<ll,ll>
using namespace std;
const ll N=100010;

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

    ll n,x,y;
    cin>>n>>x>>y;
    ll node,dis,moves;
    for(ll k=1;k<n;++k){
        ll ans=0;
        for(ll i=1;i<=n;++i){
            set<ll> lol;

            if(i<=x){
                node=i+k;
                if(node<=n){
                    dis=x-i+1+abs(node-y);
                    if(dis>=k){
                        lol.insert(node);
                    }
                }
                moves=x-i+1;
                if(moves<=k){
                    node=y-(k-moves);
                    if(node>i&&node<=n){
                        dis=abs(node-i);
                        if(dis>=k){
                            lol.insert(node);
                        }
                    }
                    node=y+(k-moves);
                    if(node>i&&node<=n){
                        dis=abs(node-i);
                        if(dis>=k){
                            lol.insert(node);
                        }
                    }
                }
            }
            else{
                node=i+k;
                if(node<=n){
                    dis=i-x+1+abs(y-node);
                    if(dis>=k){
                        lol.insert(node);
                    }
                }
                moves=i-x+1;
                if(moves<=k){
                    node=y-(k-moves);
                    if(node>i&&node<=n){
                        dis=abs(node-i);
                        if(dis>=k){
                            lol.insert(node);
                        }
                    }
                    node=y+(k-moves);
                    if(node>i&&node<=n){
                        dis=abs(i-node);
                        if(dis>=k){
                            lol.insert(node);
                        }
                    }
                }
            }

            ans+=lol.size();
        }
        cout<<ans<<endl;
    }

    return (0);
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;

constexpr double EPS = 1e-7;
constexpr int INF = 1e9;
#define PI (acos(-1))

constexpr int MOD = 1e9 + 7;

int main(int argc, char const *argv[]) {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);

	int N;
	cin >> N;

	vector<int> P(N);
	for (int i = 0; i < N; i++) {
		cin >> P[i];
	}

	int min_v = N + 1;
	int ans = 0;
	for (int i = 0; i < N; i++) {
		if (P[i] < min_v) {
			ans++;
			min_v = P[i];
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
#!/usr/bin/env python
import os
import sys
from io import BytesIO, IOBase

def ispal(x):
    for i in range((len(x)//2)+1):
        if x[i] !=x[len(x)-i-1]:
            return False
    return True
def main():
    s = input()
    n = len(s)
    # print(s[:(n-1)//2],s[:(n-1)//2+1])
    # print(ispal(s) ,ispal(s[:(n-1)//2]),ispal(s[(n+3)//2-1:]))
    if ispal(s) and ispal(s[:(n-1)//2]) and ispal(s[(n+3)//2-1:]):
        print('Yes')
    else:
        print('No')





# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()

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

using namespace std;

int main(){
    string s;

    while(cin >> s){
        int ret = 0;
        for(int i=0; i< s.size(); i++){
            if(s[i] == 'O'){
                int count = 1;
                while(s[i+count] == 'O') count++;
                bool is = true;
                for(int j=i+count; j < i+count+count; j++) if(s.size() <= j || s[j] != 'I'){is = false; break;}
                for(int j=i-count; j < i; j++) if(j < 0 || s[j] != 'J'){is = false; break;}
                if(is) ret = max(ret, count);
                i = i+count;
            }
        }
        cout << ret << endl;
    }
}

Measured memory_bytes: 2052
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	C
# CreatedDate:  2020-09-10 18:36:43 +0900
# LastModified: 2020-09-11 02:01:32 +0900
#


import os
import sys
# import numpy as np
# import pandas as pd


def main():
    L, R = map(int, input().split())
    cool = R // 2019 - L // 2019
    if cool == 0:
        ans = 2020
        for l in range(L, R+1):
            for r in range(l+1, R+1):
                if ans > l*r % 2019:
                    ans = l*r % 2019
        print(ans)

    else:
        print(0)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9100
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;

template<typename T>
ostream& operator << (ostream& os, vector<T>& v){
	rep(i,v.size()){ os << v[i] << (i == v.size() - 1 ? "" : " "); } return os;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& v){
	for(T& x: v){ is >> x; } return is;
}

typedef vector<char> vc;
typedef vector<vc> Pic;

class Bit{
	int bit;
	public:
	Bit() : bit(0) { }
	bool at(int i, int j){
		return ( bit >> (i * 4 + j) ) & 1;
	}
	void set(int i, int j){
		bit |= 1 << (i * 4 + j);
	}
	int get(){
		return bit;
	}
};

const char color[] = {'R', 'G', 'B'};

bool canDelete(Pic& pic, Bit& b, pair<int, int> s, int y, int x, char c){
	bool f = false;
	range(i,y,y + s.first){
		range(j,x,x + s.second){
			if(i < 0 or j < 0 or i >= 4 or j >= 4) continue;
			if(not b.at(i,j)) f = true;
			if(pic[i][j] != c and not b.at(i,j)) return false;
		}
	}
	return f;
}
void output(Bit b){
}

Bit getUpdatedBit(Bit& b, pair<int, int> s, int y, int x){
	Bit res = b;
	range(i,y,y + s.first){
		range(j,x,x + s.second){
			if(i < 0 or j < 0 or i >= 4 or j >= 4) continue;
			res.set(i,j);
		}
	}
	return res;
}

struct P{
	int cnt;
	Bit bit;
	P(int cnt, Bit bit) : cnt(cnt), bit(bit) {}
	bool operator < ( const P &right ) const {
		return cnt < right.cnt;
	}
	bool operator > ( const P &right ) const {
		return cnt > right.cnt;
	}
};

void bfs(vector<pair<int, int>>& stamps, Pic& pic){
	//priority_queue<P, vector<P>, greater<P>> q;
	queue<P> q;
	q.emplace(0, Bit());

	vector<int> dis(1 << 16, 1e9);
	dis[0] = 0;

	while(not q.empty()){
		P tmp = q.front(); q.pop();

		Bit b = tmp.bit;
		int cnt = tmp.cnt;


		//if(dis.at(b.get()) <= cnt) continue;
		//dis[b.get()] = cnt;

		if((1 << 16) - 1 == b.get()){
			cout << cnt << endl;
			return;
		}

		rep(c,3){
			rep(i,stamps.size()){
				range(y, 1 - stamps[i].first, 4){
					range(x, 1 - stamps[i].second, 4){
						if(canDelete(pic, b, stamps[i], y, x, color[c])){
							Bit tmp = getUpdatedBit(b, stamps[i], y, x);
							if(dis.at(tmp.get()) > cnt + 1){
								dis[tmp.get()] = cnt + 1;
								q.emplace(cnt + 1, getUpdatedBit(b, stamps[i], y, x));
							}
						}
					}
				}
			}
		}
	}
}

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

	vector<pair<int, int>> stamps(n);
	rep(i,n){
		cin >> stamps[i].first >> stamps[i].second;
	}

	Pic pic(4, vc(4));
	rep(i,4) rep(j,4) cin >> pic[i][j];

	bfs(stamps, pic);
}



Measured memory_bytes: 3360
#include<iostream>
using namespace std;
int p1, p2, p3, j1, j2;
int main(){
cin >> p1 >> p2 >> p3 >> j1 >> j2;
cout << min(min(p1, p2), p3) + min(j1, j2) - 50 << endl;
return 0;
}

Measured memory_bytes: 3072
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <numeric>
#include <cmath>

using namespace std;
typedef long long LL;
template <typename F, typename S> std::ostream& operator<<(ostream& os, const pair<F,S>& p) {
    os << "(" << p.first << "," << p.second << ")"; return os; }
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "["; for(const T& a: v){ os << a << ", "; } os << "]"; return os; }
template <typename K, typename V> ostream& operator<<(ostream& os, const map<K,V>& m) {
    os << "{"; for(const auto& p: m){ os << p.first <<":"<< p.second << ", "; } os << "]"; return os; }


// import here

int main(){
    string s;
    cin >> s;
    if(s.size() == 26){
        int i = 25;
        for(;i >= 1;--i){
            if(s[i-1] < s[i]) break;
        }
        if(i >= 1){
            char c = s[i];
            for(int j = i; j < s.size(); ++j){
                if(s[j] > s[i-1]) c = min(c, s[j]);
            }
            cout << s.substr(0, i-1) + c << endl;
        }else{
            cout << -1 << endl;
        }
    }else{
        vector<int> used(26);
        for(int i = 0; i < s.size(); ++i){
            used[s[i] - 'a'] = 1;
        }
        for(int i = 0; i < 26; ++i){
            if(!used[i]){
                cout << s + (char)('a'+i) << endl;
                break;
            }
        }
    }
    return 0;
}



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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll n;
    map<char, pair<ll, ll>> m;
    string ans;
    cin >> n;
    rep(i, n) {
        string s;
        map<char, ll> chars;
        cin >> s;
        iter(c, s) chars[c]++;
        iter(j, chars) {
            if(m.find(j.first) == m.end()) {
                m[j.first] = pair<ll, ll>{1, j.second};
            } else {
                m[j.first].first++;
                m[j.first].second = min(m[j.first].second, j.second);
            }
        }
    }
    iter(i, m) {
        if(i.second.first == n) ans += string(i.second.second, i.first);
    }
    sort(ans.begin(), ans.end());
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())

ab = []
for _ in range(N):
    a, b = map(int, input().split())
    ab.append([a, b])

cd = []
for i in range(M):
    c, d = map(int, input().split())
    cd.append([c, d, i + 1])

INF = 10 ** 9
def check_point(a, b): #a, bが集まるチェックポイントの番号
    distance = INF
    ans = 1
    for c, d, i in cd:
        if distance > abs(a - c) + abs(b - d):
            distance = abs(a - c) + abs(b - d)
            ans = i
    return ans

for a, b in ab:
    print (check_point(a, b))



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

int main(void)
{
	int a,b,c;
    cin >> a >> b >> c;
    if(a + b >= c)
    {
    	cout << "Yes" << endl;
    }
    else
    {
    	cout << "No" << 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 a=sc.nextInt();
    int b=sc.nextInt();
    int k=a+b;

    if(k%2==0){
      if(k>=0){
        System.out.println(k/2);
      }else{
        System.out.println(-k/2);
      }
    }else{
      System.out.println("IMPOSSIBLE");
    }

  }
}


Measured memory_bytes: 21716
s=input()
s_len=len(s)
for i in range(s_len-1):
  if s[i]==s[i+1]:
    print(i+1,i+2)
    exit()
  if i!=s_len-2 and s[i]==s[i+2]:
    print(i+1,i+3)
    exit()

print(-1,-1)

Measured memory_bytes: 9172
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define INF 100000000
#define EPS 1e-10
#define MOD 1000000007
using namespace std;
typedef pair<int,int> P;

struct UF{
	int par[100000];
	int rank[100000];

	void init(int n){
		rep(i,n){
			par[i] = i;
			rank[i] = 0;
		}
	}

	int find(int x){
		if(par[x] == x) return x;
		else return par[x] = find(par[x]);
	}

	void unite(int x, int y){
		x = find(x);
		y = find(y);
		if(x == y) return;
		
		if(rank[x] < rank[y]) par[x] = y;
		else{
			par[y] = x;
			if(rank[x] == rank[y]) rank[x]++;
		}
	}

	bool same(int x, int y){
		return find(x) == find(y);
	}
};

int n, m;
UF uf;

void solve(){
	uf.init(n);
	rep(i,m){
		int a, b;
		cin >> a >> b;
		a--; b--;
		uf.unite(a,b);
	}
	long long ans = 1;
	bool check = false;
	rep(i,n){
		if(uf.par[i] != i) continue;
		if(uf.rank[i] > 0){
			ans *= 2;
			check = true;
		}
		else ans *= 2;
		ans %= MOD;
	}
	if(check) ans += 1;
	ans %= MOD;
	cout << ans << endl;
}

int main(){
	while(cin>>n >> m ){
		if(n == 0 && m == 0) break;
		solve();
	}
}

Measured memory_bytes: 1940
#include <iostream>
#include <cstdio>
using namespace std;
 
typedef long long ll;
ll n, ans = 3;
ll M = 1e9 + 7;
string a[2];
int main()
{
	ll i;
	cin >> n >> a[0] >> a[1];
	if (a[0][0] == a[0][1]) i = 2, ans = 6;
	else i = 1, ans = 3;
	for (; i < n; i++) {
		if (a[0][i] == a[1][i]) {
			if (a[0][i - 1] == a[1][i - 1]) ans *= 2;
		} else {
			if (a[0][i - 1] != a[1][i - 1]) ans *= 3;
			else ans *= 2;
			i++;
		}
		ans %= M;
	}
    cout << ans << endl;
    return 0;
}

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

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

#define INF INT_MAX/3
#define REP(i,n) for(int i=0;i<n;i++)

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

	if(abs(x - a) < abs(x - b)){
		cout<<'A'<<endl;
	}
	else{
		cout<<'B'<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include  <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include <stdlib.h>
#include<stdio.h>
#include <queue>
#include<map>
#include <sstream>
#include<set>
#include<stack>

//#include<bits/stdc++.h>


using namespace std;



int main() {

	long long int a;
	cin >> a;
	int t = 10000;
	while (a>=100) {
		int x = a % 1000;
		t = min(t, abs(753 - x));
		a /= 10;

	}
	
	cout << t << endl;


	return 0;



}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll arr[100005];
ll memo[100005];
int main()
{
    memset(memo,-1,sizeof(memo));
    ll n,k;
    cin>>n>>k;
    ll minn=1e9;
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
        minn=min(minn,arr[i]);
        memo[arr[i]]=1;
    }
    
    for(int i=0;i<minn;i++)
    {
        memo[i]=2;
    }
    //cout<<minn<<"\n";
    
    for(int i=minn+1;i<=k;i++)
    {
        if(memo[i]==-1)
        {
            bool flag=false;
        
            for(int j=0;j<n;j++)
            {
                if(i-arr[j]<0) continue;
                if(memo[i-arr[j]]==2) flag=true;
            }
            
            if(flag)
            {
                memo[i]=1;
            }
            
            else
            {
                memo[i]=2;
            }
        }
    }
    
    if(memo[k]==1) printf("First\n");
    else printf("Second\n");
    
    
    
}

Measured memory_bytes: 1024
/*
g++ -std=c++14 -Wall -O2 -o main.exe main.cpp
main.exe
*/

#include <cstdlib>
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <map>
#include <functional>
#include <algorithm>
#include <complex>
#include <numeric>
//最大公約数: gcd()
//最小公倍数: lcm()

#define ll long long int

using namespace std;

template <typename T>
string itos(T val){ //数値を文字列(string)に変換
	stringstream ss;

	ss << val;
	return ss.str();
}

int stoi(string s){ //文字列(string)を数値に変換
	stringstream ss;
	int val = 0;

	ss << s;
	ss >> val;
	return val;
}

template <typename T>
void sortasc(vector<T> &v){ //vectorを昇順にソート
    sort(v.begin(), v.end(), std::less<T>());
    return;
}

template <typename T>
void sortdesc(vector<T> &v){ //vectorを降順にソート
    sort(v.begin(), v.end(), std::greater<T>());
    return;
}

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

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

	cout << (a - 1) * (b - 1) << endl;

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void) {
	int t, n, m,k=100,kazu=1;

	scanf("%d%d", &n, &m);
	
		for (t = 0; t < k; t++) {
			if (kazu >= m) {
				printf("%d\n", t);
				break;
			}
			else {
				kazu = kazu - 1;
			}
			kazu = kazu + n;
			
		}
	
	return 0;
}

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

using namespace std;

int main(){
	int D,N;
	int ans;
	cin >> D >> N;
	ans = pow(100,D)*N;
	if(N %100 == 0){
		ans+=pow(100,D);
	}

	cout <<  ans << 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;
using ll = long long;
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; }
int main(){
    ios::sync_with_stdio(false);
    const vector<int> clr_idx = {0,400,800,1200,1600,2000,2400,2800,3200};
    int n;
    cin >> n;
    set<int> clr_lst = {};
    int over_red_num =0;
    rep(i,n) {
        int a;
        cin >> a;
        rep(j, clr_idx.size()) {
            if(j == clr_idx.size()-1) {
                over_red_num++;
                break;
            }
            if(clr_idx[j] <= a && a < clr_idx[j+1]) {
                clr_lst.insert(j);
                break;
            }
        }
    }
    int ans_min = clr_lst.size();
    int ans_max = ans_min + over_red_num;
    //if(ans_max > clr_idx.size()-1) ans_max = clr_idx.size()-1;
    if(ans_min == 0) ans_min = 1;
    cout << ans_min << " " << ans_max << endl;
}

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

const int N = 2e5 + 5;

int n, q;
char t[N], d[N];
string s;

bool check(int x, int type) {
	char cur = s[x];
	for (int i = 0; i < q; ++i) {
		if (t[i] == cur) {
			x += (d[i] == 'L') ? -1 : +1;
			if (x >= 0 && x < n) cur = s[x];
		}
		if (x < 0 || x >= n) {
			if (type == 0 && x < 0) return true;
			if (type == 1 && x >= n) return true;
			return false;
		}
	}
	return false;
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	
	cin >> n >> q;
	cin >> s;
	for (int i = 0; i < q; ++i) {
		cin >> t[i] >> d[i];
	}
	
	int res = n;
	
	int low = 0, high = n - 1;
	while(low < high) {
		int mid = ((low + high + 1) >> 1);
		if (check(mid, 0)) low = mid;
		else high = mid - 1;
	}
	if (check(low, 0)) res -= low + 1;
	cerr << low << endl;
	
	low = 0, high = n - 1;
	while(low < high) {
		int mid = ((low + high) >> 1);
		if (check(mid, 1)) high = mid;
		else low = mid + 1;
	}
	if (check(low, 1)) res -= n - low;
	cerr << low << endl;
	
	cout << res << endl;
}


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

using namespace std;

int main()
{
    bool oh=false;
   int x,z,k;
   int sum=0;
   cin>>x>>z;
   for(int i=0;i<z;i++)
   {
       cin>>k;
       sum=sum+k;
       if(x-sum<=0) oh=true;
       
       
   }
   if(oh==true) cout<<"Yes"<<endl;
   else cout<<"No"<<endl;
    return 0;
}


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

#define int long long

using namespace std;

int a[100001];
int all, kol;

 main () {   
 	int n;
 	cin >> n;
 	for (int i = 1;i <= n;i ++) {
 		cin >> a[i];
 		all += a[i];
 	}
 	int qwe = (n * (n + 1)) / 2;
 	if (all % qwe) {
 		cout << "NO";
 		return 0;
 	}
 	int k = all / qwe;
 	a[0] = a[n];
 	for (int i = 1;i <= n;i ++) {
 		int d = a[i] - a[i - 1];
		d -= k;
 		d = -d;
 		if (d < 0 || d % n) {
 			cout << "NO";
 			return 0;
 		}
 		kol += d / n;
 	} 
 	if (kol == k) cout << "YES";
 	else cout << "NO";
    return 0;           		
}

Measured memory_bytes: 1024
# ref) https://atcoder.jp/contests/sumitrust2019/submissions/8731837

N, *A = map(int, open(0).read().split())

MOD = 10 ** 9 + 7

ans = 1
X = [0, 0, 0]
for a in A:
    c = X.count(a)
    ans = ans * c % MOD
    
    if X[0] == a:
        X[0] += 1
    elif X[1] == a:
        X[1] += 1
    else:
        X[2] += 1
        
print(ans)



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

int main (){
        long long N;
        int arr[100005];
        long long Max = 0;
        long long money;
        cin >>N;

        arr[0] =0;
        for (int i = 1; i <= N; i++) {
                cin >>arr[i];
                Max += abs(arr[i-1] - arr[i]);
        }
        arr[N+1] =0;
        Max += abs(arr[N] - arr[N+1]);

        for (int i = 1; i <= N; i++) {
                money = Max-abs(arr[i-1]-arr[i])-abs(arr[i]-arr[i+1])+abs(arr[i-1]-arr[i+1]);
                cout <<money <<endl;
        }

        return 0;
}


Measured memory_bytes: 1664
#include<stdio.h>
#include<string.h>
int main()
{
	char s[100],t[100];
	int a,i,j,x,y;
	scanf("%s %s",s,t);
	x=strlen(s);
	y=strlen(t);
	a=0;
	for(i=0;i<x-1;i++){
		for(j=i+1;j<x;j++){
			if(s[i]>s[j]){
				a=s[i];
				s[i]=s[j];
				s[j]=a;
			}
		}
	}
	for(i=0;i<y-1;i++){
		for(j=i+1;j<y;j++){
			if(t[i]<t[j]){
				a=t[i];
				t[i]=t[j];
				t[j]=a;
			}
		}
	}
	if(strcmp(s,t)<0){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main() {

    int x,y;
    scanf("%d %d", &x, &y);
    printf("%d", (x % y == 0 ? x / y : x / y+1));
    // if(x % y == 0) {
    //     printf("%d\n", x / y);
    // } else {
    //     printf("%d", x / y+1);
    // }

    return 0;
}

Measured memory_bytes: 1700
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  char a;
  set<char> st;
  for(int i=0;i<n;i++){
    cin>>a;
    st.insert(a);
  }
  if(st.size()==3){
    cout<<"Three"<<endl;
  }else{
    cout<<"Four"<<endl;
  }
}

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

namespace _0318
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            bool[] a = new bool[n];
            bool[] b = new bool[n];
            int ret = 0;
            for (int i = 0; i < n; i++) a[i] = true;
            int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            for (int i = 1; i <= x[0]; i++) a[x[i] - 1] = false;
            int[] y = Console.ReadLine().Split().Select(int.Parse).ToArray();
            for (int i = 1; i <= y[0]; i++) b[y[i] - 1] = true;
            int[] z = Console.ReadLine().Split().Select(int.Parse).ToArray();
            for (int i = 1; i <= z[0]; i++)
            {
                if (a[z[i] - 1] || b[z[i] - 1]) ret++;
            }
            Console.WriteLine(ret);
        }
    }
}

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

struct segment_tree {
  vector<int> node;
  int n;
  const function<int(int,int)> fn;
  const int initial;

  segment_tree(int n, function<int(int,int)> fn, int initial) : fn(fn), initial(initial) {
    int msb = 1LL << ((n==0) ? 0 : 64 - __builtin_clzll(n)-1);
    this->n = (n==msb) ? n : msb << 1;
    node.resize(2 * this->n - 1);
    fill(node.begin(), node.end(), initial);
  }

  inline int r_child(int v) { return v*2+2; }
  inline int l_child(int v) { return v*2+1; }
  inline int parent(int v) { return (v + (v%2)) / 2 - 1; }

  int query(int ql, int qr, int v=0, int l=0, int r=-1) {
    r = (r==-1) ? n-1 : r;
    if(ql<=l && r<=qr) return node[v];
    int ret = initial, mid=(l+r)/2;
    if(ql <= mid)   ret = fn(ret, query(ql, qr, l_child(v), l,     mid));
    if(qr >= mid+1) ret = fn(ret, query(ql, qr, r_child(v), mid+1, r  ));
    return ret;
  }

  void set_value(int index, int val) {
    int v = node.size()/2 + index;
    node[v] = val;
    while((v=parent(v)) != -1) node[v] = fn(node[r_child(v)], node[l_child(v)]);
  }

  void add_value(int index, int val) { set_value(index, node[node.size()/2 + index] + val); }
  int get_value(int index) { return node[node.size()/2 + index]; }
};


int N;
int h[200000], a[200000];
segment_tree dp(200000, [](int u, int v) { return max(u,v); }, 0);

signed main() {
  cin >> N;
  for(int i=0; i<N; i++) {cin >> h[i]; h[i]--;}
  for(int i=0; i<N; i++) cin >> a[i];

  int ans = 0;
  for(int i=0; i<N; i++) {
    int hi = h[i], ai = a[i];
    //for(int j=0; j<hi; j++) d = max(d, dp[j]);
    int d = dp.query(0, hi) + ai;
    dp.set_value(hi, d);
    ans = max(ans, d);
  }
  cout << ans << endl;
}


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

int main (){
    ll n,ans=0;
    cin>>n;
    ll a[n];
    for(ll i=0;i<n;i++) cin>>a[i];
    for(ll i=n-2;i>=0;i--){
        if(a[i]>a[i+1]) a[i]--;
        if(a[i]>a[i+1]) ans=1;
    }
    if(ans==1)   cout<<"No";
    else        cout<<"Yes";
    return 0;
}





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

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define SUM(x) accumulate(ALL(x), 0)
#define print(x) cout << x;
#define println(x) cout << x << endl;
#define printd(x, f) cout << fixed << setprecision(f) << x << endl;

#define PB push_back
#define MP make_pair
#define F first
#define S second

#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000
#define PI acos(-1.0)

int main()
{
  string S; cin >> S;
  ll cnt = 0;
  ll b = 0;
  REP(i, SIZE(S)) {
    if (S[i] == 'B') b++;
    else if (S[i] == 'W') cnt += b;
  }
  println(cnt);
  return 0;
}


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

#define rep(i,a,b)      for(int i=a;i<=b;i++)
#define revp(i,a,b)     for(int i=b;i>=a;i--)

string s;
int n;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    

    cin>>n>>s;
    rep(i,0,s.length())
         s[i] = 'A' + ((s[i] - 'A' + n) % 26);
    cout<<s;
}




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

int dp[100001];
vector <int> v;
int n,k,t;
int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);

	fill(dp,dp+100001,1e9);
	dp[0] = 0;

	cin >> n >> k;

	for(int i=0;i<n;i++)
	{
		cin >> t;
		v.push_back(t);
	}

	for(int i=1;i<n;i++)
	{
		for(int j=1;j<=k;j++)
		{
			if(i-j<0)
			{
				break;
			}
			dp[i] = min(dp[i],dp[i-j] + abs(v[i] - v[i-j]));
		}
	}

	cout << dp[n-1] << '\n';

	return 0;
}


Measured memory_bytes: 1276