akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main()
{
  unsigned long long n,a,b;
  cin>>n>>a>>b;
  unsigned long long t=b-a;
  if(t%2==0)
  cout<<t/2;
  else
  {
    cout<<min(n-b+1+(t-1)/2,a-1+1+(t-1)/2);
  }
}


Measured memory_bytes: 256
function Main(s){
  s = s.split("\n").map(a=>+a);
  var n = s[0];
  var a = Array(n + 1).fill(0);
  for(var i = 1; i <= n; i++){
    a[s[i]] = a[s[i]-1] + 1;
  }
  var m = 0;
  for(i = 0; i <= n; i++){
    m = Math.max(m, a[i]);
  }
  console.log(n - m);
}

Main(require("fs").readFileSync("/dev/stdin","utf8"));

Measured memory_bytes: 35396
import scala.annotation.tailrec

object Main extends App {


  val tmp = io.StdIn.readLine().split(' ').map(_.toInt)
  val (n, m) = (tmp(0), tmp(1))

  val tree = new IUnionFind(n)

  val t = io.StdIn.readLine().split(' ').map(_.toInt - 1)

  for(_ <- (1 to m)) {
    val ar = io.StdIn.readLine().split(' ').map(_.toInt - 1)
    val (x, y) = (ar(0), ar(1))
    tree.union(x, y)
  }

  val ans = t.zipWithIndex
    .count{
      case (x, i) => tree.connected(x, i)
    }

  println(ans)

  class IUnionFind(val size: Int) {

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

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

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

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

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

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

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

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


Measured memory_bytes: 95264
#include<iostream>
#include<cstdio>

const char clr[5]="RYGB";

int main()
{
	int i,j;
	int H,W,d;
	scanf("%d%d%d",&H,&W,&d);
	for(i=0;i<H;i++)
	{
		for(j=0;j<W;j++)
		{
			int x = ((i + j) % (2 * d) + (2 * d)) % (2 * d) / d;
			int y = ((i - j) % (2 * d) + (2 * d)) % (2 * d) / d;
		    putchar(clr[2 * x + y]);
		}
		putchar('\n');
	}
	return 0;
}

Measured memory_bytes: 512
#include<cstdio>
#include<string>
char s[101],s2[101];
int s1,a;
int main()
{
    scanf("%s",s);
	s1=sizeof(s);
    for(int i=0; i<s1; i++)
    {
       switch(s[i])
        {
            case'0':s2[a]='0';
			a++;
			break;
            case'1':s2[a]='1';
			a++;
			break;
            case'B':if(a!=0)
			a--;
			break;
        }
    }
    for(int i=0; i<a; i++)
	{
	   printf("%c",s2[i]);
	}
    printf("\n");
}

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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
 
typedef long long ll;
typedef pair<int, int> ii;

int main() {
	
	ll n, p;
	vector<int> prime;
	vector<bool> check(150000);
	
	check[1] = check[0] = true;
	REP(i, 2, 150000){
		if(!check[i]) prime.push_back(i);
		for(int j = 2; i * j < 150000; j++){
			check[i * j] = true;
		}
	}
	
	//rep(i, prime.size()) cout << prime[i] << endl;
	//return 0;
	
	
	while(cin >> n >> p){
		if(n == -1 && p == -1) break;
		
		auto it = upper_bound(prime.begin(), prime.end(), n);
		vector<ll> tmp(p*p);
		rep(i, p){
			auto it2 = it;
			rep(j, p){
				tmp[i*p+j] = (ll)(*it) + *it2;
				it2++;
			}
			it++;
		}
		
		SORT(tmp);
		cout << tmp[p-1] << endl;
		
	}
	
	
	// your code goes here
	return 0;
}

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

// 基本テンプレート
#pragma region MACRO
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define PED cout << "\n"
#define rep(i,n) for(int i=0; i<(int)n; ++i)
#define REP(i,x,n) for(int i=x; i<(int)n; ++i)
#define repi(i,n) for(int i=0; i<=(int)n; ++i)
#define REPI(i,x,n) for(int i=x; i<=(int)n; ++i)
#define ILP while(true)
#define FOR(i,c) for(__typeof((c).begin())!=(c).begin(); i!=(c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#pragma endregion

// 型
#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long double> vld;
typedef vector<long> vl;
typedef vector<long long> vll;
typedef vector<string> vs;
#pragma endregion

// Effective std
#pragma region ESTD
template<typename C, typename T> int count(C& c, T t) { return count(ALL(c), t); }
template<typename C, typename F> int count_if(C& c, F f) { return count_if(ALL(c), f); }
template<typename C, typename T> void erase(C& c, T t) { remove(ALL(c), t), c.end(); }
template<typename C> void remove(vector<C>& c, unsigned int index) { c.erase(c.begin()+index); }
template<typename C, typename T, typename U> void replace(C& c, T t, U u) { replace(ALL(c), t, u); }
template<typename C, typename F, typename U> void replace_if(C& c, F f, U u) { (ALL(c), f, u); }
template<typename C> void reverse(C& c) { reverse(ALL(c)); }
template<typename C> void sort(C& c) { sort(ALL(c)); }
template<typename C, typename Pred> void sort(C& c, Pred p) { sort(ALL(c), p); }
#pragma endregion

// 定数
#pragma region CONST_VAL
constexpr int PI = (2*acos(0.0));
constexpr int EPS = (1e-9);
constexpr int MOD = (int)(1e9+7);
constexpr int INF = 100000000;
#pragma endregion


int main()
{

    ll N;
    ll A, B;
    cin >> N;
    cin >> A >> B;
    vi X(N);
    rep(i, N) {
        cin >> X[i];
    }
    ll ans = 0;
    REP(i,1,N) {
        ans += min((X[i]-X[i-1])*A, B);
    }
    P(ans);

    return 0;
}



Measured memory_bytes: 640
import java.util.*;

class Main {
	public static int map[][];
	public static int t, n;
	public static int dx[] = {0,1,1,0,-1,-1};
	public static int dy[] = {1,1,0,-1,-1,0};

	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			t = sc.nextInt();
			n = sc.nextInt();
			if (t == 0 && n ==0) {
				break;
			}
			map = new int[1000][1000];
			for (int i = 0; i < 1000; i++) {
				for (int j = 0; j < 1000; j++) {
					map[i][j] = 1 << 30;
				}
			}
			for (int i = 0; i < n; i++) {
				map[sc.nextInt() + 500][sc.nextInt() + 500] = -1;
			}
			Queue<Integer[]> que = new ArrayDeque<Integer[]>();
			int nx = sc.nextInt() + 500;
			int ny = sc.nextInt() + 500;
			que.add(new Integer[]{nx, ny});
			map[nx][ny] = 0;
			while (que.size()!=0) {
				Integer[] now = que.poll();
				int x = now[0];
				int y = now[1];
				if (map[x][y] >= t) {
					continue;
				}
				for (int i = 0; i < 6; i++) {
					if (map[x + dx[i]][y + dy[i]] > map[x][y] + 1) {
						map[x + dx[i]][y + dy[i]] = map[x][y] + 1;
						que.add(new Integer[]{x + dx[i],y + dy[i]});
					}
				}
			}		

			int ans = 0;
			for (int i = 0; i < 1000; i++) {
				for (int j = 0; j < 1000; j++) {
					if (map[i][j] >= 0 && map[i][j] != 1 << 30) {
						ans++;
					}
				}
			}
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 310144
#include "bits/stdc++.h"
using namespace std;
#define long int64_t

struct Solver {
	void solve() {
		int X;
		cin >> X;

		int ans = 0;
		int angle = 0;
		do {
			ans += 1;
			angle += X;
		} while( angle%360 != 0 );
		cout << ans << endl;
	}
};

int main() {
	ios::sync_with_stdio( false );
	cout << fixed << setprecision( 10 );
	Solver().solve();
	return 0;
}


Measured memory_bytes: 3604
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct node{
  unsigned int key;
  struct node *next;
  struct node *prev;
};

typedef struct node * NodePointer;

NodePointer nil;

NodePointer listSearch(int key){
  NodePointer x;
  x = nil->next;
  while(x != nil && x->key != key){
    x = x->next;
  }
  return x;
}

void init(){
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  NodePointer cur=nil->next;
  int isf=1;
  while(1){
    if(cur == nil){
      break;
    }
    if(isf == 0){
      printf(" ");
    }
    printf("%d",cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}

void deleteNode(NodePointer t){
  if(t == nil){
    return;
  }
  t->prev->next = t->next;
  t->next->prev = t->prev;
}

void deleteFirst(){
  NodePointer t = nil->next;
  if(t == nil){
    return;
  }
  deleteNode(t);
}

void deleteLast(){
  NodePointer t = nil->prev;
  if(t == nil){
    return;
  }
  deleteNode(t); 
}

void delete(int key){
  NodePointer x;
  x = listSearch(key);
  deleteNode(x);
}

void insert(int key){
  NodePointer x;
  x = malloc(sizeof(struct node));
  x->key = key;

  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
  
}

int main(){
  int key,n,i;
  int size=0;
  char com[20];
  int np=0,nd=0;
  scanf("%d",&n);
  init();
  for(i=0; i < n; i++){
    scanf("%s%d",com,&key);
    if(com[0] == 'i'){
      insert(key);
      np++;
      size++;
    } else if(com[0] == 'd'){
      if(strlen(com) > 6){
	if(com[6] == 'F'){
	  deleteFirst();
	} else if(com[6] == 'L'){
	  deleteLast();
        }
      } else {
	delete(key);
	nd++; 
      }
      size--;
    }
  }

  printList();
  return 0;
}



Measured memory_bytes: 36064
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <cassert>
#include <fstream>
#include <iomanip>
#include <stack>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

const ll mod = 1e9 + 7;
const ll mmod = 998244353;

vector<ll> dx = {1, -1, 0, 0};
vector<ll> dy = {0, 0, 1, -1};

vector<vector<ll>> g;
vector<vector<ll>> par;
vector<vector<ll>> dp;
vector<ll> d;


int main() {
    
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    
    ll n;
    cin >> n;
    
    vector<ll> a(n + 1);
    for (int i = 0; i < n + 1; ++i)
    {
        cin >> a[i];
    }
    
    if (a[0] != 0 && a[0] != 1)
    {
        cout << -1 << endl;
        return 0;
    }
    if (a[0] == 1)
    {
        if (n != 0)
        {
            cout << -1 << endl;
        }
        else
        {
            cout << 1 << endl;
        }
        return 0;
    }
    
    vector<ll> r(n + 1);
    
    reverse(a.begin(), a.end());
    for (int i = 0; i < n + 1; ++i)
    {
        r[i] += a[i];
        if (i > 0)
        {
            r[i] += r[i - 1];
        }
    }
    reverse(r.begin(), r.end());
    reverse(a.begin(), a.end());
    
    ll cur = 1;
    ll ret = 0;
    for (int i = 0; i < n + 1; ++i)
    {
        cur = min(cur, r[i]);
        if (cur - a[i] < 0)
        {
            cout << -1 << endl;
            return 0;
        }
        ret += cur;
        cur = (cur - a[i]) * 2ll;
    }
    
    cout << ret << endl;
    
    return 0;
}

Measured memory_bytes: 4784
#!/usr/bin/env python3

import sys
sys.setrecursionlimit(300000)


def solve(N: int, M: int):
    ret = 0
    if N > 1:
        ret += N * (N - 1) // 2
    if M > 1:
        ret += M * (M - 1) // 2
    print(ret)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    solve(N, M)

if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
# 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>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
# include <random>
# include <chrono>
# include <cstdlib>
# include <tuple>
# include <array>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2147483647;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr double HDINF = 50000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define RALL(qpqpq)           (qpqpq).rbegin(),(qpqpq).rend()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define RFOR(i,tptpt,ypypy)  for(LL i=(tptpt);i>=(ypypy);i--)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

int n, a[101010];

int main() {
	cin >> n;
	int ans = 0;
	REP(i, n) {
		cin >> a[i];
		while (a[i] % 2 == 0) {
			ans++;
			a[i] /= 2;
		}
	}
	cout << ans << endl;
}

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

using namespace std;
using LL = long long;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e19;
const int MOD = (int)1e9 + 7;

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

    int a[3], b[3];
    REP(i, 3) cin >> a[i] >> b[i];

    vector<int> num(4);
    REP(i, 3) num[a[i]-1]++, num[b[i]-1]++;

    sort(all(num));
    if(num[0] == 1 && num[1] == 1 && num[2] == 2 & num[3] == 2){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

N = int(input())
answer = 0
len_div = len(make_divisors(N))

if len_div % 2 == 0:
    A_len = len(str(make_divisors(N)[len_div // 2 - 1]))
    B_len = len(str(make_divisors(N)[len_div // 2]))
    if A_len <= B_len:
        answer = B_len
    else:
        answer = A_len
else:
    answer = len(str(make_divisors(N)[len_div // 2]))
print(answer)



Measured memory_bytes: 3188
'use strict'
function main(input) {
  input = input.trim().split(' ')
  const a = Number(input.shift())
  const b = Number(input.shift())
  const c = Number(input.shift())
  const x = Number(input.shift())
  const y = Number(input.shift())

  let ans = 0
  
  const both = Math.min(x, y);
  ans += both * ((a + b < c * 2) ? (a + b) : c * 2)

  if (y === both) {
    ans += (x - both) * ((a > c * 2) ? c * 2 : a)
  } else {
    ans += (y - both) * ((b > c * 2) ? c * 2 : b)
  }

  console.log(ans)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

    using namespace std;
    typedef long long ll;
    # define M_PI  3.14159265358979323846

    void solve(){
        int n;
        cin>>n;
        string s;
        cin>>s;
        int total=1;
        for(int i=1;i<n;i++){
            if(s[i]!=s[i-1])
                total++;
        }
        cout<<total;
    }
    int main(){
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        cout<<fixed;
        cout<<setprecision(10);
        int t=1;
//        cin>>t;
        for(int i=1;i<=t;i++){
            solve();
        }
        return 0;
    }


Measured memory_bytes: 3752
#include<bits/stdc++.h>
using namespace std;
const int MAX = 1e9+5;
signed main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n,a;cin>>n;
  set<int> s;
  for(int i=0;i<n;i++){
    cin>>a;
    if(s.find(a)==s.end()){s.insert(a);}
    else{s.erase(a);}
  }
  cout<<s.size();
}

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

int main(){
    int n;
    cin >> n;
    int tmp;
    int cnt = 0;
    for (int i = 0; i<n; i++){
        cin >> tmp;
        if (tmp % 2 == 1) cnt++;
    }
    if (cnt % 2 == 0) cout << "YES" << endl;
    else cout << "NO" << endl;
}


Measured memory_bytes: 256
while True:
    a,b = map(int,input().split())
    if a == 0 and b == 0: break
    count = 0
    for i in range(a):
        count = i
        for j in range(b):
            if count % 2 == 0:
                print('#',end="")
            else:
                print('.',end="")
            count = count + 1
        print()
    print()
            


Measured memory_bytes: 7000
#include <bits/stdc++.h>
using namespace std;
int main() {
	string S;
	cin >> S;
	int ans = 1;
	char tmp = ' ';
	for(int i = 0; i < 4; i++) {
		if(tmp == S[i]) {
			ans++;
		} else {
			ans = 1;
		}
		tmp = S[i];
		if(ans >= 3) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(){
    int n;
    string a,b;
    cin>>n>>a>>b;
    for(int i=0;i<n;i++){
        cout<<a.at(i)<<b.at(i);
    }
    
    return 0;
}

Measured memory_bytes: 256
import java.util.*;


public class Main {
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int n = sc.nextInt();
			int [] data = new int[n];
			for(int i = 0; i < n;i++){
				data[i] = sc.nextInt();
			}
			long min = 2;
			long max = 2;
			boolean flg = true;
			for(int i = n-1; i >= 0; i--){
				int now = data[i];
				long tempmin = now * (min / now + (min % now == 0 ? 0 : 1));
				long tempmax = now * (max / now + 1) - 1;
				if(! (min <= tempmin / now * now && tempmin / now * now <= max)){
					flg = false;
					break;
				}
				if(!(min <= tempmax / now * now && tempmax / now * now <= max)){
					flg = false;
					break;
				}
				min = tempmin;
				max = tempmax;
			}
			if(flg){
				System.out.println(min + " " + max);
			}
			else{
				System.out.println(-1);
			}
			
		}
	}



	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

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

}


Measured memory_bytes: 50856
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const int inf=1e9+7;
const ll INF=1e18;

vector<vector<pair<ll,ll>>> edge(200050);
vll d(100050,INF);

void dijkstra(ll s){
    priority_queue<pair<ll,ll>,vector<pair<ll,ll>>,greater<pair<ll,ll>>> q;
    d[s]=0;
    q.push(mp(0,s));
    while(q.size()){
        auto p=q.top();q.pop();
        auto v=p.second;
        if(d[v]<p.first)continue;
        for(auto e:edge[v]){
            if(d[e.first]>d[v]+e.second){
                d[e.first]=d[v]+e.second;
                q.push(mp(d[e.first],e.first));
            }
        }
    }
    return;
}

int main(){
    int n,m;cin>>n>>m;
    vll a(m),b(m);
    rep(i,m){
        cin>>a[i]>>b[i];
        edge[a[i]].push_back(mp(b[i],1));
        edge[b[i]].push_back(mp(a[i],1));
    }
    dijkstra((ll)1);
    vin ans(n+1,inf);
    rep(i,m){
        if(d[a[i]]-d[b[i]]==1)ans[a[i]]=b[i];
        else if(d[b[i]]-d[a[i]]==1)ans[b[i]]=a[i];
    }
    rep2(i,1,n){
        if(ans[i+1]==inf){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    rep2(i,1,n)cout<<ans[i+1]<<endl;
}

Measured memory_bytes: 24228
#include<bits/stdc++.h>
 
using namespace std;
 
typedef vector<int> vi;
 
#define looplr(i,l,r) for(int i=l;i<=r;++i)
#define pb push_back
 
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
    //fastio;
 
 
    int command,x,a,b,n,query;
    scanf("%d %d",&x,&query);
    vi v[x];
    while(query--){
        scanf("%d",&command);
 
        if(command==0) {
            scanf("%d %d",&a,&b);
            v[a].pb(b);
 
        }
        else if(command==1) {
            scanf("%d",&a);
            if(v[a].size()==0) cout << endl;
            else{
            cout << v[a][0];
            looplr(i,1,v[a].size()-1) cout <<" " << v[a][i];
 
            cout << endl;
            }
            }
        else if (command==2){
                scanf("%d",&a);
                v[a].clear();
            }
        }
 
 
    //cout << clock()*1.0/ CLOCKS_PER_SEC << endl;
    return 0;
}


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

#define db double
const db pi = acos(-1);

db a,b,x;

signed main()
{
	cin >> a >> b >> x;
	x /= a;
	db ans = 0;
	if(a*b/2 <  x) {
		ans = pi/2 - atan2((a*a),2*(a*b-x));
	} else {
	//	printf("%.3lf\n",b*b/(2*x));
		ans = atan2(b*b,2*x);
	}
	ans = ans/pi*180;
	printf("%.8lf",ans);
	return 0;
}

Measured memory_bytes: 384
#include"bits/stdc++.h"

using namespace std;

int main() {
	int N;
	cin >> N;
	vector<string> S(N+1);

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

	for (int i = 0; i < N - 1; i++) {
		if (S[i].back() != S[i+1].front()) {
			cout << "No" << endl;
			return 0;
		}
	}

	for (int i = 0; i < N; i++) {
		for (int j = i + 1; j < N; j++) {
			if (S[i] == S[j]) {
				cout << "No" << endl;
				return 0;
			}
		}
	}

	cout << "Yes" << endl;
	return 0;
}

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

using ll = long long;
#define int long long

#define LOG(variable) cout << #variable":\t" << (variable) << endl
#define LOGCON(i, container) for(int (i) = 0; (i) < (container).size(); ++(i)) cout << (i) << ":\t" << (container)[(i)] << endl
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, r, n) for(int i = (n); i >= (r); --i) // from n to r
#define REPOBJ(itr, obj) for(auto itr = (obj).begin(); itr != (obj).end() ; ++itr)
#define REPROBJ(itr, obj) for(auto itr = (obj).rbegin(), e = (obj).rend(); itr != e; ++itr)
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%MOD+MOD)%MOD){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD-a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= MOD; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime MOD
  mint inv() const { return pow(MOD-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
int in() {int x; cin>>x; return x;}
string stin() {string s; cin>>s; return s;}
/***** MAIN *****/
signed main() {
  int a = in();
  int b = in();
  int c = in();
  COUTS(c);
  COUTS(a);
  COUTB(b);
  
  return 0;
}
/***** MAIN *****/


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include<iomanip>
using namespace std;
#define pi acos(-1)
int main()
{
  long double a,b,h,m;
  cin>>a>>b>>h>>m;
  long double thm=(long double)m/60*2*pi;
  long double thh=(60*(long double)h+m)/720*2*pi;
  long double hx=a*cos(thh),hy=a*sin(thh);
  long double mx=b*cos(thm),my=b*sin(thm);
  long double dx=hx-mx,dy=hy-my;
  cout<<setprecision(15)<<sqrt(dx*dx+dy*dy);
  return 0;


}


   


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

int main(void){
  int i;
  string o, e;
  cin >> o >> e;
  for(i = 0; i < (int)(o.size()); i++){
    cout << o[i];
    if(e[i] != '\0') cout << e[i];
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <fstream>
using namespace std;
int main(){
    int n,a,b,s=0,i,j,s2=0;
    cin>>n>>a>>b;
    for(i=1; i<=n; ++i){
        j=i;s=0;
        while(j!=0){
            s+=j%10;
            j/=10;
        }
        if(s>=a && s<=b)
            s2+=i;
    }
    cout<<s2;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1<<30;
vector<string>in,s;
bool f(int a,int b){
	bool h=true;
	rep(i,2)rep(j,2)if(in[a+i][b+j]!=s[i][j])h=false;
	return h;
}
int main(){
	int n,m;
	cin>>n>>m;
	char q[3]={'J','O','I'};
	in=vector<string>(n);
	s=vector<string>(2);
	rep(i,n)cin>>in[i];
	rep(i,2)cin>>s[i];
	int co=0;
	rep(i,n-1)rep(j,m-1)co+=f(i,j);
	int out=co;
	rep(i,n)rep(j,m)rep(k,3)if(in[i][j]!=q[k]){
		int t=co;
		int w[4]={max(0,i-1),max(0,j-1),min(n-1,i+1),min(m-1,j+1)};
		loop(I,w[0],w[2])loop(J,w[1],w[3])t-=f(I,J);
		char C=in[i][j];
		in[i][j]=q[k];
		loop(I,w[0],w[2])loop(J,w[1],w[3])t+=f(I,J);
		in[i][j]=C;
		out=max(out,t);
	}
	cout<<out<<endl;
}

Measured memory_bytes: 2064
import sys
from collections import deque, defaultdict, Counter
from itertools import accumulate, product, permutations, combinations
from operator import itemgetter
from bisect import bisect_left, bisect_right
from heapq import heappop, heappush
from math import ceil, floor, sqrt, gcd, inf
from copy import deepcopy
import numpy as np
import scipy as sp

INF = inf
MOD = 1000000007

n = int(input())
A = [[int(i) for i in input().split()]for j in range(n)]    # nは行数

tmp = 0
res = 0

x = np.median(np.array(A), axis=0)
if n % 2 == 0:
    res = int((x[1] - x[0]) * 2 + 1)
else:
    res = int(x[1] - x[0] + 1)

print(res)


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

using LL = long long;
const LL M = 1e9+7;

LL combination(LL n, LL r) {
  if(n < r) return 0;
  if(n < 0 || r < 0) return 0;
  static std::vector<LL> fact{1, 1}, inv{1, 1}, finv{1, 1};
  for(LL i = fact.size(); i <= n; ++i) {
    fact.emplace_back(fact.back() * i % M);
    inv.emplace_back(inv.at(M % i) * (M - M / i) % M);
    finv.emplace_back(finv.back() * inv.back() % M);
  }
  return (fact[n] * finv[n - r] % M) * finv[r] % M;
}

LL power(LL m, LL n) {
  if(!n) return 1;
  return (n & 1) ? (power(m, n - 1) * m % M) : power(m * m % M, n >> 1);
}

int main() {
  int K; string S;
  cin >> K >> S;
  int N = K + S.size();
  LL ans = 0;
  for(int i=S.size(); i<=N; ++i) (ans += power(25,N-i) * combination(N,i) % M) %= M;
  cout << ans << endl;
}


Measured memory_bytes: 51288
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using loop = int;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(loop (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(loop (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(loop (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(loop (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    string s; cin >> s;
    for (int i = 0; i < s.length(); i += 2)cout << s[i];
    cout << "\n";
}

Measured memory_bytes: 592
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n = sc.nextInt();
		long mod=1000000007;
		long[][][][] dp=new long[n+1][4][4][4];
		dp[0][3][3][3]=1;
		for(int i = 1; i<=n; i++){
			for(int j=0; j<4; j++){
				for(int k=0; k<4; k++){
					for(int l =0; l<4; l++){
						if(dp[i-1][j][k][l]==0){
							continue;
						}
						for(int u=0; u<4; u++){
							if(u==2 && k==0 && l==1){
								continue;
							}else if(u==2 && k==1 && l==0){
								continue;
							}else if(u==1 && l==2 && k==0){
								continue;
							}else if(u==2 && j==0 && k==1){
								continue;
							}else if(u==2 && l==1 && j==0){
								continue;
							}
							dp[i][k][l][u]+=dp[i-1][j][k][l];
							dp[i][k][l][u]%=mod;
						}
					}
				}
			}
		}
		long ans=0;
		for(int i = 0; i<4; i++){
			for(int j = 0; j<4; j++){
				for(int k = 0; k<4; k++){
					ans+=dp[n][i][j][k];
					ans%=mod;
				}
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 22868
#include<iostream>
#include<string>
#include<vector>
#include<list>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<set>
#include<map>
#include<queue>
#include<cstring>
#include<sstream>
using namespace std;

typedef long long ll;

int main() {
  ll N,A,B; cin >> N >> A >> B;
  if ( A > B ) {
    cout << 0 << endl;
    return 0;
  }
  if ( N == 1 ) {
    if ( A==B ) cout << 1 << endl;
    else cout << 0 << endl;
    return 0;
  } else if ( N == 2 ) {
    cout << 1 << endl;
    return 0;
  } else if ( N == 3 ) {
    cout << B-A+1 << endl;
    return 0;
  }

  ll X = N-2;
  ll S = A+B;
  S += X*A;
  //  cout << S << endl;
  ll E = A+B;
  E += X*B;
  //  cout << E << endl;
  cout << E-S+1 << endl;
  return 0;
}


Measured memory_bytes: 256
if __name__ == "__main__":
    n, m = (int(x) for x in input().split())

    node___neighs = {x: set() for x in range(1, n + 1)}

    for _ in range(m):
        n1,n2 = (int(x) for x in input().split())
        node___neighs[n1].add(n2)
        node___neighs[n2].add(n1)

    node___comp = {}

    curr_comp = 1
    comp___size = {}
    for node in range(1, n+1):
        if node___comp.get(node, False):
            continue
        stack = [node]
        curr_size = 1
        node___comp[node] = curr_comp

        while stack:
            curr_node = stack.pop()
            for neigh in node___neighs[curr_node]:
                if node___comp.get(neigh, False):
                    continue
                node___comp[neigh] = curr_comp
                curr_size += 1
                stack.append(neigh)
            
        comp___size[curr_comp] = curr_size
        curr_comp += 1
    print(max(comp___size.values()))

Measured memory_bytes: 177700
use std::io::*;
use std::str::FromStr;
use std::cmp;
use std::collections::HashMap;
use std::collections::HashSet;
use std::char;
use std::cmp::{min, max};
use itertools::Itertools;
use std::ops::{Add, AddAssign};
use num_integer::{Integer, gcd, lcm};
use std::collections::VecDeque;
use smallvec::alloc::collections::LinkedList;
use regex::internal::Char;

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")
}

fn read_tuple2<T: FromStr, S: FromStr>() -> (T, S) {
    let a = read();
    let b = read();
    (a, b)
}

fn read_tuple3<T: FromStr, S: FromStr, R: FromStr>() -> (T, S, R) {
    let a = read();
    let b = read();
    let c = read();
    (a, b, c)
}

fn lower_bound<T: Copy, F>(v: &Vec<T>, f: F) -> Option<usize> where
    F: Fn(T) -> bool
{
    let mut left = 0;
    let mut right = v.len() - 1;
    if !f(v[left]) {
        return None;
    }
    if f(v[right]) {
        return Some(right);
    }
    loop {
        if right - left == 1 {
            return Some(left);
        }
        let mid = (left + right) / 2;
        if f(v[mid]) {
            left = mid;
        } else {
            right = mid;
        }
    }
}

fn main() {
    let n:u32 = read();
    let a = {
        let mut a:Vec<u64> = (0..n).map(|_|read()).collect();
        a.sort_by(|a, b| b.cmp(a));
        a
    };
    let mut ans = 0;
    for i in 0..n {
        ans += match i {
            0 => 0,
            1 => a[0],
            i => a[(i/2) as usize]
        };
    }
    println!("{}", ans);


}



Measured memory_bytes: 4284
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define endl '\n'
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int,int> PI;

int main(int argc, char *argv[])
{
  int n,m;
  cin >> n >> m;
  string a;
  rep(i,n){
    char ch;
    cin >> ch;
    a += ch;
  }

  string g1,g2;
  rep(j,m){
    int t;
    cin >> t;
    rep(jj,t){
      g1 += char('0'+j%2);
      g2 += char('1'-j%2);
    }
  }
  
  queue<pair<int,string> > q;
  set<string> app;
  q.push(mp(0,a));
  while(!q.empty()){
    auto cv=q.front().S;
    int cc =q.front().F;
    q.pop();
    if(app.count(cv)) continue;
    app.insert(cv);
    if(cv == g1 || cv == g2){
      cout << cc << endl;
      return 0;
    }
    
    rep(i,n-1){
      swap(cv[i],cv[i+1]);
      if(!app.count(cv))
        q.push(mp(cc+1,cv));
      swap(cv[i],cv[i+1]);      
    }
  }
  
  return 0;
}

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

int main() {
	int n, x; cin >> n >> x;
	vector<int> m(n); 
	int ans = 0;
	for (int i = 0; i < n; i++) {
		cin >> m[i];
		ans++;
		x -= m[i];
	}
	sort(m.begin(), m.end());

	ans += x / m[0];

	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;
typedef long long ll;
using P = pair<int,int>;
const int MOD = 1000000007;

int main() {
    int n;
    cin>>n;
    cout<<n/3<<endl;
} 


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int a[5];
	char s[5];
	int i;
	while(scanf("%s",s)!=EOF)
	{
		for(i=0;i<4;i++){
			a[i]=s[i]-'0';
		}
		if(a[0]+a[1]+a[2]+a[3]==7)printf("%d+%d+%d+%d=7\n",a[0],a[1],a[2],a[3]);
		else if(a[0]+a[1]+a[2]-a[3]==7)printf("%d+%d+%d-%d=7\n",a[0],a[1],a[2],a[3]);
		else if(a[0]+a[1]-a[2]+a[3]==7)printf("%d+%d-%d+%d=7\n",a[0],a[1],a[2],a[3]);
		else if(a[0]-a[1]+a[2]+a[3]==7)printf("%d-%d+%d+%d=7\n",a[0],a[1],a[2],a[3]);
		else if(a[0]+a[1]-a[2]-a[3]==7)printf("%d+%d-%d-%d=7\n",a[0],a[1],a[2],a[3]);
		else if(a[0]-a[1]+a[2]-a[3]==7)printf("%d-%d+%d-%d=7\n",a[0],a[1],a[2],a[3]);
		else if(a[0]-a[1]-a[2]+a[3]==7)printf("%d-%d-%d+%d=7\n",a[0],a[1],a[2],a[3]);
		else if(a[0]-a[1]-a[2]-a[3]==7)printf("%d-%d-%d-%d=7\n",a[0],a[1],a[2],a[3]);
	}
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(void){
  	int N;	cin >> N;
  	if(N == 1)	cout << "Hello World" << endl;
  	else{
		int A, B;	cin >> A >> B;
      	cout << A + B << endl;
    }
    return 0;
}

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

int main(){
  string s;
  cin >> s;
  vector<int> A(4);
  rep(i, 4){
    A.at(i) = s.at(i) - '0';
  }
  if(A.at(0) + A.at(1) + A.at(2) + A.at(3) == 7){
    cout << s.at(0) << '+' << s.at(1) << '+' << s.at(2) << '+' << s.at(3)<< "=7" << endl;
    return 0;
  }
  else if(A.at(0) + A.at(1) + A.at(2) - A.at(3) == 7){
    cout << s.at(0) << '+' << s.at(1) << '+' << s.at(2) << '-' << s.at(3)<< "=7" << endl;
    return 0;
  }
  else if(A.at(0) + A.at(1) - A.at(2) + A.at(3) == 7){
    cout << s.at(0) << '+' << s.at(1) << '-' << s.at(2) << '+' << s.at(3)<< "=7" << endl;
    return 0;
  }
  else if(A.at(0) + A.at(1) - A.at(2) - A.at(3) == 7){
    cout << s.at(0) << '+' << s.at(1) << '-' << s.at(2) << '-' << s.at(3)<< "=7" << endl;
    return 0;
  }
  else if(A.at(0) - A.at(1) + A.at(2) + A.at(3) == 7){
    cout << s.at(0) << '-' << s.at(1) << '+' << s.at(2) << '+' << s.at(3)<< "=7" << endl;
    return 0;
  }
  else if(A.at(0) - A.at(1) + A.at(2) - A.at(3) == 7){
    cout << s.at(0) << '-' << s.at(1) << '+' << s.at(2) << '-' << s.at(3)<< "=7" << endl;
    return 0;
  }
  else if(A.at(0) - A.at(1) - A.at(2) + A.at(3) == 7){
    cout << s.at(0) << '-' << s.at(1) << '-' << s.at(2) << '+' << s.at(3)<< "=7" << endl;
    return 0;
  }
  else if(A.at(0) - A.at(1) - A.at(2) - A.at(3) == 7){
    cout << s.at(0) << '-' << s.at(1) << '-' << s.at(2) << '-' << s.at(3)<< "=7" << endl;
    return 0;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int N = 1000000;
const ll mod = 1000000007;
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int h, w;
char a[10][10];
int d[10][10];

int bfs(){
    queue<P> que;
    rep(i, h){
        rep(j, w){
            d[i][j] = 100000;
        }
    }
    que.push(P(0, 0));
    d[0][0] = 0;

    while(que.size()){
        P p = que.front(); que.pop();

        if(p.first == h - 1 && p.second == w - 1)break;
        rep(i, 4){
            int nx = p.first + dx[i];
            int ny = p.second + dy[i];

            if(0 <= nx && nx < h && 0 <= ny && ny < w && 
            a[nx][ny] != '.' && d[nx][ny] == 100000){
                que.push(P(nx, ny));
                d[nx][ny] = d[p.first][p.second] + 1;
                //cout << nx << " " << ny << endl;
            }
        }
    }
    return d[h - 1][w - 1];
}

int main(){
    cin >> h >> w;
    int count = 0;
    rep(i, h){
        rep(j, w){
            cin >> a[i][j];
            if(a[i][j] == '#')count++;
        }
    }
    int res = bfs();
    //cout << count << " " << res << endl;
    if(h + w - 1 == count)cout << "Possible" << endl;
    else cout << "Impossible" << endl;    
}

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int x, a, b;

int main() {
	cin >> x >> a >> b;
	
	cout << ((x - a) % b) << endl;
	
	return 0;
}


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

using namespace std;

#define Rep(i,a,b)  for (int i=(a);i<(b);i++)
#define rep(i,n)    for (int i=0;i<(n);i++)
#define all(x)      (x).begin(), (x).end()

#define ll long long

int main()
{
	int n, k;
	string s;
	cin >> n;
	cin >> s;
	cin >> k;
	rep (i, s.length()) {
		if (s[i] != s[k-1])
			s[i] = '*';
	}
	cout << s << endl;
}



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

#define REP(i,m,n) for(int i=(m); i<(int)(n); i++)
#define RREP(i,m,n) for(int i=(int)(n-1); i>=m; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aut(r,v) __typeof(v) r = (v)
#define each(it,o) for(aut(it,(o).begin()); it!=(o).end(); ++it)
#define reach(it,o) for(aut(it,(o).rbegin()); it!=(o).rend(); ++it)
#define fi first
#define se second
#define debug(...) {cerr<<"[L"<<__LINE__<<"] "; _debug(__VA_ARGS__);}

template<typename T1, typename T2> ostream& operator<<(ostream& o, const pair<T1, T2>& p)
{return o<<"("<<p.first<<", "<<p.second<<")";}
template<typename T>string join(const vector<T>&v, string del=", ")
{stringstream s;rep(i,v.size())s<<del<<v[i];return s.str().substr(del.size());}
template<typename T>ostream& operator<<(ostream& o, const vector<T>&v)
{if(v.size())o<<"["<<join(v)<<"]";return o;}
template<typename T>ostream& operator<<(ostream& o, const vector<vector<T> >&vv)
{int l=vv.size();if(l){o<<endl;rep(i,l){o<<(i==0?"[ ":",\n  ")<<vv[i]<<(i==l-1?" ]":"");}}return o;}
template<typename T>ostream& operator<<(ostream& o, const set<T>& st)
{vector<T> v(st.begin(),st.end());o<<"{ "<<join(v)<<" }";return o;}
template<typename T1, typename T2>ostream& operator<<(ostream& o, const map<T1, T2>& m)
{each(p,m){o<<(p==m.begin()?"{ ":",\n  ")<<*p<<(p==--m.end()?" }":"");}return o;}
inline void _debug(){cerr<<endl;}
template<class First, class... Rest>
void _debug(const First& first, const Rest&... rest){cerr<<first<<" ";_debug(rest...);}

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

const double PI = (1*acos(0.0));
const double EPS = 1e-9;
const ll INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const ll mod = 1e9 + 7;

inline void finput(string filename) {
    freopen(filename.c_str(), "r", stdin);
}

int main(){
    ios_base::sync_with_stdio(0);
    // finput("./input");

    int n; cin >> n;
    vi a(n+1);
    rep(i,n) cin >> a[i+1];

    vi b(n+1);
    vi ans;
    RREP(i,1,n+1){
        if(b[i] % 2 != a[i]){
            ans.push_back(i);
            int x = 1;
            while(i >= x*x){
                if(i % x == 0) b[x] = (b[x]+1) % 2;
                if(i % x == 0 && i != x*x) b[i/x] = (b[i/x]+1) % 2;
                x++;
            }
        }
    }
    reverse(all(ans));
    cout << ans.size() << endl;
    if(ans.size()) cout << join(ans, " ") << endl;
    return 0;
}

Measured memory_bytes: 7796
N = int(input())
A = [int(i) for i in input().split()]

ans = 0
sum = 0
right = 0
for left in range(N):
    while right < N and sum ^ A[right] == sum+A[right]:
        sum += A[right]
        right += 1
    ans += right-left
    # if right == left:
    #     right += 1
    # sum = A[left]
    # else:
    sum -= A[left]
print(ans)


Measured memory_bytes: 23560
#define X first
#define Y second
#include<bits/stdc++.h>
using namespace std;
typedef pair <int, int > ii;
using ll = long long;
const int MAX=3005,inf=0x3f3f3f3f,mod=1e9+7;
int a[MAX],b[MAX];
ll f[MAX][MAX];
int n,m;
char s[MAX];
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //freopen("bao.inp","r",stdin);
    //freopen("ESCAPE.out","w",stdout);
    int T;
    cin>>n>>m;
    cin>>s+1;
    for(int i=1;i<=n;i++) {
            b[i]=i;
        a[i]=a[i-1]+s[i]-'0';
    }


    for(int i=1,x,y;i<=m;i++){
        cin>>x>>y;
        b[x]=max(b[x],y);
    }
    f[0][0]=1;
    for(int i=1,now;i<=n;i++){
        b[i]=max(b[i],b[i-1]);
        if(a[b[i]]-0 < b[i]-i+1 )  f[i][0]=f[i-1][0];
        for(int j=1;j<=i;j++){
            if(a[b[i]]-j < b[i]-i+1 ) f[i][j]=f[i-1][j];
            if(a[b[i]]-j >= 0 ) f[i][j]+=f[i-1][j-1];
            if(f[i][j]>=mod) f[i][j]-=mod;
            //cout<<i<<' '<<j<<' '<<f[i][j]<<'\n';
        }
    }
    ll ans=0;
    for(int i=0;i<=n;i++){
        ans+=f[n][i];if(ans>=mod) ans-=mod;
    }
    cout<<ans;
}


Measured memory_bytes: 49836
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
 
int main()
{
  int X, A, B; cin >> X >> A >> B;
  if(A >= B) puts("delicious");
  else if(A+X>=B) puts("safe");
  else puts("dangerous");
  return 0;
}

Measured memory_bytes: 256