akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ALL(A) (A).begin(),(A).end()
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
 
const ll mod = 1e9+7;
const ll INF = -1*((1LL<<63)+1);
const int inf = -1*((1<<31)+1);
 
using namespace std;

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

struct edge{
    ll cost;
    ll now;
    ll next;
};

bool cmp( edge &a, edge &b){
    return a.cost < b.cost;
}
int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
    cin >> N;
    UnionFind uni(N);
    vector<pair<ll,int>> x(N),y(N);
    vector<vector<ll>> to(N),cost(N);
    vector<edge> e;
    rep(i,N){
        cin >> x[i].first >> y[i].first;
        x[i].second = i;
        y[i].second = i;
    }
    sort(ALL(x));
    sort(ALL(y));
    rep(i,N-1){
        int now = x[i].second;
        int next= x[i+1].second;
        ll cost = abs(x[i].first -x[i+1].first);
        // now と nextを結ぶcostがcostの辺をどこかに保存しておきたい
        edge x;
        x.cost = cost;
        x.next = next;
        x.now = now;
        e.push_back(x);
        now = y[i].second;
        next= y[i+1].second;
        cost = abs(y[i].first - y[i+1].first);
        edge y;
        y.cost = cost;
        y.next = next;
        y.now = now;
        e.push_back(y);
    }
    ll ans = 0;
    sort(ALL(e),cmp);
    for(int i=0;i<e.size();i++){
        int now = e[i].now;
        int next= e[i].next;
        ll cost = e[i].cost;
        if(uni.root(now)!=uni.root(next)){
            ans += cost;
            uni.unite(now,next);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 16624
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>

using namespace std;

int main() {
  string a,b;
  cin >> a >> b;
  if(a.length() > b.length()) {
    cout << "GREATER" << endl;
  } else if(a.length() < b.length()) {
    cout << "LESS" << endl;
  } else {
    bool ok = false;
    for(int i = 0; i < a.length(); i++) {
      if(a[i] > b[i]) {
        cout << "GREATER" << endl;
        ok = true;
        break;
      }
      else if(a[i] < b[i]) {
        cout << "LESS" << endl;
        ok = true;
        break;
      }
    }
    if(!ok) cout << "EQUAL" << endl;
  }
}


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(){
    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    rep(i, n) cin >> h[i];
    sort(h.begin(), h.end());
    if(k >= n){
        cout << 0 << endl;
        return 0;
    }
    ll ans = 0;
    rep(i, n - k){
        ans += h[i];
    }
    cout << ans << endl;    
    return 0;
}

Measured memory_bytes: 4028
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include <iomanip>
#include<deque>
#include<stack>
#include<set>
#include <numeric>

using namespace std;
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;
const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const int MOD = 1e9 + 7; //10^9 + 7
const double PI = 3.14159265358979323846264338327950288;




int main() {

	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	//==================================

	int N, Y;
	cin >> N >> Y;

	for (int i = 0; i <= N; i++) {
		for (int j = 0; i + j <= N; j++) {
			if (10000 * i + 5000 * j + 1000 * (N - i - j) == Y) {
				cout << i << " " << j << " " << N - i - j;
				return 0;
			}
		}
	}

	cout << "-1 -1 -1";





}	




Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
typedef long long int ll;
ll dp[100005];
int main()
{
    memset(dp,-1,sizeof(dp));
    ll n;
    cin>>n;
    ll arr[n];
    for(ll i=1;i<=n;i++)
        cin>>arr[i];
    dp[1]  = 0;
    dp[2] =  abs(arr[1] - arr[2]);
    for(int i=3;i<=n;i++)
    {
        dp[i] = min(dp[i-1] + abs(arr[i] - arr[i-1]),dp[i-2] + abs(arr[i] - arr[i-2]));
    }
    cout<<dp[n]<<endl;
}

Measured memory_bytes: 1792
import Control.Applicative
import Control.Monad
import Control.Monad.ST
import qualified Data.ByteString as BS
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
import qualified Data.Set as Set
--import qualified Data.Sequence as Sequence
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
--import Data.Array
--import Data.Array.Unboxed
import Data.Array.IArray
import Data.Array.MArray
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
-- import System.IO.Unsafe

-- templete
readInt = read :: String -> Int
readInteger = read :: String -> Integer
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getInteger = readLn :: IO Integer
getIntegers = map readInteger . words <$> getLine
getDouble = readLn :: IO Double
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
binMap :: (a -> a -> b) -> [a] -> [b]
binMap f (x:xs@(y:_)) = f x y : binMap f xs
binMap _ _ = []
splitRec :: Int -> [a] -> [[a]]
splitRec _ [] = []
splitRec n xs = let (y,ys) = splitAt n xs in y : splitRec n ys
infixl 7 `divCeil`
divCeil :: Integral a => a -> a -> a
x `divCeil` y = (x+y-1) `div` y
coverC :: Ord a => (a, a) -> a -> Bool
coverC (l,r) x = l<=x && x<=r
coverH :: Ord a => (a, a) -> a -> Bool
coverH (l,r) x = l<=x && x<r
-- templete



main = do
  n <- getInt
  unless (n==0) $ do
      ts <- sort <$> replicateM n getInt
      print $ sum $ init $ scanl (+) 0 ts
      main


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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	char A, B;

	cin >> A >> B;

	if (A == B)
	{
		cout << "=" << endl;
	}
	else if (A > B)
	{
		cout << ">" << endl;
	}
	else
	{
		cout << "<" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define SOR(vec) sort((vec).begin(),(vec).end())
using namespace std;
int n,m,pa1[12],pa2[12];
string grid[12],sorg[12];
bool ac(int id1,int id2){
	for(int it=0;it<n;it++) if(grid[it][id1]!=grid[pa1[it]][id2]) return false;
	return true;
}
void dfs1(int cur,int rem){
	if(cur==m) cout<<"YES"<<endl,exit(0);
	else if(pa2[cur]!=-1) dfs1(cur+1,rem);
	else{
		for(int nxt=cur+1;nxt<m;nxt++)
			if(pa2[nxt]==-1&&ac(cur,nxt))
				pa2[nxt]=cur,pa2[cur]=nxt,dfs1(cur+1,rem),pa2[nxt]=pa2[cur]=-1;
		if(rem) pa2[cur]=cur,dfs1(cur+1,0),pa2[cur]=-1;
	}
}
void dfs2(int cur,int rem){
	if(cur==n) dfs1(0,(m%2));
	else if(pa1[cur]!=-1) dfs2(cur+1,rem);
	else{
		for(int nxt=cur+1;nxt<n;nxt++)
			if(pa1[nxt]==-1&&sorg[cur]==sorg[nxt])
				pa1[nxt]=cur,pa1[cur]=nxt,dfs2(cur+1,rem),pa1[nxt]=pa1[cur]=-1;
		if(rem) pa1[cur]=cur,dfs2(cur+1,0),pa1[cur]=-1;
	}
}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>m;
	memset(pa1,-1,sizeof(pa1));
	memset(pa2,-1,sizeof(pa2));
	for(int i=0;i<n;i++) cin>>grid[i];
	for(int i=0;i<n;i++) sorg[i]=grid[i],SOR(sorg[i]);
	dfs2(0,(n%2));
	cout<<"NO"<<endl;
	return 0;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
const double pi = 3.14159265358979323846;

#define all(s) s.begin(),s.end()
#define allr(s) s.rbegin(),s.rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

void rw()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif // ONLINE_JUDGE
}

int main()
{
	speed;
	//rw();

	string s, t;
	cin >> s >> t;

	ll n = s.size(), m = t.size(), c = 0, ma = 0;

	for (int i = 0; i <= n - m; i++)
	{
		c = 0;
		for (int j = 0; j < m; j++)
			if (s[i + j] == t[j])
				c++;
		ma = max(ma, c);
	}

	cout << m - ma;
	return 0;
}


Measured memory_bytes: 3652
(defn split [xs]
  (-> xs
      (clojure.string/split #" ")
      (as-> x (map read-string x))))


(let [[h n] (split (read-line))
      a (split (read-line))]
  (if (<= h (reduce #'+ a))
    (println "Yes")
    (println "No")))

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

#define ankit_2305 cerr<<"\nTime taken : "<<(float)(clock()-time_p)/CLOCKS_PER_SEC<<" sec\n";
#define START clock_t
#define TIMER time_p=clock();
#define ll long long

#define MOD 1000000007

using namespace std;


int main(){
    START TIMER
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
	int k, n;
	cin>>k>>n;
	int a[n], mn = INT_MAX;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}

	sort(a, a+n);
	mn = min(mn, k - abs(a[0] - (a[1])));
	mn = min(mn, k - abs((k+a[0]) - a[n-1]));
	for(int i=1;i<n-1;i++){
		//cout<<k - abs(a[i] - a[(i+1)%n])<<" "<<k - abs(a[i] - a[(n+i-1)%n])<<"\n";
		mn = min(mn, k - abs(a[i] - a[(i+1)%n]));
		mn = min(mn, k - abs(a[i] - a[(n+i-1)%n]));
	}
	mn = min(mn, k - abs(a[n-1] - (k + a[0])));
	mn = min(mn, k - abs(a[n-1] - a[n-2]));
	cout<<mn;
    ankit_2305
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <set>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>
#include <map>
#include <utility>
#include <list>
#include <climits>
#include <bitset>
#include <numeric>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, n) for(auto i = (n).begin(); i != (n).end(); i++)
#define in_arr(type, a, n) copy_n(istream_iterator<type>(cin), n, (a).begin());
#define ll long long int

int main(){
    int n, m;
    cin >> n >> m;
    int ans = 1;
    for(int i = 1; i < sqrt(m) + 1; ++i){
        if(m % i != 0)
            continue;
        if(i >= n)
            ans = max(m / i, ans);
        if(m / i >= n)
            ans = max(i, ans);
    }
    for(int i = 1; i < sqrt(m) + 1; ++i){
        if(m % i != 0)
            continue;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

#define YEN_500 500
#define YEN_5 5
#define HAPPINESS_POINTS_LARGE 1000
#define HAPPINESS_POINTS_SMALL 5

int main()
{
	long moneyInput, fiveHundreadCoinsAmount, fiveCoinsAmount;

	scanf("%ld", &moneyInput);

	// Count amount of 500 and 5 Yen coins
	fiveHundreadCoinsAmount = moneyInput / YEN_500;
	fiveCoinsAmount = (moneyInput % YEN_500) / YEN_5;
	// Counts points for every coin
	printf("%ld \n", (fiveHundreadCoinsAmount * HAPPINESS_POINTS_LARGE) + (fiveCoinsAmount * HAPPINESS_POINTS_SMALL));

	return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#define  MAX 100005
#define NIL -1

struct Node {int parent, left, right;};

Node T[MAX];
int n, D[MAX], H[MAX];

void setDepth(int u, int d) {
  if(u == NIL) return;
  D[u] = d;
  setDepth(T[u].left, d + 1);
  setDepth(T[u].right, d + 1);
}

int setHeight(int u) {
  int h1 = 0, h2 = 0;
  if (T[u].left != NIL)
    h1 = setHeight(T[u].left) + 1;
  if (T[u].right != NIL)
    h2 = setHeight(T[u].right) + 1;
  return H[u] = (h1 > h2 ? h1 : h2);
}

int getSibling(int u) {
  if(T[u].parent == NIL) return NIL;
  if(T[T[u].parent].left != u && T[T[u].parent].left != NIL)
  return T[T[u].parent].left;
  if(T[T[u].parent].right != u && T[T[u].parent].right != NIL)
  return T[T[u].parent].right;
  return NIL;
}

void print(int u) {
  printf("node %d: ", u);
  printf("parent = %d, ", T[u].parent);
  printf("sibling = %d, ", getSibling(u));
  int deg = 0;
  if(T[u].left != NIL) deg++;
  if(T[u].right != NIL) deg++;
  printf("degree = %d, ", deg);
  printf("depth = %d, ", D[u]);
  printf("height = %d, ",H[u]);

  if (T[u].parent ==NIL) {
    printf("root\n");
  } else if (T[u].left == NIL && T[u].right == NIL) {
    printf("leaf\n");
    /* code */
  } else {
    printf("internal node\n");
  }
}

int main() {
  int v, l, r, root = 0;
  scanf("%d", &n);

  for(int i = 0; i < n; i++) T[i].parent = NIL;

  for(int i = 0; i < n; i++) {
    scanf("%d %d %d", &v, &l, &r);
    T[v].left = l;
    T[v].right = r;
    if(l != NIL) T[l].parent = v;
    if(r != NIL) T[r].parent = v;
  }

  for(int i = 0; i < n; i++) if(T[i].parent == NIL) root = i;

  setDepth(root, 0);
  setHeight(root);

  for (int i = 0; i < n; i++) print(i);

  return 0;
}



Measured memory_bytes: 2736
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String[] s = new String[N];
		
		for(int i = 0; i < N; i++) {
			s[i] = sc.next();
		}
		
		int M = sc.nextInt();
		String[] t = new String[M];
		
		for(int i = 0; i < M; i++) {
			t[i] = sc.next();
		}
		
		int temp = 0;
		int money = 0;
		
		for(int i = 0; i < N; i++) {
			for(int j = 0; j < N; j++) {
				if(s[i].equals(s[j])) {
					temp++;
				}
			}
			for(int j = 0; j < M; j++) {
				if(s[i].equals(t[j])) {
					temp--;
				}
			}
			money = Math.max(money, temp);
			temp = 0;
		}
		System.out.println(money);
	}
}


Measured memory_bytes: 23124
#include<bits/stdc++.h>
#define gc getchar
#define re register
#define rep(i,s,t) for(re int i=s;i<=t;++i)
#define reb(i,s,t) for(re int i=s;i>=t;--i)

using namespace std;
typedef long long ll;

const int Mod=1e9+7,N=3010;
int n,f[N],pre[N],suf[N];
string S;

inline int read(){
	int rt=0;
	char ch=gc();
	while(ch<'0'||ch>'9')ch=gc();
	while(ch>='0'&&ch<='9'){
		rt=(rt<<3)+(rt<<1)+(ch&15);
		ch=gc();
	}
	return rt;
}
int main(){
	n=read();
	cin>>S;
	f[1]=pre[1]=suf[1]=1;
	rep(i,2,n){
		if(S[i-2]=='<')rep(j,1,i)f[j]=pre[j-1];
		else rep(j,1,i)f[j]=suf[j];
		rep(j,1,i)pre[j]=(pre[j-1]+f[j])%Mod;
		reb(j,i,1)suf[j]=(suf[j+1]+f[j])%Mod;
	}
	return not printf("%d",pre[n]);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long optimalStrategyOfGame(long long *arr, int n) 
{ 
    long long table[n][n]; 
    for (int gap = 0; gap < n; ++gap) { 
        for (int i = 0, j = gap; j < n; ++i, ++j) { 
            long long x = ((i + 2) <= j) ? table[i + 2][j] : 0; 
            long long y = ((i + 1) <= (j - 1)) ? table[i + 1][j - 1] : 0; 
            long long z = (i <= (j - 2)) ? table[i][j - 2] : 0; 
  
            table[i][j] = max(arr[i] + min(x, y), arr[j] + min(y, z)); 
        } 
    } 
  
    return table[0][n - 1]; 
} 
int main(){
	int n;
	cin >> n;
	long long a[n+1],sum=0;
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
		sum += a[i];
	}
	cout << 2*optimalStrategyOfGame(a,n) - sum;
	return 0;
}


Measured memory_bytes: 70528
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define REP(X, Y, Z) for (ll(X) = (Y); (X) < (Z); (X)++)
#define REV(X, Y, Z) for (ll(X) = (Y); (X) > (Z); (X)--)

using namespace std;
using ll = long long;
using dll = deque<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using usll = unordered_set<ll>;
using umll = unordered_map<ll, ll>;
using sll = stack<int>;
using vll = vector<ll>;
using vvll = vector<vll>;

constexpr ll kMod = 1e9 + 7;

ll gcd(ll a, ll b) {
  if (a < b) {
    return gcd(b, a);
  }
  ll c = a % b;
  while (c != 0) {
    a = b;
    b = c;
    c = a % b;
  }
  return b;
}

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

void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

int main() {
  init();

  string O, E;
  cin >> O >> E;
  REP(i, 0, E.size()) {
    cout << O[i] << E[i];
  }
  if (O.size() > E.size()) {
    cout << O[O.size() - 1] << endl;
  }

  return 0;
}


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

using namespace std;
const int MAXN = 2e5+10;
long long f[MAXN];
long long n, d, a;

int main(){
    cin >>n>>d>>a;
    vector<pair<long long, long long>> m(n);

    for(int i=0;i<n;i++){
        long long x, h;
        cin >>x>>h;
        m[i] = make_pair(x, (h+a-1)/a);
    }

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

    int l=0,r=0;
    long long cnt = 0;
    long long atk = 0;
    while(l<n){
        while(r<n && m[l].first + 2*d >= m[r].first)
            r++;

        atk += f[l];
        long long b = max(0LL, m[l].second - atk);
        cnt += b;
        atk += b;
        f[r] -= b;
        l++;
    }

    cout <<cnt;

}


Measured memory_bytes: 4864
#include<iostream>
#include<set>
#include <bitset>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include <cstdio>
#include<algorithm>
#include <sstream>
#include<string.h>
#include <cmath>
#include <iomanip>
#include <string>
#include<list>
#include <limits>
#include <numeric>
#include <type_traits>
#define int long long
#define ll long long
#define mod  1000000007
#define MOD  1000000007
#define inf 1e17
#define rep(i,j,n) for(int i=j;i<n;i++)
#define P pair<int,int>
#define ps push_back
#define all(x) x.begin(),x.end()
double pi = 3.141592653589793;
using namespace std;
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; }
//ここから始めよう
int dp[3333][3333];
signed main(){
    int n;cin>>n;
    memset(dp,0,sizeof(dp));
    string s;cin>>s;
    dp[1][1]=1;
    rep(i,2,n+1){
        if(s[i-2]=='<'){
        rep(j,1,i+1){
                if(j==1)dp[i][j]=0;
                else dp[i][j]=(dp[i][j-1]+dp[i-1][j-1])%mod;
        }
        }
        else {
            for(int j=i;j>=1;j--){
                if(j==i)dp[i][j]=0;
                else dp[i][j]=(dp[i][j+1]+dp[i-1][j])%mod;
            }
        }
    }
    int ans=0;
    rep(i,1,n+1){
        ans=(ans+dp[n][i])%mod;
    }
    cout<<ans<<endl;return 0;
}

Measured memory_bytes: 87168
// inputに入力データ全体が入る
let input = ""
    function Main(input) {
    	input = input
        input = parseInt(input)
        console.log(input * 2 * 3.14);
    }
    //*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
    Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29628
#include <iostream>
#include <vector>
#include <cassert>

int main(int argc, char **argv)
{
    std::vector<int> a(3, 0);
    std::vector<int> b(3, 0);
    std::vector<std::vector<int>> c(3, std::vector<int>(3));
    
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 3; j++){
            int k;
            std::cin >> k;
            assert(0 <= k && k <= 100);
            c.at(i).at(j) = k;
        }
    }

    for(int i = -105; i <= 105; i++){
        a.at(0) = i;
        b.at(0) = c.at(0).at(0) - a.at(0);
        b.at(1) = c.at(0).at(1) - a.at(0);
        b.at(2) = c.at(0).at(2) - a.at(0);
        a.at(1) = c.at(1).at(0) - b.at(0);
        a.at(2) = c.at(2).at(0) - b.at(0);

        //std::cout << "a:" << a.at(0) << " " << a.at(1) << " " << a.at(2) << std::endl;
        //std::cout << "b:" << b.at(0) << " " << b.at(1) << " " << b.at(2) << std::endl;
        bool flag = true;
        for(int j = 0; j < 3; j++){
            for(int k = 0; k < 3; k++){
                if(a.at(j) + b.at(k) != c.at(j).at(k)){
                    flag = false;
                    break;
                }
            }
        }
        if(flag){
            std::cout << "Yes" << std::endl;
            return 0;
        }
    }
    
    std::cout << "No" << std::endl;
    
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        if(n >= m){
            System.out.println(0);
            return;
        }
        int[] x = new int[m];
        for(int i = 0; i < m; i++){
            x[i] = Integer.parseInt(sc.next());
        }
        Arrays.sort(x);
        
        int[] x2 = new int[m-1];
        for(int i = 0; i < m-1; i++){
            x2[i] = x[i+1] - x[i];
        }
        Arrays.sort(x2);
        
        int ans = 0;
        for(int i = 0; i < m-n; i++){
            ans += x2[i];
        }
        
        System.out.println(ans);
    }
}

Measured memory_bytes: 46540
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        char[] s = sc.next().toCharArray();
        char[] t = sc.next().toCharArray();
        int unmatch = 0;
        int unmatch_min = 1000;
        int cyc_max=s.length-t.length;
        for (int i=0; i<=cyc_max; i++){
            unmatch=0;
            for (int j=0; j<t.length; j++){
                if (!(s[i+j]==t[j])) unmatch++;
            }
            if (unmatch<unmatch_min) unmatch_min=unmatch;
        }

        System.out.println(unmatch_min);
    }
}

Measured memory_bytes: 35624
#define _CRT_SECURE_NO_WARNINGS
#define MOD 1000000007
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <bitset>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <string>
#include <functional>
#include <algorithm>
#include <iterator>
#include <cstdio>
#include <utility>
#include <unordered_map>
#include <cmath>
#include <chrono>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

typedef pair<ll, ll> P;
struct edge { ll to, cost; };

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define RFOR(i,a,b) for(ll i=(a);i>(b);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,n,-1)

inline ll madd(ll a, ll b) {
	a %= MOD;b %= MOD;
	return (a + b) % MOD;
}
inline ll msub(ll a, ll b) {
	a %= MOD;b %= MOD;
	a += MOD;
	return (a - b) % MOD;
}
inline ll mmul(ll a, ll b) {
	a %= MOD;b %= MOD;
	return (a*b) % MOD;
}
inline ll mpow(ll a, ll r) {
	long long res = 1;
	while (r > 0) {
		if (r & 1) res = res * a % MOD;
		a = a * a % MOD;
		r >>= 1;
	}
	return res;
}
inline ll minv(ll a) {
	a %= MOD;
	ll b = MOD, u = 0, v = 1;
	while (a) {
		ll t = b / a;
		b -= t * a; swap(a, b);
		u -= t * v; swap(u, v);
	}
	if (u < 0) u += MOD;
	return u;
}
inline ll mdiv(ll a, ll b) {
	a %= MOD;
	a *= minv(b);
	return a%MOD;
}

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) { }
	bool unite(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool same(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

/*int V;
vector<edge> G[MAX_V];
int d[MAX_V]:
void dijkstra(int s) {
priority_queue<P, vector<P>, greater<P>> q;
fill(d, d + V, INF);


}*/
//ll fact[100001], fact_inv[100001];
/*
ll combi(int a, int b) {
return mmul(fact[a], mmul(fact_inv[b], fact_inv[a - b]));
}
*/

int main(void) {
	int n, k;
	cin >> n >> k;
	vector<int> a(n),v(n);
	int suma = 0;
	REP(i, n) {
		cin >> a[i];
		suma += a[i];
	}
	/*
	int ma = suma, mi = 0;
	while (ma - mi>1) {
		if ((ma+mi)*(ma+mi)/4 < suma) {
			mi = (ma + mi) / 2;
		}
		else {
			ma = (ma + mi) / 2;
		}
	}
	*/
	int memo;
	FOR(i, 1, suma+1){
		if (i*i > suma) {
			memo = i;
			break;
		}
		if (suma%i == 0) {
			int div = suma / i;
			int sv = 0;
			REP(j, n) {
				v[j] = a[j] % div;
				sv += a[j] % div;
			}
			int wbar = sv / div;
			sort(v.begin(), v.end());
			int cost = 0;
			REP(j, n - wbar) cost += v[j];
			if (cost <= k) {
				cout << div;
				return 0;
			}
		}
	}
	RFOR(i, memo, 1) {
		if (suma%i == 0) {
			int div = i;
			int sv = 0;
			REP(j, n) {
				v[j] = a[j] % div;
				sv += a[j] % div;
			}
			int wbar = sv / div;
			sort(v.begin(), v.end());
			int cost = 0;
			REP(j, n - wbar) cost += v[j];
			if (cost <= k) {
				cout << div;
				return 0;
			}
		}
	}
	cout << 1;
	return 0;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

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

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

void Main() {
    ll N, M;
    cin >> N >> M;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    ll x = 1;
    ll ans = 0;
    set<ll> used;
    rep(i, N) {
        ll a = A[i];
        a /= 2;
        used.insert(a);
        x = lcm(x, a);
    }
    ll ok2 = true;
    rep(i, N) {
        ll a = A[i];
        a/=2;
        if ((x / a) % 2 == 0) {
            ok2 = false;
        }
    }
    if (x <= M && ok2) {
        M -= x;
        ans ++;
        ans += M / (2*x);

    }
    cout << ans << '\n';
}

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


Measured memory_bytes: 5760
###########################################################     #####            
############################################ ###############          #   #      
############################################# ################     ##            
##################### #####################  # ##################     #          
######################  ################## #    #######   ##########      #      
######################## ################  #   #######  #      ####  ####        
################## ## #    #########        # #        ## ###                    
###################    #     ###           # ###    #  ##  ########              
########### ########                        #########  #   ########   ###        
#######  ###  ####     #####                  #######       ## ####  #    #      
#######      #   ########### #                 ####         #  ###           #   
#######       #####    #                                  #    ##               #
#######     ########                                    ##    #                  
#######     ##############                      #          #                     
#########  ###############                                      #                


n = int(input())
v = list(map(int, input().split()))
c = list(map(int, input().split()))

ans = 0
for i in range(n):
    if v[i] - c[i] > 0:
        ans += v[i] - c[i]

print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c,n;
	cin>>a;
	cin>>b;
	cin>>c;
	n=a+b+c;
	if(n>=22)
	cout<<"bust";
	else
	cout<<"win";
	return 0;
}


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

#define int long long 
typedef long long ll;
typedef pair<int,int>pi;
typedef vector<int>vi;

const int MAXN=200005;
const int MOD=998244353;

#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define DEC(i,a,b) for(int i=(a);i>=(b);i--)
#define pb push_back
#define mp make_pair
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
#define db(x) cerr<<#x<<" = "<<x<<"\n"
#define LOW(v,x) (lower_bound(all(v),(x))-(v).begin())
#define UP(v,x) (upper_bound(all(v),(x))-(v).begin())
int N,M,K;

ll qmult(ll X, ll Y, ll M) {    
    return X * Y % M;
}

ll qexp(ll A, ll B, ll M) {
    if (B == 0) return 1;
    ll half = qexp(A, B/2, M); 
    half = qmult(half, half, M);
    half %= M;
    if (B%2==1) half *= A%M; 
    return half%M;
}

int modinv(int x){
	return qexp(x, MOD-2, MOD);
}

int famod[MAXN], finv[MAXN];

int ans;

/*
int compute(int tk){
	int comp = famod[N-1];
	comp *= modinv(famod[tk]); comp%=MOD;
	comp *= modinv(famod[N-1-tk]); comp%=MOD;
	comp *= qexp(M,N-tk,MOD); comp%=MOD;
	return comp;
}
*/

int compute(int tk){
	int comp = famod[N-1];
	comp *= modinv(famod[tk]); comp%=MOD;
	comp *= modinv(famod[N-1-tk]); comp%=MOD;
	comp *= M; comp%=MOD;
	comp *= qexp(M-1,N-tk-1,MOD); comp%=MOD;
	return comp;
}

main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin>>N>>M>>K;
	famod[0]=1;
	FOR(i,1,MAXN-1) famod[i]=(famod[i-1]*i)%MOD;
	//int org = qexp(M,N,MOD);
	//db(org);
	/*
	FOR(i,K+1,N-1){
		if ((i-K)%2) org -= compute(i), org=(org+MOD)%MOD;
		else org += compute(i), org=(org+MOD)%MOD;
	}
	*/
	int ans = 0;
	FOR(i,0,K) ans += compute(i), ans %= MOD;
	cout<<ans;
}


Measured memory_bytes: 5200
#include<iostream>
#include<vector>
#include<utility>
#include<map>
#include<deque>
#include<numeric>
#include<algorithm>
#include<unordered_map>
#include<cmath>
#include<string>
#include<iomanip>

using namespace std;
using ll = long long int;
constexpr int INF = 1 << 30;
constexpr ll MOD = ll(1e9 + 7);

int n;
vector<double> p;
vector<vector<double>> dp;

int main(void) {
	cin >> n;
	p = vector<double>(n + 1);
	dp = vector<vector<double>>(n + 1, vector<double>(n + 1, 0));
	for (int i = 1; i < n + 1; i++)
		cin >> p[i];
	dp[0][0] = 1;
	for (int i = 1; i < n + 1; i++) {
		for (int j = 0; j <= i; j++) {
			if (j > 0)
				dp[i][j] = dp[i - 1][j] * (1 - p[i]) + dp[i - 1][j - 1] * p[i];
			else
				dp[i][j] = dp[i - 1][j] * (1 - p[i]);
		}
	}
	double ret = 0.;
	for (int i = (n + 1) / 2; i < n + 1; i++)
		ret += dp[n][i];
	cout << fixed << setprecision(10) << ret << endl;
	return 0;
}

Measured memory_bytes: 73624
#include <iostream>
#include <cmath>
using namespace std;
typedef long long ll;

ll pow(ll m, ll n, ll mod) {
  ll res = 1;
  while(n > 0) {
	if(n & 1) {
	  res = res * m % mod;
	}
	m = m * m % mod;
	n >>= 1;
  }
  return res;
}
int main() {
  ll a, b;
  cin >> a >> b;
  cout << pow(a, b, 1000000007) << endl;
  return 0;
}

Measured memory_bytes: 3080
#include<cstdio>
#include<cstring>
using namespace std;
#define MAXL 100000

char s[MAXL];

int main() {
	scanf("%s",s);
	int len=strlen(s),cnt=0;
	for(int i=0;i<len;i++)
		if(s[i]=='p')
			cnt++;
	printf("%d\n",len/2-cnt);
	return 0;
}

Measured memory_bytes: 384
from collections import deque

string = input()
x = deque()
for s in string:
    x.append(s)

head_left = True
B = int(input())
for i in range(B):
    cmd = input().split()
    if len(cmd) == 1 and cmd[0] == "1":
        head_left = not head_left
    else:
        _, n, c = cmd
        if (n == "1" and head_left) or (n == "2" and not head_left):
            x.appendleft(c)
        else:
            x.append(c)

if head_left:
    print("".join(list(x)))
else:
    print("".join(reversed(list(x))))

Measured memory_bytes: 10100
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
double n=sc.nextDouble();
double s=0;
for(int i=1;i<=n;i++){
	if(i%2==1){
s++;
	}
}
System.out.println(s/n);
	}
}

Measured memory_bytes: 23252
#include<iostream>
#include<string>

using namespace std;

int main(){

  string S;

  int x=0;

  cin >> S;

  if(S[0]==S[1] && S[2]==S[3] && S[0] != S[2]){
    x=1;
  }
  if(S[0]==S[3] && S[2]==S[1] && S[0] != S[1]){
    x=1;
  }

  if(S[0]==S[2] && S[1]==S[3] && S[0] != S[1]){
    x=1;
  }

  if(x==0){
    cout << "No" << endl;
  }else{
    cout << "Yes" <<endl;
  }

  return 0;
}


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

int main()
{
    int n, sum{};
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
    {
        int l, r;
        scanf("%d%d", &l, &r);
        sum += r - l + 1;
    }
    printf("%d\n", sum);

    return 0;
}

Measured memory_bytes: 256
#include<bits//stdc++.h>
using namespace std;
int main(){
    int n,a[3];cin >> n;
    while(n--){
        cin >> a[0] >> a[1] >> a[2];
        sort(a,a+3);
        if(a[0] * a[0] + a[1] * a[1] == a[2]*a[2]) cout << "YES"<<endl;
        else cout << "NO"<<endl;
    }
}


Measured memory_bytes: 3120
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
using lint = long long;

int main() {

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

	int H, W;
	cin >> H >> W;


	vector<string> grid(H);
	for (int i = 0; i < H; i++) cin >> grid[i];

	int dx[4]{ 1,-1,0,0 }, dy[4]{ 0,0,-1,1 };
	bool flag = true;
	for (int row = 0; row < H; row++) {
		for (int col = 0; col < W; col++) {
			if (grid[row][col] == '#') {
				for (int i = 0; i < 4; i++) {
					if (0 <= row + dx[i] && row + dx[i] < H &&
							0 <= col + dy[i] && col + dy[i] < W) {
						if (grid[row + dx[i]][col + dy[i]] == '#') break;
					}
					if (i == 3) flag = false;
				}
			}
			if (!flag) break;
		}
		if (!flag) break;
	}

	if (flag) cout << "Yes" << "\n";
	else cout << "No" << "\n";

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+10;
const int mod=1e9+7;

int gi() {
	int x=0,o=1;char ch=getchar();
	while(!isdigit(ch)&&ch!='-') ch=getchar();
	if(ch=='-') o=-1,ch=getchar();
	while(isdigit(ch)) x=x*10+ch-'0',ch=getchar();
	return x*o;
}

void inc(int &a,int b) {
	a=a+b>=mod?a+b-mod:a+b;
}

int n,m,f[N];
char s[N];

int main() {
	cin>>n>>m;
	scanf("%s",s+1);
	int p=m+1;
	for(int i=2;i<=m;i++)
		if(s[1]!=s[i]) { p=i;break; }
	if(p==m+1) {
		f[0]=1;
		for(int i=2,s=1;i<=n;i++) {
			f[i]=s;inc(s,f[i-1]);
		}
		int ans=1;
		for(int i=2;i<=n;i++)
			ans=(ans+1ll*i*f[n-i])%mod;
		cout<<ans;
	}
	else {
		--p;int mx=p+!(p&1),len=0;
		for(int i=p+1;i<=m;i++) {
			if(s[i]==s[1]) ++len;
			else {
				if(len&1) mx=min(mx,len);
				len=0;
			}
		}
		++mx;f[0]=1;
		for(int i=2,s=1;i<=n;i+=2) {
			f[i]=s;
			if(i>=mx) inc(s,mod-f[i-mx]);
			inc(s,f[i]);
			//cerr<<i<<' '<<f[i]<<endl;
		}
		int ans=0;
		for(int i=2;i<=mx;i+=2)
			ans=(ans+1ll*i*f[n-i])%mod;
		cout<<ans;
	}
	return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define MD 1000000007
typedef long long int ll;
typedef pair<ll, ll> P;
template <typename T>
std::string tostr(const T &t){std::ostringstream os;os << t;return os.str();}
int dx[4]={1, 0, -1, 0}, dy[4]={0, 1, 0, -1};

//親の場合parには，-(集合のサイズ)を格納
vector<ll> par(1e5+5,-1),dep(1e5+5,0);

//木の根を求める
ll find(ll x){
    if(par[x]<0){
        return x;
    }else{
        //return find(par[x])でも可能だが
        //根をつなぎなおして計算量を落としている
        return par[x]=find(par[x]);
    }
}

//xとyが同じ集合に属するか否か
bool same(ll x, ll y){
    return find(x)==find(y);
}

//xとyの属する集合を併合
void unite(ll x, ll y){
    //同じ集合なら意味なし
    x=find(x);
    y=find(y);
    if(x==y) return;
    //rankの大小でどちらにくっつけるかを判定
    if(dep[x]<dep[y]){
        par[y]+=par[x];
        par[x]=y;
    }else{
        par[x]+=par[y];
        par[y]=x;
        //同じdepのときは，yをxにくっつけ
        //xのdepをプラスする
        if(dep[x]==dep[y]) dep[x]++;
    }
}

//xの属する集合のサイズを求める
ll size(ll x){
    return -par[find(x)];
}

int main()
{
    ll n,m;
    cin>>n>>m;
    vector<P> pa(m+2);
    vector<ll> ans(m+2);
    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        a--;
        b--;
        pa[i]={a,b};
    }
    //m番目の辺から順につなげていく
    //UnionFind利用
    for(int i=m-1;i>=0;i--){
        //全ての橋が壊れている場合
        if(i==m-1){
            ans[i]=n*(n-1)/2;
        }else{
            if(ans[i+1]==0 || same(pa[i+1].first,pa[i+1].second)) {
                ans[i]=ans[i+1];
            }else{
                ll tmp=size(pa[i+1].first)*size(pa[i+1].second);
                ans[i]=ans[i+1]-tmp;
                unite(pa[i+1].first,pa[i+1].second);
            }
        }
    }
    //答え出力
    for(int i=0;i<m;i++){
        cout<<ans[i]<<endl;
    }
    return 0;
}

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


void solve(long long N, std::vector<long long> A){
    vector<ll> count(N, 0);
    REP(i, N){
        A.at(i)--;
        count.at(A.at(i))++;
    }
    ll total = 0;
    REP(i, N){
        total += count.at(i) * (count.at(i) - 1) / 2;
    }
    REP(i, N){
        ll ans = total;
        const ll v = A.at(i);
        ans -= count.at(v) * (count.at(v) - 1) / 2;
        ans += (count.at(v) - 1) * (count.at(v) - 2) / 2;
        cout << ans << endl;
    }
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 5760
import sys

#fp = open("input.txt", "r")
fp = sys.stdin

def operate(string):
    count = 1
    prev = string[0]
    ret = ""
    for c in string[1:]:
        if c == prev:
            count += 1
        else:
            ret += str(count) + prev
            count = 1
        prev = c
    ret += str(count) + prev
    #print ret
    return ret
            

while True:
    n = int(fp.readline()[:-1])
    if n == 0:
        break

    orig = fp.readline()[:-1]

    for i in xrange(n):
        orig = operate(orig)

    print orig

Measured memory_bytes: 4328
import java.util.Scanner;
class Main{
	public static void main(String[] a){
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			int n = scan.nextInt();
			int sum = 0;
			if(n > 36) System.out.println(0);
			else{
				for(int i = 0; i <= 9; i++){
					for(int j = 0; j <= 9; j++){
						for(int k = 0; k <= 9; k++){
							for(int l = 0; l <= 9; l++){
								if(i+j+k+l == n) sum++;
							}
						}
					}
				}
				System.out.println(sum);
			}
		}
	}
}

Measured memory_bytes: 18912
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    string S[310];
    rep(i, N) cin >> S[i];
    int ans = 0;
    rep(A, N) {
        bool ok = true;
        rep(i, N) {
            rep(j, N) {
                int i1 = (i + A) % N;
                int j1 = j;
                int i2 = (j + A) % N;
                int j2 = i;
                if(S[i1][j1] != S[i2][j2]) ok = false;
                //cout << i1 << " " << j1 << " " << S[i1][j1] << " " << i2 << " " << j2 << " " << S[i2][j2] << endl;
            }
        }
        ans += ok;
    }
    cout << ans * N << endl;

    return 0;
}


Measured memory_bytes: 3748
import sys
from collections import Counter

N = int(input())
A = list(map(int, input().split()))

Amx = max(A)
A.sort()
As = set(A)
# DP
ca = Counter(A)
ans = 0
dp = [True] * (Amx + 1)
for a in A:
    if ca[a] <= 1 and dp[a]:
        ans += 1
    k = 1
    while k * a <= Amx:
        dp[k * a] = False
        k += 1
print(ans)

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

int main(){
  bool a=false,b=false;
  int N;
  cin>>N;
  if(N/100 >0 && N/100 <13) a=true;
  if(N%100 >0 && N%100 <13) b=true;
  if(a && b)cout <<"AMBIGUOUS"<<endl;
  if(a && !b) cout<<"MMYY"<<endl;
  if(!a && b) cout<<"YYMM"<<endl;
  if(!a && !b) cout <<"NA"<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>

#define For(i, j, k) for(int i = j; i <= k; i++)
#define Forr(i, j, k) for(int i = j; i >= k; i--)

using namespace std;

const int N = 200010;

int n, A[N];
bool B[N];

bool check(int x){
	For(i, 1, 2 * n - 1) B[i] = A[i] >= x;
	int r = n;
	while(r < 2 * n - 1 && B[r + 1] ^ B[r]) ++r;
	int l = n;
	while(l > 1 && B[l - 1] ^ B[l]) --l;
	if(B[l] == B[r]) return B[l];
	if(!B[l]) return r - n < n - l;
	return r - n > n - l;
}

int main(){
	scanf("%d", &n);
	For(i, 1, 2 * n - 1) scanf("%d", &A[i]);
	int L = 2, R = 2 * n - 2;
	while(L < R){
		int mid = (L + R + 1) >> 1;
		if(check(mid)) L = mid;
		else R = mid - 1;
	}
	printf("%d\n", L);
	return 0;
}

Measured memory_bytes: 1280
d[100];i,j,k;s;main(h){
	for(gets(d);j<100;)scanf("%d",d+j++);
	for(;i<10;i++)for(j=0;j<10;j++)for(k=0;k<10;k++)d[j*10+k]=fmin(d[j*10+k],d[j*10+i]+d[i*10+k]);
	for(;~scanf("%d",&h);)~h&&(s+=d[h*10+1]);
	printf("%d",s);
}

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

using namespace std;

#define ll long long

const ll MAX = 10000000000;

int main(){
    ll n; cin >> n;
    
    ll sum = 0;
    ll i;
    
    for(i = 0 ; i < MAX ; i ++){
        sum += i;
        if(sum >= n) break;
    }
    
    cout << i -- << endl;
    
}


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

using namespace std;

bool isprime(int x)
{
  if(x == 2) return true;

  if(x <= 1) return false;

  for(int i=2;i*i <= x;i++)
    {
      if(x % i == 0)
	{
	  return false;
	}
    }
  return true;
}
int main(){
  int n;

  while(1)
    {
      int cnt = 0;
      cin >> n;
      if(n == 0) break;

      for(int i=n+1;i <= n*2;i++)
	{
	  if( isprime(i) ) cnt++;
	}
      cout << cnt << endl;
    }
  return 0;
}
  



Measured memory_bytes: 3100
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>

using namespace std;

using ll = long long;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

#define input(...) __VA_ARGS__; in(__VA_ARGS__)

template<class T>
void print(vector<T> a) {
  cout << "[ ";
  REP(i, a.size()) cout << a[i] << " ";
  cout << "]" << endl;
}

void print() {
  std::cout << std::endl;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  std::cout << head << " ";
  print(std::forward<Tail>(tail)...);
}

void in() { }

template <class Head, class... Tail>
void in(Head&& head, Tail&&... tail) {
  cin >> head;
  in(std::forward<Tail>(tail)...);
}

int main() {
  ll input(n);
  vector<vector<ll>> graph(n);
  REP(i, n) {
    ll input(u, k);
    REP(j, k) {
      ll input(v);
      graph[u - 1].push_back(v - 1);
    }
  }

  vector<bool> visited(n);
  vector<ll> cost(n);
  queue<pair<ll, ll>> que;
  que.push({0, 0});
  while (!que.empty()) {
    pair<ll, ll> node = que.front();
    que.pop();

    if (!visited[node.first]) {
      cost[node.first] = node.second;
    }
    visited[node.first] = true;

    for(auto v: graph[node.first]) {
      if (!visited[v]) {
        que.push({v, node.second + 1});
      }
    }
  }
  REP(i, n) {
    if (!visited[i]) cost[i] = -1;
    cout << i + 1 << " " << cost[i] << endl;;
  }
}



Measured memory_bytes: 3580
use proconio::input;

fn main() {
    input! {
        n: u64,
    }

    let mut ret = 0;
    let tmp = [3, 5, 7];
    let mut v: Vec<u64> = Vec::new();
    for i in tmp.iter() {
        v.push(*i);
        ret += dfs(&mut v, n);
        v.pop();
    }
    println!("{}", ret);
}

fn make_num(v: &Vec<u64>) -> u64 {
    let n = v.len();
    let mut ret = 0;
    for i in 0..n {
        ret = ret * 10 + v[n - 1 - i];
    }
    ret
}

fn dfs(v: &mut Vec<u64>, n: u64) -> u64 {
    if make_num(v) > n {
        return 0;
    }

    let tmp = [3, 5, 7];
    let mut ret = 0;
    for i in tmp.iter() {
        v.push(*i);
        ret += dfs(v, n);
        v.pop();
    }

    if v.iter().any(|&x| x == 3) && v.iter().any(|&x| x == 5) && v.iter().any(|&x| x == 7) {
        ret + 1
    } else {
        ret
    }
}


Measured memory_bytes: 2152
#include <bits/stdc++.h>
#define ll long long
inline int roundup(int a, int b) { return (((a + (b -1)) / b)); }
using namespace std;

signed main(void) {
    ll x, y;
    ll n, d, count = 0;
    cin >> n >> d;
    ll d_sq = d*d;
    for(int i = 0; i < n; i++) {
        cin >> x >> y;
        if((x*x + y*y) <= d_sq ) {
            count++;
        }
    }
    cout << count << '\n';
    return 0;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, a, n) for (ll i = (a); i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    ll n, k;
    cin >> n >> k;
    if (k == 1) cout << 0 << endl;
    else cout << n - k << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <cmath>
#include <map>
using namespace std;
typedef long long LL;

int main() {
    int d;
    cin >> d;
    if (d == 25) puts("Christmas");
    if (d == 24) puts("Christmas Eve");
    if (d == 23) puts("Christmas Eve Eve");
    if (d == 22) puts("Christmas Eve Eve Eve");
}


Measured memory_bytes: 256
from functools import lru_cache

@lru_cache(maxsize=None)
def rec_div(i):
    if i < 2:
        return 0
    a, b = divmod(i, 2)
    if b == 0:
        return rec_div(a) + 1
    else:
        return 0
n = input()
l = map(lambda x: rec_div(int(x)), input().split())
print(sum(l))

Measured memory_bytes: 16416
#include<bits/stdc++.h>
using namespace std;
main(){
  double av;
  int x[200000]={},m[200000]={},n;
  cin>>n;
  for(int i=0;i<n;i++){cin>>x[i];m[i]=x[i];}
  sort(m,m+n);
  av=(m[n/2]+m[n/2-1])/2;
  for(int i=0;i<n;i++)
    if(av>=x[i])cout<<m[n/2]<<endl;
    else cout<<m[n/2-1]<<endl;
}

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

int main(){
	int a,b,A;
	char op;;
	while(1){
		cin >> a >> op >> b ;
		if ( op == '+' ){
			A = a + b;
		}else if ( op == '+' ){
			A = a + b;
		}else if ( op == '-' ){
			A = a - b;
		}else if ( op == '*' ){
			A = a * b;
		}else if ( op == '/' ){
			A = a / b;
		}else{
			break;
		}
		cout << A << endl;
}
    return 0;
}

Measured memory_bytes: 3084