akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int X;
    cin >> X;
    if (X >= 30) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
    return 0;
}

Measured memory_bytes: 3636
#include <cstdio>
#include <deque>
using namespace std;
int len,ans;
char ch[200005];
deque<int>v;
int main(){
	scanf("%d%s",&len,ch);
	for(int i=0;i<len;++i){
		if(ch[i]=='R')v.push_back(i);
	}
	for(int i=0;i<len;++i){
		if(v.empty())break;
		if(v.front()<i)v.pop_front();
		if(v.empty())break;
		if(ch[i]=='W'){
			v.pop_back();
			++ans;
		}
		if(v.empty())break;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 4100
#include <iostream>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <set>
#include <cmath>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;
//const int MAX=;

int dsum(int n){
	if(n<10) return n;
	return dsum(n/10)+n%10;
}

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


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <map>

using namespace std;


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

    for(int i=0; i<S.size(); i++){
        cout << char('A'+(S[i]+N-'A')%26);
    }
    cout<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main(void) {

	int n, i, ans = 0;
	int A[21] = {0};
	int B[21] = {0};
	int C[21] = {0};

	//データ入手
	scanf("%d", &n);
	for(i = 0; i < n; i++)
		scanf("%d", &A[i]);
	for(i = 0; i < n; i++)
		scanf("%d", &B[i]);
	for(i = 0; i < n-1; i++)
		scanf("%d", &C[i]);

	//計算
	ans = B[A[0]-1];

	for(i = 1; i < n; i++){
		ans += B[A[i]-1];

		if((A[i]-1) == A[i-1]){
			ans += C[A[i]-2];
		}
	}

	printf("%d", ans);


	return EXIT_SUCCESS;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> per(n);
  vector<int> delta(n);
  for (int i = 0; i < n; ++i) {
    cin >> per[i];
    --per[i];
    delta[per[i]] = i;
  }

  const int L = n + 1;
  for (int i = 0; i < n; ++i) {
    cout << L * i + 1 << ' ';
  }
  cout << endl;
  for (int i = 0; i < n; ++i) {
    cout << L * (n - i) + delta[i] + 1 << ' ';
  }
  cout << endl;

  return 0;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
int main(){
  int s;
  cin>>s;
  set<int> st;
  while(st.count(s)==0){
    st.insert(s);
    if(s%2==0){
      s/=2;
    }else{
      s=s*3+1;
    }
  }
cout<<st.size()+1<<endl;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

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

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

	H, W := nextInt(), nextInt()
	board := make([]string, H)
	for i := 0; i < H; i++ {
		board[i] = next()
	}

	L, R, U, D := make([][]int, H), make([][]int, H), make([][]int, H), make([][]int, H)
	for i := 0; i < H; i++ {
		L[i], R[i], U[i], D[i] = make([]int, W), make([]int, W), make([]int, W), make([]int, W)
	}

	for i := 0; i < H; i++ {
		for j := 0; j < W; j++ {
			if board[i][j] != '#' {
				if j == 0 {
					L[i][j] = 1
				} else {
					L[i][j] = L[i][j-1] + 1
				}

				if i == 0 {
					U[i][j] = 1
				} else {
					U[i][j] = U[i-1][j] + 1
				}
			}

			if board[H-i-1][W-j-1] != '#' {
				if j == 0 {
					R[H-i-1][W-j-1] = 1
				} else {
					R[H-i-1][W-j-1] = R[H-i-1][W-j] + 1
				}

				if i == 0 {
					D[H-i-1][W-j-1] = 1
				} else {
					D[H-i-1][W-j-1] = D[H-i][W-j-1] + 1
				}
			}
		}
	}

	max := 0
	for i := 0; i < H; i++ {
		for j := 0; j < W; j++ {
			if board[i][j] == '#' {
				continue
			}

			l := L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3
			if max < l {
				max = l
			}
		}
	}

	fmt.Println(max)
}


Measured memory_bytes: 138240
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <iterator>
#include <numeric>
#include <cstdint>
#include <cmath>
#include <bitset>
#include <string>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>

#define N_TIMES(i, n)     for ( uint64_t i = 0;     i <  n; ++i )
#define N_TIMES_REV(i, n) for (  int64_t i = n - 1; i >= 0; --i )

uint64_t length_of_longest_decrease_subsequence(const std::vector<uint64_t> &A)
{
  const int64_t INF = static_cast<int64_t>(-1e+8);

  std::vector<int64_t> dp(A.size(), INF);

  for (uint64_t i = 0; i < A.size(); ++i) {
    auto itr = std::lower_bound(dp.begin(), dp.end(), A[i], std::greater_equal<int64_t>());
    uint64_t j = std::distance(dp.begin(), itr);
    dp[j] = A[i];
  }

  uint64_t counter = 0;
  for (; (counter < A.size()) && (dp[counter] != INF); ++counter);
  return counter;
}

using namespace std;

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

  vector<uint64_t> A(N);
  N_TIMES(n, N) { cin >> A[n]; }

  cout << length_of_longest_decrease_subsequence(A) << endl;

  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define REP(i, a, n) for (long long i = (a); i < (long long)(n); ++i)
#define REPC(i, a, n) for (long long i = (a); i <= (long long)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init) \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T>
using VEC = std::vector<T>;
template <class T>
using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail>
void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec) os << v << ",";
  os << "}";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, set<T> &s) {
  os << "{";
  for (auto p : s) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  int K, T;
  cin >> K >> T;
  VEC<int> A(T);
  priority_queue<int> B;
  REP(i, 0, T) {
    cin >> A[i];
    B.push(A[i]);
  }

  sort(ALL(A));
  while (B.size() >= 2) {
    int one = B.top();
    B.pop();
    int two = B.top();
    B.pop();
    one--;
    two--;
    if (one > 0) B.push(one);
    if (two > 0) B.push(two);
  }

  int ans = B.top()-1;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main(void) {

	int n;

	scanf("%d", &n);

	if (n%10 == 3) {
		printf("bon");
	}

	else if (n % 10 == 0 || n % 10 == 1 || n % 10 == 6 || n % 10 == 8) {
		printf("pon");
	}

	else {
		printf("hon");
	}

	return 0;
}

Measured memory_bytes: 1732
#include <iostream>

using namespace std;

int main()
{
    int syllables_1,syllables_2,syllables_3;
    cin >> syllables_1;
    cin >> syllables_2;
    cin >> syllables_3;
    if(syllables_1 == 5&&syllables_2 == 7&&syllables_3 == 5 ||
       syllables_1 == 5&&syllables_2 == 5&&syllables_3 == 7 ||
       syllables_1 == 7&&syllables_2 == 5&&syllables_3 == 5){
        cout << "YES" << endl;
       }else{
        cout << "NO" << endl;
       }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

#define IOS ios::sync_with_stdio(0);cin.tie(0);

int main(){
	IOS;
	long long a,b,c,d;
	while(cin>>a>>b>>c>>d){
		if((a+b) == (c+d)){
			cout<<"Balanced"<<endl;
		}
		else if((a+b) > (c+d)){
			cout<<"Left"<<endl;
		}
		else{
			cout<<"Right"<<endl;
		}
	}
	return 0;	
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int m;
  bool flag=0;
  while(n!=0)
  {
    m=n%10;
    if(m==7)
    {
      flag=1;
      break;
    }
    n=n/10;
  }
  if(flag==1)
  {
    cout<<"Yes";
  }
  else
  {
    cout<<"No";
  }
  return 0;
}

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

int main(){
  int N,x;
  cin>>N>>x;
  if(x==1||x==2*N-1)cout<<"No"<<endl;
  else{
    if(N==2)cout<<"Yes"<<endl<<1<<endl<<2<<endl<<3<<endl;
    else{
      vector<int> v(2*N-1);
      if(x==2*N-2){
        v[N-3]=x-2;
        v[N-2]=x+1;
        v[N-1]=x;
        v[N]=x-1;
        int j=1;
        if(j==x-2)j+=4;
        for(int i=0;i<2*N-1;i++){
          if(i<N-3||i>N){
            v[i]=j;
            j++;
            if(j==x-2)j+=4;
          }
        }
      }
      else{
        v[N-3]=x+2;
        v[N-2]=x-1;
        v[N-1]=x;
        v[N]=x+1;
        int j=1;
        if(j==x-1)j+=4;
        for(int i=0;i<2*N-1;i++){
          if(i<N-3||i>N){
            v[i]=j;
            j++;
            if(j==x-1)j+=4;
          }
        }
      }
      cout<<"Yes"<<endl;
      for(int i=0;i<2*N-1;i++)cout<<v[i]<<endl;
    }
  }
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
#include <algorithm>
#include <string>
#include<iostream>
using namespace std;
typedef long long ll;
ll a[1000005],s[1000005];
int main()
{
    ll b,c,ma=1231231231,ans=0,n;
    cin>>n;
    for(ll i=1;i<=n;i++)
    {
        scanf("%lld",&a[i]);
        s[i]=s[i-1]+a[i];
    }
    for(ll i=1;i<=n;i++)
    {
        ans+=(a[i]*((s[n]-s[i])%1000000007));
        ans%=1000000007;
    }
    printf("%lld\n",ans);

}


Measured memory_bytes: 6852
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H, W;
  cin >> H >> W;
  
  vector<vector<char>> vec(H, vector<char>(W));
  for (int i = 0; i < H; i++){
    for (int j = 0; j < W; j++){
      cin >> vec.at(i).at(j);
    }
  }
  
  vector<bool> row(H, false);
  vector<bool> col(W, false);
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (vec.at(i).at(j) == '#') {
        row.at(i) = true;
        col.at(j) = true;
      }
    }
  }
  
  for (int i = 0; i < H; i++) {
    if (row.at(i)) {
      for (int j = 0; j < W; j++) {
        if (col.at(j)) {
          cout << vec.at(i).at(j);
        }
      }
      cout << endl;
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
  int sum = 0,N,p, max = 0;
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> p;
    sum += p;
    if (max < p) max = p;
  }
  cout << sum - max / 2 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <math.h>
#define MAX 1000
int n,m;
char  a[51][51],c[MAX];
int pos[MAX][2];
int main()
{
    while(scanf("%d%d",&n,&m)&&(m||n))
    {
        for(int i=0; i<n; i++)
        {
            getchar();
            for(int j=0; j<m; j++)
                scanf("%c",&a[i][j]);
        }
        getchar();
       scanf("%s",c);
        int len=strlen(c);
        for(int i=0; i<len; i++)
        {
            for(int j=0; j<n; j++)
                for(int k=0; k<m; k++)
                    if(a[j][k]==c[i])
                    {
                        pos[i][0]=j;
                        pos[i][1]=k;
                        break;
                    }
        }
        int sum=pos[0][0]+pos[0][1];
        for(int i=1; i<len; i++)
            sum+=fabs(pos[i][0]-pos[i-1][0])+fabs(pos[i][1]-pos[i-1][1]);
            printf("%d\n",sum+len);
        }
         return 0;
}




Measured memory_bytes: 2620
#include<math.h>
#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)

class Point
{
    public:
    double x, y;

    Point(double x = 0, double y = 0): x(x), y(y) {}

    Point operator + (Point p) {return Point(x + p.x, y + p.y); }
    Point operator - (Point p) {return Point(x - p.x, y - p.y); }
    Point operator * (double a) {return Point(x * a, y * a);}
    Point operator / (double a) {return Point(x / a, y / a);}

    double abs() {return sqrt(norm());}
    double norm() {return x * x + y * y;}
    
    bool operator < (const Point &p) const {
        return x != p.x ? x < p.x : y < p.y;
    }

    bool operator == (const Point &p) const{
        return equals(x, p.x) && equals(y, p.y);
    }
};typedef Point Vector;

struct Segment {
    Point p1, p2;
};

double dot(Vector a, Vector b){
    return a.x * b.x + a.y * b.y;
}

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

bool isOrthogonal(Vector a, Vector b){
    return equals(dot(a, b), 0.0);
}

bool isOrthogonal(Point a1, Point a2, Point b1, Point b2){
    return isOrthogonal(a1 - a2, b1 - b2);
}

bool isParallel(Vector a, Vector b){
    return equals(cross(a, b), 0.0);
}

bool isParallel(Point a1, Point a2, Point b1, Point b2){
    return isParallel(a1 - a2, b1 - b2);
}
#include<iostream>
#include<iomanip>
using namespace std;
Point projection(Segment s, Point p){
    Vector base = s.p2 - s.p1;
    double r = dot(p-s.p1, base) / base.norm();
    return s.p1 + base * r;
}
Point reflect(Segment s, Point p){
    return p + (projection(s, p) - p) * 2.0;
}
int main(){
    int x1, y1, x2, y2, q;
    cin >> x1 >> y1 >> x2 >> y2 >> q;
    Point p1 = Point(x1, y1), p2 = Point(x2, y2);
    Segment s;
    s.p1 = p1; s.p2 = p2;
    for (int i = 0; i < q; i++)
    {
        int x, y;
        cin >> x >> y;
        Point p3;
        p3.x = x; p3.y = y;
        Point p = reflect(s, p3);
        cout << fixed << setprecision(10) << p.x<< " " << p.y << endl;
    }
    
}


Measured memory_bytes: 3296
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr=input.trim().split("\n");
while(true){
   var abc=arr.shift();
   if(abc=="0 0 0 0 0")break;
   var ary=(abc+" "+arr.shift()).split(" ").map(Number);
   (function(a,b,c,d,e,na,nb,nc){
      var A,B;
      var amari=nc%d;
      A=na*a+nb*b+Math.floor(nc/d)*d*e+amari*c;
      if(nc>=d)B=na*a+nb*b+nc*e;
      else{
         var husoku=d-amari;
         while(husoku--){
            if(nb>0)nb--;
            else if(na>0)na--;
         }
         B=na*a+nb*b+d*e;
      }
      console.log(Math.min(A,B));
   }).apply(null,ary);
}

Measured memory_bytes: 17200
#define scanf_s scanf
//#define gets_s gets
#include <stdio.h>
#include <string>
#include <iostream>
#include <math.h>
using namespace std;
#define MAX 10
#define MIN -100001
#define _MAX 10
int main(void)
{
	int x, n[MAX] = { 1,2,4,8,16,32,64,128,256,512 }, cou = 0, m[MAX];
	while (scanf_s("%d", &x) != EOF) {
		for (int i = MAX - 1; i >= 0; --i) {
			if (x >= n[i]) {
				x -= n[i];
				m[cou] = n[i]; ++cou;
			}
		}
		for (int i = cou - 1; i >= 0; --i) {
			if (i != cou - 1) printf(" ");
			printf("%d", m[i]);
		}
		printf("\n");
		cou = 0;
	}
}	

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

using namespace std;

int main()
{
    int n;
    cin>>n;
    string s;
    int arr[4]={0};
    for (int i=0;i<n;i++){
        cin>>s;
        if (s=="AC")
            arr[0]++;
        else if (s=="WA")
            arr[1]++;
        else if (s=="TLE")
            arr[2]++;
        else
            arr[3]++;
    }
    cout<<"AC x "<<arr[0]<<"\n";
    cout<<"WA x "<<arr[1]<<"\n";
    cout<<"TLE x "<<arr[2]<<"\n";
    cout<<"RE x "<<arr[3];

    return 0;
}


Measured memory_bytes: 3612
import math

a, b, h, m = map(int, input().split())

hmove = 360 / 12 * h + 360 / 12 / 60 * m
mmove = 360 / 60 * m

# radianを求める
rad = math.radians(abs(hmove - mmove))

# 余弦定理 a^2 = b^2 + c^2 -2*b*c*cosA
print(math.sqrt(a**2 + b**2 - 2*a*b*math.cos(rad)))


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

int main() {
	int n, m, x;
	cin >> n >> m >> x;
	int c[13];
	int a[13][13];
	for (int i = 0; i < n; i++) {
		cin >> c[i];
		for (int j = 0; j < m; j++) {
			cin >> a[i][j];
		}
	}
	int min = 1000000000;
	for (int i = 1; i <= pow(2, n); i++) {
		int t[13] = {0};
		int sum[13] = {0};
		int y = 0;
		for (int j = 0; j < n; j++) t[j] = (i>>j) & 1;
		for (int j = 0; j < n; j++) if (t[j]) y += c[j];
		for (int j = 0; j < n; j++) {
			if (t[j]) for (int l = 0; l < m; l++) sum[l] += a[j][l];
		}
		int flag = 1;
		for (int l = 0; l < m; l++) if (sum[l] < x) flag = 0;
		if (flag == 1 && y < min) min = y;
	}
	if (min == 1000000000) cout << -1 << endl;
	else cout << min << endl;
	return 0;
}

Measured memory_bytes: 4064
use std::io::{Read, stdin};
use std::str::FromStr;

fn main() {
    let k: i64 = read();
    let s: i64 = read();
    let mut ans: i64 = 0;
    for i in 0..(k+1) {
        for j in 0..(k+1) {
            if 0 <=s - (i + j) && s - (i + j) <= k{
                ans += 1;
            }
        }
    }
    println!("{}", ans);
}


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")
}

Measured memory_bytes: 4352
import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
sys.setrecursionlimit(10**7)

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())

# b,r = map(str, readline().split())
# A,B = map(int, readline().split())
br = LS()
AB = LI()
U = _S()

def main():
    brAB = zip(br, AB)
    tmp=[]
    for c,n in brAB:
        if c==U:
            tmp.append(n - 1)
        else:
            tmp.append(n)
    return str(tmp[0])+' '+str(tmp[1])
print(main())


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


#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define pii pair<int,int>
#define pli pair<long long,int>
#define pil pair<int,long long>
#define ll long long
#define el '\n'

using namespace std;

const int N = 2e5 + 10;

int n, k;
int ar[N];

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

    cin >> n >> k;
    for (int i=1;i<=n;i++){
        cin >> ar[i];
    }
    for (int i=1;i<=k;i++){
        int ton[n + 2];
        fill(ton, ton + n + 2, 0);

        for (int j=1;j<=n;j++){
            int l = max(1, j - ar[j]);
            int r = min(n, j + ar[j]);
            ton[l]++;
            ton[r + 1]--;
        }
        int cur = 0;
        int cnt = 0;
        for (int i=1;i<=n;i++){
            cur += ton[i];
            ar[i] = cur;
            if (cur == n) cnt++;
        }
        if (cnt == n) break;
    }
    for (int i=1;i<=n;i++){
        cout << ar[i] << " ";
    }
    cout << el;

    return 0;
}

Measured memory_bytes: 5128
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    while (scanf("%d",&n)!=EOF)
    {
        int i,j,k,l,cnt=0;
        for (i=0;i<=9;i++)
            for (j=0;j<=9;j++)
                for (k=0;k<=9;k++)
                    for (l=0;l<=9;l++)
                    {
                        if (i+j+k+l==n)
                        cnt++;
                    }
    cout<<cnt<<endl;

    }
}


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

int main(){
	int a , b , c , d;
	int l1=0,l2=0,l=0 ;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	if(a>=c)
	l1=a;
	else 
	l1=c;
    if(b<=d)
	l2=b;
	else
	l2=d;
	l=l2-l1;
	if(l<=0)
	printf("0");
	else
	printf("%d",l);
	
}

Measured memory_bytes: 256
N, K = map(int, input().split())
X = list(map(int, input().split()))
if N == 1:
    ans = abs(X[0])
else:
    tmp = 0
    ans = 10**9
    for left in range (N-K+1):
        right = left + K - 1
        if X[right] <= 0:
            tmp = 0 - X[left]
        elif X[left] >= 0:
            tmp = X[right]
        else:
            tmp = min(X[right] - 2 * X[left], 2 * X[right] - X[left])
        ans = min(tmp, ans)
print(ans)


Measured memory_bytes: 14384
//add(i, x) := a[i] に x を加算する
//getSum(s,t): [s, t) の合計値を出力する
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int sqrtN = 512;

struct SqrtDecomposition{
    int N, K;
    vector<int> data;
    vector<int> bucketSum;
    SqrtDecomposition(int n) : N(n){

        //切り上げ(K := バケット数, sqrtN := バケットサイズ)
        K = (N + sqrtN - 1) / sqrtN;
        data.assign(K * sqrtN, 0);
        bucketSum.assign(K, 0);
    }

    void add(int x, int y){
        int k = x / sqrtN;
        data[x] += y;
        int sum = 0;
        for (int i = k * sqrtN; i < (k + 1) * sqrtN; ++i) {
            sum += data[i];
        }
        bucketSum[k] = sum;
    }

    //[x, y)
    int getSum(int x, int y){
        
        int sum = 0;
        
        for(int k = 0; k < K; k++){
            
            int l = k * sqrtN;
            int r = (k + 1) * sqrtN;
            if(r <= x || y <= l) continue;

            if(x <= l && r <= y) sum += bucketSum[k];
            else{
                for(int i = max(x, l); i < min(y, r); i++){
                    sum += data[i];
                }
            }
        }

        return sum;
    }

    void debug(){
        for(int i = 0; i < N; i++){
            cout << data[i] << " ";
        }
        cout << endl;
        for(int i = 0; i < N; i++){
            if(i % sqrtN == 0) cout << bucketSum[i] << " ";
            else cout << "  "; 
        }
        cout << endl;
    }
};


signed main(){

    int N, Q; cin >> N >> Q;
    SqrtDecomposition decomp(N);
    while(Q--){
        int c, x, y; cin >> c >> x >> y;
        if(c == 0) decomp.add(x, y);
        else cout << decomp.getSum(x, y + 1) << endl;
        
        //decomp.debug();
    }

    return 0;
}



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

int main() {
  int n,k;
  cin >> n >> k;
  vector<int> d(n);
  rep(i,n) cin >>d[i];
  sort(d.begin(),d.end());
  int ans = 0;
  rep(i,k)  ans += d[i];
  cout << ans << endl;
}


Measured memory_bytes: 3632
// Package main provides
//
// File:  a.go
// Author: ymiyamoto
//
// Created on Sat Jan  5 16:16:00 2019
//
package main

import (
	"fmt"
	"sort"
)

func min(slice ...int) int {
	sort.Ints(slice)
	return slice[0]
}

func main() {
	var N, A, B int
	fmt.Scan(&N, &A, &B)

	fmt.Println(min(N*A, B))
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin >> n >> m;
  vector<string>a(n);
  vector<string>b(m);
  int i,j,k,l;
  for(i=0;i<n;i++){
    cin >> a[i];
  }
  for(i=0;i<m;i++){
    cin >> b[i];
  }
  int anss = 0;
  int chk = 0;

  for(i=0;i<=n-m;i++){
    for(j=0;j<=n-m;j++){
      if(a[i][j]==b[0][0]){
        chk = 1;
        for(k=0;k<m;k++){
          for(l=0;l<m;l++){
            if(a[i+k][j+l]!=b[k][l])chk=0;
          }
        }
        if(chk==1)anss = 1;
      }
    }
  }
  if(anss==1)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#define int long long
#define uint unsigned long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
using namespace std;

signed main()
{
	int X;
	cin >> X;

	int cnt = 0;
	int a = 0;
	for (int i = 1; i <= X; i++)
	{
		a += i;
		cnt++;
		if (a >= X)
		{
			break;
		}
	}
	
	cout << cnt << endl;
}


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

using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define ALL(c) (c).begin(), (c).end()
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;}
const int MOD = 1000000007;
const int INF = 1000000001;
const char EOL = '\n';

void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
    return 0;
}

void solve() {
    int n;
    cin >> n;
    vector<vector<ll>> a(n, vector<ll>(n));
    REP(i, n) REP(j, n) cin >> a[i][j];
    vector<ll> sum(1 << n, 0);
    REP(k, 1 << n) REP(i, n) FOR(j, i + 1, n) {
        if ((k & (1 << i)) && (k & (1 << j))) sum[k] += a[i][j];
    }

    vector<ll> dp(1 << n, 0);

    REP(i, 1 << n) {
        for (int j = i; j > 0; j = (j - 1) & i) {
            chmax(dp[i], dp[i - j] + sum[j]);
        }
    }

    cout << dp[(1 << n) - 1] << EOL;

}



Measured memory_bytes: 1280
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <deque>
#include <ctime>

using namespace std;

#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define mp make_pair
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))


typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;
const double PI = acos(-1);

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

int main(){

    int n,k;
    cin >> n;
    cin >> k;

    int x, y;
    cin >> x;
    cin >> y;

    int sum=0;

    for(int i=1; i<=n; i++){
        if(i <= k) sum += x;
        else sum += y;
    }

    cout << sum << endl;


}

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

int main()
{
    string s, t;
    cin >>s >> t;
    
    int cnt = 0;
    rep(i, 0, 3)
        if (s[i] == t[i]) ++cnt;

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,a,b,x,ans=0;
	cin>>n>>a>>b;
	for(int i=1;i<=n;i++)
	{
		cin>>x;
		if(x<a||x>=b)
		    ans++;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false);cin.tie(NULL)
using namespace std;
#define int long long
#define MOD 1000000007
typedef vector<int> vi;
typedef pair<int,int> pi;
#define inf 1e18
#define For(i,a,b) for (int i = a; i < b; i++)
#define Rep(i,a,b) for (int i = a; i <= b; i++)
#define ps(x,y) fixed << setprecision(y) << x 
#define pb push_back 
#define mp make_pair 
 
int32_t main()
{
    fast;
    int n; cin >> n;
    int ans = 1, hi = 0;
    Rep(i, 1, n) {
        int x = i;
        int count = 0;
    
        while (x % 2 == 0) {
            count++;
            x /= 2;
        }
    
        if(count > hi) {
            hi = count;
            ans = i;
        }
    }
    cout << ans;


    return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <map>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> pairs;

#define MOD 998244353


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

bool primeNumber(ll n){
    if(n < 2) return false;
    else{
        for(ll i = 2; i * i <= n; i++){
            if(n % i == 0) return false;
        }
        return true;
    }
}


int main(){
    vector<ll> w(3);
    for(ll i = 0; i<3; i++){
        cin>>w[i];
    }
    sort(w.begin(),w.end());
    cout<<w[0]<<" "<<w[1]<<" "<<w[2]<<endl;
    return 0;
}
 
    
    



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

int main()
{ 
  int w, a, b ; 
  cin >> w >> a >> b ;

  if(a < b)
  {
    if(b <= a + w)
    {
      cout << 0 << endl ;
    }
    else
    {
      cout << b - (a + w) << endl ;
    }
  }
  else if(a > b)
  {
    if(a <= b + w)
    {
      cout << 0 << endl ;
    }
    else 
    {
      cout << a - (b + w) << endl ;
    }
  }
  else
  {
    cout << 0 << endl ;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>

using namespace std;


const long long  MAX = 200000;
int main() {
   

    queue <pair<string,long>> qu;
    long n,q;
    cin >> n >> q;
    for (int i=0;i<n;i++){
        string s;
        long p;
        cin >> s >> p;
        qu.push(make_pair(s,p));
    }

    pair <string, long> u;
    int elaps = 0;
    int a;

    while (!qu.empty()){
        u = qu.front();
        qu.pop();
        a = min(u.second, q);
        u.second -= a;
        elaps += a;
        if(u.second > 0){
            qu.push(u);
        }else{
            cout << u.first << " " << elaps << endl;
        }
    }



}


Measured memory_bytes: 6200
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1001001001
#define LINF 1001001001001001001
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;
typedef long long ll;

int main() {

    int N;
    cin >> N;
    ll ans = 1;
    vector<ll> A(N);
    rep(i,N) {
        cin >> A[i];
        if (A[i] == 0) {
            cout << 0 << endl;
            return 0;
        }
    }

    rep(i,N) {
        if (A[i] > (1000000000000000000 + ans - 1) / ans) {
            cout << -1 << endl;
            return 0;
        } else {
            ans *= A[i];
            if (ans > 1000000000000000000) {
                cout << -1 << endl;
                return 0;
            }
        }
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 3996
#include<iostream>
#include<vector>
#include<sstream>
#include<string>
#include<iomanip>
using namespace std;

long comb(int n, int r);


int main() {
  int N;
  cin >> N;
  int point[N];
  int sum=0;
  int check;
  int sum_sub=0;
  for(int i=0;i<N;i++){
    cin >> point[i];
    sum += point[i];
  }

  if(sum%10!=0){
    cout << sum << endl;
    return 0;
  }
  else{
    for(int i=0;i<N;i++){
      check = sum-point[i];
      if(check%10!=0 && sum_sub < check){
        sum_sub = check;
      }
    }
    cout << sum_sub << endl;
    return 0;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <sstream>

using namespace std;

int main(void){
	string str;
	int times[10];
	int n;
	
	cin >> n;
	for(int k=0;k<n;k++){
		
		cin >> str;
		string maxi, mini;
		memset(times, 0, sizeof(times));
		for(int i=0;i<str.size();i++){
			times[str[i] - '0']++;
		}
		
		for(int i=0;i<=9;i++){
			for(int j=0;j<times[i];j++){
				mini += i + '0';
			}
			for(int j=0;j<times[9-i];j++){
				maxi += (9-i) + '0';
		 	}
		}
		istringstream issmin(mini), issmax(maxi);
		int intmin, intmax;
		issmin >> intmin;
		issmax >> intmax;
		cout << intmax - intmin<< endl;
	}
}

Measured memory_bytes: 0
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: usize
    }
    let ans = n * (n + 1) / 2 + n / 15 * (n / 15 + 1) / 2 * 15 - n / 3 * (n / 3 + 1) / 2 * 3 - n / 5 * (n / 5 + 1) / 2 * 5;
    println!("{}", ans);
}


Measured memory_bytes: 2116
#include<bits/stdc++.h>
#include<time.h>
#include<stdlib.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse4")
#define pb push_back
#define mp make_pair
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define pll pair<ll,ll>
#define vll vector<ll,ll>
#define all(a) (a).begin(),(a).end()
#define ff first
#define ss second
#define sz(x) (ll)x.size()
#define hell 1000000007
#define repf(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>b;i--)
#define lbnd lower_bound
#define ubnd upper_bound
#define bs binary_search
#define gcd(a,b) __gcd((a),(b))
#define EPS 1e-12
#define lcm(a,b) ((a)*(b))/__gcd((a),(b))
#define sqrt sqrtl
#define cbrt cbrtl
using namespace std;
ll n,q;
vector<ll> adj[200005];
ll val[200005],cnt[200005];
void dfs(ll u,ll p,ll sum)
{
	val[u]=cnt[u]+sum;
	sum+=cnt[u];
	ll i;
	for(i=0;i<adj[u].size();i++)
	{
		ll x=adj[u][i];
		if(x==p)continue;
		dfs(x,u,sum);
	}
}
int main()
{
  IOS
  cin>>n>>q;
  ll i,u,v;
  for(i=1;i<n;i++)
  {
  	 cin>>u>>v;
  	 adj[u].pb(v);
  	 adj[v].pb(u);
  }
  while(q--)
  {
  	 ll x,p;
  	 cin>>x>>p;
  	 cnt[x]+=p;
  }
  dfs(1,-1,0);
  for(i=1;i<=n;i++)
  	cout<<val[i]<<" ";
  return 0;
}                   

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

int main() {
	int N;
	int t[110000], x[110000], y[110000];
	cin >> N;
	t[0] = x[0] = y[0] = 0;
	for (int i = 0; i < N; ++i) cin >> t[i + 1] >> x[i + 1] >> y[i + 1];

	bool can = true;
	for (int i = 0; i < N; ++i) {
		int dt = t[i + 1] - t[i];
		int dist = abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i]);
		if (dt < dist) can = false;
		if (dist % 2 != dt % 2) can = false;
	}

	if (can) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 1408
import java.util.*;
import java.math.*;
public class Main{
  public static void main(String []args){
 
	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();
    }
    int dp[]=new int[n];
    if(n==1){
        System.out.println("0");
        return;
    }
    dp[0]=0;
    dp[1]=Math.abs(a[1]-a[0]);
    for(int i=2;i<n;i++){
    dp[i]=Math.min(dp[i-1]+Math.abs(a[i]-a[i-1]),dp[i-2]+Math.abs(a[i]-a[i-2]));
    
    }
  System.out.println(dp[n-1]);
  
  }
}

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

int h,w;
char a;
bool x[101], y[101];
map<pair<int,int>, char> arr;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin>>h>>w;
	memset(x, true, h+1);
	memset(y, true, w+1);

	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			cin>>a;
			arr[make_pair(i,j)]=a;
			if(a=='#'){
				x[i]=false;
				y[j]=false;
			}
		}
	}

	for(int i=1;i<=w;i++){
		if(y[i]){
			for(int j=1;j<=h;j++){
				arr[make_pair(j,i)]='x';
			}
		}
	}

	for(int i=1;i<=h;i++){
		if(x[i]){
			for(int j=1;j<=w;j++){
				arr[make_pair(i,j)]='x';
			}
		}
	}

	bool enter=false;
	for(int i=1;i<=h;i++){
		enter=false;
		for(int j=1;j<=w;j++){
			if(arr[make_pair(i,j)]!='x'){
				cout<<arr[make_pair(i,j)];
				enter=true;
			}
		}
		if(enter)
			cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 896
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#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 fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef long long ll;
const ll MOD = 1e9 + 7 ;
ll INF=1e9+10;
ll a,b;
char h[1010][1010];
ll dp[1010][1010];
ll dfs(ll x,ll y){
	if(x>=a||y>=b||h[x][y]=='#')return 0;
	if(x==a-1&&y==b-1)return 1;
	if(dp[x][y]!=-1)return dp[x][y];
	ll ans = ( ( dfs(x+1 ,y ) ) % MOD + ( dfs(x,y+1) % MOD ) ) % MOD;
	return dp[x][y]= ( ans % MOD );
}
int main(){
	fastio;
	cin>>a>>b;
	for(int i=0;i<a;i++){
		for(int j=0;j<b;j++){
			cin>>h[i][j];
		}
	}
	// debug() <<imie(mp);
	memset(dp,-1,sizeof dp);
	
	cout<<dfs(0,0)<<endl;
}

Measured memory_bytes: 9344
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define dbg(x) cerr << #x << ": " << x << endl
int main() {
  int D;
  cin >> D;
  string ans;
  if(D == 25)
    ans = "Christmas";
  else if(D == 24)
    ans = "Christmas Eve";
  else if(D == 23)
    ans = "Christmas Eve Eve";
  else
    ans = "Christmas Eve Eve Eve";
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
const int N = 500 * 1000 + 17;
const int MOD = 1000 * 1000 * 1000 + 7;

int n;
string s;

bool read() {
    if (!(cin >> s))
        return false;

    return true;
}

void solve() {
    n = s.size();
    string prev = "";
    auto ans = 0;

    for (int i = 0; i < n; )
        for (int len = 1; ; ++len)
            if (i + len > n || s.substr(i, len) != prev) {
                if (i + len > n) {
                    i += len;
                    break;
                }

                ++ans;
                prev = s.substr(i, len);
                i += len;
                break;
            }

    cout << ans << endl;
}
 
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    while (read())
        solve();
 
    return 0;
}
 


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

int main()
{
    ll n, m, k;
    cin >> n >> m >> k;

    ll *a = new ll[n];
    ll *b = new ll[m];
    rep(i, 0, n - 1) { cin >> a[i]; }
    rep(i, 0, m - 1) { cin >> b[i]; }

    ll as = 0;
    ll bs = 0;
    ll bp = 0;
    ll ans = 0;
    rep(i, 0, n - 1) { as += a[i]; }
    repr(i, n, 0)
    {
        if (i < n)
        {
            as -= a[i];
        }
        //as -= a[i];
        if (as <= k)
        {
            while (bp < m && (as + bs + b[bp] <= k))
            {
                bs += b[bp];
                bp++;
            }
            ans = max(ans, bp + i);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 6724
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef pair<ll, ll> P;

const ll mod =  1000000007;  //出力は (ans % mod + mod) % mod  (負の剰余を正にする)
const int inf = 1e9;
const long long INF = 1LL << 60;   // INF = 1152921504606846976

int n;
const int V_MAX = 205;
ll d[V_MAX][V_MAX];

void warshall_floyd(){
    for(int k = 0; k < n; k++){
        for(int i = 0; i < n; i++){
            if(d[i][k] == INF) continue;
            for(int j = 0; j < n; j++){
                if(d[k][j] == INF) continue;
                d[i][j] = min(d[i][j],d[i][k] + d[k][j]);
            }
        }
    }
}

int main()
{
    int m,k; cin >> n >> m >> k;
    vector<int> r(k);
    rep(i,k){
        cin >> r[i];
        r[i]--;
    }
    sort(all(r));
    rep(i,n) rep(j,n){
        if(i == j) d[i][i] = 0;
        else d[i][j] = INF;
    }
    rep(i,m){
        int a,b,c; cin >> a >> b >> c;
        a--; b--;
        d[a][b] = c;
        d[b][a] = c;
    }
    warshall_floyd();
    ll ans = INF;
    do{
        ll tmp = 0;
        rep(i,k-1){
            tmp += d[r[i]][r[i+1]];
        }
        ans = min(ans,tmp);
    }while(next_permutation(all(r)));
    cout << ans << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define int long  long 
#define ar array

using namespace std ;
                                                                                              
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL) ;

	int n  ;
	cin >> n ; 
	int ans = 0 ; 
	for(int i =1 ; i <= n ; ++i)
	{
		for(int j =1 ; j <= n ; ++j)
		{
			for(int k =1 ; k <= n ; ++k)
			{
				int g = __gcd(__gcd(i,j) , k) ; 
				ans += g ; 
			}
		}

	}
	cout << ans ;
}








Measured memory_bytes: 3600
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        x: i32,
        y: i32,
    }

    for i in 0..=x {
        let j = x - i;
        if i * 2 + j * 4 == y {
            println!("Yes");
            return;
        }
    }
    println!("No");
}


Measured memory_bytes: 2148
object Main extends App {
  import collection.mutable.ArrayBuffer

  case class Card(c: String, n: Int, index: Int) extends Ordered[Card]{
    override def compare(that: Card): Int = this.n - that.n
    override def toString: String = this.c + " " + this.n
  }
  def toCard(x: (String, Int)): Card = Card(x._1.substring(0,1), x._1.substring(2).toInt, x._2)

  val n = io.StdIn.readLine().toInt
  val buf: ArrayBuffer[Card] = ArrayBuffer.empty[Card]
  for (i <- 1 to n) {val x = (io.StdIn.readLine(), i); buf += toCard(x)}
  val arr: Array[Card] = buf.toArray

  def partition(a: Array[Card], pv: Int, r:Int): Int = {
    var p: Int = pv

    for(i <- p until r) {
      val (ai, ap, ar) = (a(i), a(p), a(r))
      if (i == p) {if (ai <= ar) p += 1}
      else {if (ai <= ar && ai < ap) {a(i) = ap; a(p) = ai; p += 1}}
    }
    val ap = a(p)
    a(p) = a(r); a(r) = ap
    p
  }

  def qsort(a: Array[Card], p: Int, r: Int): Unit =
    if (p < r) {
      val q: Int = partition(a, p, r)
      qsort(a, p, q-1)
      qsort(a, q+1, r)
    }

  qsort(arr, 0, n-1)
  val sb: StringBuilder = new StringBuilder
  var flag: Boolean = true
  sb ++= arr(0).toString + "\n"
  for (i <- 1 until n) {
    if (arr(i-1).n == arr(i).n && arr(i-1).index > arr(i).index) flag = false
    sb ++= arr(i).toString + "\n"
  }

  println(if (flag) "Stable" else "Not stable")
  print(sb.toString())
}

Measured memory_bytes: 135612
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()

ll gcd(ll a,ll b){
    if(b>a) 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;
}
ll rep_jijo(ll n,ll x){
    if(x==0) return 1;
    if(x%2==0){
        ll t=rep_jijo(n,x/2);
        return t*t;
    }
    return n*rep_jijo(n,x-1);
}

int main(){
    string s;
    cin >> s;
    string k="keyence";
    int len = s.size();
    int rm=len-7;
    rep(i,7){
        string t =s;
        t.erase(i,rm);
        if(k==t){
            cout << "YES" <<endl;
            return 0;
        }
    }
    cout << "NO" <<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>
#include <bitset>
#include <sstream>
#include <cassert>
#include <time.h>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}
void printvec (vec &v) {
    Rep (i, (ll)v.size()) {
        cout << v[i] << " \n"[i+1 == (ll)v.size()];
    }
}

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

    ll N, Q;
    cin >> N >> Q;

    ll ans = (N-2) * (N-2);
    set<pair<ll, ll>> r, c;
    r.insert({0, N-1});
    c.insert({0, N-1});

    while (Q--) {
        ll q, x;
        cin >> q >> x;
        q--; x--;
        if (q) {
            // put left (Query 2)
            auto p = c.lower_bound({x, inf});
            p--;
            ll cnt = (*p).second;
            ans -= cnt - 1;
            auto itr = r.begin();
            ll a = (*itr).first, b = (*itr).second;
            if (b > x) {
                r.erase(itr);
                r.insert({0, x});
                r.insert({cnt+1, b});
            }
        } else {
            // put up (Query 1)
            auto p = r.lower_bound({x, inf});
            p--;
            // cout << "query 1 " << (*p).first << " " << (*p).second << "\n";
            ll cnt = (*p).second;
            ans -= cnt - 1;
            auto itr = c.begin();
            ll a = (*itr).first, b = (*itr).second;
            if (b > x) {
                c.erase(itr);
                c.insert({0, x});
                c.insert({cnt+1, b});
            }

        }
        // cout << ans << endl;
    }

    cout << ans << endl;
}

Measured memory_bytes: 15980
#include<stdio.h>
int main(){
	char str[21];
	int i,j;
	scanf("%s",str);
	
	for(i = 0; str[i] != '\0'; i++){
	}
	
	for(j = i-1; j > -1; j--){
		printf("%c",str[j]);
	}
	
	puts("");
	
	return 0;
}

Measured memory_bytes: 0