akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define cool ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int  long long int
#define pb push_back
#define fe first
#define se second
#define endl "\n"
#define pii pair<int, int>
#define vi vector<int> 
#define vvi vector<vi>
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORR(i,a,b) for(int i=a;i>=b;i--)
#define ALL(c) (c).begin(),()c.end() 

#define PI 3.14159265358979323846
const int N = 3e5 + 10;
const int INF=2e9;

int MOD=1e9+7;

void solve() {
	int cnt=0,tot=0;
     string s;
     cin>>s;
     int len=s.size();
     
     stack<char> st;
     string p=s;
   
     for(int i=0;i<len;i++) {
		    if(i==0){
		       st.push(s[i]);
		         continue;  
			}
			
			else {
				  char ch=st.top();
				  
				  if(ch!=s[i]) {
					  
				       st.push(s[i]);
				  }  
				 
				  else  {
					    if(ch=='0') 
					     st.push('1');
					    else
					      st.push('0');
					    cnt++;   
					  }			 	  			
				}	       
		 }
		 
	
		 
		 stack<char> st1;
         for(int i=len-1;i>=0;i--) {
		    if(i==len-1){
		       st1.push(p[i]);
		       continue;
			}
			
			else {
				  char ch=st1.top();
				  if(ch==p[i]) {
					    if(ch=='0') 
					     st1.push('1');
					    else
					      st1.push('0');
					    tot++;   
					  }
					  
				  else
				       st1.push(p[i]);	  			
				}       
		 }
		 
		// cout<<cnt<<" "<<tot<<endl;
		 cout<<min(cnt,tot);
		 
      
        
	
	}  

int32_t main() {
  cool;
  int t = 1;
  while (t--)
	solve();

  return 0;
}


Measured memory_bytes: 720
use std::io::*;
use std::str::FromStr;

fn main() {
    let n: usize = read();
    let a: Vec<i64> = (0..n).map(|_| read()).collect();

    let mut m = 0;
    let mut mn = 0;
    let mut m2 = 0;
    for i in 0..n {
        if a[i] > m {
            m = a[i];
            mn = i;
        } else if a[i] > m2 {
            m2 = a[i];
        }
    }
    for i in 0..n {
        if i == mn {
            println!("{}", m2);
        } else {
            println!("{}", m);
        }
    }
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 7676
#include<bits/stdc++.h>
using namespace std;
 
long long N, M;
long long X[int(1e5)];
long long D[int(1e5)];
long long times = 0;
 
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> M;
    for(int m=0; m<M; m++)cin >> X[m];
    sort(X, X+M);
    for(int m=M-1; m>=1; m--){
        D[m-1] = X[m] - X[m-1];
    }
    D[M-1] = 0;
    sort(D, D+M-1);
    
    for(int m=0; m<M-N; m++)times += D[m];
    cout << times << "\n";
    return 0;
}

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

using namespace std;

//#define PRAGMA 448
#ifdef PRAGMA
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#endif

#ifdef LUCARIO
#define deb(...) fprintf(stderr,__VA_ARGS__)
#define deb1(x) cerr << #x << " = " << x << endl
#else
#define deb(...) 0
#define deb1(x) 0
#endif

typedef int intt;
typedef pair<long long,long long> pll;
typedef pair<int,int> pii;

#define FIN ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define ld long double
#define int long long
#define pb push_back
#define bs binary_search
#define up upper_bound
#define fs first 
#define sd second 
#define mp make_pair    
#define endl "\n"

#define fore(i,a,b) for(ll i = a; i < b; i++)
#define rfore(i, a, b) for(ll i = a - 1; i >= b; i--)
#define forev(a,b) fore(i,0,b)cout<<a[i]<<" "; 
#define ing(g,u,v)  g[u].pb(v); g[v].pb(u);
#define ingp(g,u,v,c) (g[u].pb({v,c});g[v].pb({u,c});)
#define mm(a,b) memset(a , b , sizeof a) 
#define ALL(a) a.begin(),a.end() 
#define SZ(n) ((ll) (n).size())
#define sfind(s,t) (s.find(t) != string::npos)

#define infll (ll)1e15
#define infi  (int)(1e9+1)
#define PI 3.14159265359 
#define mod (ll)(1e9+7)
#define eps  1e-6

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b,a%b); } 
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }


int n,m;
ld a[3001];
ld dp[3001][3001];
double res;

ld solve(int i, int j){
    if(i == n)return (j > n/2);
    ld &r = dp[i][j];
    if(r >= 0)return r;
    r = 0;
    r += solve(i+1,j+1)*a[i]+solve(i+1,j)*(1-a[i]);
    return r;
}


int32_t main(int32_t argc, char const *argv[]){
    FIN;
    fore(i,0,3001){
        fore(j,0,3001){
            dp[i][j] =-1;
        }
    }
    cin>>n;
    fore(i,0,n)cin>>a[i];

    cout<<setprecision(16)<<solve(0,0)<<endl;

    return 0;
}



















Measured memory_bytes: 141184
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int a,b;

int main(void){
	scanf("%d%d",&a,&b);
	int ans=0;
	int now=1;
	while(now<b){
		now+=a-1;
		ans++;
	}
	printf("%d\n",ans);
	return 0;
}


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

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF (long long)(1e18)
#define MOD (int)(1e9+7)

#define yn(f) ((f)?"Yes":"No")
#define YN(f) ((f)?"YES":"NO")

#define MAX 110000

int N, A[MAX];
int hoge[MAX];

signed main(){
	cout<<fixed<<setprecision(7);
	
	int count = 0, con = 0;
	
	cin>>N;
	
	rep(i,N){
		cin>>A[i];
		hoge[A[i]]++;
	}
	

	
	for(int i = 0; i < MAX; i++){
		if(hoge[i] >= 2){
			count += hoge[i]-2;
			if(hoge[i]%2 == 0)con++;
			else count++;
		}
	}
	// cout<<con<<" "<<count<<endl;
	count += (con/2)*2;
	if(con%2) count+=2;
	// cout<<count<<endl;
	cout<<max(1ll,N-count)<<endl;
	
	
		// sort(A,A+N);
	// for(int j = 0; j < N; j++){
			// cout<<(j?" ":"")<<A[j];
	// }cout<<endl;
	
	return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;

 public class Main{
 public static void main(String[] args){
 Scanner sc =new Scanner(System.in);
 int w=sc.nextInt();
 int n=sc.nextInt();
 int[] values =new int[w];
 for(int i=0;i<values.length;i++){
 values[i]=i+1;
 }
 for(int i=0;i<n;i++){
 String str=sc.next();
 String[] ab=str.split(",");
 int a=Integer.parseInt(ab[0])-1;
 int b=Integer.parseInt(ab[1])-1;
 int c;
 c=values[a];
 values[a]=values[b];
 values[b]=c;
 }
 for(int i=0;i<w;i++){
 System.out.println(values[i]);
 }

 }
 }

Measured memory_bytes: 17200
fn main() {
    let n: usize = read();
    let mut v: Vec<Vec<i32>> = Vec::new();
    for i in 0..n {
        let a: i32 = read();
        let b: i32 = read();
        let s: Vec<i32> = vec![a, b];
        v.push(s);
    }

    let mut ans = 0;
    for e in v {
        ans += e[1] - e[0] + 1;
    }
    println!("{}", ans);
}

// 以下関数

use std::io::*;
use std::str::FromStr;
pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

pub const MOD: u64 = 10e9 as u64 + 7;

pub fn is_prime(n: i32) -> bool {
    if n < 2 {
        return false;
    } else if n == 2 {
        return true;
    }
    let mut i = 2;
    while i * i < n {
        if n % i == 0 {
            return false;
        } else {
            i += 1;
            continue;
        }
    }
    true
}

pub fn lcm(mut n: i32, mut m: i32) -> i32 {
    n = if n > m { m } else { n };
    m = if n > m { n } else { m };
    let mut i = n;
    while i % m != 0 {
        i += n;
    }
    i
}

pub fn abs(n: i32) -> i32 {
    if n >= 0 {
        n
    } else {
        -n
    }
}

pub fn max(n: i32, m: i32) -> i32 {
    if n >= m {
        n
    } else {
        m
    }
}

pub fn min(n: i32, m: i32) -> i32 {
    if n <= m {
        n
    } else {
        m
    }
}

Measured memory_bytes: 4352
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;

// Integral Rectangles
// 2013/08/13
public class Main{
	Scanner sc=new Scanner(System.in);

	int INF=1<<28;
	double EPS=1e-12;

	int nTeams, nProblems, nTick;
	int[] ticks, teams, problems, results;

	void run(){
		for(;;){
			int M=sc.nextInt();
			nTeams=sc.nextInt();
			nProblems=sc.nextInt();
			nTick=sc.nextInt();
			if((M|nTeams|nProblems|nTick)==0){
				break;
			}
			ticks=new int[nTick];
			teams=new int[nTick];
			problems=new int[nTick];
			results=new int[nTick];
			for(int i=0; i<nTick; i++){
				ticks[i]=sc.nextInt();
				teams[i]=sc.nextInt()-1;
				problems[i]=sc.nextInt()-1;
				results[i]=sc.nextInt();
			}
			solve();
		}
	}

	void solve(){
		int[][] states=new int[nTeams][nProblems];
		int[][] times=new int[nTeams][nProblems];
		for(int i=0; i<nTick; i++){
			if(results[i]==0){
				states[teams[i]][problems[i]]=1;
				times[teams[i]][problems[i]]+=ticks[i];
			}else{
				times[teams[i]][problems[i]]+=20;
			}
		}
		int[] ACs=new int[nTeams];
		int[] penalties=new int[nTeams];
		for(int j=0; j<nTeams; j++){
			for(int i=0; i<nProblems; i++){
				ACs[j]+=states[j][i];
				penalties[j]+=states[j][i]*times[j][i];
			}
		}
		// debug("AC", AC);
		// debug("pena", pena);
		int[] _=new int[nTeams];
		for(int i=0; i<nTeams; i++){
			_[i]=i;
		}
		for(int i=0; i<nTeams; i++){
			for(int j=i+1; j<nTeams; j++){
				if(comp(ACs[_[i]], penalties[_[i]], _[i], ACs[_[j]],
						penalties[_[j]], _[j])>0){
					int t=_[i];
					_[i]=_[j];
					_[j]=t;
				}
			}
		}
		// debug(_);
		for(int i=0; i<nTeams; i++){
			print(1+_[i]+"");
			if(i<nTeams-1){
				print(comp(ACs[_[i]], penalties[_[i]], ACs[_[i+1]],
						penalties[_[i+1]])==0?"=":",");
			}
		}
		println("");
	}

	int comp(int ac1, int time1, int ac2, int time2){
		if(ac1!=ac2){
			return -(ac1-ac2);
		}else{
			return time1-time2;
		}
	}

	int comp(int ac1, int time1, int id1, int ac2, int time2, int id2){
		if(comp(ac1, time1, ac2, time2)!=0){
			return comp(ac1, time1, ac2, time2);
		}else{
			return -(id1-id2);
		}
	}

	void debug(Object... os){
		System.err.println(Arrays.deepToString(os));
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

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

Measured memory_bytes: 61032
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define N 100000000
#define rep(i,n) for(int i = 0 ; i < n ; ++i)

typedef struct{
    int rx,ry,lx,ly;
}Point;
Point queue[N];
int w,h;

int chk(int y,int x,char s[99][99]){
    return (y >= 0 && x >= 0 && y < h && x < w && s[y][x] != '#');
}

char rin[99][99] , len[99][99];

int used[52][52][52][52];

int rx,ry,lx,ly;

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

int head,num;
void enqueue(int ly,int lx,int ry,int rx){
    if(num<N){
        queue[(head+num)%N].ly=ly;
        queue[(head+num)%N].lx=lx;
        queue[(head+num)%N].ry=ry;
        queue[(head+num)%N].rx=rx;
        num++;
    }else{
        printf("エラー");
        exit(1);
    }
}
Point dequeue(){
    Point d={-1,-1,-1,-1};
    if(num>0){
        d=queue[head];
        head=(head+1)%N;
        num--;
    }
    return d;
}

int bfs(){
    
    memset(used,0,sizeof(used));
    enqueue(ly,lx,ry,rx);
    
    while(1){
        Point p=dequeue();
        if(p.ly==-1) break;
        
        if(used[p.ly][p.lx][p.ry][p.rx])continue;
        used[p.ly][p.lx][p.ry][p.rx] = 1;
        
        if(len[p.ly][p.lx] == '%' && rin[p.ry][p.rx] == '%')return 1;
        if(len[p.ly][p.lx] == '%' || rin[p.ry][p.rx] == '%')continue;
        
        rep(i,4){
            
            int nrx = p.rx,nry = p.ry,nlx = p.lx,nly = p.ly;
            
            if(chk(nly+dy[i],nlx+dx[i],len))nly += dy[i],nlx += dx[i];
            if(chk(nry+dy[i],nrx-dx[i],rin))nry += dy[i],nrx -= dx[i];
            
            
            if(!used[nly][nlx][nry][nrx])
                enqueue(nly,nlx,nry,nrx);
        }
    }
    
    return 0;
}

int main(){
    while(1){
        scanf("%d%d",&w,&h);
        if(w+h==0) break;
        getchar();
        rep(i,h) scanf("%s%s",len[i],rin[i]);
        rep(i,h){
            rep(j,w){
                if(len[i][j] == 'L')ly = i,lx = j;
                if(rin[i][j] == 'R')ry = i,rx = j;
            }
        }
        head=num=0;
        printf("%s\n",(bfs() ? "Yes": "No"));
        
    }
}



Measured memory_bytes: 69040
parseInt(x::String) = parse(Int, x)
parseInt(x::SubString{String}) = parse(Int, x)
parseInt(x::Char) = parse(Int, x)
parseInt(x::Float64) = trunc(Int, x)
parseFloat(x::String) = parse(Float64, x)
parseFloat(x::Int) = trunc(Float64, x)
parseFloat(x::SubString{String}) = parse(Float64, x)
parseFloat(x::Char) = parse(Float64, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    n=parseInt(readline())
    println(800*n-200*div(n,15))
end
main()

Measured memory_bytes: 118128
// by newbiechd
#include <algorithm>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>

// DELETE the debugging information!
#define debug(x) std::cerr << #x << " = " << (x) << std::endl

int main() {
  int a, b;
  scanf("%d%d", &a, &b);
  if (a <= 0 && b >= 0) {
    printf("Zero\n");
    return 0;
  }
  if (a > 0) {
    printf("Positive\n");
    return 0;
  }
  printf(((b - a + 1) & 1) ? "Negative\n" : "Positive\n");
  return 0;
}


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

struct store {
  long long price;
  long long quantity;
};

bool cmp(const store &a, const store &b) {
  return a.price < b.price;
}

int main() {
  long long N, M;
  cin >> N >> M;
  
  vector<store> A(N);
  for(int i=0; i<N; i++) {
    cin >> A[i].price;
    cin >> A[i].quantity;
  }
  
  sort(A.begin(), A.end(), cmp);
  
  long long num = 0;
  long long total = 0;
  for(int i=0; i<N; i++) {
    if(A[i].quantity <= M) {
      num += A[i].quantity;
      total += A[i].price * A[i].quantity;
      M -= A[i].quantity;
    } else {
      total += A[i].price * M;
      break;
    }
  }
  
  cout << total << endl;
  
  return 0;
}


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

int main(){
  string s;
  cin >> s;
  vector<pair<char, int>>line(s.size());
  int cnt = 1;
  vector<int>length(s.size());
  for(int i = 0; i < s.size(); i++){
    if(s[i] == 'R' && s[i+1] == 'L' && i != s.size() - 1){
      length[i+1] = cnt;
      cnt = 1;
    }else if(s[i] == 'R' && s[i] == s[i+1] && i != s.size() - 1){
      cnt += 1;
    }
  }
  //for(int i = 0; i < s.size(); i++)cout << length[i];
  //cout << endl;

  reverse(s.begin(), s.end());
  reverse(length.begin(), length.end());
  for(int i = 0; i < s.size(); i++){
    if(s[i] == 'L' && s[i+1] == 'R' && i != s.size() - 1){
      length[i+1] = cnt;
      cnt = 1;
    }else if(s[i] == 'L' && s[i] == s[i+1] && i != s.size() - 1){
      cnt += 1;
    }
  }
  reverse(s.begin(), s.end());
  reverse(length.begin(), length.end());

//  for(int i = 0; i < s.size(); i++)cout << length[i];
//  cout << endl;

  vector<int> ans(s.size());
  for(int i = 0; i < s.size(); i++){
    if(length[i] != 0){
      if(s[i] == 'R'){
        if(length[i]%2 == 0){
          ans[i] += length[i]/2;
          ans[i+1] += length[i]/2;
        }else{
          ans[i] += (length[i] + 1)/2 - 1;
          ans[i+1] += (length[i] + 1)/2;
        }
      }else{
        if(length[i]%2 == 0){
          ans[i] += length[i]/2;
          ans[i-1] += length[i]/2;
        }else{
          ans[i] += (length[i] + 1)/2 - 1;
          ans[i-1] += (length[i] + 1)/2;
        }
      }
    }
  }
  for(int i = 0; i < s.size(); i++){
    cout << ans[i] << " ";
  }
  cout << endl;
}


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

int main() {
  double A, B;
  cin >> A >> B;
  
  double numMin = max( 10. * B , 100. * A / 8);
  double numMax = min(10. * (B+1) , 100. * (A+1)/8);
  
  int intMin = (int)numMin;
  if( numMin - (double)intMin > 0){
    intMin++;
  }
  int intMax = (int)numMax;
  if(numMax - (double)intMax == 0){
    intMax--;
  }
  
  int ans = -1;
  
  if (intMin <= intMax){
    ans = intMin;
  }
  
  cout << ans << endl;
}


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

int main() {
	double v;
	while(~scanf("%lf",&v))
	{
		double t=v/9.8;
		t*=t*4.9;
		int c=1;
		double h=0.0;
		while(h<t)
		{
			h+=5.0;
			c++;
		}
		cout<<c<<endl;
	}
	return 0;
}

Measured memory_bytes: 3152
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, double> pid;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

int N;
vector<pii> G[100010];
int COL[100010];
int maxc;

void dfs(int v, int col, int pre)
{
	int c = 0;
	rep(i,0,SZ(G[v]))
	{
		if (G[v][i].first == pre)continue;
		if (c == col)c++;
		COL[G[v][i].second] = c;
		chmax(maxc, c);
		dfs(G[v][i].first, c, v);
		c++;
	}
}

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

	cin >> N;
	int a, b;
	rep(i, 0, N - 1)
	{
		cin >> a >> b;
		a--, b--;
		G[a].push_back(mp(b, i));
		G[b].push_back(mp(a, i));
	}

	dfs(0, -1, -1);

	cout << maxc + 1 << endl;
	rep(i, 0, N - 1)
	{
		cout << COL[i]+1 << endl;
	}

	return 0;
}

Measured memory_bytes: 10752
num_list = []
while True:
    values = [int(x) for x in input().split()]
    if 0 == values[0] and 0 == values[1]:
        break
    num_list.append(values)

for n, t in num_list:
    ret = ''.join(str(1) for x in range(1, n + 1) for y in range(x + 1, n + 1) for z in range(y + 1, n + 1) if t == x + y + z)
    print(ret.count(str(1)))

Measured memory_bytes: 7724
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    a,b = LI()
    if a == b:
        return a

    r = 0
    if (a ^ b) & 1:
        r = (b-a+1) // 2 % 2
    else:
        r = (a+b) // 2 & 1

    for ii in range(1,44):
        i = 2 ** ii
        if a < i and b < i:
            break

        t = a + i - a % i
        if t > b:
            if a & i and (b-a) % 2 == 0:
                r += i
            continue
        k = t - a

        j = b % i + 1
        u = b - j

        s = 0
        if a & i:
            s += k
        if b & i:
            s += j

        if s & 1:
            r += i

    return r


print(main())




Measured memory_bytes: 7624
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for(int i = 0; i < n; i++){
            a[i] = sc.nextInt();
        }
        if(n % 2 == 0){
            for(int i = 0; i < n; i += 2){
                System.out.print(a[n - i - 1] + " ");
            }
            for(int i = 0; i < n; i += 2){
                System.out.print(a[i] + " ");
            }
        } else {
            for(int i = 0; i < n; i += 2){
                System.out.print(a[n - i - 1] + " ");
            }
            for(int i = 1; i < n; i += 2){
                System.out.print(a[i] + " ");
            }
        }
    }
}


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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'
#define rep(i,n) for(int_fast32_t i = 0; i < ((int_fast32_t)(n)); i++)   // 0-indexed up
#define rep1(i,n) for(int_fast32_t i = 1; i <= ((int_fast32_t)(n)); i++) // 1-indexed up
#define rrep(i,n) for(int_fast32_t i = ((int_fast32_t)(n)-1); i >= 0; i--)  // 0-indexed down
#define rrep1(i,n) for(int_fast32_t i = ((int_fast32_t)(n)); i >= 1; i--)   // 1-indexed down
#define all(x) (x).begin(),(x).end()

using namespace std;

template<typename T>
using vec = vector<T>;
using i32 = int_fast32_t;
using i64 = int_fast64_t;
using u32 = uint_fast32_t;
using u64 = uint_fast64_t;
using ll = long long;
using ld = long double;
using vi = vec<int_fast32_t>;
using vl = vec<int_fast64_t>;
using vld = vec<ld>;
using vii = vec<vi>;
using PII = pair<int_fast32_t, int_fast32_t>;

template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

const ld Pi = std::acos(-1.0L);
constexpr ll infll = (1LL<<62)-1;
constexpr int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    int START_TIME = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
//    cout << fixed << setprecision(15);

    i32 n, k; cin >> n >> k;
    vi a(n); rep(i,n) cin >> a[i];

    i32 cnt = 0;
    rep(_, k) {
        vi tmp(n+1);
        rep(i, n) {
            i32 d = a[i];
            if(d == 0) continue;
            else {
                ++tmp[max<i32>(0, i-d)];
                --tmp[min<i32>(n, i+d+1)];
            }
        }
        rep(i,n) tmp[i+1] += tmp[i];
        rep(i,n) if(a[i]==0) tmp[i]++;
        rep(i,n) {
            if(tmp[i]>n) {
                tmp[i] = n;
            }
        }
        bool fin = 1;
        rep(i,n) if(tmp[i] != n) fin = 0;
        tmp.pop_back();
        a = tmp;
        ++cnt;
        if(fin) break;
    }

//    debug(cnt);
    rep(i,n) cout << a[i] << (i == n-1 ? '\n' : ' ');

    // printf("ExecutionTime: %d /ms\n",1000*(int)((clock()-START_TIME)/CLOCKS_PER_SEC));
}


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

int n, num[22];
int most, mini, cnt;

int main()
{
  cin >> n;

  for (int i = 0; i < n; i++) cin >> num[i];

  cnt = 0;
  
  for (int i = 1; i < n-1; i++) {
    most = 0;
    mini = 99999999;
    
    most = max(num[i-1], num[i]);
    most = max(most, num[i+1]);

    mini = min(num[i-1], num[i]);
    mini = min(mini, num[i+1]);
      
    if (most != num[i] && mini != num[i]) cnt++;
  }
  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 256
N,M,X,Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))

x.sort()
y.sort()
if Y-X <= 0 or x[-1] >= Y or y[0] <= X or x[-1] >= y[0]:
  print("War")
else:
  print("No War")


Measured memory_bytes: 3060
import java.util.*;
 
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        boolean boo = true;
        String words[] = new String[n];
        words[0] = sc.next();
        String str[] = words[0].split("");
        String endC = str[str.length -1];
        for(int i=1; i<n; i++){
            String s = sc.next();
            if(Arrays.asList(words).contains(s)) boo = false;
            String nowStr[] = s.split("");
            String startC = nowStr[0];
            if(!startC.equals(endC)) boo = false;
            endC = nowStr[nowStr.length -1];
            words[i] = s;
        }
        if(boo) System.out.println("Yes");
        else System.out.println("No");
    }
}

Measured memory_bytes: 21972
n=int(input())
t,a=map(int,input().split())
h=list(map(int,input().split()))
k=[]
for i in range(0,n):
    k.append([h[i],i+1])
k.sort()
s=(t-a)/(6*(10**(-3)))
for i in range(1,n):
    if s-k[i][0]<0:
        if abs(s-k[i][0])>abs(s-k[i-1][0]):
            print(k[i-1][1])
            break
        else:
            print(k[i][1])
            break

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

#define REP(i,n) for(int i =0; i <n; ++i)

#define REPR(i,n) for(int i =n; i >=0; --i)

#define _REP(i,m,n) for(int i =m; i <n; ++i)

#define INF 2e9

using namespace std;

int main(){
    
    int n,k,q;
    cin >> n >> k >> q;
    vector<int> cnt(n,q);
    vector<bool> ans(n,true);

    REP(i,q){
        int a;cin >>a;
        a--;
        cnt[a]--;
    }
    REP(i,n){
        if((k - cnt[i] ) <= 0)cout << "No" << endl;
        else cout << "Yes" << endl;
    }


    return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    val n = sc.nextLine
    if (Array(n(0), n(1), n(2)).distinct.length == 1 | Array(n(1), n(2), n(3)).distinct.length == 1) println("Yes")
    else println("No")
  }
}


Measured memory_bytes: 25420
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = int64_t;
using pii = pair<int, int>;
using pll = pair<int64_t, int64_t>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}

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

  int n; cin >> n;
  vector<int> h(n);
  for (int i = 0; i < n; ++i) cin >> h[i];

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

  print(dp[n - 1]);

  return 0;
}

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

int main(void){
    char O[51],E[51];
    int i,size;
    scanf("%s",O);
    scanf("%s",E);
    size = strlen(O) + strlen(E);
    char ans[size];
    if(strlen(O) - strlen(E) == 0){
        for(i=0;i<strlen(E);i++){
            printf("%c",O[i]);
            printf("%c",E[i]);
        }
    }else{
        for(i=0;i<strlen(E);i++){
            printf("%c",O[i]);
            printf("%c",E[i]);
        }
        printf("%c",O[strlen(O) - 1]);
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main() {
	int a,b;
	cin>>a>>b;
	if(a>0)
		cout<<"Positive";
	else if(a==0||(a<0&&b>0))
		cout<<"Zero";
	else if((abs(b)-abs(a))%2!=0)
		cout<<"Positive";
	else
		cout<<"Negative";
	return 0;
}

Measured memory_bytes: 256
a,b,x = map(int,input().split())
import math
#print(y)
if 2*x <= a*a*b:
  y = (a*b*b) / (2*x)
  print(math.degrees(math.atan(y)))
else:
  z = (2*a*a*b-2*x) / (a*a*a)
  print(math.degrees(math.atan(z)))

Measured memory_bytes: 3060
N=int(input())
A=list(map(int,input().strip().split()))
def border_judge(N,A):
    judge=True
    for n in range(len(A)):
        if A[n]%2==0:
            if A[n]%5==0 or A[n]%3==0:
                judge=True
            else:
                judge=False
                break
        else:
            pass

    if judge==True:
        return "APPROVED"
    elif judge==False:
        return "DENIED"

print(border_judge(N,A))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF=1e18;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll S,T,D; cin >> S >> T >> D; S-=T;
    vector<ll> w(D),sum(D+1,0);
    for (int i=0;i<D;++i) cin >> w[i],w[i]*=-1;
    for (int i=0;i<D;++i) sum[i+1]=sum[i]+w[i];
    ll ans=INF;
    for (int i=0;i<D;++i){
        if (sum[D]<=0&&sum[i]<S) continue;
        if (S<=sum[i]){ans=min(ans,(ll)i); continue;}
        ans=min(ans,(S-sum[i]+sum[D]-1)/sum[D]*D+i);
    }
    cout << (ans==INF?-1:ans) << '\n';
}


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


int main(){
	int cnt=0;
	string s="CODEFESTIVAL2016",s2;
	cin >> s2;
	
	for(int i=0;i<s.size();i++){
		if(s[i]!=s2[i]) cnt++;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define lp(i,n) for(int i=0;i<n;i++)
#include<bits/stdc++.h>


using namespace std;
int main() {
	int a, b, x;
	cin >> a >> b >> x;
	if (a + b > x) {
		if (a > x)
			cout << "NO" << endl;
		else
			cout << "YES" << endl;
	}
	else
		cout << "NO" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.1415926535897
using namespace std;
typedef long long ll;
const int INF = 1000000000;
const ll LINF = 1000000000000000000; //1e18
const double EPS = 1e-10;

int main(void)
{
    std::cout << std::fixed << std::setprecision(10);
    int N;
    cin >> N;

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

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

    double sum = 0;
    int counter = 0;
    do
    {
        for (int i = 0; i < N - 1; i++)
        {
            sum += sqrt(pow((x[pattern[i]] - x[pattern[i + 1]]), 2) + pow((y[pattern[i]] - y[pattern[i + 1]]), 2));
            // printf("sum = %d\n", sum);
        }
        counter++;
    } while (next_permutation(pattern.begin(), pattern.end()));

    double ans = sum / counter;
    cout << ans << endl;
    return (0);
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
typedef pair<int,int> pii;
#define rep(i,n) for(int i = 0 ; i < n ; i++)
#define mp(a,b) make_pair(a,b)
int N;

vector<pii> graph[20];

int _inc(int n,int e,bool d[20]){
	if(d[n]) return false;
	else d[n] = true;
	if(n == e) return true;
	rep(i,graph[n].size()){
		if(_inc(graph[n][i].first,e,d)) return true;
	}
	return false;
}

int inc(int n,int e,bool from[20]){
	bool d[20];
	for(int i = 0 ; i < 20 ; i++)
		d[i] = from[i];
	return _inc(n,e,d);
}

int dfs(int s,int t,bool d[20]){
	if(d[s]) return 0;
	else d[s] = true;
	
	int w = 0;
	rep(i,graph[s].size()){
		int next = graph[s][i].first;
		if(d[next])continue;
		if(!inc(next,t,d)){
			if(graph[next].size() != 1) w += dfs(next,t,d) + graph[s][i].second * 2;
			else d[next] = true;
		}else{
			w += dfs(next,t,d) + graph[s][i].second;
		}
	}
	return w;
}
int main(){
	while(cin >> N,N){
		rep(i,20)graph[i].clear();
		rep(i,N-1){
			int a,b,c;
			cin >> a >> b >> c;
			a--,b--;
			graph[a].push_back(mp(b,c));
			graph[b].push_back(mp(a,c));
		}
		int ans = (1<<21);
		rep(i,N){
			bool d[20] = {0};
			ans = min(ans,dfs(0,i,d));
		}
		bool d[20] = {0};
		cout << ans << endl;
		
		
	}
}

Measured memory_bytes: 0
#include<stdio.h>
 
int main()
{
  int t[4][14];
  int n, i,j,c;
  char m, d;
  for(i=0; i < 4; i++){
    for(j=0; j < 14; j++){
      t[i][j]=0;
    }
  }
 scanf("%d", &c);
  for(i = 0; i < c; i++){
    scanf("%c", &d);
    scanf("%c %d", &m, &n);
    if(m == 'S'){
      t[0][n] = 1;
    }
    else if(m == 'H'){
      t[1][n] = 1;
    }
    else if(m == 'C'){
      t[2][n] = 1;
    }
    else if(m == 'D'){
      t[3][n] = 1;
    }
  }
  for(j=1; j < 14; j++){
    if(t[0][j] != 1){
      printf("S %d\n", j);
    }
  }
 
 for(j=1; j < 14; j++){
    if(t[1][j] != 1){
      printf("H %d\n", j);
    }
  }
 
 for(j=1; j < 14; j++){
    if(t[2][j] != 1){
      printf("C %d\n", j);
    }
  }
 
 for(j=1; j < 14; j++){
    if(t[3][j] != 1){
      printf("D %d\n", j);
    }
  }
 return 0;
}



Measured memory_bytes: 2048
n=int(input())
dic=dict()
for i in range(n):
  s = ''.join(sorted(list(input())))
  if s in dic:
    dic[s] += 1
  else:
    dic[s]=1
res = sum([x*(x-1)//2 for x in dic.values() if x > 1])
print(res)

Measured memory_bytes: 60504
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define f first
#define se second
#define pb push_back
#define ms memset
#define MOD 1000000007
#define sp fixed<<setprecision
#define sz sizeof
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod2=998244353;
ll fpow(ll x,ll y,ll p=MOD){ if(y==0)return 1; else if(x==0)return 0; x=x%p;ll sum=1;while(y){if(y&1)sum=sum*x;sum%=p;y=y>>1;x=x*x;x%=p;}return sum;}
ll inv(ll a,ll m=MOD){ll c=m;ll y=0,x=1;if(m==1)return 0;while(a>1){ll q=a/m;ll t=m;m=a%m,a=t;t=y;y=x-q*y;x=t;}if(x<0)x+=c;return x;}
ll spf[1000005];
void sieve()
{
  for(int i=1;i<1000005;i++)
  spf[i]=i;
  for(int i=2;i*i<=1000005;i++)
  if(spf[i]==i)
  for(int j=2*i;j<1000005;j+=i)
  spf[j]=min(spf[j],(ll)(i));
}
vector<ll>adj[1000005];
bool vis[1000005];
ll cur=0;
void dfs(ll x){
  cur++;
  //cout<<cur<<"\n";
  vis[x]=true;
  for(auto u:adj[x]){
    if(!vis[u])
      dfs(u);
  }
}
int main(){
   ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
   ll n,m;
   cin>>n>>m;
   for(int i=0;i<m;i++){
     ll x,y;
     cin>>x>>y;
     adj[x].pb(y);
     adj[y].pb(x);
   }
   ll res=0;
   for(int i=1;i<=n;i++){
     if(!vis[i]){
       cur = 0;
       dfs(i);
       res = max(res,cur);
     }
   }
   cout<<res;
}


Measured memory_bytes: 39716
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{	
	ll n;
	cin >> n;
	ll ar[n+1];
	for(ll x = 1; x <= n; x++) {
		cin >> ar[x];
	}
	ll dp[n+1] = {0};
	dp[1] = 0;
	dp[2] = abs(ar[2] - ar[1]);
	for(ll x = 3; x <= n; x++) {
		dp[x] = min(dp[x-1] + abs(ar[x]-ar[x-1]), dp[x-2] + abs(ar[x]-ar[x-2]));
	}
	cout << dp[n];
}	

Measured memory_bytes: 5188
/*	
	*  Sachin Mittal
	*/
	#include<bits/stdc++.h>
	#define int long long
	#define M 998244353
	#define mod 1000000007
	#define all(v) v.begin(),v.end()
	#define rep(i,j,n) for(int i=j;i<n;i++)
	#define F first
	#define S second
	#define lb lower_bound
	#define mem0(dp) memset(dp,0,sizeof(dp))
	#define mem1(dp) memset(dp,-1,sizeof(dp))
	#define pb push_back
	#define sz(s) (int)(s.size())
	#define debug(x) cout << #x << " = " << x << '\n';
	using namespace std;

	void solve()
	{
		int n;cin>>n;
		string s;cin>>s;
		int ans=0;
		map<char,int>mp1,mp2;
		rep(i,1,n)mp2[s[i]]++;
		mp1[s[0]]++;
		rep(i,1,n-1)
		{
			mp2[s[i]]--;
			int minus=0;
			for(int j=1;i-j>=0 and i+j<n;j++)
			{
				set<char> st;
				st.insert(s[i]);
				st.insert(s[i-j]);
				st.insert(s[i+j]);
				if(sz(st)==3)minus++;
			}
			if(s[i]=='R')
			{
				ans+=mp1['G']*mp2['B']+mp1['B']*mp2['G'];
			}
			else if(s[i]=='G')
				ans+=mp1['R']*mp2['B']+mp1['B']*mp2['R'];
			else 
				ans+=mp1['G']*mp2['R']+mp1['R']*mp2['G'];
			ans-=minus;
			//cout<<ans<<" "<<minus;
			mp1[s[i]]++;
		}
		cout<<ans;
	}

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

Measured memory_bytes: 3664
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
 
#define el '\n'
#define MOD 1000000007
 
int n, m, link[150005], siz[150005];
 
void initDSU(){
    for(int i=1;i<=n;i++){
        link[i]=i;
        siz[i]=1;
    }
}
 
int find(int v) {
    if (v == link[v])
        return v;
    return link[v] = find(link[v]);
}
 
void unite(int a, int b) {
    a = find(a);
    b = find(b);
    if(a!=b){
        if (siz[a] < siz[b]){
            swap(a,b);
        }
        siz[a] += siz[b];
        link[b] = a;
    }
}
 
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin >> n >> m;
    initDSU();
    while(m--){
        int a,b,c;
        cin >> a >> b >> c;
        unite(a, b);
    }
    int cnt=0;
    for(int i=1;i<=n;i++){
        if(find(i)==i){
            cnt++;
        }
    }
    cout << cnt << el;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string.h>
#include <stack>
#include <queue>
#include <algorithm>
#include <climits>
#include <cmath>
#include <map>
#include <set>
#include <assert.h>
#include <stdio.h>
#define REP(i,n) for(ll i=0;i<(n);i++)
#define MOD 998244353
#define int long long
#ifdef int
const long long INF = LLONG_MAX / 10;
#else
const int INF = 1010101010;
#endif
using namespace std;
typedef long long ll;
typedef vector<vector<ll> > mat;
typedef pair<int, int> P;
//typedef pair<double, double> P;
const int dx[9] = {-1, 0, 0, 1, -1, -1, 1, 1, 0};
const int dy[9] = {0, -1, 1, 0, -1, 1, -1, 1, 0};
 
string S;
int dp[202020][2][3][3]; 

set<string> se;

void dfs(string ss) {
  se.insert(ss);
  REP(i,ss.length()-1) if (ss[i] != ss[i+1]) {
    string t = ss;
    if ((ss[i] == 'b' && ss[i+1] == 'c') || (ss[i] == 'c' && ss[i+1] == 'b')) t[i] = t[i+1] = 'a';
    else if ((ss[i] == 'a' && ss[i+1] == 'c') || (ss[i] == 'c' && ss[i+1] == 'a')) t[i] = t[i+1] = 'b';
    else if ((ss[i] == 'a' && ss[i+1] == 'b') || (ss[i] == 'b' && ss[i+1] == 'a')) t[i] = t[i+1] = 'c';
    if (se.find(t) == se.end()) {
      dfs(t);
    }
  }
}

int brute(string ss) {
  dfs(ss);
  return se.size();
}

signed main() {
  cin >> S;
  int N = S.length();

  // if (N <= 7) assert(false);

  if (N <= 3) {
    cout << brute(S) % MOD << endl;
    return 0;
  }

  bool same = true;
  REP(i,N-1) if (S[i] != S[i+1]) {
    same = false;
    break;
  }
  if (same) {
    cout << 1 << endl;
    return 0;
  }

  dp[1][0][0][0] = 1;
  dp[1][0][1][1] = 1;
  dp[1][0][2][2] = 1;
  for (int i=1; i<=N-1; i++) {
    REP(C,2) {
      REP(last,3) {
        REP(mod,3) {
          if (dp[i][C][last][mod] != 0) {
            REP(j,3) {
              dp[i+1][C|(last==j)][j][(mod+j)%3] += dp[i][C][last][mod];
              dp[i+1][C|(last==j)][j][(mod+j)%3] %= MOD;
            }
          }
          // REP(j,3) {
          //   dp[i+1][C|(last==j)][j][(mod+j)%3] += dp[i][C][last][mod];
          //   dp[i+1][C|(last==j)][j][(mod+j)%3] %= MOD;
          // }
        }
      }
    }
  }

  int mod = 0;
  REP(i,N) mod += S[i] - 'a';
  mod %= 3;

  int ans = 1;
  ans += dp[N][1][0][mod] + dp[N][1][1][mod] + dp[N][1][2][mod];
  REP(i,N-1) if (S[i] == S[i+1]) {
    ans--;
    break;
  }
  cout << ans % MOD << endl;
}

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

using namespace std;

typedef long long int ll;

#define faster ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

#define endl "\n"

int main()
{
	faster;
	
	int n;
	cin >> n;
	if(n % 1000 == 0){
		cout << 0 << endl;
	}else {
		cout << (1000-(n%1000)) << endl;
	}
	return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>
#include <string>
#include <map>
using namespace std;

int n;
vector<string> a;
map<int, vector<int>> v;

void func(int i, int d)
{
    cout<<string(d, '.')<<a[i]<<endl;
    for(auto& e: v[i]) func(e, d+1);
}

int main()
{
    int k;
    string m;
    cin>>n>>k>>m;
    a.push_back(m);
    for(int i=1; i<n; ++i) {
        cin>>k>>m;
        v[k-1].push_back(a.size());
        a.push_back(m);
    }
    func(0, 0);
}

Measured memory_bytes: 3448
'use strict';
(function(stdin) { 
  var inputs = stdin.toString();
  var params = inputs.split('\n')[0].split(' ').map(Number);
  (function(a,b) {
     console.log(a * b,(a + b) * 2)//????????????????????????
  }(params[0],params[1])); 
}(require('fs').readFileSync('/dev/stdin', 'utf8')));

Measured memory_bytes: 7376
#include <iostream>
#include <vector>
using namespace std;
int main(int argc, char* argv[])
{
	int N,M,i;
	cin>>N>>M;
	vector<int> Num(M,0);
	for (i=0;i<N;i++){
		int K;
		cin>>K;
		for (int j=0;j<K;j++){
			int A;
			cin>>A;
			Num[A-1]++;
		}
	}
	int ans=0;
	for (i=0;i<M;i++){
		if (Num[i]==N){
			ans++;
		}
	}
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define pii pair<int,int>
#define len(s) s.length()
#define all(v) v.begin(),v.end()
const ll INF = INT_MAX;
const int N = 2e5 + 5;
const ll mod = 1000000007 ;
using namespace std;

int main() {


	ios_base::sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);


	ll tc = 1;
	// cin >> tc;
	while (tc--) {

		ll n, m, l, r;
		ll i, j;
		ll x, y;

		cin >> n;

		ll a[n], b[n];

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

		if (n % 2) {
			ll l = a[n / 2];
			ll r = b[n / 2];

			cout << r - l + 1 << endl;
		}
		else {
			ld l = (a[n / 2] + a[n / 2 - 1]) / 2.000;
			ld r = (b[n / 2] + b[n / 2 - 1]) / 2.000;

			ld diff = 2 * (r - l) + 1;

			cout << ll(diff) << endl;
		}





	}
}

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

struct Edge {
  long to, c, t;
};

const long inf = 1e18; 
const long mx = 5000;
long n, m, s;
vector<Edge> g[50];
long ca[50];
long ti[50];

vector<long> sub() {
  using PP = pair<long, long>;
  using TT = pair<long, PP>;
  
  priority_queue<TT, vector<TT>, greater<TT>> q;
  q.push(TT(0, PP(0, min(s, mx))));
  
  vector<vector<long>> dist(n, vector<long>(mx + 1, inf));
  while (!q.empty()) {
    auto tt = q.top(); q.pop();
    long d = tt.first;
    long from = tt.second.first;
    long mon = tt.second.second;
    if (dist[from][mon] != inf) continue;
    dist[from][mon] = d;
    for (auto e : g[from]) {
      long to = e.to;
      long c = e.c;
      long t = e.t;
      if (mon >= c) {
        q.push(TT(d + t, PP(to, mon - c)));
      }
    }
    q.push(TT(d + ti[from], PP(from, min(mon + ca[from], mx))));
  }
  
  vector<long> ret(n);
  for (int i = 0; i < n; ++i) {
    long mn = inf;
    for (int j = 0; j <= mx; ++j) {
      mn = min(mn, dist[i][j]);
    }
    ret[i] = mn;
  }
  return ret;
}

int main() {
  cin >> n >> m >> s;
  for (int j = 0; j < m; ++j) {
     int u, v, a, b;
     cin >> u >> v >> a >> b;
     --u; --v;
     g[u].push_back(Edge{v, a, b});
     g[v].push_back(Edge{u, a, b});
  }
  for (int i = 0; i < n; ++i) {
    cin >> ca[i] >> ti[i]; 
  }
  
  auto v = sub();
  for (int i = 1; i < n; ++i) {
    cout << v[i] << endl;
  }
}

Measured memory_bytes: 29636
#include <bits/stdc++.h>
#define F first
#define S second
#define forn(i, n) for(int i = 0; i < int(n); i++)
#define p_b push_back
#define all(c)              c.begin(), c.end()
using namespace std;
typedef long long ll; //printf("%lld ", ll); to out put long
typedef pair <int , int> pii;
typedef pair <ll , ll> pll;
const double eps = 1e-6;
const int MAXN = 1e6 + 5;
const ll MOD = 1e9 + 7;
bool ODD(ll O) {return (O % 2 != 0);}
ll gcd(ll a, ll b) {return __gcd(a , b);}
int dx[] = {1, 0, -1 ,0 , -1 , 0};
int dy[] = {0, 1, 0, -1 , -1 , 0};
ll power (ll x, ll y) {
    if(y == 0) return 1;
    if(ODD(y)) return x * power(x , y / 2) * power(x , y / 2);
    return power(x , y / 2) * power(x , y / 2);
}
/*------ never give up --------*/
int fix(ll n) {
    return (n % 26);
}

int main () {
    int t = 1;
    //cin >> t;
    while(t--) {
        ll n;
        cin >> n;
        string ans = "";
        while(n > 0) {
            n--;
            int cur = fix(n);
            ans += cur + 'a';
            n /= 26;
        }
        reverse(all(ans));
        cout << ans;

    }
    return 0;
}


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

int trace(int pt, int record, int all_mask, std::vector<std::vector<int>>& connectTo, int num){
    if((record & all_mask) == all_mask){
        return num+1;
    }
    int sum = num;
    std::vector<int> connections = connectTo.at(pt);
    for(unsigned int i = 0; i < connections.size(); i++){
        int np = connections.at(i);
        int mask = 1 << np;
        if((record & mask) == 0){
            sum = trace(np, (record | mask), all_mask, connectTo, sum);
        }
    }
    return sum;
}


int main(int argc, char **argv)
{
    int N, M;
    std::cin >> N >> M;
    std::vector<int> a(M), b(M);
    for(int i = 0; i < M; i++){
        std::cin >> a.at(i) >> b.at(i);
    }
    std::vector<std::vector<int>> connectTo(N, std::vector<int>(0));
    for(int i = 0; i < M; i++){
        connectTo.at(a.at(i)-1).push_back(b.at(i)-1);
        connectTo.at(b.at(i)-1).push_back(a.at(i)-1);
    }
    int all_mask = (1 << N) - 1;
    int num = trace(0, 0x001, all_mask, connectTo, 0);
    std::cout << num << std::endl;
}


Measured memory_bytes: 256