akhauriyash/Code-Regression huggingface dataset:
/* {{{ Shinobu kawaii */
/*
  ______   __        _                  __                 
.' ____ \ [  |      (_)                [  |                
| (___ \_| | |--.   __   _ .--.   .--.  | |.--.   __   _   
 _.____`.  | .-. | [  | [ `.-. |/ .'`\ \| '/'`\ \[  | | |  
| \____) | | | | |  | |  | | | || \__. ||  \__/ | | \_/ |, 
 \______.'[___]|__][___][___||__]'.__.'[__;.__.'  '.__.'_/ 

*/
/* }}} */

#include <bits/stdc++.h>
using namespace std;

// #define int long long
//struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* cpp template {{{ */

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (int i = (a); i >= n; --i)
#define DEP(i, n) DEPS(i, n, 0)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* alias */
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; std::cin >> x; return x;}
template <typename T> void print(T x) {std::cout << x << '\n';}
template <typename T>
void print(std::vector<T>& v, std::string s = " ") {
  REP(i, v.size()) {
    if (i != 0) std::cout << s;
    std::cout << v[i];
  }
  std::cout << '\n';
}

/* }}} */

int n, m;

void warshall_floyd(vvi& d)
{
  REP(k, n) REP(i, n) REP(j, n) {
    d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
  }
}

signed main()
{
  scanf("%d%d", &n, &m);
  vvi dp(n, vi(n, INF));
  REP(i, m) {
    int a, b, c, d;
    scanf("%d,%d,%d,%d", &a, &b, &c, &d);
    a--; b--;
    dp[a][b] = c; dp[b][a] = d;
  }
  warshall_floyd(dp);
  int s, g, v, p;
  scanf("%d,%d,%d,%d", &s, &g, &v, &p);
  s--; g--;
  print(v - p - dp[s][g] - dp[g][s]);

  return 0;
}

Measured memory_bytes: 3212
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int M = 1e9+7;
inline int mod(int a,int m){
	int r = a%m;
	if(r<0)r+=m;
	return r;
}
int H,W;
char G[1010][1010];
int dp[1010][1010];
int solve(int l,int c){
	if(dp[l][c]!=-1)return dp[l][c];
	if(G[l][c]=='#')return dp[l][c]=0;
	if(l==H && c==W)return 1;
	dp[l][c]=0;

	if(l+1<=H){
		dp[l][c]=mod(solve(l+1,c),M);
	}
	if(c+1<=W){
		dp[l][c]=mod(dp[l][c]+solve(l,c+1),M);
	}
	return dp[l][c];
}

int32_t main(){
	memset(dp,-1,sizeof(dp));
	cin>>H>>W;
	for(int i=1;i<=H;i++){
		for(int j=1;j<=W;j++){
			cin>>G[i][j];
		}
	}
	cout<<solve(1,1)<<endl;
}

Measured memory_bytes: 9344
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cctype>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>
#include <bitset>
#include <iterator>
#include <iomanip>
#include <sstream>
#include <numeric>
#include <cassert>
using namespace std;
int dx[5]={1,0,-1,0,0},dy[5]={0,1,0,-1,0};
long long gcd(long long a,long long b){if(a%b==0){return b;}else return gcd(b,a%b);}
long long lcm(long long a,long long b){if(a==0){return b;} return a/gcd(a,b)*b;}
#define INF 2000000000
#define MOD 1000000007
#define sym cout<<"---------"<<endl;
#define ll long long
#define mk make_pair
#define en endl
#define RE return 0
#define int ll
#define P pair<int,int>

signed main(){
	int n; cin>>n;
	if(n==1) cout<<"Hello World"<<en;
	else{
		int a,b; cin>>a>>b;
		cout<<a+b<<en;
	}
}



Measured memory_bytes: 256
import heapq

N, M, S, T = map(int, input().split())

INF = 10 ** 15
G1, G2 = [[] for i1 in range(N)], [[] for i2 in range(N)]
used1, used2 = [0 for i3 in range(N)], [0 for i4 in range(N)]
dist1, dist2 = [INF for i5 in range(N)], [INF for i6 in range(N)]


def dijkstra(g, s, d, c):
    d[s], pq = 0, []
    heapq.heappush(pq, (0, s))

    while len(pq) != 0:
        u = heapq.heappop(pq)
        c[u[1]] = 2

        if d[u[1]] < u[0]:
            continue

        for v in g[u[1]]:
            if c[v[0]] != 2:
                if d[u[1]] + v[1] < d[v[0]]:
                    d[v[0]], c[v[0]] = d[u[1]] + v[1], 1
                    heapq.heappush(pq, (d[v[0]], v[0]))


def main():
    for i in range(M):
        u, v, a, b = map(int, input().split())
        G1[u-1].append((v-1, a))
        G1[v-1].append((u-1, a))
        G2[u-1].append((v-1, b))
        G2[v-1].append((u-1, b))

    dijkstra(G1, S-1, dist1, used1)
    dijkstra(G2, T-1, dist2, used2)

    c = [0 for i in range(N)]
    for i in range(N):
        c[i] = dist1[i] + dist2[i]

    cc = [0 for i in range(N)]
    cc[N-1] = c[N-1]
    for i in range(N-2, -1, -1):
        cc[i] = min(cc[i+1], c[i])

    for i in range(N):
        print(10**15-cc[i])


if __name__ == '__main__':
    main()


Measured memory_bytes: 89776
#include <iostream>
#include <stdlib.h>
using namespace std;

int main(void){
    int w,h,x,y,r;
    cin >> w >> h >> x >> y >> r;
    if ( x-r >= 0 && x+r <= w && y-r >= 0 && y+r <= h)
    {
        cout << "Yes" << endl;
    }
    else {
            cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>

int main(void){
	int a,s,m,h;
	scanf("%d",&a);
	h = a / 3600;
	m = (a % 3600) / 60;
	s = (a % 3600) % 60;
	printf("%d:%d:%d\n",h,m,s);
	return 0;
}

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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

string S[1005];
ll x[2] = {0, 1};
ll y[2] = {1, 0};
ll A[1005][1005];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll H, W;
    cin >> H >> W;
    REP(i, H) {
        cin >> S[i];
    }
    A[0][0] = 1;
    REP(i, H) {
        REP(j, W) {
            if (S[i][j] == '#')
                continue;
            if (i > 0)
                A[i][j] += +A[i - 1][j];
            if (j > 0)
                A[i][j] += A[i][j - 1];
            A[i][j] %= MOD;
        }
    }

    cout << A[H - 1][W - 1] << endl;
    return 0;
}

Measured memory_bytes: 9216
str=gets.chomp
num=str.split
W=num[0].to_i
H=num[1].to_i
x=num[2].to_i
y=num[3].to_i
r=num[4].to_i
if x-r>=0 && y-r>=0 && x+r<=W && y+r<=H then
  puts "Yes"
else
  puts "No"
end

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

int dp[101][100001];
/// dp[i][j] 考慮第 1 ~ i 項物品 重量不超過 j 的情況下的最大總價值

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

    int N, W;
    cin >> N >> W;

    for (int i = 1; i <= N; i++)
    {
        int w, v;
        cin >> w >> v;

        for (int j = 0; j < w; j++)
            dp[i][j] = dp[i - 1][j];
        for (int j = W; j - w >= 0; j--)
            dp[i][j] = max(dp[i - 1][j - w] + v, dp[i - 1][j]);
    }

    int ans = 0;
    for (int i = 0; i <= W; i++)
        ans = max(ans, dp[N][i]);
    cout << ans << '\n';

    return 0;
}


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

string s;
vector<string> ans;

void solve(int now, string nows, bool ch);

int main() {
  while(1) {
    cin >> s;
    if(s == "#") break;
    solve(24, s, 0);
    sort(ans.begin(), ans.end());
    ans.erase(unique(ans.begin(), ans.end()), ans.end());
    cout << ans.size() << endl;
    if(ans.size() <= 10)
      for(int i = 0; i < ans.size(); ++i)
        cout << ans[i] << endl;
    else {
      for(int i = 0; i < 5; ++i) cout << ans[i] << endl;
      for(int i = 0; i < 5; ++i)
        cout << ans[ans.size() - 5 + i] << endl;
    }
    ans.erase(ans.begin(), ans.end());
  }
  return 0;
}

void solve(int now, string nows, bool ch) {
  if(now == -1) {
    ans.push_back(nows);
    return;
  }
  for(int i = 0; i < nows.size(); ++i)
    if(nows[i] == 'a' + now) {
      string nexts = nows;
      nexts[i] = 'a' + now + 1;
      solve(now - 1, nexts, 0);
    }
    else if(nows[i] == 'a' + now + 1)
      return;
  solve(now - 1, nows, 0);
}


Measured memory_bytes: 4312
n = int(input())
ls = []

for _ in range(n):
    s = int(input())
    ls.append(s)

ans = sum(ls)

if ans % 10 == 0:
    ls.sort()
    for i in range(n):
        if ls[i] % 10 != 0:
            ans -= ls[i]
            print(ans)
            exit()
    print(0)
    exit()
else:
    print(ans)


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

int main() {
  int x,y;
  cin>>x>>y;
  for (int i=0;i<=x;i++){
    if (i*2+(x-i)*4==y) {
      cout<<"Yes"<<endl;
      goto loopend;
    }
  }
  cout<<"No"<<endl;
  loopend:
  return 0;
}

Measured memory_bytes: 3132
object Main {

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)

    val N = sc.nextInt()
    val A = Array.fill(N)(sc.nextInt())

    def solve(N: Int, A: Array[Int]): Long = {
      val MAX = N - 1
      val C = new Array[Int](N)
      (0 to MAX) foreach { n =>
        C(((MAX - n) - n).abs) += 1
      }

      val INF = Math.pow(10, 9).toLong + 7.toLong
      def ans(n: Int, acm: Long): Long =
        if (n < N / 2) ans(n + 1, (acm * 2L) % INF)
        else acm

      def find(i: Int): Long =
        if (i < N) {
          C(A(i)) -= 1
          find(i + 1)
        } else {
          if (C.forall(_ == 0)) ans(0, 1L)
          else 0
        }

      find(0)
    }

    println(solve(N, A))
  }

}


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

int main() {
  long N, K;
  cin >> N >> K;
  vector<long> H(N);
  for (long& h : H) cin >> h;
  sort(H.begin(), H.end());
  long ans = -1;
  for (int i = 0; i < N - K + 1; i++) {
    long tmp = H[K+i-1] - H[i];
    if (ans == -1 || tmp < ans) ans = tmp;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1152
INF = float("inf")

sc = iter(open(0).read().split())
ni = lambda: int(next(sc))
ns = lambda: next(sc)

LR, UD, RU, LD, LU, RD = [[[] for _ in range(400_100)] for _ in range(6)]

U = []

N = ni()
for i in range(N):
    x, y, u = ni(), ni(), ns()
    U.append(u)

    if u in "LR":
        LR[y].append((x, i))
    if u in "UD":
        UD[x].append((y, i))
    if u in "LD":
        LD[x + y].append((y, i))
    if u in "RU":
        RU[x + y].append((y, i))
    if u in "LU":
        LU[y - x + 200_000].append((x, i))
    if u in "RD":
        RD[y - x + 200_000].append((x, i))

ans = INF
for i in range(400_001):
    LR[i].sort()
    UD[i].sort()
    LD[i].sort()
    RU[i].sort()
    LU[i].sort()
    RD[i].sort()

    ans = min(
        ans,
        5 * min(
            ((LR[i][j + 1][0] - LR[i][j][0])
            for j in range(len(LR[i]) - 1)
            if U[LR[i][j][1]] == "R" and U[LR[i][j + 1][1]] == "L"),
            default=INF
        ),
        5 * min(
            ((UD[i][j + 1][0] - UD[i][j][0])
            for j in range(len(UD[i]) - 1)
            if U[UD[i][j][1]] == "U" and U[UD[i][j + 1][1]] == "D"),
            default=INF
        ),
        10 * min(
            ((LD[i][j + 1][0] - LD[i][j][0])
            for j in range(len(LD[i]) - 1)
            if U[LD[i][j][1]] == "L" and U[LD[i][j + 1][1]] == "D"),
            default=INF
        ),
        10 * min(
            ((RU[i][j + 1][0] - RU[i][j][0])
            for j in range(len(RU[i]) - 1)
            if U[RU[i][j][1]] == "U" and U[RU[i][j + 1][1]] == "R"),
            default=INF
        ),
        10 * min(
            ((LU[i][j + 1][0] - LU[i][j][0])
            for j in range(len(LU[i]) - 1)
            if U[LU[i][j][1]] == "U" and U[LU[i][j + 1][1]] == "L"),
            default=INF
        ),
        10 * min(
            ((RD[i][j + 1][0] - RD[i][j][0])
            for j in range(len(RD[i]) - 1)
            if U[RD[i][j][1]] == "R" and U[RD[i][j + 1][1]] == "D"),
            default=INF
        )
    )

print("SAFE" if ans == INF else ans)

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

using namespace std;

const long long MOD = 1000000007LL;
long long GCD(long long a, long long b){return b == 0 ? a : GCD(b, a % b);}
long long fast_exp(long long base, long long exp, long long mod = MOD) {
    long long tot = 1;
    for(;exp > 0;exp >>= 1) {
       if((exp & 1) == 1) tot = tot * base % mod;
       base = base * base % mod;
    }
    return tot;
}

int dsu[200005], r[200005], c[200005];

void dsu_clear(){
    for(int i = 0; i < 200004; ++i){
        dsu[i] = i; r[i] = 0;
    }
}

int find(int node){
    if(node == dsu[node]) return node;
    return dsu[node] = find(dsu[node]);
}

void combine(int a, int b){
    a = find(a); b = find(b);
    if(a == b) return;
    if(r[a] <= r[b]){
        dsu[a] = b; r[b] += r[a];
    } else if(r[b] < r[a]){
        dsu[b] = a; r[a] += r[b];
    }
}

int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    string s, t;
    int h, w, n, x, y; cin >> h >> w >> n >> y >> x >> s >> t;

    int up = 0, down = 0, left = 0, right = 0;

    // lets go greedy afff

    // all out on left

    int cx = x;

    for(int i = 0; i < n; ++i){
        if(s[i] == 'L') --cx;
        if(cx <= 0){
            cout << "NO";
            return 0;
        }
        if(t[i] == 'R' && cx < w) ++cx;
    }

    cx = x;

    for(int i = 0; i < n; ++i){
        if(s[i] == 'R') ++cx;
        //cout << cx << endl;
        if(cx > w){
            cout << "NO";
            return 0;
        }
        if(t[i] == 'L' && cx > 1) --cx;
    }

    cx = y;

    for(int i = 0; i < n; ++i){
        if(s[i] == 'D') ++cx;
        if(cx > h){
            cout << "NO";
            return 0;
        }
        if(t[i] == 'U' && cx > 1) --cx;
    }

    cx = y;

    for(int i = 0; i < n; ++i){
        if(s[i] == 'U') --cx;
        if(cx <= 0){
            cout << "NO";
            return 0;
        }
        if(t[i] == 'D' && cx < h) ++cx;
    }

    cout << "YES";

    return 0;

}


Measured memory_bytes: 920
let ans, n = ref 1, read_int ()
let us, a_s = Array.(make (n + 1) 0, init n @@ fun _ -> Scanf.scanf " %d" (+) 0)
let _ = us.(0) <- 3; Array.iter (fun a -> ans := !ans * us.(a) mod 1000000007; us.(a) <- us.(a) - 1; if us.(a) < 0 then (print_endline "0"; exit 0); us.(a + 1) <- us.(a + 1) + 1) a_s; Printf.printf "%d\n" !ans

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

int main(){
  ll a,b,c;
  cin >> a >> b >> c;
  ll left = 4*a*b;
  ll d = c-a-b;
  ll right = (c-a-b)*(c-a-b);
  if(d>0 && left < right) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

int main() {
    int x,y ;
    while(cin>> x >> y,!(x==0&&y==0)){
 
     if(x<=y) { cout << x << " " << y <<endl;
    } else{ cout << y << " " << x <<endl;
    }
    }
   return 0;
    }



Measured memory_bytes: 2976
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i < (n);i++)
using namespace std;
vector<int> to[200005];
vector<int> ans;
void dfs(int v,int p=-1){//来た所に戻らないように双方向の引数をもつ
  for(int u: to[v]) {
    if(u == p) continue;//親ノードには行かない
    ans[u] += ans[v];
    dfs(u,v);
  }
}
int main(){
  int n,q;
  cin >> n >> q;
  rep(i,n-1){
    int a,b;
    cin >> a >> b;
    --a;--b;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  ans.resize(n);
  rep(i,q){
    int p,x;
    cin >> p >> x;
    --p;
    ans[p] += x;
  }
  dfs(0);
  rep(i,n) cout << ans[i] << endl;
  return 0;
} 


Measured memory_bytes: 23424
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
#include <ctime>
#include <tuple>
#include <bitset>
#include <assert.h>
#include <deque>
#include <functional>
using namespace std;
typedef long long ll;

#define fi first
#define se second
#define rep(i, n) for (ll i = 0; i < n; i++)
#define debugA cerr << "AAAAA" << endl
#define debug_ cerr << "-------------" << endl
#define debug(x) cerr << #x << ": " << x << endl
#define debug_vec(v)                   \
    cout << #v << endl;                \
    for (int i = 0; i < v.size(); i++) \
    {                                  \
        cout << v[i] << " ";           \
    }                                  \
    cout << endl;
#define debug_vec2(v)                         \
    cout << #v << endl;                       \
    for (int i = 0; i < v.size(); i++)        \
    {                                         \
        for (int j = 0; j < v[i].size(); j++) \
        {                                     \
            cout << v[i][j] << " ";           \
        }                                     \
        cout << endl;                         \
    }

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

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

using Graph = vector<vector<int>>;
using P = pair<int, int>;
using P1 = pair<int, pair<int, int>>; // クラスカル法とかで、{cost, {from, to}}的に使う。
const ll INF = 1001001001;
const double pi = acos(-1);

int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    int q;
    cin >> q;
    vector<set<int>> a(26);
    for (int i = 0; i < n; i++)
    {
        int c = s[i] - 'a';
        a[c].insert(i);
    }
    // for (int i = 0; i < 26; i++)
    // {
    //     for (auto v : a[i])
    //     {
    //         cout << v;
    //     }
    //     cout << endl;
    // }
    for (int i = 0; i < q; i++)
    {
        int x;
        cin >> x;
        if (x == 1)
        {
            int b;
            char c;
            cin >> b >> c;
            b--;
            a[s[b] - 'a'].erase(b);
            a[c - 'a'].insert(b);
            s[b] = c;
        }
        else
        {
            int b, c;
            cin >> b >> c;
            b--;
            c--;
            int ans = 0;
            for (int j = 0; j < 26; j++)
            {
                auto d = a[j].lower_bound(b);
                if (d == a[j].end())
                {
                    continue;
                }
                if (*d <= c)
                {
                    ans++;
                }
            }
            cout << ans << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 27236
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int main(){
	string s; int K;
	while(cin >> s >> K){
		vector<string> vs;
		for(int i=0;i<s.size();i++){
			for(int j=1;j<=K;j++){
				if(i+j > s.size()) break;
				vs.push_back(s.substr(i, j));
			}
		}
		sort(vs.begin(), vs.end());
		vs.erase(unique(vs.begin(), vs.end()), vs.end());
		cout << vs[K-1] << endl;
	}
}

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

using namespace std;

const int N = 105,M = 105;

struct drk{
	int p,x;
}d[M];

int t[N],n,m;

int main()
{
	std::ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    long long sum = 0;
    for(int i=1;i<=n;i++){
    	cin >> t[i];
		sum += t[i];	
	}
    cin >> m;
    for(int i=1;i<=m;i++){
    	cin >> d[i].p >> d[i].x;
	}
	
	for(int i=1;i<=m;i++){
		for(int j=1;j<=n;j++){
			if(d[i].p==j){
				cout << sum-t[j]+d[i].x << endl;
				break;
			}
		}
		
	}
	    
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <typeinfo>
#include <cxxabi.h>
#ifdef LOCAL
#include "dbgtoki.hpp"
#define DUMP(i) dump((string)TOSTRING(i), demangle(typeid(i).name()), __LINE__ , i) 
#else
#define DUMP(i) 
#endif

using namespace std;
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(s) (s).begin(), (s).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()) , v.end());
#define dis distance
#define so sort
#define rev reverse
#define pub push_back


typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
const int EPS = 1e-9;
const int MOD = 1e9+7;

int main (){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> V(100001,0);
  int ans = 0;
  REP(i,n){
    int a;
    cin >> a;
    V[a]++;
  }
  FOR(i,1,100000){
    int sum = V[i]+V[i-1]+V[i+1];
    ans = max(ans,sum);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
using System;

namespace ABC111_A_AtCoderBeginnerContest999
{
	internal class Program
	{
		public static void Main(string[] args)
		{
			string inStr = Console.ReadLine();
			int[] convertStr = new int[inStr.Length];

			for (int i = 0; i < inStr.Length; i++)
			{
				convertStr[i] = int.Parse(inStr.Substring(i, 1));
				
				if (convertStr[i] == 1)
				{
					convertStr[i] = 9;
				}else if (convertStr[i] == 9)
				{
					convertStr[i] = 1;
				}
				
				Console.Write(convertStr[i]);
			}
		}
	}
}

Measured memory_bytes: 13140
import sys
# sys.setrecursionlimit(100000)


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


def input_int():
    return int(input())


def input_int_list():
    return [int(i) for i in input().split()]


def main():
    n = input_int()
    S = input()
    ans = 0
    for i in range(1, n):
        x = set(S[:i])
        y = set(S[i:])
        cnt = 0
        for c in x:
            if c in y:
                cnt += 1
        ans = max(cnt, ans)
    print(ans)

    return


if __name__ == "__main__":
    main()


Measured memory_bytes: 65232
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define pb push_back
#define mp make_pair
#define in insert
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define mod 1000000007
#define sz(v) (int)(v.size())
#define all(x) x.begin(), x.end()
#define prec fixed << setprecision(12)
#define rep(i, a, b) for (int i = a; i <= b; ++i)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define test int t; cin >> t; while(t--)

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef set<int> si;
typedef map<int, int> mii;
typedef vector<pii> vpi;

void solve() {
	int n;
	cin >> n;
	vi v(n);
	rep(i, 0, n - 1) cin >> v[i];
	sort(all(v));
	reverse(all(v));
	int ans = v[0];
	int rem = n - 2;
	if (rem % 2 == 0) {
		int l = rem / 2;
		// cout << l;
		int i = 1;
		while (l) {
			ans += 2 * v[i];
			l--;
			i++;
		}
	} else {
		int l = (rem - 1) / 2;
		int i = 1;
		while (l) {
			ans += 2 * v[i];
			l--;
			i++;
		}
		ans += v[i];
	}
	cout << ans;
}

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


#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	// test
	solve();

	return 0;
}


Measured memory_bytes: 4780
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus < 201703L
#        pragma GCC target("avx")
#    else
#        pragma GCC target("avx2")
#    endif

#endif

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;
typedef long double Ld;

using namespace std;
using Graph = vector<vector<Int>>;

template <typename T>
using vec = vector<T>;

template <typename T>
using vec2 = vector<vector<T>>;

template <typename T>
using vec3 = vector<vector<vector<T>>>;

const Ld pi = M_PI;
const Int MOD = 1000000007;
const Int INF = 1LL << 61;

Int Floor(Int a, Int b) {
    return (a - (a % b)) / b;
}

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

    int n;
    cin >> n;
    vec<int> a(n + 1), b(n + 1, 0);
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }

    for (int i = n; i >= 1; i--) {
        int tem = 0;
        for (int j = 1;; j++) {
            int mult = j * i;
            if (mult <= n) {
                tem += b[mult];
            } else {
                break;
            }
        }

        if (tem % 2 == a[i]) {
            b[i] = 0;
        } else {
            b[i] = 1;
        }
    }

    int ans = 0;
    vec<int> ansbox;
    for (int i = 1; i <= n; i++) {
        if (b[i]) {
            ans++;
            ansbox.push_back(i);
        }
    }

    cout << ans << endl;
    if (ans != -1 && ans != 0) {
        for (int i = 0; i < ans - 1; i++) {
            cout << ansbox[i] << ' ';
        }
        cout << ansbox.back() << endl;
    }

    return 0;
}


Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
#define INF -1
typedef pair<int,int> P;
#define MAX_H 59
#define MAX_W 59
char maze[MAX_H][MAX_W+1];
int h,w;
int sx,sy;
int gx,gy;
int dp[MAX_H][MAX_W];
const int dx[4]={1,0,-1,0};
const int dy[4]={0,-1,0,1};
int main(){
    while(scanf("%d%d%*c",&w,&h)){
        int i,j;
        sx=0;
        sy=0;
        gx=2*h-2;
        gy=2*w-2;
        queue<P>que;
        P p;
        if(w==0 && h==0){
            break;
        }
        for(i=0;i<2*h-1;i++){
            for(j=0;j<2*w-2;j++){
                maze[i][j]=getchar();
            }
            if(i%2==0){
                maze[i][j]=' ';
            }else{
                maze[i][j]=getchar();
            }
            getchar();
        }
        for(i=0;i<2*h-1;i++){
            for(j=0;j<2*w-1;j++){
                dp[i][j]=INF;
            }
        }
        que.push(P(sx,sy));
        dp[sx][sy]=1;
        while(que.size()){
            p=que.front();
            que.pop();
            if(p.first==gx && p.second==gy){
                break;
            }
            for(i=0;i<4;i++){
                int nx=p.first+2*dx[i];
                int ny=p.second+2*dy[i];
                if(0<=nx && nx<(2*h-1) && 0<=ny && ny <(2*w-1) && maze[p.first+dx[i]][p.second+dy[i]]== '0' && dp[nx][ny]==INF){
                    que.push(P(nx,ny));
                    dp[nx][ny]=dp[p.first][p.second]+1;
                }
            }
        }
        /*for(j=0;j<2*h-1;j++){
            for(i=0;i<2*w-1;i++){
                printf("%2d",dp[i][j]);
            }
            printf("\n");
        }*/
        while(que.size()){
            que.pop();
        }
        if(dp[gx][gy]==INF){
            cout<<0<<endl;
        }else{
            cout<<dp[gx][gy]<<endl;
        }   
    }  
    return 0;
}

Measured memory_bytes: 3128
import java.util.*;

public class Main {    
    
  public static void main(String[] args) {              
      Scanner sc = new Scanner(System.in);
      
      int n = sc.nextInt();
      
      LinkedList<Integer> b = new LinkedList<>();
      
      for(int i = 0;i < n;i++){
          int a = sc.nextInt();
                
          if(i%2 == 0){
              b.addLast(a);
          }else{
              b.addFirst(a);
          }          
      }
      
      if(n%2 == 1){
          Collections.reverse(b);
      }
      
      StringBuilder sb = new StringBuilder();
      
      for(Integer v:b){
          sb.append(v);
          sb.append(" ");
      }
      
      System.out.println(sb);
      
  }          
}



Measured memory_bytes: 99880
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<cmath>
#include<math.h>
#include<algorithm>
#include<string.h>
#include <iomanip>
#include <sstream>
using namespace std;

int main() {
  int N, R;
  int ans = 0;

  cin >> N >> R;

  if( N >= 10){
    ans = R;
  }else{
    ans = R + 100*(10-N);
  }
  cout << ans << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int main(){
     int N,M;
     cin>>N>>M;
     vector<int>L(M),R(M);
     for(int i=0;i<M;i++){
         cin>>L.at(i)>>R.at(i);
     }
     sort(L.begin(),L.end(),greater<int>());
     sort(R.begin(),R.end());
     int count=0;
     for(int i=L.at(0);i<=N;i++){
         if(i<=R.at(0)){
             count++;
         }
         else break;
     }
cout<<count<<endl;
}



Measured memory_bytes: 1024
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
  int H = sc.nextInt();
  int W = sc.nextInt();
  String[] s = new String[H];
  for(int i = 0;i < H;i++){
    s[i] = sc.next();
    System.out.println(s[i]);
    System.out.println(s[i]);
  }
}}

Measured memory_bytes: 22868
use std::io;
use std::str::FromStr;

fn input<T:FromStr>() -> T {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.trim().parse().ok().unwrap()
}

fn main() {
    let x: i64 = input();
    let limit = 1000;
    for i in -limit..limit {
        for j in -limit..limit {
            if i * i * i* i * i - j * j * j * j * j == x {
                println!("{} {}", i, j);
                return;
            }
        }
    }
}


Measured memory_bytes: 2100
#include <iostream>
#include <algorithm>
#include <cmath>
#include <list>
#include <queue>
#include <set>
#include <vector>

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define FOR(i,a,b) for (int i=(int)(a);i<(int)(b);++i)
#define FORE(i,a,b) for (int i=(int)(a);i<=(int)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define REPE(i,n) FOR(i,0,n)

typedef long long ll;

int main() {
  int N;
  cin >> N;
  double sum = 0;
  REP(i, N) {
    double a;
    cin >> a;
    sum += 1/a;
  }
  cout << printf("%.6f", 1/sum) << endl;
}

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

int main(){
  int input;
  int c[6]={500,100,50,10,5,1};

  while(true){
    cin >> input;
    if(input == 0) break;
    input = 1000-input;
    int n=0;
    for(int i=0;i<6;i++){
      n+=input/c[i];
      input = input%c[i];
    }
    cout << n << endl;
  }
  return 0;
}

Measured memory_bytes: 3068
import sys
#input = sys.stdin.readline

def main():
    n=int(input())
    v=sorted(list(map(int,input().split())))
    ans=v[0]
    for i in range(1,n):
        ans=(ans+v[i])/2
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
import sys
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import floyd_warshall
from itertools import permutations

input = sys.stdin.readline
ans = -1

n, m, r = map(int, input().split())
r  = list(map(int, input().split()))
A, B, C = [], [], []
for i in range(m):
    a, b, c = map(int, input().split())
    A.append(a-1)
    B.append(b-1)
    C.append(c)

wf = floyd_warshall(csr_matrix((C, (A, B)), shape = (n, n)), directed=False)

for pi in permutations(r):
    cand = 0
    for r1, r2 in zip(pi, pi[1:]):
        cand += int(wf[r1-1][r2-1])
    if ans < 0 or ans > cand:
        ans = cand

print(ans)


Measured memory_bytes: 19116
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define int long long
#define endl "\n"
#define pii pair<int,int> 
#define ff first
#define ss second
#define mii map<int,int>
#define si set<int>
#define sti stack<int>
#define qi queue<int>
#define vi vector<int>
#define pq priority_queue<int>
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int M=1e9+7;
const int N=2e5+5;
const int N1=-1e18-5;
int dp[N][3];
int a[N];
 
int func(int x,int y,int n,int flag=0){
	if(x>=n||y<0) return 0;
	if(dp[x][y]!=N1) return(dp[x][y]);
	if(flag==0&&x==n-1) return(N1);
	int res=N1;
	for(int i=0;i<=y;i++){
		res=max(res,a[x+i]+func(x+i+2,y-i,n,((flag==1)||(i>0)))); 
	}
	return(dp[x][y]=res);
}
 
int32_t main(){
    IOS;
    int n;
    cin>>n;
    for(int i=0;i<n;i++) cin>>a[i];
    for(int i=0;i<n;i++){
    	for(int j=0;j<3;j++) dp[i][j]=N1;
    }
	int ans=func(0,n%2+1,n);
	cout<<ans<<endl;
}

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

int main() {
	ll n;
	cin >> n;
	ll total = 0;
	for(ll i=1;i<=n;i++) {
		if ((i%3 != 0) && (i%5 != 0)) total += i;
	}
	cout << total << endl;
	return 0;
}


Measured memory_bytes: 3592
#include <stdio.h>

int main(void)
{
	int n;
	int i;
	float high;
	float t;
	float in;
	
	while (scanf("%f", &in) != EOF){
		t = in / 9.8;
		high = 4.9 * t * t;
		n = 1;
		while (1){
			if (high < 5 * n - 5){
				break;
			}
			n++;
		}
		
		printf("%d\n", n);
	}
	
	return (0);
}

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

int main()
{
	int a,A,B,C,flag=0;
	char c;

	cin >> A >> B >> C;

	if (A == 5 && B == 7&& C==5) {
		flag = 1;
	}

	if (A == 7 && B == 5 && C == 5) {
		flag = 1;
	}
	if (A == 5 && B ==  5&& C == 7) {
		flag = 1;
	}


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


	


    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define re register
using namespace std;
const int maxn=3e3+10;
const ll mod=1e9+7;
template<typename T> void read(T &x){
	T f=1;x=0;
	char c=getchar();
	while(c<'0' || c>'9'){if(c=='-') f=-1;c=getchar();}
	while(c>='0' && c<='9'){x=(x<<3)+(x<<1)+c-48;c=getchar();}
	x*=f;
}
int n;
ll ans;
string s;
ll dp[maxn][maxn];
ll pre[maxn][maxn];
int main(){
	read(n);
	cin>>s;
	dp[0][0]=1;
	for(re int i=1;i<=n;i++){
		pre[0][i]=1;
	}
	for(re int i=1;i<n;i++){
		for(re int j=1;j<=n;j++){
			if(s[i-1]=='<'){
				dp[i][j]=pre[i-1][j-1]%mod;
				pre[i][j]=(pre[i][j-1]+dp[i][j])%mod; 
			}
			else{
				dp[i][j]=(pre[i-1][i]-pre[i-1][j-1]+mod)%mod;
				pre[i][j]=(pre[i][j-1]+dp[i][j])%mod;
			}
		}
	}
	for(re int i=1;i<=n;i++){
		ans=(ans+dp[n-1][i])%mod;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 141568
#include<stdio.h>

int main(){
  int a;
  char s[10];

  scanf("%d",&a);
  scanf("%s", s);

  if(a >= 3200){
    printf("%s", s);
    return 0;
  }else{
    printf("red");
    return 0;
  }
  return 0;
  }

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<tuple>

using namespace std;

typedef long long ll;
typedef long double ld;

#define int ll
#define loop(i, n) for (int i = 0; i < n; ++i)
#define loop1(i, n) for (int i = 1; i < n; ++i)
#define ti tuple<int, int, int>

const int INF = 1e9 + 7;

void solve() {
    int m, n, x;
    cin >> m >> n >> x;
    int a[m][n], cost[m];
    loop(i, m) {
        cin >> cost[i];
        loop(j, n)
            cin >> a[i][j];
    }
    int ans = INF;
    loop(mask, (1 << m)) {
        int sum[n] = {0}, cans = 0;
        loop(i, m)
            if (mask & (1 << i)) {
                cans += cost[i];
                loop(j, n)
                    sum[j] += a[i][j];
            }
        bool ok = 1;
        loop(i, n)
            if (sum[i] < x)
                ok = 0;
        if (ok)
            ans = min(ans, cans);
    }
    cout << (ans == INF ? -1 : ans);
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}

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

int main(void) {
    char x, y;

    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> x >> y;
    if (x - 'A' < y - 'A') {
        cout << "<\n";
    } else if (x - 'A' > y - 'A') {
        cout << ">\n";
    } else {
        cout << "=\n";
    }

    return 0;
}

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

public class Main {
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        int n = sc.nextInt();
        List<String> s = new ArrayList<>();
        boolean ok = true;
        for (int i = 0; i < n; i++) {
            String x = sc.next();
            if (s.contains(x)) {
                ok = false;
            }
            s.add(x);
        }
        if (!ok) {
            System.out.println("No");
            return;
        }
        for (int i = 0; i < n; i++) {

            int last = s.get(i).length() - 1;
            if (i == n - 1) {
                break;
            }
            if (s.get(i).charAt(last) != s.get(i + 1).charAt(0)) {
                System.out.println("No");
                return;
            }
        }
        System.out.println("Yes");
    }
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


Measured memory_bytes: 21204
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);++i)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;

const int INF = 1e9;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int a, b, k;

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

  cin >> a >> b >> k;

  int s = 0;
  int m = min(a, b);
  int i = m;
  for(; i>0; i--) {
    if(a % i == 0 && b % i == 0) s++;
    if(s == k) break;
  }

  cout << i << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <climits>
using namespace std;
int mod = 1e9+7;

int main()
{
    ios::sync_with_stdio(false);
    int h,w;
    cin >> h >> w;
    vector<string> v(h);
    for(int i=0;i<h;i++)
        cin >> v[i];
    vector<vector<int> > dp(h,vector<int> (w,0));
    dp[h-1][w-1] = 1;
    for(int j=w-2;j>-1;j--)
        if(v[h-1][j]=='.')
            dp[h-1][j] = dp[h-1][j+1];
            
    for(int i=h-2;i>-1;i--)
        if(v[i][w-1]=='.')
            dp[i][w-1] = dp[i+1][w-1];
    
    for(int i=h-2;i>-1;i--){
        for(int j=w-2;j>-1;j--){
            if(v[i][j]=='.')
                dp[i][j] = (dp[i+1][j]+dp[i][j+1])%mod;
        }
    }
    /*
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++)
            cout << dp[i][j] << " ";
        cout << "\n";
    }
    */
    cout << dp[0][0];
    return 0;
}


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

using namespace std;

string sum(string &a, string &b)
{
    if (a.size() < b.size()) swap(a, b);
    reverse(a.begin(), a.end());
    reverse(b.begin(), b.end());

    int N = a.size();
    
    while ((int)b.size() < N) {
        b.push_back('0');
    }
    
    bool up = 0;
    string res;
    for (int i = 0; i < N; i++) {
        int v = up + (a[i] - '0') + (b[i] - '0');
        if (v >= 10) {
            up = 1;
            v %= 10;
        } else {
            up = 0;
        }
        res += to_string(v);
    }
    if (up) res += "1";
    reverse(res.begin(), res.end());
    return res;
}

int main()
{
    int N;
    string a, b;
    cin >> N;
    while (N--) {
        cin >> a >> b;
        string res = sum(a, b);
        if (res.size() > 80) {
            cout << "overflow" << endl;
        } else {
            cout << res << endl;
        }
    }
    return 0;
}

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

vector <int> num, rec;

int main() {
	int n;
	cin >> n;
	num.resize(n + 1);
	rec.resize(n + 1);
	for(int i = 1; i <= n; ++i) {
		cin >> num[i];
		rec[i] = 0;
	}
	
	vector <int> ans;
	for(int i = n; i > 0; --i) {
		int sum = 0;
		int j = 2 * i;
		while(j <= n) {
			sum += rec[j];
			j += i;
		}
		if(sum % 2 != num[i]) {
			rec[i] = 1;
			ans.push_back(i);
		}
	}
	
	cout << ans.size() << endl;
	
	for(int i = 0; i < ans.size(); ++i) {
		cout << ans[i] << " ";
	}
}

Measured memory_bytes: 3064
S = input()
S = S.replace("><", ">,<").split(",")
Ans = 0
for T in S:
    a = T.count(">")
    b = T.count("<")
    for i in range(1, max(a, b) + 1):
        Ans += i
    for j in range(1, min(a, b)):
        Ans += j

print(Ans)



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

using namespace std;

int main() {
	vector<int> heights;
	int meter;

	for(int index = 0; index < 10; ++index) {
		cin >> meter;
		heights.push_back(meter);
	}
	
	sort(heights.begin(), heights.end());
	
	cout << heights[9] << endl;
	cout << heights[8] << endl;
	cout << heights[7] << endl;
	
	return 0;
}


Measured memory_bytes: 3164
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

long long int A, B, V, W, T;

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

	string ans;

	if (V <= W) { ans = "NO"; }
	if (V*T - W*T >= abs(A - B)) { ans = "YES"; }
	else { ans = "NO"; }

	cout << ans << endl;

	return 0;
}

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

using namespace std;

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

int main() {
	int n;
	string s;
	cin >> s;
	n = s.size();
	vector<int> ans(n);
	rep(ri, 2) {
		{
			int cnt = 0;
			rep(i, n) {
				if (s[i] == 'R') cnt++;
				else {
					ans[i] += cnt / 2;
					ans[i - 1] += (cnt + 1) / 2;
					cnt = 0;
				}
			}
		}

		reverse(ans.begin(), ans.end());
		reverse(s.begin(), s.end());
		rep(i, n) {
			if (s[i] == 'L') s[i] = 'R';
			else s[i] = 'L';
		}
	}

	rep(i, n) {
		printf("%d\n", ans[i]);
	}
	return 0;
}


Measured memory_bytes: 1024
from collections import Counter
n = int(input())
for i in range(n):
	if not i:
		c0 = Counter(input())
	else:
		c = Counter(input())
		for l in c0.keys():
			c0[l] = min(c0[l], c[l])
k = sorted(c0.keys())
ans = ""
for l in k:
	ans += l*c0[l]
print(ans)


Measured memory_bytes: 3444
#include<bits/stdc++.h>
#define ll long long
#define f   first
#define s   second
#define pb          push_back
#define mod         1000000007
#define hell        998244353
#define inf         1000000000000000000LL
using namespace std;
ll n,k,m;
//ll dp[15][1005];
ll dp[100005];
ll lvl[100005];
ll power(ll x,ll y)
{
    ll res=1;
    while(y>0)
    {
        if(y%2){res=(res*x)%mod;}
        x=(x*x)%mod;
        y/=2;
    }
    return res;
}
ll invmod(ll x)
{ return power(x,mod-2);}
void solve()
{   ll W,X,D;
    cin>>k>>n;
    ll ar[n+1];
    ll v[n+1];
    for(int i=1;i<=n;i++)
    {
        cin>>ar[i];
    }
    for(int i=2;i<=n;i++) v[i]=ar[i]-ar[i-1];
    ll ans=ar[n]-ar[1];
    for(int i=2;i<=n;i++)
        ans=min(ans,k-v[i]);
    //ans=min(ans,k-ar[n]);
    cout<<ans;
    


    
   

    
}

int main()
{
    ll t=1;
    //cin>>t;
    
    while(t--)
        solve();

}

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

//-----------------------------------------------

//------------------------------------------------
int main(){
  string s,t;
  int a,b;
  cin>>s;
  t=s;
  a=s.size();
  for(int i=0;i<a;i++) t.at(i)='x';
  cout<<t<<endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N;
  cin >> N;
  int t1 = 0, ti, t2 = 0;
  F0R(i, N) {
    int a;
    cin >> a;
    if (a >= t1) {
      t2 = t1;
      t1 = a;
      ti = i;
    }
    else if (a > t2) {
      t2 = a;
    }
  }
  F0R(i, N) {
    cout << (i == ti ? t2 : t1) << newl;
  }
}
#endif


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
long long n,x,y,a,b,k;
int main()
{
    cin>>n>>a>>b;
    for (int i=0;i<n;i++)
    {
        cin>>x>>y;
        if (x>=a&&y>=b)
            k++;
    }
    cout<<k;
    return 0;
}


Measured memory_bytes: 256
import math


l = int(input())
node = int(math.log2(l)) + 1
edges = []

for _from in range(1, node):
    edges.append([_from, _from+1, 0])
    edges.append([_from, _from+1, 2**(_from-1)])

count = 2 ** (node-1)
lack = l - count
length = 2 ** (node-1)

for _from in range(node-1, 0, -1):
    if not lack:
        break
    add_line = 2 ** (_from-1)
    if add_line > lack:
        continue
    edges.append([_from, node, length])
    lack -= add_line
    length += add_line

print(node, len(edges))
for _from, to, length in edges:
    print(_from, to, length)


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

int main() {
	int N, ans = 0;
	cin >> N;

	vector<int> L(N);
	for (int i = 0; i < N; i++) cin >> L.at(i);

	sort(L.begin(), L.end());

	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < i; j++) {
			for (int k = 0; k < j; k++) {
				if (L[k] != L[j] and L[i] != L[j] and L[k] + L[j] > L[i]) {
					ans++;
				}
			}
		}
	}

	cout << ans << endl;

}

Measured memory_bytes: 3612
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
using namespace std;

#define ll long long
#define INF (1 << 30)
#define INFLL (1LL << 60)

#define FOR(i,a,b) for(ll i = (a);i<(b);i++)
#define REP(i,a) FOR(i,0,(a))
#define MP make_pair

int main() {
	int n, y;
	int ans1 = -1, ans2 = -1, ans3 = -1;
	cin >> n >> y;
	for(int i = 0;i <= 2000;i++){
		for(int j = 0;j <= 2000;j++){
			int last = y - 10000*i - 5000*j;
			if(last < 0) continue;

			int ret = last / 1000;

			if(i + j + ret == n){
				ans1 = i;
				ans2 = j;
				ans3 = ret;
			}
		}
	}

	cout << ans1 << " " << ans2 << " " << ans3 << endl;
	return 0;
}

Measured memory_bytes: 256