akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

	public static int dfs(int n, int limit, int k, boolean[] is_prime, int[][][] memo){
		if(n < 0){
			return 0;
		}else if(memo[k][limit][n] >= 0){
			return memo[k][limit][n];
		}else if(k == 0 && n == 0){
			return 1;
		}else if(k == 0){
			return 0;
		}
		
		int ans = 0;
		//System.out.println(n + " " + limit);
		for(int prime = Math.min(n, limit - 1); prime >= 2; prime--){
			if(!is_prime[prime]){
				continue;
			}
			
			ans += dfs(n - prime, prime, k - 1, is_prime, memo);
		}
		
		return memo[k][limit][n] = ans;
	}
	
	public static final int MAX = 1120;
	public static final int SQRT = (int)(Math.ceil(Math.sqrt(MAX)));
	
	public static void main(String[] args) {
		final Scanner sc = new Scanner(System.in);

		boolean[] is_prime = new boolean[MAX + 1];
		
		for(int i = 2; i <= MAX; i++){
			is_prime[i] = true;
		}
		
		for(int i = 2; i <= SQRT; i++){
			if(is_prime[i]){
				for(int j = 2 * i; j <= MAX; j += i){
					is_prime[j] = false;
				}
			}
		}
		
		int[][][] memo = new int[15][MAX+2][MAX+1];
		
		for(int i = 0; i <= 14; i++){
			for(int j = 0; j <= MAX + 1; j++){
				Arrays.fill(memo[i][j], -1);
			}
		}
		
		while(true){
			final int n = sc.nextInt();
			final int k = sc.nextInt();
			
			if(n == 0 && k == 0){
				break;
			}
			
			System.out.println(dfs(n, n + 1, k, is_prime, memo));
		}
		
	}

}

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

#ifdef LOCAL
#include "debug.h"
#else
#define DEBUG(...)
#endif

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  s[1] ^= 'B' ^ 'R';
  cout << s << '\n';
}


Measured memory_bytes: 3576
import java.util.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main{
//    static final long mod=1000000007;
//    static int dx[]={-1,0,1,0};
//    static int dy[]={0,-1,0,1};

    public  static void main(String[] args)   throws Exception, IOException{        
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);
        // int n=sc.nextInt();
        // char c[][] = new char[h][w];
        // char c[]=sc.nextString().toCharArray();
        // int d[]=new int[n];
        // for(int i=0; i<n; i++) {d[i]=sc.nextInt();}

        int n=sc.nextInt();
        int h=sc.nextInt();
        int w=sc.nextInt();
        
        int a=(-h+n+1)*(-w+n+1);

        out.println(a<0?0:a);
        out.flush();
    }
    
    static boolean validpos(int x,int y,int r, int c){
        return x<r && 0<=x && y<c && 0<=y;
    }

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

//class P {
//    int id, d;
//    P(int  id, int d) {
//        this.id=id;
//        this.d=d;
//    }
//}

//class P implements Comparable<P>{
//    int id, d;
//    P(int  id, int d) {
//        this.id=id;
//        this.d=d;
//    }
//    public int compareTo(P p){
//        return d-p.d; //des
//    }
//}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public int[] nextIntArray(int size) throws IOException{
    	int r[] = new int[size];
    	for (int i = 0; i < size; i++) {
			r[i] = this.nextInt(); 
		}
    	return r;
    }
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}


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

int n, pos;
vector<int> pre, in, post;

void rec(int l, int r) {
    if (l >= r) return;
    int root = pre[pos++];
    int m = distance(in.begin(), find(in.begin(), in.end(), root));
    rec(l, m);
    rec(m + 1, r);
    post.push_back(root);
}

void solve() {
    pos = 0;
    rec(0, pre.size());
    for (int i = 0; i < n; i++) {
        if (i) cout << " ";
        cout << post[i];
    }
    cout << endl;
}

int main() {
    int k;
    cin >> n;

    for (int i = 0; i < n; i++) {
        cin >> k;
        pre.push_back(k);
    }

    for (int i = 0; i < n; i++) {
        cin >> k;
        in.push_back(k);
    }

    solve();
    
    return 0;
}


Measured memory_bytes: 3172
#include <bits/stdc++.h>
using namespace std;
#define start_routine cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false); int begtime = clock();
#define end_routine int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0
#define contests_de_diya_kar 0
#define PB push_back
#define MP make_pair
#define int long long
#define MOD ((long long) (1000*1000*1000 + 7))
#define inf (int) 2e15
#define exit(a, b) return cout << a, b;
#define eps (double)1e-8
#define forn(a, b, i) for (int i = a; i < b; i += 1)
#define vi vector<int>
#define vb vector<bool>
#define all(v) v.begin(), v.end()
#define ll long long 
#define pii pair<int, int>
#define mii map<int, int> 
#define print(stuff) cout << stuff << endl
#define len(stuff) stuff.size()

const int MODULO = MOD;
int n;
bool vis[3][1001][4];
int dp[3][1001][4];
bool blocked[3][1001];

int rec (int row, int col, int type) {
	if (vis[row][col][type]) return dp[row][col][type];
	vis[row][col][type] = true;
	if (blocked[row][col]) {
		dp[row][col][type] = 0;
		return 0;
	}
	if (type == 0) {
		if (row >= 1) {
			if (col >= n - 1 && row != 2) {
				dp[row][col][type] = 0;
				return 0;
			}
			dp[row][col][type] += rec(row - 1, col, 2);
			dp[row][col][type] %= MODULO;
		}
	} 
	if (type == 1) {
		if (row <= 1) {
			if (col >= n - 1) {
				dp[row][col][type] = 0;
				return 0;
			}
			dp[row][col][type] += rec(row + 1, col, 3);
			dp[row][col][type] %= MODULO;
		}
	}
	if (type == 2) {
		if (col == 0 && row == 0) {
			dp[row][col][type] = 1;
			return dp[row][col][type];
		}
		if (col >= 1 && row < 2) {
			dp[row][col][type] += rec(row, col - 1, 0);
			dp[row][col][type] %= MODULO;
			dp[row][col][type] += rec(row, col - 1, 1);
			dp[row][col][type] %= MODULO;
		}
	}
	if (type == 3) {
		if (col >= 1 && row >= 1) {
			dp[row][col][type] += rec(row, col - 1, 0);
			dp[row][col][type] %= MODULO;
			dp[row][col][type] += rec(row, col - 1, 1);
			dp[row][col][type] %= MODULO;
		}
		else {
			dp[row][col][type] = 0;
			return dp[row][col][type];
		}
	}
}
signed main () {
	start_routine;
	
	#ifndef ONLINE_JUDGE
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	#endif 

	int n;
	cin >> n;

	cout << "AB";
	if (n >= 1000) cout << "D";
	else cout << "C";
	end_routine;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl "\n"


using namespace std;

int main()
{
   int n;
   cin>>n;
   int arr[n];
   int i;
   long long ans=0;;
   for(i=0;i<n;i++) cin>>arr[i];
   int max_sofar = arr[0];
   for(i=1;i<n;i++){
       max_sofar = max(max_sofar,arr[i]);
       if(arr[i]<max_sofar){
           ans+=(max_sofar-arr[i]);
       }
   }
   cout << ans << endl;
}


Measured memory_bytes: 4372
#include<stdio.h>
main(){
  int t,m,b,sum;
  while(1){
  scanf("%d%d%d",&t,&m,&b);
  if(t==-1&&m==-1&&b==-1){
    break;
  }
  sum=t*3600+m*60+b;
  sum=120*60-sum;
  t=m=b=0;
  while(sum>0){
    if(sum>=3600){
      sum=sum-3600;
      t++;
    }
    else if(sum>=60){
      sum=sum-60;
      m++;
    }
    else{
      sum--;
      b++;
    }
  }
  printf("%02d:%02d:%02d\n",t,m,b);
  sum=(t*3600+m*60+b)*3;
  t=m=b=0;
  while(sum>0){
    if(sum>=3600){
      sum=sum-3600;
      t++;
    }
    else if(sum>=60){
      sum=sum-60;
      m++;
    }
    else{
      sum--;
      b++;
    }
  }
  printf("%02d:%02d:%02d\n",t,m,b);
  }
  return 0;
}

Measured memory_bytes: 0
#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;
int a[300];
int dp[100001][2];
double res;

int solve( int j,bool b){
    if(j == 0)return b ? -1 : 1;
    int &r = dp[j][b];
    if(r != -2)return r;
    if(b){
        r = -1;
        fore(i,0,n){
            if(j -a[i] >= 0){
                r = max(r,solve(j-a[i],!b));
            }
        }
    }else{
        r = 1;
        fore(i,0,n){
            if(j-a[i]>=0){
                r = min(r,solve(j-a[i],!b));
            }
        }
    }

    return r;
}


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

    if(solve(k,false)!=1){
        cout<<"First";
    }else{
        cout<<"Second";
    }

    return 0;
}



















Measured memory_bytes: 6528
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
#define int long long
#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 repR(i,n) for(int i=n;i>=0;i--)
#define P pair<int, int>
#define sz(x) x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<int>
#define COUT(x) cout<<(x)<<endl
#define MA map<int,int>
#define SE set<int>
#define PQ priority_queue
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl

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

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
	if (a.second != b.second) {
		return a.second < b.second;
	}
	else {
		return a.first < b.first;
	}
}

const long long MOD = 1000000007;
const long long INF = 1LL << 50;

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	VE a(n); rep(i, n)cin >> a[i];
	int now = 0;
	int ans = 0;
	rep(i, n) {
		if (a[i] == 0) {
			ans += now / 2;
			now = 0;
		}
		else {
			now += a[i];
		}
	}
	ans += now / 2;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
      return Array.new(size1){init}
  else
      return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

S=gets.to_i
if S==10**18
    puts "0 0 0 #{10**9} #{10**9} 0"
    exit
end
x1=0
y1=0
x2=10**9
y2=1
s=S/x2
r=S%x2
x3=x2-r
y3=s+1
puts [x1,y1,x2,y2,x3,y3].join(" ")

Measured memory_bytes: 14264
#include<cmath>
#include<algorithm>
#include<iostream>
#include<vector>

using namespace std;

double EPS = 1e-10;

double add(double a, double b){
  if(abs(a+b) < EPS * (abs(a)+abs(b)))return 0;
  return a+b;
}

struct point{
  double x, y;
  point(){}
  point(double x,double y) : x(x) , y(y){}

  point operator + (point p){
    return point(add(x,p.x), add(y,p.y));
  }

  point operator - (point p){
    return point(add(x,-p.x), add(y,-p.y));
  }

  point operator * (double d){
    return point(x*d,y*d);
  }
};

double cross(point a, point b) {
  return (a.x * b.y - a.y * b.x);
}

int is_intersected_ls(point a1, point a2, point b1, point b2) {
  return ( cross(a2-a1, b1-a1) * cross(a2-a1, b2-a1) < EPS ) &&
         ( cross(b2-b1, a1-b1) * cross(b2-b1, a2-b1) < EPS );
}

int main(void){
  int n;
  point p[3],k,s;

  cin >> n;
  while(n--){
    for(int i=0;i<3;i++)
      cin >> p[i].x >> p[i].y;
    
    cin >> k.x >> k.y >> s.x >> s.y;
    int cnt=0;
    for(int i=0;i<3;i++)
      for(int j=i+1;j<3;j++)
	  cnt+=is_intersected_ls(p[i],p[j],k,s);
    
    if(cnt%2)cout << "OK" << endl;
    else cout << "NG" << endl;
    
  }

  return 0;
}

Measured memory_bytes: 952
IDENTIFICATION DIVISION.
       PROGRAM-ID. ABC045-A.
       DATA DIVISION.
       FILE SECTION.
       WORKING-STORAGE SECTION.
       77 A PIC 9(3).
       77 B PIC 9(3).
       77 H PIC 9(3).
       77 ANS PIC 9(5).
       77 ANSS PIC Z(5).

       PROCEDURE DIVISION.
       MAIN-PROCEDURE.
               ACCEPT A FROM SYSIN.
               ACCEPT B FROM SYSIN.
               ACCEPT H FROM SYSIN.
               COMPUTE ANS = (A + B) * H / 2.
               MOVE ANS TO ANSS.
               DISPLAY ANSS.
               STOP RUN.
       END PROGRAM ABC045-A.


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

int main() {
	int N;
	cin >>N;
	int A[N];
	int v;
	for(int i=0;i<N;i++){
		cin >>A[i];
	}
	for(int i=0;i<N;i++){
		v=A[i];
		int j=i-1;
		while(j >=0 && A[j]>v){
			A[j+1]=A[j];
			j--;
			A[j+1]=v;
		}
		for(int k=0;k<N-1;k++){
			cout <<A[k]<<" ";
		}
		cout <<A[N-1];
		cout <<endl;
	}
}


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

using namespace std;

#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define Debug(...) fprintf(stderr, __VA_ARGS__)

typedef long long LL;
typedef long double LD;
typedef unsigned int uint;
typedef pair <int, int> pii;
typedef unsigned long long uLL;

template <typename T> inline void Read(T &x) {
  char c = getchar();
  bool f = false;
  for (x = 0; !isdigit(c); c = getchar()) {
    if (c == '-') {
      f = true;
    }
  }
  for (; isdigit(c); c = getchar()) {
    x = x * 10 + c - '0';
  }
  if (f) {
    x = -x;
  }
}

template <typename T> inline bool CheckMax(T &a, const T &b) {
  return a < b ? a = b, true : false;
}

template <typename T> inline bool CheckMin(T &a, const T &b) {
  return a > b ? a = b, true : false;
}

const int N = 500005;
const int mod = 998244353;

int n, m, ans, fac[N], inv[N];

inline int C(int x, int y) {
  if (x < 0 || y < 0 || x < y) {
    return 0;
  }
  return 1LL * fac[x] * inv[y] % mod * inv[x - y] % mod;
}

int main() {
#ifdef wxh010910
  freopen("d.in", "r", stdin);
#endif
  Read(n), Read(m), fac[0] = fac[1] = inv[0] = inv[1] = 1;
  for (int i = 2; i <= m; ++i) {
    fac[i] = 1LL * fac[i - 1] * i % mod;
    inv[i] = 1LL * (mod - mod / i) * inv[mod % i] % mod;
  }
  for (int i = 2; i <= m; ++i) {
    inv[i] = 1LL * inv[i - 1] * inv[i] % mod;
  }
  for (int i = n; i <= m; ++i) {
    ans = (ans + C(m, i)) % mod;
    ans = (ans - C(m, i * 2 - n + 1) + mod) % mod;
  }
  printf("%d\n", ans);
#ifdef wxh010910
  Debug("My Time: %.3lfms\n", (double)clock() / CLOCKS_PER_SEC);
#endif
  return 0;
}


Measured memory_bytes: 4224
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse2")


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;


typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;

#define int         long long
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define mp          make_pair
#define all(a)      (a).begin(),(a).end()
#define FF           first
#define SS           second
#define sz(x)       (int)x.size()
#define endl        '\n'
//#define hell          1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
// mp::cpp_int

const int hell=1000000007;



int solve( ){


int n;
cin>>n;
vi a(n);
int sum1=0;
rep(i,0,n){
  cin>>a[i];
  sum1+=a[i];
}


int ans=hell;
int sum=0;
rep(i,0,n-1)
{ 
  sum+=a[i];
 ans=min(ans,abs(sum-sum1+sum));
}
cout<<ans;

}
signed main()
{  int t=1;

 ios::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
   cin.exceptions(cin.failbit);                                                                    

  clock_t time_req;

    // Without using pow function
                                                                                                                   
//cin>>t;

    int k=1;
   while(t--)
     {
       //cout<<"case #"<<k<<":"<<" ";k++;
      solve();
      cout<<endl;

     }

         time_req = clock() - time_req;
    //cout <<endl<< "Processor time taken is "
     // << (double)time_req/CLOCKS_PER_SEC << " seconds" << endl;


    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int t=0, i=0, ans=0, j=0, k=0, m=0, n=0;
int main()
{
    for(i=0;i<5;i++)
    {
        cin>>m;
        if(m==0)
        {
            ans=i+1;
        }
    }
    cout<<ans;
}


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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

#define MAXN 100001
int dp[MAXN][2];

int main(){
  string s; cin>>s;
  int n = s.size();

  //dp[i][j]:sをi文字目まで見た時のa+bの種類数、j=1の時はその数がL未満であることが確定している、j=0の時はその数はi文字目まではLと一致している。
  dp[0][0]=1;
  rep(i, n){
    {//a+bのi bit目が0
      if(s[i]=='0'){
        dp[i+1][0] = dp[i][0];
        dp[i+1][1] = dp[i][1];
      }else{
        dp[i+1][1] = (dp[i][0] + dp[i][1])%MOD;
      }
    }
    {//a+bのi bit目が1
      if(s[i]=='0'){
        //a+bのi文字目が1でsのi文字目が0であれば、a+bがLよりもでかくなることが確定するので、それまでの数字が一致しているs[i][0]は使用不可、a+b<Lが確定しているdp[i][1]のみが使用可能。そして数字の組み合わせは反転させることで2倍になる。
        (dp[i+1][1] += dp[i][1]*2%MOD) %= MOD;
      }else{
        (dp[i+1][0] += dp[i][0]*2%MOD) %= MOD;
        (dp[i+1][1] += dp[i][1]*2%MOD) %= MOD;
      }
    }
  }
  cout<<(dp[n][0]+dp[n][1]) % MOD<<endl;

  return 0;
}

Measured memory_bytes: 1280
#include <stdio.h>

int main(){
	int d;
	int n = 600;
	long S = 0;
	
	while(scanf("%d",&d) != EOF){
		while(n - d > 0){
			n -= d;
			S += d*(600-n)*(600-n);
		}
		printf("%ld\n",S);
		S = 0;
		n = 600;
	}
	return 0;
}

Measured memory_bytes: 596
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<functional>
#include<numeric>
#include<queue>
#include<stack>
#include<map>
#include<unordered_map>
#include<set>
#include<bitset>
#include<random>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,y,x) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
const ll inf = 2222222222222222222LL;
const ll mod = 1000000007LL;

ll n = 0, m = 0, ans = 0, tmp = 0, ma = -inf, mi = inf;
string s;
bool ok;
ll dx[9] = { 0,1,-1,0,0,1,1,-1,-1 }, dy[9] = { 0,0,0,1,-1,1,-1,1,-1 };
#define endl '\n'
#pragma endregion
#define MAX 222222





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


  ll x, y, z;
  cin >> x >> y >> z >> m;
  vll a(x), b(y), c(z), v;
  rep(i, x) cin >> a[i];
  rep(i, y) cin >> b[i];
  rep(i, z) cin >> c[i];
  sort(rall(a)); sort(rall(b)); sort(rall(c));
  rep(i, a.size()) rep(j, b.size()) rep(k, c.size()) {
    if (i*j*k > 3000) continue;
    tmp = a[i] + b[j] + c[k];
    v.pb(tmp);
  }
  sort(rall(v));
  rall(v);
  rep(i, m) cout << v[i] << endl;



  return 0;
}

Measured memory_bytes: 35176
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
ll i,j,k;
vector<ll> sum1,sum2,sum3,sum4;

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

void pre_process(vector<ll> &a,vector<ll> &s){//累積和のvector
    ll n=(ll)a.size();
    s.assign(n+1,a[0]);
    for(i=1;i<n;i++){
        s[i+1]=gcd(s[i],a[i]);
    }
}

int main(){
    int n;cin>>n;
    vector<ll> a(n),b(n);
    for(i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a.begin(),a.end());
    for(i=0;i<n;i++){
        b[i]=a[n-1-i];
    }
    pre_process(a,sum1);
    pre_process(b,sum2);


    ll mina=1000000,minb=1000000,key1,key2,ans;
    for(i=1;i<=n;i++){
        if(mina>sum1[i]){mina=sum1[i];key1=i;}
    }
    key1--;
    for(i=1;i<=n;i++){
        if(minb>sum2[i]){minb=sum2[i];key2=n-i;}
    }

    vector<ll> c;
    vector<ll> d;
    for(i=0;i<n;i++){
        if(i!=key1){c.push_back(a[i]);}
    }
    for(i=0;i<n;i++){
        if(i!=key2){d.push_back(a[i]);}
    }

    pre_process(c,sum3);
    pre_process(d,sum4);
    
    ans=max(sum3[n-1],sum4[n-1]);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 6644
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;

int main(){
    int n, k;
    cin >> n >> k;
    if(k==1){
      cout << 0 << endl;
    }else{
      cout << n - k << endl;
    }
    return 0;
}

Measured memory_bytes: 3608
/*
 Templatka c++ Kacper Fis																							   																											   //
*/

#include <iostream>
#include <cstdio>
#include <limits>
#include <cstdlib>
#include <utility>
#include <iterator>
#include <bitset>
#include <list>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cmath>
#include <string>
#include <time.h>
#include <iomanip>
#include <sstream>
#include <bits/stdc++.h>

using namespace std;

const int INF = 1000000001;
const float PI = 3.14;
typedef long long LL;

typedef vector<int> vi;
typedef list<int> li;
typedef queue<int> qi;
typedef pair<int,int> ii;
typedef map<string,int> msi; //np msi['nazwa'] = 'liczba'
typedef vector<ii> vii; //vector par<int>, do tworzenia tablicy dla grafów wagowych #dijkstra #Bellman_Ford
typedef priority_queue< ii, vector<ii>, greater<ii> > pq; //kolejka priorytetowa vectorów par(top()=min) #dijkstra


#define print_list(x) for(it = (x).begin(); it != (x).end(); it++) {cout << *it << " ";}
#define print_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++) {cout << *it2 << " ";}
#define search_list(x) for(it = (x).begin(); it != (x).end(); it++)
#define search_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++);
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define mp(x, y) make_pair(x, y)
///////////////////////////////////////////////GLOBAL DEFINITIONS////////////////////////////////////////////////////////


///////////////////////////////////////////////////FUNCTIONS/////////////////////////////////////////////////////////////



/////////////////////////////////////////////////////MAIN////////////////////////////////////////////////////////////////
int main(int argc, char* argv[])
{ios_base::sync_with_stdio(false); cin.tie(NULL);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	
	int a, b, c;
	cin >> a >> b >> c;
	if(a == b && b == c){
		if(a % 2 == 1) cout << "0" << endl;
		else cout << -1 << endl;
	}
	else{
		LL counter = 0;
		while(a % 2 == 0 && b % 2 == 0 && c % 2 == 0){
			LL one = a / 2;
			LL two = b / 2;
			LL three = c / 2;
			a = two + three;
			b = one + three;
			c = one + two;
			counter++;
		}
		
		cout << counter << endl;
	}

	
	
	return 0;
}


Measured memory_bytes: 764
import java.util.*;

class Main {
  public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
    
    int N = sc.nextInt();
    int M = sc.nextInt();
    long X = sc.nextLong();
    long[] P= new long[N]; 
    long[][]  Y = new long[N][M];
    long[] ans = new long[M];
    for (int i = 0; i < N; i++){
      P[i] = sc.nextLong();
      for (int j = 0;j<M;j++){        
        Y[i][j] = sc.nextLong();
      }
    }
            
    long max = 10000000;
    for (long bit = 0; bit < (1<< N);bit++){
      Arrays.fill(ans, 0);
      long sum = 0;
      for (int j = 0; j < N; j++){
        if ((bit & (1 << j)) == 0){
          sum += P[j];
          for (int i = 0; i < M; i++){            
          	ans[i] += Y[j][i];            
          }
        }
      }
      int temp = 0;
      while (temp < M  && ans[temp] >= X){
      	temp++;        
      }
      if (temp == M){
        max = Math.min(sum,max);
      }
    }
   if (max != 10000000){
     System.out.println(max);
   }else{
     System.out.println(-1);
   }
  }
}


Measured memory_bytes: 37496
#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
#include <map>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;

string s;
int main() {
	cin >> s;
	if ((s[0] == s[1] && s[1] == s[2]) || (s[1] == s[2] && s[2] == s[3])) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<algorithm>
using namespace std;
const int MAXN=100005;

void NoSolution()
{
	puts("NO");
	fclose(stdin);
	fclose(stdout);
	exit(0);
}

int n,A[MAXN];
vector<int> adj[MAXN];

int dfs(int u,int fa=0)
{
	if(adj[u].size()==1U)
		return A[u];
	long long sum=0;
	int tmp=0,mx=0;
	for(int i=0;i<(int)adj[u].size();i++)
	{
		int v=adj[u][i];
		if(v==fa)
			continue;
		tmp=dfs(v,u);
		mx=max(mx,tmp);
		sum+=tmp;
	}
	if(fa==0)
	{
		if(sum%2==1||mx>sum/2||A[u]!=sum/2)
			NoSolution();
		return 0;
	}
	long long delta=sum-A[u];
	if(A[u]<delta||sum<A[u]||sum-mx<delta)
		NoSolution();
	return A[u]-delta;
}

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&A[i]);
	if(n==2)
	{
		if(A[1]==A[2])
			puts("YES");
		else
			puts("NO");
		return 0;
	}
	for(int i=1;i<n;i++)
	{
		int a,b;
		scanf("%d%d",&a,&b);
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	for(int i=1;i<=n;i++)
		if(adj[i].size()>1U)
		{
			dfs(i);
			break;
		}
	puts("YES");
	
	return 0;
}


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

int main() {
    int N;
    string S1, S2;
    cin >> N >> S1 >> S2;

    long long ans;
    long long MOD = 1e9 + 7;
    int tmp;
    if (S1[0] == S2[0]) {
        ans = 3;
        tmp = 0;
    }
    else {
        ans = 6;
        tmp = 1;
    }

    if (tmp == 0) {
        for (int i = 1; i < N; i++) {
            //cout << i << endl;
            if (S1[i] == S2[i]) {
                if (tmp == 0) {
                    ans *= 2;
                    ans %= MOD;
                }
                tmp = 0;
            }
            else {
                if (tmp == 0) {
                    ans *= 2;
                    ans %= MOD;
                }
                else {
                    ans *= 3;
                    ans %= MOD;
                }
                i++;
                tmp = 1;
            }
        }
    }
    else {
        for (int i = 2; i < N; i++) {
            if (S1[i] == S2[i]) {
                if (tmp == 0) {
                    ans *= 2;
                    ans %= MOD;
                }
                tmp = 0;
            }
            else {
                if (tmp == 0) {
                    ans *= 2;
                    ans %= MOD;
                }
                else {
                    ans *= 3;
                    ans %= MOD;
                }
                i++;
                tmp = 1;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
#include <cstring>
#define MAXN 200005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef double db;
int N,P[MAXN],V[MAXN],fa[MAXN],C[2][MAXN];
int getfa(int x) {
	return fa[x] == x ? x : fa[x] = getfa(fa[x]);
}
struct cmp {
	bool operator() (const int &a,const int &b) {
		if(1LL * C[0][a] * C[1][b] != 1LL * C[0][b] * C[1][a])
			return 1LL * C[0][a] * C[1][b] > 1LL * C[0][b] * C[1][a];
		else return a > b;
	}
};
multiset<int,cmp> S;
void Solve() {
	scanf("%d",&N);
    for(int i = 2 ; i <= N ; ++i) scanf("%d",&P[i]);
   	for(int i = 1 ; i <= N ; ++i) scanf("%d",&V[i]);
   	for(int i = 1 ; i <= N ; ++i) fa[i] = i;
   	for(int i = 1 ; i <= N ; ++i) C[V[i]][i] = 1;
   	for(int i = 2 ; i <= N ; ++i) S.insert(i);
   	int64 ans = 0;
   	for(int i = 1 ; i <= N - 1 ; ++i) {
   		int v = *S.begin();
   		int p = getfa(P[v]);
   		S.erase(v);S.erase(p);
   		ans += 1LL * C[0][v] * C[1][p];
   		C[1][p] += C[1][v];C[0][p] += C[0][v];
   		fa[v] = p;
   		if(p != 1) S.insert(p);
   	}
   	printf("%lld\n",ans);	
}

int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
    return 0;
}

Measured memory_bytes: 13568
a = [int(_) for _ in input().split()]
if len(a) == 2 and all(1 <= item <= 100 for item in a):
    if (a[0] + a[1]) % 2 == 0:
        print((a[0] + a[1]) // 2)
    else:
        print((a[0] + a[1]) // 2 + 1)
else:
    print('hoge!')

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define crap ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
typedef long long int ll;
typedef unsigned long long ull;
typedef std::vector<int> vi;
typedef std::vector<ll> vll;
typedef std::vector<vi > vvi;
typedef std::vector<vll > vvll;
typedef std::pair<int,int> ii;
typedef std::pair< ll, ll > lp;
typedef std::vector<ii> vii;
typedef std::vector<vii > vvii;

#define pb push_back 
#define PB pop_back
#define pf push_front
#define PF pop_front
#define mp make_pair
#define ub(a,b) upper_bound(all(a),b)
#define lb(a,b) lower_bound(all(a),b)
#define bs(a,b) binary_search(all(a),b)
#define mem(a,b) memset(a,b,sizeof(a))
#define in(a,n) F(i,0,n-1)cin>>a[i]
#define in1(a,n) F(i,1,n)cin>>a[i]
#define out(a,n) F(i,0,n-1)cout<<a[i]<<" ";cout<<"\n"
#define ff first
#define ss second
#define F(i,a,b) for (int i=a;i<=b;i++)
#define RF(i,a,b) for(ll i=a;i>=b;i--)
#define rep(i,n) F(i,0,n-1)
#define clr(a) (a).clear()
#define rz resize
#define sqr(a) ((a) * (a))
#define sz(a) int((a).size())
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin() ,(a).rend()
#define endl '\n'

int main(int argc, char const *argv[])
{
	crap;
	string s;
	cin>>s;
	int n=s.length();
	ll ans=0,b=0,w=0;
	rep(i,n)
	{
		if (s[i]=='W')
			ans+=b;
		else
			b++;
	}

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

Measured memory_bytes: 720
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;

long long cnt;
int l;
int A[1000000];
int n;
vector<int> G;

void insertionSort(int A[], int n, int g){
  for(int i = g; i < n; i++){
    int v = A[i];
    int j = i - g;

    while(j >= 0 && A[j] > v){
      A[j + g] = A[j];
      j -= g;
      cnt++;
    }
    A[j + g] = v;
  }
}

void shellSort(int A[], int n){
  for(int h = 1; ; ){
    if(h > n) break;
    G.push_back(h);
    h = 3*h + 1;
  }

  for(int i = G.size()-1; i >= 0; i--){
    insertionSort(A, n, G[i]);
  }
}

int main(){
  cin >> n;

  for(int i = 0; i < n; i++){
    scanf("%d", &A[i]);
  }
  cnt = 0;

  shellSort(A, n);

  cout << G.size() << endl;

  for(int i = G.size() - 1; i >= 0; i--){
    printf("%d", G[i]);
    if(i) printf(" ");
  }
  printf("\n");
  printf("%lld\n", cnt);

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

  return 0;
}
    



Measured memory_bytes: 7176
using System;
class program{
	static void Main(){
      var vals = Console.ReadLine().Split(' ');
      var H = int.Parse(vals[0]);
      var W = int.Parse(vals[1]);
      var K = int.Parse(vals[2]);
      var grid = new char[H][];
      for (int i = 0; i < H; i++)
        {
            grid[i] = Console.ReadLine().ToCharArray();
        }
      int ans = 0,count;
      for(int i = 0;i < (1 << H);i++){
        for(int j = 0;j < (1 << W);j++){
          count = 0;
          for(int x = 0;x < H;x++){
            for(int y = 0;y < W;y++){
              if(((i >> x)&1)==0 && ((j >> y)&1)==0 && grid[x][y]=='#') count++;
            }
          }
          if(count == K) ans++;
        }
      }
      
      Console.WriteLine(ans);
	}
}


Measured memory_bytes: 27476
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define time__(d) for ( auto blockTime = make_pair(chrono::high_resolution_clock::now(), true);blockTime.second;\
debug("%s: %lld ms\n", d, chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - blockTime.first).count()), blockTime.second = false)
#define li long long int
#define ld long double
#define eb push_back
#define pb pop_back
#define INF 1e18+10
#define MINF -1e18-10
#define rep(i,a,b) for(li i=a;i<b;i++)
#define size(a) a.size()
#define rev(a) reverse(a.begin(),a.end())
#define len(a) a.length()
#define f first
#define s second
#define sort(a) sort(a.begin(),a.end())
#define vli vector<li>
#define vvli vector<vli >
#define pli pair<li,li>199
#define vpli vector<pli>
#define inp(t) li t;cin>>t; while(t--)
using namespace std;
const li mod = 1e9+7;
#define MAXN 2000001
#define PI 3.14159265358979323846264338327950

li power(li a, li b) { a%=mod; li ret=1;while(b) {if(b&1) ret*=a;a*=a;if(ret>=mod) ret%=mod;if(a>=mod) a%=mod;b>>=1;}return ret;}
li add(li a,li b) { return (((a%mod)+(b%mod))%mod);}
li sub(li a,li b) { return (((a%mod)-(b%mod))%mod);}
li mul(li a,li b) { return (((a%mod)*(b%mod))%mod);}

void solve()
{
  li a,b,h,m;

  cin>>a>>b>>h>>m;

  cout<<setprecision(20);

  long double angle = PI*2*((long double)h/12.0 + ((long double)m/60.0)/12.0 - (long double)m / 60.0 );

  long double ans = sqrt((long double)(power(a,2) + power(b,2)) - (long double)(2*a*b)*cosl(angle));

  cout<<ans<<endl;

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

    solve();
    
    return 0;
}

Measured memory_bytes: 4188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(long long i=0; i<(n); i++)
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; }


int main(){
    ll n; cin>>n;
    ll res=0;
    map<string,ll> m;
    rep(i,n){
        string s; cin>>s;
        if(m[s]==0) res++;
        m[s]=1;
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 19156
"use strict";

// read lines from stdin
const input = require("fs")
  .readFileSync("/dev/stdin", "utf8")
  .split("\n");

const N = parseInt(input[0], 10);
const S = input[1];

const list = {};

for (let i = 0; i < N; i++) {
  const char = S.charAt(i);
  list[char] = list[char] ? list[char] + 1 : 1;
}

let ans = 1;

Object.keys(list).forEach((key) => {
  ans *= list[key] + 1;
  ans %= Math.pow(10, 9) + 7;
});

console.log(ans - 1);


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

string s, t, ans="";
int dp[3003][3003], n, m;

void self_max(int &a, int b){
	a=max(a,b);
}

int main(){
	cin >> s >> t;
	n=s.length();
	m=t.length();
	for (int i=0;i<=n;i++){
		for (int j=0;j<=m;j++){
			if (i==0 || j==0) dp[i][j]=0;
			else if (s[i-1]==t[j-1]) dp[i][j]=dp[i-1][j-1]+1;
			else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
		}
	}
	int posx=n, posy=m;
	while (posx>0 && posy>0){
		if (s[posx-1]==t[posy-1]){
			ans.push_back(s[posx-1]);
			posx--;
			posy--;
		}
		else if (dp[posx-1][posy]<dp[posx][posy-1]) posy--;
		else posx--;
	}
	reverse(ans.begin(),ans.end());
	cout << ans << "\n";
}

Measured memory_bytes: 35456
#include <bits/stdc++.h>
using namespace std;
#define _MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) _MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define mp make_pair
#define pb push_back
#define all(x) begin(x),end(x)
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cerr<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cerr<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

int main(){
  long n,m;
  cin>>n>>m;

  if(n==1 && m==1){
    cout << 1 << endl;
    return 0;
  }

  if(n==1 || m==1){
    cout << max(n,m)-2 << endl;
    return 0;
  }

  cout << max(0L,n-2) * max(0L,m-2) << endl;

  return 0;
}


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

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()
#define endl "\n"

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

void solve() {
    string s;
    cin >> s;
    char bef = '#';
    bool trip = false;
    int cnt = 0;
    for(const auto &c : s ) {
        if(c==bef && !trip) trip=true;
        else {
            bef = c;
            if(trip) {
                bef= '#';
            }
            cnt++; trip = false;
        }
    }
    cout << cnt << endl;
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 3748
main(s,t,a,b,c,d){scanf("%d%d%d%d",&a,&b,&c,&d);s=a+b+c+d;scanf("%d%d%d%d",&a,&b,&c,&d);t=a+b+c+d;printf("%d\n",s>t?s:t);exit(0);}

Measured memory_bytes: 592
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;

namespace AtCoder {
    class Program {
        static void Main(string[] args) {

            var n = int.Parse(Console.ReadLine());

            var list = new List<int>();
            list.Add(n);

            while (true) {
                if (n % 2 == 0) {
                    n = n / 2;
                } else {
                    n = 3 * n + 1;
                }
                list.Add(n);
                if(list.Reverse<int>().Skip(1).Any(x => x == n)) {
                    break;
                }
            }

            Console.WriteLine(list.Count());
        }
    }
}

Measured memory_bytes: 13268
n = int(input())
a = list(map(int, input().split()))
res = float("inf")
arai = sum(a)
sunuke = 0
ans = sum([abs(a[i]) for i in range(n)])
if n == 2:
    print(abs(a[0] - a[1]))
    exit()
for i in range(n-1):
    sunuke += a[i]
    arai -= a[i]
    ans = min(ans, abs(arai-sunuke))
print(ans)


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

using namespace std;

typedef long long int llint;
typedef pair<int, int> pii;
typedef pair<llint, llint> pll;
typedef vector<int> vi;
typedef vector<llint> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define ci cin
#define co cout
#define en endl
#define ln cout<< '\n'
#define rep(i, n) for(int i = 0; i < n; i++)
#define outl(x) cout<< (x) << '\n'
#define pb push_back
#define fi first
#define se second
#define MOD 1000000007

template<typename Tn> Tn gcd(Tn a, Tn b)
{
    return (b ? gcd(b, a % b) : a);
}

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

string IntToString(int number)
{
    stringstream ss;
    ss << number;
    return ss.str();
}

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

int main()
{
    string heisei = "2019/04/30";
    string s;
    ci >> s;

    if(heisei < s) co << "TBD" << en;
    else co << "Heisei" << en;
    
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

 class Main{
    int ninzu,k;
	int ban;
	
    public void solve(){
        Scanner sc = new Scanner(System.in);
    
	     for(int i=0;i<4;i++){
		 	ban= sc.nextInt();
			if(ban==1){
				k = 6000;
				}else if(ban==2){
					k = 4000;
					}else if(ban==3){
						k = 3000;
					}else{
						k = 2000;
					}
					ninzu = sc.nextInt();
					int uriage = k*ninzu;
					System.out.println(uriage);
	     }
    }
    public static void main(String[] args){
        Main obj = new Main();
        obj.solve();
    }
}

Measured memory_bytes: 17236
#include<stdio.h>
int main(){
    int a,b,c;
    int flag5=0,flag7=0;
    scanf("%d %d %d",&a,&b,&c);
    if(a==5){
        flag5=flag5+1;
    }
    else if(a==7){
        flag7=flag7+1;
    }
    if(b==5){
        flag5=flag5+1;
    }
    else if(b==7){
        flag7=flag7+1;
    }
    if(c==5){
        flag5=flag5+1;
    }
    else if(c==7){
        flag7=flag7+1;
    }
    
    
    if(flag5==2 && flag7==1){
        printf("YES\n");
    }
    else{
        printf("NO\n");
    }
    return 0;
}

Measured memory_bytes: 128
from collections import deque


class Dinic:

    def __init__(self, N0, N1):
        self.N0 = N0
        self.N1 = N1
        self.N = N = 2+N0+N1
        self.G = [[] for i in range(N)]
        for i in range(N0):
            forward = [2+i, 1, None]
            forward[2] = backward = [0, 0, forward]
            self.G[0].append(forward)
            self.G[2+i].append(backward)
        self.backwards = bs = []
        for i in range(N1):
            forward = [1, 1, None]
            forward[2] = backward = [2+N0+i, 0, forward]
            bs.append(backward)
            self.G[2+N0+i].append(forward)
            self.G[1].append(backward)

    def add_edge(self, fr, to):
        #assert 0 <= fr < self.N0
        #assert 0 <= to < self.N1
        v0 = 2 + fr
        v1 = 2 + self.N0 + to
        forward = [v1, 1, None]
        forward[2] = backward = [v0, 0, forward]
        self.G[v0].append(forward)
        self.G[v1].append(backward)

    def bfs(self):
        G = self.G
        level = [None]*self.N
        deq = deque([0])
        level[0] = 0
        while deq:
            v = deq.popleft()
            lv = level[v] + 1
            for w, cap, _ in G[v]:
                if cap and level[w] is None:
                    level[w] = lv
                    deq.append(w)
        self.level = level
        return level[1] is not None

    def dfs(self, v, t):
        if v == t:
            return 1
        level = self.level
        for e in self.it[v]:
            w, cap, rev = e
            if cap and level[v] < level[w] and self.dfs(w, t):
                e[1] = 0
                rev[1] = 1
                return 1
        return 0

    def flow(self):
        flow = 0
        while self.bfs():
            *self.it, = map(iter, self.G)
            while self.dfs(0, 1):
                flow += 1
        return flow

    def matching(self):
        return [cap for _, cap, _ in self.backwards]

#####################################################################################

N = int(input())

X = []
Y = []
for i in range(N):
    X.append([int(i) for i in input().split()])

for i in range(N):
    Y.append([int(i) for i in input().split()])

dinic = Dinic(len(X), len(Y))

for i in range(len(X)):
    for j in range(N):
        if X[i][0] < Y[j][0] and X[i][1] < Y[j][1]:
            dinic.add_edge(i,j)


print(dinic.flow())

Measured memory_bytes: 74880
#include<iostream>
#include<string>
#include<cstring>
using namespace std;
int main()
{
	int w,h;
	while(cin>>h>>w,h) 
	{
		string f[h];
		for(int i = 0; i < h; ++i)
		{
			cin>>f[i];
		}

		bool used[h][w];
		memset(used,0,sizeof(used));

		int x=0,y=0;
		while(1) 
		{
			if(used[y][x])
			{
				cout<<"LOOP"<<endl;
				break;
			}
			if(f[y][x]=='.')
			{
				cout<<x<<" "<<y<<endl;
				break;
			}
			used[y][x]=true;

			if(f[y][x]=='>') x+=1;
			if(f[y][x]=='<') x-=1;
			if(f[y][x]=='^') y-=1;
			if(f[y][x]=='v') y+=1;
		}
	}
  return 0;
}

Measured memory_bytes: 1248
#include<bits/stdc++.h>
using namespace std;
int main() {
	int N; cin >> N;
	int A[N];
	pair<int, int> B[N];
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		B[i].first = A[i];
		B[i].second = i;
	}
	int maxn, minn;
	sort(B, B + N);
	maxn = B[N - 1].first;
	minn = B[0].first;
	int  add;
	if (abs(minn) <= abs(maxn)) add = B[N - 1].second;
	else add = B[0].second;
	add++;
	cout << 2 * N - 1 << endl;
	for (int i = 0; i < N; i++) {
		cout << add << " " << i + 1 << endl;
	}
	if(A[add-1]<0){
		for (int i =N; i>1; i--) {
			cout << i << " " << i-1 << endl;
		}
	}
	else {
		for (int i = 0; i < N - 1; i++) {
			cout << i + 1 << " " << i + 2 << endl;
		}
	}
	//  cout<<"/"<<add<<"/"<<endl;
}

Measured memory_bytes: 256