akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define fst first
#define snd second
#define rep(n) for(lint I = 0; (I) < (lint)(n); ++(I))
#define repeat(i, n) for(lint i = 0; (i) < (lint)(n); ++(i))
#define repeat_to(i, n) for(lint i = 0; (i) <= (lint)(n); ++(i))
#define repeat_from(i, m, n) for(lint i = (m); (i) < (lint)(n); ++(i))
#define repeat_from_to(i, m, n) for(lint i = (m); (i) <= (lint)(n); ++(i))
#define repeat_reverse_from_to(i, m, n) for(lint i = (m); (i) >= (lint)(n); --(i))
#define el cout<<endl
#define dump(x) cout<<" "<<#x<<"="<<x
#define pdump(p) cout<<" "<<#p<<"=("<<p.fst<<","<<p.snd<<")"
#define vdump(v) for(size_t I=0; I<v.size(); ++I){cout<<" "<<#v<<"["<<I<<"]="<<v[I];} cout<<endl
using namespace std; using lint = long long; using ld = long double;
using pii = pair<int, int>; using pll = pair<lint, lint>;

int main(void) {
    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    repeat (i, n) cin >> h[i];
    sort(h.begin(), h.end());
    
    int ans = 1e9 + 1;
    repeat (i, n - k + 1) {
        //cout << "h[" << i+k-1 << "]-h[" << i << "]=" << h[i+k-1] - h[i] << endl;
        ans = min(ans, h[i+k-1] - h[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main() {
  int k; cin >> k;
  int s = 0;
  for (int a = 1; a <= k; a++) {
    for (int b = 1; b <= k; b++) {
      for (int c = 1; c <= k; c++) {
        s += __gcd(a, __gcd(b, c));
      }
    }
  }
  cout << s << endl;
}

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

int n, A[20];

bool solve(int i, int m){
    if(m==0){
        return true;
    }
    if(i>=n){
        return false;
    }
    bool res = solve(i+1, m) || solve(i+1, m-A[i]);
    return res;
}

int main(){
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> A[i];
    }
    int q;
    cin >> q;
    int m[q];
    for(int j=0;j<q;j++){
        cin >> m[j];
    }
    
    for(int j=0;j<q;j++){
        if(solve(0, m[j])){
            cout << "yes" << endl;
        }else{
            cout << "no" << endl;
        }
    }
    
    return 0;
}


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

int main(){
    int N; cin >> N;
    int i;
    map <string,int> cnt;
    string S;
    for(i = 0;i < N;i++){
        cin >> S;
        cnt[S]++;
    }
    for(string s : {"AC","WA","TLE","RE"}){
       cout << s << " x " << cnt[s] << endl;
    }
   

    return 0;
}

Measured memory_bytes: 3564
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n,k;cin>>n>>k;
  cout<<n*n-k<<endl;

  return 0;

}


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

//以下大槻型 ただし文字は自分のものに合わせた。

// グラフを隣接行列で管理する
bool edge[8][8];
 
int main() {
    int n, m; cin >> n >> m;
    for (int i = 0; i < m; i++) {
        int x, y; cin >> x >> y;
        edge[x-1][y-1] = edge[y-1][x-1] = true;
    }
 
    // 順列
    vector<int> ord(n);
    for (int i = 0; i < n; i++) ord[i] = i;
 
    // 順列を全部試す
    int ans = 0;

    
    do {
        if (ord[0] != 0) break;
 
        bool ok = true;
        for (int i = 0; i +1 < n; i++) {
            int from = ord[i];
            int to = ord[i+1];
            if (!edge[from][to]) ok = false;
        }
        if (ok) ans++;
      } while (next_permutation(ord.begin(), ord.end()));
 
    cout << ans << endl;
}


Measured memory_bytes: 3568
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

type pos struct {
	x, y int
}

func main() {
	sc.Split(bufio.ScanWords)
	H, W, N := getInt(), getInt(), getInt()
	total := (H - 2) * (W - 2)

	p := make([]pos, N)
	for i := 0; i < N; i++ {
		x, y := getInt()-1, getInt()-1
		p[i] = pos{x, y}
	}

	q := make(map[pos]int)
	for _, i := range p {
		// out("black", i)
		for x := -1; x <= 1; x++ {
			for y := -1; y <= 1; y++ {
				px := i.x + x
				py := i.y + y
				// out("---", px, py)
				if px <= 0 || px >= H-1 {
					continue
				}
				if py <= 0 || py >= W-1 {
					continue
				}
				// out(px, py)
				q[pos{px, py}]++
			}
		}
	}

	J := make([]int, 10)
	for _, v := range q {
		J[v]++
		total--
	}
	out(total)
	for i := 1; i < 10; i++ {
		out(J[i])
	}
}


Measured memory_bytes: 115456
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())
#define fi first
#define se second

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<endl;
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;
const ll inf=1e15;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s,t;
  cin>>s>>t;
  int ans=0;
  rep(i,3) if(s[i]==t[i]) ans++;
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
	int N;
	cin >> N;
	string S;
	cin >> S;
	string ans = "No";
	if (N % 2 == 0) {
		string T = S.substr(0, N / 2);
		if (S == T + T) ans = "Yes";
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
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; }
int main(){
    ios::sync_with_stdio(false);
    ll n,k;
    cin >> n >> k;
    vector<ll> num(100001,0);
    rep(i,n) {
        ll a,b;
        cin >> a >> b;
        num[a] += b;
    }
    vector<ll> sum(num.size());
    partial_sum(num.begin(), num.end(), sum.begin());
    auto pos = lower_bound(sum.begin(), sum.end(), k);
    ll idx = distance(sum.begin(), pos);
    cout << idx << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
namespace mine
{
    typedef long long ll;
    #define pr pair<int,int>
    #define FR first
    #define SE second
    #define MP make_pair
    #define PB push_back
    #define vc vector
    #define all(x) (x).begin(),(x).end()
    #define sz(x) ((int)(x).size())
    #define bin(x) (1ll<<(x))
    #define GG(x) if(x) puts("error")
    ll qread()
    {
        ll ans=0,f=1;char c=getchar();
        while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
        while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
        return ans*f;
    }
    void write(ll num)
    {
        if(num<0) putchar('-'),num=-num;
        if(num>=10) write(num/10);
        putchar('0'+num%10);
    }
    void write1(ll num){write(num);putchar(' ');}
    void write2(ll num){write(num);putchar('\n');}
    template<typename T> void chmax(T &x,const T y) {x=(x>y?x:y);}
    template<typename T> void chmin(T &x,const T y) {x=(x<y?x:y);}
    ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

    const int INF=0x3f3f3f3f;
    const int MOD=993244853;
    inline int mm(const int x){return x>=MOD?x-MOD:x;}
    template<typename T> inline void add(T &x,const T y){x=mm(x+y);}
    inline ll qpower(ll x,ll e)
    {
        ll ans=1;GG(e<0);
        while(e){if(e&1)ans=ans*x%MOD;x=x*x%MOD;e>>=1;}
        return ans;
    }
    ll invm(ll x){return qpower(x,MOD-2);}
    const int N=1e5+10;

    priority_queue<int> q;
    void main()
    {
        int n=qread(),m=qread();for(int i=1;i<=n;i++) q.push(qread());
        while(m--)
        {
            int pp=q.top();q.pop();
            q.push(pp/2);
        }
        ll sum=0;
        while(q.size()) sum+=q.top(),q.pop();write(sum);
    }//(ans+MOD)%MOD
};
int main()
{
    srand(time(0));
    mine::main();
}


Measured memory_bytes: 892
#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 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;};

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,x;
    cin>>n>>x;
    vector<int> l(n);
    REP(i,n) cin>>l[i];
    int d = 0;
    int ans = 1;
    for(int i=0;i<n;i++){
        d+=l[i];
        if(d<=x) ans++;
    }
    cout<<ans<<endl;
}


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

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

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

    int ans = 0;
    for (int i=0; i<N-1; i++) {
        if (v[i] == i+1 && v[i+1] == i+2) {
            swap(v[i], v[i+1]);
            ans++;
        }
    }
    for (int i=0; i<N-1; i++) {
        if (v[i] == i+1 || v[i+1] == i+2) {
            swap(v[i], v[i+1]);
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();
		char [][] field = new char[H][W];
		for(int i=0;i<H;i++){
				field[i]=sc.next().toCharArray();
		}
		for(int i=0;i<H;i++){
			int Answer = -1;
			for(int j=0;j<W;j++){
				if(field[i][j]=='c'){
					Answer=0;
				}else if(Answer>=0){
					Answer++;
				}
				System.out.print(Answer);
				if(j!=W-1) System.out.print(" ");
			}
			System.out.println("");
		}
	}
}

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

int dp[100005];
int h[100005];

int n;

int f(int i, int cost)
{
 int& x = dp[i];
 if(x != -1) return x;

 if(i == n) return cost;
 if(i+1 == n) return cost+abs(h[i]-h[i+1]);
 
 return x = min(f(i+1, cost+abs(h[i]-h[i+1])), f(i+2, cost+abs(h[i]-h[i+2])));
}

int main()
{
  cin >> n;
  for(int i = 1; i <= n; ++i) { cin >> h[i]; dp[i] = -1; }

  dp[1] = 0;
  dp[2] = abs(h[2]-h[1]);
  for(int i = 3; i <=n; ++i)
  {
    dp[i] = min(dp[i-2]+abs(h[i]-h[i-2]), dp[i-1]+abs(h[i]-h[i-1]));
  }
  cout << dp[n] << endl;
}


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

int main(){
  int n;
  cin >> n;
  vector<int> w(n+10);
  rep(i,n) cin >> w[i];
  int dis = 100;
  rep(t,n){
    int a = 0;
    int b = 0;
    rep(i,n){
      if(i <= t) a += w[i];
      else b += w[i];
    }
    if(dis > abs(b-a)){
      dis = abs(b-a);
    }
  }
  cout << dis << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cmath>
#include <complex>
#include <cctype>
#include <cassert>
#include <sstream>
#include <ctime>
 
using namespace std;
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
 
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
 
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> P;
 
const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS  = 1e-10;
 
ll N, K;
ll cnt[112345];
 
int main() {
	cin >> N >> K;
	REP(i, N) {
		int a, b;
		scanf("%d %d", &a, &b);
		cnt[a] += b;
	}
	
	ll now = 0;
	REP(i, 112345) {
		if (now + cnt[i] >= K) {
			printf("%d\n", i);
			break;
		}
		now += cnt[i];
	}
	return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <iostream>
#include <cassert>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <deque>
using namespace std;
typedef long long LL;
typedef long double LD;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;

int main() {
    int n;
    scanf("%d", &n);
    set<pii> ans;
    for (int i = 1; i <= n; i++) {
        for (int j = i + 1; j <= n; j++) {
            ans.insert(make_pair(i, j));
        }
    }
    if (n % 2 == 0) {
       for (int i = 1; i <= n; i++) {
           int a = n + 1 - i , b = i;
           if (a > b) swap(a, b);
           if (ans.count(make_pair(a, b)))
              ans.erase(make_pair(a, b));
       }
    } else {
       for (int i = 1; i < n; i++) {
           int a = n - i , b = i;
           if (a > b) swap(a, b);
           if (ans.count(make_pair(a, b)))
              ans.erase(make_pair(a, b));
       }
    }
    printf("%d\n", (int)ans.size());
    for (auto i : ans) printf("%d %d\n", i.first, i.second);
    return 0;
}


Measured memory_bytes: 512
//B - Product Max
//Hiia
#include <stdio.h>
#include <stdlib.h>//rannsuu, zettaichi(absolute)
#include <time.h>
//srand((unsigned int) time(0));
#include <math.h>//koudona keisann
#include <string.h>//hairetsu
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
typedef long long ll;
//#define N 998244353
#define pi 3.1415926535897932384626433832

int gcd(int m,int n){if((0==m)||(0==n))return 0;while(m!=n)if(m>n)m=m-n;else n=n-m;return m;}
int lcm(int m,int n){if((0==m)||(0==n))return 0;return(m*n/gcd(m, n));}
int fact(int x){if(x==1) return(x);else return(x*fact(x-1));}//Kaijou x!
int ruijou(int base,int exponent){int i,answer=1;i=exponent;while(i!=0){answer=answer*base;--i;}return answer;}//ruijou base^exponent

long long int llgcd(long long int m,long long int n){if((0==m)||(0==n))return 0;while(m!=n)if(m>n)m=m-n;else n=n-m;return m;}
long long int lllcm(long long int m,long long int n){if((0==m)||(0==n))return 0;return(m*n/llgcd(m, n));}
long long int llfact(long long int x){if(x==1) return(x);else return(x*llfact(x-1));}//Kaijou
int llruijou(long long int base,long long int exponent){long long int i,answer=1;i=exponent;while(i!=0){answer=answer*base;--i;}return answer;}//ruijou base^exponent

int main()
{
  ll a,b,c,d,n,i;
  scanf("%lld %lld %lld %lld", &a,&b,&c,&d);

  ll ans1, ans2, ans3, ans4;
  ans1=a*d;
  ans2=b*c;
  ans3=a*c;
  ans4=b*d;

  printf("%lld\n", max(max(ans1,ans2),max(ans3,ans4)) );
  return 0;
}


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

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll A[25];
ll B[25];
ll C[25];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll ans = 0;
    REP(i, N) {
        cin >> A[i];
    }
    REP(i, N) {
        cin >> B[i];
        ans += B[i];
    }
    REP(i, N - 1) {
        cin >> C[i];
    }
    REP(i, N - 1) {
        if (A[i + 1] == A[i] + 1)
            ans += C[A[i] - 1];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,ans=0;
  cin >>N;
  string S;
  cin >>S;
  for(int i=0; i<S.size()-2; i++){
    if(S[i]=='A'){
      if(S[i+1]=='B'){
        if(S[i+2]=='C'){
          ans++;
        }
      }
    }
  }
  cout <<ans <<endl;
}


Measured memory_bytes: 256
n=int(input())
*h,=map(int,input().split())

dp=[float('inf')]*n
dp[0]=0

for i in range(n-1):
      dp[i+1]=min(dp[i+1],dp[i]+abs(h[i+1]-h[i]))
      if i<(n-2):
            dp[i+2]=min(dp[i+2],dp[i]+abs(h[i+2]-h[i]))

print(dp[-1])


Measured memory_bytes: 13928
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			int a = sc.nextInt();
			int b = sc.nextInt();
			if(a >=1 && a <=100) {
				if(b >=1 && b <=100) {
					System.out.println(a*b +" " + 2*(a+b));			
				}
			}
		}
	}
}

Measured memory_bytes: 25944
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    resolve(System.in, System.out);
  }

  static void resolve(InputStream is, PrintStream pw) {
    Scanner sc = new Scanner(is);
    int n = Integer.parseInt(sc.next());
    int m = Integer.parseInt(sc.next());
    Integer[] condition = new Integer[n + 1];
    for (int i = 0; i < m; i++) {
      int s = Integer.parseInt(sc.next());
      int c = Integer.parseInt(sc.next());
      if (condition[s] != null && condition[s] != c) {
        pw.println(-1);
        return;
      }
      condition[s] = c;
    }
    if (condition[1] != null && condition[1] == 0 && n != 1) {
      pw.println(-1);
      return;
    }
    StringBuilder answer = new StringBuilder();
    if (condition[1] != null) {
      answer.append(condition[1]);
    } else {
      answer.append(n == 1 ? "0" : "1");
    }
    for (int i = 2; i <= n; i++) {
      if (condition[i] != null) {
        answer.append(condition[i]);
      } else {
        answer.append(0);
      }
    }
    pw.println(answer.toString());
  }
}


Measured memory_bytes: 22996
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

int ba[12][12];
int dx[] = {1,0,-1,0};
int dy[] = {0,-1,0,1};
void dfs(int x,int y) {
  REP(i,4) {
    int xx = x+dx[i];
    int yy = y+dy[i];
    if (xx<0||xx>=12||yy<0||yy>=12) continue;
    if (ba[xx][yy]) {
      ba[xx][yy] = 0;
      dfs(xx,yy);
    }
  }
}

int main() {
  char b;
  while(cin >> b) {
    ba[0][0] = b-'0';
    REP(i,12) {
      REP(j,12) {
        if (i==0&&j==0)continue;
        char a;
        cin >> a;
        ba[j][i] = a-'0';
      }
    }
    int ans = 0;
    REP(i,12) {
      REP(j,12) {
        if (ba[i][j]) {
          ans++;
          dfs(i,j);
        }
      }
    }
    cout << ans << endl;
  }
}

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

int main()
{
    // 入力
    string S;
    cin >> S;

    string prevS = "";
    string currentS = "";
    int k = 0;
    rep (i, S.size()) {
        currentS = currentS + S[i];
        if (prevS != currentS) {
            prevS = currentS;
            currentS = "";
            k++;
        }
    }

    // 出力
    cout << k << endl;
    return 0;
}


Measured memory_bytes: 640
N,K = map(int,input().split())
A = list(map(int,input().split()))

bs = [0] * 40
for a in A:
    for k in range(40):
        if a&(1<<k):
            bs[k] += 1

x = 0
for k in range(39,-1,-1):
    if x + (1<<k) > K: continue
    if bs[k] < (N+1)//2:
        x += (1<<k)

ans = 0
for a in A:
    ans += x^a
print(ans)


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

int main(){
    int n;
  	cin>>n;
    int v[n];
    int c[n];
    for(int i=0;i<n;i++) cin>>v[i];
    for(int i=0;i<n;i++) cin>>c[i];
    int x=0;
    int y=0;
    for(int i=0;i<n;i++) {
        if(v[i]>c[i]) {
            x+=v[i];
            y+=c[i];
        }
    }
    cout<<x-y<<endl;
  	return 0;
}


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

//sort(v.rbegin(), v.rend(), [](auto& x, auto& y){return x[1] < y[1];});
typedef long long ll;

int main(){
    int Q,res=0,l,r;
    cin >> Q;
    vector<bool> v(1e5+5,true);

    v[1]=false;

    for (int i=2;i<v.size();i++){
        if(v[i]){
            for(int j=2*i;j<v.size();j+=i){
                v[j] = false;
            }
        }
    }

    vector<int> v2(v.size(),0);
    for (int i=3;i<v2.size();i+=2){
            v2[i]=v2[i-2];
            if(v[i]&&v[(i+1)/2]){
                v2[i]+=1;
        }
    }

    for (int i=0;i<Q;++i){
        cin >> l >> r;
        if (l!=1) res = v2[r] - v2[l-2];
        else res = v2[r];
        cout << res << endl;
    }
}

Measured memory_bytes: 1024
//Date:10-06-17

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#include<float.h>
#include<math.h>
#include<inttypes.h>
#include<assert.h>
#include<ctype.h>
#include<limits.h>
#include<time.h>
#define ll long long
#define For(i,n)	for(i=0;i<n;i++)
#define rep(i ,a ,b)	for(i=(a);i<=(b);i++)
#define mset(a ,value)	memset(a ,value ,sizeof(a))
#define s(a)	scanf("%d" ,&a);
#define ls(a)	scanf("%ld" ,&a)
#define lls(a)	scanf("%lld" ,&a);
#define reg(i)	register int i
#define infinite INT_MAX
#define MAX 100001
#define NIL -1
int min(int a,int b){	return (a<b?a:b);	}
int max(int a,int b){	return (a>b?a:b);	}
main(){
	int n ,i;
	s(n);
	char s[n+1];
	scanf(" %s" ,s);
	int a=0 ,b=0;
	For(i ,n){	
		if(s[i]=='(')	a++;	
		else{
			b++;
			while(b>a){
				printf("(");
				a++;
			}
		}
	}
	printf("%s" ,s);
	while(a>b){
		printf(")");
		b++;
	}
	return 0;
}

Measured memory_bytes: 128
open System
open System.Numerics

// prelude
let readStr () = stdin.ReadLine()

let readInt () = stdin.ReadLine() |> int
let readInts () = stdin.ReadLine().Split() |> Array.map int

let pair = function
| [|a; b|] -> (a, b)
| _ -> failwith "owatta"

let triple = function
| [|a; b; c|] -> (a, b, c)
| _ -> failwith "owatta"

let inc n = n + 1
let dec n = n - 1

module Option =
  let getOr defaultValue = function
  | Some x -> x
  | None -> defaultValue
  
module Array =
  let modify (arr: _ []) i f =
    arr.[i] <- f arr.[i]

module Array2D =
  let modify (arr: _ [,]) i j f =
    arr.[i, j] <- f arr.[i, j]

// start

let rec popCnt = function
| 0 -> 0
| n -> (if (n &&& 1) <> 0 then 1 else 0) + popCnt (n>>>1)

let main () =
  let (H, W, K) = readInts() |> triple

  let grid =
    let g = Array2D.create H W 0
    for y in 0..(H-1) do
      let s = readStr().ToCharArray()
      for x in 0..(W-1) do
        g.[y, x] <- if s.[x] = '1' then 1 else 0
    g

  seq {
    for split in 0..((1<<<H-1)-1) do
      let sum =
        let s = Array2D.create 10 W 0
        let mutable i = 0
        for y in 0..(H-1) do
          for x in 0..(W-1) do
            Array2D.modify s i x ((+) grid.[y, x])
          if (split &&& (1<<<y)) <> 0 then do i <- i + 1
        for y in 0..(10-1) do
          for x in 1..(W-1) do
            Array2D.modify s y x ((+) s.[y, x-1])
        s
      
      let pred x1 x2 =
        [0..9]
        |> List.forall (fun i ->
          let c = sum.[i, x2] - if x1=0 then 0 else sum.[i, x1-1]
          c <= K
        )
      
      let rec loop x1 x2 =
        if pred x1 x2 then 0
        else
          let rec f x = if pred x1 x then f (x+1) else x
          let x' = f x1
          if x'=x1 then 10*1000
          else 1 + loop x' x2

      let cnt = loop 0 (W-1) + popCnt split
      yield cnt
  }
  |> Seq.min
  |> printfn "%A"

main()

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

typedef long long ll;

const int maxn = 1e5 + 5;

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

  int N, M, C; cin >> N >> M >> C;
  vector<int> b(M);
  for (auto& x : b) {
    cin >> x;
  }
  vector<vector<int>> a(N, vector<int>(M));
  for (auto& x : a) {
    for (auto& y : x) {
      cin >> y;
    }
  }
  int ans = 0;
  for (auto& v : a) {
    int sum = C;
    for (int i = 0; i < M; i++) {
      sum += v[i] * b[i];
    }
    if (sum > 0) {
      ++ans;
    }
  }
  cout << ans << "\n";
}


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

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

ll ans;
int cnt[100005];
int id[100005];

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

    int N; cin >> N;

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

    memset(cnt,-1,sizeof(cnt));
    memset(id,-1,sizeof(id));

    ans = 0;

    for (int i = 0;i < N;i++){
        int pos = i;
        int depth = 0;
        while(cnt[pos] == -1){
            cnt[pos] = depth;
            id[pos] = i;
            pos = (pos+a[pos])%N;
            depth++;
        }
        if(id[pos] == i) ans += (depth-cnt[pos]);
    }

    cout << ans << endl;

    return 0;

}


Measured memory_bytes: 4328
int main(){

int m=0,f=0,r=0;

while(1){
	
	scanf("%d %d %d",&m,&f,&r);	
	if(m==-1 && f==-1){
      if(r==-1)break;
    }
	
	if(m==-1 || f==-1){
		printf("F\n");
	}
	else if(m+f>=80){
		printf("A\n");
	}
	else if(m+f<80 && m+f>=65){
		printf("B\n");
	}
	else if(m+f<65 && m+f>=50){
		printf("C\n");
	}
	else if(m+f>=30 && m+f<50){
		if(r>=50){
			printf("C\n");
		}
		else{printf("D\n");}
	}
	else if(m+f<30){
		printf("F\n");
	}
}

return 0;
}	

Measured memory_bytes: 584
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#define MOD 1000000007
#define ll long long
using namespace std;

int main() {
    string s;
    cin >> s;
    int n = s.size();
    vector<vector<ll>> dp(n+1, vector<ll>(13, 0));

    dp[0][0] = 1;
    for (int i=0; i<n; ++i) {
        int c;
        if (s[i] == '?') c = -1;
        else c = s[i] - '0';
        
        for (int j=0; j<10; ++j) {
            if (c != -1 && c != j) continue;
            for (int ki=0; ki<13; ++ki) {
                dp[i+1][(ki*10+j)%13] += dp[i][ki];
            }
        }
        for (int j=0; j<13; ++j) {
            dp[i+1][j] %= MOD;
        }
    }
    cout << dp[n][5] << endl;
    
    return 0;
}

Measured memory_bytes: 13696
import java.util.*;
import static java.lang.Math.*;

public class Main {

	class Star{
		double x, y, z;
		Star(double _x, double _y, double _z){
			this.x = _x;
			this.y = _y;
			this.z = _z;
		}
		Star(double theta, double phi){
			this.x = cos(theta)*cos(phi);
			this.y = sin(theta)*cos(phi);
			this.z = sin(phi);
		}
		Star rotAround(Star n, double th){
			double nx = (n.x*n.x*(1-cos(th)) + cos(th))*this.x
						+ (n.x*n.y*(1-cos(th)) - n.z*sin(th))*this.y
						+ (n.z*n.x*(1-cos(th)) + n.y*sin(th))*this.z,
					ny = (n.x*n.y*(1-cos(th)) + n.z*sin(th))*this.x
						+ (n.y*n.y*(1-cos(th)) + cos(th))*this.y
						+ (n.y*n.z*(1-cos(th)) - n.x*sin(th))*this.z,
					nz = (n.z*n.x*(1-cos(th)) - n.y*sin(th))*this.x
						+ (n.y*n.z*(1-cos(th)) + n.x*sin(th))*this.y
						+ (n.z*n.z*(1-cos(th)) + cos(th))*this.z;
			return new Star(nx,ny,nz);
		}
	}

	Star NorthStar = new Star(PI, 43.2*PI/180.0);
	int[] month = {0,31,29,31,30,31,30,31,31,30,31,30,31};

	void run(){
		Scanner in = new Scanner(System.in);
		in.useDelimiter("[/:\\s]");
		int T = in.nextInt();
		while(T-- > 0){
			int mon = in.nextInt();
			int day = in.nextInt();
			int hour = in.nextInt();
			int min = in.nextInt();
			for(int i=0; i<mon; i++){
				day += month[i];
			}
			day--;
			min += (day*24+hour)*60;
			double angle = min*(1.0 + 1.0/365.24)*2*PI/60.0/24.0;
			int n = in.nextInt();
			for(int i=0; i<n; i++){
				String name = in.next();
				int m = in.nextInt();
				boolean canSee = true;
				for(int j=0; j<m; j++){
					double a = in.nextDouble(), h = in.nextDouble();
					Star st = new Star((180-a)*PI/180.0,h*PI/180.0);
					st = st.rotAround(NorthStar, -angle);
					if(st.z < 0) canSee = false;
				}
				if(canSee){
					System.out.println(name);
				}
			}
		}
	}

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

Measured memory_bytes: 13000
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
struct Node
{
	int l, r, lval, rval;
}a[maxn];
int n, m, q, r[maxn];
void prework()
{
	a[0].r = a[0].rval = m;
	for(int i = 1; i <= n; ++i)
	{
		int t = r[i] - r[i - 1];
		if(i & 1) //下降
		{
			if(a[i - 1].r <= t)
			{
				a[i].l = 0;
				a[i].r = 0;
				a[i].lval = a[i - 1].rval;
				a[i].rval = a[i - 1].rval;
			}
			else if(a[i - 1].l >= t)
			{
				a[i].l = a[i - 1].l - t;
				a[i].r = a[i - 1].r - t;
				a[i].lval = a[i - 1].lval;
				a[i].rval = a[i - 1].rval;
			}
			else
			{
				a[i].l = 0;
				a[i].r = a[i - 1].r - t;
				a[i].lval = a[i - 1].lval + (t - a[i - 1].l);
				a[i].rval = a[i - 1].rval;	
			}
		}
		else //上升 
		{
			if(a[i - 1].r + t <= m)
			{
				a[i].l = a[i - 1].l + t;
				a[i].r = a[i - 1].r + t;
				a[i].lval = a[i - 1].lval;
				a[i].rval = a[i - 1].rval;
			}
			else if(a[i - 1].l + t >= m)
			{
				a[i].l = m;
				a[i].r = m;
				a[i].lval = a[i - 1].lval;
				a[i].rval = a[i - 1].lval;
			}
			else
			{
				a[i].l = a[i - 1].l + t;
				a[i].r = m;
				a[i].lval = a[i - 1].lval;
				a[i].rval = a[i - 1].rval - (t - (m - a[i - 1].r));
			}
		}
	}
}
int main()
{
	scanf("%d%d", &m, &n);
	for(int i = 1; i <= n; ++i) scanf("%d", &r[i]);
	prework();
	scanf("%d", &q);
	while(q--)
	{
		int t, val;
		scanf("%d%d", &t, &val);
		int i = upper_bound(r + 1, r + n + 1, t) - r - 1, cur;
		if(val < a[i].lval) cur = a[i].l;
		else if(val > a[i].rval) cur = a[i].r;
		else cur = a[i].l + (val - a[i].lval);
		t -= r[i];
		if(i & 1) //上升
			cur = min(m, cur + t);
		else //下降 
			cur = max(0, cur - t);
		printf("%d\n", cur);
	}
	return 0;
}

Measured memory_bytes: 3200
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<bitset>

#define pb push_back
#define mp make_pair

using namespace std;

template<typename T>inline void upmin(T &x,T y) { y<x?x=y:0; }
template<typename T>inline void upmax(T &x,T y) { x<y?x=y:0; }

typedef unsigned int u32;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double lod;
typedef pair<int,int> PR;
typedef vector<int> VI;

const lod pi=acos(-1);
const int oo=1<<30;
const LL OO=1e18;

const int N=1e5;

int gi() {
	int w=0;bool q=1;char c=getchar();
	while ((c<'0'||c>'9') && c!='-') c=getchar();
	if (c=='-') q=0,c=getchar();
	while (c>='0'&&c <= '9') w=w*10+c-'0',c=getchar();
	return q? w:-w;
}

PR p[N];
int main()
{
	int n=gi(),i,ans=0;LL s=0;priority_queue<int>q;
	for (i=1;i<=n;i++) p[i].first=gi(),p[i].second=gi(),p[i].first+=p[i].second;
	sort(p+1,p+1+n);
	for (i=1;i<=n;i++)
		if (s+p[i].second<=p[i].first)
			s+=p[i].second,ans++,q.push(p[i].second);
		else
			if (!q.empty()&&p[i].second<q.top())
				s-=q.top(),q.pop(),q.push(p[i].second),s+=p[i].second;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<vector>


int main(void){
    int n, m;
    std::cin >> n >> m;
    std::vector<int> h(n);
    for(int i = 0; i < n; i++){
	std::cin >> h[i];
    }
    int a, b;
    std::vector<std::vector<int>> k;
    k.resize(n);
    for(int i = 0; i < m; i++){
	std::cin >> a >> b;
	a--;
	b--;
	k[a].push_back(b);
	k[b].push_back(a);
    }

    int ans = 0;
    for(int i = 0; i < n; i++){
	bool flag = 0;
	for(int j = 0; j < k[i].size(); j++){
	    if(h[i] <= h[k[i][j]]){
		flag = 1;
	    }
	}
	if(!flag) ans++;
    }
    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 8700
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979;
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int n) { return n & 1; }
constexpr bool even(const int n) { return ~n & 1; }
template<typename T = int> T in() { T x; cin >> x; return x; }
template<typename T = int> T in(T &&x) { T z(forward<T>(x)); cin >> z; return z; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &x : v) is >> x; return is; }
template<typename A, typename B> istream &operator>>(istream &is, pair<A, B> &p) { return is >> p.first >> p.second; }
template<typename T> ostream &operator<<(ostream &os, const vector<vector<T>> &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "" : "\n"); return os; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "" : " "); return os; }
template<typename A, typename B> ostream &operator<<(ostream &os, const pair<A, B> &p) { return os << p.first << ' ' << p.second; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
// clang-format on

int p[24][3] = {{1, 2, 3}, {1, 3, 5}, {1, 5, 4}, {1, 4, 2}, {2, 1, 4}, {2, 4, 6}, //
                {2, 6, 3}, {2, 3, 1}, {3, 1, 2}, {3, 2, 6}, {3, 6, 5}, {3, 5, 1}, //
                {4, 1, 5}, {4, 5, 6}, {4, 6, 2}, {4, 2, 1}, {5, 1, 3}, {5, 3, 6}, //
                {5, 6, 4}, {5, 4, 1}, {6, 2, 4}, {6, 4, 5}, {6, 5, 3}, {6, 3, 2}};

bool iso(const vector<int> &v, const vector<int> &w) {
  bool f = false;
  rep(i, 24) {
    bool g = true;
    rep(j, 3) g &= v[j] == w[p[i][j] - 1] && v[j + 3] == w[6 - p[i][2 - j]];
    f |= g;
  }
  return f;
}

main {
  int n;
  cin >> n;
  auto v = in(vectors(n, 6, 0LL));
  bool f = true;
  rep(i, n) loop(j, i + 1, n) f &= not iso(v[i], v[j]);
  cout << (f ? "Yes" : "No") << endl;
}



Measured memory_bytes: 3176
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();
        if(a+b<24){
            System.out.println(a+b);
        }else{
            System.out.println(a+b-24);
        }
    }
}

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

using namespace std;

#define DUMP(x) std::cout << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++ i)
#define ALL(r) r.begin(), r.end()
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
#define IMP puts("IMPOSSIBLE")
#define Imp puts("Impossible")
#define imp puts("impossible")
#define pb push_back

template<typename T> T DUP(T x, T y) { return (x + y - 1) / y; };
template <typename A, size_t N, typename T> inline void arrayFill(A(&array)[N], const T& val) { std::fill((T*)array, (T*)(array + N), val); }
template <class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template <class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using pll = pair<ll, ll>;
using setint = unordered_set<int32_t>;
using setstr = unordered_set<string>;
using qint = queue<int32_t>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;


void Main() {
    int n;
    cin >> n;
    rep(i, 30) rep(j, 15) {
        if (4 * i + 7 * j == n) {
            Yes; return;
        }
    }
    No;
}
 
int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}



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

// isDebug?
#ifndef ONLINE_JUDGE
#define _DEBUG
#endif

// Function Macros:
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define setpre(n) cout << fixed << setprecision(n)

// -* https://xn--kst.jp/blog/2019/08/29/cpp-comp/ *- Thx :)
// debug methods
// usage: debug(x,y);
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define debug_1(x1) cout << #x1 << ": " << x1 << endl
#define debug_2(x1, x2) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define debug_3(x1, x2, x3) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << endl
#define debug_4(x1, x2, x3, x4) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << endl
#define debug_5(x1, x2, x3, x4, x5) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#ifdef _DEBUG
#define debug(...)                                                        \
    cout << __FILE__ << ": " << __LINE__ << ": " << __func__ << " -> ";   \
    CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) \
    (__VA_ARGS__)
#else
#define debug(...)
#endif

// namespace / type / class / struct - alias, def:
using namespace std;

using ll = long long;
using ull = unsigned long long;

// Constants:
const int INF = (1ll << 30) - 1;  // approx 1.07e9
const ll INFLL = 1ll << 60;       // approx 1.15e18
const int MOD = 1e9 + 7;          // 998244353
const long double EPS = 1.0e-14;
const int FACN = 510000;

// Global Variables:
// ll fac[FACN], finv[FACN], inv[FACN];

// Prototype Declarations:
int gcd(int, int);
int lcm(int, int);
template <class T>
inline bool chmin(T&, T);
template <class T>
inline bool chmax(T&, T);

// ================ Main Loop ================
int main() {
    int n;
    cin >> n;
    int d1, d2;
    int cnt = 0, mx = 0;
    rep(i, n) {
        cin >> d1 >> d2;
        if(d1 == d2) {
            cnt++;
        } else {
            cnt = 0;
        }
        chmax(mx, cnt);
    }

    if(mx >= 3) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}
// ===========================================

// Functions:
// 最大公約数 O(log(min(a, b)))
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
// 最小公倍数 O(log(min(a, b)))
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

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

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


Measured memory_bytes: 3632
n = gets.to_i
@bt = Hash.new
hasNode = Array.new n, false
n.times do
  node, left, right = readline.split(" ").map(&:to_i)
  @bt[node] = {left: left, right: right}
  hasNode[left] = true unless left == -1
  hasNode[right] = true unless right == -1
end

top = hasNode.index false

def preorder i
  l = @bt[i][:left] == -1 ? [] : preorder(@bt[i][:left])
  r = @bt[i][:right] == -1 ? [] : preorder(@bt[i][:right])
  return [i] + l + r
end

def inorder i
  l = @bt[i][:left] == -1 ? [] : inorder(@bt[i][:left])
  r = @bt[i][:right] == -1 ? [] : inorder(@bt[i][:right])
  return l + [i] + r
end

def postorder i
  l = @bt[i][:left] == -1 ? [] : postorder(@bt[i][:left])
  r = @bt[i][:right] == -1 ? [] : postorder(@bt[i][:right])
  return l + r + [i]
end

puts "Preorder"
puts " " + preorder(top).map(&:to_s).join(" ")
puts "Inorder"
puts " " + inorder(top).map(&:to_s).join(" ")
puts "Postorder"
puts " " + postorder(top).map(&:to_s).join(" ")


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

int main() {
  int a,b,c,x;
  cin>>a>>b>>c>>x;
  x/=50;
  int ans=0;
  for(int i=0;i<a+1;i++){
    for(int j=0;j<b+1;j++){
      for(int k=0;k<c+1;k++){
        if(i*10+j*2+k==x)ans++;
      }
    }
  }
  cout<<ans<<endl;
}


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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int MOD = 1000000009;
const long long INF = 1LL << 60;

int main() {
    string S;
    cin >> S;
    int res = 0;
    int count = 0;
    for (int i = 0; i < S.length(); ++i) {
        if (S[i] == 'A' || S[i] == 'C' || S[i] == 'G' || S[i] == 'T') {
            ++count;
            res = max(res, count);
        }
        else {
            count = 0;
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3608
N, Y = map(int, input().split())
I = -1
J = -1
K = -1
for i in range(N+1)[::-1]:
  for j in range(N+1-i)[::-1]:
      if i*10 + j*5 + (N-i-j) == Y/1000:
        I = i
        J = j
        K = N-i-j
        break
print('{} {} {}'.format(I, J, K))

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
    int D;
    cin >> D;
    vector<int>c(26);
    for(int i = 0; i < 26; i++) {
        cin >> c[i];
    }
    vector<vector<int>>s(D,vector<int>(26));
    for(int i = 0; i < D; i++) {
        for(int j = 0; j < 26; j++) {
            cin >> s[i][j];
        }
    }
    vector<int>t(D);
    for(int i = 0; i < D; i++) {
        t[i] = rand()%26+1;
    }
    int ans = 0;
    vector<int>Last(26);
    for(int i = 0; i < D; i++) {
        ans+=s[i][t[i]-1];
        Last[t[i]-1] = i+1;
        for(int j = 0; j < 26; j++) {
            ans-=c[j]*(i+1-Last[j]);
        }
    }
    int M = 300000;
    for(int i = 0; i < M; i++) {
        int d = rand()%D+1;
        int q = rand()%26+1;
        int ord = ans;
        int X = 0;
        int Y = 0;
        int A = 0;
        int B = 0;
        ans+=s[d-1][q-1]-s[d-1][t[d-1]-1];
        for(int j = 0; j < D; j++) {
            if(t[j] == t[d-1]) {
                if(j == d-1) {
                    Y = j+1;
                }
                else {
                    X = j+1;
                }
                A = j+1;
            }
            if(t[j] == q) {
                Y = j+1;
                B = j+1;
            }
            ans-=c[t[d-1]-1]*(j+1-X)-c[t[d-1]-1]*(j+1-A);
            ans+=c[q-1]*(j+1-B)-c[q-1]*(j+1-Y);
        }
        if(ans > ord) {
            ord = ans;
            t[d-1] = q;
        }
        else {
            ans = ord;
        }
    }
    for(int i = 0; i < D; i++) {
        cout << t[i] << endl;
    }
}


Measured memory_bytes: 3704
n = int(input())
A = []
B = []
for i in range(n):
    a,b = map(int,input().split())
    A.append((a,b))
for i in range(n):
    a,b = map(int,input().split())
    B.append((a,b))
A.sort()
B.sort()

ans = 0

for i in B:
    dis = -1
    check = -1
    for j in range(len(A)):
        if i[0] > A[j][0] and i[1] > A[j][1]:
            
            if dis < A[j][1]:
                check = j
                dis = A[j][1]
    if check > -1:
        ans += 1
        A.pop(check)

print(ans)

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

const int N = 1e6 + 100;

typedef long long LL;

map<pair<int,int>, LL> dp[18][18];
LL A[18], inf = 1e18;

LL solve(int l, int r, int cl, int cr) {
    if(r-l==1) return 0;
    if(dp[l][r].find(make_pair(cl, cr)) != dp[l][r].end()) return dp[l][r][make_pair(cl, cr)];
    LL ans = inf;
    for(int m = l+1; m < r; m++) {
        ans = min(ans, solve(l, m, cl, cl + cr) + solve(m, r, cl + cr, cr) + (cl + cr) * A[m]);
    }
    return dp[l][r][make_pair(cl, cr)] = ans;
}

int main() {
    // freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    for(int i = 0; i < n; i++) cin >> A[i];
    cout << solve(0, n-1, 1, 1) + A[0] + A[n-1] << endl;
    return 0;
}



Measured memory_bytes: 18560
////////////////いろいろあるよ//////////////////////////////////
//include,namespace
 #include<bits/stdc++.h>
 #include<iostream>
 #include<bitset>
 using namespace std;
//REPmacro
 #define all(x) (x).begin(),(x).end()             //ソート
 #define FOR(i,x,n)for(int i=(x);i<(n);i++)
 #define FOR_R(i,x,n) for(int i=(n-1);i>=(x);i--)
 #define REP(i, n) FOR(i, 0, n)
 #define REP_R(i, n) FOR_R(i, 0, n)
//long long(define)
 using ll = long long;
 typedef long long ll;
 typedef long long int64;
 typedef long long lint;
 typedef long long lli;
////////////////いろいろあるよ//////////////////////////////////

int main(){
	long long a;
	cin >>a;
	long long count=0;
	while(a>1){
		a=a/2;
		count++;
	}
  long long ans = pow(2,count+1)-1;
	cout << ans <<endl;
}

Measured memory_bytes: 256
from collections import defaultdict

sent = input()
w_count = defaultdict(int)

for i in range(len(sent)):
    w_count[sent[i]] += 1

result = set(list(w_count.values()))

if len(result) == 1 and list(result)[0] == 2:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3316
#include<bits/stdc++.h>
#include <vector>
#include <iostream>
using namespace std;
typedef pair<int,int>PP;
int Max(int a,int b){
  if(a>b){
    return(a);
  }else{
    return(b);
  }
}
int main(){
  int n,a;
  cin>>n>>a;
  string s;
  cin>>s;
  int lg=s.size();
  int seg[lg+1];
  seg[0]=0;
  if(s[0]=='A'&&s[1]=='C'){
    seg[0]=1;
  }
  for(int i=1;i<lg-1;i++){
    if(s[i]=='A'&&s[i+1]=='C'){
      seg[i]=seg[i-1]+1;
    }else{
      seg[i]=seg[i-1];
    }
  }
  int l,r;
  for(int i=0;i<a;i++){
    cin>>l>>r;
    if(l==1){
      cout<<seg[r-2]<<endl;
    }else{
      cout<<seg[r-2]-seg[Max(l-2,0)]<<endl;
    }
  }
  return(0);
}


Measured memory_bytes: 1408
import Foundation

func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}
func main() {
    let a = Double(readInts()[0])
    print(Int(a + pow(a, 2) + pow(a, 3)))
//    print(a)
    
}
main()

Measured memory_bytes: 13904
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

var fact []int

func initFactorial(N int) {
	fact = make([]int, N+1)
	fact[0] = 1
	fact[1] = 1

	for i := N; i > 0; i-- {
		f := 1
		for j := i; j > 0; j-- {
			f *= j
		}
		fact[i] = f
	}
}

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

	N, A := nextInt(), nextInt()
	x := make([]int, N)
	for i := 0; i < N; i++ {
		x[i] = nextInt()
	}

	var dp [51][51][3010]int
	dp[0][0][0] = 1
	for i := 0; i < N; i++ {
		for j := 0; j < N; j++ {
			for k := 0; k < 2500; k++ {
				if dp[i][j][k] > 0 {
					dp[i+1][j][k] += dp[i][j][k]
					dp[i+1][j+1][k+x[i]] += dp[i][j][k]
				}
			}
		}
	}

	ans := 0
	for i := 1; i <= N; i++ {
		ans += dp[N][i][i*A]
	}
	fmt.Println(ans)

	// ans := 0
	// for bit := uint(0); bit < (1 << uint(N)); bit++ {
	// 	slice := []int{}
	// 	for i := uint(0); i < uint(N); i++ {
	// 		if (bit & (1 << i)) == 1<<i {
	// 			slice = append(slice, x[i])
	// 		}
	// 	}
	// 	sum := 0
	// 	for _, ss := range slice {
	// 		sum += ss
	// 	}

	// 	if (len(slice) != 0) && (float64(sum)/float64(len(slice)) == float64(A)) {
	// 		ans++
	// 	}
	// }
	// fmt.Println(ans)
}


Measured memory_bytes: 62080