akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
    using namespace std;
     
    int n;
    vector<int> r[1000];
     
    int main(){
    	scanf("%d", &n);
      	for(int i=1; i<1000; i++){
        	if(2*n == i*(i-1)){
            	puts("Yes");
              	for(int j=1, c=1; j<=i; j++){
                	for(int k=j+1; k<=i; k++, c++){
                      	r[j].push_back(c);
                      	r[k].push_back(c);
                    }
                }
              	printf("%d\n", i);
              	for(int j=1; j<=i; j++){
                	printf("%d ", i-1);
                    for(int k:r[j]) printf("%d ", k);
                  	puts("");
                }
                return 0;
            }
        }
      	puts("No");
    }

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

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

    for(int x=0; x<=N/4; x++)
    {
        a = N - 4 * x;
    	if(a%7==0)
    	{
    	   cout << "Yes" << endl;
    	   return 0;
    	}
    }


    cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
// using int = long long;
// using lpair = pair<ll, ll>;
const int MOD = 1e9+7;
#define rep(i,m,n) for(int i=(m);i<(n);i++)
#define rrep(i,m,n) for(int i=(m);i>=(n);i--)
#define printa(x,n) for(int i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}
string S[1000010];
bool visit2[1000010] = {};
int dist[1000010] = {};
typedef struct {
    int x;
    int y;
    int d;
    int mode;
} P;


void solve(){
    int H,W,K;
    cin >> H >> W >> K;
    int x1,y1,x2,y2;
    cin >> x1 >> y1 >> x2 >> y2;
    x1--; y1--; x2--; y2--;
    rep(i,0,H) cin >> S[i];
    queue<P> que;
    que.push({x1,y1,0,-1});
    int dx[4] = {0,0,1,-1};
    int dy[4] = {1,-1,0,0};
    bool reach = false;
    rep(i,0,H*W){
        dist[i] = 1e9;
    }

    while(not que.empty()){
        P l1 = que.front();
        que.pop();
        int lx = l1.x, ly = l1.y;
        if(visit2[lx * W + ly]) continue;
        visit2[lx * W + ly] = true;
        if(lx == x2 && ly == y2){
            reach = true;
            dist[lx*W+ly] = l1.d;
            break;
        }
        rep(k,0,4){
            if(l1.mode == k) continue;
            rep(d,1,K+1){
                int xx = lx + dx[k] * d;
                int yy = ly + dy[k] * d;
                if(xx >= 0 && xx < H && yy >= 0 && yy < W && visit2[xx * W + yy] == false && S[xx][yy] == '.'){
                    if(d == K){
                        que.push({xx,yy, l1.d+1, -1});
                    }else{
                        que.push({xx,yy, l1.d+1, k});
                    }
                }else{
                    break;
                }
            }
        }
    }
    if(not reach){
        print(-1);
        return;
    }else{
        print(dist[x2*W+y2]);
    }
}

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


Measured memory_bytes: 877788
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=1; i<=n; i++)
#define rep_rev(i,n) for(int i=n; i>=2; i--)

int main(){
    int n;
    cin >> n;
    vector<int> vec(n+1);
    rep(i,n) cin >> vec[i];
    rep_rev(i,n) cout << vec[i] << " ";
    cout << vec[1];
    cout << endl;
    return 0;   
}


Measured memory_bytes: 3104
n=int(input())
x=[]
for i in range(n):
  x1,l1=map(int,input().split())
  x.append([x1+l1,l1])
x.sort()
s=1
m=x[0][0]
for i in range(n):
  if m<=x[i][0]-2*x[i][1]:
    s+=1
    m=x[i][0]
print(s)

Measured memory_bytes: 20104
import java.util.Scanner;
import java.util.TreeSet;

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

        TreeSet<Long> shrines = new TreeSet<>();
        TreeSet<Long> temples = new TreeSet<>();

        for (int i = 0; i < s; i++) {
            shrines.add(sc.nextLong());
        }

        for (int i = 0; i < t; i++) {
            temples.add(sc.nextLong());
        }

        for (int i = 0; i < q; i++) {
            long query = sc.nextLong();
            Long fl1 = shrines.floor(query);
            Long cl1 = shrines.ceiling(query);
            Long fl2 = temples.floor(query);
            Long cl2 = temples.ceiling(query);

            long min = Long.MAX_VALUE;
            min = Math.min(min, getClosest(query, fl1, fl2));
            min = Math.min(min, getClosest(query, cl1, cl2));
            min = Math.min(min, getClosest(query, fl1, cl2));
            min = Math.min(min, getClosest(query, cl1, fl2));
            System.out.println(min);
        }
    }

    private static long getClosest(long query, Long p1, Long p2) {
        if (p1 != null && p2 != null) {
            long diff1 = Math.abs(query - p1);
            long diff2 = Math.abs(query - p2);
            long diffBetweenPoints = Math.abs(p1-p2);
            return diff1 < diff2 ? diff1 + diffBetweenPoints : diff2 + diffBetweenPoints;
        }
        return Long.MAX_VALUE;
    }
}


Measured memory_bytes: 107864
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        Map<String , Integer> M = new HashMap<>();
        int MaxS = -8000;
        String strMaxL = "";
        int MaxI = -1;
        String strMax = "";
        
        while(sc.hasNext()){
            String str = sc.next();
            /*
            if(Max < str.length){
                Max = str.length;
                strMax = str;
            }
            */
            
            if(M.get(str) == null){
                M.put(str,0);
            }else{
                M.put(str,M.get(str) + 1);
            }
        }
        
        for(Map.Entry<String,Integer> m : M.entrySet()){
            if(m.getKey().length() > MaxS){
                MaxS = m.getKey().length();
                strMaxL = m.getKey();
            }
            if(MaxI < m.getValue()){
                MaxI = m.getValue();
                strMax = m.getKey();
            }
        }
        System.out.println(strMax + " " + strMaxL);
    }
}


Measured memory_bytes: 25828
import java.util.*;
/*
Main class for AOJ where there is no input.
*/
public class Main{
   public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      String temp;
      int i = 1;
      
      while(true){
         temp = sc.nextLine();
         if(temp.equals("0")){
            break;
         }else{
            System.out.println("Case " + i + ": " + temp );
            i ++;
         }
         
      }
                   
   }//main method
   
         
}//class

Measured memory_bytes: 60600
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <functional>
using namespace std;

int main(){
    unsigned int n, m;
    cin >> n >> m;
    vector<pair<int, int> > pairs(n);
    for(int i = 0; i < n; i++){
        int a, b;
        cin >> a >> b;
        pairs[i] = make_pair(a, b);
    }

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

//    for(int i = 0; i < n; i++){
//        cerr << pairs[i].first << " " << pairs[i].second << endl;
//    }

    long long buy = 0;
    long long money = 0;
    for(int i = 0; i < n; i++){
        if(buy+pairs[i].second >= m){
            money += (m-buy)*pairs[i].first;
            break;
        }
        money += pairs[i].second * pairs[i].first;
        buy += pairs[i].second;
    }

    cout << money << endl;

    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>
#include<queue>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

bool isPrime(Int n) {
	if (n == 2 || n == 3) return true;
	else if (n % 2 == 0 || n % 3 == 0) return false;
	else if (n % 6 != 1 && n % 6 != 5) return false;
	for (Int i = 5; i * i <= n; i += 6) {
		if (n % i == 0) return false;
		if (n % (i + 2) == 0) return false;
	}
	return true;
}

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	Int N;
	cin >> N;

	Int len = 5;
	vector<Int> ans = { 7,17,37,47,67 };

	Int temp = 67;
	while (len != N) {
		temp += 10;
		if (isPrime(temp)) {
			ans.push_back(temp);
			len++;
		}
	}

	for (Int i = 0; i < len; i++) {
		cout << ans[i] << " ";
	}
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  int N = 0, temp = 0, result = 0, M = 0, P = 0, X = 0;
  cin >> N;
  int *T = new int[N];
  for(int i = 0; i < N; i++){
    cin >> T[i];  
  }
  cin >> M;

  for(int i = 0; i < M; i++){
    cin >> P;
    cin >> X;

    temp = T[P - 1];
    T[P - 1] = X;
    for(int j = 0; j < N; j++){
      result += T[j];
    }
    cout << result << endl;
    result = 0;

    T[P - 1] = temp;
  }

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

int main(){
    int i,j,k,ans;
    int n,w[100],t,S1,S2;

    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&w[i]);
    }
    
    for(i=0;i<n;i++){
        S1=0;
        S2=0;
//        t = w[i];
        for(j=0;j<n;j++){
            if(j<=i){
                S1 += w[j];
            } else {
                S2 += w[j];
            }
        }
        if(i==0){
            ans = abs(S1-S2);
        } else {
            if(ans > abs(S1-S2)){
                ans = abs(S1-S2);
            }
        }
    }

    printf("%d",ans);
    
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <set>
#define INF 2000000000
#define LLINF 2000000000000000
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define LOOP(i,N) for(int i=0;i<N;i++)
#define LOOP1(i,N) for(int i=1;i<=N;i++)
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
// #define int long long

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

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

int h, w;
string S[20];
bool t[20][20];
int scr[20][20];

// string S[3];
// bool t[3][3];
// int scr[3][3];

int f(int x,int y, int sc){
  // cerr << ":" << x << "," << y << "," << sc << endl;
  if(x < 0 || y < 0 || x >= h || y >= w)return 0;
  // cerr << "!";
  if(S[x][y] == '#')return 0;
  if(t[x][y]) return 0;
  if(scr[x][y] <= sc)return 0;
  t[x][y] = true;
  scr[x][y] = sc;
  int mi = sc;
  // cerr << "!";
  // if(sc%10 == 0)

  int dis[4][2] = {{0,1},{0,-1},{1,0},{-1,0}};
  LOOP(i,4){
    dis[i][0] += x, dis[i][1] += y;
    // cerr << "*";
    mi = max(mi, f(dis[i][0], dis[i][1], sc+1));
    // cerr << "*";
  }
  t[x][y] = false;
  return 0;
}

signed main(){
  cin >> h >> w;
  LOOP(i,h){
    cin >> S[i];
  }
  int ans = 0;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      LOOP(ii,h)  LOOP(jj,w)scr[ii][jj]=INF;
      f(i,j,0);
      LOOP(ii,h){
        LOOP(jj,w) if(scr[ii][jj]!=INF)ans = max(ans,scr[ii][jj]);
      }
      //cerr << h << "," << w << endl;
      // break;
    }
    // break;
  }

  cout << ans << endl;

}


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

using namespace std;

int main(){
	int l,a,b,c,d;

	scanf("%d%d%d%d%d",&l,&a,&b,&c,&d);
	int ans = l;

	ans = min(ans,l-(a+c-1)/c);
	ans = min(ans,l-(b+d-1)/d);

	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define FastRead                      \
                                    ios_base::sync_with_stdio(false); \
                                    cin.tie(0);
#define ll long long
#define endl "\n"
#define f for
using namespace std;
int main()

{
    FastRead
    ll int a[5],i;
    f(i=0;i<3;i++)
    {
        cin>>a[i];
    }
    sort(a,a+3);
    if(a[0]==5 && a[1]==5 && a[2]==7)
        cout<<"YES";
    else
        cout<<"NO";

    return 0;

}


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

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))

#define INF 2e9
#define INF_LL 1LL<<60
#define ll long long
#define MAX_V 100005

bool table[MAX_V];
bool niteru[MAX_V];
int ruiseki[100005];

int main() {
    REP(i, MAX_V) {
        table[i] = true;
    }
    table[0] = table[1] = false;

    REPN(i, 2, MAX_V) {
        if(table[i]) {
            for(int j = 2; i*j < MAX_V; j++) {
                table[i*j] = false;
            }
        }
    }

    REP(i, MAX_V) {
        niteru[i] = table[i];
    }

    REPN(i, 2, MAX_V) {
        if(i % 2 == 1) {
            if(table[i]) {
                if(!table[(i+1)/2]) {
                    niteru[i] = false;
                }
            }
        }
    }
    niteru[2] = false;
    REPN(i, 1, MAX_V) {
        if(niteru[i]) {
            ruiseki[i] = ruiseki[i-1]+1;
        } else {
            ruiseki[i] = ruiseki[i-1];
        }
    }

    REPN(i, 1, 100) {
        //cout << i << " " << table[i] << " " << niteru[i] << endl;
    }


    int q;
    cin >> q;
    REP(i, q) {
        int l, r;
        cin >> l >> r;

        cout << ruiseki[r] - ruiseki[l-1] << endl;
    }

}
 

Measured memory_bytes: 1280
#!/use/bin/env python3

import math
from collections import defaultdict

(a, b, c) = [input() for _ in range(0, 3)]

p = {
    'A': a,
    'B': b,
    'C': c,
}

t = 'A'
while 1:
    cc = p[t][0]

    p[t] = p[t][1:]

    if cc == 'a':
        t = 'A'
    elif cc == 'b':
        t = 'B'
    else:
        t = 'C'

    if len(p[t]) == 0:
        break

print(t)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
int c2i (char c){
    return c - '0';
}
int main () {
    string s;
    cin >> s;
    int min = 1000;
    for(int i = 0; i < (int)(s.size())-2; i++)
    {
        int tmp = c2i(s[i]) * 100 + c2i(s[i+1]) * 10 + c2i(s[i + 2]) * 1;
        if(min > abs(tmp - 753)){
            min = abs(tmp - 753);
        }
        
    }
    cout << min << endl;
    
}

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

class Program
{
    private static long Solve(int N, long x, int[] a)
    {
        long[] sum = new long[N];
        for (int i = 0; i < N; ++i)
        {
            long min = long.MaxValue;
            for (int j = 0; j < N; ++j)
            {
                min = Math.Min(a[(i - j + N) % N], min);
                sum[j] += min;
            }
        }
        return Enumerable.Range(0, N).Min(i => sum[i] + i * x);
    }
    static void Main(string[] args)
    {
        int[] values = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        int[] a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        Console.WriteLine(Solve(values[0], values[1], a));
    }
}


Measured memory_bytes: 3160
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef  unsigned long long int ull;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
ll GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int main(){
    int n;
    cin>>n;
    ll ans=0;
    ll x,y;
    ll d=inf;
    ll sum=0;
    for(int i=0;i<n;i++){
        cin>>x>>y;
        if(x>y){
            chmin(d,y);
        }
        sum+=x;
    }
    if(d>=inf)cout<<0<<"\n";
    else cout<<sum-d<<"\n";
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
using namespace std;

int main(){
	int a,b,c;
	while(cin >> a){
		cin >> b;
		while(1){
			if(b>a){
				c=b;b=a;a=c;
			}
			a=a%b;
			if(a==0){
				break;
			}
		}
		cout << b <<"\n";
	}
		
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define int long long
#define inf 1000000007
#define LINF 100000000000000007LL
#define ll long long
using namespace std;
signed main(){
	int n;
	cin>>n;
	vector<int> a(n);
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	int ans = LINF;
	for(int i=1;i<=100;i++){
		int c = 0;
		for(int j=0;j<n;j++){
			c += ( i - a[j] ) * ( i - a[j] );
		}
		if( c < ans ) ans = c;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int main(){
    priority_queue<string, vector<string> , greater <string> > pq;
    int N, L;
    cin >> N >> L;
    string a;
    for(int i = 0; i < N; i++){
        cin >> a;
        pq.push(a);
    }
    while(!pq.empty()){
        cout << pq.top();
        pq.pop();
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <sstream>

using namespace std;

int main(void){
  int N;
  int step = 0;
  string ss;
  vector<int> d;
  vector<int> d_count;
  cin >> N;
  
  int count = 0;
  for(int i = 0; i < N; i++){
    int di;
    cin >> di;
    d.push_back(di);
  }
  for(int i = 0; i < N; i++){
    int j = 0;
    bool exist = false;
    if(d_count.size() == 0){
      d_count.push_back(d[i]);
      step += 1;
      continue;
    }
    while(j < d_count.size()){
      if(d[i] == d_count[j]){
        exist = true;
        break;
      }
      j++;
    }
    if(!exist){
      d_count.push_back(d[i]);
      step += 1;
    }
  }
  cout << step;
  return 0;
}

Measured memory_bytes: 384
// CONTEST

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

// Utility
#define ALL(X) (X).begin(), (X).end()
#define FOR(I, X, Y) for (int I = (X); I < (Y); I++)
using ll = int64_t;
using ull = uint64_t;
template<typename T> struct is_container {
template<typename C> static char test(typename C::const_iterator*); template<typename> static int test(...);
static bool const value = sizeof(test<T>(nullptr)) == sizeof(char) && !std::is_same<std::string, T>::value;
};
namespace std {
template<class ...Ts>        istream& operator>>(istream& i, tuple<Ts...>& x) { apply([&](auto&&... ys){ ((i >> ys), ...); }, x); return i; }
template<class T1, class T2> istream& operator>>(istream& i, pair<T1, T2>& x) { i >> x.first >> x.second; return i; }
template<class T, enable_if_t<is_container<T>::value, int> = 0>
istream& operator>>(istream& i, T& x) { for (auto& y : x) { i >> y; } return i; }
}

// Debugging
#ifndef DEBUG
#define DEBUG 0
#endif
#define dbg(X) do { if (DEBUG) { cout << #X ": " << (X) << endl << flush; } } while (0)
#define dbg2(X) do { if (DEBUG) { cout << #X ":" << endl; for (auto& __x : (X)) { cout << __x << endl << flush; } } } while (0)
#define dbgv(...) do { if (DEBUG) { cout << "(" #__VA_ARGS__ "): " << make_tuple(__VA_ARGS__) << endl << flush; } } while (0)
namespace std {
template<class ...Ts>        ostream& operator<<(ostream& o, const tuple<Ts...>& x) { o << "("; apply([&](auto&& y, auto&&... ys){ o << y; ((o << ", " << ys), ...); }, x); o << ")"; return o; }
template<class T1, class T2> ostream& operator<<(ostream& o, const pair<T1, T2>& x) { o << tie(x.first, x.second); return o; }
template<class T, enable_if_t<is_container<T>::value, int> = 0>
ostream& operator<<(ostream& o, const T& x) { o << "{"; for (auto it = x.begin(); it != x.end(); it++) { if (it != x.begin()) { o << ", "; } o << *it; } o << "}"; return o; }
}

// Main
void mainCase() {
  ll d, t, s;
  cin >> d >> t >> s;

  // d/s <= t
  bool res = d <= s * t;
  cout << (res ? "Yes" : "No") << endl;
}

int main() {
  ios_base::sync_with_stdio(0); cin.tie(0);
  // [ Single case ]
  mainCase();
  return 0;
  // [ Multiple cases ]
  // int t;
  // cin >> t;
  // FOR(i, 0, t) { mainCase(); }
  // return 0;
}

/*
python misc/run.py atcoder/abc177/a/main.cpp --check

%%%% begin
%%%%
%%%% end
*/


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int mod = 1e9+7;

vector<string> x;

void dfs(int i,string j)
{
    if(i == 10) x.emplace_back(j);
    else{
        dfs(i+1,j+'1');
        dfs(i+1,j+'0');
    }    
}

int main()
{
    int n;
    cin >> n;
    int f[n][10],p[n][10];
    for(int i = 0; i < n; i++) for(int j = 0; j < 10; j++) cin >> f[i][j];
    for(int i = 0; i < n; i++) for(int j = 0; j < 11; j++) cin >> p[i][j];

    dfs(0,""); x.pop_back();

    int ans = -INF;
    for(int i = 0; i < x.size(); i++){
        int cnt1 = 0;
        for(int j = 0; j < n; j++){
            int cnt2 = 0;
            for(int k = 0; k < 10; k++){
                if(x[i][k]-'0' && f[j][k]) cnt2++;
            }
            cnt1 += p[j][cnt2];
        }
        ans = max(ans,cnt1);        
    }

    cout << ans << endl;

    return 0;
}

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

using namespace std;

void subsets(vector<int> U, int m) 
{
    long nSub = 1 << m;
    
    for(long i = 0; i < nSub; i++)
    {
        long d = 0;
        
        for(int k = 0; k < m; k++)
        {
            if((1 << k) & i)
            {
                d += (1 << U[k]);
            } 
        }
        
        printf("%ld:", d);
        for(int k = 0; k < m; k++)
            if((1 << k) & i)
                printf(" %d", U[k]);
        printf("\n");
    }
}

int main() 
{
    int n, m, k;
    scanf("%d %d", &n, &k);

    vector<int> U;
    
    for(int i = 0; i < k; i++)
    {
        scanf("%d", &m);
        U.emplace_back(m);
    }
    
    subsets(U, k);
    
    return 0;
}


Measured memory_bytes: 3288
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    while (sc.hasNext()) {
        val v = sc.nextDouble()
        val y = 4.9 * Math.pow(v/9.8, 2.0)
        println(Math.ceil(y/5).toInt()+1)
    }
}


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

#define int long long
#define ll long long
#define rep(i,n) for (ll i = 0; i < (n) ; i++)
ll ltmp;
int f(string s,int a){
  if(a==0)return -1;
  int res=0,t=1;
  reverse(s.begin(),s.end());
  for(int i=0;i<s.size();i++){
    (res+=t*(s[i]=='1'))%=a;
    (t*=2)%=a;
  }
  return res;
}
int p(int a){
  int res=0;
  while(a){
    if(a&1)res++;
    a>>=1;
  }
  return res;
}
#define base10_6 1000000    //1e6
ll popcount[base10_6+10]={};
int F(int a){
  int res=0;
  while(a){
    res++;
    a%=popcount[a];  //p(a);
  }
  return res;
}

ll getMod(ll value,ll mod){
    if(value == 0) return 0;
    return (value + mod) % mod;
}


ll getPower(ll value,ll shisu,ll mod){
    ll ans = 1;
    ll cnt = shisu;
    while(cnt>0){
        if(cnt%2==1){
            ans = ans * value % mod;
        }
        value = value * value % mod;
        cnt = cnt/2;
    }
    return ans;
}
ll bit2[1000010]={};

ll mod_p[base10_6+10]={};
ll mod_m[base10_6+10]={};
ll getIntSubstr(string s,ll start_index,ll length){
    return atoi(s.substr(start_index,length).c_str());
}

signed main(){
    int n;cin>>n;
    string s;cin>>s;
    int sum=0;
    for(char p:s)sum+=p=='1';
  
    ll base_pop = 0;
    string S = s;
    ll N = n;
    rep(ni,N){
        bit2[ni] = getIntSubstr(S,ni,1);
        //bit2[ni] = 1;
        base_pop+=bit2[ni];
    }
    sum = base_pop;

    ll basev= 1;
    basev=1;
    for( ll ni = 1 ; ni <=base10_6 ; ni=ni*2 ){
        popcount[ni]=1;
    }
    for( ll ni = 1 ; ni <=base10_6 ; ni++ ){
        if(popcount[ni]==1) basev = ni;
        else popcount[ni]= 1 + popcount[ ni % basev  ]; 
    }


    ll base_pop_p;
    ll base_pop_m;
    base_pop_p = base_pop+1;
    base_pop_m = base_pop-1;
    if(base_pop_m==0) base_pop_m=1;

    basev = 1;
    ltmp = 1;
    for( ll keta = 1 ; keta <=base10_6 ; keta++ ){
        mod_p[keta] = basev;
        basev = basev * 2;
        basev = getMod(basev,base_pop_p); 
    }
    basev = 1;
    for( ll keta = 1 ; keta <= base10_6 ; keta++ ){
        mod_m[keta] = basev;
        basev = basev * 2;
        basev = getMod(basev,base_pop_m); 
    }

    ll base_f1_p = 0;
    ll base_f1_m = 0;
    for( ll keta = 1 ; keta <=N ; keta++ ){
        ll ind = N -keta;
        base_f1_p += mod_p[keta] * bit2[ind];
        base_f1_m += mod_m[keta] * bit2[ind];
        base_f1_p = getMod(base_f1_p,base_pop_p );
        base_f1_m = getMod(base_f1_m,base_pop_m );
    }

    int A=base_f1_p;//f(s,sum+1);
    int B=base_f1_m;//f(s,sum-1);


  for(int i=0;i<n;i++){
    if(sum==1&&s[i]=='1'){
      cout<<0<<endl;
      continue;
    }
    ll keta = N - i;
      
    if(s[i]=='0'){
      int res=A;
      ll value = base_f1_p + mod_p[keta];
      value = getMod(value,base_pop_p);

      //res+=getPower(2,n-i-1,sum+1);res%=sum+1;
      
      res = value;
      cout<<F(res)+1<<endl;
    }
    else{
      int res=B;
      res-=getPower(2,n-i-1,sum-1);
      res+=sum-1;res%=sum-1;
      ll value = base_f1_m - mod_m[keta];
      value = getMod(value,base_pop_m);
      res = value;
      cout<<F(res)+1<<endl;
    }
  }
}


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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#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()
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
#define int ll

int n, s, ret, dp[15][1010];

signed main(void)
{
  VI data;
  REP(i, 10) data.PB(i);
  do {
    int tmp = 0;
    REP(i, 10) {
      tmp += data[i]*(i+1);
      dp[i][tmp]++;
    }
  } while(next_permutation(ALL(data)));

  int fact[15] = {0};
  fact[0] = 1;
  FOR(i, 1, 10) fact[i] = fact[i-1]*i;

  while(cin >> n >> s) {
    if(s > 1000) {cout << 0 << endl; continue;}
    cout << dp[n-1][s]/fact[10-n] << endl;
  }

  return 0;
}

Measured memory_bytes: 3168
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, n) for (int i = (a); i < (n); i++)
#define repb(i, n, a) for (int i = (n - 1); i >= (a); i--)
#define all(x) x.begin(), x.end()
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define pb push_back
#define mp make_pair
#define fir first
#define sec second

void change(char &pre, char &now) {
    if (now == '0') {
        pre = '1';
    } else {
        pre = '0';
    }
}

void Main() {
    string S;
    cin >> S;
    int len = S.size();
    char now, pre = S[0];
    int ans1 = 0, ans2 = 0;
    rep(i, 1, len) {
        now = S[i];
        if (pre == now) {
            change(pre, now);
            ans1++;
        } else {
            pre = now;
        }
    }
    pre = S[len - 1];
    repb(i, len - 1, 0) {
        now = S[i];
        if (pre == now) {
            change(pre, now);
            ans2++;
        } else {
            pre = now;
        }
    }
}

int main() {
    string S;
    cin >> S;
    int len = S.size();
    char now, pre = S[0];
    int ans1 = 0, ans2 = 0;
    rep(i, 1, len) {
        now = S[i];
        if (pre == now) {
            change(pre, now);
            ans1++;
        } else {
            pre = now;
        }
    }
    pre = S[len - 1];
    repb(i, len - 1, 0) {
        now = S[i];
        if (pre == now) {
            change(pre, now);
            ans2++;
        } else {
            pre = now;
        }
    }
    cout << min({ans1, ans2}) << endl;
    // cin.tie(0);
    // ios_base::sync_with_stdio(false);
    // cout << fixed << setprecision(12) << endl;
    // Main();
}

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

int main() {
  
  int a;
  cin >> a;
  int b;
  cin >> b;
  
  if (a>=13) cout << b << endl;
  else if (a<=5) cout << 0 << endl;
  else cout << b/2 << endl;
}

Measured memory_bytes: 256
N, M, R = gets.split.map(&:to_i)
r = gets.split.map(&:to_i).map{ |i| i-=1 }

d = Array.new(N){ Array.new(N,1e9) }
(0...N).each{ |i| d[i][i] = 0 }

M.times do
  a, b, c = gets.split.map(&:to_i)
  a-=1
  b-=1
  d[a][b] = d[b][a] = c
end

N.times do |k|
  N.times do |i|
    N.times do |j|
      v = d[i][k]+d[k][j]
      d[i][j] = v if d[i][j] > v
    end
  end
end

p = r.permutation(R).to_a
ans = 1e9

p.each do |k|
  dist = 0
  (1...R).each do |i|
    dist += d[k[i]][k[i-1]]
  end
  ans = dist if ans > dist
end

p ans

Measured memory_bytes: 8572
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define mod 1000000007ll
#define mod1 998244353ll
#define endl '\n'
#define inf ((ll)1e18+1)
#include<chrono>
using namespace chrono;
mt19937_64 rng(high_resolution_clock::now().time_since_epoch().count());
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update>
#define debr(x,y) {cout<<"-->  "<<#x<<" to "<<#y<<" :  "; auto itr=x; while(itr!=y) cout<<(*itr++)<<' '; cout<<endl; }
#define deba(x) {cout<<"-->  "<<#x<<" :  "; for(auto ele:(x)) cout<<ele<<"  "; cout<<endl; }
#define deb(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s);istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {cout<<endl;}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a <<"  ,  ";
    err(++it, args...);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll n,m,k;
    cin>>n>>m>>k;
    ll a[n],b[m];
    for(ll x=0;x<n;x++){
        cin>>a[x];
    }
    for(ll x=0;x<m;x++){
        cin>>b[x];
    }
    ll pre1[n],pre2[m];
    pre1[0]=a[0];
    for(ll x=1;x<n;x++){
        pre1[x]=pre1[x-1]+a[x];
    }
    pre2[0]=b[0];
    for(ll x=1;x<m;x++){
        pre2[x]=pre2[x-1]+b[x];
    }
    ll low=0,high=n+m;
    ll ans=0;
    while(low<=high){
        ll mid=(low+high)/2;
        bool poss=false;
        for(ll x=0;x<=min(n,mid);x++){
            ll taken=0;
            if(x>0)taken+=pre1[x-1];
            ll y=mid-x;
            if(y>m)continue;
            if(y>0)taken+=pre2[y-1];
            if(taken<=k){
                poss=true;
                break;
            }
        }
        if(poss){
            ans=mid;
            low=mid+1;
        }else{
            high=mid-1;
        }
    }
    cout<<ans<<endl;
    return 0;

}

Measured memory_bytes: 9916
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
#define PI 3.14159265358979323846264338327950L
using namespace std;
using P = pair<int,int>;
using ll = long long;
using namespace std;
char in[120];
pair<pair<string,int>,int> p[110];
int main(){
    int n;
    cin >> n;
    int a[n];
    int cnt[n];
    rep(i, n){cnt[i] = 0;}
    for(int i = 2; i <= n; ++i){
        cin >> a[i];
        cnt[a[i]-1] += 1; 
    }
    rep(i, n){cout << cnt[i] << endl;}
    return 0;
}

Measured memory_bytes: 5172
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<stack>
#include<vector>
#include<queue>
#include<set>
#include<algorithm>
#define INF 0x3f3f3f3f
#define mod 1000000009
#define e  2.718281828459045
#define eps 1.0e18
#define PI acos(-1)
#define lowbit(x) (x&(-x))
#define memset(x,y) memset(x,y,sizeof(x))
#define lson i << 1,l,m
#define rson i << 1 | 1,m + 1,r
#define ll long long
using namespace std;
const int N =10;
int a[N];
bool vis[N];

int main()
{
    int n,m,pos,val;
	scanf("%d%d",&n,&m);
	
	bool f = 0;
	for(int i = 1;i <= m;++i){
		scanf("%d%d",&pos,&val);
		if(vis[pos]){
			if(val != a[pos]) f = 1;
			continue;
		}
		vis[pos] = 1;
		a[pos] = val;
	}
	if(f) printf("-1\n");
	else{
		if(n == 1) printf("%d",a[1]);
		else{
			if(!vis[1]) a[1] = 1;
			if(!a[1]) printf("-1\n");
			else{
				for(int i = 1;i <= n;++i) printf("%d",a[i]);
			}
		}
	}
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
/* see https://github.com/pllk/cphb/
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,
    tree_order_statistics_node_update> indexed_set;
 **/
 
typedef long long ll;
#define endl "\n"
#define fori(n) for(ll i=0; i<(n); i++)
 
#define cins(s) string s; cin>>s;
#define cini(i) int i; cin>>i;
#define cinll(l) ll l; cin>>l;
#define cinai(a, n) vi a(n); fori(n) { cin>>a[i]; }
#define cinall(a, n) vll a(n); fori(n) { cin>>a[i]; }
#define cinas(s, n) vs s(n); fori(n) { cin>>s[i]; }
 
//typedef __int128 lll;
typedef pair<int, int> pii;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<string> vs;
typedef vector<ll> vll;
 
int main() {
cin.tie(nullptr);
std::ios::sync_with_stdio(false);
    cins(s);
    cins(t);
 
    vvi f('z'+1);
    for(size_t i=0; i<s.size(); i++)
        f[s[i]].push_back(i);
 
    ll ans1=0;
    ll ans2=-1;
    for(size_t i=0; i<t.size(); i++) {
        if(f[t[i]].size()==0) {
            ans1=0;
            ans2=-2;
            break;
        }
 
        auto it=upper_bound(f[t[i]].begin(), f[t[i]].end(), ans2);
        if(it==f[t[i]].end()) {
            ans1++;
            ans2=f[t[i]][0];
        } else
            ans2=*it;
    }
 
    ans1*=s.size();
    ll ans=ans1+ans2+1;
    cout<<ans<<endl;
}

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

int main() {
  int A,B,C,sum=0;
  cin >> A >> B >> C;
  bool a=false;
  for(int i=A;i<B*A+1;i+=A){
    sum+=A;
    if(sum%B==C){
      a=true;
      break;
    }
  }
  if(a){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
}

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

public class Main {

    static class Task {

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            long[] arr = new long[n];
            long xor = 0;
            for (int i = 0; i < n; i++) {
                arr[i] = in.nextInt();
                xor ^= arr[i];
            }

            for (int i = 0; i < n; i++) {
                long ans = xor ^ arr[i];
                out.print(ans + " ");
            }

            out.println();
        }
    }

    private static void sort(double[] arr) {
        Double[] objArr = Arrays.stream(arr).boxed().toArray(Double[]::new);
        Arrays.sort(objArr);
        for (int i = 0; i < arr.length; i++) {
            arr[i] = objArr[i];
        }
    }

    private static void sort(int[] arr) {
        Integer[] objArr = Arrays.stream(arr).boxed().toArray(Integer[]::new);
        Arrays.sort(objArr);
        for (int i = 0; i < arr.length; i++) {
            arr[i] = objArr[i];
        }
    }

    private static void sort(long[] arr) {
        Long[] objArr = Arrays.stream(arr).boxed().toArray(Long[]::new);
        Arrays.sort(objArr);
        for (int i = 0; i < arr.length; i++) {
            arr[i] = objArr[i];
        }
    }

    private static void solve() {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task task = new Task();
        task.solve(1, in, out);
        out.close();
    }

    public static void main(String[] args) {
        new Thread(null, () -> solve(), "1", 1 << 26).start();
    }

    static class InputReader {

        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

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

        public long nextLong() {
            return Long.parseLong(next());
        }

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

    }

}

Measured memory_bytes: 60468
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;
const int N=1005;
const double inf=1e18;
struct Cir{double x,y,r;}e[N];
double a[N][N],d[N];
int vis[N];
double sqrr(double x) {return x*x;}
double dis(double xa,double ya,double xb,double yb) {return sqrt(sqrr(xa-xb)+sqrr(ya-yb));}

double dijkstra(int n,int S,int T)
{
    int i,mini;
    for (i=1;i<=n;i++) d[i]=inf,vis[i]=0;
    d[S]=0;d[0]=inf+1;
    while (!vis[T])
    {
        for (i=1,mini=0;i<=n;i++) if (!vis[i]&&d[mini]>d[i]) mini=i;
        vis[mini]=1;
        for (i=1;i<=n;i++) if (!vis[i]) d[i]=min(d[i],d[mini]+a[mini][i]);
    }
    return d[mini];
}

int main()
{
  //  freopen("in.txt","r",stdin);freopen("out.txt","w",stdout);
    int i,j,n;double xs,ys,xt,yt;
    scanf("%lf%lf%lf%lf",&xs,&ys,&xt,&yt);
    scanf("%d",&n);
    for (i=1;i<=n;i++) scanf("%lf%lf%lf",&e[i].x,&e[i].y,&e[i].r);
    for (i=1;i<=n;i++)
     for (j=i+1;j<=n;j++)
     {
          double r1=e[i].r,r2=e[j].r;
          a[i][j]=a[j][i]=max(0.0,dis(e[i].x,e[i].y,e[j].x,e[j].y)-r1-r2);  
     }
    for (i=1;i<=n;i++)
    {
        a[n+1][i]=a[i][n+1]=max(0.0,dis(xs,ys,e[i].x,e[i].y)-e[i].r);
        a[n+2][i]=a[i][n+2]=max(0.0,dis(xt,yt,e[i].x,e[i].y)-e[i].r);
        a[i][i]=0;
    }
    a[n+1][n+1]=a[n+2][n+2]=0;
    a[n+1][n+2]=a[n+2][n+1]=dis(xs,ys,xt,yt);
    
    printf("%.10lf\n",dijkstra(n+2,n+1,n+2));
    
    return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> Vector;
typedef vector<vector<ll>> DVector;

#define fi          first
#define se          second
#define pb          push_back
#define INF         INT_MAX
#define bcnt        __builtin_popcount
#define all(x)      (x).begin(),(x).end()
#define dbg(x)      cout<<#x"="<<x<<endl
#define ub(x,y)     upper_bound(all(x),y)-x.begin()
#define lb(x,y)     lower_bound(all(x),y)-x.begin()
#define uni(x)      x.erase(unique(all(x)),x.end())
#define rep(i,n)    repl(i,0,n-1)
#define repl(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);i++)
#define mmax(x,y)   (x>y?x:y)
#define mmin(x,y)   (x<y?x:y)
#define maxch(x,y)  x=mmax(x,y)
#define minch(x,y)  x=mmin(x,y)
#define exist(x,y)  (find(all(x),y)!=x.end())
#define each(itr,v) for(auto itr:v)
#define usort(x)    sort(all(x))
#define dsort(x)    sort(all(x),greater<int>())
#define mkp(x,y)    make_pair(x,y)
int n;
DVector f,p;

ll dfs(Vector a){
  ll ans;
  if(a.size() == 10){
    bool flag = false;
    rep(i,10)if(a[i] != 0)flag = true;
    if(!flag)ans = -INF;
    else{
      Vector c(n,0);
      ll sum = 0;
      rep(i,n)rep(j,10)if(a[j] && f[i][j])c[i]++;
      rep(i,n) sum += p[i][c[i]];
      ans = sum;
    }
  }else{
    Vector tmp1 = a;
    Vector tmp2 = a;
    tmp1.pb(1);
    tmp2.pb(0);
    ans = mmax(dfs(tmp1),dfs(tmp2));
  }
  return ans;
}

int main(){
  cin.sync_with_stdio(false);
  cin >> n;
  f.resize(n,Vector(10));
  p.resize(n,Vector(11));
  rep(i,n)rep(j,10)cin >> f[i][j];
  rep(i,n)rep(j,11)cin >> p[i][j];
  Vector a;
  cout << dfs(a) << endl;
}


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

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define repp(i,k,n) for(int i=k;i<(int)n;i++)
#define rei(n) for(int i=0;i<(int)n;i++)
#define rel(n) for(int l=0;l<(int)n;l++)
#define all(s) s.begin(),s.end()
#define INT_MAX 2147483647
#define debug(x) cout<<#x<<": "<<x<<endl;
#define PI 2*acos(0,0)
#define pb push_back
#define inin(x) int x; cin>>x;
#define ll long long
#define pb push_back

typedef pair<int, int> pii;
typedef pair<int, pii> pipii;

struct Calendar
{
	long long year;
	long long month;
	long long day;
	long long dat[2][13];
	Calendar(long long y, long long m, long long d)
	{
		year = y;
		month = m;
		day = d;
		dat[0][0] = dat[1][0] = 0;
		dat[0][1] = dat[1][1] = 31;
		dat[0][2] = dat[1][2] = 28;
		dat[0][3] = dat[1][3] = 31;
		dat[0][4] = dat[1][4] = 30;
		dat[0][5] = dat[1][5] = 31;
		dat[0][6] = dat[1][6] = 30;
		dat[0][7] = dat[1][7] = 31;
		dat[0][8] = dat[1][8] = 31;
		dat[0][9] = dat[1][9] = 30;
		dat[0][10] = dat[1][10] = 31;
		dat[0][11] = dat[1][11] = 30;
		dat[0][12] = dat[1][12] = 31;
		dat[1][2] = 29;
	}
	int uruu()
	{
		if (year % 4 == 0)
		{
			if (year % 400 != 0 && year % 100 == 0)
			{
				return 0;
			}
			else
			{
				return 1;
			}
		}
		return 0;
	}
	int uruu(long long y)
	{
		if (y % 4 == 0)
		{
			if (y % 400 != 0 && y % 100 == 0)
			{
				return 0;
			}
			else
			{
				return 1;
			}
		}
		return 0;
	}
	long long pday(long long d)
	{
		day += d;
		for (;; month++)
		{
			if (month >= 13)
			{
				year++;
				month = 1;
			}

			if (dat[uruu()][month] < day)
			{
				day -= dat[uruu()][month];
			}
			else
			{
				break;
			}
		}
		pmonth(0);
		return d;
	}
	long long pmonth(long long m)
	{
		month += m;
		for (;; year++)
		{
			if (month > 12)
			{
				month -= 12;
			}
			else
			{
				break;
			}
		}
		return m;
	}
	long long pyear(long long y)
	{
		year += y;
		return y;
	}
	long long dif(Calendar c)
	{
		long long ans = 0;
		Calendar a(year, month, day);
		ans -= a.day;
		ans += c.day;
		a.day = 0;
		c.day = 0;
		for (; a.month >= 1; a.month--)
		{
			ans -= dat[a.uruu()][a.month - 1];
		}
		for (; c.month >= 1; c.month--)
		{
			ans += dat[c.uruu()][c.month - 1];
		}
		for (; a.year != c.year; a.year++)
		{
			ans += 365;
			if (a.uruu())ans++;
		}
		return ans;
	}


};


int main()
{
	int n;
	while (cin >> n&&n)
	{
		string a;
		
		cin >> a;
		rep(i, n)
		{
			stringstream b;
			char cha=a[0];
			int num=1;
			repp(l, 1, a.size())
			{
				if (a[l] == cha)
				{
					num++;
				}
				else
				{
					b << num << cha;
					num = 1;
					cha = a[l];
				}
			}
			b << num << cha;
			a = b.str();
		}
		cout << a << endl;
	}
}

Measured memory_bytes: 1380
// Vicfred
// https://atcoder.jp/contests/abc166/tasks/abc166_c
use std::io;
use std::collections::HashMap;
use std::collections::HashSet;

fn main() {
    let mut line = String::new();

    io::stdin()
        .read_line(&mut line)
        .unwrap();

    let words: Vec<i64> =
        line
        .split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect();

    let n = words[0];
    let m = words[1];

    let mut line = String::new();

    io::stdin()
        .read_line(&mut line)
        .unwrap();

    let h: Vec<i64> =
        line
        .split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect();


    let mut obs = [0; 100001];

    for _ in 0..m {
        let mut line = String::new();

        io::stdin()
            .read_line(&mut line)
            .unwrap();

        let words: Vec<usize> =
            line
            .split_whitespace()
            .map(|x| x.parse().unwrap())
            .collect();

        let mut a = words[0] - 1;
        let mut b = words[1] - 1;
        
        if h[a] > h[b] {
            obs[b] = 1;
        } else if h[b] > h[a] {
            obs[a] = 1;
        } else {
            obs[b] = 1;
            obs[a] = 1;
        }
    }
    let mut ans = 0;
    for i in 0..n as usize {
        if obs[i] == 0 {
            ans += 1;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4316
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
int p[5005];
long long a[5005];
long long pre[5005]={0};
int maxstep;
void dfs(int u,int step,int start)
{
    maxstep=max(maxstep,step);
    pre[step]=pre[step-1]+a[u];
    if(u==start){
        return ;
    }
    dfs(p[u],step+1,start);
}
int main()
{
    int n,k;
    cin >> n >> k ;
    for(int i=1;i<=n;i++){
        cin >> p[i];
    }
    long long ans = -INT_MAX ;
    for(int i=1;i<=n;i++){
        cin >> a[i];
        ans = max(ans,a[i]);
    }
    for(int i=1;i<=n;i++){
        maxstep=0;
        dfs(p[i],1,i);
        //cout << maxstep <<endl;
        long long ret = 0 ;
        if(pre[maxstep]<0){
            for(int j=1;j<=min(k,maxstep);++j)
                ans= max(ans,pre[j]);
            if(k>=maxstep){
                ans = max(ans,pre[maxstep]);
            }
        }
        else{
            for(int j=0;j<=k%maxstep;++j)
                ans= max(ans,pre[maxstep]*(k/maxstep)+pre[j]);
            for(int j=0;j<=maxstep;++j)
                ans= max(ans,pre[maxstep]*(k/maxstep-1)+pre[j]);
        }
        //ans = max(ans,+pre[k%maxstep]);
    }
    cout <<ans <<endl;
    return 0;
}


Measured memory_bytes: 3680
require 'set'

k = gets.to_i

$lunlun = Set.new


def search(s, i)
  if i >= 10
    return
  end

  $lunlun << s.to_i

  d = s[0].to_i

  (([0, d-1].max)..([9, d+1].min)).each do |g|
    search(g.to_s + s, i + 1)
  end
end

0.upto(9) do |i|
  search(i.to_s, 0)
end

p $lunlun.to_a.sort[k]


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

const int INF = 1e9+7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    cin>>n;
    vector<ll> h(n);
    for(ll i=0;i<n;i++){
        cin>>h[i];
    }
    vector<ll> dp(n,INF);
    dp[0]=0;
    for(ll i=0;i<n;i++){
        for(ll j=i+1;j<=i+2;j++){
            if(j<n){
                dp[j] = min(dp[j],dp[i] + abs(h[j]-h[i]));
            }
        }
    }
    cout<<dp[n-1]<<"\n";
    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
int p[1<<20],n,q,a,i,j,c;main(){std::cin>>n>>q;for(i=0;i<n;i++){std::cin>>a;p[a]=1;}for(i=0;i<q;i++){std::cin>>a;for(j=a-1;j>=0;j--){c=j;while(1){if(p[c]){std::cout<<j<<"\n";goto E;}c+=a;if(c>300000)break;}}E:;}}

Measured memory_bytes: 2332
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int x = stdIn.nextInt();
		int y[][][] = new int[5][4][11];
		for(int i=0; i < x; i++){
			int b = stdIn.nextInt();
			int f = stdIn.nextInt();
			int r = stdIn.nextInt();
			int v = stdIn.nextInt();

		    y[b][f][r]+= v;
		}
		stdIn.close();
		for(int a=1; a <= 4; a++){
			for(int c=1; c <= 3; c++){
				for(int d=1; d <= 10; d++){
						System.out.printf(" %d",y[a][c][d]);
				}
				System.out.println();
			}
			if(a != 4){
				System.out.println("####################");
			}
		}
	}
}



Measured memory_bytes: 30648
//jinhaonan
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
template<class T>inline void read(T &x){
	x=0;char c=getchar();bool f=0;
	for(;c>'9'||c<'0';f=c=='-',c=getchar());
	for(;c>='0'&&c<='9';x=(x<<1)+(x<<3)+c-'0',c=getchar());
	x=f?-x:x;
}
template<class T>inline void write(T x){
	if(x<0)putchar('-'),x=-x;
	if(x>=10)write(x/10);
	putchar(x%10+48);
}
template<class T>inline bool chkmax(T &a,T const &b){
	return a<b?a=b,1:0;
}
template<class T>inline bool chkmin(T &a,T const &b){
	return a>b?a=b,1:0;
}
int main(){
	// freopen("in.txt","r",stdin);
	int n,k;read(n),read(k);
	write((n+k-3)/(k-1)),putchar('\n');
	return 0;
}

Measured memory_bytes: 256