akhauriyash/Code-Regression huggingface dataset:
var n, g, u, d;

function connected(i){
	u[i] = true;
	rep(26, function(j){
		if(g[i][j] && !u[j]){
			connected(j);
		}
	});
}

function main(){
	while(1){
		n = scan();
		if(!n){
			break;
		}

		g = [];
		u = [];
		d = [];
		rep(26, function(i){
			g[i] = [];
			d[i] = 0;
		});

		rep(n, function(){
			var s = scan('string');
			var a = s.charCodeAt(0) - 'a'.charCodeAt(0);
			var b = s.charCodeAt(s.length - 1) - 'a'.charCodeAt(0);
			g[a][b] = g[b][a] = true;
			++d[a];
			--d[b];
		});

		rep(26, function(i){
			var ind = true;
			rep(26, function(j){
				ind = !g[i][j] && ind;
			});
			if(ind){
				u[i] = true;
			}
		});

		rep(26, function(i){
			if(!u[i]){
				connected(i);
				return false;
			}
		});

		ans = true;
		rep(26, function(i){
			ans = u[i] && d[i] === 0 && ans;
		});

		print(ans ? 'OK' : 'NG');
	}
}
 
function rep(a, b, c){
	if(c == null){
		c = b;
		b = a;
		a = 0;
	}
	for(var i = a; i < b; ++i){
		if(c(i) === false){
			break;
		}
	}
}
 
process.stdin.resume();
process.stdin.setEncoding('utf8');
 
var input = '';
var input_index = 0;
 
function scan(type){
	if(type === 'string'){
		return input[input_index++];
	}
	else{
		return +input[input_index++];
	}
}
 
function print(val){
	console.log(val);
}
 
process.stdin.on('data', function(chunk){
	input += chunk;
});
process.stdin.on('end', function(){
	input = input.split(/\s+/);
	main();
});

Measured memory_bytes: 21928
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <numeric>
typedef long long Int;
#define rep(i,a,b) for(Int i=a;i<b;++i)
#define rrep(i,a,b) for(Int i=a;i>=b;--i)
using namespace std;

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

  	vector<Int> a(3);
    rep(i, 0, 3) cin >> a[i];
    sort(a.begin(), a.end(), greater<Int>());
    cout << a[0]*10 + a[1] + a[2] << endl;
}


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

using namespace std;

const int64_t MOD = 1000000007;

int main() {
  int N;
  cin >> N;
  vector<int64_t> A(N);
  for (int i = 0; i < N; i++) cin >> A[i];
  int64_t sum = 0;
  int64_t answer = 0;
  for (int i = N - 1; i >= 0; i--) {
    answer = (answer + sum * A[i] % MOD) % MOD;
    sum = (sum + A[i]) % MOD;
  }
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 4784
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
using namespace std;
int main() {
  
  int N,n;
  cin>>N;
  n=N;
  
  int sum=0;
  while(N>0){
    sum+=N%10;
    N=N/10;
  }

  if(n%sum==0){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 3684
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> i_i;

#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define ALL(v) v.begin(), v.end()
#define SZ(x) ((int)(x).size())
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int A[10001];
int main() {
    int N, K;
    cin >> N >> K;
    vector<ll> A(N);
    rep(i, N)cin >> A[i];
    for (int i = K; i < N; i++){
        if (A[i] > A[i - K]){
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
    return 0;
}



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

int main() {
  ll a,b; cin >> a >> b;
  ll x,y,z;
  x = a+b;
  y = a-b;
  z = a*b;
  cout << max(x, max(y,z)) << endl;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
 using namespace std;
  int x,i,n,k,ans=0;
  int a[200005]={0};
  bool cmp(int x,int y)
  {
    return x>y;
  }
  int main()
  {
      cin>>n>>k;
      for(i=0;i<n;++i)
      {
          cin>>x;
          a[x]++;
      }
      sort(a,a+200005,cmp);
      for(i=k;i<=200000&&a[i]!=0;++i)
      ans+=a[i];
      cout<<ans<<endl;
      return 0;
  }

Measured memory_bytes: 1024
#include <iostream>
#include <sstream>
#include <queue>
#include <cstdlib>
#include <map>
using namespace std;

class NODE{
public:
	int num;
	int depth;
	int zero;
};

int tbl[]={1,10,100,1000,10000,100000,1000000,10000000};

int swap(const int& n,const int a,int b){
	int x = (n%tbl[7-a+1]) / tbl[7-a];
	int y = (n%tbl[7-b+1]) / tbl[7-b];
	return n-x*tbl[7-a] - y*tbl[7-b] + y*tbl[7-a] + x*tbl[7-b];
}	



int main(){
	queue<NODE> Q;
	NODE p = {1234567,0,0};
	Q.push(p);
	map<int,int> done;
	while(Q.size()){
		NODE q = Q.front(); Q.pop();
		if( done.find(q.num) != done.end())continue;
		done[q.num] = q.depth;
		if( (q.zero+1)%4 ){
			int next = q.zero+1;
			int nextNum = swap(q.num,q.zero,next);
			if( done.find(nextNum) == done.end() ){
				NODE qt = {nextNum,q.depth+1,next};
				Q.push(qt);
			}
		}
		if( q.zero%4 ){
			int next = q.zero-1;
			int nextNum = swap(q.num,q.zero,next);
			if( done.find(nextNum) == done.end() ){
				NODE qt = {nextNum,q.depth+1,next};
				Q.push(qt);
			}
		}
		
		if( q.zero < 4){
			int next = q.zero+4;
			int nextNum = swap(q.num,q.zero,next);
			if( done.find(nextNum) == done.end() ){
				NODE qt = {nextNum,q.depth+1,next};
				Q.push(qt);
			}
		}else{
			int next = q.zero-4;
			int nextNum = swap(q.num,q.zero,next);
			if( done.find(nextNum) == done.end() ){
				NODE qt = {nextNum,q.depth+1,next};
				Q.push(qt);
			}
		}
	}
	string getData,t;
	while( getline(cin,getData) && getData != ""){
		stringstream ss(getData);
		getData = "";
		while(ss >> t)getData+=t;
		int t_i = atoi(getData.c_str());
		cout << done[t_i] << endl;
		
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int T, card[16];


bool is_same_number(int a, int b, int c){
    return (a==b && b==c);
}

bool is_sequence(int a, int b, int c){
    return (a+2==b+1 && b+1==c);
}

bool is_good_set(int a, int b, int c){
    return (is_same_number(a, b, c) || is_sequence(a, b, c));
}

bool is_all_good_set(){
    return (is_good_set(card[0],card[1],card[2]) && is_good_set(card[3],card[4],card[5]) && is_good_set(card[6],card[7],card[8]));
}

int win() {
    sort(card, card+9);
    do{
        if (is_all_good_set()) return 1;
    }
    while (next_permutation(card, card+9));
    return 0;
}

int main() {
    cin >> T;
    for (int t=0; t<T; ++t) {
        for (int i=0; i<9; ++i) cin >> card[i];
        string color;
        for (int i=0; i<9; ++i) {
            cin >> color;
            if (color=="G") card[i] += 10;
            else if (color=="B") card[i] += 20;
        }
        cout << win() << endl;
    }
}



Measured memory_bytes: 3144
// 5/1 漸化式で解き直し

#include <iostream>
#include <cstring>
using namespace std;

const int MAX_N = 110;
const int MAX_W = 10010;
int v[MAX_N];
int weight[MAX_N];

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

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

    // dpを初期化
    // １つ目は0〜Nまで入る。2つ目は0〜Wまで入る。
    int dp[MAX_N][MAX_W];
    memset(dp, 0, sizeof(dp));

    for (int i = 0; i < N; i++) {
        for (int w = 0; w <= W; w++) {
            if (weight[i] <= w) {
                dp[i + 1][w] = max(dp[i][w - weight[i]] + v[i], dp[i][w]);
            } else {
                dp[i + 1][w] = dp[i][w];
            }
        }
    }

    cout << dp[N][W] << endl;
}



Measured memory_bytes: 7400
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")

#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__) << "] "


// CHECK THE LIMITS
typedef long long ll;

const int MOD = 1000000007;
const ll INFLL = 1e18;
const int INF = 1e9;
const int NMAX = 10005;

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

int ind[NMAX], value[NMAX], weight[NMAX],v[NMAX]; 
int dp[NMAX];

bool cmp(const int &a, const int &b)
{
	return v[a] > v[b];
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int h, n;

    

    cin >> h >> n;

    for(int i =0 ; i< n; ++i)
    {
		cin >> value[i] >> weight[i]; 
    }
	for(int i =0; i<= h; ++i)
		dp[i] = INF;

	dp[h] = 0;

	for(int i = h; i>= 0; i--)
	{

		for(int j = 0; j< n; ++j)
		{
			int new_health = max(0, i- value[j]);
				dp[new_health] = min(dp[new_health], dp[i] + weight[j]);
		}
	}
	cout << dp[0];


    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000000
#define ll long long
#define _USE_MATH_DEFINES
using namespace std;
int main()
{
int m,n;
cin>>m>>n;
int a[n];
for(int i=0;i<n;i++)
{
cin>>a[i];
m-=a[i];
}
cout<<max(m,-1);
}


Measured memory_bytes: 3652
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

//C - Walk on Multiplication Table https://atcoder.jp/contests/abc144/tasks/abc144_c

public class ABC144_C // ←Class名変更！！    Program
{
    public static void Main()
    {
        var n = Rl();
        //var c = n / 2;

        double root = Math.Sqrt(n);
        var c = (int)Ceiling(root);   //切り上げ

        var min = n+2;
        for (long i = 1; i <= c; i++)
        {
            var a = n % i;
            if (a == 0)
            {
                var v = n / i;
                if (i + v < min)
                {
                    min = i + v;
                }
            }
        }

        WriteLine($"{min - 2}");
        return;

    } // Main

    public static string Rs() { return ReadLine(); }
    public static char Rc() { var c = ReadLine(); return c[0]; }    //最初の1文字だけ返す
    public static int Ri() { return int.Parse(ReadLine()); }
    public static long Rl() { return long.Parse(ReadLine()); }
    public static char[] Rca() { return ReadLine().ToCharArray(); }
    public static int[] Ria() { return Array.ConvertAll(ReadLine().Split(' '), int.Parse); }
    public static long[] Rla() { return Array.ConvertAll(ReadLine().Split(' '), long.Parse); }
} // Class


Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define va first
#define vb second
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int N, K, S;
int main() {
	cin >> N >> K >> S;

	if (S<=2) {
		for (int i=0; i<K; i++) cout << S << ' ';
		for (int i=K; i<N; i++) cout << 2 << ' ';
	}
	else {
		for (int i=0; i<K; i++) cout << S << ' ';
		for (int i=K; i<N; i++) cout << S-1 << ' ';
	}
}

Measured memory_bytes: 1280
s=input()
f = 0
if s[:7] == 'keyence':
    f = 1
elif s[-7:] == 'keyence':
    f = 1
else:
    for i in range(7):
        if s[:i]+s[-7+i:] == 'keyence':
            f = 1
            break
if f == 1:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vl vector<ll>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvl vector<vector<ll>>
#define print(n) cout<<n<<endl
const int M=100111;
const int inf=1000000007;
const long long INF=1000000000000000007;
using ll=long long;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

unsigned gcd(unsigned a, unsigned b) {
	if(a < b) return gcd(b, a);
	unsigned r;
	while ((r=a%b)) {
		a = b;
		b = r;
	}
	return b;
}


int main(){
	
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	ll ans=b-a+1;
	ll x=c*d/gcd(c,d);

	ll tmp1=b/c+b/d-b/x;
	ll tmp2=(a-1)/c+(a-1)/d-(a-1)/x;
	print(ans-tmp1+tmp2);
		
}	

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <numeric>
#include <iomanip>
#define ll long long
#define intm INT_MAX
#define llm LLONG_MAX

using namespace std;
typedef pair<int,int> P;
const int MOD = 998244353;
const ll mod = 1e9 + 7;
const int mxN = 1e6 + 9;

struct segtree{
    int sizee;
    vector< set<int> > s;

    void init(int n){
        sizee = 1;
        while( sizee < n ) { sizee *= 2; }
        //s.assign( 2*sizee, set<int>() );
        for(int i=0; i < 2*sizee; i++){
            s.push_back( set<int>() );
        }
    }

    void set1(int i, int v){
        set1( i, v, 0, 0, sizee-1 );
    }

    void set1(int i, int v, int x, int lx, int rx){
        if( rx-lx == 0 ){
            s[x].insert(v);
            return;
        }
        int mid = lx + (rx-lx)/2;
        if( i <= mid ) set1(i, v, 2*x+1, lx, mid);
        else{
            set1(i, v, 2*x+2, mid+1, rx);
        }
        s[x] = s[2*x+1];
        for(auto &c: s[2*x+2]) s[x].insert(c);

    }

    set<int> query(int L, int R){
        return query(L, R, 0, 0, sizee-1);
    }

    set<int> query( int L, int R, int x, int lx, int rx ){
        //cout << L << " " << R << " " << x << " " << lx << " " << rx << "\n";
        //completely outside
        if( lx > R || rx < L ) return set<int>();
        //completely inside
        if( lx >= L && rx <= R ) return s[x];
        //otherwise
        int mid = lx + (rx-lx)/2;
        set<int> s1 = query( L, R, 2*x+1, lx, mid );
        set<int> s2 = query( L, R, 2*x+2, mid+1, rx );
        for(auto &c: s2) s1.insert(c);
        return s1;
    }

}	;



int main(){
	ios_base::sync_with_stdio(false); cin.tie(0);
    int k;
    cin >> k;
    int x = 7;
    int ans = 1;
    bool ok = false;
    for(int i=1; i <= 1e7; i++){
        if( x%k == 0 ) { ok = true; break; }
        x = (x*10+7)%k;
        ++ans;
    }
    if( ok  ) cout << ans;
    else{
        cout << -1;
    }



}




Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define ll long long
#define SZ(vvv) ((int)vvv.size())
#define fastIO cout << fixed << setprecision(12), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
using namespace std;

const int N = 5e5 + 5, M = 5e2 + 9, MOD = 1e9 + 7;

int arr[N];

void runtestcase() {
	int n, k;
	cin >> n >> k;
	for (int i = 0; i < n; ++i)
		cin >> arr[i];
	for (int i = k, j = 0; i < n; ++i, ++j) {
		if(arr[i] > arr[j]) {
			cout << "Yes\n";
		} else {
			cout << "No\n";
		}
	}
}


int main() {
	fastIO;
#ifdef LOCAL
	freopen("input.in", "rt", stdin);
//	freopen("output.in", "wt", stdout);
#endif
	int t = 1, tt = 1;
//	cin >> t;
	while(t) {
//		cout << "Case #" << tt << ':' << '\n';
		runtestcase();
		--t, ++tt;
//		cout << '\n';
	}
}


Measured memory_bytes: 4436
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <queue>
#include <list>
#include <stack>
#include <math.h>
#include <map>
#include <unordered_map>
#include <set>
using namespace std;

#define ll long long
#define ull unsigned long long

#define	max	1000000007

ll gcd(ll a, ll b) {
	if (a < b)
		swap(a, b);
	while (ll r = a % b)
		a = b, b = r;
	return b;
}

class mod
{
public:
	ll val;

	mod(ll v)
	{
		val = v % max;
	}

	mod()
	{
		val = 0;
	}

	void operator -=(const mod &v)
	{
		val -= v.val;

		if (val < 0)
			val += max;
	}

	void operator +=(const mod &v)
	{
		if (val + v.val >= max)
			val -= max;
		val += v.val;
	}

	void operator +=(ll &v)
	{
		if (val + v >= max)
			val -= max;
		val += v;
	}

	void operator *=(const mod &v)
	{
		val *= v.val;
		val %= max;
	}

	void operator *=(ll &v)
	{
		val *= v;
		val %= max;
	}

	ll modinv(ll a)
	{
		ll b = max, u = 1, v = 0;
		while (b)
		{
			ll t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		u %= max;
		if (u < 0)
			u += max;
		return u;
	}

	void operator /=(const mod &v)
	{
		val *= modinv(v.val);
		val %= max;
	}

	void operator /=(ll &v)
	{
		val *= modinv(v);
		val %= max;
	}
};

struct p
{
	ll a;
	int b;
	int c;
};

int main()
{
	int n, r;
	cin >> n >> r;
	if (n >= 10)
		n = 10;

	printf("%d", r + 100 * (10 - n));

	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  int a, b, ans = 0;

  cin >> a >> b;

  for (int i = 1; i <= a; i++) {
    if (i != a) {
      ans++;
    }
    else {
      for (int j = 1; j <= b; j++) {
        if (j == a) {
          ans++;
        }
      }
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
N=int(input())
S=[input()[0] for _ in range(N)]
from collections import Counter
S=Counter(S)
M=S["M"]
A=S["A"]
R=S["R"]
C=S["C"]
H=S["H"]
print(M*A*(R+C+H)+(M+A)*R*(C+H)+(M+A+R)*C*H)

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

template<typename T>
struct lca {
  int n, root, l;
  vector<vector<int>> to;
  vector<vector<T>> co;
  vector<int> dep;
  vector<T> costs;
  vector<vector<int>> par;
  lca(int n):n(n),to(n),co(n),dep(n),costs(n) {
    l = 0;
    while ((1<<l) < n) ++l;
    par = vector<vector<int>>(n+1,vector<int>(l,n));
  }
  void addEdge(int a, int b, T c=0) {
    to[a].push_back(b); co[a].push_back(c);
    to[b].push_back(a); co[b].push_back(c);
  }
  void dfs(int v, int d=0, T c=0, int p=-1) {
    if (p != -1) par[v][0] = p;
    dep[v] = d;
    costs[v] = c;
    for (int i = 0; i < to[v].size(); ++i) {
      int u = to[v][i];
      if (u == p) continue;
      dfs(u, d+1, c+co[v][i], v);
    }
  }

  void init(int _root=0) {
    root = _root;
    dfs(root);
    for (int i = 0; i < l-1; ++i) {
      for (int v = 0; v < n; ++v) {
        par[v][i+1] = par[par[v][i]][i];
      }
    }
  }
  // LCA
  int operator()(int a, int b) {
    if (dep[a] > dep[b]) swap(a,b);
    int gap = dep[b]-dep[a];
    for (int i = l-1; i >= 0; --i) {
      int len = 1<<i;
      if (gap >= len) {
        gap -= len;
        b = par[b][i];
      }
    }
    if (a == b) return a;
    for (int i = l-1; i >= 0; --i) {
      int na = par[a][i];
      int nb = par[b][i];
      if (na != nb) a = na, b = nb;
    }
    return par[a][0];
  }
  int length(int a, int b) {
    int c = lca(a,b);
    return dep[a]+dep[b]-dep[c]*2;
  }
  T dist(int a, int b) {
    int c = lca(a,b);
    return costs[a]+costs[b]-costs[c]*2;
  }
};


const int MX = 100005;
struct Edge {
  int to, co, col;
  Edge(int to, int co, int col):to(to),co(co),col(col) {}
};
vector<Edge> es[MX];

vector<ll> ans;
struct Query {
  int col, qid, coeff, y;
  Query(int col, int qid, int coeff, int y):col(col),qid(qid),coeff(coeff),y(y) {}
};
vector<Query> qs[MX];
int cnt[MX];
ll sum[MX];

void dfs2(int v, int p=-1) {
  for (auto q : qs[v]) {
    ll x = -sum[q.col];
    x += (ll)q.y*cnt[q.col];
    ans[q.qid] += x*q.coeff;
  }
  for (auto e : es[v]) {
    if (e.to == p) continue;
    cnt[e.col]++; sum[e.col] += e.co;
    dfs2(e.to, v);
    cnt[e.col]--; sum[e.col] -= e.co;
  }
}

int main() {
  int n, q;
  cin >> n >> q;
  lca<ll> g(n);
  rep(i,n-1) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    --a; --b;
    es[a].emplace_back(b,d,c);
    es[b].emplace_back(a,d,c);
    g.addEdge(a,b,d);
  }
  g.init();
  ans = vector<ll>(q);
  rep(i,q) {
    int x, y, a, b;
    cin >> x >> y >> a >> b;
    --a; --b;
    int c = g(a,b);
    ans[i] = g.costs[a]+g.costs[b]-g.costs[c]*2;
    qs[a].emplace_back(x,i,1,y);
    qs[b].emplace_back(x,i,1,y);
    qs[c].emplace_back(x,i,-2,y);
  }
  dfs2(0);
  rep(i,q) {
    printf("%lld\n",ans[i]);
  }
  return 0;
}

Measured memory_bytes: 44660
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n,ans=-(1<<30);
    cin>>n;
    int a;
    cin>>a;
    for(int i=0;i<n-1;i++){
        int b;
        cin>>b;
        ans=max(ans,b-a);
        a=min(a,b);
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 3136
sx,sy,tx,ty=map(int,input().split())
dx=tx-sx;dy=ty-sy

ans=''
ans+='R'*dx+'U'*dy
ans+='L'*dx+'D'*dy
ans+='D'+'R'*(dx+1)+'U'*(dy+1)+'L'
ans+='U'+'L'*(dx+1)+'D'*(dy+1)+'R'

print(ans)

Measured memory_bytes: 38288
# 入力「edges:隣接行列」「num_v:頂点数」「start:始点」
def shortest_path(edges, num_v, start):
    inf = float("inf")
    dist = [inf for _ in range(num_v)]
    dist[start] = 0
    # 辺の緩和
    for i in range(num_v):
        for edge in edges:
            if dist[edge[0]] != inf and dist[edge[1]] > dist[edge[0]] + edge[2]:
                dist[edge[1]] = dist[edge[0]] + edge[2]
                if i == num_v - 1 and edge[1] == num_v - 1:
                    print("inf")
                    exit()
    return dist

n, m = [int(i) for i in input().split()]
edges = []
for _ in range(m):
    a, b, c = [int(i) for i in input().split()]
    edges.append([a-1, b-1, -c])
out = shortest_path(edges,n,0)
print(-out[-1])


Measured memory_bytes: 3316
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
using namespace std;
long long n, k,dp[101][4][4][4];
long long a[101];
long long solve(int i, int m1, int m2) {
	long long sum = 0;
	if (i == n+1) return 1;
	for (int j = 1; j <= 3; j++) {
		if ((!(j == m1&&j == m2) || (a[i + 1] == m1))
			&&!(a[i]==m1&&a[i]==m2)&&(a[i]==-1||a[i]==j)) {
			if (dp[i][j][m1][m2] != -1) {
				sum += (dp[i][j][m1][m2]%10000);
			}
			else {
				sum += ((dp[i][j][m1][m2] = solve(i + 1, j, m1))%10000);
			}
		}
	}
	return (sum%10000);
}
int main() {
	while (cin >> n >> k) {
		for (int i = 0; i <= n; i++) a[i] = -1;
		for (int i = 0; i < k; i++) {
			int b, c;
			cin >> b >> c;
			a[b] = c;
		}
		for (int i = 0; i <= n; i++) {
			for (int j = 0; j < 4; j++) {
				for (int x = 0; x < 4; x++) {
					for (int y = 0; y < 4; y++) dp[i][j][x][y] = -1;
				}
			}
		}
		long long sum = 0;
		for (int i = 1; i <= 3; i++) {
			if (a[1] == -1||a[1]==i) {
				for (int j = 1; j <= 3; j++) {
					if ((a[2] == -1) || (a[2] == j)) {
						sum += (solve(3, j, i)%10000);
					}
				}
			}
		}
		cout << sum%10000 << endl;
	}
}

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

using namespace std;
typedef long long ll;
int main(){
    ll n;cin>>n;
    for(int i=-120;i<=120;i++){
        for(int j=-120;j<=120;j++){
            if(n==(i*i*i*i*i)-(j*j*j*j*j)){
                cout << i <<" "<<j<<endl;
                return 0;
            }
        }
    }
}


Measured memory_bytes: 3608
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        String str;
        while(true){
            str = sc.next();
            if (str.charAt(0)==('-'))
                break;

            int n = sc.nextInt();

            for (int i = 0; i < n; i++) {
                int h = sc.nextInt();
                String a = str.substring(0, h);
                String b = str.substring(h);
                str = b + a;
            }
            System.out.println(str);
        }
    }
}



Measured memory_bytes: 26320
#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 M_PI
 
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;

int h, w = 5;

int score(vector<queue<int> > vq){
    vector<queue<int> > vq_next(w);
    int res = 0;
    REP(i,h){
        VI a(w+1);
        REP(j,w){
            if (!vq[j].empty()){
                a[j] = vq[j].front();
                vq[j].pop();
            }
        }
        REP(j,w){
            int k = 0;
            while (a[j+k] == a[j] && j+k < w) k++;
            if (k >= 3){
                res += k * a[j];
                REP(l,k) a[j+l] = 0;
            }
        }
        REP(j,w){
            if (a[j] != 0) vq_next[j].push(a[j]);
        }
    }
    if (res == 0) return res;
    else return res + score(vq_next);
}

int main() {
    while (cin >> h && h){
        vector<queue<int> > vq(w);
        VVI a(h, VI(w));
        REP(i,h) REP(j,w) cin >> a[i][j];
        REP(j,w) REP(i,h) vq[j].push(a[h-1-i][j]);
        cout << score(vq) << endl;
    }
    return 0;
}

Measured memory_bytes: 3148
#include<bits/stdc++.h>
using namespace std;
int max1=0,a[100001],x,n;
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	{
		scanf("%d",&x);
		if (x==0) a[1]++;
		else 
		{
			a[x]++;
			a[x+1]++;
			a[x-1]++;
		}
	}
	for (int i=0;i<=100000;i++)
	  max1=max(max1,a[i]);
	printf("%d",max1);
	return 0;
}

Measured memory_bytes: 640
//#include "stdc++.h"
#include<bits/stdc++.h>
#include<iostream>
#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;
typedef vector<int> vi;
#define m1 make_pair
#define pb push_back
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
inline ll gcd(ll a,ll b){if(a==0) return b;return gcd(b%a,a);}
inline ll power(ll a,ll n,ll m){if(n==0) return 1;ll p=power(a,n/2,m);p=(p*p)%m;if(n%2) return (p*a)%m;else return p; }
#define flush fflush(stdout)
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
int main()
{
    int n,w;
    cin>>n>>w;
    pair<int,ll> p[n];
    for(int i=0;i<n;i++)
    {
        cin>>p[i].first>>p[i].second;
    }
    ll dp[w+1][n];
    //memset(dp,(ll)0,sizeof(dp));
    //for(int i=0;i<n;i++)
      //  dp[0][i]=0;
    for(int i=0;i<=w;i++)
        for(int j=0;j<n;j++)
            dp[i][j]=0;
    int wi;ll vi;
    for(int i=1;i<=w;i++)
    {
        for(int j=0;j<n;j++)
        {
            wi=p[j].first;
            vi=p[j].second;
            if(wi<=i)
            {
                if(j>=1)
                dp[i][j]=max(dp[i][j-1],vi+dp[i-wi][j-1]);
                else
                    dp[i][j]=vi;
            }
            else
                dp[i][j]=((j>=1)?dp[i][j-1]:(ll)0);
           // cout<<dp[i][j]<<endl;
        }
    }
    ll ans=0;
    for(int i=0;i<n;i++)
        ans=max(ans,dp[w][i]);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 78336
#include<bits/stdc++.h>
#define int ll

#define f			first
#define sz(a)       ((int)(a).size())
#define s			second
#define all(v)		v.begin(),v.end()
#define pii 		pair<int,int>
#define vpii 		vector<pii>
#define eb			emplace_back
#define pb			push_back
#define fo(i,n)		for(int i=0;i<n;i++)
#define Fo(i,k,n)	for(int i=k;i<n;i++)
#define vi			vector<int>

using namespace std;
using ll  = long long;
using lld = long double;

const int oo = 0x3f3f3f3f;
const ll MOD = 1000000007;

const int N = 1e5 + 10;
int hit[N + 2];

signed main(){

#ifndef ONLINE_JUDGE
	//freopen("in.txt" , "r" , stdin);
#endif
	ios_base::sync_with_stdio(0);cin.tie(0);


    int n , x , m;
    cin >> n >> x >> m;
    int f = x;
    hit[f] = 1; 
    vi before_cycle , cycle;
    int ss = f;
    for(int i = 1 ; i < n ; i++){
        f = (f * f) % m;
        if(hit[f] == 0)
        ss += f;
        if(f == 0){
            cout << ss << '\n';
            return 0;
        }
        if(hit[f] == 3)
            break;
        hit[f]++;
        if(hit[f] == 2)
            cycle.pb(f);
    }

    int ans = 0;
    //return 0;
    for(int i = 0 ; i < m ; i++)
        if(hit[i] == 1)
            ans += i , before_cycle.pb(i); 
    
    int sum = 0;
    for(int i : cycle)
        sum += i;

    int numOfHits = cycle.size();
    n -= before_cycle.size();
    n = max(n , 0LL);
    if(numOfHits)
        ans += sum * (n / numOfHits) , n %= numOfHits;

    for(int i = 0 ; i < n ; i++)
        ans += (long long)cycle[i];

    cout << ans << '\n';
    
    return 0;

}



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

using namespace std;

int main()
{
    int h, w;
    long long ans=0;
    cin >> h >> w;

    if(h >w){
        for(int i=0;i<h;i++){
            cout<<w;
        }
    }else {
        for (int i = 0; i < w; i++)
        {
            cout << h;
        }
    }
    
}

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

int main () {
  
  int N; cin >> N;
  
  vector<int> A(N);
  vector<int> B(N);
  vector<int> C(N - 1);
  
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  
  for (int i = 0; i < N; i++) {
    cin >> B[i];
  }
  
  for (int i = 0; i < N - 1; i++) {
    cin >> C[i];
  }
  
  int base = 0;
  
  for (int i = 0; i < N; i++) {
    base += B[i];
  }
  
  for (int i = 0; i < N - 1; i++) {
    if (A[i + 1] - A[i] == 1) base += C[A[i] - 1];
  }
  
  cout << base << endl;

}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath> // 変数名にy1が使えなくなるかも…。
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <limits>
#include <functional>
#include <string>

typedef __int128_t int128_t;
std::istream &operator>>(std::istream& input, int128_t& value) { // int128_tの入力。入力が64bitに収まる前提。
    long long tmp; input >> tmp; value = tmp;
    return input;
}
std::ostream &operator<<(std::ostream& output, const int128_t value) { // int128_tの出力。出力が64bitに収まる前提。
    output << (long long)value;
    return output;
}

int64_t imax(const int64_t a, const int64_t b) { return std::max(a, b); } // std::max, std::min は型が違うとエラーになるため、ラッパーを作る。
int64_t imin(const int64_t a, const int64_t b) { return std::min(a, b); }

#define rep(i, begin, end) for(int64_t i = (begin); i <= (end); i++)
#define rev(i, begin, end) for(int64_t i = (begin); (end) <= i; i--)

#define input1(begin, end, v1) v1.resize((end)+1); for (int i = (begin); i <= (end); i++) { std::cin >> v1[i]; }
#define input2(begin, end, v1, v2) v1.resize((end)+1); v2.resize((end)+1); for (int i = (begin); i <= (end); i++) { std::cin >> v1[i] >> v2[i]; } 
#define input3(begin, end, v1, v2, v3) v1.resize((end)+1); v2.resize((end)+1); v3.resize((end)+1); for (int i = (begin); i <= (end); i++) { std::cin >> v1[i] >> v2[i] >> v3[i]; } 

std::vector<int> irange(const int begin, const int end) {
    std::vector<int> ret; for (int i = begin; i <= end; i++) { ret.push_back(i); }
    return ret;
}

template <typename T>
void printvec(const std::vector<T>& vec) {
    for (int i = 0; i < vec.size(); i++) { std::cout << vec[i] << " "; } std::cout << std::endl;
}

std::vector<int> digit(int128_t n, const int128_t b) {
    // 基数bでの表示。0は0桁。非常に大きい数を入れても問題ないようにint128_tとする。intやlong longを入れても問題ないはず。
    // size()をとれば桁数になる。
    assert(1 < b);
    std::vector<int> ret;
    while (0 < n) {
        ret.push_back(n % b);
        n /= b;
    }
    return ret;
}

int N, A, B;
//int128_t ;
//std::vector<int> ;
//std::vector<int128_t> ;
//std::string ;
//std::vector<std::string> ;
//double ;
//std::vector<double> ;

int main(int argc, char **argv) {
    std::cin >> N >> A >> B;
    
    int128_t ret = 0;

    rep (i, 1, N) {
        auto dig = digit(i, 10);
        int tmp = 0;
        for (int j : dig) {
            tmp += j;
        }
        if (A <= tmp && tmp <= B) {
            ret += i;
        }
    }

    std::cout << ret << std::endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

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

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
int dp[5050];
int main(){
	memset(dp, 0, sizeof(dp));
	rep(i,5050)dp[i]=INF;
	rep(i,20)rep(j,20)rep(k,20){
		int cost =(i*380)-(i/5*380)+(j*550)-(j/4*330)+(k*850)-(k/3*306);
		int w =i*200+j*300+k*500;
		if(w<=5000){
			dp[w]=min(dp[w],cost);
		}
	}
	int n;
	while(cin>>n,n){
		cout <<dp[n]<<endl;
	}
	return 0;
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define ff first
#define ss second
typedef long long ll;
ll power(ll a, ll b){//a^b
    ll res=1;
    a=a%MOD;
    while(b>0){
        if(b&1){res=(res*a)%MOD;b--;}
        a=(a*a)%MOD;
        b>>=1;
    }
    return res;
}
bool isPalin(string s){
    if (s==string(s.rbegin(),s.rend()))
        return true;
    return false;
}
ll fermat_inv(ll y){return power(y,MOD-2);}
ll gcd(ll a, ll b){return (b==0)?a:gcd(b,a%b);}
int main(){
    ll t=1;
    //cin>>t;
    while(t--){
        string s;
        cin>>s;
        if(s=="RRR")
            cout<<"3\n";
        else if(s=="RRS"||s=="SRR")
            cout<<"2\n";
        else if(s!="SSS"||s=="RSR")
            cout<<"1\n";
        else
            cout<<"0\n";
    }
    return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>
#include <iomanip>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;

using namespace std;

int main(void){
    double total=0, x[10], y[10];
    int N;
    cin>>N;
    rep(i, N) cin>>x[i]>>y[i];
    rep(i, N){
        for(int j=i+1; j<N; j++){
            total+=sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
        }
    }
    cout<<setprecision(10)<<total*2/N<<endl;
    return 0;
}


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

int main() {
 string S;
 cin >> S;
 ll K;
 cin >> K;
 
 if(K <= S.size()){
   bool flag = false;
   char c = '0';
   for(int i = 0;i<=K-1;i++){
     if(S[i] != '1'){
       c = S[i];
       flag = true;
       break;
     }
   }
   if(flag) cout << c << endl;
   else cout << 1 << endl;
 }
  
  if(K > S.size()){
    bool flag2 = false;
   char c2 = '0';
   for(int i = 0;i<S.size();i++){
     if(S[i] != '1'){
       c2 = S[i];
       flag2 = true;
       break;
     }
   }
   if(flag2) cout << c2 << endl;
   else cout << 1 << endl;
  }
}


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

int main(void){
    int cards[4][13]={0},a,b=0;
    char c;
    cin>>a;
    for(int i=0;i<a;i++){
        cin>>c>>b;
        if(c=='S'){
            cards[0][b-1] = 1;
        }
        if(c=='H'){
            cards[1][b-1] = 2;
        }
        if(c=='C'){
            cards[2][b-1] = 3;
        }
        if(c=='D'){
            cards[3][b-1] = 4;
        }
    }
    for(int v=0;v<=3;v++){
        for(int i=1;i<14;i++){
            if(cards[v][i-1] == 0&&v==0){
                cout<<"S "<<i<<endl;
            }
            if(cards[v][i-1] == 0&&v==1){
                cout<<"H "<<i<<endl;
            }
            if(cards[v][i-1] == 0&&v==2){
                cout<<"C "<<i<<endl;
            }
            if(cards[v][i-1] == 0&&v==3){
                cout<<"D "<<i<<endl;
            }
        } 
    }
}


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

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

using namespace std;

/*long C(long n, long r){
    if(n < r) return 0;
    long p[n+1][n+1];
    p[0][0] = 1;
    for(int i = 1; i <= n; i++){
        p[i][0] = 1;
        p[i][i] = 1;
        for(int j = 1; j <= i-1; j++){
            p[i][j] = p[i-1][j] + p[i-1][j-1];
        }
    }
    return p[n][r];
}*/

void solve()
{
    string S;
    cin >> S;
    int n = S.length();
    string fs = S.substr(0, n/2);
    string bs = S.substr(n-(n/2), n/2);
    reverse(bs.begin(), bs.end());
    int ans = 0;
    REP(i, n/2){
        if(fs[i] != bs[i]) ans++;
    }
    cout << ans << endl;
}

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

Measured memory_bytes: 256
'use strict';

function Main(input) {
  const a = Number(input.split("\n")[0])
  const e = Number(input.split("\n")[4])
  const k = Number(input.split("\n")[5])
  
  if (e - a <= k) {
    console.log("Yay!")
  } else {
    console.log(":(")
  }
};

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());


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

int main(){
    int N, M;
    cin >> N >> M;
    int ans = -1;
    vector<int> V(N+1, -1);
    bool flag = true;
    for(int i=0;i<M;i++){
        int S, C;
        cin >> S >> C;
        if (V[S] == -1) V[S] = C;
        else if (V[S] != C) flag = false;
    }

    if (N >= 2 && V[1] == 0) flag = false;

    if (flag){
        if(N==1) ans = max(0, V[1]);
        else if(N==2) ans = max(1, V[1])*10 + max(0, V[2]);
        else ans = max(1, V[1])*100 + max(0, V[2])*10 + max(0, V[3]);
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var a, b, c int
	fmt.Scan(&a, &b, &c)

	if a % 2 == 0 || b % 2 == 0 || c % 2 == 0 {
		fmt.Println(0)
		return
	}

	result := min(a*b, b*c, c*a)

	fmt.Println(result)
}

func min(x, y, z int ) int {
	minV := x
	if minV > y {
		minV = y
	} else if minV > z {
		minV = z
	}
	return minV
}


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

#define REP(i, a, b) for (int i = (a); i <= (b); ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define FORV(a, A) for (auto &a : A)

using namespace std;

using ll = long long;

void Main()
{
   int A, P;
   cin >> A >> P;
   cout << (A * 3 + P) / 2 << endl;
   return;
}

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


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

int main(){
	int n, m;
	int maxL= 0;
	int minR= 100001;

	std::cin>>n>>m;

	for(int i=0; i<m; i++){
		int tmpL, tmpR;
		std::cin>>tmpL>>tmpR;

		maxL= std::max(maxL, tmpL);
		minR= std::min(minR, tmpR);
	}

	std::cout<<std::max(0, minR- maxL +1)<<std::endl;

	return 0;
}

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

L = 1000000007

state = [0,0,0]

M = [0,0,0]
for a in A:
    t = None
    n = 0
    for i,s in enumerate(state):
        if s == a:
            t = i
            n += 1
    if n == 0:
        break
    M[n-1] += 1
    state[t] += 1

if n > 0:
    x = 2**30 % L
    y = 3**19 % L


    k = M[1] % x
    l = M[2] % y
    r = 2**k * 3**l % L
    print(r)
else:
    print(0)


Measured memory_bytes: 20756
#include<bits/stdc++.h>//
#define ll long long
using namespace std;
int main()
{
    ll arr[5],ans,x,i,j,k;
    for(i=0;i<5;i++){
        cin>>x;
        if(x==0){
            ans=i+1;
        }
    }
    cout<<ans<<endl;
    return 0;
}







Measured memory_bytes: 3564
// Author: Vamsi Krishna Reddy Satti
// With love for Competitive Programming!
 
#include <bits/stdc++.h>
using namespace std;
 
#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define cout_precision cout.setf(ios::fixed); cout.precision(32);
 
using ll = int64_t; using vll = vector<ll>; using vvll = vector<vll>;
using pll = pair<ll, ll>; using vpll = vector<pll>; using vvpll = vector<vpll>;
using ld = long double;
 
// ------------------------------------------------------------------------------------------------

ll ans;
string s;

int main() {
    fast_io; cout_precision;
    cin >> s;
    ans = 0;
    for (ll i = 1; i < (ll) s.length(); i++) {
        if (s[i] != s[i - 1]) {
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
fun main(args: Array<String>) {
    val s = readLine()!!
    val t = readLine()!!
    for (i in 0..(s.length - t.length)) {
        var includeFlg = true
        for (j in 0 until t.length) {
            if (s[s.length - 1 - i - j] != '?' && (s[s.length - 1 - i - j] != t[t.length - 1 - j])) {
                includeFlg = false
                break
            }
        }
        if (includeFlg) {
            val s2 = s.replaceRange(s.length - t.length - i, s.length - i, t)
            val s3 = s2.replace("?", "a")
            println(s3)
            return
        }
    }
    println("UNRESTORABLE")
}

Measured memory_bytes: 37780
N = int(input())
A = [list(map(int, input().split())) for _ in range(2)]
b = [0] + A[0]
c = [0] + A[1]

if N == 1:
    print(A[0][0] + A[1][0])
    exit()

for i in range(1, N):
    b[i+1] += b[i]
    c[i+1] += c[i]


ans = 0
for i in range(1, N):
    tmp = (b[i]-b[0]) + (c[-1]-c[i-1])
    ans = max(ans, tmp)

print(ans)

Measured memory_bytes: 62064
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <bitset>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

	int root(int x)
	{
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool issame(int x, int y)
	{
		return root(x) == root(y);
	}

	bool merge(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion
#pragma region GCD
ll gcd(ll a, ll b)
{
	if (b == 0)return a;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region LCM
ll lcm(ll a, ll b)
{
	return a / gcd(a, b) * b;
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion


int main()
{
	int l, r, d; cin >> l >> r >> d;
	int res = 0;
	for (int i = l; i <= r; ++i)if (i%d == 0)++res;
	cout << res << endl;
}

Measured memory_bytes: 3572
n = int(input())
ans = []
if n == 0:
    print(0)
    exit()

while True:
    if n % -2 == -1:
        ans.append(1)
        n //= -2
        n += 1
    else:
        ans.append(n % -2)
        n //= -2
    if n == 1 or n == 0:
        break
ans.append(n)
result = map(str, ans[::-1])
print("".join(result))

Measured memory_bytes: 3064
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	final int MOD = 1000000007;
	final int MAX = Integer.MAX_VALUE;
	final long LMAX = Long.MAX_VALUE;
	int len = (int)1e6 + 1;

	void doIt() {
		String S = sc.next();
		int N = S.length();
		StringBuilder strb = new StringBuilder(S);
		strb.reverse();
		if(!S.equals(strb.toString())) {
			System.out.println("No");
			return;
		}
		String s = S.substring(0, (N - 1)/2);
		strb = new StringBuilder(s);
		strb.reverse();
		if(!s.equals(strb.toString())) {
			System.out.println("No");
			return;
		}
		s = S.substring((N + 3)/2 - 1);
		strb = new StringBuilder(s);
		strb.reverse();
		if(!s.equals(strb.toString())) {
			System.out.println("No");
			return;
		}
		System.out.println("Yes");
	}

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

}


Measured memory_bytes: 22484
a,b,c,d = map(int,input().split())
if b<=c or d<=a:
    print(0)
elif a<=c<=d<=b:
    print(d-c)
elif c<=a<=b<=d:
    print(b-a)
elif a<=c<=b<=d:
    print(b-c)
elif c<=a<=d<=b:
    print(d-a)


Measured memory_bytes: 9060
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define RFOR(i, start, end) for (int i = start; end <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
#define INF32 1'050'000'000
#define INF64 4'000'000'000'000'000'000
using ll = long long;
using namespace std;
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;
}

template <class T> vector<T> divisor(T N) {
    vector<T> ans;
    for (long long i = 1; i * i <= N; i++) {
        if (N % i == 0) {
            ans.push_back(i);
            if (i != 1 && i * i != N) {
                ans.push_back(N / i);
            }
        }
    }
    ans.push_back(N);

    return ans;
}

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

    int N, M;
    cin >> N >> M;
    auto div = divisor(M);
    SORT(div);
    int ans = *(lower_bound(ALL(div), (M / N) + 1) - 1);

    std::cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <sstream>
#include <numeric>
#include <set>
#include <map>

#define rep(i, j) for(int i = 0; i < j; i++)
#define all(i) i.begin(), i.end()

using namespace std;

struct dat_st{ int ac, pn, tid; };
bool compare(dat_st &t0, dat_st &t1)
{
    if (t0.ac == t1.ac) 
    {
		if(t0.pn == t1.pn){ return t0.tid > t1.tid; }
        return t0.pn > t1.pn; 
    }
    return t0.ac < t1.ac;
}
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int T, P, R; while( cin >> T >> P >> R && T != 0)
	{
		vector<dat_st> dat(T + 1);
		vector<vector<int>> wr(T + 2, vector<int>(P + 2, 0));
		rep(i, R)
		{
			int tid, pid, tm; cin >> tid >> pid >> tm;
			string ms; cin >> ms;
			rep(j, T){ dat[j + 1].tid = j + 1; }
			if( ms == "CORRECT" )
			{
				dat[tid].ac += 1;
				dat[tid].pn += wr[tid][pid] * 1200 + tm; 
			}
			else{ wr[tid][pid] += 1; }
		}
		dat.erase(dat.begin());
		sort(dat.rbegin(), dat.rend(), compare);
		rep(i, T){ printf("%d %d %d\n", dat[i].tid, dat[i].ac, dat[i].pn); }
	}
	return 0;
}

Measured memory_bytes: 3360