akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <algorithm>
#include <unordered_map>

#define rep(i, a, b) for (ll i = a; i < b; i++)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef unordered_map<string, ll> u_map;

// input
void input() {}
template <class Head, class... Tail>
void input(Head &&a, Tail &&... b)
{
    cin >> a;
    input(forward<Tail>(b)...);
}

template <class V>
void input(vector<V> &v)
{
    for_each(v.begin(), v.end(), [](auto &i) { input(i); });
}

// output
template <class V>
void output(vector<V> &v)
{
    for_each(v.begin(), v.end(), [](auto &x) { cout << x << " "; });
    cout << endl;
}

// math functions
ll mpow(ll a, ll n, ll p)
{
    ll x = 1;
    while (n > 0)
    {
        if (n & 1)
        {
            x = a * x % p;
        }
        a = a * a % p;
        n >>= 1;
    }

    return x;
}

ll mfact(ll n, ll p)
{
    ll res = 1;
    for (ll i = 2; i <= n; i++)
    {
        res = res * i % p;
    }
    return res;
}

ll mcomb(ll n, ll r, ll p)
{
    if (n == 0 && r == 0)
    {
        return 1;
    }
    if (n < r || n < 0 || r < 0)
    {
        return 0;
    }

    ll a = mfact(n, p);
    ll b = mfact(n - r, p);
    ll c = mfact(r, p);
    return (((a * mpow(b, p - 2, p)) % p) * mpow(c, p - 2, p)) % p;
}

ll gcd(ll a, ll b)
{
    if (a < b)
    {
        a ^= b;
        b ^= a;
        a ^= b;
    }
    return b ? gcd(b, a % b) : a;
}

ll lcm(ll a, ll b)
{
    return a * b / gcd(a, b);
}

int main()
{
    ll a, b;
    input(a, b);

    if (a < b)
    {
        rep(i, 0, b)
        {
            cout << a;
        }
    }
    else
    {
        rep(i, 0, a)
        {
            cout << b;
        }
    }

    cout << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = [int(i) for i in input().split()]

A.sort(reverse=True)
ret = A[0]
c = N - 2
i = 1
while c :
  if c >= 2 :
    ret += A[i] * 2
    c -= 2
  else :
    ret += A[i]
    c -= 1
  i += 1

print(ret)

Measured memory_bytes: 104972
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class C {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            int N = in.nextInt();

            int[][] com = new int[N + 1][N + 1];
            for (int i = 1; i <= N; i++) {
                Arrays.fill(com[i], -1);
                int A = in.nextInt();
                for (int j = 0; j < A; j++) {
                    int x = in.nextInt();
                    int y = in.nextInt();
                    com[i][x] = y;
                }
            }

            int max = 0;
            int m = 1 << N;
            for (int bits = 0; bits < m; bits++) {
                boolean b = true;
                for (int i = 1; b && i <= N; i++) {
                    int cur = (bits >> (i - 1)) % 2;
                    if (cur == 0) continue;
                    for (int j = 1; b && j <= N; j++) {
                        if (i == j) continue;
                        if (com[i][j] == -1) continue;
                        int tar = (bits >> (j - 1)) % 2;
                        b = com[i][j] == tar;
                    }
                }
                if (b) {
                    max = Math.max(max, Integer.bitCount(bits));
                }
            }
            out.println(max);
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 21716
#include <stdio.h>
int main(void)
{
    int A,B;
    scanf ("%d %d",&A,&B);
    if (A<=B*2)
    {
        printf ("%d",0);
    }
  else
   {
        printf ("%d",A-(B*2));
    }
    return 0;
}


Measured memory_bytes: 1724
#include<iostream>//打表做法，危险动作，请勿效仿 
#include<cstdio>
#include<cstring>
using namespace std;
char s[1000005];
bool bo;
long long ji;
int main(){
	scanf("%s",&s);
	long long len=strlen(s);
	for(long long i=0;i<len-1;i++){
		if(s[i]!=s[i+1])bo=1;
	}
	if(bo=1){
		if(s[0]!=s[len-1])
			ji=len-2;
		else ji=len-3;
	}
	else ji=0;
	if(ji%2==1)cout<<"First";
	else cout<<"Second";
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
  int x,y,ans=0,a,b,c,j=0;
  cin>>a>>b>>c;
  int w[c][2],yy[c][2];
  rep(i,c){
    cin>>w[i][0]>>w[i][1];
  }
  x=w[0][0];
  y=w[0][1];
  rep(i,c){
    while(1){
      if(x==w[i][0]&&y==w[i][1])break;
      ans++;
      if(w[i][0]>x){
	x++;
	if(w[i][1]>y)y++;
      }
      else if(w[i][0]<x){
	x--;
	if(w[i][1]<y)y--;
      }
      else{
	if(w[i][1]>y)y++;
	else if(w[i][1]<y)y--;
      }
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3100
n = int(input())

str = input()
strList = str.split()
b = []
for x in strList:
    b.append(int(x))

l = len(b)
sum = b[l-1] + b[0]

for i in range(l-1):
    if b[i] < b[i+1]:
        sum += b[i]
    else:
        sum += b[i+1]

print(sum)


Measured memory_bytes: 3064
#ifdef __GNUC__
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#endif

#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
#include <sstream>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <vector>

using namespace std;

typedef long long LL;

void solve(long long a, long long b, long long c, long long d) {
	LL ans = max({ a * c, a * d, b * c, b * d });
	cout << ans << endl;
}

int main() {
	long long a, b, c, d;
	std::cin >> a >> b >> c >> d;
	solve(a, b, c, d);
	return 0;
}


Measured memory_bytes: 3644
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	class Node {
		int parent;
		public Node(int x) {
			this.parent = x;
		}
	}
	
	class DisjointSet {
		Node[] p;
		int[] rank;
		
		public DisjointSet(int size) {
			p = new Node[size];
			rank = new int[size];
			for (int i = 0; i < size; i++) {
				makeSet(i);
			}
		}

		private void makeSet(int x) {
			p[x] = new Node(x);
			rank[x] = 0;
		}
		
		private int findSet(int x) {
			while (x != p[x].parent) {
				x = p[x].parent;
			}
			return x;
		}
		
		public boolean same(int x, int y) {
			return findSet(x) == findSet(y);
		}
		
		public void unite(int x, int y) {
			link(findSet(x), findSet(y));
		}

		private void link(int x, int y) {
			if (rank[x] < rank[y]) {
				p[x].parent = y;
			} else {
				p[y].parent = x;
				if (rank[x] == rank[y]) {
					rank[y]++;
				}
			}
		}
	}
	
	
	public static void main(String[] args) throws IOException {
		new Main().run();
	}
	
	private void run() throws IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(reader.readLine());
		int n = Integer.parseInt(st.nextToken());
		DisjointSet ds = new DisjointSet(n);
		int q = Integer.parseInt(st.nextToken());
		for (int i = 0; i < q; i++) {
			st = new StringTokenizer(reader.readLine());
			int c = Integer.parseInt(st.nextToken());
			int x = Integer.parseInt(st.nextToken());
			int y = Integer.parseInt(st.nextToken());
			if (c == 0) {
				ds.unite(x, y);
			} else {
				System.out.println(ds.same(x, y)?"1":"0");
			}
		}
		reader.close();
	}
}


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

int main(int argc, char const *argv[]) {
    int n;
    cin >> n;
    vector<int> p(n);
    for (size_t i = 0; i < n; i++) cin >> p[i];

    int ans = 0;
    int min = 3000000;
    for (size_t i = 0; i < n; i++) {
        if (p[i] < min) min = p[i];
        if (min == p[i]) ++ans;
    }

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


Measured memory_bytes: 4032
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    int n;
    cin>>n;
    vector<pair<ll ,ll > > eee;
    for(int i=0;i<n;i++)
    {
        ll a, b;
        cin>>a>>b;
        eee.push_back({b,a});

    }
    sort(eee.begin() , eee.end());
    ll start=0;
    for(auto i:eee)
    {
        if(start>i.first-i.second)
        {
            cout<<"No";
            return 0;
        }
        start=start+i.second;
    }
    cout<<"Yes";
    return 0;
}


Measured memory_bytes: 6384
#include<bits/stdc++.h>
#define LL long long
using namespace std;

const int mn=1e5+7,mod=1e9+7;
int n,k;
LL fac[mn],inv[mn];
vector<int> to[mn];

LL poww(LL a,LL b) {LL ans=1;while(b) {if(b&1) (ans*=a)%=mod;(a*=a)%=mod;b>>=1;}return ans;}

LL calc(int a,int b)
{
	if(b>a) return 0;
	return (fac[a]*inv[a-b]%mod);
}

LL dfs(int x,int fa)
{
	int use=0,f=0;
	if(fa==0) use=k-1,f=1;
	else use=k-2;
	LL ans=calc(use,to[x].size()-1+f);
	for(int i=0;i<to[x].size();++i) {
		int t=to[x][i];
		if(t==fa) continue;
		ans=(ans*dfs(t,x))%mod;
	}
	return ans;
}
	

int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<n;++i) {int a,b;scanf("%d%d",&a,&b);to[a].push_back(b),to[b].push_back(a);}
	fac[0]=inv[0]=1;
	for(int i=1;i<=k;++i) fac[i]=fac[i-1]*i%mod;
	inv[k]=poww(fac[k],mod-2);
	for(int i=k-1;i>=1;--i) inv[i]=inv[i+1]*(i+1)%mod;
	printf("%lld",(k*dfs(1,0))%mod);
}

Measured memory_bytes: 11520
/*input
2 1 2
*/
#include<bits/stdc++.h>
using namespace std;

#define int long long 
#define double long double

typedef pair<int,int> pi;

typedef vector<int> vi;
typedef vector<pi> vpi;

#define f first
#define s second
#define mp make_pair
#define pb push_back

#define gcd __gcd

const int INF = 1e18+1;
const int MOD = 1e9+7;
const double PI = 3.14159265358979323846264338;

int fast_ex(int a,int n,int m){
  if(n == 0)return 1;
  if(n == 1)return a;
  int x = 1;
    x *= fast_ex(a,n/2,m);
    x %= m;
    x *= x;
    x %= m;
    if(n%2)x*= a;
    x %= m;
    return x;
}

signed main(){
  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  int a,b,n;
  cin >> n >> a >> b;
  int turn = 0;
  int i= a;
  int j = b;
  turn = b-a;
  turn %=2;
  if(!turn)cout << "Alice";
  else cout << "Borys";
  return 0;
}

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

int matA[MAX][MAX];
int matB[MAX][MAX];

int main(){
	int l, m, n;
	
	cin >> n >> m >> l;
	
	for(int i=0; i<n; i++){
		for(int j=0; j<m; j++){
			cin >> matA[i][j];
		}
	}
	for(int i=0; i<m; i++){
		for(int j=0; j<l; j++){
			cin >> matB[i][j];
		}
	}
	for(int i=0; i<n; i++){
		for(int j=0; j<l; j++){
			long int c = 0;
			for(int k=0; k<m; k++){
				c += matA[i][k] * matB[k][j];
			}
			if(j) cout << " ";
			cout << c;
		}
		cout << "\n";
	}
	
	return 0;
}


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

int main(){
    int s; cin >> s;
    
    int a = s/100; //上2つ
    int b = s%100; //下2つ

    bool aRes = false;
    bool bRes = false;

    if (12 >= a && a >= 1) {
        aRes = true;
    }

    if (12 >= b && b >= 1) {
        bRes = true;
    }

    if (aRes && bRes){
        cout << "AMBIGUOUS" << endl;
    } else if (aRes || bRes ){
        if (aRes) {
            cout << "MMYY" << endl;
        } else if (bRes) {
            cout << "YYMM" << endl;
        }
    } else {
        cout << "NA" << endl;
    }

    return 0;
}

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

int main(){
  string s;
  cin >> s;
  map<char, int> count;
  rep(i, s.size()){
    count[s[i]] += 1;
  }
  
  bool judge = 0;
  for (auto p: count) {
    if (p.second > 1) judge = 1;
  }
  
  if (judge) cout << "no" << endl;
  else cout << "yes" << endl;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define FI first
#define SE second
#define PB(a) push_back(a)
#define DEB(x) cerr << __LINE__ << ":" << #x << ": " << x << "\n";
#define SZ(x) ((int)(x).size())
#define SO(x) sizeof((x)) / sizeof((x)[0])
//#define int long long
using namespace std;
using lint = long long;
struct Fast{Fast(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};} fast;
const int INF = INT_MAX;
const lint LINF = LLONG_MAX;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
inline int in() {int x; cin >> x; return x;}
inline lint IN() {lint x; cin >> x; return x;}
inline void co(int a[], int n) {REP(i, n) cout << a[i] << " "; cout << "\n";}
//if (IO > 1e5){lint a;	scanf(%lld, &a);	printf("%lld\n", a);}

signed main(){
	int n = in();	int c = 0;	int ans = 0;
	for(int i = 1; i < n+1; i += 2){
		FOR(j,1,i+1){
			if (i%j == 0) c++;
		}
		if (c == 8) ans++;
		//cout << i << ":" << c << "\n";
		c = 0;
	}
	cout << ans << endl;
	//cout << "Hello World" << "\n";
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,q;
string s;
set<int> st[27];
int main()
{
	ios::sync_with_stdio(false);cin.tie(false);
	//freopen("input.txt","r",stdin);
	cin>>n;
	cin>>s;
	cin>>q;
	for(int i=0;i<26;i++)
	{
		st[i].insert(n);       //防止使用lower_bound时集合为空 
	}
	for(int i=0;i<n;i++)
	{
		st[s[i]-'a'].insert(i);
	}
	int t;
	for(int i=0;i<q;i++)
	{
		cin>>t;
		if(t==1)
		{
			int a;char b;
			cin>>a>>b;
			st[s[a-1]-'a'].erase(a-1);
			st[b-'a'].insert(a-1);
			s[a-1]=b;
		}
		else
		{
			int l,r;
			cin>>l>>r;
			int ans=0;
			for(int i=0;i<26;i++)
			{
				auto it=st[i].lower_bound(l-1);
				if(*it<=r-1) ans++;
			}
			cout<<ans<<endl;
		}
	}
	return 0;
}





Measured memory_bytes: 24220
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#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 pi acos(-1.0)

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

const ll MOD = (int)1e9 + 7;
ll fact(ll x){
    if(x == 0) return 1;
    return fact(x - 1) * x % MOD;
}



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    cout << fact(n) << "\n";

    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<int(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define show(x) cout<< #x << " = " << x << endl
using namespace std;

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

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

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

const ll mod=1e9+7;
const int INF=INT_MAX/2;
const int N_MAX=100010;

ll a[3];

int main(){
	REP(i,3)cin>>a[i];
	if(a[0]%2==0 || a[1]%2==0 || a[2]%2==0)cout<<0<<endl;
	else{
		sort(a,a+3);
		cout<<a[0]*a[1]<<endl;
	}
	return 0;
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void solve() {
    ll N;
    cin >> N;
    string ans = "";
    while (N > 0) {
        ll z = N % 26;
        if (z == 0) {
            ans += 'z';
            N--;
        } else {
            ans += 'a' + (z - 1);
        }
        N /= 26;
    }
    reverse(ans.begin(), ans.end());
    cout << ans << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    return 0;
}


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

int main() {
	
	int A, B;
	cin >>A >>B;
	
	if(B%A==0){
		
		cout <<A+B <<endl;
		
	}
	else{
		
		cout <<B-A <<endl;
		
	}
	
}

Measured memory_bytes: 256
'use strict'

const main = (input) => {
    input = input.split('\n').map(i => parseInt(i))
    const X = input[0]
    const A = input[1]
    const B = input[2]
    console.log((X - A) % B)
}

main(require('fs').readFileSync('/dev/stdin', 'utf-8'))

Measured memory_bytes: 20936
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//using ll = long long;
using P = pair<int,int>;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

signed main(){
	int n;
	cin >> n;
	for(int i = 1;i <= 9;i++){
		for(int j = 1;j <= 9;j++){
			if(i * j == n){
				Yes();
				return 0;
			}
		}
	}
	No();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
#include <algorithm>
using namespace std;
#define ll long long
#define r(i,n) for(int i=0;i<n;i++)
#define rn(i,n) for(int i=1;i<=n;i++)

int main(){
  string s;
  int k;

  cin>>s>>k;

  for(int i=0;i<s.size();i++){
    if(s.at(i)!='1'){
      cout<<s.at(i)<<endl;
      break;
    }
    else if(i==min((int)s.size()-1,k-1)){
        cout<<'1'<<endl;
        break;
    }
  }





  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,m;
int d[200005],t[200005];
map<int,int> M;
int main() {
	ios::sync_with_stdio(false);
	cin>>n;
	for(int i=1;i<=n;i++) cin>>d[i];
	cin>>m;
	for(int i=1;i<=m;i++) cin>>t[i];
	for(int i=1;i<=n;i++) M[d[i]]++;
	for(int i=1;i<=m;i++) {
		if (!M[t[i]]) {
			cout<<"NO";return 0;
		}
		M[t[i]]--;
	}
	cout<<"YES";return 0;
}

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

void min(int *a, int b){//aがbより大きければ、aをbに変えて、１を返す。つまりaとbのどっちが小さいかの判定を行う
    if(*a > b){
        *a=b;

    }
}

int main() {
    int n=0, h[100000]={}, dp[100000], i=0, onestep,twostep;
    scanf("%d", &n);//入力の配列の要素数
    for(i=0;i<n;i++){
        scanf("%d", &h[i]);
    }

    for(i=0;i<100000;++i){
        dp[i]=1000000000;
    }
    dp[0]=0;

    for(i=0;i<n;i++){
        onestep=dp[i-1]+abs(h[i]-h[i-1]);
        min(&dp[i], onestep);

        if(i>1){
            twostep=dp[i-2]+abs(h[i]-h[i-2]);
            min(&dp[i], twostep);
        }


        //printf("%d step : %d\n", i+1, dp[i]);
    }


    printf("%d", dp[n-1]);

    return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

const int LIMIT = 55555;
bool isPrime[LIMIT+1];

int main() {
    // Sieve of Eratosthenes
    for (int i = 0; i <= LIMIT; i++) isPrime[i] = true;
    isPrime[0] = isPrime[1] = false;
    for (int i = 2; i <= sqrt(LIMIT); i++) {
        for (int j = i + i; j <= LIMIT; j += i) {
            isPrime[j] = false;
        }
    }
    // output
    int n, num = 1, count = 0;
    cin >> n;
    while(true) {
        num += 10;
        if (isPrime[num]) {
            if (count) cout << " ";
            cout << num;
            if (++count == n) break;
        }
    }
    cout << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <climits>
#include <bitset>
#include <list>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
	string s;
	int w;
	cin >> s >> w;
	for(int i=0; i<s.length(); i+=w) cout << s[i];
	cout << endl;
	return 0;
}

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

#define For(i, j, k) for(int i = j; i <= k; i++)
#define Forr(i, j, k) for(int i = j; i >= k; i--)
#define Set(i, v) memset(i, v, sizeof i)
#define pb push_back

using namespace std;

const int N = 100010;

int n;
int A[N], B[N], C[N];

int main(){
	scanf("%d", &n);
	For(i, 1, n) scanf("%d", &A[i]);
	For(i, 1, n) scanf("%d", &B[i]);
	For(i, 1, n) scanf("%d", &C[i]);

	sort(A + 1, A + n + 1), sort(B + 1, B + n + 1), sort(C + 1, C + n + 1);

	long long ans = 0;
	int l = 0, r = 1;
	For(i, 1, n){
		while(l < n && A[l + 1] < B[i]) ++l;
		while(r <= n && C[r] <= B[i]) ++r;
		ans += 1ll * l * (n + 1 - r);
	}

	printf("%lld", ans);

	return 0;
}

Measured memory_bytes: 1408
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>
#include<deque>

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e8;

using namespace std;


//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用


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

	int n;
	cin >> n;
	cout << n / 3 << endl;

}

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

tmp = H[0]
for i, h in enumerate(H[1:]):
    if tmp == h:
        continue
    elif tmp == h-1:
        tmp = h-1
    elif tmp < h-1:
        tmp = h - 1
    elif tmp > h-1:
        print('No')
        quit()


print('Yes')

Measured memory_bytes: 63984
#include <bits/stdc++.h>
using namespace std;
#define ll long long
vector<vector<int>> adj(100005),edj(100005);
int vis[100005],fin[100005];
int n;

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

    cin>>n;
    for(int i=0;i<n-1;i++){
        int u,v;
        cin>>u>>v;
        adj[i+1].push_back(v);
        adj[i+1].push_back(u);
        edj[u].push_back(i+1);
        edj[v].push_back(i+1);
    }
    int res=0;
    for(int i=1;i<=n;i++){
        res=max(res,(int)edj[i].size());
    }
    vector<int> colors;
    for(int i=0;i<res;i++){
        colors.push_back(i+1);
    }
    queue<pair<int,int>> qp;
    qp.push({1,1});
    fin[1]=1;
    while(!qp.empty()){
        int idx=qp.front().first;
        int color=qp.front().second;
        qp.pop();
        for(int i=0;i<adj[idx].size();i++){
            int id=0,fh=adj[idx][i];
            for(int j=0;j<edj[fh].size();j++) {
                int ch = edj[fh][j];
                if(ch==idx){
                    continue;
                }
                if (fin[ch] == 0) {
                    for (id; id < res; id++) {
                        if (colors[id] != color) {
                            fin[ch] = colors[id];
                            qp.push({ch, fin[ch]});
                            id++;
                            break;
                        }
                    }
                }
            }
        }
    }
    cout<<res<<endl;
    for(int i=1;i<n;i++){
        cout<<fin[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 12032
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <iomanip>
#include <ctype.h>

using namespace std;
using ll = long long;
using PAIR = pair<int, int>;
using PAIRLL = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

#define rep(i,N) for(int i=0;i<(int)N;++i)

ll GCD(ll x, ll y) {
    if (y == 0) return x;
    else return GCD(y, x % y);
}

bool my_compare(pair<string, int> a, pair<string, int> b) {
    if (a.first != b.first) {
        return a.first < b.first;
    }

    if (a.second != b.second) {
        return a.second > b.second;
    }
    else {
        return true;
    }
}

int main()
{
  int K,X,p,M=0;
  cin>>X;
  if(X<=3){cout<<1<<endl;}
  else{
  for(int i=2;i<=sqrt(X);++i){
  p=1;
  while(1){
    ++p;
    K=round(pow(i,p));
    if(K>X){break;}
    M=max(M,K);
  }
  }
    cout<<M<<endl;
  }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << endl
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> V;

int gcd(int m, int n) {
  if (n == 0) return m;
  return gcd(n, m%n);
}

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  dump(c%gcd(a, b) == 0 ? "YES" : "NO");
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <iostream>

using namespace std;

#define limit int(1e6)
int arr[ limit ];
int dist[ limit ];

int found_answer(int count) {
	fill(arr, arr + limit, int(1e9));
	arr[ 0 ] = dist[ 0 ];

	for(int i = 1; i < count; i++) {
		int first_answer = abs(dist[ i - 1 ] - dist[ i ]);
		int second_answer = abs(dist[ i - 1 ] - dist[ i + 1 ]);

		arr[ i ] = min(arr[ i ], arr[ i - 1 ] + first_answer);
		arr[ i + 1 ] = min(arr[ i + 1 ], arr[ i - 1 ] + second_answer);
	}

	/*
	for(int i = 0; i < count; i++) {
		printf("%i ", arr[ i ]);
	} printf("\n"); */

	return arr[ count - 1 ] - arr[ 0 ];
}

int main() {
	int count;
	scanf("%i", &count);

	for(int i = 0; i < count; i++) {
		scanf("%i", &dist[ i ]);
	}

	printf("%i", found_answer(count));
}

Measured memory_bytes: 6400
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  string s1,s2,s3;
  cin>>s1>>s2>>s3;
  cout<<(char)toupper(s1[0])<<(char)toupper(s2[0])<<(char)toupper(s3[0])<<endl;
  return 0;
}


Measured memory_bytes: 256
from collections import deque

N,K = map(int,input().split())
mod = 1000000007
root = [[] for i in range(N)]
for _ in range(N-1):
    a,b = map(int,input().split())
    root[a-1].append(b-1)
    root[b-1].append(a-1)

stack=deque([[0,K]])
check = [True]*N
check[0] = False
ans = 1
while len(stack):
    u,k = stack.popleft()
    ans = (ans*k)%mod
    if u == 0:
        k_next = K-1
    else:
        k_next = K-2
    for v in root[u]:
        if check[v]:
            check[v] = False
            stack.append([v,k_next])
            k_next -= 1
    #print(ans, k_next)
print(ans)

Measured memory_bytes: 99876
#include<iostream>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<utility>
#include<algorithm>
using namespace std;
#define vel vector<int>
#define vvel vector<vel>
#define vvvel vector<vvel>
#define veb vector<bool>
int sum(int n) {
	if (n == 0) { return 0; }
	return n % 2 + sum(n / 2);
}
void prin(vel v) {
	for (int i = 0; i < v.size() - 1; i++) {
		cout << v[i] << " ";
	}
	cout << v[v.size() - 1] << endl;
}
int rui(int n) { 
	if (n == 0) { return 1; }
	return 2 * rui(n - 1);
}
void add(int &num, int i,int bit) {
	num = 2 * (rui(i)*(num / rui(i))) + num % rui(i) + bit * rui(i);
}
int  del(int &num, int i) {
	return rui(i)*(num / rui(i + 1)) + num % rui(i);
}
int ord(int n) {
	if (n % 2 == 1) { return 0; }
	return ord(n / 2) + 1;
}
vel ret(int a, int b, int n) {
	int goa = a xor b;
	if (n == 1) {
		if (a == 0) { return { 0,1 }; }
		else { return { 1,0 }; }
	}
	int che;
	for (int i = 0; i < n; i++) {
		if ((goa & 1 << i) != 0) {
			che = i;
		}
	}
	int mn = n - 1;
	vel gray(rui(mn),0);
	for (int i = 1; i < rui(mn); i++) {
		gray[i] = gray[i - 1] xor rui(ord(i));
	}
	for (int i = 0; i < rui(mn); i++) {
		add(gray[i], che, 0);
	}
	vel q = ret(rui(mn - 1), del(goa, che), mn);
	for (int i = 0; i < rui(mn); i++) {
		add(q[i], che, 1);
	}
	vel ans(rui(n));
	for (int i = 0; i < rui(mn); i++) { ans[i] = gray[i] xor a; }
	for (int i = 0; i < rui(mn); i++) { ans[i + rui(mn)] = q[i] xor a; }
	return ans;
}
signed main() {
	int n; cin >> n;
	int a, b; cin >> a >> b;
	int goa = a xor b;
	if (sum(goa) % 2 == 0) { cout << "NO" << endl; }
	else { 
		cout << "YES" << endl;
		prin(ret(a, b, n));
	}
	return 0;
}

Measured memory_bytes: 1656
#include<stdio.h>
#define ABS(x)  ((x>=0.0)?(x):(-1*x))

int main(){
	int i,j,n,m,h,w;
	double bmi,ans,x,y;
	
	while(1){
		scanf("%d",&n);
		if(n==0)break;
		scanf("%d%d%d",&i,&h,&w);
		ans=(double)(w*10000)/(h*h);
		m=i;
		for(j=1;j<n;j++){
			scanf("%d%d%d",&i,&h,&w);
			bmi=(double)(w*10000)/(h*h);
			x=22.0-bmi;
			if(x<0.0)x=x*(-1);
			y=22.0-ans;
			if(y<0.0)y=y*(-1);
			if(x-y<0.00001){
				m=i;
				ans=bmi;
			}
		}
		printf("%d\n",m);
	}
	
	return 0;
}

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

int main() {
    int n, Yen = 0;
    long double b, Btc = 0;
    string s;

    cin >> n;

    rep(i,n) {
        cin >> b >> s;
        if (s == "JPY") {
            Yen += b;
        } else {
            Btc += b;
        }
    }

    long double BC = 380000.0 * Btc;
    long double ans = Yen + BC;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>

using namespace std;

void func(double D,double E){
	double maximum = 101.0;

	for(double x = 0; x <= D; x += 1.0){
		maximum = min(maximum,fabs(sqrt(x*x+(D-x)*(D-x))-E));
	}

	if(fabs(maximum-floor(maximum)) < 0.0000000001){
		printf("%.0lf\n",maximum);
	}else{
		printf("%.10lf\n",maximum);
	}
}

int main(){

	double D,E;

	while(true){
		scanf("%lf %lf",&D,&E);
		if(D == 0 && E == 0)break;

		func(D,E);
	}

    return 0;
}

Measured memory_bytes: 2704
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  int x;cin>>x;
  int res=1;
  for(int i=2;i<=x;i++){
    for(int j=2;1;j++){
      int t = pow(i,j);
      if(t > x) break;
      res = max(res, t);
    }
  }
  cout<<res<<endl;

  return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;
    public class Main{
        public static void main(String[] args) {
            try (Scanner sc = new Scanner(System.in)) {
                while (true) {
                    int n = sc.nextInt();
                    if (n == 0) {
                        break;
                    }
                    int[] scores = new int[n];
                    for (int i = 0; i < scores.length; i++) {
                        scores[i] = sc.nextInt();
                    }
                    double average = 0, variance = 0;

                    double sum1 = 0, sum2 = 0;
                    for (int i = 0; i < scores.length; i++) {
                        sum1 += scores[i];
                    }
                    average = sum1 / scores.length;
                    for (int i = 0; i < scores.length; i++) {
                        sum2 += Math.pow(scores[i] - average, 2);
                    }
                    variance = sum2 / scores.length;
                    System.out.println(Math.sqrt(variance));
                }
            }
        }
    }
 



Measured memory_bytes: 31380
X = int(input())
ans = 0
def isPrime(n):
    i = 2
    while i**2 <= n:
        if n%i == 0:
            return False
        i += 1
    return n != 1
while ans == 0:
    if isPrime(X):
        ans = X
    else:
        X += 1
print(ans)

Measured memory_bytes: 2940
class UnionFind():
    def __init__(self,n):
        self.n=n
        self.parents=[-1]*n

    def find(self,x): #根を見つける、繋ぎ直す
        if self.parents[x]<0:
            return x
        else:
            self.parents[x]=self.find(self.parents[x])
            return self.parents[x]
    
    def unite(self,x,y): #x,yの含むグループを併合する
        x=self.find(x)
        y=self.find(y)

        if x==y:
            return
        
        if self.parents[x]>self.parents[y]:
            x,y=y,x

        self.parents[x]+=self.parents[y]
        self.parents[y]=x
    
    def same(self,x,y):#xとyが同じグループにいるか判定
        return self.find(x)==self.find(y)
    
    def members(self,x):#xと同じグループのメンバーを列挙
        root=self.find(x)
        return [i for i in range(self.n) if self.find(i)==root]
    
    def size(self,x):#xが属するグループのメンバーの数
        return -self.parents[self.find(x)]
    
    def roots(self):#ufの根を列挙
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):#グループの数を数える
        return len(self.roots())

    def all_group_members(self):#根:メンバの辞書を返す
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):#print()での表示用
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

def main():
    import sys
    input=sys.stdin.readline
    n,m=map(int,input().split())
    edges=[0]*m
    for i in range(m):
        a,b=map(int,input().split())
        a-=1
        b-=1
        edges[i]=[a,b]
    
    cnt=0
    for i in range(m):
        uf=UnionFind(n)
        for j in range(m):
            if i!=j:
                uf.unite(edges[j][0],edges[j][1])
        if uf.size(0)!=n:
            cnt+=1
    print(cnt)   
if __name__=='__main__':
    main()

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef string str;
static const long long INF = 1LL<<59;
static const long long MOD = (ll)1e9+7;

#define endl "\n"
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
#define REP(i, n) for(ll i=0;i<n;i++)
#define SZ(v) (ll)((v).size())
#define WHOLE(v) (v).begin(), (v).end()
#define ASC(v) sort((v).begin(), (v).end())
#define DESC(v) sort((v).rbegin(), (v).rend())
#define INV(v) reverse((v).begin(), (v).end())
#define FOLDL(src, dst, lambda) partial_sum((src).begin(), (src).end(), (dst).begin(), lambda)
#define FOLDR(src, dst, lambda) INV(src);partial_sum((src).begin(), (src).end(), (dst).begin(), lambda);INV(dst)
#define CUMSUML(src, dst) FOLDL(src, dst, [](auto a, auto b) {return a+b;})
#define CUMSUMR(src, dst) FOLDR(src, dst, [](auto a, auto b) {return a+b;})
#define ACCUM(v, d0, lambda) accumulate((v).begin(), (v).end(), d0, lambda)
#define SUM(v, d0) ACCUM(v, d0, [](auto a, auto b) {return a+b;})
#define ERASE(v, i) v.erase(v.begin() + i)
#define UNIQ(v) ASC(v);v.erase(unique(v.begin(), v.end()), v.end())

template <typename T>void debug(T t) {cerr << t << endl;}
template <typename T, typename ...Args>void debug(T t, Args ...args) {cerr << t << " ";debug(args...);}
template <typename T>void out(T t) {cout << t << endl;}
template <typename T, typename ...Args>void out(T t, Args ...args) {cout << t << " ";out(args...);}

void solve() {
    ll N, K;
    cin >> N >> K;
    vll h(N);
    for(auto &a:h) cin >> a;
    ASC(h);
    ll ans = INF;
    for(ll s = 0; s <= N - K; s++) {
        ll t = s + K - 1;
        ll d = h[t] - h[s];
        ans = min(ans, d);
    }
    out(ans);
}

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

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <iomanip>
#include <sstream>
using namespace std;

int main()
{
  int i,N; cin >> N;
  vector<int> A(N);
  for(i=0;i<N;i++){
  	cin >> A.at(i);
  }
  
  bool Even = true;
  int count = 0;
  while(Even){
    for(i=0;i<N;i++){
 	  if(A.at(i) % 2 == 1){
        Even = false;
      }
    }
    if(!Even) break;
    
    for(i=0;i<N;i++){
      A.at(i) /= 2;
    }
    count++;
  }
  
  cout << count << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        while(true){
            int h =sc.nextInt();
            int w =sc.nextInt();
            if(w==0||h==0) break;
        
            for(int i=1;i<=h;i++){
                for(int j=1;j<=w;j++){
                    if((i+j)%2==0){
                        System.out.printf("#");
                    }else{
                        System.out.printf(".");
                    }
                }
                System.out.println();
            }
            System.out.println();
        }
    }
    
    
}
    


Measured memory_bytes: 56948
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,count=1;
	string s;
	cin>>n;
	vector<string>v;
	while(n--){
		cin>>s;
	v.push_back(s);
	}
	sort(v.begin(),v.end());
	for(int i=1;i<v.size();i++){
		if(v[i-1]==v[i]){
			continue;
		}
		else{
			count++;
		}
	}
	cout<<count;
}

Measured memory_bytes: 11656
let () =
    let heights = Array.make 10 0 in
    for i = 1 to 10 do
        let n = read_int () in
        heights.(i-1) <- n
    done ;

    Array.sort compare heights ;

    for i = 1 to 3 do
        let height = heights.(10-i) in
        Printf.printf "%d\n" height
    done ;

Measured memory_bytes: 2292
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <math.h>
#include <map>
#include<cmath>
#include<queue>

typedef long long ll;
using namespace std;
#define mod 10007
#define rep(i,n) for(ll i=0;i<n;i++)

int main(void){
  string a,b;
  cin >> a >> b;
  int ans=0;
  for(int i=0;i<3;i++){
    if(a[i]==b[i])ans++;
  }

  cout << ans << endl;
  return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long dp[200010][3];
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> A(n);
    for (auto & a : A) cin >> a;
    dp[0][0] = A[0];
    dp[1][1] = A[1];
    for (int i = 2; i < n; ++i) {
        dp[i][0] = dp[i-2][0]+A[i];
        dp[i][1] = dp[i-2][1]+A[i];
        dp[i][2] = dp[i-2][2]+A[i];
        if (i > 2) {
            dp[i][1] = max(dp[i][1], dp[i-3][0]+A[i]);
            dp[i][2] = max(dp[i][2], dp[i-3][1]+A[i]);
        }
        if (i > 3) {
            dp[i][2] = max(dp[i][2], dp[i-4][0]+A[i]);
        }
    }
    long long ans = max(dp[n-1][1+n%2], dp[n-2][0+n%2]);
    if (n&1) ans = max(ans, dp[n-3][0]);
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 8724
#include<bits/stdc++.h>
#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)
using namespace std;

int main() {
    int k, s;
    cin >> k >> s;
    int ans = 0;
    rep(x, 0, k + 1) {
        rep(y, 0, k + 1) {
            int z = s - x - y;
            if (0 <= z and z <= k) {
                ans = ans + 1;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
a, b = input().split()
#print(a, b)

if a == 'H' and b == 'H':
    print('H')
elif a == 'H' and b == 'D':
    print('D')
elif a == 'D' and b == 'H':
    print('D')
elif a == 'D' and b == 'D':
    print('H')

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

int main() {
	long long a,b,c,sm=0;
	cin >> a >> b >> c;
	if(c > a + b)
	{
		sm = b + a + b + 1;
	}
	else
	{
		sm = b + c;
	}
	cout << sm << endl;
	return 0;
}


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

int main(){
    string s;
    cin>>s;
    ll ans=0;
    ll cnt=1;
    for(ll i=1;i<s.size();i++){
        if(s[i-1]==s[i]){
            cnt++;
            if(i==s.size()-1){
                ans+=(cnt/3)*2;
                cnt%=3;
                if(cnt==1){
                    ans++;
                }else if(cnt==2){
                    ans++;
                }
            }
        }else{
            ans+=(cnt/3)*2;
            cnt%=3;
            if(cnt==1){
                ans++;
            }else if(cnt==2){
                ans+=2;
                i++;
            }
            cnt=1;
            if(i==s.size()-1)ans++;
        }
    }
    cout<<ans<<endl;
}


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

using namespace std;

int main(int argc, char const *argv[]) {
  long long N;
  std::vector<long long> v(5);
  std::cin >> N;
  for (size_t i = 0; i < 5; i++) {
    std::cin >> v[i];
  }
  sort(v.begin(),v.end());
  if (N % v[0] != 0)  std::cout << N / v[0] + 5 << '\n';
  else std::cout << N / v[0] + 4 << '\n';
  return 0;
}


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

using namespace std;
int n,s,target,R,L,ans,Lastans,Rsum,Lsum,a, number[11000];
int right(int in);
int left (int in);

int main(){

    while(1){
    cin >> n;
    if(n==0)break;
    Lastans=n;
   number[11000]={0};

    for(int i=0;i<n;i++){
        cin >> s;
        number[i]=s;
    }

    for(int i=0;i<n;i++){
        for(int j=1;j<4;j++){
                a=number[i];
                number[i]=j;

            while(1){
            if(Rsum==0&&Lsum==0)target=j;
            else if(number[i-Lsum-1]!=number[i+Rsum+1])break;
            else target=number[i+Rsum+1];

            R=right(i);
            L=left(i);
            if(R+L>=3&&Rsum==0&&Lsum==0){
                Rsum+=R;
                Lsum+=L;
            }else if(R+L>=4){
                Rsum+=R;
                Lsum+=L;
            }else break;
                    }
                ans=n-Rsum-Lsum-1;
                if(ans<Lastans-1)Lastans=ans;

                Lsum=0;
                Rsum=0;
                number[i]=a;

                }

            }

            cout << Lastans << endl;

    }
    return 0;
}



int right(int in){

    int sum=0;
    while(1){
    if(in+Rsum==n)break;
    in++;
    if(number[in+Rsum]==target)sum++;
    else break;
    }
    return sum;
}

int left(int in){

    int sum=0;
    while(1){
    if(in-Lsum==-1)break;
    in--;
    if(number[in-Lsum]==target)sum++;
    else break;
    }
    return sum;
}

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



int main() {
    int n;
    cin >> n;
    uint64_t a=2, b=1;
    uint64_t c;
    int i=1;

    while(i != n){
        c = b + a;
        a = b;
        b = c;
        i++;
    }
  	if(n==1) cout << 1 << endl;
    else cout << c << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define ar array
#define mp make_pair
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	int t[n], ans = 0;
	for(int i =0 ;i <n; i++)
	{
		cin>>t[i];
		ans += t[i];
	}

	int m;
	cin>>m;
	for(int i = 0,j,k; i<m; i++)
	{
		cin>>j>>k;
		int ans2 = ans;
		ans2 = ans -t[--j];
		ans2 += k;
		cout<<ans2<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		if( (a + b) >= c) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 21844
using System;
using System.Collections.Generic;
using System.Linq;

public class Solution
{
    public static void Main()
    {
        var vals = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        var m = vals[0];
        var d = vals[1];

        var count = 0;
        for (int mm = 1; mm <= m; mm++)
        {
            for (int dd = 1; dd <= d; dd++)
            {
                var d1 = dd % 10;
                var d10 = dd / 10;
                if (d1 >= 2 && d10 >= 2 && d1 * d10 == mm)
                {
                    count++;
                }
            }
        }

        Console.WriteLine(count);
    }
}

Measured memory_bytes: 13268
n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse = True)
t = sum(a)
p = 0
for i in range(n):
  if a[i] >= t/(4*m):
    p += 1
  else:
    break

if p >= m:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3188
N, C, K = gets.split.map(&:to_i)
T = N.times.map{gets.to_i}.sort

ans = 0

until T.empty?
  t = T.shift
  cnt = 1
  while !T.empty? && T.first <= t + K && cnt < C
    T.shift
    cnt += 1
  end
  ans += 1
end

p ans

Measured memory_bytes: 4656
import sys
import collections
input = sys.stdin.readline


def main():
    SA = collections.deque(input().strip())
    SB = collections.deque(input().strip())
    SC = collections.deque(input().strip())
    S = [SA, SB, SC]
    nxt = "a"
    while 1:
        a = S[ord(nxt) - ord("a")]
        if not a:
            print(chr(ord("A") + ord(nxt) - ord("a")))
            return
        else:
            nxt = a.popleft()


if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInteger = readLn :: IO Integer
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readIntegers = map ( fst . fromJust . B.readInteger ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

modifyArray a i f = writeArray a i =<< f <$> readArray a i

printList [a] = print a
printList (a:as) = putStr ( show a ) >> putChar ' ' >> printList as

main = getLine >>= print . solve

solve "SSS" = 0
solve "RRR" = 3
solve [ 'R', 'R', _ ] = 2
solve [ _, 'R', 'R' ] = 2
solve _ = 1


Measured memory_bytes: 3808
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define IO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);



int main(){
  IO;

  int a,b,c,k;
  int ans = 0;

  cin>>a>>b>>c>>k;

  ans = (a<k)? a:k;
  if(a<k){
    ans  = a;
    k -= a;
  }
  else{
    ans = k;
    cout<<k<<endl;
    return 0;
  }
  if(b<k){
    k -= b;
  }
  else{
    cout<<ans<<endl;
    return 0;
  }
  if(c<k)
    k -= c;
  else{
    ans -= k;
    cout<<ans<<endl;
  }



  return 0;


}


Measured memory_bytes: 3580