akhauriyash/Code-Regression huggingface dataset:
import itertools
import bisect

def main():
    N = int(input())
    S = input()
    d = {'R': [], 'G': [], 'B': []}
    for i, c in enumerate(S):
        d[c].append(i)
    #print(d)
    #answer = set()
    cnt = 0
    for xx, yy, zz in itertools.permutations(('R', 'G', 'B'), 3):
        x, y, z = d[xx], d[yy], d[zz]
        for i in x:
            y_start = bisect.bisect_left(y, i)
            for jj in range(y_start, len(y)):
                j = y[jj]
                assert i < j
                z_start = bisect.bisect_left(z, j)
                z_point = bisect.bisect_left(z, 2*j-i)
                #print(z_point, z)
                if (len(z) <= z_point) or (z[z_point] - j != j - i):
                    cnt += len(z) - z_start
                else:
                    cnt += len(z) - z_start - 1
                # for kk in range(z_start, len(z)):
                #     k = z[kk]
                #     assert j < k
                #     if k-j > j-i:
                #         #超えたのでもうチェックしなくていい
                #         cnt += len(z) - kk
                #         break
                #     elif k-j == j-i:
                #         cnt += len(z) - kk - 1
                #         break
                #     else:
                #         #assert k > j > i
                #         #answer.add((i+1, j+1, k+1))
                #         cnt += 1
    print(cnt)
    #assert len(answer) == cnt
    #print(answer)

if __name__ == "__main__":
    main()

Measured memory_bytes: 69664
#include "bits/stdc++.h"
using namespace std;
using ll = long long; using pii = pair<int, int>;
const int MOD = (int)1e9 + 7, INF = (1 << 27); const ll INFLL = (1LL << 55);
#define FOR(i,a,b) for(int (i)=(a);i<(int)(b);i++)
#define rep(i,n) FOR(i,0,n)
template<typename T, typename U> inline void chmax(T &x, U y) { if (x < y) x = y; }
template<typename T, typename U> inline void chmin(T &x, U y) { if (x > y) x = y; }


int main() {
    int n; cin >> n;
    string s, t;
    cin >> s >> t;
    reverse(s.begin(), s.end());
    int m = 0;
    FOR(len, 1, n + 1) {
        string ss = s.substr(0, len);
        string tt = t.substr(0, len);
        reverse(ss.begin(), ss.end());
        if (ss == tt) chmax(m, len);
    }

    printf("%d\n", 2 * n - m);
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <functional>
#include <iostream>
#include <numeric>
#include <tuple>
#include <vector>

int main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int n, m;
  std::cin >> n >> m;
  std::vector<int> x(n);
  for (int i = 0; i < n; ++i) std::cin >> x[i];
  std::vector<std::tuple<int, int, int>> ed(m);
  for (int i = 0; i < m; ++i) {
    std::cin >> std::get<1>(ed[i]) >> std::get<2>(ed[i]) >> std::get<0>(ed[i]);
    std::get<1>(ed[i])--;
    std::get<2>(ed[i])--;
  }
  std::sort(ed.begin(), ed.end());
  std::vector<int> uf(n), uf2(n);
  std::vector<int64_t> sum(x.begin(), x.end());
  std::vector<std::vector<std::pair<int, int>>> mg(n);
  std::iota(uf.begin(), uf.end(), 0);
  std::iota(uf2.begin(), uf2.end(), 0);

  std::function<int(int, std::vector<int> &)> Find = [&](int x,
                                                         std::vector<int> &uf) {
    if (x == uf[x]) return x;
    return uf[x] = Find(uf[x], uf);
  };

  std::function<int(int, int, std::pair<int, int>)> Merge =
      [&](int x, int y, std::pair<int, int> e) {
        assert((x = Find(x, uf)) != (y = Find(y, uf)));
        if (mg[x].size() > mg[y].size()) std::swap(x, y);
        uf[x] = y;
        sum[y] += sum[x];
        mg[y].push_back(e);
        mg[y].insert(mg[y].end(), mg[x].begin(), mg[x].end());
        return y;
      };

  std::vector<std::tuple<int, int, int>> others;
  for (auto &e : ed) {
    int w, u, v;
    std::tie(w, u, v) = e;
    if (Find(u, uf) == Find(v, uf)) continue;
    u = Merge(u, v, std::make_pair(u, v));
    if (sum[u] >= w) {
      for (auto e : mg[u]) {
        uf2[Find(e.first, uf2)] = Find(e.second, uf2);
      }
      mg[u].clear();
    }
  }
  std::vector<int64_t> sum2(n);
  for (int i = 0; i < n; ++i) sum2[Find(i, uf2)] += x[i];
  int ans = 0;
  for (auto &e : ed) {
    int w, u, v;
    std::tie(w, u, v) = e;
    if (Find(u, uf2) == Find(v, uf2)) {
      if (sum2[Find(u, uf2)] >= w) ++ans;
    }
  }
  std::cout << m - ans << "\n";
  return 0;
}



Measured memory_bytes: 12104
# coding: utf-8
N, K = map(int, input().split(' '))

R = []
for i in range(N):
    R.append(i + 1)
    
for i in range(K):
    d = input()
    A = list(map(int, input().split(' ')))
    for j in range(len(A)):
        try:
            R.remove(A[j])
        except ValueError:
            pass

print(len(R))


Measured memory_bytes: 9212
main :: IO ()
main = do
  [n, k] <- map read . words <$> getLine :: IO [Int]
  ds <- getContents :: IO String
  let
    s = length . filter id . (zipWith (==) <$> id <*> tail) $ ds :: Int
  print $ (s + 2 * k) `min` (n - 1)


Measured memory_bytes: 4944
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long  n,s=0;
    cin>>n;
    long long sum=0,o,mn=10000000000;
    vector<long long >v;
    for(int i=0;i<n;i++)
    {
        long long  x;
        cin>>x;
        v.push_back(x);


    }
    sort(v.begin(),v.end());
o=v[0];
 while(o<=v[n-1])
    {
 for(int i=0;i<n;i++)
 {

        s+=(abs(v[i]-o)*abs(v[i]-o));

 }
 mn=min(mn,s);
 s=0;
 o++;
    }
    cout<<mn<<endl;

}


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

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

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

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

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

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

fn main() {
    let S = rl();
    let ok = S != "AAA" && S != "BBB";

    println!("{}", if ok { "Yes" } else { "No" })
}


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

int main() {
  int a,b,c;
  cin>>a>>b>>c;
  if((a==b)&&(b==c)){
    cout<<"No"<<endl;
  }
  else if((a+b+c)/2==max(a,max(b,c))){
    cout<<"Yes"<<endl;
  }
  else{
      cout<<"No"<<endl;
     }
     }

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
 
int main(void)
{
    int n, shuffle;
    char str[500];
    char tmp;
    while (1)
    {
        for (int i = 0; i < 500; i++)
        {
            str[i] = '\0';
        }

        scanf(" %s", str);
        if (!strcmp(str, "-"))
        {
            break;
        }

        scanf(" %d", &n);

        for (int i = 0; i < n; i++)
        {
            scanf(" %d", &shuffle);
            for (int j = 0; j < shuffle; j++)
            {
                tmp = str[0];
                for (int k = 0; k < strlen(str) - 1; k++)
                {
                    str[k] = str[k+1];
                }

                str[strlen(str)-1] = tmp;
            }
        }

        printf("%s\n", str);
    }

    return 0;
}


Measured memory_bytes: 2048
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
using namespace std;

int main(){
    vector<int> vec(3);
    int sum = 0, cnt = 0;
    for (int i = 0; i < 3; i++) {
        cin >> vec[i];
        sum += vec[i];
    }
    sort(vec.begin(), vec.end());
    if(vec[0] == vec[1] && vec[1] == vec[2] && vec[2] == vec[0]){
        cout << 0 << endl;
        return 0;
    }
    if(sum % 2 == 0){
        if(vec[2] % 2 != 0) vec[2]++;vec[1]++;cnt++;
        cnt += (vec[2] * 2 - vec[1] - vec[0])/2;
    }
    else{
        if(vec[2] % 2 == 0) vec[2]++;vec[1]++;cnt++;
        cnt += (vec[2] * 2 - vec[1] - vec[0])/2;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
int a,b,d,r;
scanf("%d %d",&a,&b);
double f;
r = a%b;
d = (a-r)/b;
f = 1.0*a/b;
printf("%d %d %lf\n",d,r,f);
return 0;
}

Measured memory_bytes: 636
s = int(input())
a = [s]
i = 0
while True:
    if a[i]%2 == 0:
        tmp = a[i]/2
    else:
        tmp = a[i]*3+1
    if tmp in a:
        break
    i += 1
    a.append(tmp)
print(i+2) 

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

int main(){
    int a,b;
    cin>>a>>b;
    if(a > b){
        cout<<"a > b"<<endl;
    }else if(a < b){
        cout<<"a < b"<<endl;
    }else{
        cout<<"a == b"<<endl;
    } 
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define LINF 3e18+7
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;

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; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

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 double PI = acos(-1.0);
const double EPS = 1e-10;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    set<char> sc;
    REP(i,s.size()) sc.insert(s[i]);
    ll ans = INF;
    for(char c:sc){
        string tmp = s;
        ll sum = 0;
        bool flg = true;
        while(true){
            REP(i,tmp.size()) if(c!=tmp[i]) flg = false;
            if(flg) break;
            else{
                sum++;
                REP(i,tmp.size()){
                    if(c!=tmp[i] && tmp[i+1]==c) tmp[i] = c;
                }
                tmp.pop_back();
            }
            flg=true;
        }
        chmin(ans,sum);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String [] args) {
		Set<String> h = new HashSet<String>();
		Scanner in = new Scanner(System.in);
		
		int n = in.nextInt();
		
		for(int i = 0; i < n; i++) {
			String str = in.next();
			
			
			
			if(str.contains("insert")) {
				h.add(in.next());
				
			}
			
			
			
			else if(h.contains(in.next())) {
					System.out.println("yes");
				}
				
				
			else {
					System.out.println("no");
			}
			}
		}
	}
		


	





Measured memory_bytes: 253384
#include <stdio.h>
#include <string.h>

int main()
{
  char str[2000000];
  int len, sum;
  scanf("%s", str);
  len = strlen(str);
  sum = 0;
  
  for(int i = 0; i < len; i++) {
    sum += (str[i] - '0');
  }
  if (sum % 9 == 0) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }
  return 0;
}
  

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

using namespace std;

int main()
{
	// ------ 1. Initialize, Input ------ //

	int N, W;

	cin >> N >> W;

	vector<int> v(N);
	vector<int> w(N);
	vector<vector<int> > dp(N + 1, vector<int>(W + 1, 0));

	for (vector<int>::size_type i = 0; i < N; i++)
	{
		cin >> v[i] >> w[i];
	}


	// ------ 2. DP Calculate ( dp[i][j] = max(dp[i - 1][j - w[i - 1]] + v[i - 1], dp[i - 1][j]) )------ //

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

	
	// ------ 3. Output ------ //

	cout << dp[N][W] << endl;

	return 0;
}

// Time : O( NW )

Measured memory_bytes: 4964
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 1e9+7;

int main(){
	
	int n; cin>>n;
	for(int i=0; i<2*n; i++){
		if((int)(i*1.08)==n){
			cout << i << endl;
			return 0;
		}
		
	}
	cout << ":(" << endl;
}


Measured memory_bytes: 384
#include<stdio.h>

int main(){
	int n,i,k;
	char s[100],t;
	scanf("%d%s%d",&n,s,&k);
	t=s[k-1];
	for(i=0;i<n;i++){
		if(s[i]!=t)printf("*");
		else printf("%c",s[i]);
	}
	puts("");
	return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <map>
#include <queue>
#include <string>
using namespace std;

int main() {
	const int dx[4] = {0, 0, -1, 1};
	const int dy[4] = {-1, 1, 0, 0};

	map<string, int> memo;
	const string goal = "01234567";
	queue<pair<int, string> > que;
	que.push(make_pair(0, goal));

	while(!que.empty()) {
		int cnt = que.front().first;
		string state = que.front().second;
		que.pop();

		memo[state] = cnt;

		int zero = state.find('0');

		for(int i = 0; i < 4; ++i) {
			int nx = zero % 4 + dx[i];
			int ny = zero / 4 + dy[i];

			if(nx < 0 || ny < 0 || nx >= 4 || ny >= 2)
				continue;

			string next = state;
			swap(next[zero], next[ny * 4 + nx]);

			if(!memo.count(next))
				que.push(make_pair(cnt + 1, next));
		}
	}

	for(string input; getline(cin, input);) {
		for(int pos; (pos = input.find(" ")) != string::npos;)
			input.erase(pos, 1);

		cout << memo[input] << endl;
	}

	return EXIT_SUCCESS;
}

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

 using namespace std;
 typedef long long ll;
 #define rep(i, n) for(int i = 0; i < (int)(n); i++)

 int main() {
   int N, count = 0;
   cin >> N;
   vector<int> A(N);
   rep(i, N) {
     cin >> A.at(i);
     if (A.at(i) % 2 == 1) count++;
   }
   if (count % 2 == 0) cout << "YES" << endl;
   else cout << "NO" << endl;
 }


Measured memory_bytes: 640
{-# LANGUAGE MultiWayIf #-}

import Control.Monad
import Data.Maybe (fromJust)
import qualified Data.ByteString.Char8 as B
import Data.IORef

main :: IO ()
main = do
    [w, h, n] <- map (fst . fromJust . B.readInt) . B.words <$> B.getLine :: IO [Int]
    x1 <- newIORef 0
    x2 <- newIORef w
    y3 <- newIORef 0
    y4 <- newIORef h
    replicateM_ n $ do
        [x, y, a] <- map (fst . fromJust . B.readInt) . B.words <$> B.getLine :: IO [Int]
        xx1 <- readIORef x1
        xx2 <- readIORef x2
        yy3 <- readIORef y3
        yy4 <- readIORef y4
        if  | a == 1 -> writeIORef x1 (max xx1 x)
            | a == 2 -> writeIORef x2 (min xx2 x)
            | a == 3 -> writeIORef y3 (max yy3 y)
            | a == 4 -> writeIORef y4 (min yy4 y)
    xxx1 <- readIORef x1
    xxx2 <- readIORef x2
    yyy3 <- readIORef y3
    yyy4 <- readIORef y4
    print $ max 0 (xxx2 - xxx1) * max 0 (yyy4 - yyy3)


Measured memory_bytes: 508
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>

#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define mod 1000000007
#define inf 1e18+42
#define endl "\n"
#define pi 3.1415926535897932384626433832795028841971693993751058
#define maxn 100005

#define out1(a) cout<<#a<<" "<<a<<endl
#define out2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define out3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl

#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define fori(it,A) for(auto it=A.begin();it!=A.end();it++)

#define ft first
#define sd second
#define pb push_back
#define mp make_pair
#define pq priority_queue
#define all(x) (x).begin(),(x).end()
#define zero(x) memset(x,0,sizeof(x));
#define ceil(a,b) (a+b-1)/b
 
using namespace std;

int binpow(int a, int b) {
    int res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

//START OF CODE ->->->->->->->

void solve()
{
    int p,q,r;
    cin>>p>>q>>r;

    cout<<min(p+q,min(q+r,p+r))<<endl;
}

//END OF CODE ->->->->->->->->

signed main()
{
    fast;
    int t = 1;
    // cin>>t;

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



Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<algorithm>


using namespace std;

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

  for(int i = 0,max=s.size();i<max;i++){
    if(i+1 < max)
      if(s[i]==s[i+1]){
	cout<<i+1<<" "<<i+2<<endl;
	return 0;
      }
    if(i+2<max)
      if(s[i]==s[i+2]){
	cout<<i+1<<" "<<i+3<<endl;
	return 0;
      }
    
	
  }
	
  cout<<"-1 -1"<<endl;
	  
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
#define degreeToRadian(deg) (((deg)/360)*2*M_PI)
#define radianTodegree(rad) (((rad)/2/M_PI)*360)
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; }
using namespace std;
using P = pair<int,int>;
using ll = long long;
const ll INF = 1LL<<60;
const int MOD = 1e9 + 7;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//cin.tie(0);ios::sync_with_stdio(false);
//cout << fixed << setprecision(15) << y << endl;
int main() {
  int n; cin >> n;


  ll sum = 0;
  for (int i = 1; i <= n; i++) {
    sum += (n - 1) / i;
  }

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


Measured memory_bytes: 3632
#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
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")
    };
}


#[allow(unused_mut)]
#[allow(non_snake_case)]
fn main() {
    input! {
        n: usize,
        m: usize,
        x: [i64; m],
    }
    let mut x = x;
    if m as i64 - n as i64 <= 0 {
        println!("0");
        return;
    }
    x.sort();
    let mut dist = Vec::with_capacity(m-1);
    for ind in 1..m {
        dist.push(x[ind] - x[ind - 1]);
    }
    dist.sort();
    let mut sum = 0;
    for ind in 0..m-n {
        sum += dist[ind];
    }
    println!("{}", sum);
}

Measured memory_bytes: 8444
#include <bits/stdc++.h>
using namespace std;
 
typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<double> VD;
#define MP make_pair
#define PB push_back
#define X first
#define Y second
 
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ITER(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cout << #a << " = " << a << endl;

const double PI = acos(-1.0);
const LL INF = 1e9 + 47;
const LL LINF = INF * INF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

	string s;
	cin >> s;
	
	bool ok = 1;
	FOR(i, 0, SZ(s) - 1)
		if (s[i] == s[i + 1] && (s[i] >= '0' && s[i] <= '9'))
			ok = 0;
	if (ok)
		cout << "Good";
	else
		cout << "Bad";
	
	cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
	return 0;
}


Measured memory_bytes: 256
#!/usr/bin/ruby
class TLLI
	def initialize
		@trianies=[nil,[0,0,0]]
	end
	def root_triany
		1
	end
	def allocate_triany
		siz=@trianies.size
		@trianies[siz]=[0,0,0]
		return siz
	end
	def set_a(id,value)
		return if !@trianies[id]
		@trianies[id][0]=value
	end
	def set_b(id,value)
		return if !@trianies[id]
		@trianies[id][1]=value
	end
	def set_c(id,value)
		return if !@trianies[id]
		@trianies[id][2]=value
	end
	def get_a(id)
		return if !@trianies[id]
		@trianies[id][0]
	end
	def get_b(id)
		return if !@trianies[id]
		@trianies[id][1]
	end
	def get_c(id)
		return if !@trianies[id]
		@trianies[id][2]
	end
end

class SETI <TLLI # a=>key, b=>left, c=>right
	def set_entry(key)
		x=root_triany
		y=0
		while x!=0&&!(x==root_triany&&get_a(x)==0) #fixme
			y=x
			if key<get_a(x)
				x=get_b(x)
			else
				x=get_c(x)
			end
		end
		if y==0
			set_a(root_triany,key)
		else
			leaf=allocate_triany
			set_a(leaf,key)
			if key<get_a(y)
				set_b(y,leaf)
			else
				set_c(y,leaf)
			end
		end
	end
	def find_entry(key)
		t=root_triany
		loop{
			return true if key==get_a(t)
			if key<get_a(t)
				t=get_b(t)
				return false if t==0
			else
				t=get_c(t)
				return false if t==0
			end
		}
	end
	def delete_entry(key)
		left=false
		prev=nil
		t=root_triany
		loop{
			break if key==get_a(t)
			prev=t
			if key<get_a(t)
				t=get_b(t)
				left=true
				return false if t==0
			else
				t=get_c(t)
				left=false
				return false if t==0
			end
		}
		if get_b(t)>0&&get_c(t)>0
			children=inorder_internal(get_c(t))+[t]
			set_a(t,get_a(children[0]))

			prev=children[1]
			#left of parent of t
			if prev!=t
				set_b(prev,0)
				left=true
			else
				left=false
			end
			t=children[0]
		end
		if t==root_triany
			if get_b(root_triany)>0
				set_a(root_triany,get_a(get_b(root_triany)))
				set_c(root_triany,get_c(get_b(root_triany)))
				set_b(root_triany,get_b(get_b(root_triany)))
			elsif get_c(root_triany)>0
				set_a(root_triany,get_a(get_c(root_triany)))
				set_b(root_triany,get_b(get_c(root_triany)))
				set_c(root_triany,get_c(get_c(root_triany)))
			end
		else
			raise if !prev
			if get_b(t)+get_c(t)>0
				n=get_b(t)+get_c(t)
				if left
					set_b(prev,n)
				else
					set_c(prev,n)
				end
			else
				if left
					set_b(prev,0)
				else
					set_c(prev,0)
				end
			end
		end
	end
	def inorder_internal(t)
		t==0 ? [] : inorder_internal(get_b(t))+[t]
	end
	def print_preorder(t)
		return if t==0
		Kernel.print " #{get_a(t)}"
		print_preorder(get_b(t))
		print_preorder(get_c(t))
	end
	def print_inorder(t)
		return if t==0
		print_inorder(get_b(t))
		Kernel.print " #{get_a(t)}"
		print_inorder(get_c(t))
	end
	def print_postorder(t)
		return if t==0
		print_postorder(get_b(t))
		print_postorder(get_c(t))
		Kernel.print " #{get_a(t)}"
	end
	def print
		print_inorder(root_triany);puts
		print_preorder(root_triany);puts
	end
end

seti=SETI.new
gets.to_i.times{
	a=gets.split
	if a[0]=='insert'
		seti.set_entry(a[1].to_i)
	elsif a[0]=='find'
		puts seti.find_entry(a[1].to_i) ? :yes : :no
	elsif a[0]=='delete'
		seti.delete_entry(a[1].to_i)
	elsif a[0]=='print'
		seti.print
	end
}

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

using namespace std;

#define int long long
#define MOD 1000000007

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()

#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
template <typename T>
void print(T x)
{
    std::cout << x << '\n';
}

//typedef long long ll;
#define TENNINE 1000000005
#define TENFIVE 100005
//#define int long long

int x, y, z;

signed main()
{
    cin >> x >> y >> z;

    cout << z << " " << x << " " << y << endl;

    return 0;
}


Measured memory_bytes: 256
use text_io::*;
use std::collections::*;
use std::process::exit;

fn main() {
    let mut a:usize = read!();
    let mut b:usize = read!();
    let mut c:usize = 0;
    let mut d:usize = 0;
    let mut e:usize = 1;
    let mut f:usize = 1;
    for i in 0..a {
        c+=b*e;
        e*=10;
    }
    for i in 0..b {
        d+=a*f;
        f*=10;
    }
    if c<=d {
        println!("{}",d);
    }
    else {
        println!("{}",c);
    }
}

Measured memory_bytes: 2004
#include<bits/stdc++.h>
using namespace std;
int main(){
    int m,d,ans=0;
    cin>>m>>d;
    for(int i=1;i<=m;i++){
        for(int j=10;j<=d;j++){
            int x=j%10,y=j/10;
            if(x<2||y<2) continue;
            if(x*y==i) ans++;
        }
    }
    cout<<ans;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		double money = 100000; //貸付額
		int n = sc.nextInt(); //n週間

		for (int i = 0; i < n; i++) {
			money = money * 1.05;
			money =((Math.ceil(money/1000))*1000);
		}
		System.out.println((int)money);

	}
}



Measured memory_bytes: 25788
import sys
input = sys.stdin.readline
import math
 
def INT(): return int(input())
def MAPINT(): return map(int, input().split())
def LMAPINT(): return list(map(int, input().split()))
def STR(): return input()
def MAPSTR(): return map(str, input().split())
def LMAPSTR(): return list(map(str, input().split()))
 
f_inf = float('inf')
 
x, y = LMAPINT()
for i in range(x+1):
  for j in range(x+1):
    if i + j == x and i*2 + j*4 == y:
      print('Yes')
      exit()
print('No')

Measured memory_bytes: 64052
#include <bits/stdc++.h>
#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(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#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 int long long
#define INF 1000000000000000000
using namespace std;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readi(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }

int add0(int n){
    int k = 0, s = 1;
    while(n >= s){
        s *= 10;
        k++;
    }
    //string S = "";
    //REP(i, 6 - k) S += '0';
    return 6 - k;
}

signed main(){

    int N, M;
    cin >> N >> M;
    vec P(M), Y(M);
    REP(i, M) cin >> P[i] >> Y[i];

    map<int, vector<Pii>> m;
    set<int> s;
    REP(i, M){
        m[P[i]].push_back(Pii(Y[i], i));
        s.insert(P[i]);
    }
    for(int n: s) SORT(m[n]);

    vec ans(M);
    for(int n: s){
        REP(i, m[n].size()) ans[m[n][i].second] = i + 1;
    }

    REP(i, M){
        REP(k, add0(P[i])) cout << '0';
        cout << P[i];
        REP(k, add0(ans[i])) cout << '0';
        cout << ans[i];
        cout << endl;
    }
    
    return 0;
}

Measured memory_bytes: 19456
import math
while True:
    n=0
    a=int(input())
    if a==0:
        break
    
    b=1000-a
    
    if b>=500:
        n+=1
        b-=500
    if b>=100:
        x=math.floor(b/100)
        n+=x
        b-=x*100
    if b>=50:
        n+=1
        b-=50
    if b>=10:
        x=math.floor(b/10)
        n+=x
        b-=x*10
    if b>=5:
        n+=1
        b-=5
    if b>=1:
        n+=b
    print(n)


Measured memory_bytes: 5652
#include<iostream>
using namespace std;
int main(){
  int n,i,a,c[111],ma=0,mi=111;
cin>>n;
  for(i=0;i<=n;i++)
    c[i]=0;
  for(i=0;i<n;i++){
    cin>>a;
    c[a]++;
    ma=max(ma,a);
    mi=min(mi,a);
  }
  if(ma%2==0){
    if(mi*2!=ma||c[mi]!=1){
      cout<<"Impossible"<<endl;
      return 0;
    }
    for(i=mi+1;i<=ma;i++){
      if(c[i]<2){
        cout<<"Impossible"<<endl;
      return 0;
      }
    }
    cout<<"Possible"<<endl;
  }
  else{
    if(mi*2!=ma+1||c[mi]!=2){
      cout<<"Impossible"<<endl;
      return 0;
    }
    for(i=mi;i<=ma;i++){
      if(c[i]<2){
        cout<<"Impossible"<<endl;
      return 0;
      }
    }
    cout<<"Possible"<<endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}

int main(){
  int n,a,b;
  cin >> n >> a >> b;
  int ans = 0;
  
  rep(i,n+1){
    int tmp1 = i;
    int tmp2 = 0;
    
    while(tmp1 != 0){
      tmp2 += tmp1 % 10;
      tmp1 /=10;
    }
    
    if (tmp2 >= a && tmp2 <= b){
      ans += i;
    }
    
  }
  
  cout << ans;
  
  return 0;
}

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

int main(){
	int cnt=0;
	string a;
	string b="CODEFESTIVAL2016";

	cin>>a;
	for(int i=0;i<b.size();i++){
		if(!(a[i]==b[i])){
			cnt++;
		}
	}
	cout<<cnt<<endl;
        return 0;

}



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

#define dump(...) do{print_vars(cout<<"# "<<#__VA_ARGS__<<'=',__VA_ARGS__);cout<<endl;}while(0)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;

template<typename T,typename U>bool chmin(T& a,const U& b){return a>b?(a=b,1):0;}
template<typename T,typename U>bool chmax(T& a,const U& b){return a<b?(a=b,1):0;}

void print_vars(ostream&){}
template<typename Car,typename... Cdr>
void print_vars(ostream& os,const Car& car,const Cdr&... cdr){
	print_vars(os<<car<<(sizeof...(cdr)?",":""),cdr...);
}

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}

template<int I,typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<int I,typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	os<<get<I>(t)<<(sizeof...(Cdr)?",":"");
	print_tuple<I+1,Cdr...>(os,t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<0,Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

int main()
{
	#ifndef _GLIBCXX_DEBUG
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	constexpr char endl='\n';
	#endif

	for(int a,b;cin>>a>>b&&a|b;){
		cout<<(a<=8&&b<=8?"Yay!":":(")<<endl;
	}
}


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

typedef pair<int,int> P;

#define INF ( 1<<29 )

int N;
int p[100002];
int H[100002];


int dijk(){
  fill(H,H+N+1,INF);
  priority_queue<P,vector<P>,greater<P> > q;
  q.push( P(0,0) );
  H[0] = 0;
  while(!q.empty() ){
    P st = q.top(); q.pop();
    int id = st.second;
    int c  = st.first;
    if( H[id] < c ) continue;
    if( id == N-1) return c;
    if( p[id] != 0 ){
      int nd = min( N-1, max(0,id + p[id]) );
      if( H[nd] > c ){
	H[nd] = c;
	q.push( P(c,nd) );
      }
    } else {
      for(int i=1;i<=6;i++){
	int nc = c + 1;
	int nd = min(N-1,id + i);
	if( H[nd] > nc ){
	  H[nd] = nc;
	  q.push( P(nc,nd) );
	}
      }
    }
  }
  return -1;
}

int main(){
  cin >> N;
  for(int i=0;i<N;i++) cin >> p[i];
  cout << dijk() << endl;
}

Measured memory_bytes: 1996
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
bool comp(ll a, ll b)
{
    return (a < b);
}
int main(){

ll n,i,j,k;
cin>>n;
vector < vector<ll> > v;

ll dp1[n],dp2[n],dp3[n];
ll *a,*b,*c;
for(i=0;i<n;i++){
vector <ll> x;
    for(j=0;j<3;j++){
        cin>>k;
        x.push_back(k);
    }
    v.push_back(x);
}
                // for(i=0;i<n;i++){
                //     for(j=0;j<3;j++)
                //     cout<<v[i][j];
                //     cout<<endl;
                // }
for(i=0;i<n;i++){

if(i==0){
    dp1[i]=v[i][0];
    dp2[i]=v[i][1];
    dp3[i]=v[i][2];
}
else{
    dp1[i]=v[i][0]+ std::max(dp2[i-1],dp3[i-1],comp);
     dp2[i]=v[i][1]+ std::max(dp1[i-1],dp3[i-1],comp);
      dp3[i]=v[i][2]+ std::max(dp1[i-1],dp2[i-1],comp);
}
}
//cout<<dp1<<dp2<<dp3;
a=std::max_element(dp1, dp1 + n);
b=std::max_element(dp2, dp2 + n);
c=std::max_element(dp3, dp3 + n);

cout<<std :: max({*a,*b,*c},comp)<<endl;

return 0;
}



Measured memory_bytes: 8752
class Node(object):
    def __init__(self, num, prv = None, nxt = None):
        self.num = num
        self.prv = prv
        self.nxt = nxt
 
 
class DoublyLinkedList(object):
    def __init__(self):
        self.start = self.last = None
 
    def insert(self, num):
        new_elem = Node(num)
 
        if self.start is None:
            self.start = self.last = new_elem
        else:
            new_elem.nxt = self.start
            self.start.prv = new_elem
            self.start = new_elem
 
    def delete_num(self, target):
        it = self.start
        while it is not None:
            if it.num == target:
                if it.prv is None and it.nxt is None:
                    self.start = self.last = None
                else:
                    if it.prv is not None:
                        it.prv.nxt = it.nxt
                    else:
                        self.start = self.start.nxt
 
                    if it.nxt is not None:
                        it.nxt.prv = it.prv
                    else:
                        self.last = self.last.prv
                break
            it = it.nxt
 
    def delete_start(self):
        if self.start is self.last:
            self.start = self.last = None
        else:
            self.start.nxt.prv = None
            self.start = self.start.nxt
 
    def delete_last(self):
        if self.start is self.last:
            self.start = self.last = None
        else:
            self.last.prv.nxt = None
            self.last = self.last.prv
 
    def get_content(self):
        ret = []
        it = self.start
 
        while it is not None:
            ret.append(it.num)
            it = it.nxt
 
        return ' '.join(ret)
 
 
def _main():
    from sys import stdin
 
    n = int(input())
 
    lst = DoublyLinkedList()
     
    for _ in range(n):
        cmd = stdin.readline().strip().split()
        if cmd[0] == 'insert':
            lst.insert(cmd[1])
        elif cmd[0] == 'delete':
            lst.delete_num(cmd[1])
        elif cmd[0] == 'deleteFirst':
            lst.delete_start()
        elif cmd[0] == 'deleteLast':
            lst.delete_last()
 
    print(lst.get_content())
 
 
if __name__ == '__main__':
    _main()


Measured memory_bytes: 227608
n, k, q = map(int, input().split())
a = [0 for _ in range(n)]
for _ in range(q):
  idx = int(input())
  a[idx - 1] += 1
s = sum(a)
for i in range(n):
  print("Yes" if k - s + a[i] > 0 else "No")

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

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

using namespace std;

pair<string, string> td[200005];
string s;
int n,q;

bool solve(int k, bool isRight) {
  REP(i,q) {
    if(s[k] == td[i].first[0]) {
      if(td[i].second == "R") {
        k++;
      } else {
        k--;
      }
    }
  }
  if(isRight) {
    if (k == n + 1) {
      return true;
    }
  } else {
    if (k == 0) {
      return true;
    }
  }
  return false;

}

int main()
{
  cin >> n >> q;
  cin >> s;
  s = "*" + s + "*";
  REP(i,q) {
    string t,d;
    cin >> t >> d;
    td[i] = make_pair(t,d);
  }

  // 落ちないゴーレムのうち最も左にいるやつ
  int left = 0, mid = 0;
  int ng = 0, ok = n + 1;
  while (abs(ok - ng) > 1)
  {
    mid = (ok + ng) / 2;

    if (solve(mid, false))
    {
      ng = mid;
    }
    else
    {
      ok = mid;
    }
  }
  left = ok;

  // 最も右の奴
  int right = 0;
  ng = n + 1;
  ok = 0;
  while (abs(ok - ng) > 1)
  {
    mid = (ok + ng) / 2;

    if (solve(mid, true))
    {
      ng = mid;
    }
    else
    {
      ok = mid;
    }
  }
  right = ok;
  cout << right - left + 1 << endl;
}



Measured memory_bytes: 22348
#include<bits/stdc++.h> 
using namespace std;
string s;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	int n,sum=0,ans=0;
	cin>>n;
	cin>>s;
	for(int i=0;i<n;i++)
	if(s[i]=='R')sum++;
	for(int i=0;i<sum;i++)
	if(s[i]=='W')ans++;
	cout<<ans<<"\n";
	return 0;
}


Measured memory_bytes: 3772
import math


def ncr(n, k):
    return math.factorial(n) / (math.factorial(k) * math.factorial(n - k))


n, m = map(int, input().split())
c1, c2 = 0, 0
if n > 1:
    c1 = ncr(n, 2)
if m > 1:
    c2 = ncr(m, 2)
print(int(c1 + c2))


Measured memory_bytes: 3060
import sys
n,m=map(int,input().split())
lamp=[]
for i in range(m):
  tmp=list(map(int,input().split()))
  lamp.append(tmp[1:])
p=list(map(int,input().split()))
ans=0
for i in range(2**n):
  d={}
  for x in range(m):
    d[x]=0
  for j in range(n):
    if (i>>j)&1:
      I=0
      while I<m:
        if j+1 in lamp[I]:
          d[I]+=1
        I+=1
  judge=0
  for INDEX in range(m):
    if d[INDEX]%2==p[INDEX]:
      pass
    else:
      judge+=1
  if judge==0:
    ans+=1
print(ans)

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

using namespace std;

int main()
{
    int n, m, small, large;
    bool s_gen, gen_now, seat[100000];
    string s;
    cin>>n;
    cout<<0<<endl;
    cin>>s;
    if (s=="Vacant") return 0;
    else if (s=="Male") seat[0]=0;
    else seat[0]=1;
    cout<<n-1<<endl;
    cin>>s;
    if (s=="Vacant") return 0;
    else if (s=="Male") seat[n-1]=0;
    else seat[n-1]=1;
    m=(n-1)/2;
    small=0; s_gen=seat[0];
    large=n-1;
    while (1)
    {
        cout<<m<<endl;
        cin>>s;
        if (s=="Vacant") break;
        else if (s=="Male") { seat[m]=0; gen_now=0; }
        else { seat[m]=1; gen_now=1; }
        if ((m-small)%2)
        {
            if (s_gen==gen_now)
            {
                large=m;
                m=(small+m)/2;
            }
            else
            {
                small=m;
                s_gen=seat[m];
                m=(large+m)/2;
            }
        }
        else
        {
            if (s_gen!=gen_now)
            {
                large=m;
                m=(small+m)/2;
            }
            else
            {
                small=m;
                s_gen=seat[m];
                m=(large+m)/2;
            }
        }
    }
    return 0;
}


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

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  int ans = 3;
  if(a==b){
    ans--;
  }
  if(b==c){
    ans--;
  }
  if(c==a){
    ans--;
  }
  if(ans==0){
    ans++;
  }

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
int t,x,y,z,sum=0;
cin>>t>>z;
while(z--){
    cin>>x;
    sum+=x;

}
y=t-sum;
if(y>=0)cout<<y<<endl;
else cout<<-1<<endl;

}


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

int main(){
	int a,b;
	cin>>a>>b;
	if(a+b==15){
		cout<<"+"<<endl;
	}else if(a*b==15){
		cout<<"*"<<endl;
	}else{
		cout<<"x"<<endl;
	}

	return 0;
}

Measured memory_bytes: 256
n, m = map(int,input().split())
box = [[1,0] for i in range(n)]#個数、赤の可能性
box[0][1] = 1
ans = 1

for i in range(m):
    x, y = map(int,input().split())
    if box[x-1][0] == 0:
        continue
    box[x-1][0] -= 1
    box[y-1][0] += 1
    if box[x-1][1] == 1:
        if box[y-1][1] == 0:
            box[y-1][1] = 1
            ans += 1
        if box[x-1][0] == 0:
            box[x-1][1] = 0
            ans -= 1


print(ans)




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

int gcd(int a, int b){
    int r,temp;
    if (a < b){
        temp = a;
        a = b;
        b = temp;
    }
    while ( (r = a % b) != 0){
        a = b;
        b = r;
    }
    return b;
}

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i,N) cin >> A[i];
    bool setwise = true;
    int agcd = A[0];
    rep(i,N){
        agcd = gcd(agcd, A[i]);
    }
    if (agcd != 1) setwise = false;
    
    bool pairwise = true;
    
    vector<bool> isPrime(1001, true);
    for (int i = 2; i <= 1000; i++){
        if (isPrime[i]){
            for (int j = 2; j * i <= 1000; j++){
                isPrime[j * i] = false;
            }
        }
    }
    vector<int> prime_set(0);
    for (int i = 2; i <= 1000; i++){
        if (isPrime[i]) prime_set.push_back(i);
    }
    
    vector<int> prime_num(1001, 0);
    rep(i,N){
        if (!pairwise) break;
        rep(j, prime_set.size()){
            if (!pairwise) break;
            int cnt = 0;
            while(true){
                if (!pairwise){
                    break;
                }
                else if (A[i] % prime_set[j] != 0){
                    break;
                }
                else{
                    A[i] /= prime_set[j];
                    if (cnt == 0){
                        prime_num[prime_set[j]]++;
                    }
                    cnt++;
                    if (prime_num[prime_set[j]] >= 2){
                        pairwise = false;
                    }
                }
            }
        }
    }
    sort(all(A));
    rep(i,N - 1){
        if (A[i] == A[i + 1] && A[i] != 1) pairwise = false;
    }
    rep(i,1001){
        if (prime_num[i] >= 2) pairwise = false;
    }
    
    if (pairwise) cout << "pairwise coprime" << endl;
    else if (setwise) cout << "setwise coprime" << endl;
    else cout << "not coprime" << endl;
}

Measured memory_bytes: 7172
import java.util.*;

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

        String left = str.substring(0,2);
        String right = str.substring(2,4);

        String massage = "NA";
        if (Integer.parseInt(left) >= 0  &&
        Integer.parseInt(right) >= 1 && Integer.parseInt(right) <= 12){
            massage = "YYMM";
        }
        if (Integer.parseInt(right) >= 0  &&
        Integer.parseInt(left) >= 1 && Integer.parseInt(left) <= 12){
            if(massage.equals("YYMM")){
                massage = "AMBIGUOUS";
            } else {
                massage = "MMYY";
            }
        }
        System.out.println(massage);
        sc.close();
    }
}

Measured memory_bytes: 21844
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
double f[1005][1005],dis[1005],a[1005][3];
bool b[1005];
int main()
{
    int i,j,k,n;
    double xi,xs,ys,xt,yt;
    scanf("%lf%lf%lf%lf",&xs,&ys,&xt,&yt);
    scanf("%d",&n);
    a[0][0]=xs;a[0][1]=ys;a[0][2]=0;
    a[n+1][0]=xt;a[n+1][1]=yt;a[n+1][2]=0;
    for(i=1;i<=n;i++)
        scanf("%lf%lf%lf",&a[i][0],&a[i][1],&a[i][2]);
    n++;
    for(i=0;i<=n;i++)
        for(j=i+1;j<=n;j++)
            f[i][j]=f[j][i]=max(0.0,sqrt((a[i][0]-a[j][0])*(a[i][0]-a[j][0])+(a[i][1]-a[j][1])*(a[i][1]-a[j][1]))-a[i][2]-a[j][2]);//
    fill(dis,dis+1005,1e18);//
    dis[0]=0;
    for(i=0;i<n;i++){
        xi=1e18;//
        k=0;
        for(j=0;j<=n;j++){
            if(b[j]==0&&dis[j]<xi){
                xi=dis[j];
                k=j;
            }
        }
        b[k]=1;
        for(j=0;j<=n;j++)
            dis[j]=min(dis[j],dis[k]+f[k][j]);
    }
    printf("%.9lf\n",dis[n]);//
}


Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define mfill(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(), v.end()
#define in(x,y,h,w) if(0<=x&&x<h&&0<=y&&y<w)
#define y0 y12345
#define y1 y54321

#ifdef LOCAL
#define debug(...) fprintf(stderr,__VA_ARGS__)
#else
#define debug(...) 42
#endif

using ul = unsigned long;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;using vvint = vector<vector<int>>;
using vll = vector<ll>;using vvll = vector<vector<ll>>;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b;return 1;}return 0;}
template <class T>void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}
template <class T>T gcd(T &a, T &b){if(a<b){swap(a,b);} T r = a%b; while(r!=0){a=b;b=r;r=a%b;} return b;}

vint dx = {-1, 0, 1, 0}, dy = {0, -1, 0, 1};
vint dx8 = {-1, -1, -1, 0, 1, 1, 1, 0}, dy8 = {-1, 0, 1, 1, 1, 0, -1, -1};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    debug("debug test\n");
    int n,m;
    string s;cin>>s;n = s.length();
    vint ans(n, 0);
    int st = 0;
    int h = 0;
    rep(i, n-1){
        if(s[i]=='R'&&s[i+1]=='L'){
            h = i;
        }
        if(i+1==n-1||s[i]=='L'&&s[i+1]=='R'){
            int rnum = h-st+1;
            int lnum = i-h;
            if(i+1==n-1)lnum++;
            debug("r:%d l:%d h:%d\n", rnum, lnum, h);
            ans[h] = lnum/2 + (rnum+1)/2;
            ans[h+1] = (lnum+1)/2 + rnum/2;
            st = i+1;
        }
    }
    rep(i, n){
        if(i!=0)cout << " ";
        cout << ans[i];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 1104
#include<iostream>
#include<ios>
using namespace std;
bool isp(int a)
{
	if(a<2)return 0;
	if(!(a&1))return 0;
	for(int i=3;i*i<=a;i+=2)if(a%i<1)return 0;
	return 1;
}
bool ok[1<<20];
int ans[1<<20];
main()
{
	int n;
	for(int i=1;i<1e6;i++)ok[i]=isp(i*10+1)&&isp(i*10+3)&&isp(i*10+7)&&isp(i*10+9);
	int p;
	for(int i=1;i<1e6;i++)
	{
	    if(ok[i])p=i;
	    ans[i]=p;
	}
	while(scanf("%d",&n),n)
	{
		if(n<19)puts("13");
		else
		{
			printf("%d\n",ans[(n-9)/10]*10+9);
		}
	}
}



Measured memory_bytes: 8012
inp = list(input()) 
count = int(input())

for i in range(count):
    command = list(input().split())
    #print(command)
    if command[0] == "print":
        a = int(command[1])
        b = int(command[2])
        print("".join(inp[a:b+1]))
    elif command[0] == "reverse":
        a = int(command[1])
        b = int(command[2])
        inp[a:b+1] = reversed(inp[a:b+1])
        #print(inp)
    elif command[0] == "replace":
        a = int(command[1])
        b = int(command[2])
        inp[a:b+1] = command[3]
        #print(inp)



Measured memory_bytes: 5616