akhauriyash/Code-Regression huggingface dataset:
num = int(input())
check_list = [0] * num * num

def make_bridge(island1, island2):
    if(island1 < island2):
        check_list[(island1-1)*num + (island2-1)]=1;
    else:
        check_list[(island2-1)*num + (island1-1)]=1;

if num%2==0:
    sum_pair = num+1
else:
    sum_pair = num

for i in range(num):
    for j in range(i):
        if (i+1 + j+1 != sum_pair):
            check_list[j*num + i]=1;

bridge_num=0;

for i in range(num*num):
    if(check_list[i]==1):
        bridge_num+=1;

print(bridge_num);

for i in range(num*num):
    if(check_list[i]==1):
        left = i // num
        right = i % num
        print(str(left+1)+" "+str(right+1));


Measured memory_bytes: 3336
import sys
sys.setrecursionlimit(10**6)
N,M,Q = map(int,input().split())
a = [0]*Q
b = [0]*Q
c = [0]*Q
d = [0]*Q
for i in range(Q):
    a[i],b[i],c[i],d[i] = map(int,input().split())


sequences = []

def dfs(seq):
    if len(seq) == N+1:
        sequences.append(seq)
        return
    tail_num = seq[-1]
    for nxt_d in range(tail_num,M+1):
        dfs(seq+[nxt_d])
dfs([1])


ans = 0
for seq in sequences:
    score = 0
    for i in range(Q):
        if int(seq[b[i]]) - int(seq[a[i]]) == c[i]:
            score += d[i]
    ans = max(ans, score)
print(ans)




#     if len(seq) == N:
# TypeError: object of type 'NoneType' has no len()



# def dfs(s):
#     if len(s) == N:
#         sequences.append(s)
#         return
#     if s == '':
#         tail_num = 1
#     else:
#         tail_num = int(s[-1])
#     for nxt_d in range(tail_num,M+1):
#         dfs(s+str(nxt_d))
# dfs('')
## 10の時2桁追加されて停止条件飛び越す
## 10の時は0を追加して例外亭な処理する方針


Measured memory_bytes: 94072
#include <iostream>
#include <list>
#include <algorithm>
using namespace std;
#define B

#ifdef B
int main(void)
{
	int n;
	cin >> n;
	list<int> arr(n);
	for (auto &a : arr)
		cin >> a;
	int cunt = 0;
	list<int>::iterator it1, it2,min, itend = arr.end();
	for (it1 = arr.begin(); it1 != itend; advance(it1,1))
	{
		min = it1;
		for (it2 = next(it1); it2 != itend; advance(it2, 1))
		{
			if (*it2 < *min)
				min = it2;
		}
		if (it1 != min) {
			cunt++;
			swap(*it1, *min);
		}

	}
	list<int>::iterator it = arr.begin();
	cout << *it;
	advance(it, 1);
	for (; it != arr.end(); advance(it, 1))
		cout << " " << *it;
	cout << endl << cunt << endl;



	return 0;
}
#endif // B

Measured memory_bytes: 3080
#include <bits/stdc++.h>
#define y1 fvck_y1
using namespace std;

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

int B1[4010][4010],B2[4010][4010];
char sd[10000];
int n,m,q;
int main()
{
	//freopen("read.in","r",stdin);
	n=read(); m=read(); q=read();
	for(int i=1;i<=n;i++)
	{
		scanf("%s",sd);
		for(int j=0;j<m;j++)
			B1[i][j+1]=sd[j]-'0';
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			if(j!=m) B2[i*2-1][j*2]=B1[i][j]&B1[i][j+1];
			if(i!=n) B2[i*2][j*2-1]=B1[i][j]&B1[i+1][j];
		}
	}
	for(int i=1;i<n*2;i++) for(int j=1;j<m*2;j++)
		B2[i][j]+=B2[i-1][j]+B2[i][j-1]-B2[i-1][j-1];
	for(int i=1;i<=n;i++) for(int j=1;j<=m;j++)
		B1[i][j]+=B1[i-1][j]+B1[i][j-1]-B1[i-1][j-1];
	for(int i=1;i<=q;i++)
	{
		int x1=read(), y1=read(),x2=read(), y2=read();
		int X=B1[x2][y2]+B1[x1-1][y1-1]-B1[x1-1][y2]-B1[x2][y1-1];
		int Y=B2[x2*2-1][y2*2-1]+B2[x1*2-2][y1*2-2]-B2[x1*2-2][y2*2-1]-B2[x2*2-1][y1*2-2];
		printf("%d\n",X-Y);
	}
	
	return 0;
}

Measured memory_bytes: 96000
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100010;
typedef long long ll;
int A[MAXN];
int n;

void init(int n) {
  for (int i=1; i<=n; i++) {
    A[i] = 0;
  }
}
void add(int i,int x) {
  while (i<=n) {
    A[i] += x;
    i += i & -i;
  }
}
ll getSum(int i) {
  ll ret = 0;
  while (i) {
    ret += A[i];
    i -= i & -i;
  }
  return ret;
}
int main() {
  int q;
  cin >> n >> q;
  init(n);
  while (q--) { 
    int com, x, y;
    cin >> com >> x >> y;
    if (com==0) {
      add(x,y);
    } else {
      ll ans = getSum(y)-getSum(x-1);
      cout << ans << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3460
#include <iostream>
#include <map>
using namespace std;
typedef long long ll;
map<ll, ll> mp;
int main(void){
    // Your code here!
    ll h, w;
    string st[100];
    cin >> h >> w;
    for (ll i = 0; i < h; i++) cin >> st[i];
    for (ll i = 0; i < w; i++){
        bool jud = true;
        for (ll j = 0; j < h; j++){
            if (st[j][i] == '#') jud = false;
        }
        if (jud) mp[i]++;
    }
    for (ll i = 0; i < h; i++){
        bool jud = true;
        for (ll j = 0; j < st[i].length(); j++){
            if (st[i][j] == '#') jud = false;
        }
        if (!jud){
            for (ll j = 0; j < w; j++){
                if (mp[j] == 0) cout << st[i][j];
            }
            cout << endl;
        }
    }
}


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

int main() {
    long long n,m,a;
    cin >> n >> m ;
    for(int i = 0;i < m;i++){
        cin >> a;
        n -= a;
    }
    if(n >= 0){
        cout << n << endl;
    }
    else{
        cout << -1 << endl;
    }

}

Measured memory_bytes: 3592
#include <iostream>
using namespace std;
int p[101000],a[1010000];
int Find(int x){
    if(x == p[x]) return x;
    else return p[x] = Find(p[x]); // 경로 압축
}
void Union(int x, int y){
    x = Find(x);
    y = Find(y);
    p[y] = x;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int n,m;
    cin >> n >> m;
    for(int i=1;i<=n;i++) p[i] = i;
    for(int i=1;i<=n;i++) cin >> a[i];
    for(int i=0;i<m;i++){
        int a,b;
        cin >> a >> b;
        Union(a,b);
    }
    int cnt = 0;
    for(int i=1;i<=n;i++){
        if(Find(a[i]) == Find(i)) cnt++;
    }
    cout << cnt << '\n'; // 노드 1은 제외
    return 0;
}

Measured memory_bytes: 2944
#include<stdio.h>
int main(){
  int N,X;
  int m[1000];
  int i;
  scanf("%d %d",&N,&X);
  for(i=0;i<N;i++){
    scanf("%d\n",&m[i]);
  }
  int total=0;
  int min=m[0];
  for(i=0;i<N;i++){
    total=total+m[i];
    if(min>m[i]){
      min=m[i];
    }
  }
  int count=(X-total)/min;
  printf("%d",N+count);
}


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

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

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

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

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

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

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

using namespace std;

/* Some Libraries */

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int K; cin>>K;
    vector<vi> G(K);
    rep(i,K){
        int t = (i*10+7)%K;
        G[i].pb(t);
    }
    queue<int> que;
    que.push(7%K);
    vi dist(K,-1);
    dist[7%K] = 1;
    while(!que.empty()){
        int v = que.front(); que.pop();
        for(auto u:G[v]){
            if (dist[u]!=-1) continue;
            dist[u] = dist[v]+1;
            que.push(u);
        }
    }
    cout<<dist[0]<<endl;
    return 0;
}


Measured memory_bytes: 61708
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int x,a;
  cin>>x>>a;
  cout<<(x<a?0:10)<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <iterator>  // std::back_inserter()
#include <algorithm>  // std::copy()
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)
using namespace std;

// typedef
typedef long long ll;
typedef unsigned long ul;
// #define int long long

// macro
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (int i=0; i < (int)(n); i++)  // 0 ~ n-1
#define REPN(i, n) for (int i=1; i <= (int)(n); i++)  // 1 ~ n
#define DESCEND greater<int>()  // sort 降順 大きい順
#define UNIQUE(vec) (vec).erase(unique(ALL((vec))), (vec).end());  // 必ずsortを行なってから
#define MIN(vec) min_element(ALL((vec)))  // 値を取り出すときは * を先頭につける
#define MAX(vec) max_element(ALL((vec)))
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(ALL((vec)), 0)  // 0 は初期値
#define COPY(vec1, vec2) copy(ALL(vec1), back_inserter(vec2))  // vec1をvec2にコピーする vec2は空にしておく必要あり
#define zero_pad(num) setfill('0') << std::right << setw(num)  // 直後の要素をパディング
#define space_pad(num) setfill(' ') << std::right << setw(num)  // 直後の要素をパディング

// func declaration
template <class T> void print2DVec(vector< vector<T> >&);
template <class T> void calcVec(vector<T>&, int, char);
int char_to_int(const char);

// const
const int INF = 10000000;

/*MEMO
・辞書順
abc < abcd, atcoder < atlas
・イテレータ
std::vector<int>::iterator とタイプするのは面倒なので、
 通常は型推論の auto を使用する。
 auto iter = max_element(ALL(vec));
・2次元配列
vector<vector<int>> vec = {{1, 2, 3}, {4, 5, 6}}
・20×10の配列
vector<vector<int>> vec(20, vector<int>(10, 0));
・(n, m)の多次元配列
vector< vector<int> > vec(n, vector<int>(m, 0))  // 0で初期化
*/

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

    // input
    int N;
    cin >> N;
    
    // calculation
    if (N < 3) {
        cout << 0 << "\n";
    } else {
        cout << N / 3 << "\n";
    }
    
    
    
    
    return 0;
}


// function
template <class T> void print2DVec(vector< vector<T> >& vec) {
    REP(i, vec.size()) {
        REP(j, vec.front().size()) {
            cout << vec.at(i).at(j);
        }
        cout << endl;
    }
}

template <class T> void calcVec(vector<T> &vec, int num, char ch) {
    // vec全体への演算
    switch (ch) {
        case '+':
            REP(i, vec.size()) vec.at(i) += num; break;
        case '-':
            REP(i, vec.size()) vec.at(i) -= num; break;
        case '*':
            REP(i, vec.size()) vec.at(i) *= num; break;
        case '/':
            REP(i, vec.size()) vec.at(i) /= num; break;
        case '%':
            REP(i, vec.size()) vec.at(i) %= num; break;
        default:
            cout << "Incorrect Operator" << endl;
    }
}

int char_to_int(const char c) {
    if('0' <= c && c <= '9') return (c - '0');
    return -1;
}


Measured memory_bytes: 256
A,B =map(int,input().split())
if A%3 == 0 or B%3 ==0 or (A+B)%3 ==0:
  print("Possible")
  
else:
  print("Impossible")
  
  
#A,B,Cが少なくとも一つ三の倍数かどうかを確かめる
#A*B*C%3==0　でいける！！！

Measured memory_bytes: 2940
import java.util.Scanner;

public class Main{
    
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        sc.close();
        int RectangleArea = a*b;
        int RectangleLength = (a+b)*2;
        System.out.println(RectangleArea + " " + RectangleLength);
    }
    
}


Measured memory_bytes: 26136
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,n) for(ll i=0;i<(n);++i)
#define REPR(i,n) for(ll i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    ll n,m; cin>>n>>m;
    vector<ll> a(n);
    ll s = 0;
    rep(i,n) cin>>a[i], s+=a[i];
    priority_queue<ll> pq;

    rep(i,n) {
        ll b = a[i];
        while (b>0) {
            pq.push(b-(b/2));
            b/=2;
        }
    }

    while (!pq.empty() && m--) {
        s -= pq.top();
        pq.pop();
    }

    cout << s << '\n';
    return 0;
}

Measured memory_bytes: 35940
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
typedef long long ll;

int main() {
	string S, T;
    const int S_MAX = 3010;
    int dp[S_MAX][S_MAX];
	cin >> S >> T;

    for (int i = 0; i < S_MAX; ++i){
        for (int j = 0; j < S_MAX; ++j){
            dp[i][j] = 0;
        }
    }
    
    for (int i = 1; i <= S.length(); ++i){
        for (int j = 1; j <= T.length(); ++j){
            if (S[i-1] == T[j-1]){
                dp[i][j] = dp[i-1][j-1] + 1;
            }else{
                dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
            }
        }
    }

    string ans = "";
    int i = S.length();
    int j = T.length();
    int k = dp[i][j];
    while (dp[i][j] != 0){
        if (S[i-1] == T[j-1]){
            ans += S[i-1];
            i--;
            j--;
        } else if (dp[i][j] == dp[i][j-1]){
            j--;
        } else if (dp[i][j] == dp[i-1][j]){
            i--;
        } else {
            cout << "error" << endl;
            break;
        }
    }

    reverse(ans.begin(), ans.end());
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 38968
import java.util.*;
import java.io.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        int A = Integer.parseInt(sc.next());
        int B = Integer.parseInt(sc.next());

        int coin = 0;
        for (int i = 0; i < 2; i++) {
            if (A > B) {
                coin += A;
                A--;
            } else {
                coin += B;
                B--;
            }
        }
        out.printf("%d\n", coin);
        out.flush();
    }
}


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

vector<int> G[100005];
vector<int> li;
int n, u, v;

bool find(int x, int px){
  
  if( x == u ){
    li.push_back( x );
    return true;
  }
  
  for(int nx : G[x] ){
    
    if( nx == px ) continue;

    if( find( nx, x ) ){
      li.push_back( x );
      return true;
    }
    
  }
  
  return false;
}

int X, maxlen;

void dfs(int x, int px, int len){

  maxlen = max( maxlen, len );
  
  for(int nx : G[x] ){
    
    if( nx == px ) continue;
    if( nx == X ) continue;
    
    dfs( nx, x, len + 1 );
    
  }
  
}

signed main(){
  
  cin>>n>>u>>v;
  
  u--, v--;
  
  for(int i=0;i<n-1;i++){
    int a, b;
    cin>>a>>b;
    a--, b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  
  find( v, -1 );
  
  int s = (int)li.size() / 2 - 1;
  
  X = li[s+1];
  
  dfs( li[s], -1, 0 );
  
  int cntu = s + maxlen;
  int cntv = (int)li.size() - ( s + 1 ) + maxlen;
  
  if( cntu == 0 ){
    cout<<cntv-1<<endl;
  }
  else if( cntv - cntu == 1 ){
    cout<<cntu<<endl;
  }
  else cout<<cntu+1<<endl;
  
  return 0;
}


Measured memory_bytes: 9972
def main():
    n = int(input())
    s = []
    for _ in range(n):
        ss = int(input())
        s.append(ss)

    total = sum(s)
    if total % 10 != 0:
        print(total)
        return
    s.sort()

    for i, ss in enumerate(s):
        if ss % 10 != 0:
            print(total-ss)
            return
    print(0)

if __name__ == '__main__':
    main()


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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b)
{
    return b ? gcd(b, a % b) : a;
}
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

long long cnt = 0;

void func(long long H)
{
}

int main()
{
    // cout << fixed << setprecision(5);

    long long H;
    scanf("%lld", &H);
    ll v = H;
    ll c = 0;
    while (v >= 1)
    {
        if (c == 0)
        {
            c += 1;
            cnt += 1;
        }
        else
        {
            c *= 2;
            cnt += c;
        }
        v = floor(v / 2);
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstring>
using namespace std;
long long n,m;
long long w[101],v[101];
long long dp[101][100001];

int main(){
	cin>>n>>m;
	for (int i=0;i<n;i++){
		cin>>w[i]>>v[i];
	}
//	memset(dp,-1,sizeof(dp));
	for (int i=n-1;i>=0;i--){
		for (int j=0;j<=m;j++){
			if (j<w[i]){
				dp[i][j]=dp[i+1][j];
			}else {
				dp[i][j]=max(dp[i+1][j],dp[i+1][j-w[i]]+v[i]);
			}
		}
	}
	cout<<dp[0][m]<<endl;
	return 0;
}

Measured memory_bytes: 78336
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;


int main() {
  ios_base::sync_with_stdio(false);
  int n, d;
  cin >> n >> d;
  d = d + d + 1;
  cout << (n + d - 1) / d << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const ll Mod = 998244353;
const int MAX = 510000;
const double PI = 3.14159265358979323846;

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i=0; i<N; i++) cin >> a[i];
  vector<int> b(N, 0);
  for (int i=N-1; i>=0; i--) {
    int sum = 0;
    for (int j=i; j<N; j+=i+1) sum += b[j];
    if (sum%2==0&&a[i]%2!=0) b[i] = 1;
    else if (sum%2!=0&&a[i]%2==0) b[i] = 1;
    else b[i] = 0;
  }
  int M = 0;
  for (int i=0; i<N; i++) {
    if (b[i]==1) M++;
  }
  cout << M << endl;
  for (int i=0; i<N; i++) {
    if (b[i]==1) cout << i+1 << " ";
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 2432
/*raghav0307 - Raghav Gupta*/

#include <bits/stdc++.h>
using namespace std;

#define ff first
#define ss second
#define pb push_back
#define fast_io() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

typedef long long ll;

int main(){
	fast_io();
	int h, w;	
	cin >> h >> w;
	queue<pair<int, int > > q;
	int color[h][w];
	memset(color, -1, sizeof(color));
	bool visited[h][w];
	memset(visited, false, sizeof(visited));
	int grid[h][w];
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			char c;	cin >> c;
			grid[i][j] = c == '#';
			if(grid[i][j]){
				q.push({i,j});
				color[i][j] = 0;
			}
		}
	}

	int move[4][2] = {{1,0},{-1,0},{0,-1},{0,1}};

	// for(int i = 0; i < h; i++){
	// 	for(int j = 0; j < w; j++){
	// 		cout << color[i][j] << " ";
	// 	}cout << "\n";
	// }cout << "\n";
	
	while(!q.empty()){
		auto x = q.front(); q.pop();
		if(visited[x.ff][x.ss])	continue;
		visited[x.ff][x.ss] = true;
		for(int i = 0; i < 4; i++){
			if(x.ff + move[i][0] >= h or x.ff + move[i][0] < 0)	continue;
			if(x.ss + move[i][1] >= w or x.ss + move[i][1] < 0)	continue;
			if(color[x.ff + move[i][0]][x.ss + move[i][1]] == -1 or 
				color[x.ff + move[i][0]][x.ss + move[i][1]] > color[x.ff][x.ss] + 1){	
				color[x.ff + move[i][0]][x.ss + move[i][1]] = color[x.ff][x.ss] + 1;
				q.push({x.ff + move[i][0],x.ss + move[i][1]});
			}
		}
		// for(int i = 0; i < h; i++){
		// 	for(int j = 0; j < w; j++){
		// 		cout << color[i][j] << " ";
		// 	}cout << "\n";
		// }cout << "\n";
	}

	// for(int i = 0; i < h; i++){
	// 	for(int j = 0; j < w; j++){
	// 		cout << color[i][j] << " ";
	// 	}cout << "\n";
	// }cout << "\n";

	int ans = 0;
	for(int i = 0; i < h; i++)
		for(int j = 0; j < w; j++)
			ans = max(ans, color[i][j]);

	cout << ans;

	return 0;
}


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

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

   for(int i=0; i<25; i++){
	   if(b > a){
		t = a;
		a = b;
		b = t;
	   }else if(c > b){
		t = b;
		b = c;
		c = t;
	   }else if(d > c){
		t = c;
		c = d;
		d = t;
	   }else if(e > d){
		t = d;
		d = e;
		e = t;
	   }
   }

   cout << a << " " << b << " " << c << " " << d << " " << e << endl;

   return 0;
}

Measured memory_bytes: 1164
#include <iostream>
using namespace std;
typedef long long ll;
ll kaijo[1010], a, b, c, d, n, dp[1010][1010];
const ll mod = 1000000007;

ll pow(ll x, ll y){
    if (y == 0) return 1;
    if (y % 2){
        return x * pow(x, y - 1) % mod;
    } else {
        ll han = pow(x, y / 2);
        return han * han % mod;
    }
}

int main(void){
    // Your code here!
    cin >> n >> a >> b >> c >> d;
    kaijo[0] = 1;
    for (ll i = 1; i <= 1000; i++) kaijo[i] = kaijo[i - 1] * i % mod;
    dp[a - 1][0] = 1;
    for (ll i = a; i <= b; i++){
        for (ll j = 0; j <= n; j++){
            (dp[i][j] += dp[i - 1][j]) %= mod;
            for (ll k = c; k <= min((n - j) / i, d); k++){
                (dp[i][j + i * k] += dp[i - 1][j] * kaijo[i * k] % mod * pow(pow(kaijo[i], k) * kaijo[k] % mod, mod - 2) % mod * kaijo[n - j] % mod * pow(kaijo[i * k] * kaijo[n - j - i * k] % mod, mod - 2) % mod) %= mod;
            }
        }
    }
    cout << dp[b][n] << endl;
}


Measured memory_bytes: 8192
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
  let stdin = stdin();
  let stdin = stdin.lock();
  let token: String = stdin
    .bytes()
    .map(|c| c.expect("failed to read char") as char)
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect();
  token.parse().ok().expect("failed to parse token")
}

use std::cmp::{max, min};
use std::collections::HashMap;

fn main() {
  let mut a = read::<i64>();

  println!("{}", 800 * a - ((a / 15) * 200));
}



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

string s;
int q, t, f;
char c;
int main(){
  string pre, suf;
  bool back = false;
  cin >> s >> q;
  while (q--) {
    cin >> t;
    if (t==1) {
      back = !back;
      swap(pre, suf);
    } else {
      cin >> f >> c;
      if (f==1) pre += c;
      else suf += c;
    }
  }
  reverse(pre.begin(), pre.end());
  if (back) reverse(s.begin(), s.end());
  cout << pre << s << suf << endl;
}


Measured memory_bytes: 1088
m,n = map(int, input().split())
road_dict = {k+1:0 for k in range(m)}
for _ in range(n):
  i, j = map(int, input().split())
  road_dict[i] += 1
  road_dict[j] += 1
for v in road_dict.values():
  print(v)

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


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

	int Tlength = T.length();
	int Slength = S.length();

	vector<int> ans;

	for (int i = 0; i < Slength - Tlength + 1; i++) {
		string substr = S.substr(i, Tlength);

		int A = 0;

		for (int j = 0; j < Tlength; j++) {
			if (substr[j] != T[j]) {
				A++;
			}
		}

		ans.push_back(A);
	}

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

	cout << ans.front() << endl;
}

Measured memory_bytes: 3640
#include<iostream>
#include <string>
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define M 1000000007
#define all(v) v.begin(),v.end()
#define fr(a,b,c) for(ll i=a;i<=b;i+=c)
#define inarr(arr,n); for(ll i=0;i<n;i++) cin >> arr[i];
#define outarr(arr,n); for(ll i=0;i<n;i++) cout<<arr[i]<<" ";
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
int main() {
    ios;
	ll n;
    cin>>n;
    ll ans=0;
    ll n1=n-1;
    if(n>1e6){
    for(int i=2;i<=sqrt(n1);i++){
        if(n1%i==0){
            if(i!=sqrt(n1)){
                ans+=2;
            }
            else{
                ll z=sqrt(n1);
                if(z*z==n1){
                    ans+=1;
                }
            }
        }
    }
    ans+=1;
    for(int i=2;i<=sqrt(n);i++){
        if(n%i==0){
            if(i!=sqrt(n)){
                ll temp=n;
                ll z1=i;
                ll z2=n/i;
                while(temp>1){
                    if(temp%z1==0){
                    temp=temp/z1;}
                    else{
                        break;
                    }
                }
                if(temp%z1==1){
                    ans+=1;
                }
                temp=n;
                while(temp>1){
                    if(temp%z2==0){
                    temp=temp/z2;}
                    else{
                        break;
                    }
                }
                if(temp%z2==1){
                    ans+=1;
                }
            }
            else{
                ll z=sqrt(n);
                if(z*z==n){
                    ans+=1;
                }
            }
        }
    }
    ans+=1;
    cout<<ans<<endl;}
    else{
        for(int i=2;i<=n;i++){
            if(n%i==1){
                ans+=1;
            }
            else if(n%i==0){
                ll temp=n;
                while(temp>1){
                    if(temp%i==0){
                        temp=temp/i;
                    }
                    else{
                        break;
                    }
                }
                if(temp%i==1){
                    ans++;
                }
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}

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

int main() {
  int N, K;
  scanf("%d%d", &N, &K);
  string S;
  cin >> S;

  S.at(K - 1) = S.at(K - 1) + 0x20;

  cout << S << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
using namespace std;
int n,t;
int main(){
      ios_base::sync_with_stdio(false); cin.tie(NULL);
      cin>>n;
      float a,b,c=n;
      if(n%2)a=(c+1)/2;
      else a=c/2;
      cout<<a/n;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
    for(;;){
        int n,m;
        int a[1024];//input
        int check[1024];//check

        scanf("%d%d",&n,&m);
        if(n == 0 && m == 0)break;

        for(int i = 0;i < m; i++)check[i] = -1;

        for(int i = 0;i < n; i++){
            for(int j = 0;j < m; j++){
                scanf("%d",&a[j]);
                check[j] += a[j];
            }
        }
        int x = 0;
        for(int i = n;i >= 0; i--){
            for(int j = 0;j < m; j++){
                if(check[j] == i){
                    printf("%d",j + 1);
                    ++x;
                    if(x != m)printf(" ");
                    else printf("\n");
                }
            }
        }
    }
    return 0;
}

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

int main() {
  int n, m;
  int a[100][100], b[100];

  cin >> n >> m;
  for (int i=0;i<n;i++)
    for (int j=0;j<m;j++)
      cin >> a[i][j];
  for (int j=0;j<m;j++)
    cin >> b[j];

  for (int i=0;i<n;i++) {
    int res = 0;
    for (int j=0;j<m;j++)
      res += a[i][j] * b[j];
    cout << res << endl;
  }
}



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

const int MAX_N=1e5;

int N,A[MAX_N];

int gcd(int a,int b){
	if (b==0){
		return a;
	}
	return gcd(b,a%b);
}

bool solve(){
	bool win=true;
	while(1){
		int os=0,es=0;
		REP(i,N){
			if (A[i]%2==1){
				os++;
			}else{
				es++;
			}
		}
		if (es%2==1){
			break;
		}
		if (os==1){
			REP(i,N){
				if (A[i]%2==1){
					if (A[i]==1){
						win=!win;
						return win;
					}else{
						A[i]--;
					}
				}
			}
			int g=A[0];
			FOR(i,1,N){
				g=gcd(g,A[i]);
			}
			REP(i,N){
				A[i]/=g;
			}
			win=!win;
		}else{
			win=!win;
			break;
		}
	}
	return win;
}

int main(){
	cin>>N;
	REP(i,N){
		cin>>A[i];
	}
	if (solve()){
		cout<<"First"<<endl;
	}else{
		cout<<"Second"<<endl;
	}
	return 0;
}


Measured memory_bytes: 640
/************
* 	@Just Another Source code by: ankit.sangwan1999
*	@created on: 24 Jun 2020
*	@Based On : MCM
*/
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL) //;cout.tie(NULL)
#define ll long long
const int mod = 1e9+7;
const long double pie = 3.14159265358979323846;
#define endl '\n'
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
gp_hash_table<int, ll> ma; // orderd_map using pb_ds
const int N = 405;		
ll dp[N][N];
ll sum[N];

void pre_sum(int *arr, int n){
	sum[0] = arr[0];
	for(int i=1;i<n;i++) sum[i] = sum[i-1] + arr[i];
}

// Cost of interval l to r is -> minimum among the partitions from (k=i to k=j) + sum of terms i to j
// dp[i][j] -> stores the minimum cost of the interval i to j.

// O(n^3) time and space
ll MCM(int i, int j, int *arr){
	if(dp[i][j] != -1) return dp[i][j];
	
	if(i==j){
		return dp[i][j] = 0;
	}

	ll ans = ULLONG_MAX/2;
	
	ll curr_cost = (i==0?sum[j]:sum[j]-sum[i-1]); // sum till i to j.(cost of joining the left and right intervals)
	
	for(int k=i;k<j;k++){

		ll left_cost = MCM(i,k,arr);
		ll right_cost = MCM(k+1,j,arr);
		ll tmp = left_cost + right_cost + curr_cost;
		ans = min(ans, tmp);

	}
	return dp[i][j] = ans;

}

void solve(){
	memset(dp, -1, sizeof(dp));
	int n;
	cin>>n;
	int arr[n];
	for(int i=0;i<n;i++){
		cin>>arr[i];
	}
	pre_sum(arr, n); // to calculate the prefix sums.
	// TOP DOWN
	// cout<<MCM(0,n-1, arr);


	// Bottom-Up:
	for(int len=1;len<=n;len++){ // length of interval -> moving from smaller to larger intervals.
		for(int i=0;i<=n-len;i++){ // fixing the starting point.
			int j = i+len-1;
			// considering interval i to j
			if(i==j){
				dp[i][j] = 0;
			}
			else{
				ll tmp  = ULLONG_MAX/2;
				ll curr_cost = (i==0?sum[j]:sum[j]-sum[i-1]); // sum till i to j.(cost of joining the left and right intervals)
				for(int k=i;k<j;k++){
					tmp = min(tmp, dp[i][k] + dp[k+1][j] + curr_cost); 
				}
				dp[i][j] = tmp;
			}
		}
	}

	cout<<dp[0][n-1]<<endl;









}
signed main(){

    fastio;
    int t=1;
    //cin>>t;

    while(--t>=0){
    	solve();
    }
	
    return 0;
}

Measured memory_bytes: 4832
import bisect

s = input()
t = input()
if set(list(s + t)) != set(list(s)):
    print(-1)
    exit()
check = set(list(t))
dic = {}
for Str in check:
    dic[Str] = []
for i in range(len(s)):
    if s[i] in check:
        dic[s[i]] += [i]
times = 0
now = -1
for p in t:
    if now >= dic[p][-1]:
        now = dic[p][0]
        times += 1
    else:
        now = dic[p][bisect.bisect(dic[p], now)]
print(len(s) * times + now + 1)

Measured memory_bytes: 85184
#include<bits/stdc++.h>
#define ll long long int
#define mod 1000000007
#define SIZE 52
using namespace std;
ll n,k;
ll mat[SIZE][SIZE];
int test = 0;
void one (ll a[SIZE][SIZE])
{
	for(ll i=0;i<SIZE;i++)
	{
		for(ll j=0;j<SIZE;j++)
			a[i][j]=(i==j);
	}
}

void mul(ll a[SIZE][SIZE],ll b[SIZE][SIZE])
{
	ll res[SIZE][SIZE] ={{0}};

	for(ll i=0;i<n;i++)
	{
		for(ll j=0;j<n;j++)
		{
			for(ll k=0;k<n;k++)
			{
				res[i][j] = (res[i][j] +((a[i][k]%mod)*(b[k][j]%mod))%mod)%mod;
			}
		}
	}

	for(ll i=0;i<SIZE;i++)
	{
		for(ll j=0;j<SIZE;j++)
			a[i][j] = res[i][j];
	}
}
void print_mat(ll a[SIZE][SIZE])
{
	for(ll i=0;i<n;i++)
	{
		for(ll j=0;j<n;j++)
			cout<<a[i][j]<<" ";
		cout<<endl;
	}
}
void power(ll a[SIZE][SIZE], ll k)
{
	if(test) print_mat(a);
	ll res[SIZE][SIZE];
	one(res);

	if(test) print_mat(res);
	while(k>0)
	{
		if(k%2 == 0)
		{
			mul(a,a);
			if(test) print_mat(a);
			k/=2;
		}
		else
		{
			mul(res,a);
			if(test) print_mat(res);
			k--;
		}
	}


	ll count = 0;
	for(ll i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
			count = (count+res[i][j])%mod;
	}

	cout<<count<<endl;
}
int main()
{
	cin>>n>>k;
	for(ll i=0;i<n;i++)
	{
		for(ll j=0;j<n;j++)
			cin>>mat[i][j];
	}

	power(mat,k);
}

Measured memory_bytes: 256
#ifdef _MSC_VER
#include <__msvc_all_public_headers.hpp>
#undef min
#undef max
#else
#define NDEBUG
#include <bits/stdc++.h>
#endif

using namespace std;
using large = long long;

int main() {
    string s;
    cin >> s;

    const auto n = int(s.length());
    auto cnt = 0;
    for (auto i = 0; i < n; ++i) {
        if (s[i] == i % 2 + '0')
            ++cnt;
    }
    cout << min(cnt, n - cnt) << endl;
    return 0;
}


Measured memory_bytes: 3744
#include<cstdio>

int binarysearch(int *A,int key,int n){
  int left=0,right=n,mid;
  while(left<right){
    mid = (right+left)/2;
    
    if(key==A[mid]){
      return 1;
    }else if(key<A[mid]){
      right = mid;
    }else{
      left = mid+1;
    }
  }
  return 0;
}

int main() {
  int A[100000];
  
  int n;
  scanf("%d",&n);
  
  
  for(int i=0;i<n;i++){
    scanf("%d",A+i);
  }
  
  int q;
  scanf("%d",&q);
  
  int key,sum=0;
  for(int i=0;i<q;i++){
    scanf("%d",&key);
    if(binarysearch(A,key,n)){
      sum++;
    }
  }
  
  printf("%d\n",sum);
  
  return 0;
}

Measured memory_bytes: 2968
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	final int MOD = 1000000007;
	final int MAX = Integer.MAX_VALUE;
	final long LMAX = Long.MAX_VALUE;


	void doIt() {
		String s = sc.next();
		if(s.equals("Sunny"))System.out.println("Cloudy");
		else if(s.equals("Cloudy"))System.out.println("Rainy");
		else if(s.equals("Rainy"))System.out.println("Sunny");
	}


	public static void main(String[] args) {
		new Main().doIt();
	}
}


Measured memory_bytes: 21460
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <utility>

using namespace std;

typedef pair<int, int> pii;

#define fst first
#define scd second
#define rep(i,x) for(int i=0;i<(x);++i)

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

const int inf = 1e9;

int k[150];
vector<pii> stone[150];
int N, M;

int memo[150][150][10];

int rec(int n, int m, int i)
{
	if (n >= N - 1) return 0;

	if (~memo[n][m][i]) return memo[n][m][i];

	int res = inf;

	rep(j, k[n + 1]) {
		int dist = (stone[n][i].scd + stone[n + 1][j].scd) * abs(stone[n][i].fst - stone[n + 1][j].fst);
		chmin(res, dist + rec(n + 1, m, j));
	}

	if (m < M) {
		if (n + 2 >= N) return 0;
		rep(j, k[n + 2]) {
			int dist = (stone[n][i].scd + stone[n + 2][j].scd) * abs(stone[n][i].fst - stone[n + 2][j].fst);
			chmin(res, dist + rec(n + 2, m + 1, j));
		}
	}

	return memo[n][m][i] = res;
}

signed main()
{
	while (scanf("%d %d", &N, &M), N || M) {
		rep(i, N) {
			scanf("%d", &k[i]);

			stone[i].resize(k[i]);

			rep(j, k[i]) {
				int x, d; scanf("%d %d", &x, &d);
				stone[i][j].fst = x, stone[i][j].scd = d;
			}
		}

		int ans = inf;

        memset(memo, -1, sizeof(memo));

		rep(i, k[0]) chmin(ans, rec(0, 0, i));

		if (M > 0) rep(i, k[1]) chmin(ans, rec(1, 1, i));

		printf("%d\n", ans);
	}
}

Measured memory_bytes: 1948
N = input()
list = list(map(int,input().split()))
l = [1]
j = 0

for i in range(1,len(list)):
 if list[i] == list[i - 1]:
  l[j] += 1
 else:
  l.append(1)
  j += 1
ans = 0
for u in range(0,len(l)):
 ans += int(l[u] / 2)

print(ans)

Measured memory_bytes: 3064
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,b,n) for(int i=b;i<n;i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;

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

int main(){

	double q;
	while( cin >> q){
		if(q==-1) break;
		double x = q / 2;
		while(1){
			x = x - (x*x*x - q)/(3*x*x);
			if(abs(x*x*x-q) < 0.00001*q) break;
		}
		printf("%.6f\n",x);
	}
	return 0;
}

Measured memory_bytes: 1236
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <string>
#include <set>
#include <cassert>

using namespace std;

const int mod = (int)1e9 + 7;

// a^n % mod
long long modpow(long long a, long long n, long long mod) {
	long long ret = 1;

	while (n > 0) {
		if (n & 1) {
			ret = ret * a % mod;
		}

		a = a * a % mod;
		n >>= 1;
	}

	return ret;
}

// aの逆元
long long modinv(long long a, long long mod) {
	assert(gcd(a, mod) == 1);
	// TODO assert(modが素数)
	return modpow(a, mod - 2, mod);
}


class Combination {
public:
	vector<long long> fact, ifact;
	long long mod;
public:
	Combination(int n, int mod) : fact(n+1), ifact(n+1), mod(mod) {
		fact[0] = 1;
		for (int i = 1; i <= n; i++) {
			fact[i] = fact[i-1] * i % mod;
		}
		ifact[n] = modinv(fact[n], mod);
		for (int i = n; i > 0; i--) {
			ifact[i-1] = ifact[i] * i % mod;
		}
	};
	// ~Combination();

	// nCk
	long long comb(int n, int k) {
		assert(n >= 0);
		assert(0 <= k && k <= n);
		return fact[n] * ifact[k] % mod * ifact[n-k] % mod;
	}

	// nPk
	long long perm(int n, int k) {
		assert(n >= 0);
		assert(0 <= k && k <= n);
		return fact[n] * ifact[n - k] % mod;
	}

	// nHk n種類から重複を許してk個
	long long h(int n, int k) {
		return comb(n - k + 1, k);
	}
};

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

	n = s.size();
	Combination com(n+k, mod);

	long long sum = 0;
	for (int i = 0; i <= k; i++) {
		sum += modpow(25, i, mod) * modpow(26, k - i, mod) % mod * com.comb(i + n - 1, n - 1) % mod;
		sum %= mod;
	}

	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 35264
object Main extends App {
  val inputs: Seq[String] = scala.io.Source.stdin.getLines().toList
  val abc = inputs.head.split(" ").map(_.toInt)
  val a = abc(0)
  val b = abc(1)
  val c = abc(2)

  println(solve(a, b, c))

  private def solve(a: Int, b: Int, c: Int): String = {
    if(b - a == c - b) {
      return "YES"
    } else {
      return "NO"
    }
  }
}

Measured memory_bytes: 54852
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"

using namespace std;

const int MOD = 1000000007;
//const int MOD = 998244353;

long long int N, M, K, H, W, L, R;
//int N, M, K, H, W, L, R;

void Calculate_Depth(vector<vector<int>>&edge, vector<int>&depth, int stnode) {
	depth[stnode] = 0;
	queue<int>Q;
	Q.push(stnode);
	while (!Q.empty()) {
		int cn = Q.front();
		Q.pop();
		for (auto i : edge[cn]) {
			if (depth[i] > depth[cn] + 1) {
				depth[i] = depth[cn] + 1;
				Q.push(i);
			}
		}
	}
	return;
}

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

	cin >> N >> K;
	vector<int>v(N);
	vector<vector<int>>edge(N);
	vector<int>depth(N, MOD);
	depth[0] = 0;
	int ans = 0;
	for (auto &i : v) {
		cin >> i;
		i--;
	}
	for (int i = 1; i < N; i++) {
		edge[v[i]].push_back(i);
	}
	if (v[0]) {
		v[0] = 0;
		ans++;
	}
	Calculate_Depth(edge, depth, 0);
	priority_queue<pair<int, int>>PQ;
	for (int i = 1; i < N; i++) {
		if(depth[i]>K)PQ.push({ depth[i],i });
	}
	while (!PQ.empty()) {
		int cn = PQ.top().second;
		int c = PQ.top().first;
		PQ.pop();
		if (c != depth[cn])continue;
		ans++;
		while (depth[cn] > c - K + 1) {
			cn = v[cn];
		}
		depth[cn] = 1;
		queue<int>Q;
		Q.push(cn);
		while (!Q.empty()) {
			int ccn = Q.front();
			Q.pop();
			for (auto i : edge[ccn]) {
				if (depth[i] > depth[ccn] + 1) {
					depth[i] = depth[ccn] + 1;
					Q.push(i);
				}
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 7672
Option Explicit On

Module Module1

    Sub Main()

        Dim K As Integer = Console.ReadLine()
        Dim S As String = Console.ReadLine()

        If Len(S) <= K Then
            Console.WriteLine(S)
        Else
            Console.WriteLine(Left(S, K) & "...")
        End If

        Console.ReadLine()

    End Sub

End Module


Measured memory_bytes: 28072
#include <iostream>

using namespace std;

int main() {
	int n, m;
	char a[50][50], b[50][50];

	cin >> n >> m;
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < n; ++j) {
			cin >> a[i][j];
		}
	}
	for (int i = 0; i < m; ++i) {
		for (int j = 0; j < m; ++j) {
			cin >> b[i][j];
		}
	}
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < n; ++j) {
			bool res = true;
			for (int k = 0; k < m; ++k) {
				for (int l = 0; l < m; ++l) {
					if (a[i + k][j + l] != b[k][l]) {
						res = false;
					}
				}
			}
			if (res) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;

	return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> diff;
  for (int i = 0; i < N; i++) {
    int d;
    cin >> d;
    diff.push_back(d);
  }
  sort(diff.begin(), diff.end());
  cout << diff[N/2] - diff[N/2 - 1] << endl;
}

Measured memory_bytes: 1020
// C.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main()
{
    
    int n, m;

    cin >> n >> m;
    vector<int> point(m);
    vector<int >kan(m-1);
    for (int i = 0; i < m; i++) {
        cin >> point[i];
    }

    sort(point.begin(), point.end());
    int sum = 0;
    for (int i = 0; i < m - 1; i++) {
        kan[i] = point[i + 1] - point[i];
        sum += kan[i];
    }
    //cout << sum << endl;
    sort(kan.begin(),kan.end());
    for (int i = 0; i < n-1; i++) {
        if (m - 2 - i < 0)break;
        sum -= kan[m - 2 - i];
    }
    //for (int i = 0; i < m ; i++) {
    //    cout << kan[i] << endl;
    //}
    cout << sum << endl;

    return 0;



}



Measured memory_bytes: 3972
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
constexpr int MOD = 1000000000 + 7;
constexpr int INF = 2000000000;

int main() {
	int a, b, c, d;
	std::cin >> a >> b >> c >> d;
	std::cout << std::max(0, std::min(b, d) - std::max(a, c)) << std::endl;
}

Measured memory_bytes: 256
// inputに入力データ全体が入る
function Main(input) {
	var args = input.split("\n");
	var N = parseInt(args,10);
	var history = args.slice(1,N+1);
	var answer;
	var flg = 1;
	var plan = [];
	plan[0]=[0,0,0];
	for(var i=0;i<N;i++){
		plan[i+1] = parser(history[i]);
	}

	for(var i=1;i<plan.length;i++){
		var rec1 = plan[i-1];
		var rec2 = plan[i];
		var dt = rec2[0] - rec1[0];
		var dist = Math.abs(rec2[1]+rec2[2]-rec1[1]-rec1[2]);
		if (dt >= dist && dt % 2 === dist % 2){
		}else{
				flg = 0;
		}
	}
	answer = flg ? "Yes" : "No" ;
	//出力
	console.log(answer);
}
function parser(record){
	var args = record.split(" ");
	var return_val=[];
	return_val.push(parseInt(args[0],10));
	return_val.push(parseInt(args[1],10));
	return_val.push(parseInt(args[2],10));
	return return_val
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 58348
S = input().strip()
mod = 10**9+7
dp = [1] + [0]*3
for s in S:
    dp1 = dp[:]
    if s == 'A':
        dp1[1] += dp[0]
    elif s == 'B':
        dp1[2] += dp[1]
    elif s == 'C':
        dp1[3] += dp[2]
    else:
        dp1[1] += dp[0]
        dp1[2] += dp[1]
        dp1[3] += dp[2]
        dp1[0] += 2*dp[0]
        dp1[1] += 2*dp[1]
        dp1[2] += 2*dp[2]
        dp1[3] += 2*dp[3]
    dp = [d % mod for d in dp1]
print(dp[-1])

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

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

def solve(A: int, B: int):
    if (A*B) % 2 == 0:
        print(NO)
    else:
        print(YES)
    return


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

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940