akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
/* clang-format on */

int N;
ll a[3010];

bool done[3010][3010];
ll dp[3010][3010];

ll solve(int l, int r) {
  if (l > r) return 0;
  if (done[l][r]) return dp[l][r];
  ll& res = dp[l][r];
  int turn = (l + r) % 2;
  if (turn != N % 2) {
    ll resL = solve(l + 1, r) + a[l];
    ll resR = solve(l, r - 1) + a[r];
    res = max(resL, resR);
  } else {
    ll resL = solve(l + 1, r) - a[l];
    ll resR = solve(l, r - 1) - a[r];
    res = min(resL, resR);
  }
  done[l][r] = true;
  return res;
}

int main() {
  while (cin >> N) {
    for (int i = 0; i < N; i++) cin >> a[i];
    memset(done, false, sizeof(done));
    cout << solve(0, N - 1) << endl;
  }
  return 0;
}


Measured memory_bytes: 80000
N = input()
keta = len(N) - 1
def rec(list1,list2,initial,time):
    for e in list1:
        for b in [0,1,2,3]:
            if b == 0:
                e_copy = e + "3"
                list2.append(e_copy)
            elif b == 1:
                e_copy = e + "5"
                list2.append(e_copy)
            elif b == 2:
                e_copy = e + "7"
                list2.append(e_copy)
            elif b == 3:
                e_copy = e
                list2.append(e_copy)
    list1.clear()
    # initial + 1 がn回目のループ
    if initial + 1 >= time :
        return list2
    else:
        return rec(list2,list1,initial + 1, time)
l1 = ["3","5","7"]
l2 = []
result = rec(l1,l2,0,keta)
result = [int(e) for e in result if e.count("3")*e.count("5")*e.count("7") >= 1]
result = list(set(result))
result.sort()
count = 0
for e in result:
    if int(N) < e:
        break
    count += 1
print(count)

Measured memory_bytes: 24952
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;
 
#define rep(i, n) for(int i = 0; i < (int)(n);    i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef std::vector<int> vi;
typedef std::vector<std::vector<int>> vvi;

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


int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  int A[3][3] = { {0} };
  rep(i,3) rep(j,3) std::cin >> A[i][j];

  int N; std::cin >> N;
  std::vector<int> b(N);
  rep(i,N) std::cin >> b[i];

  bool C[3][3] = { {false} };
  rep(i,N) {
    rep(l,3) rep(k,3) if ( A[l][k] == b[i] ) C[l][k] = true;
  }

  // check
  rep(i,3) {
    bool judge = true;
    rep(j,3) if ( !C[i][j] ) judge = false;
    if ( judge ) {
      std::cout << "Yes" << std::endl;
      return 0;
    }
  }

  rep(i,3) {
    bool judge = true;
    rep(j,3) if ( !C[j][i] ) judge = false;
    if ( judge ) {
      std::cout << "Yes" << std::endl;
      return 0;
    }
  }

  bool judge = true;
  rep(i,3) if( !C[i][i] ) judge = false;
  if ( judge ) {
    std::cout << "Yes" << std::endl;
    return 0;
  }

  judge = true;
  rep(i,3) if( !C[i][2-i] ) judge = false;
  if ( judge ) {
    std::cout << "Yes" << std::endl;
    return 0;
  }

  std::cout << "No" << std::endl;

  return 0;
}


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

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, n, m) for (int i = n; i < m; i++)
#define ll long long int

using namespace std;

int size = 100000;

int main()
{
  int n;
  cin >> n;
  int a[size], b[size], c[size];
  int dp[size][3] = {}; // dp[i][j]はi+1日目にjを選んだときのi+1日目の最大値
  REP(i,n) {
    cin >> a[i] >> b[i] >> c[i];
  }

  dp[0][0] = a[0];
  dp[0][1] = b[0];
  dp[0][2] = c[0];

  FOR(i, 1, n) {
    dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + a[i];
    dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + b[i];
    dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + c[i];
  }

  int result = max(max(dp[n-1][0], dp[n-1][1]), dp[n-1][2]);
  cout << result << endl;
}


Measured memory_bytes: 2560
#include <iostream>

using namespace std;

int main(){
	int A, B, C;
	cin >> A >> B >> C;
	bool flag = false;


	for(int i = 0; i < B; i++){
		int number = B * i + C;
		if(number % A == 0){
			flag = true;
			break;
		}
	}

	if(flag){
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	}

	return 0;
}




Measured memory_bytes: 256
# D - Friends
def add_to_graph(A, B):
  global graph

  graph.setdefault(A, [])
  graph[A].append(B)


def add_to_group(p):
  global que
  global group
  global is_finished

  que.append(p)
  group.add(p)
  is_finished[p] = True


from collections import deque

N, M = map(int, input().split())
graph = dict()

for i in range(M):
  A, B = map(int, input().split())
  add_to_graph(A, B)
  add_to_graph(B, A)

# その人を探索したかどうかのフラグ
is_finished = [False] * (N + 1)
groups = []

for i in range(1, N + 1):
  que = deque()
  group = set()

  if not is_finished[i]:
    add_to_group(i)

    while len(que) > 0:
      p = que.popleft()
  
      if p in graph.keys():
        for v in graph[p]:
          if not is_finished[v]:
            add_to_group(v)
    
      groups.append(group)

ans = 0

for g in groups:
  ans = max(ans, len(g))

print(ans)

Measured memory_bytes: 82528
#
# abc064 a
#
import sys
from io import StringIO
import unittest

def input():
    return sys.stdin.readline().rstrip()

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """4 3 2"""
        output = """YES"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """2 3 4"""
        output = """NO"""
        self.assertIO(input, output)


def resolve():
    r, g, b = map(int, input().split())
    x = 100*r + 10*g + b
    ans = "NO"
    if x % 4 == 0:
        ans = "YES"
    print(ans)


if __name__ == "__main__":
    # unittest.main()
    resolve()


Measured memory_bytes: 16100
n=int(input())
a=[0]+list(map(int,input().split()))+[0]

sum_dist=0
for i in range(1,n+2):
  sum_dist+=abs(a[i]-a[i-1])

for i in range(1,n+1):
  t_dist=sum_dist
  t_dist-=abs(a[i]-a[i-1])+abs(a[i+1]-a[i])
  t_dist+=abs(a[i+1]-a[i-1])
  print(t_dist)

Measured memory_bytes: 14048
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}

void main()
{
  int w, a, b; readV(w, a, b);

  if (a > b) swap(a, b);
  writeln(max(0, b-(a+w)));
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int n;
    cin >> n;
    int* p = new int[n];
    for(int i=0; i<n; i++){
        cin >> p[i];
    }
    int ret = 0;
    for(int i=0; i<n-2; i++){
        if((p[i]<p[i+1]&&p[i+1]<p[i+2])||(p[i+2]<p[i+1]&&p[i+1]<p[i])){
            ret += 1;
        }
    }
    cout << ret << endl;
    return 0;
}

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

int main() {
    string s, t;
    cin >> s >> t;

    int dif = 0;

    for(int i = 0 ; i < s.size() ; i++){
        if(s.at(i) != t.at(i)){
            dif++;
        }
    }

    cout << dif << endl;
}

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

using namespace std;
#define rep_i(i, n) for (int i = 0; i < (n); ++i)
#define rep_ll(i, n) for (long long i = 0; i < (n); ++i)
#define r_rep_i(i, start, end) for (int i = (start); i < (end); ++i)
#define r_rep_ll(i, start, end) for (long long i = (start); i < (end); ++i)
#define debug_vi(v) copy((v).begin(), (v).end(), ostream_iterator<int>(cout, " "));
#define debug_vll(v) copy((v).begin(), (v).end(), ostream_iterator<long long>(cout, " "));
#define debug_vd(v) copy((v).begin(), (v).end(), ostream_iterator<double>(cout, " "));
#define sort_v(v) sort((v).begin(), (v).end()); //昇順
#define d_sort_vi(v) sort((v).begin(), (v).end(), greater<int>()); //降
#define d_sort_vd(v) sort((v).begin(), (v).end(), greater<double>()); //昇順
#define say(t) cout << (t) << endl;
#define sum_vi(v) accumulate((v).begin(), (v).end(), 0);
#define sum_vll(v)accumulate((v).begin(), (v).end(), 0LL);

int main(){
  int n, q;
  cin >> n >> q;
  vector< stack<int> > v(n);
  rep_i(i, n){
    stack<int> a;
    v.push_back(a);
  }

  int tmp, tmp2, tmp3;
  rep_i(i, q){
    cin >> tmp;
    switch (tmp)
    {
    case 0:
      cin >> tmp2 >> tmp3;
      v[tmp2].push(tmp3);
      break;
    case 1:
      cin >> tmp2;
      if(v[tmp2].empty()){
        break;
      }
      say(v[tmp2].top());
      break;
    case 2:
      cin >> tmp2;
      if(v[tmp2].empty()){
        break;
      }
      v[tmp2].pop();
      break;
    default:
      break;
    }
  }
}


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

int main() {
    int N, M;
    cin >> N >> M;
    int MOD = 1000000007;
    int INF = 2147483647;

    vector<bool> broken(N+10, false);
    for(int i=0; i<M; i++){
        int c;
        cin >> c;
        broken.at(c) = true;
    }

    long long int dp[100010];
    dp[0]=1;
    dp[1]=1;
    if(broken[0]) dp[0]=0;
    if(broken[1]) dp[1]=0;
     
    for(int i=2; i<=N; i++){
        if(broken[i]){
            dp[i] = 0;
        }
        else{
            dp[i] = (dp[i-1] + dp[i-2]) %MOD;
        }
    }

    cout << dp[N] << endl;

}

Measured memory_bytes: 1024
#include <cstdio>
#include <algorithm>
#define Union(x,y) fa[Find(x)]=Find(y)
int n,m,fa[200003],ans=-(1<<30),s=1,a[200003];
int Find(int x){
    return x==fa[x]?x:fa[x]=Find(fa[x]);
}
int main(){
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++) fa[i]=i;
    while(m--){
        int a,b;scanf("%d%d",&a,&b);
        int roota=Find(a),rootb=Find(b);
        if(roota!=rootb) Union(a,b);
    }
    for(int i=1;i<=n;i++) a[i]=Find(fa[i]);
    std::sort(a+1,a+1+n);
    for(int i=2;i<=n;i++){
        if(a[i]==a[i-1]) ++s;
        else ans=std::max(ans,s),s=1;
    }
    printf("%d\n",std::max(ans,s));
    return 0;
}

Measured memory_bytes: 9544
#include<bits/stdc++.h>
using namespace std;
bool flag[505];
int ans,a,n;
int main() {
    scanf("%d",&n);
    while(n--) {
        scanf("%d",&a);
        ans+=(!flag[a]);
        flag[a]=true;
    }
    return printf("%d\n",ans),0;
}

Measured memory_bytes: 256
/*input
redcoder
*/
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"
typedef vector<int> vii;
typedef pair<int,int> pii;
#define F first
#define S second
#define pb push_back
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

void solve(){
	string s;
	cin>>s;
	int ans =0 ;
	for(int i=0;i<s.size()/2;++i){
		if(s[i]!=s[s.size()-i-1])
			++ans;
	}
	cout<<ans<<endl;
}

signed main(){
	IOS
	int t=1;
	//cin>>t;
	while(t--)
		solve();
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<bitset>
#include<deque>
#include<iterator>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include <cmath>
#include<vector>
using namespace std;
#define pb push_back
#define pf push_front
#define M 1000000007
#define ll long long int
int main()
 {
 	 
     ll n;
     cin>>n;
     double ans;
    ans=2*3.14159265358979323846*n;
    printf("%.20lf",ans);
     return 0;
 }


Measured memory_bytes: 3748
# -*- coding: utf-8 -*-

loop{

  res = 0

  a,op,b = STDIN.gets.split(' ')
  a = a.to_i
  b = b.to_i  

  case op

    when '+'
      puts a + b
    when '-'
      puts a - b
    when '*'
      puts a * b
    when '/'
      puts a / b
    when '?'
      break
end
}

Measured memory_bytes: 8628
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
using namespace std;
typedef long long int ll;
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)

bool isPrime(int x){
    if(x==1)return 0;
    if(x==2)return 1;
    if(x%2==0)return 0;
    for(int i=3;i*i<=x;i++)if(x%i==0)return 0;
    return 1;
}
int main() {
    int k; cin >> k;
    int a,b; cin >> a >> b;
    for(int i=a; i<=b; i++){
        if(i%k==0){
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" <<endl;
    return 0;
}


Measured memory_bytes: 3636
#include <stdio.h>
#include <stdlib.h>
#pragma warning (disable:4996)

int main() {
	int n;
	scanf("%d",&n);
	for (int i=1; i < 10; i++) {
		if (n / i <= 9 && n%i == 0){
			printf("Yes");
		break;
		}
		else if(i==9)
			printf("No");
	}


}







Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>

#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>

using namespace std;

#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define repf(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define repr(i, a, b) for (ll i = (ll)a; i > (ll)b; i--)

#define repv(x, arr) for (auto &x : arr)
#define all(v) (v).begin(), (v).end()
#define vec(name, num) vector<ll> name((num), 0);
#define mp(a, b) make_pair(a, b)
#define op(i) cout << (i) << endl;
#define F first
#define S second

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const ll mod = 1e9 + 7;
const ll infl = 1e17;

int main()
{
    ll n;
    cin>>n;
    vll a(n);
    rep(i, n) cin >> a[i];
    ll ans = 0;
    ll x = 0,s=0;
    ll r = -1;
    rep(l,n){ 
        while (s==x && r<n){
            r++;
            s += a[r];
            x ^= a[r];
            //cout << l << " " << r << " " << s << " " << x << endl;
        }
        //cout << l << " " << r << endl;
        ans += r - l;
        s -= a[l];
        x ^= a[l];
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
Dice = Struct.new(:top, :front, :right, :left, :back, :bottom) do
    def roll(x)
        case x
        when "E"
            k = self.top
            self.top = self.left
            self.left = self.bottom
            self.bottom = self.right
            self.right = k
        when "N"
            k = self.top
            self.top = self.front
            self.front = self.bottom
            self.bottom = self.back
            self.back = k
        when "S"
            k = self.top
            self.top = self.back
            self.back = self.bottom
            self.bottom = self.front
            self.front = k
        when "W"
            k = self.top
            self.top = self.right
            self.right = self.bottom
            self.bottom = self.left
            self.left =k
        end
    end
    
    def twist
        k = self.front
        self.front = self.right
        self.right = self.back
        self.back = self.left
        self.left = k
    end
end
dice = Dice.new

dice.top, dice.front, dice.right, dice.left, dice.back, dice.bottom = gets.split
gets.to_i.times{
    top, front = gets.split
    founded = false
    for s in "WWWWSSSS".split("")
        dice.roll(s)
        if dice.top == top && !founded then
            founded = true
            4.times {
                dice.twist
                if dice.front == front
                    puts dice.right 
                    break
                end
            }
        end
    end
}


Measured memory_bytes: 6884
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rp(i,n) for(int i=1;i<=(int)n;i++)
int main(){
int a,s,d,f,g;cin>>a>>s>>d>>f>>g;
if(a==0)cout<<1<<endl;
if(s==0)cout<<2<<endl;
if(d==0)cout<<3<<endl;
if(f==0)cout<<4<<endl;
if(g==0)cout<<5<<endl;
}

Measured memory_bytes: 3624
//INCLUDE
//------------------------------------------
#include <bits/stdc++.h>
//DEFINE
//------------------------------------------
#define ll long long
#define ld long double
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
#define dcml(n) fixed<<setprecision(n)
//CONST
//------------------------------------------
const ll INF=1010000000000000017LL;
const ll MOD=1000000007LL;
const ld EPS=1e-12;
const ld PI=3.14159265358979323846;
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define  FORS(i,m,n) for(ll (i)=(m);   (i)<=(n); (i)++)
#define  RFOR(i,m,n) for(ll (i)=(n)-1; (i)>=(n); (i)--)
#define RFORS(i,m,n) for(ll (i)=(n);   (i)>(n);  (i)--)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
#define WREPS(i,in,j,jn) REPS(i,in)REPS(j,jn)
//-----------------------------------------
//namespace
using namespace std;
//ライブラリはここに
//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓

//-----------------------------------------
vector<ll> G[110];
bool done[110];
ll START[110],END[110];
ll t=1;
void dfs(ll from){
    done[from]=true;
    if(START[from]==-1) START[from]=t++;
    for(auto r:G[from]){
        if(done[r])continue;
        dfs(r);
    }
    if(END[from]==-1) END[from]=t++;
}
int main(void){
    ll N;cin>>N;
    REP(i,N){
        START[i]=END[i]=-1;
        done[i]=false;
    }
    REP(i,N){
        ll idx;cin>>idx;ll k;cin>>k;
        REP(j,k){
            ll to;cin>>to;to--;
            G[i].push_back(to);
        }
    }
    REP(i,N) dfs(i);
    REP(i,N){
        printf("%lld %lld %lld\n",i+1,START[i],END[i]);
    }
}


Measured memory_bytes: 3256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define repi(i, a, b) for (int i = (a); i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ull << (b))

using namespace std;
using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;
using f64 = double;
using f80 = long double;
using pii = pair<i32, i32>;
using vi32 = vector<i32>;
using vu32 = vector<u32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf64 = vector<f64>;
using vf80 = vector<f80>;
using vstr = vector<string>;
using vpii = vector<pii>;
using vvi32 = vector<vi32>;
using vvu32 = vector<vu32>;
using vvi64 = vector<vi64>;
using vvu64 = vector<vu64>;
using vvf64 = vector<vf64>;
using vvf80 = vector<vf80>;

template<typename T, typename S> bool amax(T &x, S y) { if (x < y) { x = y; return 1; } return 0; }
template<typename T, typename S> bool amin(T &x, S y) { if (y < x) { x = y; return 1; } return 0; }

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(16);
  cerr << fixed << setprecision(16);
  int n;
  string s;
  cin >> s;
  n = s.size();
  if (s[n - 1] == '1' || s[0] == '0') {
    cout << -1 << endl;
    return 0;
  }
  rep(i, (n - 1) / 2) {
    if (s[i] != s[n - i - 2]) {
      cout << -1 << endl;
      return 0;
    }
  }
  int last = 0;
  cout << 1 << " " << 2 << endl;
  for (int i = 1; i < n - 1; i++) {
    cout << last + 1 << " " << i + 2 << '\n';
    if (s[i] == '1') {
      last = i + 1;
    }
  }
  return 0;
}

Measured memory_bytes: 1616
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
using namespace std;

// ������ str ���ɕ����� subStr �������܂܂��邩���v�Z
int find_all(const std::string str, const std::string subStr) {
	std::vector<int> result;

	int subStrSize = subStr.size();
	int pos = str.find(subStr);

	while (pos != std::string::npos) {
		result.push_back(pos);
		pos = str.find(subStr, pos + subStrSize);
	}

	return result.size();
}

int main() {

	string S;
	cin >> S;

	string hitachi = "hi";

	int num = find_all(S, hitachi);

	if (0 == S.size() % 2 && num == S.size() / 2) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(){return +cin[cid++];}
function nextstr(){return cin[cid++];}
function nextbig(){return BigInt(cin[cid++]);}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextssort(n,a){return a?cin.slice(cid,cid+=n).map(a=>+a).sort((a,b)=>b-a):cin.slice(cid,cid+=n).map(a=>+a).sort((a,b)=>a-b);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

var myOut = main();
if(myOut !== undefined)console.log(String(myOut));

function main(){
  var [d,t,s] = nexts(3);
  return d/s<=t ? "Yes" : "No";
}

Measured memory_bytes: 29664
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::io::Read;
use std::io::{stdout, BufWriter, Write};
 
fn main() {
    let mut buf = String::new();
    
    let out = stdout();
    let mut out = BufWriter::new(out.lock());
 
    // 標準入力から全部bufに読み込む
    std::io::stdin().read_to_string(&mut buf).unwrap();
 
    // 読み込んだStringを空白で分解する
    let mut iter = buf.split_whitespace();
 
    let n: usize = iter.next().unwrap().parse().unwrap();
    let mut a: Vec<u64> = (0..n+1).map(|_| {
        iter.next().unwrap().parse().unwrap()
    }).collect();
    
    let mut b: Vec<u64> = (0..n).map(|_| {
        iter.next().unwrap().parse().unwrap()
    }).collect();
    
    let mut sum = 0;
    
    for i in 0..n {
        if b[i] > a[i] {
            sum += a[i];
            b[i] -= a[i];
            a[i] = 0;
        } else {
            sum += b[i];
            a[i] -= b[i];
            b[i] = 0;
            continue;
        }
        
        if b[i] > a[i+1] {
            sum += a[i+1];
            b[i] -= a[i+1];
            a[i+1] = 0;
        } else {
            sum += b[i];
            a[i+1] -= b[i];
            b[i] = 0;
        }
    }
    
    println!("{}", sum);
    
}

Measured memory_bytes: 10232
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

vector<int> cand(int L, int R) {
  vector<int> S;
  for (int dx = -3; dx <= 3; dx++) S.push_back(L + dx);
  for (int dx = -3; dx <= 3; dx++) S.push_back(R + dx);
  return S;
}

bool solve(int W, int sx, const vector<int>& A, const vector<int>& B) {
  int N = A.size();
  int L = 1, R = W;
  for (int i = N - 1; i >= 0; i--) {
    int nL = W + 1, nR = 0;
    for (int x : cand(L, R)) {
      if (x < 1 || W < x) continue;
      bool ok = true;
      for (int a = 0; a < 2; a++) {
        int nx = x + A[i] * a;
        if (nx < 1 || W < nx) {
          ok = false;
          break;
        }
        bool found = false;
        for (int b = 0; b < 2; b++) {
          int nx = x + A[i] * a + B[i] * b;
          if (L <= nx && nx <= R) {
            found = true;
            break;
          }
        }
        ok &= found;
      }
      if (ok) {
        chmin(nL, x);
        chmax(nR, x);
      }
    }
    L = nL, R = nR;
  }
  return (L <= sx && sx <= R);
}

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  int H, W, N;
  while (cin >> H >> W >> N) {
    int sr, sc;
    cin >> sr >> sc; 
    string S, T;
    cin >> S >> T;
    vector<int> ay(N), ax(N), by(N), bx(N);
    for (int i = 0; i < N; i++) {
      if (S[i] == 'L') ax[i] = -1;
      if (S[i] == 'R') ax[i] = +1;
      if (S[i] == 'U') ay[i] = -1;
      if (S[i] == 'D') ay[i] = +1;
    }
    for (int i = 0; i < N; i++) {
      if (T[i] == 'L') bx[i] = -1;
      if (T[i] == 'R') bx[i] = +1;
      if (T[i] == 'U') by[i] = -1;
      if (T[i] == 'D') by[i] = +1;
    }
    bool res = solve(H, sr, ay, by) && solve(W, sc, ax, bx);
    cout << (res ? "YES" : "NO") << endl;
  }
  return 0;
}


Measured memory_bytes: 3848
s = gets.chomp

if s.length > 9
  puts "NO"
  exit
end

t = "KIHBR"

if s.delete("A") != t
  puts "NO"
  exit
end

if s.include?("AAK") || s.include?("KA") || s.include?("IA") \
  || s.include?("HAA") || s.include?("BAA") || s.include?("RAA")
  puts "NO"
  exit
end

puts "YES"


Measured memory_bytes: 1788
#include<bits/stdc++.h>
#define ll long long int
#define db long double
#define ull unsigned long long int
#define mp make_pair
#define F first
#define S second
#define pb push_back
#define rep(i,a,b)  for(ll i=a;i<=b;i++)
#define all(a) a.begin(),a.end()
#define Nmax 1000005
#define INF 1000000000
#define MOD 1000000007
#define MAXN 1000005
 
using namespace std;

ll dp[100005];
ll a[105];
ll n;

ll recur(ll stones)
{
	if(stones<0) return 0;
	if(stones==0) return 1;
	if(dp[stones]!=-1) return dp[stones];
	ll res=0;
	for(ll i=1;i<=n;i++)
	{
		if(stones==a[i]) return dp[stones]=1LL;
	}
	for(ll i=1;i<=n;i++)
	{
		if(stones-a[i]<0) continue;
		if(recur(stones-a[i])) continue;
		return dp[stones]=1LL;
	}
	return dp[stones]=res;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int tests=1;
    // cin>>tests;
    while(tests--)
    {	
    	ll i,j,k;
    	cin>>n>>k;
    	rep(i,1,n) cin>>a[i];
    	memset(dp,-1,sizeof(dp));
    	dp[0]=1;
    	if(recur(k)==1) cout<<"First";
    	else cout<<"Second";
    }
    	return 0;
    
}

Measured memory_bytes: 9108
n,k = map(int,input().split())
d = [0]*k
A = [[0]*n]*k
l = set()
for i in range(k):
	d[i] = int(input())
	A[i] = list(map(int,input().split()))
for i in range(k):
	l = l.union(A[i])
if set(range(1,n+1)) == l:
	print(0)
else:
	print(len(set(range(1,n+1))-l))


Measured memory_bytes: 9168
#include<stdio.h>
#include<string.h>
#define rep(i,X) for(i=0;i<X;i++)
int n;
char c[27],s[102],cl,sl,ans;

int main(){
	int i,j,k,l,tab;
	scanf("%d%s",&n,c);
	cl=strlen(c);
	rep(i,n){
		scanf("%s",s);sl=strlen(s);
		rep(j,sl){
			if(s[j]-c[0])continue;
			rep(k,199){
				tab=k+1;
				rep(l,199){
					if(l>=cl){l=1;break;}
					if(j+tab*l>=sl || s[j+tab*l]-c[l]){l=0;break;}
				}
				if(l){ans++;goto E;}
			}
		}
	E:;
	}
	printf("%d\n",ans);
	return 0;
}
	

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

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

typedef long long ll;
typedef pair<int, int> p;

ll dp[200][500100];

void init(){
  for (int i = 0; i < 200; i++) {
    for (int j = 0; j < 500100; j++) {
      dp[i][j] = INT_MAX;
    }
  }
  dp[0][0] = 0;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, w;
  cin >> n >> w;
  vector<p> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i].first >> v[i].second;
  }
  init();

  for (int i = 1; i <= n; i++) {
    ll weight = v[i-1].first;
    ll val = v[i-1].second;
    for (int j = 0; j < 500100; j++) {
      if(j - val >= 0){
        dp[i][j] = min(dp[i-1][j], dp[i-1][j-val] + weight);
      }else{
        dp[i][j] = dp[i-1][j];
      }
    }
  }

  int ans = 500000;
  while(dp[n][ans] > w) ans--;

  cout << ans << endl;


}


Measured memory_bytes: 781696
#include <float.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部定数
#define D_POINT_MAX		100000									// 最大地点数

// 内部変数
static FILE *szpFpI;											// 入力
static int siKCnt;												// コマ数
static int si1Point[D_POINT_MAX];								// 地点
static int siPCnt;												// 地点数
static int si1Ivl[D_POINT_MAX];									// 地点間隔

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpA;
#endif

// ソート関数 - int昇順
int
fSortFnc(
	const void *pzpVal1			// <I> 値１
	, const void *pzpVal2		// <I> 値２
)
{
	int *lipVal1 = (int *)pzpVal1;
	int *lipVal2 = (int *)pzpVal2;

	// int昇順
	if (*lipVal1 > *lipVal2) {
		return 1;
	}
	else if (*lipVal1 < *lipVal2) {
		return -1;
	}

	return 0;
}

// 実行メイン
int
fMain(
	int piTNo					// <I> テスト番号 1～
)
{
	int i;
	char lc1Buf[1024], lc1Out[1024];

	// 入力 - セット
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", piTNo);
	szpFpI = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", piTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#else
	szpFpI = stdin;
#endif

	// コマ数・地点数 - 取得
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
	sscanf(lc1Buf, "%d%d", &siKCnt, &siPCnt);

	// 地点 - 取得
	for (i = 0; i < siPCnt; i++) {
		fscanf(szpFpI, "%d", &si1Point[i]);
	}
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);

	// 地点 - ソート
	qsort(si1Point, siPCnt, sizeof(int), fSortFnc);

	// 地点間隔 - セット
	for (i = 0; i < siPCnt - 1; i++) {
		si1Ivl[i] = si1Point[i + 1] - si1Point[i];
	}

	// 地点間隔 - ソート
	qsort(si1Ivl, siPCnt - 1, sizeof(int), fSortFnc);

	// 移動距離合計 - 取得
	long long llSum = 0;
	for (i = 0; i < siPCnt - siKCnt; i++) {
		llSum += si1Ivl[i];
	}

	// 結果 - セット
	sprintf(lc1Out, "%lld\n", llSum);

	// 結果 - 表示
#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, lc1Out)) {
		siRes = -1;
	}
#else
	printf("%s", lc1Out);
#endif

	// 残データ有無
#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, "")) {
		siRes = -1;
	}
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpI);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", piTNo);
	}
	else {
		printf("NG %d\n", piTNo);
	}
#endif

	return 0;
}

int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		fMain(i);
	}
#else
	fMain(0);
#endif

	return 0;
}



Measured memory_bytes: 1396
#include <stdio.h>

int main(void) {

  int n,m;
  scanf("%d %d", &n, &m);
  int a[m],b[m];
  for (int i = 0; i < m; i++) {
    scanf("%d %d", &a[i], &b[i]);
  }
  int check_list[n+1];
  int flag;
  int bridge = 0;
  for (int i = 0; i < m; i++) {
    for (int j = 1; j <= n; j++) {
      check_list[j] = 0;
    }
    if (i == 0) {
      check_list[a[1]] = 1;
      check_list[b[1]] = 1;
    } else {
      check_list[a[0]] = 1;
      check_list[b[0]] = 1;
    }
    while (1) {
      flag = 0;
      for (int j = 0; j < m; j++) {
        if (j == i) {
          continue;
        }
        if (check_list[a[j]] == 0 && check_list[b[j]] == 1) {
          check_list[a[j]] = 1;
          flag = 1;
        } else if (check_list[a[j]] == 1 && check_list[b[j]] == 0) {
          check_list[b[j]] = 1;
          flag = 1;
        }
      }
      if (flag == 0) {
        break;
      }
    }
    flag = 1;
    for (int j = 1; j <= n; j++) {
      if (check_list[j] == 0) {
        flag = 0;
        break;
      }
    }
    if (flag == 0) {
      bridge++;
    }
  }
  printf("%d\n", bridge);

  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>

using namespace std;

typedef long long int ll;
typedef pair<int, int> Pii;

const ll mod = 1000000007;

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

  int n, k, q;
  cin >> n >> k >> q;
  vector<int> a(n);
  for (auto &x: a) cin >> x;

  vector<int> as = a;
  sort(as.begin(), as.end());

  int minDiff = as[q-1] - as[0];
  int p = 0;
  while (p < n) {
    int numToBan = as[p];
    while (p < n) {
      if (as[p] == numToBan) p++;
      else break;
    }
    for (int i = 0; i < n; i++) {
      if (a[i] == numToBan) a[i] = -1; // ban minimum number
    }

    vector<vector<int> > seq;
    int seqCount = 0;
    int seqLength = 0;
    int start = 0;
    int pickable = 0;
    vector<int> seqPickable;
    for (int i = 0; i < n; i++) {
      if (a[i] != -1) seqLength++;
      else {
        if (seqLength >= k) {
          seq.push_back(vector<int>());
          for (int j = start; j < i; j++) seq[seqCount].push_back(a[j]);
          pickable += seqLength - k + 1;
          seqPickable.push_back(seqLength - k + 1);
          seqCount++;
        }
        seqLength = 0;
        start = i + 1;
      }
    }
    if (seqLength >= k) {
      seq.push_back(vector<int>());
      for (int j = start; j < n; j++) seq[seqCount].push_back(a[j]);
      pickable += seqLength - k + 1;
      seqPickable.push_back(seqLength - k + 1);
      seqCount++;
    }

    if (pickable < q) break; // cannot pick number without picking banned numbers

    for (int i = 0; i < seqCount; i++) sort(seq[i].begin(), seq[i].end());

    int picked = 0;
    int firstPicked = -1;
    int lastPicked = -1;
    priority_queue<Pii, vector<Pii>, greater<Pii> > que;
    vector<int> seqPicked;
    for (int i = 0; i < seqCount; i++) {
      que.emplace(seq[i][0], i);
      seqPicked.push_back(0);
    }

    while (picked < q) {
      auto now = que.top();
      que.pop();
      int num = now.first;
      int idx = now.second;
      if (firstPicked == -1) firstPicked = num;
      lastPicked = num;
      seqPicked[idx]++;
      if (seqPicked[idx] < seqPickable[idx]) que.emplace(seq[idx][seqPicked[idx]], idx);
      picked++;
    }

    int diff = lastPicked - firstPicked;
    if (diff < minDiff) minDiff = diff;
  }

  cout << minDiff << endl;

  return 0;
}


Measured memory_bytes: 256
io = STDIN
n,k=io.gets.chomp.split.map(&:to_i)
d=io.gets.chomp.split.map(&:to_i)
like=((0..9).to_a - d)
(n..99999).each do |x|
  if x.to_s
      .split(//)
      .map(&:to_i)
      .all?{|a|like.include?(a)}
    puts x
    break
  end
end

Measured memory_bytes: 1916
# -*- coding: utf-8 -*-

def main():
    sp = [int(e) for e in input().split(" ")]
    a = sp[0]
    b = sp[1]
    t = sp[2]

    print(int(t/a) * b)
    # if int(b/a) > c:
    #     print(c)
    # else:
    #     print(int(b/a))

main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
 
//#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (int i = 0; i < n; i++)
#define forr(i,a,b) for (int i = a; i <= b; i++)
#define all(v) v.begin(), v.end()
#define pb(x) push_back(x)
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;

string s;
deque<char> q;

int main () {
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	int Q, inv = 0;
	cin >> s >> Q;

	for (char c : s)
		q.push_back(c);

	while (Q--) {
		int t, a;
		char c;
		cin >> t;
		if (t == 1) inv ^= 1;
		else {
			cin >> a >> c;
			a--;
			if (a ^ inv) q.push_back(c);
			else q.push_front(c);
		}
	}

	while (q.size()) {
		if (inv) {
			cout << q.back();
			q.pop_back();
		} else {
			cout << q.front();
			q.pop_front();
		}
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 4084
// Created by Sharat Sachin
#include <bits/stdc++.h>
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define repA(i,a,n) for(ll i=a;i<=(n);++i)
#define repD(i,a,n) for(ll i=a;i>=(n);--i)
using namespace std;
using ll = long long;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,sol=0;
    cin>>n;
    string a,b,c;
    cin>>a>>b>>c;
    repA(i,0,n-1){
        set<char> st;
        st.insert(a[i]);
        st.insert(b[i]);
        st.insert(c[i]);
        if(st.size()==3) sol+=2;
        else if (st.size()==2) sol+=1;
        else continue;
    }
    cout<<sol;
    return 0;
}

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

ll x, y, ans = 0, mul = 1;

int main()
{
	scanf( "%lld%lld", &x, &y );
	
	while( x * mul <= y && x * mul > 0 )
		ans ++,	mul *= 2; 
	
	printf( "%lld\n", ans );
	
	return 0;
}

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

const int INF = 1e9 + 1;

int main() {

    string S;
    cin >> S;

    vector<int> A(S.size());
    rep(i, S.size()) A[i] = S[i] - '0';

    ll ans = 0;
    for (int bit = 0; bit < (1 << S.size() - 1); bit++) {
        ll tmp = A[0];
        rep(i, S.size() - 1) {
            if (bit & (1 << i)) {
                ans += tmp;
                tmp = A[i + 1];
            } else {
                tmp *= 10;
                tmp += A[i + 1];
            }
        }
        ans += tmp;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
def main(str)
  n, s = str.split("\n")
  s = s.split(//)
  n = n.to_i
  sum = 0
  (0...n).each do |i|
    ((i+1)...n).each do |j|
      k = j - i + j
      break if k >= n
      sum += 1 if (s[i] != s[j]) && (s[i] != s[k]) && (s[j] != s[k])
    end
  end
  (s.count { |x| x == 'R' } * s.count { |x| x == 'G' } * s.count { |x| x == 'B' }) - sum
end

puts main($stdin.read.chomp)

Measured memory_bytes: 14688
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
#include <numeric>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
//#define mod 998244353
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=550;
//↑templete
int main() {
	string S;
	cin>>S;
	for(int i=0;i<S.length();i++){
		if(i%2 && S[i]=='R'){
			cout<<"No"<<endl;
			return 0;
		}
		else if(i%2==0 && S[i]=='L'){
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include<stdio.h>
#include<string.h>

int main()
{
	int n;
	int count;
	char str[100000];
	char c;
	scanf("%s", str);
	n = strlen(str);
	for (int i = 0; i < n-1; i++) {
		c = str[i];
		if (c == str[i + 1]) {
			printf("%d %d", i + 1, i + 2);
			return 0;
		}
		else if (c == str[i + 2]) {
			printf("%d %d", i + 1, i + 3);
			return 0;
		}
	}
	printf("-1 -1");
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Text;

namespace AtCoder.ABC159
{
    class B
    {
        static void Main(string[] args)
        {
            int X = int.Parse(Console.ReadLine());

            int thousand = (X / 500);
            int five = (X - thousand * 500) / 5;

            Console.WriteLine(thousand * 1000 + five * 5);
        }
    }
}


Measured memory_bytes: 13140
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>

using namespace std;

typedef long long ll;
typedef long double ld;

#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep1(i,n) for(int i=1; i<=(int)(n); i++)
#define all(c) c.begin(),c.end()
#define psb push_back
#define ppb pop_back

const int I_INF = 1001001001;
const ll LL_INF = 1001001001001001001;
const ld EPS = 0.001;

int main() {
    ll A, B, V, W, T;
    cin >> A >> V >> B >> W >> T;

    if (V <= W) {
        cout << "NO" <<endl;
        return 0;
    }

    ll d = abs(A-B);
    ll d2 = (V-W)*T;

    if (d <= d2) cout << "YES" << endl;
    else cout << "NO" << endl;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i,n) for (int i = 0; i < (n); ++i)
int main() {
    int a, b, c, x;
    cin >> a >> b >> c >> x;
    int ans = 0;
    rep(i, a+1) rep(j, b+1) rep(k, c+1) {
        if ( i * 500 + j * 100 + k * 50 == x ) ++ans;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
#define ll long long
struct data
{
    int pos;
    int h;
}a[100000+5];
int cmp(struct data a,struct data b)
{
    return a.h<b.h;
}
int main()
{

    int n,i;
    scanf("%d",&n);
    for(i=1; i<=n; i++)
    {
        scanf("%d",&a[i].h);
        a[i].pos=i;
    }
    sort(a+1,a+n+1,cmp);
    for(i=1; i<=n; i++)
    {
        printf("%d ",a[i].pos);
    }
    return 0;
}


Measured memory_bytes: 1664
//g++ -std=c++14 test.cpp -o test.out

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

string S;
LL K;

string ans;

void solve(){
    set<string> strs;
    int N = S.size();
    for(int i=0;i<N;i++){
        for(int len=1;len<=5;len++){
            string str = "";
            for(int j=i;j<i+len && j<N;j++) str += S[j];
            strs.insert(str);
        }
    }
    auto iter = strs.begin();
    for(int i=1;i<K;i++) iter++;
    ans = (*iter);
}
 
int main(){
    cin >> S;
    cin >> K;
 
    solve();

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

Measured memory_bytes: 1664
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		
		String n = in.next();
		for(int i = 0; i < n.length() - 1; i++)
		{
			if(n.charAt(i) == n.charAt(i + 1))
			{
				out.println("Bad");
				out.close();
				return;
			}
		}
		
		out.println("Good");
		out.close();
	}
	
	static class InputReader
	{
		BufferedReader reader;
		StringTokenizer tokenizer;
		
		public InputReader(InputStream stream)
		{
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}
		
		public String next()
		{
			while(tokenizer == null || !tokenizer.hasMoreTokens())
			{
				try
				{
					tokenizer = new StringTokenizer(reader.readLine());
				}
				catch(IOException e)
				{
					throw new RuntimeException(e);
				}
			}
			
			return tokenizer.nextToken();
		}
		
		public int nextInt()
		{
			return Integer.parseInt(next());
		}
	}
}

Measured memory_bytes: 23124
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <string.h>
#include <numeric>
using namespace std;

#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(i,v) for(auto &(i):(v))
#define eachr(i,v) for(auto &(i)=(v).rbegin();(i)!=(v).rend();(i)++)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())
#define endl "\n"

//typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a/gcd(a,b)*b;}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
    oreno_initializer() {
        cin.tie(0);
        ios::sync_with_stdio(0);
    }
} oreno_initializer;



int n, a[26], res = 1;
string s;

signed main() {
    cin >> n >> s;
    each(i,s) a[i-'a']++;
    rep(i,26) (res *= a[i]+1) %= mod;
    (res += mod-1) %= mod;
    cout << res << endl;
}

Measured memory_bytes: 512