akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf = 1012345678;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

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

int ans;

int main(){
  int M,D;
  cin >> M >> D;
  for(int i = 1; i <= M; i++){
    for(int j = 11; j <= D; j++){
      int d1 = (j / 10);
      int d2 = (j % 10);
      int d = d1  * d2 ;
      // cout << d << endl;
      if(d == i && d1 > 1 && d2 > 1) {
	ans++;
	// cout << d << endl;

      }
      
    }
  }
  cout << ans << endl;
}




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

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var a = cin.ReadInt;
            var b = cin.ReadInt;
            string String="";
            if(a <= b) String = string.Concat(Enumerable.Repeat(a.ToString(), b));
            else String = string.Concat(Enumerable.Repeat(b.ToString(), a));
            WriteLine(String);

            // 解答はココに書く

        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}

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

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,s,n) for(int i=s;i<n;i++)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define int long long
using namespace std;
using P=pair<int,int>;
using Graph=vector<vector<int>>;
using ll=long long;


ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}
bool root(string s){
    int n=s.length();
    if(n==2){
        if(s[0]==s[1]){
            return true;
        }
        else return false;
    }
    if(n==3){
        if(s[0]==s[2]){
            return true;
        }
        else return false;
    }
 
    return false;
}
 
 
//深さ優先
vector<int> seen;
vector<ll> h;
 
//普通の深さ優先探索seenを返す感じ
void dfs(const Graph &G,int v){

    seen[v] = 0; //v探索済み
 
    P good=make_pair(v,h[v]);
    for(auto next_v :G[v]){
        if(seen[next_v]!=-1) continue;//もう探索していた
        if(h[next_v]>good.second){
            good=make_pair(next_v,h[next_v]);
        }
        dfs(G,next_v);
    }
 
    if(!(h[v]==good.second && v==good.first)){
        seen[good.first]=1;
    }
}


int n;

void dfs(string s, char mx){
    if(s.length()==n){
        cout<<s<<endl;
    }else{
        for(char c='a';c<=mx;c++){
            dfs(s+c,((c==mx) ? (char)(mx+1) : mx));
        }
    }
}


int mod = 998244353;
int m,k;

int dfs(int cnt,int pred, int sk){
    int sum=0;
    if(cnt==n){
        return 1LL;
    }
    for(int i=1;i<=m;i++){
        if(i==pred){
            if(sk+1<=k){
                sum+=dfs(cnt+1,i,sk+1)%mod;
            }
        }else{
            sum+=dfs(cnt+1,i,sk)%mod;
        }
    }

    return sum;
}

signed main(){ 
    int n,k; cin>>n>>k;
    int h[n];
    rep(i,0,n) cin>>h[i];

    sort(h,h+n);

    int ans=h[k-1]-h[0];

    for(int i=1;i<=n-k;i++){
        ans=min(ans,h[k-1+i]-h[i]);
    }

    cout<<ans<<endl;
    
}  

Measured memory_bytes: 1024
function Main(input) {
    input = input.split(" ");
    
    var P = parseInt(input[0], 10);
    var Q = parseInt(input[1], 10);
     var R = parseInt(input[2], 10);
   
    var T1 = P+Q;	
    var T2 = Q+R;
    var T3 = R+P;
    
    if ( T1 >= T2){if (T2 >= T3){console.log(T3);}
                                  else{console.log(T2);}
                       }
                    else if(T1>=T3){console.log(T3);}
                                   else{console.log(T1);}		                    


                         
                  
                         
    



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


Measured memory_bytes: 7372
// {{{ Template for Competitive Programming
// -std=c++14 -Wall -g -fsanitize=undefined -D_GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>

using namespace std;
using boost::irange;

using vint = vector<int>;
using pint = pair<int, int>;

#define int long long
#define FOR(i, a, b)  for (int(i) = (a); (i) < (b); ++(i))
#define CFOR(i, a, b) for (int(i) = (a); (i) <= (b); ++(i))
#define RFOR(i, a, b) for (int(i) = (a); (i) >= (b); --(i))
#define rep(i, n) FOR((i), 0, (n))
#define crep(i, n) CFOR((i), 0, (n))
#define rrep(i, n) RFOR((i), (n), 0)
#define ALL(x) (x).begin(), (x).end()
#define SUM(x) accumulate(ALL(x), 0)

template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline void debug(T a) { cout << "[ "; for (const auto e : a) { cout << e << ", "; } cout << "]" << endl; }

int ceil(int a, int b) { return (a + (b - 1)) / b; }

const int INF = 1'010'000'000'000'000'017LL;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
// }}}

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

	rep (i, n - 1) {
		if (s[i] == s[i + 1]) {
			s.erase(i, 1);
			n--;
			i--;
		}
	}
	cout << n << endl;
}



Measured memory_bytes: 640
#include<stdio.h>
#include<string.h>
int main(void){
char s[11];
  scanf("%s",&s);
  char t[12];
  scanf("%s",&t);
  //printf("%d\n",strlen(s));
  for(int i=0;i<strlen(s);i++){
   // printf("%c %c\n",s[i],t[i]);
    	if(s[i]==t[i])continue;
    else {
          printf("No");
             return 0;
                      }
  }
  printf("Yes");
  return 0;
}

Measured memory_bytes: 1736
#include <bits/stdc++.h>
using namespace std;
#define INF 100000000

int main(){
    int n, m, i, j;
    cin >> n >> m;
    vector<int> dp(n+1, -INF), a(m);
    int c[10] = {0,2,5,5,4,5,6,3,7,6};
    for(i=0; i<m; i++){
        cin >> a[i];
    }
    sort(a.begin(), a.end(), greater<int>());
    dp[0] = 0;
    for(i=0; i<n; i++){
        if(dp[i] == -INF) continue;
        for(j=0; j<m; j++){
            if(i+c[a[j]] > n) continue;
            dp[i+c[a[j]]] = max(dp[i+c[a[j]]], dp[i]+1);
        }
    }
    i = n;
    while(i > 0){
        for(j=0; j<m; j++){
            if(i-c[a[j]] < 0) continue;
            if(dp[i] - dp[i-c[a[j]]] == 1){
                cout << a[j];
                i -= c[a[j]];
                j = m;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cctype>
using namespace std;
int main() {
    char c;
    int t[26];
    for (int i = 0; i < 26; i++) {
        t[i] = 0;
    }
    while (cin >> c) {
        if (isalpha(c)) {
            if (isupper(c)) {
                t[c - 'A'] += 1;
            }
            else {
                t[c - 'a'] += 1;
            }
        }
    }
    for (int i = 0; i < 26; i++) {
        cout << char('a' + i) << " : " << t[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 3116
#include <stdio.h>

int main (){
	int x,a,b,x1,x2;
	
	scanf ("%d %d %d", &x,&a,&b);
	
	x>a ? x1=x-a : x1=a-x;
	x>b ? x2=x-b : x2=b-x;
	
	if (x1<x2){
		printf ("A");
	}
	else {
		printf ("B");
	}
	
	return 0;
}

Measured memory_bytes: 3124
// -----------------------------------------------
// Framework <https://github.com/vain0x/procon>
//
// See the bottom of file for solution.
// -----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

struct Solver {
    N: usize,
    x: usize,
    y: usize,
    z: usize,
    dp: Vec<Vec<Vec<Option<f64>>>>,
}

impl Solver {
    fn calc(&mut self, x: usize, y: usize, z: usize) -> f64 {
        let s = x + y + z;
        if s == 0 {
            return 0.0;
        }

        if let Some(e) = self.dp[x][y][z] {
            return e;
        }

        let mut e = 0.0_f64;
        e += self.N as f64;
        if x >= 1 {
            e += x as f64 * self.calc(x - 1, y, z);
        }
        if y >= 1 {
            e += y as f64 * self.calc(x + 1, y - 1, z);
        }
        if z >= 1 {
            e += z as f64 * self.calc(x, y + 1, z - 1);
        }
        e /= s as f64;

        self.dp[x][y][z] = Some(e);
        e
    }

    fn solve(&mut self) {
        let x = self.x;
        let y = self.y;
        let z = self.z;
        let e = self.calc(x, y, z);
        println!("{}", e)
    }
}

fn main() {
    let N = read!(usize);
    let A = read![[usize]];

    let mut x = 0;
    let mut y = 0;
    let mut z = 0;
    for &a in &A {
        match a {
            1 => x += 1,
            2 => y += 1,
            3 => z += 1,
            _ => {}
        }
    }

    let dp = vec![vec![vec![None; N + 1]; N + 1]; N + 1];
    Solver {
        N: N,
        x: x,
        y: y,
        z: z,
        dp: dp,
    }
    .solve()
}


Measured memory_bytes: 469372
#include<bits/stdc++.h>
#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define per(i,a,b) for(int i=a;i>=b;--i)
#define mem0(x) memset(x,0,sizeof(x))
#define meminf(x) memset(x,0x3f,sizeof(x))
#define VI vector<int>
#define VL vector<ll>
using namespace  std;


const int N = 3e5+5;
int a[N];
int n,k;

#define lson(x) ((x)<<1)
#define rson(x) ((x)<<1|1)
int maxx[N<<2];

void push_up(int i){
    maxx[i] = max(maxx[lson(i)],maxx[rson(i)]);
}
int qMax(int i,int tl,int tr,int l,int r){
    if(tl<=l&&r<=tr){
        return maxx[i];
    }
    int mid = (l+r)>>1;
    int ans1=0,ans2=0;
    if(tl<=mid){
        ans1 = qMax(lson(i),tl,tr,l,mid);
    }
    if(mid<tr){
        ans2 = qMax(rson(i),tl,tr,mid+1,r);
    }
    return max(ans1,ans2);
}

void updateS(int i,int l,int r,int idx,int val){
    if(l==r){
        maxx[i] = val;
        return;
    }
    int mid = (l+r)>>1;
    if(idx<=mid){
        updateS(lson(i),l,mid,idx,val);
    }
    else{
        updateS(rson(i),mid+1,r,idx,val);
    }
    push_up(i);
}
int main(){
    ios::sync_with_stdio(0);
    cin>>n>>k;
    rep(i,1,n){
        cin>>a[i];
    }
    int ans = 0;
    rep(i,1,n){
        int l = max(0,a[i]-k)+1, r = min(N-5,a[i]+k)+1;
        int res = qMax(1,l,r,1,N-4);
        res++;
        ans = max(res,ans);
        //cout<<"res:"<<res<<'\n';
        //cout<<"ans:"<<ans<<'\n';
        updateS(1,1,N-4,a[i]+1,res);
    }

    cout<<ans;
}



Measured memory_bytes: 8928
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int N;
vector<int> G[10010];
vector<int> c;
int main () {
    cin >> N;    
    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);
    }
    vector<int> v(N, -1);
    queue<int> que;
    v[0] = 0;
    que.push(0);
    int k = 1;
    while (que.size()) {
        int x = que.front();
        que.pop();
        for (auto y: G[x]) {
            if (v[y] == -1) {
                v[y] = k++;
                que.push(y);
            }
        }
    }
    vector<int> c(N);
    int sum = 0;
    for (int i = 0; i < N; i++) {
        cin >> c[i];
        sum += c[i];
    }
    sort(c.begin(), c.end());
    reverse(c.begin(), c.end());
    cout << sum-c[0] << endl;
    for (int i = 0; i < N; i++) {
        cout << c[v[i]];
        if (i != N-1) {
            cout << " ";
        }
    }
    cout << endl;
}

Measured memory_bytes: 1024
#include <stdio.h>
int h(int a,int b){
  if(b % a == 0){
   return (a + b);
 }else{
   return (b - a);
  }
}
int main(){
int a; scanf("%d",&a);
int b; scanf("%d",&b);
 printf("%d\n",h(a,b));
 return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define LI list<int>
#define vct vector
#define vi vct<int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vvi vct<vi>
#define vll vct<ll>
#define vvll vct<vll>
#define all(a) a.begin(),a.end()
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define ff first
#define ss second
#define bg begin()
#define ft cout<<"for test"<<endl;
#define read(v,a,n) for(int i=a; i<n; i++)cin>>v[i];
#define pi 2*acos(0.0)
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define t_c int test,cs=1;cin>>test;while(test--)
#define lcm(a,b) (a*b)/__gcd(a,b)
#define mod 1000000007
int main()
{
    FIO;
    double a,b,h,m;
    cin>>a>>b>>h>>m;
    double angle = (double)(abs(11*m - 60*h))/2;
    angle = (pi*angle)/180;
    angle = min(angle,2*pi-angle);
    ///cout<<angle<<endl;
    ///cout<<cos(angle)<<endl;
    double ans = a*a+b*b-2*a*b*cos(angle);
    cout<<fixed<<setprecision(10)<<sqrt(ans)<<endl;
}


Measured memory_bytes: 4156
import sys
li = list(map(int,input().split()))
li.sort()
if(str(li[0]) == str(li[1]) == str(li[2])):
  print("No")
  sys.exit()
if(str(li[0]) != str(li[1]) != str(li[2])):
  print("No")
  sys.exit()
for i in range(3):
  if(str(li[i]) == str(li[i+1])):
    print("Yes")
    break

Measured memory_bytes: 3064
#include <iostream>
#include <cmath>

using namespace std;

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

	int ans[n], h[n];

	for (int i = 0;i < n;i++) cin >> h[i];
	
	ans[0] = 0;
	ans[1] = abs(h[1] - h[0]);
	for (int i = 2;i < n;i++) 
		ans[i] = min(ans[i - 1] + abs(h[i] - h[i - 1]), ans[i - 2] + abs(h[i] - h[i - 2]));

	cout << ans[n - 1];
}

Measured memory_bytes: 1024
object Main extends App {
  val s = io.StdIn.readLine

  val n = s.length
  val matchcase1 = ("01"*((n/2.0).ceil.toInt)).take(n)
  val matchcase2 = ("10"*((n/2.0).ceil.toInt)).take(n)

  val count1 = (s zip matchcase1).count(t => t._1 != t._2)
  val count2 = (s zip matchcase2).count(t => t._1 != t._2)

  println(math.min(count1, count2))
}

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

//短縮
#define rep(i,n) for(int i=0;i<(n);++i)
//sort()用
#define all(v) v.begin(), v.end()

#define PB(N) push_back(N)

using namespace std;

using Graph = vector<vector<int>>;

int main(){
  vector<int> x(5);
  rep(i,5) cin >> x[i];

  for(int i=0;i<5;i++){
    if(x[i]==0){
      cout << i+1;
      break;
    }
  }
  return 0;
}


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

typedef long long LL;
const int N=55;

LL C(int a,int b){
	if(a<b) return 0;
    LL ans=1;
    for(int i=1;i<=b;i++){
        ans=ans*(a-i+1)/i;
    }
    return ans;
}

int main()
{	
	int n,p,tmp;
	cin>>n>>p;
	int JS=0,OS=0;
	
    for(int i=1;i<=n;i++){
    	cin>>tmp;
    	if(tmp%2==0) OS++;
    	else if(tmp%2==1) JS++;
	}
	 
	LL ans=0;  
	if(p==0){
		ans++;
		for(int i=1;i<=n;i++){
			for(int j=0;j<=i;j+=2){
				ans+=C(JS,j)*C(OS,i-j);
			}
		}
	}
	else if(p==1){
		for(int i=1;i<=n;i++){
			for(int j=1;j<=i;j+=2){
				ans+=C(JS,j)*C(OS,i-j);
			}
		}
	}
	cout<<ans<<endl;
    return 0;
}

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

int main(){
    int K,A,B;
    cin >> K >> A >> B;
    int start = A;
    while(start<=B){
        if(start%K == 0){
            break;
        }
        start++;
    }
    if(start == B+1){
        cout << "NG" << endl;
    }else{
        cout << "OK" << endl;
    }
}

Measured memory_bytes: 3632
from collections import Counter

n = int(input())
s = Counter()

for _ in range(n):
    s.update({input():1})

t = s.most_common()

ans = []
for item in t:
    if item[1] != t[0][1]:
        break
    ans.append(item[0])

ans = sorted(ans)

for i in ans:
    print(i)

Measured memory_bytes: 164676
import bisect
import os
from collections import Counter, deque
from fractions import gcd
from functools import lru_cache
from functools import reduce
import functools
import heapq
import itertools
import math
import numpy as np
import re
import sys
import string

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")

# S = sys.stdin.readline().rstrip()
# for c in string.ascii_lowercase:
#     if c not in S:
#         print(c)
#         exit()
# print('None')

A, B, C, D = list(map(int, sys.stdin.readline().split()))

print(len(set(list(range(A, B))) & set(list(range(C, D)))))


Measured memory_bytes: 13664
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define ff first
#define ss second
#define file_se_input  freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define pp long long int
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define pb push_back
#define mp make_pair
#define pi 3.141592653589793238
#define eb emplace_back
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define zip(i,a,b) for(int i=a;i<b;i++)
#define rzip(i,a,b) for(int i=a;i>=b;i--)
#define ll unsigned long long int
#define test int t;cin>>t; while(t--)
#define um unordered_map
#define en '\n'
#define us unordered_set
typedef pair<int, int>     pii;
typedef pair<char, int>    pci;
typedef pair<char, char>   pcc;
typedef vector<pii>       vii;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define INF (1e18+5)
#define inf (1e9+5)
#define mod 1000000007
vi g[123456], q[123456];
int bio[123456], group[123456];

void dfs(int u, int c)
{
	bio[u] = c;
	group[c]++;
	for (int child : g[u])
	{
		if (!bio[child])
		{
			dfs(child, c);
		}
	}
}

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	if (fopen("input.txt", "r"))
	{
		freopen ("input.txt" , "r" , stdin);
		freopen ("output.txt" , "w" , stdout);
	}
#endif
	//_______________________________-code starts-_______________________________________________

	int n, m, k;
	cin >> n >> m >> k;
	zip(i, 0, m)
	{
		int a, b;
		cin >> a >> b;
		g[a].pb(b);
		g[b].pb(a);
	}
	zip(i, 0, k)
	{
		int c, d;
		cin >> c >> d;
		q[c].pb(d);
		q[d].pb(c);
	}
	int c = 1;
	rep(i, 1, n)
	{
		if (!bio[i])
		{
			dfs(i, c);
			c++;
		}
	}
	rep(i, 1, n)
	{
		int ans = 0;
		ans = group[bio[i]];
		ans -= g[i].size();
		for (int x : q[i])
		{
			if (bio[i] == bio[x])
				ans--;
		}
		cout << ans - 1 << " ";
	}




	return 0;
}



Measured memory_bytes: 18444
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
using ll = long long;
using namespace std;
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 (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}



int main(){
  int T; cin >> T;
  rep(t,T){
    int N; cin >> N;
    vector<ll> A(N); rep(i,N) cin >> A[i];
    string S; cin >> S;
    vector<ll> base;
    bool ok = true;
    for(int i=N-1;i>=0;i--){
      ll x = A[i];
      for(auto b:base){
        chmin(x,x^b);
      }
      if(x){
        if(S[i]=='1'){
          cout << 1 << endl;
          ok = false;
          break;
        }
        else{
          base.pb(x);
        }
      }
    }
    if(ok)cout << 0 << endl;
  }

  return 0;
}


Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
// define
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (((a)%mod) * ((b)%mod)) % mod
#define rollcall cout << "I'm Sucu." << endl;
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define dmt(x, y, z) make_tuple(x, y, z)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define fi first
#define se second
// debug
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p){
  os << "(" << p.first << "," << p.second << ")";return os;
}
template <typename T, typename U, typename V>
ostream &operator<<(ostream &os, const tuple<T, U, V> &t){
  os << "(" << get<0>(t) << "," << get<1>(t) << "," << get<2>(t) << ")";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  for (auto it = v.begin();it != v.end();++it){
    if(it != v.begin())os << " ";os << *it;
  }return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &mp){
  for(auto x: mp)os << "(" << x.first << "," << x.second << ")" << endl;
  return os;
}
template<typename T, int SIZE>
int array_length(const T (&)[SIZE]){return SIZE;}
template<typename T, int N>
void PRINTF(const T (&a)[N], int s = N, int t = -1, bool f = true){
	if(t == -1){rep(i,s){if(i)cout << " ";cout << a[i];}}
	else repi(i,s,t){if(i!=s)cout << " ";cout << a[i];}
	if(f)cout << "\n";
}
template<typename T, int N1, int N2>
void PRINTF(const T (&a)[N1][N2], int h = N1, int w = N2){
	rep(i,h){rep(j,w){cout << a[i][j] << " \n"[j==w-1];}}
}
string substr(const string &str, int S1, int S2 = -1){
  if(S2 == -1)return str.substr(S1);
  return str.substr(S1, S2-S1);
}
// typedef
typedef complex<double> Point;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef tuple<int, int, int> TT;
typedef pair<int, TT> PT;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;
// int sum = accumulate(a, a+n, 0LL);
// int mx = max_element(a, a+n);
// int mn = min_element(a, a+n);
// int cnt = count(a, a+n, k);


priority_queue<P> q;
signed main(){
  int n, m;cin >> n >> m;
  rep(i,n){
    int t;cin >> t;q.push(P(t, 1));
  }
  rep(i,m){
    int b, c;cin >> b >> c;
    q.push(P(c, b));
  }
  
  int ans = 0, cnt = 0;
  while(!q.empty()){
    P p = q.top();q.pop();
    cnt += p.se;
    if(cnt <= n){
      ans += p.se*p.fi;
    }else{
      cnt -= p.se;
      int res = n-cnt;
      ans += res*p.fi;
      break;
    }
  }
  cout << ans << endl;
  return 0;
}






Measured memory_bytes: 6128
def gcd( a, b):
    if b == 0:
        return a
    else:
        return gcd( b, a % b)

n = int(input())
list = [map(int, input().split()) for i in range(n)]
 
def check(num):
    a, b, c, d = list[num]
    if a < b:
        return False
    if a % b > c:
        return False
    if b > d:
        return False
    if c < b and d != b:
        if (b - ( a % b ) - 1) // gcd( b, d) != ((c - ( a % b ))) // gcd( b, d):
            return False
    return True
 
for i in range(n):
    if check(i):
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 3188
import sys
sys.setrecursionlimit(10**7)

readline = sys.stdin.buffer.readline
def readstr():return readline().rstrip().decode()
def readstrs():return list(readline().decode().split())
def readint():return int(readline())
def readints():return list(map(int,readline().split()))
def printrows(x):print('\n'.join(map(str,x)))
def printline(x):print(' '.join(map(str,x)))

n = readint()
print((n+1)//2)

Measured memory_bytes: 61980
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		try(Scanner sc = new Scanner(System.in)) {
			
			String s = sc.next();
			String t = sc.next();
			
			int a = sc.nextInt();
			int b = sc.nextInt();
			
			String u = sc.next();
			
			if ( s.equals(u) ) {
				a--;
			}
			else {
				b--;
			}
			
			System.out.println(String.format("%d %d", a,b));
		}
	}
}

Measured memory_bytes: 35852
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cstring>
#include <queue>
#include <vector>
#include <functional>
#include <map>
#include <set>
#include <cmath>
#include <string>
#define SIZE 200005
#define INF 1000000005LL

using namespace std;
typedef long long int ll;
typedef pair <string,string> P;

int n;
char s[40];
bool c[40];

map<P,int> mp;

int main()
{
	scanf("%d",&n);
	scanf("%s",&s);
	//半分全列挙
	for(int S=0;S<1<<n;S++){
		string A="",B="";
		for(int i=0;i<n;i++){
			if(S>>i&1){
				A += s[i];
			}
		}
		for(int i=n-1;i>=0;i--){
			if(!(S>>i&1)){
				B += s[i];
			}
		}
		mp[P(A,B)]++;
	}
	ll ret=0;
	for(int S=0;S<1<<n;S++){
		string A="",B="";
		for(int i=0;i<n;i++){
			if(S>>i&1){
				A += s[n+i];
			}
		}
		for(int i=n-1;i>=0;i--){
			if(!(S>>i&1)){
				B += s[n+i];
			}
		}
		ret += mp[P(B,A)];
	}
	printf("%lld\n",ret);
	return 0;
}


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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int h, w, n;
string b[100], tmp[100];

int fall() {
    int res = 0;
    for (int r=h-1; r>0; --r) {
        for (int c=w-1; c>=0; --c) {
            if (tmp[r][c] == '.' and tmp[r-1][c] != '.') {
                swap(tmp[r][c], tmp[r-1][c]);
                res++;
            }
        }
    }
    return res;
}

void erase() {
    bitset<50*50+1> del;
    rep(r, h) rep(c, w) {
        char ch = tmp[r][c];
        if (ch == '.') continue;

        int cnt=0;
        for (int i=c; i<w; ++i) {
            if (ch == tmp[r][i]) cnt++;
            else break;
        }
        if (cnt >= n) {
            for (int i=c; i<w; ++i) {
                if (ch == tmp[r][i]) del[r*w+i] = 1;
                else break;
            }
        }

        cnt=0;
        for (int i=r; i<h; ++i) {
            if (ch == tmp[i][c]) cnt++;
            else break;
        }
        if (cnt >= n) {
            for (int i=r; i<h; ++i) {
                if (ch == tmp[i][c]) del[i*w+c] = 1;
                else break;
            }
        }
    }

    rep(r, h) rep(c, w) if (del[r*w+c]) {
        tmp[r][c] = '.';
    }
}

int main() {
    cin >> h >> w >> n;
    rep(r, h) cin >> b[r];
    rep(r, h) rep(c, w-1) {
        rep(r2, h) rep(c2, w) tmp[r2] = b[r2];
        swap(tmp[r][c], tmp[r][c+1]);
        int cnt = 1;
        while (true) {
            while (cnt) {
                cnt = fall();
            }
            erase();
            cnt = fall();
            if (!cnt) break;
        }

        bool win = true;
        rep(r2, h) rep(c2, w) {
            if (tmp[r2][c2] != '.') {
                win = false;
                break;
            }
        }
        if (win) {
            cout << "YES" << endl;
            return 0;
        }
    }

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



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

#define all(x) x.begin(), x.end()
#define lc (i << 1)
#define rc (i << 1 | 1)
using namespace std;
using ll = long long;
using pii = pair<int, int>;
const int MN = 2e5 + 5, LN = 17, MOD = 1e9 + 7, INF = 0x3f3f3f3f;

int main() {
    ios_base::sync_with_stdio(false), cin.tie(nullptr);
    int N, A, B, C;
    cin >> N >> A >> B >> C;
    if (A == 0 && B == 0 && C == 0) {
        cout << "No";
        return 0;
    }
    vector<string> moves;
    for (int i = 0; i < N; i++) {
        string s;
        cin >> s;
        moves.push_back(s);
    }
    string ret;
    for (int i = 0; i < N; i++) {
        string cur = moves[i];
       // cout << A << "  " << B << " " << C <<endl;
        if (cur == "AB") {
            if (!A && !B) {
                cout << "No\n";
                return 0;
            } else if (!A && B) {
                A++, B--;
                ret += "A";
            } else if (A && !B) {
                A--, B++;
                ret += "B";
            } else {
                if (i != N - 1) {
                    if (moves[i + 1] == "AC") {
                        A++, B--;
                        ret += "A";
                    } else {
                        A--, B++;
                        ret += "B";
                    }
                } else {
                    A++, B--;
                    ret += "A";
                }
            }
        } else if (cur == "BC") {
            if (!B && !C) {
                cout << "No\n";
                return 0;
            } else if (!B && C) {
                B++, C--;
                ret += "B";
            } else if (B && !C) {
                B--, C++;
                ret += "C";
            } else {
                if (i != N - 1) {
                    if (moves[i + 1] == "AB") {
                        B++, C--;
                        ret += "B";
                    } else {
                        B--, C++;
                        ret += "C";
                    }
                } else {
                    B++, C--;
                    ret += "B";
                }
            }
        } else {
            if (!A && !C) {
                cout << "No\n";
                return 0;
            } else if (!A && C) {
                A++, C--;
                ret += "A";
            } else if (A && !C) {
                A--, C++;
                ret += "C";
            } else {
                if (i != N - 1) {
                    if (moves[i + 1] == "AB") {
                        A++, C--;
                        ret += "A";
                    } else {
                        A--, C++;
                        ret += "C";
                    }
                } else {
                    A++, C--;
                    ret += "A";
                }
            }
        }
    }
    cout << "Yes\n";
    for (int i = 0; i < N; i++) cout << ret[i] << '\n';
    return 0;
}


Measured memory_bytes: 7428
N = int(input())
a = list(map(int, input().split()))
num2 = sum(map(lambda x : 1 if not x%2 else 0, a))
num4 = sum(map(lambda x : 1 if not x%4 else 0, a))
if (N //2-  num4 - (num2-num4)//2 <= 0):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define rep(i,N) for(int (i)=0;(i)<(N);++(i))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define MP make_pair
#define pb push_back
const int INF = 1e18;
const int MOD = INF+7;
using P = pair<int,int>;

signed main(){
    int N;
    cin >> N;
    vector<int> h(N);
    rep(i,N) cin >> h[i];
    h.emplace_back(0);

    int left = 0;
    int ans = 0;
    while(left != N){
        int right = left;
        while(h[right] != 0) ++right;

        if(left == right){
            ++left;
            continue;
        }

        bool zero = false;
        while(!zero){
            for(int i=left;i<right;++i){
                --h[i];
                if(h[i] == 0) zero = true;
            }
            ++ans;
        }
    }

    cout << ans << endl;
}

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

template <class T>
inline void read(T &res)
{
	res = 0; bool bo = 0; char c;
	while (((c = getchar()) < '0' || c > '9') && c != '-');
	if (c == '-') bo = 1; else res = c - 48;
	while ((c = getchar()) >= '0' && c <= '9')
		res = (res << 3) + (res << 1) + (c - 48);
	if (bo) res = ~res + 1;
}

const int N = 305, M = 605, djq = 1e9 + 7;

int n, m, a[M], typ[M], f[2][N][N], ans;

inline void add(int &a, const int &b) {if ((a += b) >= djq) a -= djq;}

int main()
{
	read(n);
	for (int i = 1; i <= n * 2; i++) read(a[i]);
	for (int i = 1; i <= n * 2; i += 2)
		if (a[i] != -1 && a[i + 1] != -1) typ[a[i]] = typ[a[i + 1]] = 2;
		else if (a[i] != -1 || a[i + 1] != -1) typ[a[i] != -1 ? a[i] : a[i + 1]] = 1;
		else m++;
	f[1][0][0] = 1;
	for (int i = n * 2; i >= 1; i--)
	{
		int op = i & 1, ls = op ^ 1;
		for (int j = 0; j <= n; j++) for (int k = 0; k <= n; k++)
			f[op][j][k] = 0;
		if (typ[i] == 2) for (int j = 0; j <= n; j++)
			for (int k = 0; k <= n; k++)
				f[op][j][k] = f[ls][j][k];
		else if (typ[i] == 1)
			for (int j = 0; j <= n; j++)
				for (int k = 0; k <= n; k++)
				{
					if (!f[ls][j][k]) continue;
					add(f[op][j + 1][k], f[ls][j][k]);
					if (k) add(f[op][j][k - 1], f[ls][j][k]);
				}
		else for (int j = 0; j <= n; j++)
			for (int k = 0; k <= n; k++)
			{
				if (!f[ls][j][k]) continue;
				if (j) add(f[op][j - 1][k], 1ll * f[ls][j][k] * j % djq);
				add(f[op][j][k + 1], f[ls][j][k]);
				if (k) add(f[op][j][k - 1], f[ls][j][k]);
			}
	}
	ans = f[1][0][0];
	for (int i = 1; i <= m; i++) ans = 1ll * ans * i % djq;
	return std::cout << ans << std::endl, 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using ll = long long;
// using ll = boost::multiprecision::int128_t;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
#define rep2(i, m, n) for(ll i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(ll i=int(m)-1; i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) a.begin(), a.end()
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << " "; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int Log2(ll x) { int k; for (k = 0; x > 0; ++k) x >>= 1; return k; } // number of binary digits
const int INF  = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS   = 1e-10;
const ld PI    = acos(-1.0);
const int MOD  = int(1e9)+7;


int main() {
  ll n; cin >> n;
  Vll a(n+1); cin >> a;

  Vll s = a;
  drep(i, n) s[i] += s[i+1];
  s.push_back(0);

  ll ans = 0, x = 1;
  rep(i, n+2) {
    if (i) x = min(2*(x-a[i-1]), s[i]);
    if (x < 0) {
      cout << -1 << "\n";
      return 0;
    }
    ans += x;
  }
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 5592
#include<cstdio>
#include<algorithm>

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

using namespace std;

const int INF=1<<29;

// a を base 進数で書いたものを 10 進数だと解釈したときの値
int f(int a,int base){
	int res=0;
	for(int ten=1;a>0;ten*=10){
		if(a%base>=10) return INF;
		res+=a%base*ten;
		a/=base;
	}
	return res;
}

int main(){
	for(int a,b,c;scanf("%d%d%d",&a,&b,&c),a!=-1;){
		bool ok=false;
		for(int base=2;base<=16;base++) if(f(a,base)==b) ok=true;
		if(!ok){
			puts("-1");
			continue;
		}

		for(a++;a<=c;a++){
			int b_next=INF;
			for(int base=2;base<=16;base++) if(b<=f(a,base)) b_next=min(b_next,f(a,base));
			b=b_next;
		}
		printf("%d\n",b);
	}

	return 0;
}

Measured memory_bytes: 0
//保留所有权利。
#include<iostream>
#include<stdio.h>//printするよ
#include<vector>
#include<algorithm>//辞書順はnext_permutationだよ
#include<set>
#include<string>
#include<sstream>
#include<string.h>
#include<complex>
#include<time.h>
#include<random>
#include<cmath>
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<locale>
#include<utility>//swapで数値交換するよ
//END OF LIBRARIES.
#define rt "\n"//改行を最速化させるよ
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(s,n) rep(i,n)cin>>s[i];//vcin(配列名),(繰り返し回数)
#define sort(s) sort(s.begin(),s.end())
#define reve(s) reverse(s.begin(),s.end())
#define asas int ans=0
#define llcncn llint cnt=0
#define llasas llint ans=0
#define cncn int cnt=0
#define smsm int sum=0
#define str srting
#define v vector
#define please return
#define AC 0//おまじないだよ
#define Rapid cin.tie(0);ios::sync_with_stdio(false)
//END OF DEFINE.
using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vcha;
typedef vector<double> vdou;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;
//printf("%02d:%02d:%02d\n", h, m, s);・・・2文字は埋める・h、m、ｓ
//END OF TYPEDEF.

//最大公約数（GCD）を求めるよ
//最小公倍数（LCM）は＜＜　A × B ÷ GCD　 ＞＞で求まるよ

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}
long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}
/*
  for A以上B未満でI探索 for (int I = A; i <= B; i++)

  string s = to_string(i);

  char　小文字のほうが32大　　  　大文字と小文字の境=93

  大文字→小文字 文字列のn文字目を大文字で出力→ (char)toupper(a[0])

  pow(a,b) → aのb乗を求める

  s1.erase(n) 文字列s1の、n文字目以降削除             */

int a = 0, b = 0, c = 0, d = 0, x = 0, y = 0
   , z = 0, n = 0, sum = 0, i = 0;
string s = ""; asas; cncn;

int main(void) {
	cin >> n;
	rep(i, 101) {
		rep(j, 101) {
			if (n == i * 4 + j * 7)ans++;
		}
	}
	Yes(ans != 0);
	please AC;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include "iostream"
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

int main(void)
{
	int n;
	ll a, b;
	ll atmina;
	ll power = 0;
	cin >> n >> a >> b;
	vector<ll> x(n);
	for (int i = 0; i < n; i++)
	{
		cin >> x[i];
	}

	for (int i = 0; i < n - 1; i++)
	{
		atmina = min(a*(x[i + 1] - x[i]), b);
		power += atmina;
	}


	cout << power << endl;

	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
  int N;
  cin >> N;
  vector<vector<int>> avoid;
  for (int i=0; i<N; i++){
    avoid.emplace_back(vector<int>({}));
  }
  int front = 1, rear = (N % 2 == 0 ? N : N - 1), drop = 0;
  for (front, rear; front < rear; front++, rear--){
	avoid[rear - 1].push_back(front);
    avoid[front - 1].push_back(rear);
    drop++;
  }
  vector<vector<int>> buf;
  for (int i=0; i<N; i++){
    for (int j=i; j<N; j++){
		if (find(avoid[i].begin(), avoid[i].end(), j + 1) == avoid[i].end() && i != j){
			buf.emplace_back(vector<int>({i + 1, j + 1}));
        }
    }
  }
  cout << buf.size() << endl;
  for (vector<int> e : buf){
    cout << e[0] << " " << e[1] << endl;
  }
  
  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>
#include <chrono>
#include <random>
#include <bitset>

using namespace std;

#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk
#define prev asdasfsadjkjsdfjs
#define tm aklsjdasjdasjdkdjjf
#define lcm hddalkwjeidjjhasda
#define random_shuffle asdasdd

const int MAXN = 205000;

int n;
long long a[MAXN], b[MAXN];
long long aa[MAXN], bb[MAXN];
long long ans = 0;

int main() { 

  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%lld", &a[i]);
  }
  for (int i = 0; i < n; i++) {
    scanf("%lld", &b[i]);
  }

  for (int i = 0; i <= 28; i++) {
    long long p = 1 << i;
    for (int j = 0; j < n; j++) {
      aa[j] = a[j] % (p * 2);
      bb[j] = b[j] % (p * 2);
    }
    sort(aa, aa + n);
    sort(bb, bb + n);

    long long cur = 0;

    long long from = p, to = p * 2 - 1;
    // cerr << from << " " << to << endl;

    int p1 = 0, p2 = 0;
    for (int j = n - 1; j >= 0; j--) {
      while (p1 + 1 < n && aa[j] + bb[p1] < from) {
        p1++;
      }
      p2 = max(p2, p1);
      while (p2 + 1 < n && aa[j] + bb[p2 + 1] <= to) {
        p2++;
      }
      // cerr << j << " " << p1 << " " << p2 << endl;
      if (aa[j] + bb[p1] >= from && aa[j] + bb[p2] <= to) {
        cur += p2 - p1 + 1;
      }
    }

    from = p + p * 2; to = p * 4 - 1;
    // cerr << from << " " << to << endl;
    p1 = 0, p2 = 0;
    for (int j = n - 1; j >= 0; j--) {
      while (p1 + 1 < n && aa[j] + bb[p1] < from) {
        p1++;
      }
      p2 = max(p2, p1);
      while (p2 + 1 < n && aa[j] + bb[p2 + 1] <= to) {
        p2++;
      }
      // cerr << j << " " << p1 << " " << p2 << endl;
      if (aa[j] + bb[p1] >= from && aa[j] + bb[p2] <= to) {
        cur += p2 - p1 + 1;
      }
    }

    // cerr << "Cur " << i << " " << cur << endl;
    if (cur & 1) {
      ans += p;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long int64;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;
const int MAX_NUM = 999999999;
void solve() {
	int x, a, b; cin >> x >> a >> b;
	if ((b - a) <= 0) cout << "delicious" << endl;
	else if ((b - a) <= x) cout << "safe" << endl;
	else cout << "dangerous" << endl;
	return;
}
int main() {
	solve();
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#define int long long
#define N 402
using namespace std;
const int mod=1000000007;
int n,c,a[N],b[N],sum[N][N],f[N][N],i,j,k;
int poww(int a,int b)
{
	int ans=1,base=a;
	while(b){
		if(b&1) ans=ans*base%mod;
		base=base*base%mod;
		b>>=1;
	}
	return ans%mod;
}
signed main()
{
	cin>>n>>c;
	for(i=1;i<=n;i++) cin>>a[i];
	for(i=1;i<=n;i++) cin>>b[i];
	for(i=1;i<=n;i++){
		if(a[i]>b[i]) swap(a[i],b[i]);
		for(j=0;j<=c;j++){
			for(k=a[i];k<=b[i];k++) sum[i][j]=(sum[i][j]+poww(k,j))%mod;
		}
	}
	for(i=0;i<=c;i++) f[1][i]=sum[1][i];
	for(i=2;i<=n;i++){
		for(j=0;j<=c;j++){
			for(k=0;k<=j;k++) f[i][j]=(f[i][j]+f[i-1][k]*sum[i][j-k]%mod)%mod;
		}
	}
	cout<<f[n][c]<<endl;
	return 0;
}


Measured memory_bytes: 2816
#include <bits/stdc++.h>
using namespace std;
int main(){
string n;
cin >> n ;
if(n[0]=='7') cout<<"Yes"<<endl;
else if(n[1]=='7') cout<<"Yes"<<endl;
else if(n[2]=='7') cout<<"Yes"<<endl;
else cout<<"No"<<endl;

}

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

int main() {
  int n; string s;
  cin >> n >> s;
  int ans=s.size();
  rep(i,n) {
    if(s[i]==s[i-1]) ans--;
  }
  cout << ans << endl;
}


Measured memory_bytes: 512