akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
const int TAM = 100003;
typedef long long ll;

ll arr [TAM], acum [TAM], n;

int main(){

    scanf("%lld",&n);
    for( int i = 0 ; i < n ; i ++ ){
        scanf("%lld",&arr[i]);
        acum[i] = arr[i];
        if( i ) acum[i] += acum[i-1];
    }
    ll del = 0, ca = 0, cb = 0;
    for( int i = 0 ; i < n ; i ++ ){
        if( i%2 ){
            if( acum[i] + del >= 0 ){
                ca += (acum[i] + del + 1);
                del -= (acum[i] + del + 1);
            }
        }else{
            if( acum[i] + del <= 0 ){
                ca += (-(acum[i] + del) + 1);
                del += (-(acum[i] + del) + 1);
            }
        }
    }
    del = 0;
    for( int i = 0 ; i < n ; i ++ ){
        if( i%2 == 0 ){
            if( acum[i] + del >= 0 ){
                cb += (acum[i] + del + 1);
                del -= (acum[i] + del + 1);
            }
        }else{
            if( acum[i] + del <= 0 ){
                cb += (-(acum[i] + del) + 1);
                del += (-(acum[i] + del) + 1);
            }
        }
    }
    ca = min(ca,cb);
    printf("%lld\n",ca);

    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N,M,X,Y; cin>>N>>M>>X>>Y;
    vector<int> x(N);
    for(int i=0;i<N;i++){
        cin>>x[i];
    }
    vector<int> y(M);
    for(int i=0;i<M;i++){
        cin>>y[i];
    }
    sort(x.begin(),x.end());
    sort(y.begin(),y.end());
    if(x[N-1]<y[0]&&X<y[0]&&x[N-1]<Y){
        cout<<"No War";
    }
    else{
        cout<<"War";
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<map>
using namespace std;
int main(void){
  int n,x;
  map<int, int> mp;
  cin>>x>>n;
  int a[n];
  for(int i=0;i<n;i++){
    cin>>a[i];
   	mp[a[i]]++;
  }
  int val1=0,val2=0,ind1=0,ind2=0;
  for(int i=x;;i--){
    if(mp[i]==0){
      val1=abs(x-i);
      ind1=i;
      break;
    }
  }
  for(int i=x;;i++){
    if(mp[i]==0){
      val2=abs(x-i);
      ind2=i;
      break;
    }
  }
  if(val2>=val1){
    cout<<ind1;
  }
  else{
    cout<<ind2;
  }
  return 0;
}
    

Measured memory_bytes: 3640
function main(input) {
	const args = input.split('\n')
    const str1 = args[0]
    const str2 = args[1]
    let cnt = 0
    for (let i=0, len = str1.length; i < len; i++) {
    	if (str1[i] !== str2[i]) cnt++
    }
  	console.log(cnt)
    
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 32832
while True:
  (n,x) = tuple(map(int,input().split()))
  if n == 0 and x == 0:
    break
  else:
    count = 0
    for i in range(1, n + 1):
      for j in range(1, i):
        r = x - i - j
        if 0 < r and r < j :
          count += 1
    print(count)



    


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

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

constexpr int MAX_N = 100;
constexpr int MAX_W = 1e5;

long long dp[MAX_N+1][MAX_W+1];
int w[MAX_N], v[MAX_N];

int main() {
  int N, W;
  cin >> N >> W;
  for (int i{}; i < N; ++i) {
    cin >> w[i] >> v[i];
  }

  for (int i{}; i < N; ++i) {
    for (int j{}; j <= W; ++j) {
      if (j >= w[i])
        chmax(dp[i+1][j], dp[i][j - w[i]] + v[i]);
      chmax(dp[i+1][j], dp[i][j]);
    }
  }

  cout << dp[N][W] << endl;
  return 0;
}


Measured memory_bytes: 78336
N,K=gets.split.map &:to_i
# 期待値の前計算
p=gets.split.map{|i|(i.to_f+1)*0.5}
# 累積和の計算
a=[0]
N.times do |i|
  a<<a[i]+p[i]
end
# 隣接するK項の和の計算
s=0
(N-K+1).times do |i|
  r=a[i+K]-a[i]
  s=[s,r].max
end
puts s


Measured memory_bytes: 20228
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
using namespace std;
//ここから

void solve(){
  int n;
  cin>>n;
  int cnt=0;
  rep(i,n){
    string s=to_string(i+1);
    if(s.size()%2)++cnt;
  }
  cout<<cnt<<endl;
}

int main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
	cout<<fixed<<setprecision(15);
	solve();
	return 0;
}


Measured memory_bytes: 256
import java.security.InvalidParameterException

data class LList(val value: Int, val next: LList?) {
    companion object {
        fun fromIntList(nums: List<Int>): LList {

            var list: LList? = null

            nums.reversed().forEach { num ->
                list = LList(num, list)
            }

            val result = list

            if (result == null) {
                throw InvalidParameterException("empty")
            }

            return result
        }
    }
}


fun main(args: Array<String>) {
    val nums: List<Int> = readLine()!!.trim().map {it.toString().toInt()}

    val numList = LList.fromIntList(nums)

    val total: Long = sumNums(numList, 0, 0)

    println(total)
}

fun sumNums(cur: LList, curTotal: Long, pending: Long): Long {

    if (cur.next == null) {
        return curTotal + pending * 10 + cur.value
    }

    val sum1: Long = sumNums(cur.next, curTotal + pending * 10 + cur.value, 0)
    val sum2: Long = sumNums(cur.next, curTotal, pending * 10 + cur.value)

    return sum1 + sum2
}

Measured memory_bytes: 33760
// 問題の URL を書いておく
// https://atcoder.jp/contests/abc167/tasks/abc167_b

#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <bitset>
#include <numeric>
using namespace std;

//#define ENABLE_PRINT

template<typename T>
T Input()
{
    T v;
    cin >> v;
    return v;
}

template<typename T>
vector<T> InputVector(int n)
{
    vector<T> v(n);
    for(int i = 0; i < n; ++i)
    {
        cin >> v[i];
    }
    return v;
}

template<typename T>
void InputArray(T* begin, int n)
{
    for(int i = 0; i < n; ++i)
    {
        cin >> begin[i];
    }
}

#if defined(ENABLE_PRINT)

#define Print(v) \
do {\
    cout << #v << ": " << v << endl; \
}while(0)

#define PrintVec(v) \
do {\
    for(int __i = 0; __i < v.size(); ++__i) \
    { \
        cout << #v << "[" << __i << "]: " << v[__i] << endl; \
    }\
}while(0)

#else

#define Print(v) ((void)0)
#define PrintVec(v) ((void)0)

#endif

int main(int argc, const char* argv[])
{
    int a = Input<int>();
    int b = Input<int>();
    int c = Input<int>();
    int k = Input<int>();

    int aCount = min(a, k);
    k -= aCount;

    int bCount = min(b, k);
    k -= bCount;

    int cCount = min(c, k);

    cout << aCount - cCount << endl;
    return 0;
}


Measured memory_bytes: 3596
<?php
list($s) = strs();
list($k) = ints();
for ($i = 0; $i < 26; ++$i) $a2n[chr(97 + $i)] = $i;
$n = strlen($s);
// 先頭から順番にaに出来るものをaにする
for ($i = 0; $i < $n; ++$i) {
    $x = $a2n[$s[$i]];
    if ($x === 0) continue;
    if ($k >= 26 - $x) {
        $s[$i] = 'a';
        $k -= 26 - $x;
    }
}
// 残ったkは全部最後の文字に使う
if ($k > 0) $s[$n - 1] = chr(97 + ($a2n[$s[$n - 1]] + $k) % 26);
echo $s . PHP_EOL;
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}
function strs()
{
    return explode(' ', trim(fgets(STDIN)));
}


Measured memory_bytes: 16300
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;

typedef long long ll;
typedef long double ld;

int MOD=1000000007;


int main(){
    ll S,W;
    cin >> S >> W;
    if(S>W) cout << "safe" << endl;
    else cout << "unsafe" << endl;
    }


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

int main()
{
  int h, w;
  cin >> h >> w;

  int joi[100][100];
  for (int i = 0; i < h; i++){
    int cloud = -1;
    for (int j = 0; j < w; j++){
      char c;
      cin >> c;
      if (c == 'c') cloud = 0;
      joi[i][j] = cloud;
      if (cloud == -1) continue;
      cloud++;
    }
  }

  for (int i = 0; i < h; i++){
    for (int j = 0; j < w; j++){
      cout << joi[i][j] << (j == w - 1 ? "\n" : " ");
    }
  }
}

Measured memory_bytes: 3124
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
#define Add(x, y) x = (x + (y)) % mod
#define Mult(x, y) x = (x * (y)) % mod

signed main(){
    int S,W; cin>>S>>W;
    if(S>W) Out("safe");
    else Out("unsafe");
}

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

typedef long long ll;
typedef unsigned long long ull;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout.precision(12);
    cout.setf(ios_base::fixed, ios_base::floatfield);
    
    string s;
    cin >> s;

    int a[4];
    for(int i=0;i<4;i++) a[i] = s[i]-'0';

    for(int i=0;i<8;i++){
        int v = a[0];
        for(int j=1;j<=3;j++){
            if(i&(1<<j-1)) v+=a[j];
            else         v-=a[j];
        }
        if(v==7){
            cout << a[0];
            for(int j=1;j<=3;j++) cout << ((i&(1<<j-1))?'+':'-') << a[j];
            cout << "=7" << endl;
            return 0;
        }
    }
    
    return 1;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vs = vector<string>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
typedef vector<pii> vp;
typedef vector<tiii> vt;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
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; }

bool dp[110000];

int main () {
  int n, k;
  cin >> n >> k;
  vi a(n);
  rep(i,n) cin >> a[i];
  
  for (int i = 1; i <= k; ++i) {
    for (int j = 0; j < n; ++j) {
      if (i-a[j] >= 0) dp[i] |= !dp[i-a[j]];
    }
  }

  if (dp[k]) puts("First");
  else puts("Second");
  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int h, w, n, a[10005];
int mp[105][105], zhong, cnt;
int main()
{
    scanf("%d%d%d", &h, &w, &n);
    for (int i = 1; i <= n; i++) {
        scanf("%d", &a[i]);
    }
    zhong = 1; cnt = a[1];
    for (int i = 0; i < h; i++) {
        if (i & 1) {
            for (int j = w - 1; j >= 0; j--) {
                if (cnt > 0) {
                    mp[i][j] = zhong;
                    cnt--;
                }
                else {
                    zhong++;
                    mp[i][j] = zhong;
                    cnt = a[zhong] - 1;
                }
            }
        }
        else {
            for (int j = 0; j < w; j++) {
                if (cnt > 0) {
                    mp[i][j] = zhong;
                    cnt--;
                }
                else {
                    zhong++;
                    mp[i][j] = zhong;
                    cnt = a[zhong] - 1;
                }
            }
        }
    }
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            printf("%d%c", mp[i][j], j == w - 1 ? '\n' : ' ');
        }
    }
    return 0;
}


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

#define ll long long int

int main() {
    ll n, w, weight, value;
    cin>>n>>w;
    vector<ll> dp(w + 1, 0);
    for(int i=0; i<n; i++) {
        cin>>weight>>value;
        for(int j = w - weight; j >= 0; j--)
            dp[j + weight] = max(dp[j + weight], dp[j] + value);
    }
    cout<<dp[w]<<endl;
    return 0;
}

Measured memory_bytes: 1024
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int k = sc.nextInt();
		int[] commondivisor = new int[a+1];
		int number = 0;
		int kthnumber = 0;
		for(int i = a; i >= 1; i--) {
			if(a % i == 0 && b % i == 0) {
				commondivisor[i] = i;
			}
		}
		for(int i = a; i >= 1;i--) {
			if(commondivisor[i] != 0) {
				number += 1;
			}
			if(number == k) {
				kthnumber = i;
				break;
			}
		}
		System.out.println(commondivisor[kthnumber]);
	}

}


Measured memory_bytes: 22996
#include<stdio.h>
#define N 100
#define INFTY (1<<21)
#define WHITE 0
#define GRAY 1
#define BLACK 2
#define NON -1

void dijkstra();

int M[N][N],d[N];
int n;

int main(){
  int i,j,u,k,v;
  
  scanf("%d",&n);

  for(i=0;i<n;i++){
    for(j=0;j<n;j++) M[i][j]=INFTY;
  }

  
  for(i=0;i<n;i++){
    scanf("%d %d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d",&v);
      scanf("%d",&M[u][v]);
    }
  }

  dijkstra();
  
  for(i=0;i<n;i++){
    printf("%d %d\n",i,d[i]);
  }
  
  return 0;
}



void dijkstra(){
  int u,min;
  int i;
  int color[N];

  //初期化
  for(i=0;i<n;i++){
    d[i]=INFTY;
    color[i]=WHITE;
  }
  
  d[0]=0;
  

  while(1){
    min=INFTY;
    u=NON;
    //進路決め
    for(i=0;i<n;i++){
      if(min>d[i] && color[i]!=BLACK){
        u=i;
        min=d[i];
      }
    }
    if(u==NON) break;
    color[u]=BLACK;
    //次の節点の設定
    for(i=0;i<n;i++){
      if(color[i]!=BLACK && M[u][i]!=INFTY)
      if(d[i]>M[u][i]+d[u]){
        d[i]=M[u][i]+d[u];
        color[i]=GRAY;
      }
    }
  }

}



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

public class ABC153_C {
    private static void Main(string[] args) {
        var k = Read1LineAsIntArray()[1];
        var h = Read1LineAsLongArray();

        var answer = h.OrderByDescending(x => x).Skip(k).Sum();
        Console.WriteLine(answer);
    }
  
    private static int[] Read1LineAsIntArray() => Console.ReadLine().Trim().Split().Select(x => int.Parse(x)).ToArray();
    private static long[] Read1LineAsLongArray() => Console.ReadLine().Trim().Split().Select(x => long.Parse(x)).ToArray();
}

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


int main() {
	int n;
	cin >> n;
	int* x=new int[n];
	int k;
	for (int i = 0; i < n; i++)cin >> x[i];
	sort(x, x + n);
	//for (int i = 0; i < n; i++)cout << x[i];
	k = x[0];
	int num = 1;
	int sum = 0;
	for (int i = 1; i < n; i++) {
		if (x[i] == k) {
			num++;
		}
		else {
			if (num % 2)sum++;
			k = x[i];
			num = 1;
		}
	}
	if (num % 2)sum++;
	cout << sum;
	return 0;
}

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

int main(){
    int H, W, M;
    std::cin >> H >> W >> M;
    std::map< std::string, int > bomb_pos;
    //std::vector< std::vector< int > > bomb_pos(H);
    std::vector< int > H_bomb_cnt(H);
    std::vector< int > W_bomb_cnt(W);
    
    for(int i=0; i<M; i++){
        int tmp_h, tmp_w;
        std::cin >> tmp_h >> tmp_w;
        tmp_h--;
        tmp_w--;
        H_bomb_cnt[tmp_h]++;
        W_bomb_cnt[tmp_w]++;
        std::ostringstream oss;
        oss << tmp_h << "_" << tmp_w;
        std::string tmp_s = oss.str();
        //bomb_pos[tmp_h].push_back(tmp_w);
        bomb_pos[tmp_s] = 1;
    }
    
    int H_max = 0;
    std::vector< int > H_maxpos;
    int W_max = 0;
    std::vector< int > W_maxpos;
    for(int i=0; i<H; i++){
        if(H_max < H_bomb_cnt[i]){
            H_maxpos.assign(1, i);
            H_max = H_bomb_cnt[i];
        }else if(H_max == H_bomb_cnt[i]){
            H_maxpos.push_back(i);
        }
    }
    for(int i=0; i<W; i++){
        if(W_max < W_bomb_cnt[i]){
            W_maxpos.assign(1, i);
            W_max = W_bomb_cnt[i];
        }else if(W_max == W_bomb_cnt[i]){
            W_maxpos.push_back(i);
        }
    }
    
    for(int i=0; i<H_maxpos.size(); i++){
        for(int j=0; j<W_maxpos.size(); j++){
            std::ostringstream oss;
            oss << H_maxpos[i] << "_" << W_maxpos[j];
            std::string tmp_s = oss.str();
            auto itr = bomb_pos.find(tmp_s);
            if(itr == bomb_pos.end()){
                std::cout << H_max + W_max << std::endl;
                return 0;
            }
        }
    }
    
    std::cout << H_max + W_max - 1 << std::endl;
    
    
    return 0;
    
}


Measured memory_bytes: 33228
#include "bits/stdc++.h"
using namespace std;

int N, M;
int p[10];
pair<int, int> AB[50];

int ans = 1;
void dfs(int pos, int mask) { 
    //順列生成. pos:既に決定している個数, mask:残りの数の集合
    if (pos == N) { //生成した順列に従い処理
        if (p[0] != 0) return;
        for (int i = 1; i < N; i++) {
            bool flag = false;
            for (int j = 0; j < M; j++) {
                if (make_pair(p[i - 1], p[i]) == AB[j] || make_pair(p[i], p[i - 1]) == AB[j]) {
                    flag = true;
                }
            }
            if (!flag) {
                ans--;
                break;
            }
        }
        return;
    }
    for (int i = 0; i < N; i++) {
        if (mask & (1 << i)) { //iが未使用のとき
            p[pos] = i;
            dfs(pos + 1, mask ^ (1 << i)); //iを使用済にする
        }
    }
}

int main() {
    cin >> N >> M;
    for (int i = 0; i < M; i++) {
        cin >> AB[i].first >> AB[i].second;
        AB[i].first--;
        AB[i].second--;
    }

    for (int i = 1; i < N; i++) ans *= i;
    dfs(0, (1 << N) - 1);
    cout << ans << endl;
}

Measured memory_bytes: 256
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

s = input()
res = 0
ans = 0
for i in range(3):
    if s[i] == 'R':
        res += 1
    else:
        ans = max(ans, res)
        res = 0
print(max(ans,res))

Measured memory_bytes: 10100
# B - K-th Common Divisor

A, B, K = map(int, input().split())

def gcd(x, y):
    if x==0:
        return y
    else:
        return gcd(y%x, x)

gcdAB = gcd(A, B)

cdlist = []
for i in range(1, int(gcdAB**0.5)+1)[::-1]:
    if gcdAB%i==0:
        cdlist.append(i)
        if gcdAB//i!=i: # 平方数じゃなければ、N/iも足す
            cdlist.append(gcdAB//i)

cdlist.sort(reverse=True)

print(cdlist[K-1])

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 >& p) {
  os << "{" <<p.first << ", " << p.second << "}";
  return os;
}
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; }

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = 1'000'000'007;
// const ll MOD = 998244353;
const double PI = acos(-1.0);
/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    ll H, W, M;
    cin >> H >> W >> M;
    vec<int> cntx(H,0), cnty(W,0);
    map<l_l, int> mp;
    vector<l_l> cnt_x;
    vector<l_l> cnt_y(1, {-1,-1});
    rep(i,M){
        int h, w;
        cin >> h >> w;
        h--; w--;
        cntx[h]++;
        cnty[w]++;
        mp[{h,w}]++;
    }
    rep(i,H)cnt_x.emplace_back(cntx[i], i);
    rep(j,W)cnt_y.emplace_back(cnty[j], j);
    sort(all(cnt_x), greater<>());
    sort(all(cnt_y));
    vector<int> kouho_y;
    for(int i = W; i >= 0; i--){
        kouho_y.emplace_back(cnt_y[i].second);
        if(cnt_y[i].first != cnt_y[i-1].first)break;
    }
    ll maxxy = cnt_y.back().first;
    ll ans = 0;
    rep(i,H){
        int idx = cnt_x[i].second;
        ll tmp = cnt_x[i].first;
        if(ans >= tmp + maxxy)continue;
        for(auto y: kouho_y){
            chmax(ans, tmp + maxxy - (mp[{idx,y}] > 0));
            if(ans >= tmp + maxxy)break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 41336
#include<stdio.h>

 int main(void){

   int a,b;

   scanf("%d %d",&a,&b);

   if(a<b){

  printf("a < b\n");

 }

 if(a>b){

  printf("a > b\n");

 } 

 if(a==b){

  printf("a == b\n"); 

 }

 return 0;

}

Measured memory_bytes: 580
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
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; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    vll a(n);
    for (ll i = 0; i < n; i++) {
        cin >> a[i];
    }
    if (!(n & 1)) {  // n: even
        vll evena(n + 1, 0), odda(n + 1, 0);
        for (ll i = 0; i < n; i++) {
            evena[i + 1] = evena[i];
            odda[i + 1] = odda[i];
            if (i & 1) odda[i + 1] += a[i];
            else evena[i + 1] += a[i];
        }
        ll ans = odda.back();
        for (int i = 0; i < n; i += 2) {
            ll tmp = evena[i + 1] + (odda.back() - odda[i + 2]);
            chmax(ans, tmp);
        }
        cout << ans << '\n';
    } else {
        vvll dp(8, vll(n + 1, -HIGHINF));
        dp[2][0] = 0;
        for (ll i = 0; i < n; i++) {
            dp[1][i + 1] = dp[2][i] + a[i];
            dp[2][i + 1] = max(dp[0][i], dp[1][i]);
            dp[3][i + 1] = dp[4][i] + a[i];
            dp[4][i + 1] = max(dp[2][i], dp[3][i]);
            dp[5][i + 1] = dp[6][i] + a[i];
            dp[6][i + 1] = max(dp[4][i], dp[5][i]);
        }

        // for (int i = 0; i < 8; i++) DEBUG_VLL(dp[i])
        cout << max(dp[4][n], dp[5][n]) << '\n';
    }
    return 0;
}


Measured memory_bytes: 18772
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
	int n;
	int d[4];
	int ans[12];
	int tmp;
	cin>>n;
	for(int i=0;i<3;i++)cin>>d[i];
	if(n==3)d[3]=max(max(d[0],d[1]),d[2])*10;
	else cin>>d[3];
	sort(d,d+4);
	if(n>3){
		for(int i=0;i<n-4;i++){
			cin>>tmp;
			if(d[3]>tmp)d[3]=tmp;
			sort(d,d+4);
		}
	}
	int c=0;
	int tmp2;
	for(int i=0;i<4;i++){
		for(int j=0;j<4;j++){
			if(i!=j){
				tmp=d[i];
				tmp2=1;
				while(tmp>0)tmp2*=10,tmp/=10;
				ans[c]=d[j]*tmp2+d[i];
				c++;
			}
		}
	}
	sort(ans,ans+12);
	//for(int i=0;i<4;i++)cout<<"$"<<d[i]<<endl;
	//for(int i=0;i<12;i++)cout<<"#"<<ans[i]<<endl;
	cout<<ans[2]<<endl;
	return 0;
}


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

#define sysp system("pause")
#define int long long

int q,l,r,cumsum[101010];//nを含めて

bool isprime(int a){
	for(int i=2;i*i<=a;i++){
		if(a%i==0)return false;
	}
	return true;
}

void init(){
	cumsum[1]=0;
	for(int i=3;i<=100000;i+=2){
		if(isprime(i)&isprime((i+1)/2))cumsum[i]=cumsum[i-2]+1;
		else cumsum[i]=cumsum[i-2];
	}
	/*for(int i=0;i<=20;i++){cerr<<i<<' '<<cumsum[i]<<endl;}*/
	//cerr<<isprime(4)<<endl;
}

main(){
	init();
	cin>>q;
	for(int i=0;i<q;i++){
		cin>>l>>r;
		cout<<cumsum[r]-cumsum[l-2]<<endl;
	}
	sysp;
}

Measured memory_bytes: 1656
#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <ctime>
#include <algorithm>
#include <sstream>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <cstdlib>
#include <cstdio>
#include <iterator>
#include <functional>
#include <bitset>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
clock_t __my_start_clock = clock();
#else
#define eprintf(...)
#endif

#define TIMESTAMP(x) eprintf("["#x"] Time : %.3lf s.\n", (clock() - __my_start_clock)*1.0/CLOCKS_PER_SEC)
#define TIMESTAMPf(x,...) eprintf("[" x "] Time : %.3lf s.\n", __VA_ARGS__, (clock() - __my_start_clock)*1.0/CLOCKS_PER_SEC)

using namespace std;

#ifdef LOCAL
static struct __timestamper {
  string what;
  __timestamper(const char* what) : what(what){};
  __timestamper(const string& what) : what(what){};
  ~__timestamper(){
    TIMESTAMPf("%s", what.data());
	}
} __TIMESTAMPER("end");
#else 
struct __timestamper {};
#endif

typedef long long ll;
typedef long double ld;

int main() {
#ifdef LOCAL
  freopen("a.in", "r", stdin);
  freopen("a.out", "w", stdout);
#endif

  auto read = [] () -> pair<int, int> {
    char s[100];
    scanf("%s", s);
    int p2, p5;
    p2 = p5 = 0;
    long long x = 0;
    bool have_dot = false;
    for (int i = 0; s[i]; i++) {
      if (s[i] == '.') {
        have_dot = true;
      } else {
        x = 10 * x + s[i] - '0';
        if (have_dot) {
          p2--, p5--;
        }
      }
    }

    while (x % 2 == 0) {
      p2++;
      x /= 2;
    }
    while (x % 5 == 0) {
      p5++;
      x /= 5;
    }

    return {p2, p5};
  };

  int n;
  while (scanf("%d", &n) == 1) {
    map<pair<int, int>, int> cnt;
    for (int i = 0; i < n; i++) {
      cnt[read()]++;
    }

    ll ans = 0;

    for (auto [a, c1] : cnt) {
      for (auto [b, c2] : cnt) {
        if (a.first + b.first >= 0 && a.second + b.second >= 0) {
          if (a == b) {
            ans += c1 * 1LL * (c1 - 1);
          } else {
            ans += c1 * 1LL * c2;
          }
        }
      }
    }
    ans /= 2;
    printf("%lld\n", ans);
  }

  return 0;
}


Measured memory_bytes: 3796
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 5005;
const ll mod =1e9+7;
int fr[N],to[N],val[N];
ll d[N];
int main()
{
    int n,m,p;
    scanf("%d%d%d",&n,&m,&p);
    for(int i=0; i<m; i++)
    {
        scanf("%d%d%d",&fr[i],&to[i],&val[i]);
        fr[i]--,to[i]--,val[i]-=p;
    }
    for(int i=1; i<n; i++)
        d[i]=-1e18;

   for(int i=0;i<n;i++)
    for(int j=0;j<m;j++)
   {
       if(d[fr[j]]==-1e18)continue;
       d[to[j]]=max(d[to[j]],d[fr[j]]+val[j]);
   }
   for(int i=0;i<n;i++)
    for(int j=0;j<m;j++)
   {
       if(d[fr[j]]==-1e18)continue;
        if(d[fr[j]]+val[j]>d[to[j]])
            d[to[j]]=1e18;
   }
    if(d[n-1]==1e18)
        puts("-1");
    else
        printf("%lld\n",d[n-1]<0?0:d[n-1]);
    return 0;
}


Measured memory_bytes: 384
N, M = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(M)]
P = list(map(int, input().split()))

ans = 0
for bit in range(2 ** N):
    ons = set([i + 1 for i in range(N) if bit >> i & 1])
    flg = True
    for i in range(M):
        k, *s = X[i]
        p = P[i]
        flg &= len(set(s) & ons) % 2 == p
    ans += int(flg)
    
print(ans)


Measured memory_bytes: 45788
#encoding=utf-8

me,ans = [],[]
x = input()
y = input()
for i in xrange(y):
    me.append(map(int,raw_input().split(",")))

for i in xrange(x):
    i += 1
    for j in xrange(y):
        if i == me[j][0]:
            i = me[j][1]
        elif i == me[j][1]:
            i = me[j][0]

    ans.append(i)
for i in xrange(x):
    for j in xrange(x):
        if i + 1 == ans[j]:
            print j + 1

Measured memory_bytes: 6360
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <stack>
#include <math.h>
#include <bitset>
#include <algorithm>
#include <iomanip>
#define ll long long int
#define add push_back

using namespace std; 

map<int,set<int> > graph;
map<int, bool> used;

void dfs(int curr, int &value){
    used[curr] = 1;
    for(set<int> :: iterator it = graph[curr].begin(); it != graph[curr].end(); it++){
        int val = *it;
        if(!used[val])
            dfs(val, ++value);
    }
}

int main() {

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

    int T;  
    //cin >> T;
    T = 1;
    while(T--){
        int n,m; cin >> n >> m;
        for(int i = 0; i < m; i++){
            int a,b; cin >> a >> b;
            graph[a].insert(b);
            graph[b].insert(a);
        }       
        int answ = 0;
        for(int i = 1; i <= n; i++){
            if(!used[i]){
                int value = 1;
                dfs(i,value);
                answ = max(answ, value);
            }
        }
        cout << answ << endl;
    }
    return 0;
}

Measured memory_bytes: 69244
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<map>
#include<cmath>
#define ll long long
using namespace std;
ll h,w,ans;
int main()
{
    scanf("%lld%lld",&h,&w);
    if(h==1||w==1)
    {
        printf("1");
    }
    else if(h&1&&w&1)
    {
        printf("%lld",h*w/2+1);
    }
    else
    {
        printf("%lld",h*w/2);
    }
    return 0;
}


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a/gcd(a, b) * b;
}

int main()
{
    cout << fixed << setprecision(15);
    ll N;
    cin >> N;

    ll ans = 0;
    for(ll a=1; a<=N; a++){
        if(N%a == 0){
            ans += N/a - 1;
        }
        else{
            ans += N/a;
        }
    }

    cout << ans << endl;
    return 0;
}

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

int main(void) {
	const char *SEP = " ";
	char input_str[3];

	fgets(input_str, sizeof(input_str), stdin);

	if (input_str[0] == '1') {
		printf("0\n");
	}
	else {
		printf("1\n");
	}

	return 0;
}


Measured memory_bytes: 1480
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String S = sc.next();
    char[] s = S.toCharArray();
    int ans = 1;
    
    for(int i = 0; i < n-1; i++){
      if(s[i] != s[i+1]){
        ans++;
      }
    }

      System.out.println(ans);
    
  }  
}

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

P func(int x){
    int a;
    int b = x % 10;
    while(x){
        a = x;
        x /= 10;
    }
    return P(a, b);
}

int main(){
    int n;
    cin >> n;
    map<P, int> freq;
    for(int i = 1; i <= n; i++){
        freq[func(i)]++;
    }
    ll ans = 0;
    for(int i = 1; i <= n; i++){
        P p = func(i);
        ans += freq[P(p.second, p.first)];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.math.*;

public class Main{

  final static BigInteger CONST = BigInteger.valueOf(1000000000L+7);
  final static BigInteger TWO = BigInteger.valueOf(2L);

  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    Integer[] NM = Arrays.stream(in.readLine().split(" ")).map(Integer::parseInt).toArray(Integer[]::new);
    int N = NM[0];
    int M = NM[1];
    if(Math.abs(N-M)>1){
      System.out.println(0);
      return ;
    }

    BigInteger nRes = BigInteger.ONE;
    for(int i=1;i<=N;i++){
      nRes = BigInteger.valueOf(i).multiply(nRes).mod(CONST);
    }

    BigInteger mRes = BigInteger.ONE;
    for(int i=1;i<=M;i++){
      mRes = BigInteger.valueOf(i).multiply(mRes).mod(CONST);
    }

    if(N==M){
      System.out.println(nRes.multiply(mRes).multiply(TWO).mod(CONST));
    }else{
      System.out.println(nRes.multiply(mRes).mod(CONST));
    }
  }
}


Measured memory_bytes: 48412
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <functional>
using namespace std;
string s;
int main() {
	cin >> s;
	int cnt = 0;
	for(int i=0; i<s.size()-1; ++i){
		if (s[i] != s[i + 1]) cnt++;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 512
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int counter = 0;
		for(int i = 0; i <= s.length() - 2; i++) {
			if(s.charAt(i) != s.charAt(i + 1))
				counter++;
		}
		System.out.println(String.valueOf(counter));
	}
}

Measured memory_bytes: 13720
#include<bits/stdc++.h>
using namespace std;
 
int main(){
    int n;
    cin>>n;
    if(n%10==2 ||n%10==4 || n%10==5 || n%10==7 || n%10==9 )
        cout<<"hon"<<endl;
    if(n%10==0 ||n%10==1 || n%10==6 || n%10==8)
        cout<<"pon"<<endl;
    if(n%10 == 3)
        cout<<"bon"<<endl;
    return 0;
}

Measured memory_bytes: 3572
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <queue>
 
using namespace std;
 
#define pb(n)	push_back(n)
#define mp(n,m) make_pair(n,m)
#define fi 	first
#define se 	second
#define all(r) (r).begin(),(r).end()

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
const int IMAX=((1<<30)-1)*2+1;
const double EPS=1e-10;
//int mod=1000000007;


vector<string> split(string s,char c){
	stringstream ss(s);
	string t;
	vector<string> ret;
	while(getline(ss,t,c)){
		ret.pb(t);
	}
	return ret;
}

vector<vector<string> > split_vss(vector<string> s,char c){
	vector<vector<string> > ret;
	for(int i=0; i<s.size(); i++){
		stringstream ss(s[i]);
		string t;
		vector<string> u;
		while(getline(ss,t,c)){
			u.pb(t);
		}
		ret.pb(u);
	}
	return ret;
}

vector<vector<vector<string> > > split_vsss(vector<vector<string> >  s,char c){
	vector<vector<vector<string> > > ret;
	for(int i=0; i<s.size(); i++){
		vector<vector<string> > w;
		for(int j=0; j<s[i].size(); j++){
			stringstream ss(s[i][j]);
			string t;
			vector<string> u;
			while(getline(ss,t,c)){
				u.pb(t);
			}
			w.pb(u);
		}
		ret.pb(w);
	}
	return ret;
}


int main(){
	string s;
	getline(cin,s);
	set<string> se;
	bool f=false;
	vector<string> vs=split(s,' ');
	vector<vector<string> > vss=split_vss(vs,'.');
	vector<vector<vector<string> > > vsss=split_vsss(vss,',');
	for(int i=0; i<vsss.size(); i++){
		for(int j=0; j<vsss[i].size(); j++){
			for(int k=0; k<vsss[i][j].size(); k++){
				if(vsss[i][j][k].size()>=3&&vsss[i][j][k].size()<=6){
					//if(se.count(vsss[i][j][k])==0){
						if(f)cout<<" ";
						cout<<vsss[i][j][k];
						f=true;
					//	se.insert(vsss[i][j][k]);
					//}
				}
			}
		}
	}
	cout<<endl;
}

Measured memory_bytes: 1240
#include <iostream>

using namespace std;

int main() {
  int N;
  int a[100];

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

  int tmp, cnt = 0;
  int flag = 1;
  while (flag) {
    flag = 0;
    for (int j = N-1; j > 0; j--) {
      if (a[j] < a[j-1]) {
	cnt++;
	tmp = a[j];
	a[j] = a[j-1];
	a[j-1] = tmp;
	flag = 1;
      }
    }
  }

  for (int i = 0; i < N-1; i++) {
    cout << a[i] << " ";
  }
  cout << a[N-1] << endl;
  cout << cnt << endl;
  
  return 0;
}

Measured memory_bytes: 3120
#include <bits/stdc++.h>
using  namespace std;
int count(int x, int y, int max){
  int check = (max-x) + (max-y);
  int count;
  if(check%2==0){
    count = check/2;
  }else{
    count = 1 + (check+1)/2;
  }
  return count;
}
int main(){
  int a, b, c, ans;
  cin >> a >> b >> c;
  if(a>=b && a>=c){
    ans = count(b, c, a);
  }else if(b>=a && b>=c){
    ans = count(a, c, b);
  }else{
    ans = count(a, b, c);
  }
  
  cout << ans << endl;
  return 0;

}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<sstream>
#include<random>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
//const int inf = 1e9 + 7;
int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};
int dx[] = {1, -1, 0, 0, -1, 1, 1, -1};

//const int flo = 100000000;
int isprime(int x) {
    if (x == 0 || x == 1) return 0;
    if (x == 2 || x == 3) return 1;
    if (x % 2 == 0 || x % 3 == 0) return 0;
    if (x < 25) {
        if (x == 9 || x == 15 || x == 21) return 0;
        else return 1;
    }
    for (int i = 5; i <= sqrt(x); i += 2) {
        if (x % i == 0) return 0;
    }
    return 1;
}
int main() {
    int n; cin >> n;
    int c = 0;
    rep(i, n) {
        int x; cin >> x;
        if (isprime(x)) c++;
    }
    cout << c << endl;
}



Measured memory_bytes: 3088
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>
#include <limits>
#include <cassert>
#include <bitset>

using namespace std;

/* template */

using ll = long long;

void debug_out() { std::cout << std::endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cout << "debug: "; debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif

#define rep(i, a, n) for (int i = (int)(a); i < (int)(n); i++)
#define rrep(i, a, n) for (int i = ((int)(n-1)); i >= (int)(a); i--)
#define Rep(i, a, n) for (long long i = (long long)(a); i< (long long)(n); i++)
#define RRep(i, a, n) for (long long i = ((long long)(n-1ll)); i>=(long long)(a); i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}

struct Edge{
    int to;
    ll weight;
    Edge(int t, ll w) : to(t), weight(w){ }
};

struct edge{
    int from;
    int to;
    ll weight;
    edge(int f,int t,ll w) : from(f), to(t), weight(w){ }
};


using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;
using edges = vector<edge>;

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

template <class T>
inline bool chmax(T &a, T b){
    if (a < b){
        a = b;
        return true;
    }
    return false;
}

template <class T>
T lcm(T a, T b){
    return (a*b)/gcd(a,b);
}

bool isPalindrome(string s){
    string t = s;
    reverse(all(t));
    return s==t;
}

constexpr ll LNF = 1LL<<60;

constexpr int INF = 1e9+7;

const double PI=3.14159265358979323846;


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

/* template */

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n,m; cin >> n >> m;
    vector<int> h(n);
    rep(i,0,n) cin >> h[i];
    vector<int> t(n,1);
    rep(i,0,m){
        int a,b; cin >> a >> b;
        a--; b--;
        if(h[a]>h[b]){
            t[b] = -1;
        } else if(h[a]<h[b]){
            t[a] = -1;
        } else if(h[a]==h[b]){
            t[a] = -1;
            t[b] = -1;
        }
    }
    int ans = 0;
    rep(i,0,n){
        if(t[i]>0) ans++;
    }
    cout << ans << endl;
} 

Measured memory_bytes: 3988
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <array>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include<numeric>

using namespace std;

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

long long lcm(long long a,long long b){
    return (a/gcd(a,b))*b;
}

int main() {
    int A,B,C,D,ans=0;
    cin>>A>>B>>C>>D;
    if(max(A,C)<=min(B,D))ans=min(B,D)-max(A,C);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
YL = [[int(i) for i in input().split()] + [j] for j in range(M)]
YL.sort()
ct = 1
for i in range(M):
    if YL[i][0] != YL[i-1][0]:
        ct = 1
    YL[i].append('{:0=6}'.format(YL[i][0]))
    YL[i].append('{:0=6}'.format(ct))
    ct += 1
YL.sort(key=lambda x:x[2])
for i in YL:
    print('%s%s' % (i[3], i[4]))


Measured memory_bytes: 40856
s = input()
chk1 = True
chk2 = True
for i in range(0, len(s)):
    if i % 2 == 0:
        if s[i] == 'L':
            chk1 = False
    else:
        if s[i] == 'R':
            chk2 = False
if chk1 == True and chk2 == True:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define MOD 1000000007
#define MOD2 1000000009
#define endl "\n"
#define pii pair <int, int>
#define pll pair <ll, ll>
#define vll std::vector<int>

int main()
{   
    IOS;
        #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
        #endif


   ll n, k;
   cin >> n >> k;

   ll arr[n + 1] = {0};

   while(k--) {
    ll d;
    cin >> d;
    std::vector<ll> a(d);
    for(int i = 0; i < d; i++) {
        cin >> a[i];
        arr[a[i]] = 1;
    }
   }
   ll cnt = 0;
   for(int i = 1; i <= n; i++) {
    if(arr[i] == 0)
        cnt++;
   }

    cout << cnt << endl; 
        
    


return 0;
}

Measured memory_bytes: 3612
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import java.util.stream.Stream;

public class Main {
    public static void main(String[] args) {
        try (InputReader in = new InputReader(); PrintWriter out = new PrintWriter(System.out)) {
            new Main().solve(in, out);
        }
    }

    private void solve(InputReader in, PrintWriter out) {
        int n = in.nextInt();
        in.nextLine();

        List<Integer> vs = Arrays.stream(in.nextLine().split(" ")).map(Integer::parseInt).collect(Collectors.toList());
        List<Integer> cs = Arrays.stream(in.nextLine().split(" ")).map(Integer::parseInt).collect(Collectors.toList());
        int ans = IntStream.range(0, 1 << n)
                .map(i -> IntStream.range(0, n)
                    .map(j -> (((i >> j) & 1) == 1) ? vs.get(j) - cs.get(j) : 0)
                    .sum()
                )
                .max()
                .getAsInt();
        out.println(ans);
    }
}

class InputReader implements AutoCloseable {
    private final Scanner sc = new Scanner(System.in);

    String next() {
        return this.sc.next();
    }

    int nextInt() {
        return Integer.parseInt(this.sc.next());
    }

    long nextLong() {
        return Long.parseLong(this.sc.next());
    }

    double nextDouble() {
        return Double.parseDouble(this.sc.next());
    }

    String nextLine() {
        return this.sc.nextLine();
    }

    @Override
    public void close() {
        this.sc.close();
    }
}


Measured memory_bytes: 89048