akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>

#define MAX 100005
#define NIL -1

typedef struct{
	int p;
	int l;
	int r;
}Node;

Node T[MAX];
int n , D[MAX];

void print( int u ){
	
	int i , c;
	printf( "node %d: " , u );
	printf( "parent = %d, " , T[u].p );
	printf( "depth = %d, " , D[u] );
	
	if( T[u].p == NIL ){
		printf( "root, " );
	}else if( T[u].l == NIL ){
		printf( "leaf, " );
	}else{
		printf( "internal node, " );
	}
	
	printf( "[" );
	
	for( i = 0 , c = T[u].l; c != NIL; i++ , c = T[c].r ){
		if(i){
			printf( ", " );
		}
		printf( "%d" , c );
	}
	printf( "]\n" );
}

int rec( int u , int p ){
	D[u] = p;
	if( T[u].r != NIL ){
		rec( T[u].r , p );
	}
	if( T[u].l != NIL ){
		rec( T[u].l , p+1 );
	}
}

int main( void ){
	
	int i , j , d , v , c , l , r;
	
	scanf( "%d" , &n );
	
	for( i = 0; i < n; i++ ){
		T[i].p = T[i].l = T[i].r = NIL;
	}
	
	for( i = 0; i < n; i++ ){
		scanf( "%d" , &v );
		scanf( "%d" , &d );
		for( j = 0; j < d; j++ ){
			scanf( "%d" , &c );
			if( j == 0 ){
				T[v].l = c;
			}else{
				T[l].r = c;
			}
			l = c;
			T[c].p = v;
		}
	}
	
	for( i = 0; i < n; i++ ){
		if( T[i].p == NIL ){
			r = i;
		}
	}
	
	rec( r , 0 );
	
	for( i = 0; i < n; i++ ){
		print( i );
	}
	
	return 0;
}


Measured memory_bytes: 6384
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
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; }
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
const int MOD = 1e9+7;
const int INF = 1<<30;
const ll LINF = 1LL<<60;

const int MAXN = 100;
const int MAXK = 100;

int A[MAXN][MAXK];

int main() {
    int N,K;
    cin>>N>>K;
    int d[K];//iのお菓子を持っている人数
 
    // int A[N][K]={0};//お菓子を持っているかフラグ

    
    // rep(i, N) {
    //     rep(j, K) {
    //         cout << A[i][j] << " ";
    //     }
    //     cout << endl;
    // }

    int count =0;
    for(int i =0;i<K;i++)
    {
      cin>>d[i];
      //cout<<d[i]<<endl;
      for(int t=0;t<d[i];t++)
      {
        int num=0;
        cin>>num;
        //cout<<num-1<<endl;
        A[num-1][i]=1;
      }
    }



    for(int t=0;t<N;t++)
      {
        bool flg =true;
        for(int i =0;i<K;i++)
    	{
          //cout<<i+1<<"種類目のお菓子"<<endl;
          //cout<<t+1<<"人目:"<<A[i][t]<<endl;      
          if(A[t][i]==1)flg=false;      
        }
        if(flg)count++;
      }
    cout<<count<<endl;
    return 0;
}


// int main()
// {
//     cin.tie(0);
//     ios_base::sync_with_stdio(0);

//     int n, k;
//     cin >> n >> k;
//     vector<int> x(n, 0);
//     rep(i, k) {
//         int d;
//         cin >> d;
//         rep(j, d) {
//             int a;
//             cin >> a;
//             --a;
//             x[a]++;
//         }
//     }

//     int sum = 0;
//     rep(i, n) {
//         if(x[i] == 0) sum++;
//     }

//     cout << sum << endl;


//     return 0;
// }

Measured memory_bytes: 3652
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;


int n;
double dp[303][303][303]={};

double sd(int i,int j,int k){
  if (i==0 && j==0 && k==0) return 0.0;
  if (dp[i][j][k]>0.0) return dp[i][j][k];
  
  double res=0;
  if (i+j+k==n) res++;
  if (i+j+k < n) res+=(double)n/(i+j+k);
  if (i>0) res+=sd(i-1,j,k)*(double)i/(i+j+k);
  if (j>0) res+=sd(i+1,j-1,k)*(double)j/(i+j+k);
  if (k>0) res+=sd(i,j+1,k-1)*(double)k/(i+j+k);
  return dp[i][j][k]=res;
}


int main(void){
  int i,a,su[4]={};
  
  cin >> n;
  for (i=0;i<n;i++){
    cin >> a;
    su[a]++;
  }
  
  printf("%.12lf\n",sd(su[1],su[2],su[3]));
  
  return 0;
}

Measured memory_bytes: 217344
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::f64::consts::*;

#[allow(unused)]
const INF: usize = std::usize::MAX / 4;
#[allow(unused)]
const M: usize = 1000000007;

fn main() {
    input! {
        n: usize,
        a: [usize; n],
    }
    let mut count = 0;
    for i in 0..n {
        if i % 2 == 0 && a[i] % 2 == 1 {
            count += 1;
        }
    }
    println!("{}", count);
}


Measured memory_bytes: 2080
S = input()
S = list(S)

N = len(S)

ans = 0
for i in range(N-1):
    if S[i] == S[i+1]:
        if S[i+1] == "1":
            S[i+1] = "0"
        else:
            S[i+1] = "1"
        ans += 1
print(ans)
            

Measured memory_bytes: 49604
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author hakamada
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ABC117_1 solver = new ABC117_1();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABC117_1 {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            //float T = in.nextInt();
            //float X = in.nextInt();
            out.println(
                    (float) in.nextInt() / (float) in.nextInt()
            );

        }

    }
}



Measured memory_bytes: 21844
#include <iostream>

using namespace std;

int main(){
  int n;
  cin>>n;
  long a[87]={};
  a[0]=2;a[1]=1;
  for(int i=2;i<=n;++i){
    a[i]=a[i-1]+a[i-2];
  }
  cout<<a[n];
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 700000 
#define W 800 
#define H 800 

using namespace std;
typedef long long int ll;

char c[H][W];
ll d[H][W];

int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
queue< pair<int, int> > que;

int main() {
	int h, w;
	ll k, ans;
	scanf("%d %d %d", &h, &w, &k);

	for (int i = 0; i < w; i++) {
		for (int j = 0; j < h; j++) {
			d[i][j] = INF;
		}
	}

	for (int i = 0; i < h; i++) {
		scanf("\n");
		for (int j = 0; j < w; j++) {
			scanf("%c", &c[j][i]);
			if (c[j][i]=='S') {
				d[j][i] = 0;
				que.push(pair<int, int>(j, i));
			}
		}
	}

	while (!que.empty()) {
		int x, y;
		int x1, y1;
		ll a;
		tie(x, y) = que.front();
		a = d[x][y];
		que.pop();
		for (ll i = 0; i < 4; i++) {
			x1 = x + dx[i];
			y1 = y + dy[i];
			if (x1 >= w) continue;
			if (y1 >= h) continue;
			if (x1 < 0) continue;
			if (y1 < 0) continue;
			if (k <= a) break;
			if (c[x1][y1] == '.') {
				if (d[x1][y1] == INF) {
					d[x1][y1] = a + 1;
					que.push(pair<int, int>(x1, y1));
				}
			}
		}
	}

	ll dis, dis1, dis2;
	ll min_out = INF;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (d[j][i] != INF) {
				
				dis1 = min(i,j);
				dis2 = min((h-i-1),(w-j-1));
				dis = min(dis1, dis2);

				if (k >= d[j][i] & min_out > dis) {
					min_out = dis;
				}
			}
		}
	}

//	for (int i = 0; i < h; i++) {
//		for (int j = 0; j < w; j++) {
//			printf("%d ", d[j][i]);
//		}
//		printf("\n");
//	}

	ans = 1;
	while(1) {
		if (min_out <= 0) {
			printf("%d\n", ans);
			return 0;
		}
		min_out -= k;
		ans++ ;
	}

}


Measured memory_bytes: 5888
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long ans=0;
	string s1;
	cin>>s1;
	for(int i=1;i<s1.size();i++)
	{
		if(s1[i]!=s1[i-1])
			ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 512
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
const int INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
const ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a[ohara], b, c, d, tmp, m, h, w, x, y, sum[ohara], k, q;
set<ll> st;
U_MAP mp;

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

  cin >> n >> k;
  rep(i, n) {
    cin >> a[i];
    st.insert(a[i]);
    sum[a[i]]++;
  }
  sort(sum, sum + n + 1);
  ll syu = Size(st);
  rep(i, n + 5) {
    if (syu <= k) break;
    if (sum[i] == 0) continue;
    ans += sum[i];
    syu--;
  }
  Cout(ans);
  return 0;
}

Measured memory_bytes: 15360
#include<bits/stdc++.h>
/* #define int long long */
/* #define double long double */
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define repa(i, s, n) for(int i = s; i < (int)n; i++)
#define MOD 1000000007
using namespace std;
using ll = long long;
typedef vector<int> vi;
typedef pair<int, int> P;
#define rrep(i,a,b) for(int i=a;i>=b;i--)

signed main(){
    int x;
    cin >> x;
    if(x >= 30) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3592
import java.io.PrintWriter;
import java.util.*;

public class Main {


    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        int n = sc.nextInt();
        int q = sc.nextInt();
        int[] col = new int[n+1];
        for(int i=1; i<=n; i++) {
            col[i] = Integer.parseInt(sc.next());
        }

        int[] last = new int[n + 1];
        BIT bit = new BIT(n);

        int[] res = new int[q];
        Pair[] list = new Pair[q];
        for(int i=0; i<q; i++) {
            list[i] = new Pair(Integer.parseInt(sc.next()), Integer.parseInt(sc.next()), i);
        }
        Arrays.sort(list, (a, b) -> Integer.compare(a.r, b.r));
        int pos = 0;
        int sum = 0;
        for(Pair p : list) {
            while(pos < p.r) {
                int c = col[pos+1];
                if(last[c] >= 1) {
                    bit.add(last[c], -1);
                    sum--;
                }
                bit.add(pos+1, 1);
                sum++;
                last[c] = pos+1;
                pos++;
            }
            res[p.i] = sum - bit.sum(p.l-1);
        }
        for(int i=0 ;i<q; i++) {
            out.println(res[i]);
        }
        out.flush();

    }

    static class Pair {
        int l;
        int r;
        int i;
        Pair(int l, int r, int i) {
            this.l = l;
            this.r = r;
            this.i = i;
        }
    }
    static class BIT {
        int n ;
        int[] bit;

        BIT(int n) {
            this.n = n;
            bit = new int[n+1];
        }
        void add(int i, int num) {
            while(i <= n) {
                bit[i] += num;
                int lsb =  i & (-i);
                i += lsb;
            }
        }
        int sum(int i) {
            int sum = 0;
            while(i > 0) {
                sum += bit[i];
                int lsb =  i & (-i);
                i -= lsb;
            }
            return sum;
        }
        int sum(int l, int r) {
            return sum(r) - sum(l-1);
        }
    }


}


Measured memory_bytes: 82484
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Deque;
import java.util.Scanner;

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

	private void run() {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int n = scanner.nextInt();
			if (n == 0)
				break;

			int[][] num = new int[n][3];
			int size = 0;
			for (int i = 0; i < n; i++) {
				int a = scanner.nextInt();
				int b = scanner.nextInt();
				int c = scanner.nextInt();
				num[i][0] = a;
				num[i][1] = b;
				num[i][2] = c;
				size = Math.max(size, Math.max(a, b));
			}
			size++;
			int[][] cost = new int[size][size];
			for (int[] t : cost)
				Arrays.fill(t, 1 << 24);
			for (int i = 0; i < n; i++) {
				int a = num[i][0];
				int b = num[i][1];
				int c = num[i][2];
				cost[a][b] = c;
				cost[b][a] = c;

			}
			for (int i = 0; i < size; i++) {
				slove(i, cost);
			}
			int ans = 0;
			int min = Integer.MAX_VALUE;
			for (int i = 0; i < size; i++) {
				int sum = 0;
				for (int j = 0; j < size; j++) {
					sum += cost[i][j];
				}
				if (sum < min) {
					min = sum;
					ans = i;
				}
			}
			System.out.println(ans + " " + min);
		}

	}

	private void slove(int x, int[][] cost) {
		Deque<Integer> deque = new ArrayDeque<Integer>();
		for (int i = 0; i < cost.length; i++) {
			if (cost[i][x] != 1 << 24) {
				deque.offer(i);
			}
		}
		cost[x][x] = 0;
		while (!deque.isEmpty()) {
			int pri = deque.poll();
			for (int i = 0; i < cost.length; i++) {
				if (pri == i)
					continue;
				if (cost[pri][i] != 1 << 24
						&& cost[x][i] > cost[pri][i] + cost[x][pri]) {
					cost[x][i] = cost[pri][i] + cost[x][pri];
					cost[i][x] = cost[pri][i] + cost[x][pri];
					deque.offer(i);
				}
			}
		}

	}
}

Measured memory_bytes: 19700
/*
 * ARC097_D.cpp
 *
 *  Created on: May 12, 2018
 *      Author: 13743
 */

#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<stack>
#include<unordered_set>

using namespace std;

vector<int> adj[100001];
int p[100001];
vector<vector<int>> comps;
int vis[100001];



void connected(int rt, int i) {
	if(vis[rt]) return;
	vis[rt] = i;
	comps[i].push_back(rt);
	for(int j=0; j<adj[rt].size(); j++) {
		connected(adj[rt][j], i);
	}
}

int main() {
	comps.resize(100000);
	int n, m;
	cin >> n >> m;
	for(int i=1; i<=n; i++) {
		cin >> p[i];
	}
	int x, y;
	for(int i=0; i<m; i++) {
		cin >> x >> y;
		adj[x].push_back(y);
		adj[y].push_back(x);
	}

	int n2 = 1;
	for(int i=1; i<=n; i++) {
		if(vis[i] == 0) {
			connected(i, n2);
			n2++;
		}
	}
	int sumS = 0;
	for(int i=0; i<comps.size(); i++) {
		
		for(int j=0; j<comps[i].size(); j++) {
			if(vis[p[comps[i][j]]] == vis[comps[i][j]]) {sumS++;}
		}
	}

	cout << sumS << endl;
}




Measured memory_bytes: 12540
using System;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using static Scanner;

class Program
{
    static void Main(string[] args) {
        var writer = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
        Console.SetOut(writer);
        Solve();
        Console.Out.Flush();
    }
    static void Solve() {
        var N = ScanInt();
        var array = new (int index, string s, int p)[N];
        for (int i = 0; i < N; i++) {
            array[i].index = i;
            array[i].s = Scan();
            array[i].p = ScanInt();
        }
        foreach (var (index, _, _) in array.OrderBy(x => x.s).ThenByDescending(x => x.p)) {
            Console.WriteLine(index + 1);
        }
    }
}

public static class Scanner
{
    static readonly Stream stream = Console.OpenStandardInput();
    static readonly byte[] buffer = new byte[1024];
    static int length, p;
    static bool isEof;
    private static byte ConsoleIn() {
        if (isEof) return 0;
        if (p < length) return buffer[p++];
        p = 0;
        if ((length = stream.Read(buffer, 0, 1024)) > 0) return buffer[p++];
        isEof = true;
        return 0;
    }
    public static char GetChar() {
        var by = ConsoleIn();
        while ((by < '!' || '~' < by) && !isEof) by = ConsoleIn();
        return (char) by;
    }
    public static string Scan() {
        var sb = new StringBuilder();
        for (var ch = GetChar(); '!' <= ch && ch <= '~'; ch = (char) ConsoleIn()) {
            sb.Append(ch);
        }
        return sb.ToString();
    }
    public static int ScanInt() {
        var temp = 0;
        for (var ch = GetChar(); '0' <= ch && ch <= '9'; ch = (char) ConsoleIn()) {
            temp = temp * 10 + ch - '0';
        }
        return temp;
    }
}

Measured memory_bytes: 25896
from collections import Counter
H,W=map(int,input().split())
a=[list(str(input())) for i in range(H)]
b=[]
n_H=0
for l in a:
    c=Counter(l)
    if c['.']!=W:
        b.append(l)
        n_H+=1
d=[]
b=list(map(list,zip(*b)))
for l in b:
    c=Counter(l)
    if c['.']!=n_H:
        d.append(l)
d=list(map(list, zip(*d)))

for l in d:
    s=''.join(l)
    print(s)

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-12;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	char c; cin >> c;
	string s = "aiueo";
	if (s.find(c) != string::npos) cout << "vowel" << endl;
	else cout << "consonant" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <set>

using namespace std;

char preback (const string &s) {
  return *next(s.rbegin());
}

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

  if ((int) s.size() == 26) {
    if (s == string("zyxwvutsrqponmlkjihgfedcba")) {
      cout << -1 << endl;
    } else {
      set<char> dels;
      while (dels.upper_bound(s.back()) == dels.end()) {
        dels.insert(s.back());
        s.pop_back();
      }

      char add = *dels.upper_bound(s.back());
      s.pop_back();
      cout << s << add << endl;
    }
  } else {
    set<char> unseen;
    for (char c = 'a'; c <= 'z'; c++) {
      unseen.insert(c);
    }
    for (char c : s) {
      unseen.erase(c);
    }
    cout << s << *unseen.begin() << '\n';
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<string>
#include<set>
#include<cstdio>
#include<map>
#include<vector>
#include<queue>

using namespace std;

#define up(i,j,k) for(int i=j;i<k;i++)
#define down(i,j,k) for(int i=j;i>=k;i--)
#define mem(i,j) memset(i,j,sizeof i)
#define mod(x) (x)%mod
#define sfi(a) scanf("%d",&a)
#define sfd(a) scanf("%lf",&a)
#define sfs(a) scanf("%s",a)
#define sfl(a) scanf("%lld",&a)
#define sff(a) scanf("%f",&a)

const int inf=0x3f3f3f3f;
int n,m;
int mapp[25][25];
struct node
{
	int x,y;
}s;
int vis[25][25][5];
int step,minn;
void dfs(int x1,int y1,int n1)
{
	n1++;
	up(i,0,4)
	{
		int x=x1,y=y1;
		if(i==0&&x>=2&&mapp[y][x-1]!=1)
		{
			while(x>=2&&(mapp[y][x-1]==0||mapp[y][x-1]==2))
			{
				x--;
			}
			x--;
			if(mapp[y][x]==3)
			{
				minn=min(minn,n1);
				return ;
			}
			if(mapp[y][x]==1)
			{
				if(n1<10&&!vis[y][x+1][0])
				{
					vis[y][x+1][0]=1;
					x++;
					mapp[y][x-1]=0;
					dfs(x,y,n1);
					vis[y][x][0]=0;
					mapp[y][x-1]=1;
				}
			}
		}
		if(i==1&&( x<=n-1)&& mapp[ y][ x+1]!=1)
		{
			while(( x<=n-1)&&( mapp[ y][ x+1]==0|| mapp[ y][ x+1]==2))
			{
				 x++;
			}
			x++;
			if( mapp[ y][ x]==3)
			{
				minn=min(minn,n1);
				return;
			}
			if( mapp[ y][ x]==1)
			{
				if( n1<10&&! vis[ y][ x-1][1])
				{
					 vis[ y][ x-1][1]=1;
					 x--;
					 mapp[ y][ x+1]=0;
					dfs(x,y,n1);
					vis[y][x][1]=0;
					mapp[y][x+1]=1;
				}
			}
		}
		if(i==2&& y<=m-1&& mapp[y+1][x]!=1)
		{
			while(( y<=m-1)&&( mapp[ y+1][ x]==0|| mapp[y+1][x]==2))
			{
				 y++;
			}
			 y++;			
			if( mapp[ y][ x]==3)
			{
				minn=min(minn,n1);
				return ;
			}
			if( mapp[ y][ x]==1)
			{
				if( n1<10&&! vis[ y-1][ x][2])
				{
					 vis[ y-1][ x][2]=1;
					 mapp[y][x]=0;
					 y--;
					dfs(x,y,n1);
					vis[y][x][2]=0;
					mapp[y+1][x]=1;
				}
			}
		}
		if(i==3&& y>=2&& mapp[y-1][x]!=1)
		{
			while(( y>=2)&&( mapp[ y-1][ x]==0|| mapp[ y-1][ x]==2))
			{
				 y--;
			}
			 y--;
			if( mapp[ y][ x]==3)
			{
				minn=min(minn,n1);
				return;
			}
			if( mapp[ y][ x]==1)
			{
				if( n1<10&&! vis[ y+1][ x][3])
				{
					 vis[ y+1][ x][3]=1;
					 y++;
					 mapp[y-1][x]=0;
					dfs(x,y,n1);
					vis[y][x][3]=0;
					mapp[y-1][x]=1;
				}
			}
		}
	}
}
int main()
{
	while(~scanf("%d%d",&n,&m)&&(n||m))
	{
		up(i,0,25)
		{
			up(j,0,25)
			{
				mapp[i][j]=-1;
			}
		}
		mem(vis,0);
		up(i,1,m+1)
		{
			up(j,1,n+1)
			{
				scanf("%d",&mapp[i][j]);
				if(mapp[i][j]==2)
				{
					 s.x=j;
					 s.y=i;
				}
			}
		}
		step=0,minn=inf;
		dfs(s.x,s.y,0);
		if(minn!=inf)
		printf("%d\n",minn);
		else
			printf("-1\n");
	}
	return 0;
}

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



int main() {
	string s1, s2, s3;
	cin >> s1 >> s2 >> s3;

	cout << s1[0] << s2[0] << s3[0] << endl;
	return 0;
}


Measured memory_bytes: 3588
n, m = map(int, input().split())
edge = [tuple(map(int, input().split())) for _ in range(m)]

connect = [[0 for _ in range(n)] for _ in range(n)]
for a, b in edge:
    connect[a-1][b-1] = 1
    connect[b-1][a-1] = 1

import itertools
ans = 0
for l in itertools.permutations(range(1, n)):
    ok = True
    pre = 0
    for x in l:
        if connect[pre][x] == 0:
            ok = False
            break
        pre = x
    if ok:
        ans += 1
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
int main()
{
    int n;
    string s;
    cin >> n >> s;
    int cnt = 0;
    rep(i, 0, s.length())
    {
        if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C')
        {
            cnt++;
            i += 2;
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3540
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                    \
  ifstream in("abc140/abc140_b.txt"); \
  cin.rdbuf(in.rdbuf());
#define print_vec(v)                        \
  rep(l, v.size()) { cout << v[l] << " "; } \
  cout << endl;
#else
#define INPUT_FILE
#define print_vec(v)
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
typedef pair<ll, ll> pl;
const int INF = 100100100;
const ll LINF = 1e18 + 100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  int N;
  cin >> N;

  vector<int> a(N);
  vector<int> b(N);
  vector<int> c(N - 1);
  rep(i, N) {
    cin >> a[i];
    a[i]--;
  }
  rep(i, N) { cin >> b[i]; }
  rep(i, N - 1) { cin >> c[i]; }

  ll ans = 0;
  rep(i, N) {
    ans += b[a[i]];
    if (i < N && a[i + 1] - a[i] == 1) {
      ans += c[a[i]];
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
let () =
  let n, c = Scanf.scanf "%d %d " (fun a b -> a, b) in
  let d_mat = Array.init c (fun _ ->
      Array.init c (fun _ -> Scanf.scanf "%d " (fun a -> a))
    ) in
  let c_mat = Array.init n (fun _ ->
      Array.init n (fun _ -> Scanf.scanf "%d " (fun a -> a-1))
    ) in

  let diag_d = Array.make_matrix (3) c 0 in

  for i=0 to n-1 do
    for j=0 to n-1 do
      let cij = c_mat.(i).(j) in
      for k=0 to c-1 do
        let d = d_mat.(cij).(k) in
        let diag = (i+j) mod 3 in
        diag_d.(diag).(k) <- d+ diag_d.(diag).(k);
      done;
    done;
  done;

  let res = ref max_int in
  for c1 = 0 to c-1 do
    for c2 = 0 to c-1 do
      for c3 = 0 to c-1 do
        if c1 = c2 || c2 = c3 || c3 = c1 then
          ()
        else (
          let tmp = diag_d.(0).(c1) + diag_d.(1).(c2) + diag_d.(2).(c3) in
          if !res > tmp then res := tmp else ();
        )
      done;
    done;
  done;

  Printf.printf "%d\n" !res



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

int main() {
    init();

    string s; cin >> s;
    int ans = 0;
    each(c, s)if (c == '1')++ans;
    cout << ans << "\n";
}

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

int main() {
	while (1){
		int n, k;
		cin >> n >> k;

		if (n == 0 && k == 0){ break; }
		else{
			int i, inp;
			int *a;
			a = new int[n];

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

			int sum1 = 0, sum2 = 0, max = 0;

			for (i = 0; i<k; i++){ sum1 += a[i]; }
			max = sum1;

			for (i = k; i<n; i++){
				sum2 = sum1 + a[i] - a[i - k];
				if (sum2>max){ max=sum2; }
				sum1 = sum2;
			}

			cout << max << endl;

			delete[] a;
		}
	}
	return 0;
}

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

int main() {
  int N, Y;
  cin >> N >> Y;

  for (int x{}; x <= N; ++x) {
    for (int y{}; y <= N-x; ++y) {
      int z = N - x - y;
      if (x * 10000 + y * 5000 + z * 1000 == Y) {
        cout << x << " " << y << " " << z << endl;
        return 0;
      }
    }
  }

  cout << "-1 -1 -1" << endl;
  return 0;
}


Measured memory_bytes: 256
N, S = map(int, input().split())
A = list(map(int, input().split()))

MOD = 998244353

dp = [0] * (S + 1)
dp[0] = 1

for i in range(N):
    ai = A[i]
    for j in range(S, -1, -1):
        dp[j] = 2 * dp[j]
        if j - ai >= 0:
            dp[j] += dp[j - ai]
        dp[j] %= MOD

print(dp[S])


Measured memory_bytes: 70840
#include<stdio.h>

int main(){
  int N, A, B, c1, c2, c3;
  scanf("%d", &N);
  scanf("%d %d", &A, &B);

  c1 = 0;
  c2 = 0;
  c3 = 0;

  int P[N];
  int i;

  for(i = 0; i < N; i++){
    scanf("%d", &P[i]);
    if(P[i] <= A) c1++;
    else if(P[i] <= B) c2++;
    else c3++;
  }

  int min = c1;
  if(min > c2) min = c2;
  if(min > c3) min = c3;

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

  return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

void Sort(int A[], int N){
  int j, i, v;
  for( i = 0; i < N; i++){
    v = A[i];
    j = i - 1;
    while(j >= 0 && A[j] > v){
      A[j + 1] = A[j];
      j -- ;
    }
    A[j + 1] = v;
  }
}

int main(){
  int i;
  int N = 3;
  int A[N];
  for(i = 0;i < N; i++) scanf("%d", &A[i]);

  Sort(A, N);

  for(i = 0;i < N; i++){
    if(i == (N - 1)){
      printf("%d\n", A[i]);
    }else{
      printf("%d ", A[i]);
    }
  }
  return 0;
}


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

int main() {
	int A, B;
	cin >> A >> B;
	int ans = 0;
	int kuchi = 1;
	while(kuchi < B){
		kuchi += A;
		kuchi -= 1;
		ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const long Mod = 1000000007;

    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var spl = input.ReadLine().Split(' ');
        var n = int.Parse(spl[0]);

        int sn = n.ToString().Sum(x => (int)(x - '0'));

        return n % sn == 0 ? Yes : No;
    }

    static long[] ToIntArray(string strs, int n) {
        var ret = new long[n];
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = long.Parse(spl[i]);
        return ret;
    }
}


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

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int N = stdIn.nextInt();
		int[][] P = new int[N][3];
		for(int i = 0; i < N; i++) {
			P[i][0] = stdIn.nextInt();
			P[i][1] = stdIn.nextInt();
			P[i][2] = stdIn.nextInt();
		}
		
		LABEL: for(int x = 0; x <= 100; x++) {
			for(int y = 0; y <= 100; y++) {
				boolean flag = true;
				long H = 0;
				int temp = 0;
				for(int i = 0; i < N; i++) {
					if(P[i][2] > 0) {
						H = P[i][2]+Math.abs(P[i][0]-x)+Math.abs(P[i][1]-y);
						break;
					}
				}
				for(int j = 0; j < N; j++) {
					if(Math.max(H-Math.abs(P[j][0]-x)-Math.abs(P[j][1]-y),0) != P[j][2]) {
						flag = false;
						break;
					}
				}
				if(flag) {
					System.out.println(x+ " " +y+ " " +H);
					break LABEL;
				}
			}
		}

	}

}

Measured memory_bytes: 23380
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

func scanInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func scanInt64() int64 {
	sc.Scan()
	i, _ := strconv.ParseInt(sc.Text(), 10, 64)
	return i
}

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func scanInts64(n int) []int64 {
	res := make([]int64, n)
	for i := range res {
		res[i] = scanInt64()
	}
	return res
}

func scanText() string {
	sc.Buffer([]byte{}, math.MaxInt64)
	sc.Scan()
	return sc.Text()
}

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)

	x, y := scanInt(), scanInt()
	if 2*x <= y && y <= 4*x && y%2 == 0 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}

}


Measured memory_bytes: 1752
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[4] = {-1,0,1,0};
int dx[4] = {0,1,0,-1};
int Dy[8] = {-1,-1,0,1,1,1,0,-1};
int Dx[8] = {0,1,1,1,0,-1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 100100;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,k;
    cin>>n>>k;
    vector<int> a(n);
    for(int i=0;i<n;i++)cin>>a[i];
    int dp[d5];
    //dp[i]:石が残りi個の状態から始めたときに勝つ方
    //1:First,0:second;
    for(int i=0;i<=k;i++)dp[i]=0;
    for(int i=1;i<d5;i++){
        for(auto it:a){
            if(i-it<0)continue;
            if(dp[i-it]==0)dp[i]=1;
        }
    }
    //for(int i=0;i<10;i++)cout<<dp[i];
    if(dp[k]==1)cout<<"First"<<endl;
    else cout<<"Second"<<endl;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
#define MAXN	100005
void debug() {int a = 10; a += 10; }
int num[MAXN];
multiset <int> a[MAXN];
queue <int> qx, qy;
int F(int x) {
	if (x == num[x]) return x;
	else return num[x] = F(num[x]);
}
int main() {
	int n; scanf("%d", &n);
	for (int i = 1; i <= n; i++)
		num[i] = i;
	for (int i = 1; i <= 2 * n - 2; i++) {
		int x, y;
		scanf("%d%d", &x, &y);
		a[x].insert(y);
		a[y].insert(x);
	}
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		multiset <int> :: iterator j, k;
		for (j = a[i].begin(); j != a[i].end(); k = j, j++)
			if (j != a[i].begin() && *j == *k) {
				qx.push(i);
				qy.push(*j);
			}
	}
	/*
	multiset <int> :: iterator j;
	for (int i = 1; i <= n; i++) {
		for (j = a[i].begin(); j != a[i].end(); j++)
			cerr << *j << ' ';
		cerr << endl;
	}
	*/
	while (!qx.empty()) {
		int tx = F(qx.front());
		int ty = F(qy.front());
		//if (tx == 4 && ty == 1) debug();
		qx.pop(), qy.pop();
		if (tx == ty) continue;
		ans++;
		if (a[tx].size() > a[ty].size()) swap(tx, ty);
		num[tx] = ty;
		multiset <int> :: iterator j;
		for (j = a[tx].begin(); j != a[tx].end(); j++) {
			int value = *j;
			if (value == ty) continue;
			a[value].erase(a[value].find(tx));
			a[value].insert(ty);
			a[ty].insert(value);
			if (a[value].count(ty) >= 2) {
				qx.push(value);
				qy.push(ty);
			}
		}
		a[ty].erase(tx);
		a[tx].clear();
		/*
		for (int i = 1; i <= n; i++) {
			for (j = a[i].begin(); j != a[i].end(); j++)
				cerr << *j << ' ';
			cerr << endl;
		}
		for (int i = 1; i <= n; i++)
		for (j = a[i].begin(); j != a[i].end(); j++)
			if (F(*j) != *j) debug();
		*/
	}
	if (ans == n - 1) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 26112
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int r=0;
		
		
		for(int i = a;i <= b;i++) {
			if(c%i==0) {
				r++;
			}

		}
		
		System.out.println(r);
		

	




    }

}



Measured memory_bytes: 26292
#include <bits/stdc++.h>
using namespace std;
int n,a[15],sum,p = 1;
int main()
{
    cin >> n;
    for(int i=0;i<n;i++)cin >> a[i];
    for(int i=0;i<n;i++){
        if(a[i]%2==0){
            sum += p*pow(3,n-i-1);
            p *= 2;
        }
        else{
            sum += 2*p*pow(3,n-1-i);
        }
    }
    cout << sum;
    return 0;
}


Measured memory_bytes: 256
def f(x,y):
    return x//y + (1 if x%y > 0 else 0)
n = int(input())
a,b = list(map(int,input().split()))
for i in range(n-1):
    c,d = list(map(int,input().split()))
    e = max(f(a,c),f(b,d))
    a,b = c*e,d*e
print(a+b)


Measured memory_bytes: 3064
/* Dsingh_24 */

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define ios	    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

#define N  100005
vi a[N];
int main()
{
	ios
	ll n,m,i,j;
	cin>>n>>m;
	ll h[n+2],x,y,ans=0;
	for(i=1;i<=n;i++)
		cin>>h[i];
	for(i=0;i<m;i++){
		cin>>x>>y;
		a[x].pb(y);
		a[y].pb(x);
	}
	for(i=1;i<=n;i++){
		ll val=h[i],f=0;
		for(auto j:a[i])
			if(j!=i&&h[j]>=val)f=1;
		if(!f)ans++;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 10280
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,j,n) for(int i=j;i<n;++i)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(), i.rend()
#define INF 1e9
#define LINF 1e18
const int mod = 998244353;
 
typedef long long i64;
typedef pair<int, int> pi;
 
template <class T> using vt = vector<T>;
template <class T> using vvt = vector<vector<T>>;
 
i64 gcd(i64 n, i64 m) {return (m == 0? n : gcd(m, n % m));}
i64 lcm(i64 n, i64 m) {return (n / gcd(n, m) * m);}
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

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

  int v[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

  int k;
  cin >> k;
  cout << v[k - 1] << endl;
}

Measured memory_bytes: 256
# 169A
# A × B  を求めてください

# 1.入力を受け取ること
a, b = map(int, input().split())
# print(a, b)

# 2.受け取った入力値を使って計算
answer = a * b  # atcoder でよく見る変数

# 3.計算した結果を出力
print(answer)



Measured memory_bytes: 9104
n = int(input())
b = [int(i) for i in input().split()]

a = [None for i in range(n)]

a[0] = b[0]
for i in range(1, n - 1):
  a[i] = min(b[i - 1], b[i])
a[n - 1] = b[n - 2]

print(sum(a))


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

int main(){
  char c;
  char b='0';
  int s=0;
  while(true){
    scanf("%c", &c);
    if(c=='0' && b=='\n')break;
    if(c=='\n'){
      cout << s << endl;
      s=0;
    } else {
      s+=int(c-'0');
    }
    b=c;
  }
}


Measured memory_bytes: 3156
#include <iomanip>
#include <iostream>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  int ans = (N + 1) / 2;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
n,m = gets.split.map(&:to_i)
sc = m.times.map{gets.split.map(&:to_i)}
1000.times{|i|
  t = i.to_s
  next if t.size!=n
  if sc.map{|(s,c)| t[s-1].to_i == c}.all?
    p i
    exit
  end
}
p -1

Measured memory_bytes: 1788
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    int N; cin >> N;
    if (N == 1) {
        cout << 1 << endl;
        return 0;
    }
    string S; cin >> S;
    auto i = begin(S);
    char prev = *i;
    for (++i; i < end(S);) {
        if (prev == *i) S.erase(i);
        else {
            prev = *i;
            i++;
        }
    }
    cout << S.size() << endl;
}


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

using namespace std;

#define endl "\n"
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define f first
#define se second
#define ALL(v) v.begin(), v.end()
#define ALLA(arr, sz) arr, arr + sz
#define SORT(v) sort(ALL(v))
#define REVERSE(v) reverse(ALL(v))
#define SORTA(arr, sz) sort(ALLA(arr, sz))
#define REVERSEA(arr, sz) reverse(ALLA(arr, sz))
#define PI 3.14159265358979323846264338327950L
#define MOD 1000000007

typedef long long ll;



void solve()
{
    int N;
    cin>>N;
    vector<int> dp(3);
    for(int i=1; i<=N; ++i)
    {
        vector<int> c(3);
        vector<int> dp2(3,0);
        for(int i=0; i<3; ++i) cin>>c[i];
        for(int i=0; i<3; ++i)
        {
            for(int j=0; j<3; ++j)
            {
                if(i!=j)
                {
                    dp2[j]=max(dp2[j],dp[i]+c[j]);
                }
            }
        }
        dp=dp2;
    }
    cout<<max(dp[0],max(dp[1],dp[2]))<<endl;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    //int t;
    //cin>>t;
    //while(t--)
    solve();
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-


import sys


class FactMod():
    '''
    modの値が素数の時のfactと組み合わせを求める
    フェルマーの小定理を用いているため、modが素数以外の時は使えない
    '''

    def __init__(self, n, mod):
        '''
        コンストラクタ
        f:nまでの i!の値を　配列に入れる
        inv: (i!)^-1　の値を配列に入れる
        '''
        self.mod = mod
        self.f = [1]*(n+1)
        for i in range(1, n+1):
            self.f[i] = self.f[i-1]*i % mod

        self.inv = [pow(self.f[-1], mod-2, mod)]
        for i in range(1, n+1)[::-1]:
            self.inv.append(self.inv[-1]*i % mod)
        self.inv.reverse()

    def fact(self, n):
        '''
        n!の値を返す
        '''
        return self.f[n]

    def comb(self, n, r):
        '''
        nCrの値を返す
        '''
        if n < r:
            return 0
        ret = self.f[n] * self.inv[n-r]*self.inv[r]
        ret %= self.mod
        return ret


# python template for atcoder1
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

n = int(input())
N = n+1
A = list(map(int, input().split()))
MOD = 10**9+7
# 重複する数字を見つける
already = set()
for i, l in enumerate(A):
    if l in already:
        dup_ind = i
        dup_num = l
        break
    else:
        already.add(l)
# 重複する数字について、その間にある数字の個数
mid_dup = dup_ind-A.index(dup_num)+1

F = FactMod(n+1, MOD)

# 全体から、重複分を除く
for k in range(1, n+2):
    all_pattern = F.comb(N, k)
    rem_pattern = F.comb(N-mid_dup, k-1)
    print((all_pattern-rem_pattern+MOD) % MOD)


Measured memory_bytes: 62732
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using ld = long double;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const long double PI = acos(-1.0L);
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
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; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, a;
  cin >> n >> a;
  if (n%500-a <= 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()

class modfact(object):
    def __init__(self, n):
        fact, invfact = [1] * (n + 1), [1] * (n + 1)
        for i in range(1, n + 1): fact[i] = i * fact[i - 1] % MOD
        invfact[n] = pow(fact[n], MOD - 2, MOD)
        for i in range(n - 1, -1, -1): invfact[i] = invfact[i + 1] * (i + 1) % MOD
        self._fact, self._invfact = fact, invfact

    def fact(self, n):
        return self._fact[n]

    def invfact(self, n):
        return self._invfact[n]

    def comb(self, n, k):
        return self._fact[n] * self._invfact[k] % MOD * self._invfact[n - k] % MOD if 0 <= k <= n else 0

    def perm(self, n, k):
        return self._fact[n] * self._invfact[n - k] % MOD if 0 <= k <= n else 0

def resolve():
    n, m = map(int, input().split())
    mf = modfact(m)
    ans = 0
    for k in range(n + 1):
        if k & 1:
            ans -= mf.comb(n, k) * mf.perm(m - k, n - k)
        else:
            ans += mf.comb(n, k) * mf.perm(m - k, n - k)
        ans %= MOD
    ans *= mf.perm(m, n)
    ans %= MOD
    print(ans)
resolve()

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

using namespace std;

using ll = long long;

const ll MOD = 1000000007;

struct Union_Find {
    //各要素が属する集合の代表(根)を管理する
    //もし、要素xが根であればdata[x]は負の値を取り、-data[x]はxが属する集合の大きさに等しい
    vector<int> data;

    Union_Find(int size) : data(size, -1) {}
    bool Union(int x, int y) {
        x = Find(x);
        y = Find(y);
        bool is_union = (x != y);
        if (is_union) {
            if (data[x] > data[y]) swap(x, y);
            data[x] += data[y];
            data[y] = x;
        }
        return is_union;
    }
    int Find(int x) {
        if (data[x] < 0) { //要素xが根である
            return x;
        } else {
            data[x] = Find(data[x]); //data[x]がxの属する集合の根でない場合、根になるよう更新される
            return data[x];
        }
    }
    bool same(int x, int y) {
        return Find(x) == Find(y);
    }
    int size(int x) {
        return -data[Find(x)];
    }
};

struct Edge {
    int u, v;
    ll cost;
    bool operator<(const Edge& e) const {
        return cost < e.cost;
    }
};

ll modpow(ll x, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % MOD;
        x = x * x % MOD;
        n >>= 1;
    }
    return res;
}

ll solve(ll x, int m, vector<ll>& ds) {
    int len = ds.end() - upper_bound(ds.begin(), ds.end(), x) + 1;
    len = min(m, len);
    return modpow(2, len);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    ll x;
    cin >> x;
    vector<Edge> es(m);
    for (int i = 0; i < m; i++) {
        cin >> es[i].u >> es[i].v >> es[i].cost;
        es[i].u--;
        es[i].v--;
    }

    sort(es.begin(), es.end());
    vector<ll> ds(m);
    for (int i = 0; i < m; i++) {
        ll min_cost = es[i].cost;
        Union_Find uf(n);
        uf.Union(es[i].u, es[i].v);
        for (int j = 0; j < m; j++) {
            if (!uf.same(es[j].u, es[j].v)) {
                uf.Union(es[j].u, es[j].v);
                min_cost += es[j].cost;
            }
        }
        ds[i] = min_cost;
    }
    
    sort(ds.begin(), ds.end());
    cout << (solve(x - 1, m, ds) - solve(x, m, ds) + MOD) % MOD << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = Integer.parseInt(sc.next());
		
		char []c = sc.next().toCharArray();
		
		
		int ans = 0;
		
		for(int i = 0 ;i < n-2 ;i++) {
			if(c[i] == 'A' && c[i+1] == 'B' && c[i+2] == 'C') 
				ans++;
		}
		
		System.out.println(ans);

	}

}


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

#define MOD 1000000007
#define ll long long int 
#define off ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

int main()
{
    off;    
    string s, t;cin>>s>>t;

    int ls = s.length(), lt = t.length();

    int dp[ls][lt];

    dp[0][0] = (s[0]==t[0])?1:0;

    for (int i = 1; i < ls; ++i)
    {
      dp[i][0] = dp[i-1][0];
      if(s[i]==t[0]) dp[i][0] = 1;
    }

    for (int i = 1; i < lt; ++i)
    {
      dp[0][i] = dp[0][i-1];
      if(s[0]==t[i]) dp[0][i] = 1;
    }

    for (int i = 1; i < ls; ++i)
    {
      for (int j = 1; j < lt; ++j)
      {
        dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
        if(s[i]==t[j])
          dp[i][j] = max(dp[i-1][j-1]+1, dp[i][j]);
        else
          dp[i][j] = max(dp[i-1][j-1], dp[i][j]);
      }
    }

    string ans = "";

    int a = ls-1, b = lt-1;
    while(a>=0 && b>=0){
      if(dp[a][b]==dp[a-1][b]) a--;
      else if(dp[a][b]==dp[a][b-1]) b--;
      else {
        if(s[a]==t[b]){
          ans = s[a] + ans;
        }
        a--;b--;
      }
    }

    cout<<ans;

    return 0;
}

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

#define DB	double
#define lf	else if
#define	I64	long long
#define Rd()	(rand() << 15 | rand())
#define For(i,a,b)	for(int i=a;i<=b;i++)
#define Rep(i,a,b)	for(int i=a;i>=b;i--)
	
#define fi	first
#define se	second
#define MK	make_pair
#define PA	pair<int, int>

#define CH	(ch=getchar())
int		IN()	{
		int x= 0, f= 0, ch;
		for (; CH < '0' || ch > '9';)	f= (ch == '-');
		for (; ch >= '0' && ch <= '9'; CH)	(x*= 10)+= ch - '0';
		return	f ? -x : x;
}

#define n	505

int		N, C[n], S[n], F[n];

int		main()	{
		N= IN() - 1;
		For(i, 1, N)	C[i]= IN(), S[i]= IN(), F[i]= IN();

		For(st, 1, N)	{
			int T= 0;
			For(i, st, N)	{
				if	(T <= S[i])	T= S[i];
				else	{
					for (; (T - S[i]) % F[i]; )	T++;
				}
				
				T+= C[i];
			}
			
			cout << T << endl;
		}
		
		cout << 0 <<endl;
}


Measured memory_bytes: 256