akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;

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

    int n = s.size();
    vector<int> v(n);

    int r = 0;
    rep(i, n-1){
        if(s[i] == 'R') r++;
        if(s[i] == 'R' && s[i+1] == 'L'){
            v[i] += r;
            r = 0;
        }
    }

    int l = 0;
    for(int i = n-1; i>0; i--){
        if(s[i] == 'L') l++;
        if(s[i] == 'L' && s[i-1] == 'R'){
            v[i] += l;
            l = 0;
        }
    }

    rep(i, n-1){
        if(s[i] == 'R' && s[i+1] == 'L'){
            int x = v[i], y = v[i+1];
            int t = max(x-1, y-1);
            if(v[i] >= v[i+1]){
                v[i] = (x+y)/2 + (x+y)%2;
                v[i+1] = (x+y)/2;
            }
            else if(v[i+1] > v[i]){
                v[i] = (x+y)/2;
                v[i+1] = (x+y)/2 + (x+y)%2;
            }

            if(t%2 == 1) swap(v[i], v[i+1]);

            i++;
        }
    }

    rep(i, n) cout << v[i] << " ";
    cout << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <cfloat>
#define zero(x) (((x)>0?(x):-(x))<eps)

#define pause cout << " press ansy key to continue...",  cin >> chh
#define file_r(x) freopen(x,  "r",  stdin)
#define file_w(x) freopen(x,  "w",  stdout)
#define lowbit(x) ((x) & (-x))
#define repit(i, c) for (__typeof__((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repe(i, u) for (int i = head[u]; i != -1; i = nxt[i])
#define repd(i, n) for (int i = (n - 1); i >= 0; i--)
#define FOR(i, n, m) for (int i = (n); i <= (m); i++)
#define FORD(i, n, m) for (int i = (n); i >= (m); i--)
#define pb push_back
#define X first
#define Y second
#define ins insert
#define rb rbegin
#define be begin
#define er erase
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define SZ(c) (c).size()
#define ALL(c) (c).begin(), (c).end()
#define sqr(r) ((r) * (r))
#define dis(x1, y1, x2, y2) (((x1) - (x2)) * ((x1) - (x2)) + ((y1) - (y2)) * ((y1) - (y2)))
#define FASTIO ios::sync_with_stdio(false);cin.tie(0)

#define sc(x) cout << #x" = " << x << endl, system("pause")
#define sc2(x, y) cout << #x" = " << x << " " << #y" = " << y << endl, system("pause")
#define sc3(x, y, z) cout << #x" = " << x << " " << #y" = " << y << " " << #z" = " << z << endl, system("pause")
#define sc4(x, y, z, w) cout << #x" = " << x << " " << #y" = " << y << " " << #z" = " << z << " " << #w" = " << w << endl, system("pause")

#define in(n) scanf("%d", &n)
#define in2(n, m) scanf("%d %d", &n, &m)
#define in3(x, y, z) scanf("%d %d %d", &x, &y, &z)

using namespace std;
int chh;

typedef vector<int> vi;
typedef set<int> si;
typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<int, pii> pi3;
typedef vector< pair<int, int> > vpii;
typedef long long LL;

const int N = 100005;

int n;
char s[N];
bool f[N];

bool ok() {
    int p2, p1, now;
    bool id;
    FOR (i, 2, n + 1) {
        now = (i + n) % n;
        p1 = (i - 1 + n) % n;
        p2 = (i - 2 + n) % n;
        if (f[p1] == 0) {
            if (s[p1] == 'o') id = f[p2];
            else id = f[p2] ^ 1;
        } else {
            if (s[p1] == 'o') id = f[p2] ^ 1;
            else id = f[p2];
        }
        if (i == n && id != f[0]) return 0;
        if (i == n + 1 && id != f[1]) return 0;
        f[now] = id;
    }
    return 1;
}

bool solve() {
    rep (i, 2) rep (j, 2) {
        f[0] = i, f[1] = j;
        if (ok()) return 1;
    }
    return 0;
}

int main() {
    bool flag;
    while (~in(n)) {
        scanf("%s", s);
        flag = solve();
        if (!flag) puts("-1");
        else {
            rep (i, n - 1) printf("%c", f[i] ? 'W' : 'S');
            printf("%c\n", f[n - 1] ? 'W' : 'S');
        }
    }
    return 0;
}


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

import static java.lang.System.in;

class Main{
    public static void main(String[] args)throws IOException{
        Scanner sc = new Scanner(System.in);
        double r1 = sc.nextDouble(), r2=sc.nextDouble();
        double ans = r1*r2/(r1+r2);
        System.out.println(ans);
    }
}


Measured memory_bytes: 25300
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

vector<long> vc;

void dfs(long n)
{
  if (1000000000 < n)
    return;
  vc.push_back(n);
  dfs(10 * n + 7);
  dfs(10 * n + 5);
  dfs(10 * n + 3);
}

int main()
{
  int N;
  cin >> N;
  dfs(0);
  int ans = 0;
  REP(i, vc.size())
  {
    string s = to_string(vc[i]);
    if (s.find('7') != s.npos && s.find('5') != s.npos && s.find('3') != s.npos && vc[i] <= (long)N)
      ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
#include <iostream>

int main()
{
  int N, A, B;
  std::cin >> N >> A >> B;
  int ans = 0;

  for ( int i = 1; i <= N; i++ ) {
    int tmp = i;
    int sum = 0;
    while (tmp > 0) {
      sum += tmp % 10;
      tmp /= 10;
    }
    if ( A <= sum && sum <= B ) ans += i;
  }
  std::cout << ans << std::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;
typedef long long ll;

int main(){
    string s;
    cin >> s;
    bool ans=false;
    int n=s.size();
    if(s[0]=='A'){
        int cnt=0;
        for(int i=2;i<n-1;i++){
            if(s[i]=='C')cnt++;
        }
        if(cnt==1){
            int j=0;
            for(int i=1;i<n;i++){
                if(s[i]<'a')j++;
            }
            if(j==1)ans=true;
        }
    }
    if(ans)cout<<"AC"<<endl;
    else cout<<"WA"<<endl;
    return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <queue>
#include <ctime>
#include <cassert>
#include <cstdio>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <bitset>

using namespace std;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define epr(...) fprintf(stderr, __VA_ARGS__)
#define db(x) cerr << #x << " = " << x << endl
#define db2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n"; 
#define db3(x, y, z) cerr << "(" << #x << ", " << #y << ", " << #z << ") = (" << x << ", " << y << ", " << z << ")\n"
#define all(a) (a).begin(), (a).end()

#define equal equalll
#define less lesss
const int N = 1e6 + 10;
const long long INF = 1e9 + 19;

int n;
int a[N];

void read() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]); a[i]--;
	}
	int cnt = 0;
	for (int i = 0; i < n; i++)
		cnt += a[a[i]] == i;
	cout << cnt / 2 << endl;

}

void solve() {

}

void stress() {

}

int main(){
#ifdef MY_DEBUG
    freopen("in", "r", stdin);
    //freopen("out", "w", stdout);
#endif
    if (1) {
        int k = 1;
        for (int tt = 0; tt < k; tt++) {
            read();
            solve();
        }
    }
    else {
        stress();
    }

    return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main() {
  int K,X;
  cin >> K >>X;
  for(int i=K-1; i>=0; i--){
	cout << X-i;
    cout << " ";
  }
  for(int i=1; i<K; i++){
    cout << X+i;
    cout << " ";
  }
  cout << endl;
}

Measured memory_bytes: 256
N,T = (int(i) for i in input().split())
t = [int(i) for i in input().split()]
time = 0
for i in range(N-1):
    if t[i+1]-t[i] >= T:
        time += T
    else:
        time += (t[i+1]-t[i])

time += T
print(time)

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

int main(){
  int N;
  cin >> N;
  vector<pair<int,int>> V;
  for(int i = 0; i < N; ++i){
    int a;
    cin >> a;
    V.emplace_back(a,i+1);
  }
  sort(V.begin(), V.end());
  for(auto p : V)
    cout << p.second << " ";
  cout << endl;
}


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

template <class T>
inline void read(T &x) {
    x = 0;
    char c = getchar();
    bool f = 0;
    for (; !isdigit(c); c = getchar()) f ^= c == '-';
    for (; isdigit(c); c = getchar()) x = x * 10 + (c ^ 48);
    x = f ? -x : x;
}

template <class T>
inline void write(T x) {
    if (x < 0) {
        putchar('-');
        x = -x;
    }
    T y = 1;
	int len = 1;
    for (; y <= x / 10; y *= 10) ++len;
    for (; len; --len, x %= y, y /= 10) putchar(x / y + 48);
}

int h, w, d;
char s[4] = { 'R', 'Y', 'G', 'B' };

int main() {
	read(h), read(w), read(d);
	for (int i = 1; i <= h; ++i, putchar('\n'))
		for (int j = 1; j <= w; ++j) {
			int x = i + j + w, y = i - j + w;
			putchar(s[((x / d) & 1) * 2 + ((y / d) & 1)]);
		}
	return 0;
}

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

int main()
{
  int n;
  long long temp,ans=1;
  double lock;

  cin>>n;
  for(int i=0;i<n;i++)
  {
    scanf("%lld",&temp);
    if(temp==0)
    {
      cout<<0;
      return 0;
    }
    lock=lock+log10(temp);
    ans *=temp;
  }
  if (lock>18.0 || ans>1000000000000000000)
     {
         cout<<-1;
         return 0;
     }
     cout<<ans;
     return 0;
}


Measured memory_bytes: 4000
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG_ 
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

int main(void) {
    ll n, a, b;
    cin >> n >> a >> b;

    if(__builtin_popcountll(a)%2 == __builtin_popcountll(b)%2) {
        cout << "NO" << endl;
        return 0;
    }

    // 0からa^bにいく
    ll num = __builtin_popcountll(a^b);
    vector<ll> ord;
    REP(i, num) {
        // [i+1,n-1] を全部回す
        vector<ll> v;
        FOR(j, i+1, n) {
            auto tmp(v);
            v.push_back(j);
            for(auto k: tmp) v.push_back(k);
        }
        for(auto j: v) ord.push_back(j);
        // iを反転する
        ord.push_back(i);
    }
    vector<ll> v;
    FOR(j, num, n) {
        auto tmp(v);
        v.push_back(j);
        for(auto k: tmp) v.push_back(k);
    }
    for(auto j: v) ord.push_back(j);

    ll idx1 = 0, idx2 = __builtin_popcountll(a^b);
    vector<ll> x(n, -1);
    REP(i, n) {
        if((a^b)&1LL<<i) x[idx1++] = i;
        else x[idx2++] = i;
    }
    REP(i, ord.size()) ord[i] = x[ord[i]];

    ll now = 0;
    vector<ll> ret;
    REP(i, ord.size()) {
        ret.push_back(now);
        now ^= 1LL<<ord[i];
    }
    ret.push_back(now);
    for(auto &i: ret) i ^= a;

    cout << "YES\n";
    REP(i, ret.size()) cout << ret[i] << (i+1==(ll)ret.size() ? '\n' : ' ');
    cout << flush;

    return 0;
}

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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  ll n; cin >> n;
  ll now = 1;
  ll ans = 0;
  while(1) {
    ll tmp = n - now;
    if(tmp / now == 0) break;
    if(tmp % now == 0) {
      if(n / (tmp / now) == n % (tmp / now)) ans += tmp / now;
    }
    if(now >= tmp / now) {
      break;
    }
    now++;
  }
  cout << ans << endl;

}


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


int main()
{
  int n,x;
  cin >> n >> x;
  vector<int> a(n+1);
  a[0] = x;
  for(int i = 1;i <= n;i++){
    cin >> a[i];
  }
  sort(a.begin(),a.end());

  int res = a[1] - a[0];
  for(int i = 1;i < n;i++){
    res = __gcd(res,a[i+1] - a[i]);
  }

  cout << res << endl;
  return 0;

}


Measured memory_bytes: 640
using System;


public class A{
	
	public static void Main(){
	
		string[] args = Console.ReadLine().Split(' ');
		int a = Int32.Parse(args[0]);
		int b = Int32.Parse(args[1]);
		int c = Int32.Parse(args[2]);
		
		int result;
		if( a > b ){
			if( a > c ){
				result = 10 * a + b + c;
			}else{
				result = 10 * c + a + b;
			}			
		}else{
			if( b > c ){
				result = 10 * b + a + c;
			}else{
				result = 10 * c + a + b;
			}
		}
		Console.WriteLine(result);
		
	}
	
}

Measured memory_bytes: 11092
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <fstream>
#include <list>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str(); }
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = INT_MAX / 10;

int main() {
	int n, w;
	while (cin >> n >> w, n) {
		vi v(n);
		int maxv = -1;
		REP(i, n) {
			cin >> v[i];
			maxv = max(maxv, v[i]);
		}

		vi bar(maxv / w + 1);
		REP(i, n) {
			bar[v[i] / w]++;
		}

		double maxh = -1, size = bar.size();
		REP(i, size) {
			maxh = max(maxh, 1.0*bar[i]);
		}

		double ans = 0.01;
		REP(i, size) {
			ans += ((size - 1 - i) / (size - 1)) * (bar[i] / maxh);
		}

		cout.precision(10);
		cout << ans << endl;
	}
	return 0;
}

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

using namespace std;

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

int main() {
	int n, m;
	cin >> n >> m;
	int x, y, z;
	set<int> pos;
	map<int, vector<int>> rec;
	vector<int> l(m), r(m), d(m);
	for (int i = 0; i < m; i++) {
		cin >> l[i] >> r[i] >> d[i];
		pos.insert(l[i]);
		pos.insert(r[i]);
		if (!rec.count(l[i])) {
			rec[l[i]] = vector<int>();
		}
		rec[l[i]].push_back(i);
		if (!rec.count(r[i])) {
			rec[r[i]] = vector<int>();
		}
		rec[r[i]].push_back(i);
	}
	if (!rec.count(1)) {
		cout << -1 << endl;
		return 0;
	}
	set<PII> sta;
	vector<ll> f(m, -1);
	for (int i: rec[1]) {
		f[i] = d[i];
		sta.insert(make_pair(f[i], i));
	}
	pos.erase(1);
	for (int p: pos) {
		// cout << p << ": " << sta.size() << endl;
		if (sta.size() == 0) {
			break;
		}
		for (int i: rec[p]) {
			if (l[i] == p) {
				f[i] = sta.begin() -> first + d[i];
				sta.insert(make_pair(f[i], i));
			}
		}
		for (int i: rec[p]) {
			if (r[i] == p) {
				sta.erase(make_pair(f[i], i));
			}
		}
	}
	ll ans = -1;
	for (int i = 0; i < m; i++) {
		if (r[i] == n && f[i] != -1) {
			ans = ans == -1 ? f[i] : min(ans, f[i]);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 18176
#include <bits/stdc++.h>
using namespace std;
 
#define faster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define mp make_pair
#define mod 1000000007
#define qmod 998244353
#define endl "\n"
#define pb push_back
#define ff first
#define ss second
 
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
 
const int MOD = 1e9 + 7;
const int INF = 1e9 + 5;
const ll LINF = LLONG_MAX;

int main(){
	int a,b,c;
	cin>>a>>b>>c;
	int count=0;
	if(a==b&&b==c){
		if(a&1){
			cout<<"0"<<endl;
			return 0;
		}
		else{
			cout<<"-1"<<endl;
			return 0;
		}
	}
	while(a%2==0 and b%2==0 and c%2==0){
		int x = a/2;
		int y = b/2;
		int z = c/2;
		a /=2;
		b /=2;
		c /=2;
		a +=y;
		b +=z;
		c +=x;
		count++;
	}
	cout<<count;;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;
    long long ans = 0;
    if ((A + B) / 2 >= C)
    {
        long long min_num = min(X, Y);
        ans += min_num * 2 * C;
        X -= min_num;
        Y -= min_num;
        if ((A <= 2 * C) || (B <= 2 * C))
        {

            ans += (min(A, 2*C) * X + min(B,2*C) * Y);
        }
        else
        {
            ans += max(X, Y) * 2 * C;
        }
    }
    else
    {
        ans += (A * X + B * Y);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
A.sort(reverse=True)
C = A[0]
j=0
for i in range(1,N-1):
  if i%2 == 0:
    C = C+A[j]
  elif i%2 != 0:
    j=j+1
    C = C+A[j]
print(C)

Measured memory_bytes: 31448
# -*- coding: utf-8 -*-
def solve():
    N, M = map(int, input().split())
    WA = dict()
    AC = dict()
    for i in range(1, M+1):
        p, S = input().split()
        if S == 'WA' and p not in AC:
            WA[p] = WA.get(p,0)+1
        if S == 'AC':
            AC[p] = 1

    return str(len(AC)) + ' ' + str(sum(WA.get(p,0) for p in AC))

if __name__ == '__main__':
    print(solve())


Measured memory_bytes: 17108
using System;
using System.Linq;

class Program
{
    public static void Main()
    {
        int count = 0;
        double[] input = Console.ReadLine().Split(' ').Select(i => double.Parse(i)).ToArray();

        do
        {
            count++;
            input[0] /= input[1];
        } while (input[0] >= 1);

        Console.WriteLine(count);
    }
}

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

#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define EPS (1e-7)

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

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

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

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

int main(){
	int n;
	cin>>n;
	int left=0;
	int right=n;
	int mid=0;
	int sex[n];
	fill(sex,sex+n,-1);
	string pre;
	int ans;
	for(int i=0;i<20;i++){
		cout<<mid<<endl;
		string res;
		cin>>res;
		if(res=="Vacant"){
			ans=mid;
			break;
		}else if(res=="Male"){
			sex[mid]=1;
		}else if(res=="Female"){
			sex[mid]=2;
		}

		if(i>0){
			if((left-mid)%2!=0){
				if(sex[left]!=sex[mid]){
					left=mid;
				}else{
					right=mid;
				}
			}else{
				if(sex[left]!=sex[mid]){
					right=mid;
				}else{
					left=mid;
				}
			}
			pre=res;
		}
		mid=(right+left)/2;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1236
#include<iostream>
#include<string>
#include<vector>
#include<cstdio>
#include<sstream>
#include<algorithm>
#include<cmath>
#include<map>
using namespace std;
int stoi(string x){stringstream ss;ss<<x;int tmp;ss>>tmp;return tmp;}
string itos(int x){stringstream ss;ss<<x;return ss.str();}
double ta[300][3];
bool used[300],tused[300];

	int n,m;
double ans=0;
double solve(int now){
double ret=0.0;
while(true){
	tused[now]=0;

	int next=0,f=0;
	for(int i=0;i<n;i++){
		if(tused[i]&&!f)next=i,f=1;
	}
	for(int i=0;i<n;i++){
	if(tused[i]){
		for(int j=0;j<3;j++)ret+=(ta[i][j]-ta[now][j])*(ta[i][j]-ta[now][j]);

		}
	}
	now=next;
	bool endf=1;
	for(int i=0;i<n;i++)if(tused[i])endf=0;
	if(endf)break;
}
return ret;
}
void  dfs(int h,int use){
	if(h==n){
	//for(int i=0;i<n;i++)cout<<used[i]<<" ";cout<<endl;
	if(use==m){
	int next=0;
	for(int i=n-1;i>=0;i--)if(used[i])next=i,tused[i]=used[i];
	ans=max(ans,solve(next));
	}
	return ;
	}
	used[h]=1;
	dfs(h+1,use+1);
	used[h]=0;
	dfs(h+1,use);
}
int main(){

	scanf("%d%d",&n,&m);
	for(int i=0;i<n;i++)cin>>ta[i][0]>>ta[i][1]>>ta[i][2];
	dfs(0,0);
	printf("%.10f\n",ans);
	return 0;
}

Measured memory_bytes: 1284
#include <stdio.h>

int main (void)
{
    int a, b, c;

    scanf("%d %d %d", &a, &b,&c);

    if (a == b) {
        printf("%d\n", c);
    } else if (a == c) {
        printf("%d\n", b);
    } else {
        printf("%d\n", a);
    }

    return 0;
}

Measured memory_bytes: 128
function main()
    a,b,c,d=myreads(Int)
    println(maximum([a*c,a*d,b*c,b*d]))
end

# ----------input function----------
sread()=chomp(readline())
sreads(sp=" ")=split(readline(),sp)
myread(ty)=parse(ty,sread())
myreads(ty)=map(x->parse(ty,x),sreads())
main()

Measured memory_bytes: 172628
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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; }

const int mod=1000000007;
const int INF=1001001001;
int main() {
  int N;
  cin>>N;
  string s;
  cin>>s;
  if(N%2==0&&s.substr(0,N/2)==s.substr(N/2,N/2)){cout<<"Yes"<<endl;}
  else{cout<<"No"<<endl;}
  return 0;
}


Measured memory_bytes: 3632
/*
A0006
Reverse Sequence

*/
#include <stdio.h>
#include <string.h>
main()
{
	char str[100];
	int i,l,h;
	char	w;

	scanf("%s",str);
	l=strlen(str);h=l/2;
	for(i=0;i<h;i++)
	{	w = str[i];
		str[i] = str[l-i-1];
		str[l-i-1]=w;
	}
	printf("%s\n",str);
	return(0);
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int main() {
  int A, B, C, D, E, X;
  cin >> A >> B >> C >> D >> E >> X;
  int ma, mi;
  ma = max(max(max(max(A, B), C), D), E);
  mi = min(min(min(min(A, B), C), D), E);
  if(ma - mi > X) {
    cout << ":(" << endl;
  }
  else {
    cout << "Yay!" << endl;
  }
}

Measured memory_bytes: 3608
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <math.h>

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



int main() {
	
	
	int A, B, C;
	cin >> A >> B >> C;

	vector<int> x(3);
	x[0] = A;
	x[1] = B;
	x[2] = C;

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

    int ans=0;
	rep(i, 2) 
	{
		if (x[i] == x[i + 1])
		{
			ans +=1;
		}
		
	}

	if (ans == 0 || ans == 2)
	{
		cout << "No" << endl;
	}
	else
	{
		cout << "Yes" << endl;
	}


	return 0;
}




Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include<string>
#include <bitset>
#include <vector>
#include <functional>
#include <climits>
#include <iomanip>
#include <utility>
#include <stack>
#include <queue>
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
using namespace std;
using ll = long long;
ll n, m;
ll sum = 0;
	ll memo[50][50] = {};
void kansuu(ll num, ll visited[10]) {
	ll flag = 0;
	for (int i = 2; i <= n; i++)
	{
		if (visited[i]==0)
		{
			flag = 1;
		}
	}
	if (flag==0)
	{
		sum++;
		return;
	}
			ll x[10] = {};
	for (ll i = 1; i <= n; i++)
	{
		if (memo[num][i]==1&&visited[i]==0)
		{
			memcpy(x, visited, sizeof(ll)*10);
			/*cout << "x=" ;
			for (ll z = 1; z <= n; z++)
			{
				cout << x[z];
			}
			cout << endl;
			cout << "visited=";
			for (ll z = 1; z <= n; z++)
			{
				cout << visited[z];
			}
			cout << endl;
			cout << endl;
*/
			x[i]=1;
			kansuu(i, x);
		}
	}
	
}
int main()
{
	ll a, b = 0, c = 0, d = 0;
	ll l;
	char C[1000][1000] = {};
	ll h, w, sy, sx, gy, gx;
	queue<int> x, y;
	cin >> n;
	cin >> m;
	for (int i = 0; i < m; i++)
	{
		cin >> a;
		cin >> b;
		memo[a][b] = 1;
		memo[b][a] = 1;
	}
	ll zz[10] = {};
	zz[1] = 1;
	kansuu(1,zz);


	cout << sum << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef pair<string,string> Pstring;
typedef pair<double,double> Pdouble;



#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define Precision13 cout << fixed << setprecision(13)
const double PI=3.14159265358979323846;
const int MAX = 510000;
const int MOD = 1000000007;
const int INF = 1<<29;

using Graph = vector<vector<char>>;

int main() {
  ll N,W;
  cin >> N >> W;
  vector<int> v(N);
  vector<int> w(N);
  REP(i,N) cin >> v.at(i) >> w.at(i);
  int dp[110][10010];
  for(int i=0; i<=W; i++) dp[0][i] = 0;

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

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


Measured memory_bytes: 7032
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())





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


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

	if (k == 1)cout << 0 << endl;
	else cout << n - k << endl;


	return 0;
}

Measured memory_bytes: 256
export default solve;

// =================================================
// ABC086A
// =================================================

// main
function main(lines) {
  console.log(solve(lines));
}

// solver
function solve(lines: string[]): string {
  const { a, b } = parseLines(lines);

  return (a * b) % 2 === 0 ? 'Even' : 'Odd';
}

// helpers
function parseLines(lines: string[]) {
  const [a, b] = lines[0].split(' ').map(s => +s);
  const obj = { a, b };
  debug(obj);
  return obj;
}

// general helpers
function debug(message?: any, ...optionalParams: any[]) {
  if (!!process.env.LOCAL_DEBUG) console.log(message, ...optionalParams);
}

// reader
if (!process.env.LOCAL_DEBUG) {
  const { stdin: input, stdout: output } = process;
  input.resume().setEncoding('utf8');
  const lines = [];
  require('readline')
    .createInterface({ input, output })
    .on('line', line => lines.push(line))
    .on('close', () => main(lines));
}


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

int main() {
    int a, b;
    cin >> a >> b;
    int res = -1;
    for (int i = 0; i < 10000; i++){
        if(floor(i * 0.08) == a && floor(i * 0.1) == b){
            res = i;
            break;
        }
    }
    cout << res << endl;
    return 0;
}

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

int main() {
    string s;
    bool w[4] = {false};
    cin >> s;
    for(char c : s) {
        if(c == 'N') w[0] = true;
        else if(c == 'S') w[1] = true;
        else if(c == 'W') w[2] = true;
        else if(c == 'E') w[3] = true;
    }
    cout << (w[0] == w[1] && w[2] == w[3] ? "Yes" : "No") << endl;
}

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

using namespace std;

typedef long long          ll;
typedef unsigned long long ull;
typedef vector<int>	       vi;
typedef vector<bool>       vb;
typedef map<int, int>      mii;
typedef pair<int, int>     ii;

#define INF                0x3f3f3f3f
#define INFLL              0x3f3f3f3f3f3f3f3f
#define each(x, s)         for(auto& x : s)
#define loop(x)	           for(int i = 0;i < x;i++)
#define vloop(v, x)        for(int v = 0;v < x;v++)
#define avg(l, r)          l + (r - l) / 2
#define iter(a)            a.begin(), a.end()
#define riter(a)           a.rbegin(), a.rend()
#define endl               "\n"

const ll mod = 1000000007;

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

	int n;
	cin >> n;
	vi a(n);
	vb primes(1e6 + 1, false);
	loop(n) cin >> a[i], primes[a[i]] = true;
	int ans = 0;
	sort(iter(a));
	loop(n) {
		if (primes[a[i]]) {
			if (i and a[i] == a[i - 1]) ans--, primes[a[i]] = false;
			else ans++;
			for (int j = a[i] + a[i];j <= 1e6;j += a[i]) primes[j] = false;
		}
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 4268
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics; 

class _Class
{
  void _Do()
  {
    var S = Split.strings()[0];
    var w = Split.ints()[0];

    for (int i = 0; i < S.Length; i += w)
      Console.Write(S[i]);

    Console.WriteLine();
 
  }


  //
  static void Main(string[] args)
  {
    _(args);
    new _Class()._Do();
  }

  [Conditional("DEBUG")]
  static void _(string[] args)
  {
    if (args.Length != 0 && File.Exists(args[0]))
      Console.SetIn(new StreamReader(args[0]));
    else
      Console.Error.WriteLine("in");
  }
}

static class Split
{


  // 1
  public static string[] strings()
  {
    return Console.ReadLine().Split();
  }


  // [2.1] -2,147,483,648 ~ +2,147,483,647
  public static int[] ints()
  {
    var _s = Console.ReadLine().Split();

    var x = new int[_s.Length];
    for (var i = 0; i < _s.Length; i++)
      x[i] = int.Parse(_s[i]);

    return x;
  }

  // [2.2] 
  // -9,223,372,036,854,775,808 ~ 
  // +9,223,372,036,854,775,807
  public static long[] longs()
  {
    var _s = Console.ReadLine().Split();

    var x = new long[_s.Length];
    for (var i = 0; i < _s.Length; i++)
      x[i] = long.Parse(_s[i]);

    return x;
  }

  public static double[] doubles()
  {
    var _s = Console.ReadLine().Split();

    var x = new double[_s.Length];
    for (var i = 0; i < _s.Length; i++)
      x[i] = double.Parse(_s[i]);

    return x;
  }

  public static BigInteger[] bigs()
  {
    var _s = Console.ReadLine().Split();

    var x = new BigInteger[_s.Length];
    for (var i = 0; i < _s.Length; i++)
      x[i] = BigInteger.Parse(_s[i]);

    return x;
  }
}




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

using namespace std;
typedef long long ll;

inline int at(ll x, int k){ return (x >> k) & 1; }
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)


int main() {
	int k,a,b;
	int flag =0;
	cin >> k>>a>>b;
	//cin >> s;
	rep(i,a,b+1){
		if(i%k==0){
			cout << "OK" << endl;
			flag =1;
			break;
		}
	}

if(flag==0){
  cout << "NG"<< endl;
}
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  int d[N];
  for(int i=0;i<N;i++)cin>>d[i];
  set<int> mochi;
  for(int i=0;i<N;i++)mochi.insert(d[i]);
  cout<<mochi.size()<<endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    long a, b, k;
    cin >> a >> b >> k;
    
    if(a <= k){  // aを食い尽くす
        k = k - a;
        if(b <= k){
            cout << 0 << " " << 0 << endl;
        }else{
            cout << 0 << " " << b-k << endl;
        }
    }else{
        cout << a-k << " " << b << endl;
    }
}

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

using namespace std; 
#define REP(i, n) for (int i = 0; i < (n); i++)

typedef long long ll;
int main(int argc, char const *argv[])
{
    cin.tie(0);
   	ios::sync_with_stdio(false);
    int N; cin >> N;
    string S; cin >> S;
    REP(i, (int)S.size()) {
        S[i] = 'A' + (S[i] - 'A' + N) % 26;
    }
    cout << S << endl;
    return 0;
}


Measured memory_bytes: 256
#<ABC175>
#<A>
S = input()

if S == "SSS":
    print(0)
if S == "RRR":
    print(3)
if S == "RRS" or S == "SRR":
    print(2)
if S == "RSR" or S == "RSS" or S == "SRS" or S == "SSR":
    print(1)


    



Measured memory_bytes: 9088
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << " ";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define tp tuple
#define ft first
#define sc second
#define ve vector
#define tos to_string
#define len length
#define rt return 0
#define br break
#define con continue
#define lcm(n, m) (n * m / gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define repill(i, m, n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define repll(i, n) repill(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m);i>(int)(n);i--)
#define rev(i, n) revi(i, 0, n)
#define revill(i, m, n) for(ll i=(ll)(m);i>(ll)(n);i--)
#define revll(i, n) revill(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define all(n) (n.begin(), n.end())
#define allr(n) (n.rbegin(), n.rend())
#define sp(n) cout << fixed << setprecision(n)
#pragma endregion
// sqrt ルート, int 2*10^9, gcd　最大公約数
// __builtin_popcount bitの個数

int main() {
  ll A, B, C;
  ci(A, B, C);
  repi(i, 1, 1000){
    rep(j, 1000){
      if(A * i == B * j + C){
        co("YES");
        rt;
      }
    }
  }
  co("NO");
}

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

using namespace std;

int main(void)
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int n, k;
	cin >> n >> k;
	vector<int> h(n);
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}
	vector<int> dp(n, INT_MAX);
	dp[0] = 0;
	for (int i = 0; i < n - 1; i++) {
		for (int j = i + 1; j <= i + k && j < n; j++) {
			dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j]));
		}
	}
	cout << dp[n - 1] << '\n';

	return 0;
}



Measured memory_bytes: 1024
#![allow(non_snake_case)]
#![allow(unused_variables)]

fn main() {
    let (N, K): (usize, usize) = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap()
        )
    };
    let A: Vec<i64> = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|x| x.parse().unwrap())
            .collect()
    };

    let mut c = vec![0; N + 1];
    for a in A {
        c[a as usize] += 1;
    }
    let mut b: Vec<_> = c.iter().filter(|&&z| z > 0).collect();
    b.sort();
    let m = b.len();
    let ans: i64 = if m <= K {
        0
    } else {
        let mut res: i64 = 0;
        for i in 0..(m - K) {
            res = res + b[i];
        }
        res
    };

    println!("{}", ans);
}


Measured memory_bytes: 10492
#include<bits/stdc++.h>
using namespace std;
const int MOD = 1e9+7;
char a[10010];
int dp[10010][2][110];
int n,len;
int play(int now,int state,int num){
    if(dp[now][state][num]!=-1) return dp[now][state][num];
    if(now == len)    return (num == 0);
    int sum = 0;
    int ma = (state)?a[now]-'0':9;
    for(int i=0;i<=ma;i++)
        sum = (sum + play(now+1,state && (i==ma),(num+i)%n ) )%MOD;
    return dp[now][state][num] = sum;
}
int main(){
    scanf(" %s %d",a,&n);
    len = strlen(a);
    memset(dp,-1,sizeof dp);
    printf("%d\n",(play(0,1,0)-1+MOD)%MOD);
    return 0;
}


Measured memory_bytes: 9728
#include <bits/stdc++.h>
#define PI acos(-1)
#define falcon ios_base::sync_with_stdio(false) ; cin.tie(NULL) ;
typedef long long ll ;
using namespace std ;



int main()
{
    falcon ;

    int dp[3001][3001] , nowi , nowj ;
    vector <char> characters ;

    string s , t ;
    cin >> s >> t ;
    for(int i = 0 ; i <= s.length() ; i++)
    {
        for(int j = 0 ; j <= t.length() ; j++)
        {
            if(i == 0 || j == 0) dp[i][j] = 0 ;
            else
            {
                if(s[i - 1] != t[j - 1]) dp[i][j] = max(dp[i - 1][j] , dp[i][j - 1]) ;
                else dp[i][j] = dp[i - 1][j - 1] + 1 ;
            }
        }
    }
    nowi = s.length() ;
    nowj = t.length() ;
    while(nowi > 0 && nowj > 0)
    {
        if(dp[nowi][nowj] == dp[nowi - 1][nowj]) nowi-- ;
        else if(dp[nowi][nowj] == dp[nowi][nowj - 1]) nowj-- ;
        else
        {
            characters.push_back(s[nowi - 1]) ;
            nowi-- ;
            nowj-- ;
        }
    }
    reverse(characters.begin() , characters.end()) ;
    for(int i = 0 ; i < characters.size() ; i++) cout << characters[i] ;
    cout << "\n" ;
}

Measured memory_bytes: 38804
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define Repr(i, n, a) for (int i = (n); i >= (a); i--)
#define rep(i, n) Rep(i, 0, n)
#define repr(i, n) Repr(i, n, 0)
#define all(a) a.begin(), a.end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    int n, l;
    cin >> n >> l;
    int sum = 0;
    rep(i, n) sum += l + i;
    int ans = INF, c;
    rep(i, n)
    {
        int now = l + i;
        int summ = sum - now;
        if (ans > abs(sum - summ))
        {
            ans = abs(sum - summ);
            c = sum - now;
        }
    }
    cout << c << endl;
}

Measured memory_bytes: 256
// 見せてやるぜ、奇跡ってやつをよぉ……
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, u, v; cin >> n >> u >> v;
    u--, v--;
    vvll edges(n);
    REP(i, n - 1) {
        ll a, b; cin >> a >> b;
        edges[a - 1].emplace_back(b - 1);
        edges[b - 1].emplace_back(a - 1);
    }

    vll dt(n, -1), da(n, -1);
    dt[u] = 0;
    queue<ll> que; que.push(u);
    while (!que.empty()) {
        ll q = que.front(); que.pop();
        for (ll e: edges[q]) {
            if (dt[e] == -1) {
                dt[e] = dt[q] + 1;
                que.push(e);
            }
        }
    }

    ll ans = 0;
    da[v] = 0;
    que.push(v);
    while (!que.empty()) {
        ll q = que.front(); que.pop();
        for (ll e: edges[q]) {
            if (da[e] == -1) {
                da[e] = da[q] + 1;
                que.push(e);
            }
        }
        if (da[q] > dt[q]) chmax(ans, da[q]);
    }
    cout << ans - 1 << '\n';
    return 0;
}



Measured memory_bytes: 8064
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<ctime>
#include<cstdlib>
#define LL long long 

using namespace std;
const int MAXN = 1e5 + 10, INF = 1e8 + 10, mod = 1e9 + 7, mod2 = 1e9 + 6;
inline int read() {
    char c = getchar(); int x = 0, f = 1;
    while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
    return x * f;
}
char s[MAXN];
main() { 
#ifdef WIN32
//	freopen("a.in", "r", stdin);
	//freopen("b.out", "w", stdout);
#endif
	scanf("%s", s + 1);
	int N = strlen(s + 1), k, tot = 0;
	scanf("%d", &k);
	for(int i = 1; i <= N; i++) {
		if(tot == 0)
			putchar(s[i]);
		 tot = (tot + 1) % k;
	}
	return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>//sort,reverse
#include<utility>//pair
#include<queue>//queue,priority_queue
#include<deque>//double_ended queue
using namespace std;
typedef pair<int,int> P;//Pでpair<-,->を表す。
typedef long long LL; 
LL MOD=1000000007;

int main()
{ 
    int n;
    cin>>n;
    LL a[10][10];
    for(int i=0;i<10;i++){
        for(int j=0;j<10;j++){
            a[i][j]=0;
        }
    }
    int deg=1;
    int deg2=10;
    for(int i=1;i<=n;i++){
        if(i>=deg2){deg2=deg2*10;deg=deg*10;}
        int b=i%10;
        int c=i/deg;
        a[c][b]++;
    }
    LL ans=0;
    for(int i=1;i<10;i++){
        for(int j=1;j<10;j++){
            ans=ans+a[i][j]*a[j][i];
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

A = [0] * N
A[0] = B[0]
for i in range(1,N-1):
    A[i] = min(B[i],B[i-1])
    
A[N-1] = B[N-2]

print(sum(A))

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {
    private static int MOD = 1000000007;


    public static void main(String[] args) throws IOException {
        InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(isr);
        String s = br.readLine();
        int n = Integer.parseInt(s.split(" ")[0]);
        int m = Integer.parseInt(s.split(" ")[1]);

        long n_ans = calcCombination(n, 2);
        long m_ans = calcCombination(m, 2);
        System.out.println(n_ans + m_ans);
    }

    private static long calcCombination(int n, int m) {
        if (n < m || m < 0) {
            return 0;
        }
        long c = 1;
        m = (n - m < m ? n - m : m);
        for (int ns = n - m + 1, ms = 1; ms <= m; ns++, ms++) {
            c *= ns;
            c /= ms;
        }
        return c;
    }

}


Measured memory_bytes: 23124
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <ctime>
#include <map>
#include <iomanip>
using namespace std;

typedef long long ll;

#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
 
long gcd(long long a, long long b){
	if (a%b==0){
		return b;
	}
	else{
		return gcd(b,a%b);
	}
}
 
long lcm(long long a, long long b){
	return a / gcd(a,b) * b;
}
 
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a < b) { a = b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a > b) { a = b; return 1; } return 0; }
 
const ll INF = 1ll<<60;
const ll MOD = 1000000007;
const double EPS = 1e-10;

string s;
ll k;

int main(){
	cin >> s >> k;

	int i = 0;
	while (s[i] == '1'){
		i++;
	}

	if (k <= i) cout << "1" << endl;
	else cout << s[i] << endl;

	return 0;
}

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

int main() {
	int N, Q;
	cin >> N >> Q;
	dsu d(N);
	for (int q = 0; q < Q; q++) {
		int t, u, v;
		cin >> t >> u >> v;
		if (t == 0) d.merge(u, v);
		else cout << (int)d.same(u, v) << endl;
	}
}


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

vector<pair<int,int>> v[20];
int n;

void init(){
    for(int i = 0; i < 20; i++) v[i].clear();
}

int dfs(int now, int par){
    int ret = 0;
    for(pair<int,int> p : v[now]){
        if(p.first == par)  continue;
        if(v[p.first].size() != 1){
            ret += dfs(p.first, now) + 2*p.second;
        }
    }
    return ret;
}

int dfs2(int now, int par){
    int ret = 0;
    for(pair<int,int> p : v[now]){
        if(p.first == par)  continue;
        if(v[p.first].size() != 1){
            ret = max(ret, p.second+dfs2(p.first, now));
        }
    }
    return ret;
}

int main(){
    while(cin >> n, n){
        init();
        int a, b, t;
        for(int i = 0; i < n-1; i++){
            cin >> a >> b >> t;
            a--, b--;
            v[a].push_back({b,t});
            v[b].push_back({a,t});
        }
        cout << dfs(0,-1) - dfs2(0,-1) << endl;
    }
    return 0; 
}


Measured memory_bytes: 3116
/****************************************************************
*	Author: huhao
*	Email: 826538400@qq.com
*	Create time: 2020-02-15 17:45:39
****************************************************************/
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#define fr(i,a,b) for(int i=(a),end_##i=(b);i<=end_##i;i++)
#define fd(i,a,b) for(int i=(a),end_##i=(b);i>=end_##i;i--)
int read()
{
	int r=0,t=1,c=getchar();
	while(c<'0'||c>'9')
	{
		t=c=='-'?-1:1;
		c=getchar();
	}
	while(c>='0'&&c<='9')
	{
		r=(r<<3)+(r<<1)+(c^48);
		c=getchar();
	}
	return r*t;
}
#define i64 long long
const int N=110;
i64 f[N][N],F[N][N],n,m,k,mod,C[N][N],p[N][N*N],P[N][N][N];
i64 &Add(i64 &a,i64 b){ return a=(a+b)%mod; }
i64 power(i64 a,i64 b,i64 p)
{
	i64 r=1;
	for(;b;b>>=1,a=a*a%p) if(b&1) r=r*a%p;
	return r;
}
int main()
{
	n=read(); m=read(); k=read(); mod=read();
	fr(i,0,100) C[i][0]=C[i][i]=1;
	fr(i,1,100) fr(j,1,i-1) C[i][j]=(C[i-1][j]+C[i-1][j-1])%mod;
	fr(i,0,100) fr(j,0,10000) p[i][j]=power(i,j,mod);
	f[0][0]=1;
	fr(l,1,k) fr(i,0,std::max(n,m)) fr(j,0,std::max(n,m)) P[l][i][j]=power(p[l][i]+mod-p[l-1][i],j,mod);
	fr(l,1,k)
	{
		fr(i,0,n) fr(j,0,m) F[i][j]=0;
		fr(i,0,n) fr(j,0,m) fr(o,i,n)
			Add(F[o][j],f[i][j]*C[o][i]%mod*P[l][m-j][o-i]%mod*p[k-l+1][j*(o-i)]);
//		fr(i,0,n) fr(j,0,m) printf("%d%c",int(F[i][j]),j==m?'\n':' '); putchar(10);
		fr(i,0,n) fr(j,0,m) f[i][j]=0;
		fr(i,0,n) fr(j,0,m) fr(o,j,m)
			Add(f[i][o],F[i][j]*C[o][j]%mod*P[k-l+1][i][o-j]%mod*p[l][(n-i)*(o-j)]);
//		fr(i,0,n) fr(j,0,m) printf("%d%c",int(f[i][j]),j==m?'\n':' '); putchar(10);
	}
	printf("%d\n",int(f[n][m]));
	return 0;
}

Measured memory_bytes: 20736
n, a, b = gets.split.map(&:to_i)
s = gets.chomp
total_passed = 0
foreign_passed = 0
s.each_char do |c|
  ok = false
  case c
  when "a"
    if total_passed < (a + b)
      ok = true
      total_passed += 1
    end
  when "b"
    if total_passed < (a + b) && (foreign_passed + 1) <= b
      ok = true
      total_passed += 1
      foreign_passed += 1
    end
  when "c"
    ok = false
  end
  puts ok ? "Yes" : "No"
end


Measured memory_bytes: 2300
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        long N = scan.nextLong();
        BigInteger answer = BigInteger.ZERO;
        long temp = (long) Math.sqrt(N);
        temp += 10;
        BigInteger x = new BigInteger(Long.toString(temp));
        BigInteger y = BigInteger.ZERO;
        do {
            x = x.subtract(BigInteger.ONE);
            y = (x.add(BigInteger.ONE)).multiply(x);
        }
        while ((new BigInteger(Long.toString(N)).compareTo(y)) < 1);
        for (int i = 1; i < x.longValue()+1; i++) {
            if (N % i != 0) {
                continue;
            }
            answer = answer.add(new BigInteger(Long.toString(N / i - 1)));
        }
        System.out.println(answer);
    }
}


Measured memory_bytes: 24112
x,y = map(int, input().split())
a = [4,6,9,11]
if (x==2 or y==2):
    print("No")
    exit()
elif (x in a):
    if (y in a):
        print("Yes")
    else:
        print("No")
else:
    if (y in a):
        print("No")
    else:
        print("Yes")

Measured memory_bytes: 3064