akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;

class Field{
	final char SEA ='0';
	final char LAND='1';
	
	StringBuilder map;
	int width;
	int height;
	
	Field(int w,int h, String[][] buf){
		width = w;
		height= h;
		map= new StringBuilder();
		StringBuilder edge= new StringBuilder();
		for(int i=0;i<w+2;i++){
			edge.append(SEA);
		}
		map.append(edge);
		for(int i=0;i<h;i++){
			map.append(SEA);
			for(int j=0;j<w;j++){
				map.append(buf[i][j]);
			}
			map.append(SEA);
		}
		map.append(edge);
	}
	
	int point2int(int x, int y){
		return (width+2)*y + x;
	}
	int int2x(int n){
		return n%(width+2);
	}
	int int2y(int n){
		return n/(width+2);
	}
	
	int[] neighbor(int x, int y){
		int[] neib= {point2int(x-1,y-1),point2int(x,y-1),point2int(x+1,y-1),
				     point2int(x-1,y  ),                 point2int(x+1,y  ),
				     point2int(x-1,y+1),point2int(x,y+1),point2int(x+1,y+1)};
		return neib;
	}
	int[] neighbor(int n){
		int x= int2x(n); int y= int2y(n);
		int[] neib= {point2int(x-1,y-1),point2int(x,y-1),point2int(x+1,y-1),
			         point2int(x-1,y  ),                 point2int(x+1,y  ),
			         point2int(x-1,y+1),point2int(x,y+1),point2int(x+1,y+1)};
		return neib;
	}

	char charAt(int x, int y){
		return map.charAt(point2int(x,y));
	}
	char charAt(int n){
		int x= int2x(n); int y= int2y(n);
		return map.charAt(point2int(x,y));
	}
	
	void traverse(){
		Deque<Integer> dfs= new LinkedList<Integer>();
		int tmp;
		int cnt=0;
		while ( ( tmp=map.indexOf(String.valueOf(LAND)) ) >=0 ) {
			cnt++;
			dfs.push(tmp);
			map.setCharAt(tmp, SEA);
			while (!dfs.isEmpty()) {
				tmp = dfs.peek();
				boolean reached = true;
				for(int i=0; i<neighbor(tmp).length; i++) {
					int next = neighbor(tmp)[i];
					if ( charAt(next) == LAND ) {
						dfs.push(next);
						map.setCharAt(next, SEA);
						reached = false;
					}
				}
				if (reached) {
					dfs.pop();
				}
			} 
		}
		System.out.println(cnt);
	}
}

public class Main{
    public static void main(String args[]) throws Exception{
    	Scanner sc= new Scanner(System.in);
    	int width,height;
    	while(true){
    		width = sc.nextInt();
    		height= sc.nextInt();
    		if( width!=0 || height!=0 ){
    			String[][] buf_map= new String[height][width];
    			for(int i=0;i<height;i++){
    				for(int j=0;j<width;j++){
    					buf_map[i][j]= sc.next();
    				}
    			}
    			Field f= new Field(width,height,buf_map); 
    			f.traverse();
    		} else{ break; }
    	}
    }
}

Measured memory_bytes: 38964
#include<stdio.h>

int main(){
  int i;
  int n;
  int s = 100000;
  int r = 0;

  scanf("%d",&n);

  for(i = 0; i < n; i++){
    r = s * 0.05;
    s = s + r;
    if(s % 1000 != 0){
      s = s - s % 1000 + 1000;
    }
  }
  
  printf("%d\n",s);

  return 0;

}

Measured memory_bytes: 592
# Simple Calculator
loop do
    a, op, b = gets.split
    a = a.to_i
    b = b.to_i
    case op
    when '+'
        puts a + b
    when '-'
        puts a - b
    when '*'
        puts a * b
    when '/'
        puts a / b
    else
        break
    end
end

Measured memory_bytes: 8608
#include <bits/stdc++.h>
using namespace std;
typedef bool boolean;

#define ll long long

void exgcd(int a, int b, int& x, int& y) {
	if (!b) {
		x = 1, y = 0;
	} else {
		exgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
}

int inv(int a, int n) {
	int x, y;
	exgcd(a, n, x, y);
	return (x < 0) ? (x + n) : (x);
}

const int Mod = 998244353;

template <const int Mod = :: Mod>
class Z {
	public:
		int v;

		Z() : v(0) {	}
		Z(int x) : v(x){	}
		Z(ll x) : v(x % Mod) {	}

		friend Z operator + (const Z& a, const Z& b) {
			int x;
			return Z(((x = a.v + b.v) >= Mod) ? (x - Mod) : (x));
		}
		friend Z operator - (const Z& a, const Z& b) {
			int x;
			return Z(((x = a.v - b.v) < 0) ? (x + Mod) : (x));
		}
		friend Z operator * (const Z& a, const Z& b) {
			return Z(a.v * 1ll * b.v);
		}
		friend Z operator ~(const Z& a) {
			return inv(a.v, Mod);
		}
		friend Z operator - (const Z& a) {
			return Z(0) - a;
		}
		Z& operator += (Z b) {
			return *this = *this + b;
		}
		Z& operator -= (Z b) {
			return *this = *this - b;
		}
		Z& operator *= (Z b) {
			return *this = *this * b;
		}
		friend boolean operator == (const Z& a, const Z& b) {
			return a.v == b.v;
		} 
};

Z<> qpow(Z<> a, int p) {
	Z<> rt = Z<>(1), pa = a;
	for ( ; p; p >>= 1, pa = pa * pa) {
		if (p & 1) {
			rt = rt * pa;
		}
	}
	return rt;
}

typedef Z<> Zi;

const int N = 2e7 + 7;

int n, A, B;
Zi fac[N], _fac[N];

void init(int n) {
	fac[0] = 1;
	for (int i = 1; i <= n; i++)
		fac[i] = fac[i - 1] * i;
	_fac[n] = ~fac[n];
	for (int i = n; i; i--)
		_fac[i - 1] = _fac[i] * i;
}
Zi comb(int n, int m) {
	return (n < m) ? (0) : (fac[n] * _fac[m] * _fac[n - m]);
}
Zi calc(int x, int y) {
	return comb(x + y, x) - comb(x + y, x + 1);
}

int main() {
	scanf("%d%d%d", &n, &A, &B);
	if (!B) {
		puts("1");
		return 0;
	} 
	init(n << 1);
	Zi ans = 0;
	for (int k = 0; k <= n - B && k <= A; k++) {
		if (B + k == n) {
			ans += (A == k) * calc(B - 1, A);
		} else {
			ans += calc(B - 1, k) * comb(n - B - k - 1 + A - k, A - k);
		}
	}
	printf("%d\n", ans.v);
	return 0;
}


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

int a, b;

int main(){

	cin >> a >> b;

	string A = "";
	string a_str = to_string(a);
	for (int i=0; i<b; i++) {
		A += a_str;
	}

	string B = "";
	string b_str = to_string(b);
	for (int i=0; i<a; i++) {
		B += b_str;
	}

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

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main() {
	int flag = 0;
	int card[3][3] = { 0 };
	int A[3][3] = { 0 };
	int N = 0;
	int b[100] = { 0 };
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) scanf("%d", &A[i][j]);
	}
	scanf("%d", &N);
	for (int i = 0; i < N; i++) scanf("%d", &b[i]);
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < 9; j++) {
			if (b[i] == A[j/3][j%3]) card[j / 3][j % 3] = 1;
		}
	}
	
	for (int i = 0; i < 3; i++) {
		if ((card[i][0] == 1) && (card[i][1] == 1) && (card[i][2] == 1)) {
			flag = 1;
		}
		if ((card[0][i] == 1) && (card[1][i] == 1) && (card[2][i] == 1)) {
			flag = 1;
		}
		if (flag == 1) break;
	}
	if ((card[0][0] == 1) && (card[1][1] == 1) && (card[2][2] == 1)) flag = 1;
	if ((card[0][2] == 1) && (card[1][1] == 1) && (card[2][0] == 1)) flag = 1;
	if (flag == 1) {
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}
	return 0;
}

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



int main(int argc, char const *argv[])
{

#if !ONLINE_JUDGE

	freopen("in1.txt", "r", stdin);
	freopen("out1.txt", "w" , stdout);

#endif

	int n;
	cin >> n;


	long long zx = n * 800;
	int rem = n / 15;
	cout << zx - rem * 200 << endl;


	return 0;
}

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

int main() {
  int D, G;
  cin >> D >> G;
  vector<int> p(D), c(D);
  for (int i = 0; i < D; ++i) {
    cin >> p.at(i) >> c.at(i);
  }
  int min_problems = INT_MAX;
  for (int i = 0; i < (1 << D); ++i) {
    vector<bool> solved(D, false);
    int score = 0;
    int problems = 0;
    for (int j = 0; j < D; ++j) {
      if ((i >> j)%2 == 1) {
        problems += p.at(j);
        score += (j+1)*100*p.at(j) + c.at(j);
        solved.at(j) = true;
      }
    }
    if (score < G) {
      for (int l = D-1; l >= 0; --l) {
        if (!solved.at(l)) {
          int additional_prob = (G - score + ((l+1)*100 - 1)) / ((l+1)*100);
          if (additional_prob > p.at(l)) {
            problems = INT_MAX;
            break;
          }
          else {
            problems += additional_prob;
            break;
          }
        }
      }
    }
    min_problems = min(problems, min_problems);
  }
  cout << min_problems << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

#define INF 100000000

#define writeln(n) cout<<n<<endl

using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
//vector<tuple<long long, long long, long long>>vec;

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;
}

llong pownew(llong m, llong n) {
    if (n == 0) { return 1; }
    if (n % 2 == 0) { return pow(m*m, n/2); }
    return pow(m, n-1) * m;
}

bool isprime(int p) {
    if (p == 1) return false;
    for (int i = 2; i < p; i++) {
        if (p%i == 0) return false;
    }
    return true;
}

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

const int inf=100000000;

long long modpow(long long a, long long n, long long mod) //a^n
{
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

llong gcd(llong a, llong b) {
    return b != 0 ? gcd(b, a % b) : a;
}
//setprecision(10);


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    //COMinit();
    string S; cin>>S;
    llong ans=0;
    llong num=0;
    for(int i=0; i<S.size(); i++){
        if(S[i]=='W') ans+=num;
        else ++num;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 720
import java.util.Scanner;

public class Main {

	private void solve() {
		Scanner in = new Scanner(System.in);
		String A = in.next();
		int[] alph = new int[26];
		for(int i=0;i<A.length();i++){
			alph[A.charAt(i)-'a'] ++;
		}
		
		long ans = 1 + c2(A.length());
		for(int i=0;i<26;i++){
			if(alph[i]>=2){
				ans -= c2(alph[i]);
			}
		}
		
		System.out.println(ans);
		
		
	}
	
	private long c2(int a){
		return 1L * a * (a-1) / 2;
	}

	public static void main(String[] args) {
		new Main().solve();
	}
}

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

int main(){
    int n;
    cin >> n;
    if(n <= 999) cout << "ABC" << endl;
    else cout << "ABD" << endl;
}

Measured memory_bytes: 256
# include <stdio.h>

int main (void)
{
    int N, Tmax;
    int c[101], t[101];
    scanf("%d%d", &N, &Tmax);
    int i;
    for (i=0;i<N;i++) {
        scanf("%d%d",&c[i],&t[i]);
    }
    
    int result;
    result = 101;
    c[result] = 1001;
    t[result] = Tmax + 1;
    for (i=0;i<N;i++) {
        if ((c[i] <= c[result]) && (t[i] <= Tmax)) result = i;
        //printf("%d:%d\n",i,c[result]);
    }
    
    if (t[result] > Tmax ){
        printf("TLE");
    } else {
        printf("%d", c[result]);
    }
    return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	ll k; cin>>k;
	if(k%2==0 || k%5==0){
		cout<<-1<<endl;
		return 0;
	}
	ll x=7%k;
	for(int i=1; i<=k; i++){
		if(x==0){
			cout<<i<<endl;
			return 0;
		}
		x=(x*10+7)%k;
	}
	cout<<-1<<endl;
	return 0;
}

Measured memory_bytes: 3620
import scala.io.StdIn

object Main {
  def main(args: Array[String]){
    // val input = StdIn.readLine().map(_.toInt)
    val time = StdIn.readInt()
    val hour = time / 3600
    val min = (time % 3600) / 60
    val sec = time % 60
    println(s"$hour:$min:$sec")
  }
}


Measured memory_bytes: 43696
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
	cout << fixed << setprecision(10);
	int n;
	cin >> n;
	vector<ll> v(n);
	rep(i,n) cin >> v[i];
	ll ans = 0;
	rep(i,n) ans += v[i]-1;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	static int[][][] field;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int n = sc.nextInt();
			int m = sc.nextInt();
			int p = sc.nextInt();
			if (n == 0 && m == 0 && p == 0)
				break;
			field = new int[n][n][n];
			String winner = "Draw";
			int turn = 0;
			for (int i = 0; i < p; i++) {
				int x = sc.nextInt() - 1;
				int y = sc.nextInt() - 1;
				move(x, y, i, n);
				if (winner.equals("Draw") && checkEnd(n, m) != 0) {
					if (checkEnd(n, m) == 1)
						winner = "Black";
					else
						winner = "White";
					turn = i + 1;
				}
				// printField(n);
			}
			if (winner.equals("Draw"))
				System.out.println(winner);
			else
				System.out.println(winner + " " + turn);
		}
		sc.close();
	}

	static void move(int x, int y, int turn, int n) {
		for (int i = 0; i < n; i++)
			if (field[x][y][i] == 0) {
				field[x][y][i] = turn % 2 + 1;
				break;
			}
	}

	static int checkEnd(int n, int m) {
		int[] dx = { -1, 0, 1 };
		int[] dy = { -1, 0, 1 };
		int[] dz = { -1, 0, 1 };
		for (int i = 0; i < n; i++)
			for (int j = 0; j < n; j++)
				for (int k = 0; k < n; k++)
					if (field[i][j][k] != 0)
						for (int a = 0; a < dx.length; a++)
							for (int b = 0; b < dx.length; b++)
								for (int c = 0; c < dx.length; c++) {
									if (i + dx[a] * (m - 1) >= 0
											&& i + dx[a] * (m - 1) < n
											&& j + dy[b] * (m - 1) >= 0
											&& j + dy[b] * (m - 1) < n
											&& k + dz[c] * (m - 1) >= 0
											&& k + dz[c] * (m - 1) < n) {
										boolean x = true;
										if (dx[a] == 0 && dy[b] == 0
												&& dz[c] == 0)
											x = false;
										else
											for (int l = 1; l < m; l++)
												x = x
														&& (field[i][j][k] == field[i
																+ dx[a] * l][j
																+ dy[b] * l][k
																+ dz[c] * l]);
										if (x)
											return field[i][j][k];
									}
								}
		return 0;
	}

	static void printField(int n) {
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				for (int k = 0; k < n; k++)
					System.out.print(field[k][i][j] + " ");
				System.out.println();
			}
			System.out.println();
		}
	}
}

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

using namespace std;
 
int main()
{
    double q;
     
    while (cin >> q, q != -1) {
        double x = q/2;
         
        while (1) {
            x -= (pow(x, 3) - q) / (3 * pow(x, 2));
            if(abs(pow(x, 3) - q) < 0.00001 * q) break;
        }
        printf("%.6f\n", x);
    }
    return 0;
}

Measured memory_bytes: 3400
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<list>
#include<set>
#include<string>
using namespace std;
int gcd(int a, int b) {
	int c = a % b;
	while (c != 0) {
		a = b;
		b = c;
		c = a % b;
	}
	return b;
}
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;
	}
};
typedef long long ll;

ll M = 1000000007;

vector<ll> fac(300001); //n!(mod M)
vector<ll> ifac(300001); //k!^{M-2} (mod M)

ll mpow(ll x, ll n) {
	ll ans = 1;
	while (n != 0) {
		if (n & 1) ans = ans * x % M;
		x = x * x % M;
		n = n >> 1;
	}
	return ans;
}
void setcomb() {
	fac[0] = 1;
	ifac[0] = 1;
	for (ll i = 0; i < 300000; i++) {
		fac[i + 1] = fac[i] * (i + 1) % M; // n!(mod M)
		ifac[i + 1] = ifac[i] * mpow(i + 1, M - 2) % M; // k!^{M-2} (mod M) ←累乗にmpowを採用
	}
}
ll comb(ll a, ll b) {
	if (a == 0 && b == 0)return 1;
	if (a < b || a < 0)return 0;
	ll tmp = ifac[a - b] * ifac[b] % M;
	return tmp * fac[a] % M;
}
// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a) {
	long long b = M, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= M;
	if (u < 0) u += M;
	return u;
}
vector<vector<ll>> mul(vector<vector<ll>> a, vector<vector<ll>> b, int n) {
	int i, j, k, t;
	vector<vector<ll>> c(n);
	for (i = 0; i < n; i++) {
		for (j = 0; j < n; j++) {
			t = 0;
			for (k = 0; k < n; k++)
				t = (t + a[i][k] * b[k][j] % M) % M;
			c[i].push_back(t);
		}
	}
	return c;
}

template< typename Monoid >
struct SegmentTree {

	int sz;
	vector< Monoid > seg;

	const Monoid M1;

	SegmentTree(int n, const Monoid &M1) : M1(M1) {
		sz = 1;
		while (sz < n) sz <<= 1;
		seg.assign(2 * sz, M1);
	}

	void set(int k, const Monoid &x) {
		seg[k + sz] = x;
	}

	void build() {
		for (int k = sz - 1; k > 0; k--) {
			seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
		}
	}

	void update(int k, const Monoid &x) {
		k += sz;
		seg[k] = x;
		while (k >>= 1) {
			seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
		}
	}

	Monoid query(int a, int b) {
		Monoid L = M1, R = M1;
		for (a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
			if (a & 1) L = f(L, seg[a++]);
			if (b & 1) R = f(seg[--b], R);
		}
		return f(L, R);
	}

	Monoid value(const int &k) const {
		return seg[k + sz];
	}

	Monoid f(Monoid a, Monoid b) {
		return a + b;
	}
};

int main() {
	int k, i;
	char s[111111];
	cin >> s >> k;
	for (i = 0; s[i] != '\0'; i++) {
		if (s[i] != 'a'&&'z' - s[i] + 1 <= k) {
			k -= 'z' - s[i] + 1;
			s[i] = 'a';
		}
	}
	i--;
	while(k > 0) {
		if (s[i] == 'z')
			s[i] = 'a';
		else
			s[i]++;
		k--;
	}
	cout << s << endl;
}


Measured memory_bytes: 7040
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	io, flush := NewIO()
	defer flush()
	n := io.ScanInt()
	p := io.ScanInts(n)
	count := 1
	min := p[0]
	for i := 1; i < n; i++ {
		if p[i] <= min {
			count++
			min = p[i]
		}
	}
	fmt.Println(count)
}

type IO struct {
	scanner *bufio.Scanner
	writer  *bufio.Writer
}

func NewIO() (*IO, func()) {
	io := &IO{
		scanner: newScanner(),
		writer:  newWriter(),
	}
	return io, func() { io.writer.Flush() }
}

func newScanner() *bufio.Scanner {
	s := bufio.NewScanner(os.Stdin)
	s.Buffer(make([]byte, 10000000), 10000000)
	s.Split(bufio.ScanWords)
	return s
}

func newWriter() *bufio.Writer {
	return bufio.NewWriter(os.Stdout)
}

func (io *IO) ScanBytes() []byte {
	if !io.scanner.Scan() {
		panic("scan string failed")
	}
	return io.scanner.Bytes()
}

func (io *IO) ScanString() string {
	if !io.scanner.Scan() {
		panic("scan string failed")
	}
	return io.scanner.Text()
}

func (io *IO) ScanStrings(n int) []string {
	strs := make([]string, n)
	for i := 0; i < n; i++ {
		strs[i] = io.ScanString()
	}
	return strs
}

func (io *IO) Scan2DStrings(y, x int) [][]string {
	strings := make([][]string, y)
	for i := 0; i < y; i++ {
		strings[i] = io.ScanStrings(x)
	}
	return strings
}

func (io *IO) Scan2DGraph(y int) [][]string {
	strs := make([][]string, y)
	for i := 0; i < y; i++ {
		strs[i] = strings.Split(io.ScanString(), "")
	}
	return strs
}

func (io *IO) ScanInt() int {
	return int(io.ScanInt64())
}

func (io *IO) ScanInts(n int) []int {
	ints := make([]int, n)
	for i := 0; i < n; i++ {
		ints[i] = io.ScanInt()
	}
	return ints
}

func (io *IO) Scan2DInts(y, x int) [][]int {
	ints := make([][]int, y)
	for i := 0; i < y; i++ {
		ints[i] = io.ScanInts(x)
	}
	return ints
}

func (io *IO) ScanInt64() int64 {
	i, err := strconv.ParseInt(io.ScanString(), 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *IO) ScanFloat64() float64 {
	i, _ := strconv.ParseFloat(io.ScanString(), 64)
	return i
}

func (io *IO) ScanFloat64s(n int) []float64 {
	floats := make([]float64, n)
	for i := 0; i < n; i++ {
		floats[i] = io.ScanFloat64()
	}
	return floats
}

func (io *IO) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}


Measured memory_bytes: 7168
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;

#define endl            "\n"
#define forn(i,x,n)     for(int i=x; i<n; i++)
#define forit(it, m)    for(decltype(m)::iterator it = m.begin(); it!=m.end(); ++it)
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());


void zeus()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

int fast_pow(long long base, long long n, long long M)
{
    if (n == 0)
        return 1;
    if (n == 1)
        return base;
    long long halfn = fast_pow(base, n / 2, M);
    if (n % 2 == 0)
        return ( halfn * halfn ) % M;
    else
        return ( ( ( halfn * halfn ) % M ) * base ) % M;
}

int32_t main() {

    zeus();

    int n; cin >> n;

    string x; cin >> x;

    int count = 0;

    forn(i, 0, n) {
        if (x[i] == '1') {
            count++;
        }
    }
    // cout << count << endl;
    int a1 = 0, a2 = 0;
    int mult1 = 1, mult2 = 1;

    for (int i = n - 1; i >= 0; i--) {


        // cout << "m " << mult1 << " " << mult2 << endl;
        if (x[i] == '1') {
            if (count != 1) {
                a1 += (mult1) % (count - 1);
                a1 = a1 % (count - 1);
            }
            a2 += (mult2) % (count + 1);
            a2 = a2 % (count + 1);
        }
        // cout << a1 << " " << a2 << endl;

        if (count != 1)
            mult1 = (2 * mult1) % (count - 1);

        mult2 = (2 * mult2) % (count + 1);
    }

    // cout << a1 << " " << a2 << endl;
    forn(i, 0, n) {
        int cnt = 0;
        if (x[i] == '0') {
            int rem = a2;
            rem += (fast_pow(2, n - i - 1, count + 1));
            rem = rem % (count + 1);
            cnt++;

            while (rem != 0) {
                rem = rem % (setbits(rem));
                cnt++;
            }
            cout << cnt << endl;
        }
        else {
            if (count == 1) {
                cout << 0 << endl;
                continue;
            }
            int rem = a1;
            rem = rem - (fast_pow(2, n - i - 1, count - 1));
            rem = (rem % (count - 1) + (count - 1)) % (count - 1);
            cnt++;

            while (rem != 0) {
                rem = rem % (setbits(rem));
                cnt++;
            }
            cout << cnt << endl;

        }
    }








}

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

int main(void)
{
	int n;
	while (cin >> n, n){
		int tmp, sum = 0;
		for (int i = 0; i < (n*(n-1)/2); i++){
			cin >> tmp;
			sum += tmp;
		}
		cout << sum / (n-1) << endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
#include<string.h>
#include<utility>
#include<iostream>
#include<queue>
#include<math.h>
#include<algorithm>
#include<vector>
#include<map>
 
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
 
 
int main()
{
    int n,t,a;
    scanf("%d\n%d %d\n",&n,&t,&a);
    double temp[1005]={};
    int h;
    REP(i,n)
    {
        scanf("%d",&h);
        temp[i]=a-(t-0.006*h);
        if(temp[i]<0)temp[i]*=-1;
    }
    double mint=114514;
    int ti=-1;
    REP(i,n)
    {
        if(mint>temp[i])
        {
            mint=temp[i];
            ti=i;
        }
    }
    printf("%d\n",ti+1);
    return 0;
}

Measured memory_bytes: 256
//K-OS WITH THE OCDE

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <deque>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <climits>

using namespace std;

typedef long long int ll;
typedef long double db;


#define TEST ll t; cin>>t; while(t--)
#define vell vector<ll>
#define pl pair<ll,ll>
#define all(v) v.begin(),v.end()
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define dbg(x)  cerr << #x << ": "<< x <<endl
#define dbg2(x,y) cerr<< #x <<": "<< x <<" || "<< #y << ": " << y << endl

#define endl "\n"
#define MAX 1e18
#define MIN INT_MIN
#define mod 1000000007



void solve()
{
     ll n;
     cin >> n;
     ll a[n] , curr = 1000 , s = 0;
     for(ll i=0 ; i<n ; ++i) {
     	cin >> a[i];
     }

     ll prev = 300;

     for(ll i=1 ; i<n ; ) {

     	 if(a[i] <= a[i-1]) {
     	 	i++;
     	 	continue;
     	 }

     	 s = curr / a[i-1];
     	 curr %= a[i-1];


     	 ll j = i;

     	 while(j < n && a[j] >= a[j-1])
     	 	j++;

     	 ll p = j - 1;

     	 curr += s * a[p];
     	 s = 0;
     	 i = j;

     }

     cout << curr;


}

int main()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0);cin.tie(0);   
    //TEST
     solve();
}



Measured memory_bytes: 3556
#include<stdio.h>
#include<stdlib.h>

typedef struct node{
    int id;
    int p;
    int y;
}node;

int cmp1(const void* a, const void* b){
    if(((node*)a)->p == ((node*)b)->p){
        return ((node*)a)->y - ((node*)b)->y;
    }
    return ((node*)a)->p - ((node*)b)->p;
}

int cmp2(const void* a, const void* b){
    return ((node*)a)->id - ((node*)b)->id;
}

int main(){
    int n, m;
    scanf("%d %d", &n, &m);
    node a[m];
    for(int i=0; i<m; i++){
        a[i].id = i;
        scanf("%d %d", &(a[i].p), &(a[i].y));
    }
    qsort(a, m, sizeof(node), cmp1);
    /*for(int i=0; i<m; i++){
        printf("id:%d p:%d y:%d\n", a[i].id, a[i].p, a[i].y);
    }*/
    int x = a[0].p, y = 0;
    for(int i=0; i<m; i++){
        //printf("x:%d y:%d\n", x, y);
        if(a[i].p == x){
            y++;
            a[i].y = y;
        }else{
            y = 1;
            x = a[i].p;
            a[i].y = y;
        }
    }
    qsort(a, m, sizeof(node), cmp2);
    for(int i=0; i<m; i++){
        printf("%06d%06d\n", a[i].p, a[i].y);
    }

    return 0;
}

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

#ifdef LOCAL
#include "debug.h"
#else
#define DEBUG(...)
#endif

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int h, w, k;
  cin >> h >> w >> k;
  vector<string> s(h);
  for (auto&& e : s) cin >> e;
  int res = 0;
  for (int bh = 0; bh < 1 << h; ++bh) {
    for (int bw = 0; bw < 1 << w; ++bw) {
      int cnt = 0;
      for (int i = 0; i < h; ++i) {
        if (bh >> i & 1) continue;
        for (int j = 0; j < w; ++j) {
          if (bw >> j & 1) continue;
          cnt += s[i][j] == '#';
        }
      }
      res += cnt == k;
    }
  }
  cout << res << '\n';
}


Measured memory_bytes: 3648
def main():
    O = input()
    E = input()
    last = ""
    if len(O) > len(E):
        last = O[-1]
        O = O[:-1]

    ans = ""
    for s1, s2 in zip(O, E):
        ans += s1 + s2

    ans += last
    print(ans)


if __name__ == "__main__":
    main()

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

int main () {
  int N;
  cin >> N;
  vector <int> l(N);
  for (int i = 0; i < N; i++) cin >> l.at(i);
  int count = 0;
  sort (l.begin(),l.end());
  for (int i = 0; i < N; i++){
    for (int j = 0; j < i; j++){
      for (int k = 0; k < j; k++){
       if ((l.at(k) != l.at(i)) && (l.at(k) != l.at(j))&&(l.at(i) != l.at(j)) && (l.at(i) < l.at(j)+l.at(k))) count ++;
      }
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 3608
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<stdbool.h>
#include<assert.h>
typedef long long ll;
typedef long double ld;
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define rrep(i,l,r)for(ll i=(l);i>=(r);i--)
#define INF (1LL<<60)
#define MOD1 1000000007
#define MOD2 998244353
#define MAX_N (1 << 17)
#define YES printf("Yes\n")
#define NO printf("No\n")
#define PN printf("\n")
#define charsize 100005 //10^5+5

void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a= c;}
// void fill(ll n, ll a[n], ll value){ rep(i,0,n) a[i] = value; }
void cin(ll *n){ scanf("%lld",&(*n)); }
void cin2(ll *a, ll *b){ scanf("%lld%lld",&(*a),&(*b)); }
void cin3(ll *a, ll *b, ll *c){ scanf("%lld%lld%lld",&(*a),&(*b),&(*c)); }
ll max2(ll a,ll b){return a>=b?a:b;}
ll min2(ll a,ll b){return a>=b?b:a;}
ll min3(ll a, ll b, ll c){return (a<=b && a<=c) ? a : b<=c ? b : c;}
ll max3(ll a, ll b, ll c){return (a>=b && a>=c) ? a : b>=c ? b : c;}
ll minn(ll n, ll a[n]){ll b=INF;rep(i,0,n) b=min2(b,a[i]);return b;}
ll maxn(ll n, ll a[n]){ll b=-INF;rep(i,0,n) b=max2(b,a[i]);return b;}
ll ABS(ll a){return a>=0?a:(-a);}
ll POW(ll a, ll b){ll c=1;rep(i,0,b) c*=a;return c;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll mod_MOD1(ll n){n+= n<0?((-n)/MOD1+1)*MOD1:0; return n%=MOD1;}
ll mod_p(ll n ,ll p){n+= n<0?((-n)/p+1)*p:0; return n%=p;}
ll change_into_num(char s[] , ll len, ll p){ return !p ? 0 : POW(10,p-1)*(s[len-p]-'0') + change_into_num(s,len,p-1); }

int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
// int int_sort( const void * a , const void * b ) {
//   return strcmp(( char * )a , ( char * )b );
// }
//     qsort((void*)s,n,sizeof(s[0]),int_sort );

typedef struct{ ll a , b;}fr;
int cmp1( const void *p, const void *q ) { return ((fr*)p) ->a - ((fr*)q)->a;}
int cmp2( const void *p, const void *q ) { return ((fr*)q) ->a - ((fr*)p)->a;}
void strsortup(fr*a,int n){qsort(a,n,sizeof(fr),cmp1);}
void strsortdown(fr*a,int n){qsort(a,n,sizeof(fr),cmp2);}

int main(void){
    char s[5];
    // ll n;
    // ll ans=0;
    // cin(&n);
    // cin(&);
    scanf("%s",s);
    // cin(&);
    // cin2(&,&);
    // cin3(&,&,&);
    // ll [n];
    // rep(i,0,n){
    //     cin(&[i]);
    // }
    if(s[1]=='R'){
        printf("ABC\n");
    }else{
        printf("ARC\n");
    }
    
    // printf("%lld\n");
    return 0;
}


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

using namespace std;

const int N = 100005;
const long long MOD = (long long)1e9 + 7;

long long fac[N];
int n, a[N], mark[N];
long long res[N];

long long fastPow(long long base, long long e){
  long long foo = 1, bar = base;
  while(e){
    if(e & 1){
      foo = foo * bar % MOD;
    }
    bar = bar * bar % MOD;
    e >>= 1;
  }
  return foo;
}

long long cnm(int n, int m){
  return fac[n] * fastPow(fac[m] * fac[n - m] % MOD, MOD - 2) % MOD;
}

int main(){
  scanf("%d", &n);
  ++n;
  fac[0] = 1;
  int loc;
  for(int i = 1; i <= n; ++i){
    scanf("%d", &a[i]);
    ++mark[a[i]];
    if(mark[a[i]] == 2){
      loc = a[i];
    }
    fac[i] = i * fac[i - 1] % MOD;
  }
  int l = 0, r = 0;
  for(int i = 1; i <= n; ++i){
    if(a[i] == loc){
      if(!l){
        l = i;
      }
      else{
        r = i;
      }
    }
  }
  long long m = n - r + l - 1;
  for(int i = 1; i <= n; ++i){
    res[i] = cnm(n, i);
    //cout << i << ' ' << res[i] << endl;
    if(m >= i - 1){
      res[i] = (res[i] - cnm(m, i - 1) + MOD) % MOD;
    }
  }
  for(int i = 1; i <= n; ++i){
    cout << res[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
int n;
int main(){
  cin>>n;
  int len=1,sum=1;
  while(sum<n){
    len++;
    sum+=len;
  }
  int cnt=sum-n;
  string ans="";
  for(int i=len;i>=1;i--){
    while(cnt>=i){
      cnt-=i;
      ans+='(';
    }
    ans+=')';
  }
  while(len*2>(int)ans.size())ans+='(';
  cout<<ans<<endl;
  return 0;
}

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

struct UnionFind {
  UnionFind(int n) : n(n), v(n, -1) {}
  int n;
  vector<int> v;

  int root(int x) {
    return (v[x] < 0 ? x : v[x] = root(v[x]));
  }

  bool same(int x, int y) {
    return root(x) == root(y);
  }

  void unite(int x, int y) {
    x = root(x);
    y = root(y);
    if (x != y) {
      if (v[x] > v[y]) swap(x, y);
      v[x] += v[y];
      v[y] = x;
    }
  }

  int size(int x) {
    return -v[x];
  }
};

int main() {
  int n, q;
  cin >> n >> q;

  UnionFind uf(n);
  while (q--) {
    int c, x, y;
    cin >> c >> x >> y;
    if (c) {
      cout << uf.same(x, y) << endl;
    } else {
      uf.unite(x, y);
    }
  }
}

Measured memory_bytes: 3144
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int mod7 = n / 7;
    int mod4 = n / 4;
    boolean f = false;
    
    for(int j = 0; j <= mod7; j++){
      for(int i = 0; i <= mod4; i++){
        if(7 * j + 4 * i == n)
          f = true;
      }
    }
    
    if(f == false)
      System.out.println("No");
    else
      System.out.println("Yes");
  }
}


Measured memory_bytes: 21844
#include<stdio.h>
#include<stdlib.h>

#define MAX 101

void DFS(int, int);

int Adj[MAX][MAX];
int D[MAX], F[MAX];
int C[MAX]={0};
int count = 1;

int main(void){
  //int Adj[MAX][MAX];
  int i, j, n, u, k, v;

  scanf("%d", &n);
  for(i=1; i<n+1; i++){
    for(j=1; j<n+1; j++){
      Adj[i][j] = 0;
    }
  }

  for(i=1; i<n+1; i++){
    scanf("%d%d", &u, &k);
    for(j=1; j<k+1; j++){
      scanf("%d", &v);
      Adj[i][v] = 1;
    }
  }

  /* A.c
  for(i=1; i<n+1; i++){
    for(j=1; j<n+1; j++){
      if(j == n) printf("%d\n", Adj[i][j]);
      else printf("%d ", Adj[i][j]);
    }
    }*/

  for(i=1; i<n+1; i++){
    if(C[i] == 0) DFS(i, n);
  }

  for(i=1; i<n+1; i++) printf("%d %d %d\n", i, D[i], F[i]);

  return 0;
}

void DFS(int i, int n){
  int j;

  D[i] = count++;
  C[i] = 1;

  for(j=1; j<n+1; j++){
    if(Adj[i][j] == 1 && C[j] == 0) DFS(j, n);
  }

  F[i] = count++;

  return;
}

Measured memory_bytes: 640
//abc136

#include "iostream"
#include <string>
using namespace std;


int main(void)
{
	int k,x;
	cin >> k;
	cin >> x;

	for (int i = 0; i < k * 2 - 1; i++)
	{
		cout << (x - k + 1 + i)<<' ';
	}

	return 0;
}






Measured memory_bytes: 256
import sys
class UnionFind:
    def __init__(self, n):
        # 親要素のノード番号を格納　par[x] == x の時そのノードは根
        self.par = [i for i in range(n+1)]
        # 木の高さを格納する（初期状態では0)
        self.rank = [0] * (n+1)
        # 各々の集合の要素数（根が代表して値を持っておく）
        self.count = [1] * (n+1)

    # 検索
    def find(self, x):
        # 根ならその番号を返す
        if self.par[x] == x:
            return x
        # 根でないなら親の要素で再検索
        else:
            # 検索する過程で親を更新
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    # 併合
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
            self.count[y] += self.count[x]
            self.count[x] = 0
        else:
            self.par[y] = x
            self.count[x] += self.count[y]
            self.count[y] = 0
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    # 同じ集合に属しているか判定
    def same_check(self, x, y):
        return self.find(x) == self.find(y)

    # 属している集合の要素数
    def size(self,x):
        q = UnionFind.find(self,x)
        return self.count[q]

N,M=map(int,input().split())
K=[set() for i in range(M)]
tree=UnionFind(N)
for i in range(N):
    L=[int(i)-1 for i in input().split()]
    for m in L[1:]:
        K[m].add(i)
for i in range(M):
    Ki=list(K[i])
    if len(Ki)==0:
        continue
    for h in range(len(Ki)):
        tree.union(Ki[h],Ki[0])
for i in range(N):
    if not tree.same_check(0,i):
        print('NO')
        sys.exit()
print('YES')

Measured memory_bytes: 84512
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include <functional>
#include <numeric>
#include "math.h"
using namespace std;

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

#define inf long long_MAX/3
#define INF long long_MAX/3
#define PB push_back
#define pb push_back
#define MP make_pair
#define mp make_pair
#define ALL(a) (a).begin(),(a).end()
#define all(a) (a).begin(),(a).end()
#define SET(a,c) memset(a,c,sizeof a)
#define CLR(a) memset(a,0,sizeof a)
#define PII pair<long long,long long>
#define pii pair<long long,long long>
#define pcc pair<char,char>
#define pic pair<long long,char>
#define pci pair<char,long long>
#define VS vector<string>
#define VI vector<long long>
#define debug(x) cout<<#x<<": "<<x<<endl
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
#define pi 2*acos(0.0)
#define INFILE() freopen("in0.txt","r",stdin)
#define OUTFILE()freopen("out0.txt","w",stdout)
#define in scanf
#define out prlong longf
#define LL long long
#define ll long long
#define ULL unsigned long long
#define ull unsigned long long
#define eps 1e-14
#define FST first
#define SEC second

int n,d;
vector <vector <int> > x;

int main(){

	cin >> n >> d;
	x.resize(n);
	REP(i,n){
		x[i].resize(d);
	}
	REP(i,n){
		REP(j,d){
			cin >> x[i][j];
		}
	}
	int ans = 0;
	REP(i,n-1){
		FOR(j,i+1,n){
			int sum = 0;
			REP(k,d){
				sum += (x[i][k] -x[j][k]) * (x[i][k] -x[j][k]);
			}
			double sq = sqrt(sum);

			if (ceil(sq) == floor(sq)){
				ans++;
			}
		}
	}
	cout << ans;

}


Measured memory_bytes: 256
N, x = gets.chomp.split.map(&:to_i)
A = gets.chomp.split.map(&:to_i).sort

ans = 0
A.each do |a|
  if x >= a
    ans += 1
    x -= a
  else
    break
  end
end

if ans < N or x == 0
  puts ans
else
  puts ans - 1
end

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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main() {
	std::string s;
	std::cin >> s;
	int n = s.size();
	int cnt = 0;
	for (int i = 0; i < n / 2; i++) {
		if (s[i] != s[n - i - 1]) cnt++;
	}
	std::cout << cnt << std::endl;
	return 0;
}


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

int main() {
  int H,A;
  cin >> H>>A;
  

    if(H%A==0){
      cout<<H/A<<endl;
    }
    if(H%A!=0){
     
    
  
    cout<<H/A+1<<endl;
    }
  

}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int n = Integer.parseInt(sa[0]);
		long m = Long.parseLong(sa[1]);
		sa = br.readLine().split(" ");
		long[] a = new long[n];
		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(sa[i]);
		}
		br.close();

		Arrays.parallelSort(a);
		long ng = 1;
		long ok = a[n - 1] * 2 + 1;
		while (ok - ng > 1) {
			long mid = (ok + ng) / 2;
			long cnt = 0;
			for (int i = 0; i < n; i++) {
				int idx = binarySearch(a, mid - a[i] - 0.5);
				cnt += n - idx;
			}
			if (cnt < m) {
				ok = mid;
			} else {
				ng = mid;
			}
		}

		long[] b = new long[n + 1];
		for (int i = 0; i < n; i++) {
			b[i + 1] = b[i] + a[i];
		}

		long ans = 0;
		long cnt = 0;
		for (int i = 0; i < n; i++) {
			int idx = binarySearch(a, ng - a[i] - 0.5);
			long c = n - idx;
			cnt += c;
			long val = a[i] * c + (b[n] - b[idx]);
			ans += val;
		}
		ans -= (cnt - m) * ng;
		System.out.println(ans);
	}

	static int binarySearch(long[] array, double val) {
		int start = -1;
		int end = array.length;

		while (Math.abs(end - start) > 1) {
			int mid = (end + start) / 2;
			if (mid == array.length) {
				return mid;
			}
			if (array[mid] >= val) {
				end = mid;
			} else {
				start = mid;
			}
		}
		return end;
	}
}


Measured memory_bytes: 39348
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
#define MOD 1'000'000'007
using namespace std;
typedef long long ll;
typedef long double ld;

int n;
string s[50];
int cnt[26], sum[26];

int main(){
    cin>>n;
    rep(i,n){
        cin>>s[i];
    }
    fill(sum,sum+26,1001001001);

    rep(i,n){
        fill(cnt,cnt+26,0);
        rep(j,(int)s[i].size()){
            cnt[(int)(s[i][j]-'a')]++;
        }
        rep(j,26){
            sum[j]=min(sum[j],cnt[j]);
        }
    }

    string ans;
    rep(i,26){
        if(sum[i]!=1001001001){
            rep(j,sum[i]){
                char c='a'+i;
                ans+=c;
            }
        }
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 3604
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define MT make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define RT return
#define vv(a,b,c,d) vector<vector<a> >(b,vector<a>(c,d))
#define vvv(a,b,c,d,e) vector<vector<vector<a> > >(b,vv(a,c,d,e))
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;

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

    int a[3], odd=0;
    rep(i, 3) {
        cin >> a[i];
        odd += a[i] & 1;
    }
    if (odd == 1)rep(i, 3)if (!(a[i] & 1))a[i] += 1;
    if (odd == 2)rep(i, 3)if (a[i] & 1)a[i] += 1;
    int ans = 0;
    if (odd == 1 || odd == 2)ans++;
    int ma = 0;
    rep(i, 3)smax(ma, a[i]);
    rep(i, 3)ans += (ma - a[i]) / 2;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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;
}

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);
//const ll mod = 1000000007;
ll H, N;

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> H >> N;
    while(N--) {
        ll a;
        cin >> a;
        H -= a;
    }
    string ans = "No";
    if(H <= 0) ans = "Yes";
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()



//library mod int
template <int mod>
struct modint{
    ll x;

    //constructor
    modint(ll x=0): x((x%mod+mod)%mod){}

    //unary operator
    modint operator-() const { return modint(mod-x);}
    modint inv() const { return this->pow(mod-2);}
    

    //compound assignment
    modint& operator+=(const modint& a){
        if((x+=a.x)>=mod) x-=mod;
        return *this;
    }
    modint& operator-=(const modint& a){
        if((x-=a.x)<0) x+=mod;
        return *this;
    }
    modint& operator*=(const modint& a){
        (x*=a.x)%=mod;
        return *this;
    }
    modint& operator/=(const modint& a){
        return *this *= a.inv();
    }

    //arithmetic
    modint operator-(const modint& a) const {return modint (*this) -= a ; }
    modint operator+(const modint& a) const {return modint (*this) += a ; }
    modint operator*(const modint& a) const {return modint (*this) *= a ; }
    modint operator/(const modint& a) const {return modint (*this) /= a ; }
    //n should not be smaller than 0.
    modint pow(ll n) const{
        auto x=modint(1);
        auto m=*this;
        while(n>0){
            if(n&1) x*=m;
            n>>=1;
            m*=m;
        }
        return x;
    }

    //compare
    bool operator==(const modint& a) const {return x==a.x ; }
    bool operator!=(const modint& a) const {return x!=a.x ; }

    //I/O
    friend istream& operator>>(istream& is, modint& a ) noexcept {return is >> a.x ; }
    friend ostream& operator<<(ostream& os, const modint& a ) noexcept {return os << a.x ; }

};

//modの調整
constexpr int mod = 1e9 + 7;
using mint = modint<mod>;






mint comb(int n, int r){
    r=min(r,n-r);
    mint ans=1;
    rep(i,r){
        ans*=(n-i);
        ans*=(mint(i+1).inv());
    }
    return ans;
}


int main(){
    int n,a,b;
    cin>>n>>a>>b;
    mint ans=mint(2).pow(n)-1;
    ans-=comb(n,a);
    ans-=comb(n,b);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 384
n=int(input())
L=list(map(int,input().split()))
a=0
for i in range(n-2):
    for j in range(i+1,n-1):
        if L[i]!=L[j]:
            for k in range(j+1,n):
                
                
                if L[i]!=L[k] and L[j]!=L[k] and L[i]<L[j]+L[k] and L[j]<L[i]+L[k] and L[k]<L[j]+L[i]:
                    a+=1
                    
                    

print(a)

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

int n,cnt;
char s[100005];

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin>>n;
    cin>>s+1;
    cnt = 1; 
    for(int i=2;i<=n;i++){
        cnt+=s[i]!=s[i-1];
    }
    cout<<cnt<<endl;

    return 0;
}

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

int main(void){
  
  int N, inp;
  cin >> N;
  int count = 0, check = 1;
  for(int i = 0; i < N; i++){
    cin >> inp;
    if(inp != check){
      count++;
      if(count > 2){
        cout << "NO";
        return 0;
      }
    }
    check++;
  }
  cout << "YES";
 return 0;
  
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

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

    ll N, K;
    cin >> N >> K;
    if(K == 0) {
        cout << 1ll * N * N << endl;
        return 0;
    }
    ll rsl = 0;
    rep(i, K + 1, N + 1) {
        ll tmp = (N + 1) / i;
        ll r = (N + 1) % i;
        rsl += (tmp * (i - K));
        ll part = max(0ll, r - K);
        rsl += part;
    }

    cout << rsl << endl;
}


Measured memory_bytes: 256