akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
//----***やべーやつら***----
using namespace std;
#define int long long

//----***型定義***----
using ll = long long;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;
typedef long double lb;
typedef vector<int,vector<int>> vvec;
typedef long double ld;
typedef pair<int,int> P;

//----***Like a Pythonista***----
#define REP(i,j,n) for (ll i=j;i<(n);i++)
#define RREP(i,n,j) for (ll i = n; j<i;i--)
#define each(i,...) for (auto&& i:__VA_ARGS__)
#define ALL(vec) (vec).begin(),(vec).end()
#define sum(...) accumulate(ALL(__VA_ARGS__),0LL)
#define dsum(...) accumulate(ALL(__VA_ARGS__),0.0L)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
inline ll gcd(ll a, ll b){ while(b){ ll c = b; b = a % b; a = c; } return a; }
inline ll lcm(ll a, ll b){ if(!a || !b) return 0; return a * b / gcd(a, b); }

//----***定数***----
const int MOD=1000000007;
#define INF 1e9;
#define EPS 1e-9;

//----***入出力***---
#define print(out) cout<< out  << "\n";
#define debug(var)  do{std::cerr << #var << " ↓ "<<"\n";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
#define here  cout<<"Here"<<endl;


//----***初期時読み込み***----
struct initial{initial(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}initial_;

signed main(){
  int N,M,a,b;cin>>N>>M;
  vector<vector<int>> V(1000000);
  priority_queue<int> pque;
  REP(i,0,N){
    cin>>a>>b;
    V[a].push_back(b);
  }
  int ans=0;
  REP(i,1,M+1){
    REP(j,0,V[i].size()){
      int c=V[i][j];
      pque.push(c);
    }
    if(pque.size()){
      ans += pque.top();
      pque.pop();
    }
  }
  print(ans)
  return 0;
}


Measured memory_bytes: 26752
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
using namespace std;

int main()
{
	int N;
	cin >> N;
	vector<unsigned long long> A(N);
	for (auto i = 0; i < N; ++i)
	{
		cin >> A[i];
	}

	auto r = 0;
	auto x = 0ull;
	auto sum = 0ull;
	auto result = 0ull;
	for (auto l = 0; l < N; ++l)
	{
		while (r < N && (x ^ A[r]) == (sum + A[r]))
		{
			x ^= A[r];
			sum += A[r];
			++r;
		}

		result += r - l;
		x ^= A[l];
		sum -= A[l];
	}

	cout << result << endl;

	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a) ; i < (b); i++)
#define FOE(i,a,b) for (int i = (a) ; i <= (b); i++)
#define FOD(i,a,b) for (int i = (a) ; i >= (b); i--)
#define LL long long
#define pb push_back
 
using namespace std;

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

    string S;
    cin >> S;
    
    int n = S.length();
    int sum = 0, ans = 0, power = 1;
    unordered_map<int,int> exist;
    
    exist[0] = 1;

    FOD(i, n-1, 0){
        sum = (sum + (S[i] - '0') * power) % 2019;
        ans+= exist[sum];
        exist[sum]++;
        power *= 10;
        power %= 2019;
    }

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

    return 0;
}

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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1)
    printEoln();
  if (suc == 2)
    printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U> void chmax(T &a, U b) {
  if (a < b)
    a = b;
}

template <class T, class U> void chmin(T &a, U b) {
  if (b < a)
    a = b;
}

template <class T> T Sq(const T &t) { return t * t; }


signed main() {
  string str;
  cin >> str;
  REP(i, 3) {
    if(str[i] == '1')
      str[i] = '9';
    else
      str[i] = '1';
  }

  cout << str << endl;

  return 0;
}


Measured memory_bytes: 256
def resolve():
    n, m = map(int, input().split())
    ans = [-1] * n
    for _ in range(m):
        s, c = map(int, input().split())
        if ans[s - 1] not in (-1, c):
            print(-1)
            return
        ans[s - 1] = c
    if ans[0] == 0 and n != 1:
        print(-1)
        return
    if ans[0] == -1 and n != 1:
        ans[0] = 1
    print("".join([str(x) if x > 0 else "0" for x in ans]))


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) (x).begin(),(x).end()
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	
	int n; cin >> n;
	
	vector<int> a(n); rep(i,n) cin >> a[i];
	
	sort(all(a));
	
	int r=a[0];
	
	bool f=1;
	
	while(f){
		f=0;
		rep(i,a.size()){
			if(a[i]%r==0) continue;
			else{
				r=a[i]%r;
				f=1;
				break;
			}
		}
	}
	
	cout << r << endl;

	
	return 0;
}



Measured memory_bytes: 640
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
//increase stack size
#pragma comment(linker, "/STACK:16777216")

ll mxm() {return LLONG_MIN;}
template<typename... Args>
ll mxm(ll a, Args... args) { return max(a,mxm(args...)); }

ll mnm() {return LLONG_MAX;}
template<typename... Args>
ll mnm(ll a, Args... args) { return min(a,mnm(args...)); }

template<class T> ostream& operator<<(ostream& os,vector<T> V){
	os<<"[ ";for(auto v:V)os<<v<<" ";return os<<"]";
}
template<class L,class R> ostream& operator<<(ostream& os,pair<L,R> P){
	return os<<"("<<P.first<<","<<P.second<<")";
}

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__,__VA_ARGS__)
template<typename Arg1>
void __f(const char* name,Arg1&& arg1){
	cout<<name<<" : "<<arg1<<endl;
}
template <typename Arg1,typename... Args>
void __f(const char* names,Arg1&& arg1,Args&&... args){
	const char* comma=strchr(names+1,',');cout.write(names,comma-names)<<" : "<<arg1<<" | ";__f(comma+1,args...);
}
#else
#define trace(...) 1
#endif

#define ld long double
#define pll pair<ll,ll>
#define ii pair<int,int>
#define vll vector<ll>
#define vii vector<ii>
#define vi vector<int>
#define vpll vector<pll>
#define vld vector<ld>
#define vvld vector<vld>
#define vvi vector<vi>
#define vvll vector<vll>
#define vvpll vector<vpll>
#define vvii vector<vii>
#define I insert
#define F first
#define S second
#define pb push_back
#define endl "\n"
#define all(x)	x.begin(),x.end()

const int mod=1e9+7;
// 128 bit: __int128
inline int add(int a,int b){a+=b;if(a>=mod)a-=mod;return a;}
inline int sub(int a,int b){a-=b;if(a<0)a+=mod;return a;}
inline int mul(int a,int b){return (a*1ll*b)%mod;}
inline int power(int a,int b){int rt=1;while(b>0){if(b&1)rt=mul(rt,a);a=mul(a,a);b>>=1;}return rt;}
inline int inv(int a){return power(a,mod-2);}

struct compare{
	bool operator() (const int &a,const int &b) const{
		return a>b;
	}
};

int main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cout<<setprecision(25);
	int n;
	cin >> n;
	if(n % 10 == 7)
		cout << "Yes";
	else if((n / 10) % 10 == 7)
		cout << "Yes";
	else if((n / 100) % 10 == 7)
		cout << "Yes";
	else cout << "No";
	cout << endl;			
}


Measured memory_bytes: 3636
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
while(true){
   var Sum=Arr.shift()-0;
   if(Sum==0)break;
   var sum=0;
   for(var i=0;i<9;i++)sum+=(Arr.shift()-0);
   console.log(Sum-sum);
}

Measured memory_bytes: 7644
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

int main()
{
	long double n, d;
	std::cin >> n >> d;
	int ans = 0;
	for (int i = 0; i < n; i++)
	{
		long double x, y;
		std::cin >> x >> y;
		if (x * x + y * y <= d * d)
			++ans;
	}
	std::cout << ans << '\n';
	return (0);
}

Measured memory_bytes: 3784
#include <algorithm>
#include <iostream>
#include <queue>
#include <cmath>
#include <string>
#include <iterator>
#include <map>
#include <set>
#include <iomanip>
#include <vector>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using Graph = vector<vector<int>>;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
#define INF 100000000
#define MAX 200001
#define MOD 1000000007
ll fac[MAX], finv[MAX], inv[MAX];
const int MX = 1000005;

int main(){
    int n,k;cin>>n>>k;
    ll ans=1;
    vector<ll> a(n+1);
    a[0]=0;
    for(int i=1;i<n+1;i++){
        a[i]=a[i-1]+i;
    }
    for(int i=k;i<n+1;i++){
        ans+=(a[n]-a[n-i])-a[i-1]+1;
        ans%=MOD;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 4752
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

x, y= na()

if (4*x-y)%2 == 0 and (4*x-y)//2 >= 0  and (4*x-y)//2 <= x:
  print("Yes")
else:
  print("No")


Measured memory_bytes: 9176
#include <stdio.h>

int main(){
    int x, y;
    while(1){
        scanf("%d %d", &x, &y);
        if(x==0 && y==0)break;
        if(x<y){
            printf("%d %d\n", x, y);
        }else{
            printf("%d %d\n", y, x);
        }
    }
    return 0;
}


Measured memory_bytes: 2052
n,k=map(int,input().split())
a=list(map(int,input().split()))

ans_mono=0
ans_di=0
for i in range(n):
    for j in range(i+1,n):
        if a[i]>a[j]:ans_mono+=1
for i in range(n):
    for j in range(n):
        if a[i]>a[j]:ans_di+=1
print((ans_mono*k+ans_di*(k*(k-1)//2))%int(1e+9+7))


Measured memory_bytes: 9296
package main

import (
	"fmt"
)

func solution(s string) string {
	l := len(s)
	b := make([]byte, l)
	for i := 0; i < l; i++ {
		b[i] = byte('x')
	}
	return string(b)
}

func main() {
	var s string
	fmt.Scan(&s)
	fmt.Println(solution(s))
}


Measured memory_bytes: 512
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.NoSuchElementException;

public class Main {
	
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		
		int n = sc.nextInt();
		sc.nextInt();
		
		String[] s = new String[n];
		for (int i = 0; i < n; i++) {
			s[i] = sc.next();
		}
		Arrays.sort(s);
		
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < n; i++) {
			sb.append(s[i]);
		}
		
		out.println(sb.toString());
		out.flush();
	}
	
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
	
	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}
	
	private byte readByte() {
		if (hasNextByte()) {
			return buffer[ptr++];
		} else {
			return -1;
		}
	}
	
	private boolean isPrintableChar(int c) {
		return '!' <= c && c <= '~';
	}
	
	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
			ptr++;
		}
	}
	
	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}
	
	public String next() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		StringBuilder sb = new StringBuilder();
		byte b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	
	public int nextInt() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		int n = 0;
		boolean minus = false;
		byte b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
}

Measured memory_bytes: 8404
#include "bits/stdc++.h"
using namespace std;
typedef long long li;

li n;
vector<vector<li>> g;
li rec(li pos, li parent, bool parent_antenna) {
    if (g[pos].size() == 1 && parent != -1) {
        if (parent_antenna) {
            return 0;
        } else {
            return 1;
        }
    }

    bool next_parent_antenna = parent_antenna || (g[pos].size() >= 3);
    li sum = 0;
    li zeros = 0;
    for (auto next : g[pos]) {
        if (next == parent) {
            continue;
        }
        li sub = rec(next, pos, next_parent_antenna);
        sum += sub;
        if (sub == 0) {
            zeros++;
        }
    }
    li zero_cost = max(zeros - (parent_antenna ? 1 : 0), 0LL);
    return sum + zero_cost;
}

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

    cin >> n;
    g = vector<vector<li>>(n);
    for (int i = 0; i < n - 1; ++i) {
        li a, b;
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    for (int i = 0; i < n; ++i) {
        if (g[i].size() == 1) {
            li ans = min(rec(i, -1, false), rec(i, -1, true) + 1);
            cout << ans << endl;
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 13568
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!(n: usize,k: usize,a: [usize;n]);
    let result = solve(n,k,a);
    println!("{:?}",result);
}

pub fn solve(n: usize,k:usize,a: Vec<usize>) -> usize {
     ((n - k) as f64 / (k - 1) as f64).ceil() as usize + 1
}

       


Measured memory_bytes: 6396
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(){
  int a,b,x;
  cin >> a >> b >> x;
  if(x>=a && x<=a+b){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
  return 0;
}

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

using namespace std;

const int INF = 1000000000;
const int INF_x = -1000000000;
const int INF_y = -1000000000;

struct Point {
  int x;
  int y;
  int num;
};

bool operator<(const Point &left, const Point &right) {
  int dl = abs(left.x - INF_x) + abs(left.y - INF_y);
  int dr = abs(right.x - INF_x) + abs(right.y - INF_y);
  if (dl == dr) {
    return left.num < right.num;
  }
  return dl < dr;
}

int calc(const Point &left, const Point &right) {
  return abs(left.x - right.x) + abs(left.y - right.y);
}

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

  vector<Point> students;
  vector<Point> points;
  for (int i = 0; i < n; i++) {
    Point p;
    cin >> p.x;
    cin >> p.y;
    p.num = i;
    students.push_back(p);
  }
  for (int i = 0; i < m; i++) {
    Point p;
    cin >> p.x;
    cin >> p.y;
    p.num = i;
    points.push_back(p);
  }
  
  /*
    アイデア
    INFを基準に、マンハッタン距離でソート
  */
  sort(points.begin(), points.end());

  for (int i = 0; i < n; i++) {
    Point best;
    int best_d = INF;
    for (int j = 0; j < m; j++) {
      int d = calc(students[i], points[j]);
      if (best_d > d) {
        best = points[j];
        best_d = d;
      }
    }
    cout << best.num+1 << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using P = vector<int>;
using ll = long long;

const int N = 100010;

int n;
int m;
ll k;
ll a[N];

P& operator*=(P& a, const P& b) {
    P c(a.size());

    for (int i = 0; i < int(a.size()); i++) {
        c[i] = a[b[i]];
    }
    a = c;

    return a;
}

P power(P a, ll b) {
    P r(a.size());
    iota(r.begin(), r.end(), 0);

    for (; b > 0; b >>= 1) {
        if (b & 1) {
            r *= a;
        }

        a *= a;
    }

    return r;
}

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

    scanf("%d %lld", &m, &k);
    P p(n - 1);
    iota(p.begin(), p.end(), 0);
    for (int i = 0; i < m; i++) {
        int x;
        scanf("%d", &x);
        x--;
        swap(p[x - 1], p[x]);
    }

    P r = power(p, k);

    ll cur = a[0];
    for (int i = 0; i < n - 1; i++) {
        printf("%lld\n", cur);
        int j = r[i];
        cur += a[j + 1] - a[j];
    }
    printf("%lld\n", cur);
}


Measured memory_bytes: 3184
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>


using namespace std;

int main(){

	string s;

	cin >> s;

	if(s[0] != 'A'){
		cout << "WA" << endl;
		return 0;
	}

	int x = 0;
	bool flag = false;

	for(int i = 1; i < s.size(); i++){
		if(s[i] < 'a' || s[i] > 'z'){
			if(s[i] == 'C' && i >= 2 && i <= s.size() - 2 && flag == false){
				flag = true;
			} else {
				cout << "WA" << endl;
				return 0;
			}
		}
	}
		
	if(flag == true){
		cout << "AC" << endl;
		return 0;
	} else {
		cout << "WA" << endl;
		return 0;
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n;
	cin >> n;

	vector<int> perm(n + 1);
	for (int i = 1; i <= n; ++i) {
		cin >> perm[i];
	}

	int ops = 0;
	for (int i = 1; i <= n - 1; ++i) {
		if (perm[i] == i && perm[i + 1] == i + 1) {
			++ops;
			swap(perm[i], perm[i + 1]);
		}
	}

	for (int i = 1; i <= n; ++i) {
		if (perm[i] == i) {
			++ops;
		}
	}

	cout << ops << "\n";

	return 0;

}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0; (i)<(n); (i)++)
#define each(i, c) for (auto& (i) : (c))

using namespace std;
typedef long long int lli;
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }

int main() {
    int a, b;
    cin >> a >> b;
    cout << (a*b%2 == 1 ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define why(n,x) int n;while(cin >>n,n!=x)
#define iFOR(i,x,n)for(int i=x;i<n;i++)
#define unless(flg) if ( !(flg) )
#define read cin<<
#define echo cout<<
#define fin <<'\n'
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
#define SWAP(a,b) ((a != b) && (a += b,b = a - b,a -= b))
#define cinf(n,x) for(int UNCH=0;UNCH<(n);UNCH++) cin >> x[UNCH];
#define fcin(n,x) for(int UNCH=1;UNCH<=(n);UNCH++) cin>> x[UNCH];
#define memmin(x) memset((x),-1,sizeof((x)))
#define memzer(x) memset((x), 0,sizeof((x)))
#define meminf(x) memset((x),0x3f,sizeof((x)))
#define int long long
typedef long long ll;
typedef pair < int , int >  pii;
typedef vector < int > vit;
typedef map < string , int > mstit;
typedef vector < pii > vpi ;
typedef greater < pii > gpi;
typedef priority_queue < pii , vpi , gpi > dijk ;
static const signed int INF = 0x3f3f3f3f;
static const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static const signed int SMOD = 1000000007;
static const signed int NMOD = 1000000009;
static const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static const signed int dy[]={0,-1,0,1,-1,1,-1,1};

bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>T abs(T &x){return x<0 ? -x : x;}
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; }
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}



signed main(){
    string str;
    cin >> str;
    sort(ALL(str));
    if(str=="abc") cout <<"Yes\n";
    else cout <<"No\n";
  
  return 0;
}



struct xyz{ xyz(){ cin.tie(0), ios::sync_with_stdio(false); cout <<fixed<<setprecision(12);};}xyzzy;



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
using namespace std;
typedef long long ll;
int main() {
    int num[100];
    while(cin >> num[0] >> num[1] >> num[2]) {
        sort(num, num + 3);
        if(num[0] == 5 && num[1] == 5 && num[2] == 7)
            cout << "YES" << endl;
        else cout << "NO" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
n = int(input())
p = list(map(int,input().split()))
q = list(range(1,n+1))
if p == q:
    print("YES")
    exit(0)
cnt = 0
for i in range(n):
    if p[i] != q[i]:
        cnt += 1
        if cnt == 1:
            t = i
        if cnt == 2:
            if p[t] != q[i]:
                print("NO")
                exit(0)
    if cnt > 2:
        print("NO")
        exit(0)
print("YES")

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

using namespace std;

int main(){
 string s,t;
  cin >> s >> t;
  int n=stoi(s+t);
  
  bool res=false;
  for(int i=1;i*i<=n;i++){
   if(i*i==n) res=true;
  }
  if(res) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b)  for(int i=(a),i##formax=(b);i< i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formin=(b);i>=i##formin;i--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max((x),(y))
#define mins(x,y) x=min((x),(y))
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define all(a) ((a).begin()),((a).end())
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define bit(n) (1LL<<(n))
typedef long long ll;
typedef __int128_t lll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>using P=pair<T,Y>;
template<class T,class Y>ostream& operator<<(ostream&o,P<T,Y>&p){return o<<"("<<p.fi<<","<<p.se<<")";}
template<class T>ostream& operator<<(ostream&o,V<T>&v){for(T&t:v)o<<t<<",";return o;}
template<class T>void uniq(V<T>&v){sort(all(v));v.erase(unique(all(v)), v.end());}

lll gcd(lll a,lll b,lll&x,lll&y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return(x%m+m)%m;}
ll modPow(lll a,lll n,ll m){lll p=1;for(;n;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return p;}
V<ll>Fac,Rac;void setF(int n,int mod){Fac=Rac=V<ll>(++n);Fac[0]=1;FOR(i,1,n)Fac[i]=Fac[i-1]*i%mod;Rac[n-1]=modInv(Fac[n-1],mod);FORR(i,n-1,1)Rac[i-1]=Rac[i]*i%mod;}
ll comb(int a,int b,int m){return a<b||b<0?0:Fac[a]*Rac[b]%m*Rac[a-b]%m;}

const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7; //998244353;
const int N = 1e5;
string s;
int k, p9[4]={1,9,81,729};
ll any(int a, int b){
  if(a<b||b<0) return 0;
  ll ret = 1;
  FOR(i, 0, b) ret *= a-i;
  FOR(i, 0, b) ret /= i+1;
  return ret * p9[b];
}
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  setF(200, MOD);
  cin >> s >> k;
  int n = sz(s);
  ll ans = 0;
  FOR(i, 0, n){
    int a = s[i]-'0';
    if(!a) continue;
    ans += any(n-i-1, k) + any(n-i-1, k-1)*(a-1);
    k -= !!a;
    if(k<0) break;
  }
  if(!k) ans++;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int N;
  cin >> N;
  bool A=false;
  rep(i,30){
    rep(j,30){
      if(4*i+j*7==N){
        A=true;
        break;
      }
    }
  }
  if(A){
    cout << "Yes"  << endl;
  }
  else{
    cout << "No" <<endl;
  }
}

Measured memory_bytes: 256
import Data.Array.IO
import Data.IORef
import Data.Array
main::IO()
main = do
  _<-getLine
  dc<-getLine
  let dat =map read (words dc)::[Int]
  ar<-newArray (1,100000) 0
  ar_pt<- newIORef ar
  make_histgram ar_pt dat
  i_ar<-freeze ar
  let hist_ls = elems i_ar
  print (solver hist_ls)

make_histgram::IORef (IOArray Int Int) -> [Int] -> IO()
make_histgram ar_pt [] = return ()
make_histgram ar_pt (x:xs) = do
                          ar<- readIORef ar_pt
                          v<-readArray ar x
                          writeArray ar x (v+1)
                          make_histgram ar_pt xs

solver::[Int]->Int
solver ls = let non_zero = filter (\x-> x/=0) ls in
            let ev_length = length (filter (\x-> mod x 2 ==0 ) non_zero) in
            let od_length = length (filter (\x-> mod x 2 /=0 ) non_zero) in
            od_length+ev_length+ (if mod ev_length 2 == 0 then 0 else (-1))

Measured memory_bytes: 25980
#include<iostream>
using namespace std;
int main(){
	int a, b,c = 0;
	cin >> a >> b >> c;
	if (a < b){
		if (b < c){
			cout << "Yes" << endl;
		}
		else{
			cout << "No" << endl;
		}
	}
	else{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 3100
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <utility>
#include <map>
#include <bitset>
#include <numeric>
#define ll long long
using namespace std;
using p = pair<ll, ll>;
ll dx[8]={ 0, 1, 0,-1, 1, 1,-1,-1}; // x軸方向への変位
ll dy[8]={ 1, 0,-1, 0, 1,-1, 1,-1}; // y軸方向への変位

int main(void) {
    ll x, y;
    cin >> x >> y;
    vector<ll> a(1000, 0);
    a[1] = 300000;
    a[2] = 200000;
    a[3] = 100000;
    ll ans = a[x]+a[y];
    if(x==1&&y==1) ans += 400000;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i = ((ll) a); i < ((ll) n); i++)
using namespace std;
typedef long long ll;

int main(void) {
  ll N;
  cin >> N;

  REP(i, 1, 50) {
    if(pow(2LL , i) - 1 <= N && N < pow(2LL, i + 1) - 1) {
      cout << i << endl;
    }
  }
}



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

int main(void){
  int a, b;
  cin >> a >> b;
  int n = gcd(a, b);
  if(n == 1) cout << (ll)a*b << endl;
  else {
    int s = a / n;
    int t = b / n;
    cout << n*s*t << endl;
  }
  return 0;
}

Measured memory_bytes: 3636
N = int(input())
A = list(map(int, input().split()))
count_4 = 0
count_2 = 0
count_1 = 0
for a in A:
  if a % 4 == 0:
    count_4 += 1
  elif a % 2 == 0:
    count_2 += 1
  else:
    count_1 += 1
if count_2 == 0:
  if count_4 + 1 >= count_1:
    print('Yes')
  else:
    print('No')
else:
  if count_4 >= count_1:
    print('Yes')
  else:
    print('No')
  
    


Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define range(a) a.begin(), a.end()

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, R; cin >> N >> R;
  if (N >= 10) {
    cout << R << endl;
  } else {
    cout << R + 100 * (10 - N) << endl;
  }
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
int n, w[101000];
long long s;
int main() {
	int i;
	scanf("%d", &n);
	n++;
	for (i = 1; i < n; i++) {
		scanf("%d", &w[i]);
	}
	for (i = 0; i < n; i++) {
		s += abs(w[i + 1] - w[i]);
	}
	for (i = 1; i < n; i++) {
		printf("%lld\n", s - abs(w[i + 1] - w[i]) - abs(w[i] - w[i - 1]) + abs(w[i + 1] - w[i - 1]));
	}
}

Measured memory_bytes: 1536
<?php

$l = str_split(fgets(STDIN));
array_pop($l);

$n = count($l);

// print_r($l);
// echo $n;

if($l[$n-1]=="s"){
    $l[] = "es";
}else{
    $l[] = "s";
}

foreach($l as $a){
    echo $a."";
}
echo "\n";

Measured memory_bytes: 16256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<int,int> pi;
#define f first
#define s second
#define FAST ios_base::sync_with_stdio(0); cin.tie(0);

int n;
int a[110];
int main() {
	cin >> n;
	for (int i =0;i<n;i++) {
		cin >> a[i];
	}
	sort(a,a+n);
	reverse(a,a+n);
	int sum1 = 0, sum2 = 0;
	for (int i = 0;i<n;i++) {
		if (i%2 == 0) sum1 += a[i];
		else sum2 += a[i];
	}
	cout << sum1 - sum2;
}


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

input = sys.stdin.readline
mod = 1000000007


def ST():
    return input().rstrip()


def I():
    return int(input())


def MI():
    return map(int, input().split())


def LI():
    return list(MI())


def cmb(n, r, mod):
    if r < 0 or r > n:
        return 0
    r = min(r, n - r)
    return g1[n] * g2[r] * g2[n - r] % mod


s = I()

g1 = [1, 1]  # 元テーブル
g2 = [1, 1]  # 逆元テーブル
inverse = [0, 1]  # 逆元テーブル計算用テーブル

for i in range(2, s + 1):
    g1.append((g1[-1] * i) % mod)
    inverse.append((-inverse[mod % i] * (mod // i)) % mod)
    g2.append((g2[-1] * inverse[-1]) % mod)

n = s // 3

ans = 0
for i in range(1, n + 1):
    s -= 3
    ans += cmb(s + i - 1, s, mod)
    ans %= mod

print(ans)


Measured memory_bytes: 9336
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=105,p=1000000007;
const ll P=8ll*p*p;
int read(){
	int f=1,g=0;
	char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-') f=-1;
	for (;isdigit(ch);ch=getchar()) g=g*10+ch-'0';
	return f*g;
}
int T,k;
ll n,m,f[N],ans;
struct num{
	ll x,y;
	num(ll _x=0,ll _y=0){x=_x;y=_y;}
}a[N][N];
void check(ll &x,ll y){x=(x+y<P) ? (x+y) : (x+y-P);}
int main(){
	f[0]=f[1]=1;
	for (int i=2;i<=90;i++) f[i]=f[i-1]+f[i-2];
	a[0][1]=num(1,1);
	for (int i=1;i<90;i++){
		for (int j=1;j<=i;j++)
		a[i][j]=num(a[i-1][j].x+a[i-1][j].y,a[i-1][j].x);
		a[i][i+1]=num(a[i-1][1].x*2+a[i-1][1].y,a[i-1][1].x);
	}
	T=read();
	while (T--){
		scanf("%lld %lld",&n,&m);
		if (n>m) swap(n,m);
		if (n==1){printf("1 %lld\n",m%p);continue;}
		else if (m==2) {puts("1 4");continue;}
		ans=0;
		for (k=1;(f[k+1]<=n)&&(f[k+2]<=m);k++);
		for (int i=1;i<=k;i++){
			ll x=a[k-1][i].x,y=a[k-1][i].y;
			if ((x<=n)&&(y<=m)) check(ans,(m-y)/x);
			if ((x<=m)&&(y<=n)) check(ans,(n-y)/x);
		}
		printf("%d %lld\n",k,ans%p);
	}
	return 0;
}

Measured memory_bytes: 4224
#include <iostream>
#include <vector>
#include <string>
#include <set>
using namespace std;
using ll = long long;

int main() {
    // input
    string S;
    cin >> S;
    set<char> chars;
    for (ll i = 0; i < S.length(); ++i) chars.insert(S[i]);  // チェックするための文字秋雨号
    
    if (chars.size() == 1) {
        // 全部同じ文字
        cout << 0 << "\n";
        return 0;
    }
    
    // calculation
    ll res = 100, times;
    for (auto key = chars.begin(); key != chars.end(); ++key) {
        // prepare simulation
        string str = S;
        bool flag = true;  // 全ての文字が同じでない:true
        times = 1;
        
        while (flag) {
            string vacant;
            flag = false;
            for (ll i = 0; i < str.length()-1; ++i) {
                // shrink
                if (str[i] == *key || str[i+1] == *key) {
                    vacant += *key;
                } else {
                    vacant += str[i];
                    flag = true;
                }
            }
            
            if (flag) {
                // 1回の操作後，違う文字が混じっていた場合
                str = vacant;
                times++;
            }
        }
        
        // update
        res = min(res, times);
    }
    
    cout << res << "\n";
    
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#define LENGTH 100005 // プロセスの制約 100000 のため

// 構造体
// Process という別名をつけている
typedef struct pp {
	char name[100];
	int time;
} Process;

Process Queue[LENGTH]; // Process structの配列
int head, tail, countOfProcess; // head ... 先頭ポインタ, tail ... 末尾ポインタ

void enqueue(Process process)
{
	Queue[tail] = process;
	tail = (tail + 1) % LENGTH;
}

Process dequeue()
{
	Process process = Queue[head];
	head = (head + 1) % LENGTH;
	return process;
}

int min(int a, int b ) { return a < b ? a : b; }

int main()
{
	// 変数は、使用する前に宣言しなければならない。
	// C言語では宣言はプログラムの冒頭でなければならなかったが、 C言語を拡張した C++ ではプログラムのどこでも宣言できる。
	int totalTime = 0, consumption;
	int i, quantum;
	Process process;
	scanf("%d %d", &countOfProcess, &quantum);

	for ( i = 1; i <= countOfProcess; i++)
	{
		// timeは int のためポインタを渡すが、
		// nameは配列なのでそのままでいい
		// （配列名は配列の最初の要素のアドレスを表している）
		scanf("%s", Queue[i].name);
		scanf("%d", &Queue[i].time);
	}
	head = 1; tail = countOfProcess + 1;

	while(head != tail){
		process = dequeue();
		consumption = min(quantum, process.time);
		process.time -= consumption;
		totalTime += consumption;
		if(process.time > 0){
			enqueue(process);
		}else{
			printf("%s %d\n", process.name, totalTime);
		}
	}
	return 0;
}


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

int main() {
    double A, B, H, M; cin >> A >> B >> H >> M;
    static const double pi = 3.141592653589793;
    double degreeH = pi * (H / 6.0 + M / (30.0 * 12.0));
    double degreeM = pi * M / 30.0;
    double degree = degreeH - degreeM;
    double ans = A * A + B * B - 2 * A * B * cos(degree);
    ans = sqrt(ans);
    cout << std::fixed << std::setprecision(10) << ans << endl;
}

Measured memory_bytes: 4076
def main():
    from collections import Counter
    n = int(input())
    s = [input() for _ in range(n)]
    c = Counter(s)
    p = lambda x: print(f'{x} x {c[x]}')
    p('AC')
    p('WA')
    p('TLE')
    p('RE')

if __name__ == '__main__':
    main()


Measured memory_bytes: 16612
import sys
input = sys.stdin.readline
s = input()[:-1]
t = input()[:-1] # 入力が1つ
# map(int, input().split()) # 入力が複数

ans = 'No'
for i in range(len(s)):
    if s == t:
        ans = 'Yes'
        break
    s = s[1:] + s[0]
print(ans)

Measured memory_bytes: 38384
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        int n = scanner.nextInt();
        int max = Integer.MAX_VALUE;
        for (int i = 0; i < n; i++) {
            max = Math.min(max, Integer.numberOfTrailingZeros(scanner.nextInt()));
        }
        System.out.println(max);
    }
}

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

int main(){
  int k,t,c[101],big,sec,a;
  cin>>k>>t;
  for(int i=0;i<t;i++){
    cin>>a;
    c[i]=a*-1;
  }
  c[t]=0;
  t++;
  sort(c,c+t);
  big=0;
  sec=1;
  while(1){
    c[big]-=c[sec];
    c[sec]=0;
    sort(c,c+t);
    if(c[sec]==0)break;
  }
  if(c[big]!=0)cout<<c[big]*-1-1<<endl;
  else cout<<"0"<<endl;
  return 0;
}


Measured memory_bytes: 256
/*<<head>> {{{*/
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
using namespace std;
typedef double db;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define dd(x) cout << #x << " = " << x << ", "
#define de(x) cout << #x << " = " << x << endl
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
//INF = 1 061 109 567 ; INF + INF = 2 122 219 134 ;
//LINF = 4 557 430 888 798 830 399 ; LINF + LINF = 9 114 861 777 597 660 798 ;
const int INF = 0x3f3f3f3f;     // -INF: 0xc0   abs(-INF) = INF + 1
const ll LINF = 0x3f3f3f3f3f3f3f3f;
/*}}}*/                         // zr, zm
const int MOD = (int)1e9+7;     // when MOD = 1e9+7, inv2 = 500000004
const int N = (int)2e5+7;

// ------- 变量 ------- //

int n, q;
vi e[N];
int lz[N], ans[N];

// ------- 函数 ------- //

void dfs(int u, int f = 0) {
    for (auto v : e[u]) if (v != f) {
        if (lz[u]) {
            lz[v] += lz[u];
        }
        dfs(v, u);
    }
    ans[u] += lz[u];
}

void Init() {
    memset(lz, 0, sizeof(lz));
    memset(ans, 0, sizeof(ans));

    rep(i, 1, n) {
        int u, v; scanf("%d%d", &u, &v);
        e[u].pb(v);
        e[v].pb(u);
    }
}

int Solve() {
    while (q--) {
        int p, x;
        scanf("%d%d", &p, &x);
        lz[p] += x;
    }
    dfs(1);
    rep(i, 1, n+1) printf("%d%c", ans[i], " \n"[i==n]);
    return 0;
}

// ------- main ------- //

int main ()
{
    //ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);

    //Pre();
    //int t; scanf("%d", &t); while (t--) {
    while (~scanf("%d%d", &n, &q)) {
    //while(fgets(s, N, stdin)) {   // 注意 fgets 会读入换行符
        //if (n == 0) break;
        //static int kase = 0; printf("Case %d: ", ++kase);
        Init();
        Solve();
        //if (t) puts("");
    }
    return 0;
}

Measured memory_bytes: 24320
S = input()
formula_list = []
total_sum = 0

def calcformula(s) :
    return sum(list(map(int, s.split("+"))))

def stackformula(s, i) :
    
    if len(s) == 1 :
        formula_list.append(s)
        return 
    
    if i >= len(s) :
        return 
    
    formula_y = s[:i] + "+" + s[i:]
    formula_n = s
    
    formula_list.append(formula_y)
    stackformula(formula_y, i + 2)
        
    formula_list.append(formula_n)
    stackformula(formula_n, i + 1)


stackformula(S, 1)
# calculate sum for each formula
for f in set(formula_list) :
    total_sum += calcformula(f)

print(total_sum)

Measured memory_bytes: 3064
from itertools import product

H, W, K = map(int, input().split())
grid = [input() for _ in range(H)]

ans = 0
for row in product([0, 1], repeat=H):
    for col in product([0, 1], repeat=W):
        cnt = 0
        for i in range(H):
            for j in range(W):
                # 当該のマス(i, j)が赤く塗られておらず かつ 黒色のとき
                if row[i] and col[j] and grid[i][j] == '#':
                    cnt += 1
        if cnt == K:
            ans += 1

print(ans)

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

# define Rep(i,a,b) for(int i=a;i<=b;i++)
# define _Rep(i,a,b) for(int i=a;i>=b;i--)
# define RepG(i,u) for(int i=head[u];~i;i=e[i].next)

typedef long long ll;

const int N=2e5+5;

template<typename T> void read(T &x){
   x=0;int f=1;
   char c=getchar();
   for(;!isdigit(c);c=getchar())if(c=='-')f=-1;
   for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+c-'0';
    x*=f;
}

int n;
int a[N];
map<int,int> var;
ll ans;

int main()
{
    read(n);
    Rep(i,1,n)read(a[i]);
    Rep(i,1,n){
        ans+=var[i-a[i]];
        var[i+a[i]]++;
    }
    printf("%lld\n",ans);
    return 0;
}

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

using namespace std;

int main() {

	string s;
	cin >> s;

	int counter = 1;
	int i = 0;
	while (1) {
		if (s[i] != s[i + 1]) { i++; }
		else {
			i++; i++; i++;
			if (i > s.size() ) { break; }
			counter++;
		}

		if (i > s.size() - 1) { break; }
		counter++;
	}

	cout << counter << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
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; }
using ll = long long;
using P = pair<int, int>;
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; }

// UnionFind
struct UnionFind {
  vector<int> d;
  UnionFind(int n=0): d(n,-1) {}

  // ある要素がどの集合に属しているかを返す
  int find(int x) {
    if (d[x] < 0) return x;
    return d[x] = find(d[x]);
  }

  // 集合をマージする、すでに同じ集合ならfalseが返る
  bool unite(int x, int y) {
    x = find(x); y = find(y);
    if (x == y) return false;
    if (d[x] > d[y]) swap(x,y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }

  // 2つの要素が同じ集合か判定する
  bool same(int x, int y) { return find(x) == find(y);}
  
  // ある集合の大きさあを答える
  int size(int x) { return -d[find(x)];}
};

int main() {
    int n, m;
    cin >> n >> m;
    UnionFind tree(n);
    vector<bool> A(n, false);
    vector<bool> AA(n, false);
    for(int i = 0; i < m; ++i) {
        int xx, yy, zz;
        cin >> xx >> yy >> zz;
        xx--; yy--;
        tree.unite(xx, yy);
        A.at(xx) = true; A.at(yy) = true;
    }

    int cnt = 0;
    for(int i = 0; i < n; ++i) {
        if(!A.at(i)) {
            cnt++;
            AA.at(i) = true;
        }
        if(!AA.at(tree.find(i))) {
            cnt++;
            int check = tree.find(i);
            AA.at(check) = true;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 768
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
using namespace std;
int dp[100005];
int main(){
	int n; cin >> n;
	vector<int> a(n);
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	for(int i=0;i<=n;i++){
		dp[i]=1e9;
	}
	dp[0]=0;
	for(int i=1;i<n;i++){
		dp[i]=min(dp[i],dp[i-1]+abs(a[i]-a[i-1]));
		if(i>1){
			dp[i]=min(dp[i],dp[i-2]+abs(a[i]-a[i-2]));
		}
	}
	cout << dp[n-1] << endl;
}

Measured memory_bytes: 1024
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int people = sc.nextInt();
		int height = sc.nextInt();
		List<Integer> heights = new ArrayList<>();

		for(int i = 0;i < people;i++) {
			heights.add(sc.nextInt());
		}

		int count = 0;
		for (Integer h : heights) {
			if(h >= height)
				count++;
		}

		System.out.println(count);
	}
}


Measured memory_bytes: 52660
#include <stdio.h>
#include <stdlib.h>

int main()
{
	//変数宣言
	long n;
	long long int A[100000];
	
	long long int ans , b;
	
	int i;
	int flag = 0;
	
	scanf("%d",&n);
	
	for(i=0;i<n;i++)
	{
		scanf("%lld",&A[i]);
		if(A[i] == 0)
		{
			flag = 1;
		}
	}
	
	if( flag == 1)
	{
		printf("0");
	}
	
	
	else{
		ans = 1;
		for(i=0;i<n;i++)
		{
			b = ans;
			ans *= A[i];
			if(ans < b || ans < 0)
			{
				flag = -1;
				break;
			}
		}
		
		if(flag == -1 || ans > 1000000000000000000)
		{
			printf("-1");
		}
		else
		{
			printf("%lld",ans);
		}
	}
	
	
	return 0;
}

Measured memory_bytes: 2504
#include<stdio.h>

int main(){
		long long int n,k;
		scanf("%lld%lld",&n,&k);
		if(k%2==1){
				printf("%lld",(n/k)*(n/k)*(n/k));
		}
		else{
				long long int tmp=0,tmp2=0;
				tmp=n/k;
				tmp2=(n+k/2)/k;
				printf("%lld",tmp*tmp*tmp+tmp2*tmp2*tmp2);
		}
		return 0;
}


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

int main(){
	string s;
	int k;
	cin >> s >> k;
	int n = s.size();
	string curr;
	vector<string> a;
	for(int i = 0; i < n; ++ i){
		for(int j = i; j < min(n, i + 5); ++ j){
			curr += s[j];
			a.push_back(curr);
		}
		curr = "";
	}
	sort(a.begin(), a.end());
	a.erase(unique(a.begin(), a.end()), a.end());
	cout << a[k - 1] << '\n';
}


Measured memory_bytes: 1660
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        sc.close();

        int sum = 0;
        int tmp = n;
        while(true) {
            sum += tmp % 10;
            if(tmp / 10 > 0) {
                tmp /= 10;
            } else {
                 break;
            }
        }

        if(n % sum == 0) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
using ld = long double;
ll mod = 1000000007;

int main() {
    ll h, w, m;
    cin >> h >> w >> m;
    vector<ll> memo_h(h), memo_w(w);
    map<ll, bool> table;

    rep(i, m) {
        ll x, y;
        cin >> x >> y;
        x--;
        y--;
        memo_h[x]++;
        memo_w[y]++;
        table[x * mod + y] = true;
    }

    ll max_h = 0, max_w = 0;
    rep(i, h) { max_h = max(max_h, memo_h[i]); }
    rep(i, w) { max_w = max(max_w, memo_w[i]); }

    vector<ll> ch, cw;
    rep(i, h) {
        if (memo_h[i] == max_h) {
            ch.push_back(i);
        }
    }
    rep(i, w) {
        if (memo_w[i] == max_w) {
            cw.push_back(i);
        }
    }

    ll sum = max_h + max_w;
    ll counter = 0;
    for (auto fh : ch) {
        for (auto fw : cw) {
            if (!table[fh * mod + fw]) {
                cout << sum << endl;
                return 0;
            }
            if (counter > 2 * m) {
                cout << sum - 1 << endl;
                return 0;
            }
            counter++;
        }
    }
    cout << sum - 1 << endl;

    return 0;
}



Measured memory_bytes: 35012
while True:
    try:
        x = map(float, raw_input().split(" "))
        a = (x[2]*x[4]-x[1]*x[5])/(x[0]*x[4]-x[1]*x[3])
        b = (-x[3]*x[2]+x[0]*x[5])/(x[0]*x[4]-x[1]*x[3])
         
        if a == -0: a = 0
        if b == -0: b = 0
         
        print "%.3f %.3f" % (a, b)
     
    except EOFError:
        break

Measured memory_bytes: 5016
#include<string>
#include<iostream>
#include<cctype>
using namespace std;

string shuffle(string str, int h){
  string str1 = str.substr(0, h);
  string str2 = str.substr(h, str.size() - h);
  str = str2 + str1;

    return str;
}

int main(){
  while (1) {
    string str;
    cin >> str;
    if (str == "-") break;

    int n, h;
    cin >> n;
      for (int i = 0; i < n; i++){
        cin >> h;
        str = shuffle(str, h);
        }
        cout << str << endl;
      }


return 0;
}

Measured memory_bytes: 3160