akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll MOD=1000000007;
const ll INF=10000000100000;
const int MAX=100001;
const double EPS=1e-10;
struct edge{int to;double cost;};
typedef pair<double,int> P;
int V;
vector<edge> G[114514];
double d[114514];
void dijkstra(int s){
    priority_queue<P,vector<P>,greater<P>>que;
    fill(d,d+V,INF);
    d[s]=0;
    que.push(P(0,s));
    while(!que.empty()){
        P p=que.top();
        que.pop();
        int v=p.second;
        if(d[v]<p.first){
            continue;
        }
        for(int i=0;i<(int)G[v].size();i++){
            edge e=G[v][i];
            if(d[e.to]>d[v]+e.cost){
                d[e.to]=d[v]+e.cost;
                que.push(P(d[e.to],e.to));
            }
        }
    }
}
double dist(double x1,double y1,double r1,double x2,double y2,double r2){
    double res=max(0.0,sqrt(pow(x1-x2,2)+pow(y1-y2,2))-(r1+r2));
    return res;
}
int main() {
    double sx,sy,gx,gy;
    cin>>sx>>sy>>gx>>gy;
    int n;
    cin>>n;
    V=n+2;
    double x[1010],y[1010],r[1010];
    G[0].push_back({n+1,dist(sx,sy,0.0,gx,gy,0.0)});
    for(int i=1;i<=n;i++){
        cin>>x[i]>>y[i]>>r[i];
        G[0].push_back({i,dist(sx,sy,0.0,x[i],y[i],r[i])});
        G[i].push_back({n+1,dist(x[i],y[i],r[i],gx,gy,0.0)});
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            if(i==j){
                continue;
            }
            G[i].push_back({j,dist(x[i],y[i],r[i],x[j],y[j],r[j])});
            G[j].push_back({i,dist(x[i],y[i],r[i],x[j],y[j],r[j])});
        }
    }
    dijkstra(0);
    printf("%.12lf\n",d[n+1]);
    return 0;
}


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

int main(){
  int a[4],c[4];
  while(1){
    int e=0,b=0,k;
    for(int i=0;i<4;i++)
      k=scanf("%d",&a[i]);
    if(k==-1)break;
    for(int i=0;i<4;i++){
      cin >> c[i];
      for(int j=0;j<4;j++)
	if(c[i]==a[j]){
	  if(i==j)e++;
	  else b++;
	}
    }
    cout<<e<<' '<<b<<endl;
  }
  return 0;
}

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

using namespace std;
typedef long long ll;

int n;
const int N = 100100;
int dp[N][2];
int head[N << 1], nxt[N << 1], to[N << 1];
int edgeCount;
int md = 1e9+7;
void addEdge(int x, int y)
{
    to[edgeCount] = y;
    nxt[edgeCount] = head[x];
    head[x] = edgeCount;
    ++edgeCount;
}
int f(int u, int p, bool blockBlack)
{
    int &ret = dp[u][blockBlack];
    if (~ret) return ret;
    ll ret1 = 1;
    ll ret2 = !blockBlack;
    for (int v = head[u]; ~v; v = nxt[v])
        if (to[v] != p)
        {
            ret1 *= f(to[v], u, 0);
            if (ret1 >= md)
                ret1 %= md;
            if (!blockBlack)
            {
                ret2 *= f(to[v], u, 1);
                if (ret2 >= md)
                    ret2 %= md;
            }
        }
    ret1 += ret2;
    if (ret1 >= md)
        ret1 -= md;
    return ret = ret1;
}
int main()
{
    memset(head, -1, sizeof head);
    memset(dp, -1, sizeof dp);

    scanf("%d", &n);
    for (int i = 1, x, y; i < n; ++i)
    {
        scanf("%d%d", &x, &y);
        --x; --y;
        addEdge(x, y);
        addEdge(y, x);
    }
    printf("%d\n", f(0, 0, 0));

    return 0;
}


Measured memory_bytes: 10368
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <limits.h>
#include <iomanip>
#include <cassert>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
#define REP(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define Cout(x) cout << x << endl;
#define check(v) rep(i, v.size()) cout << v[i] << endl;
#define vint(x) vector<int> x
#define vll(x) vector<long long> x
#define vstr(x) vector<string> x
const long long LLINF = 1LL << 60;
const int INF = 1e9;
const long long MOD = 1000000007;
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;
}
typedef long long ll;
#define pint pair<int, int>
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

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

    int h, a;
    cin >> h >> a;
    cout << (h - 1) / a + 1 << endl;
    return 0;
}

Measured memory_bytes: 256
////////////////////////////////////////////
///                                      ///
///         Template ver. 1 rapel        ///
/// Fear is Temporary, Regret is Forever ///
///          Must Try and Get AC         ///
///                                      ///
////////////////////////////////////////////
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <iomanip>

#include <algorithm>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <utility>

#include <math.h>
#include <complex>

#include <assert.h>
#include <time.h>
//#include <chrono>
//#include <random>

#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <bitset>

#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define PF push_front
#define POB pop_back
#define POF pop_front
#define endl '\n'
using namespace std;

typedef long long LL;
typedef unsigned long long ULL;

void desperate_optimization(int precision){
  	ios_base::sync_with_stdio(false);
  	cin.tie(0);
  	cout.tie(0);
  	cout.setf(ios::fixed);
  	cout.setf(ios::showpoint);
  	cout.precision(precision);
}

const int N = 21;
const LL MOD = 1e9 + 7;
LL dp[N][1<<N];
int arr[N + 5][N + 5];
int n;

LL solve(int idx,int bm) {
	if(idx == -1) return 1;
	LL &res = dp[idx][bm];
	if(res != -1) return res;
	res = 0;
	for(int i = 0;i < n;i++) {
		if(((1<<i) & bm) && arr[idx][i]) {
			res = (res + solve(idx - 1,bm ^ (1<<i))) % MOD;
		}
	}
	return res;
}

void hora(int tc) {
	cin>>n;
	for(int i = 0;i < n;i++) for(int j = 0;j < n;j++) cin>>arr[i][j];
	memset(dp,-1,sizeof dp);
	cout<<solve(n - 1,(1<<n) - 1)<<endl;
}

int main(){
	desperate_optimization(10);
	int ntc = 1;
	//cin>>ntc;
	for(int tc = 1;tc <= ntc;tc++) hora(tc);
	return 0;
}



Measured memory_bytes: 344320
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdlib.h>
#include <math.h>
#include <numeric>


int main() {
	int n;

	std::cin >> n;

	std::vector<int> v(n + 2, 0);

	int dist = 0;
	for (size_t i = 0; i < n; i++)
	{
		std::cin >> v[i + 1];
		dist += abs(v[i] - v[i + 1]);
	}
	dist += abs(v[n] - v[n + 1]);

	for (size_t i = 0; i < n; i++)
	{
		int ans = dist;

		ans -= abs(v[i] - v[i + 1]);
		ans -= abs(v[i + 1] - v[i + 2]);
		ans += abs(v[i] - v[i + 2]);

		std::cout << ans << std::endl;
	}

	return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i, n) for(int i = n; i >= 0; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define SORT(v) sort((v).begin(), (v).end())
#define REV(v) sort((v).begin(), (v).end(), greater<int>())
typedef long long ll;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a * b / gcd(a, b);};

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


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

#define EMPTY 0
#define FULL 1
#define DELETED 2
 
#define INF 1000000000
 
#define min(a,b) (((a)<(b))?(a):(b))
#define max(a,b) (((a)>(b))?(a):(b))

typedef struct {
	long key;
	int flag;
} Data;

long H, W, N;
long a[100001];
long b[100001];
Data map[5678920] = {0};
int state_map[5678920] = {0};
Data taboo[5678920];
int state_taboo[5678920] = {0};
long ans[10] = {0};
int dx[] = {-1, 0, 1};
int dy[] = {-1, 0, 1};


long hash(long key, long count) {
	return (key + count) % 5678912;
}

void insert_map(long key) {
	int i, k;
	
	i = 0;
	k = hash(key, i++);
	while(state_map[k] == FULL) {
		k = hash(key, i++);
	}
	
	map[k].key = key;
	map[k].flag = 1;
	state_map[k] = FULL;
}

int search_map(long key) {
	int i, k;
	
	i = 0;
	k = hash(key, i++);
	while(state_map[k] != EMPTY) {
		if(state_map[k] == FULL && map[k].key == key) {
			return map[k].flag;
		}
		k = hash(key, i++);
	}
	
	return 0;
}

void insert_taboo(long key) {
	int i, k;
	
	i = 0;
	k = hash(key, i++);
	while(state_taboo[k] == FULL) {
		k = hash(key, i++);
	}
	
	taboo[k].key = key;
	taboo[k].flag = 1;
	state_taboo[k] = FULL;
}

long search_taboo(long key) {
	int i, k;
	
	i = 0;
	k = hash(key, i++);
	while(state_taboo[k] != EMPTY) {
		if(state_taboo[k] == FULL && taboo[k].key == key) {
			return taboo[k].flag;
		}
		k = hash(key, i++);
	}
	
	return 0;
}

int main() {
	int i, j, k, x, y, xx, yy, ii, jj;
	int count;
	long sum;
	
	scanf("%ld %ld %ld", &H, &W, &N);
	for(i=0;i<N;i++) {
		scanf("%ld %ld", &a[i], &b[i]);
		insert_map(a[i] * W + b[i]);
	}
	
	for(k=0;k<N;k++) {
		yy = a[k];
		xx = b[k];
		for(i=0;i<3;i++) {
			for(j=0;j<3;j++) {
				y = yy + dy[i];
				x = xx + dx[j];
				
				if(search_taboo(y * W + x)) continue;
				if(y <= 1 || y >= H || x <= 1 || x >= W) continue;
			
				insert_taboo(y * W + x);
				count = 0;
				for(ii=0;ii<3;ii++) {
					for(jj=0;jj<3;jj++) {
						if(search_map((y+dy[ii]) * W + (x+dx[jj]))) {
							count++;
						}
					}
				}
				ans[count]++;
			}
		}
	}

	sum = 0;
	for(i=1;i<=9;i++) {
		sum += ans[i];
	}
	
	ans[0] = (H * W) - (2 * H + 2 * W) + 4 - sum;

	for(i=0;i<=9;i++) {
		printf("%ld\n", ans[i]);
	}
	
	return 0;
}

Measured memory_bytes: 222592
#include<bits/stdc++.h>
using namespace std;
int main() {
	int n;
	cin >> n;
	int a[500000]={}, aa0=0,aa1=0,aa2=0,a0=0, a1=0, a2=0, count=0, sum = 0,b=0;
	int counta=0,suma=0;
	for(int i=0;i<n;i++){
		cin >> a[i];
		if(a[i]%3 == 0) a0++;
		else if(a[i]%3 == 1) a1++;
		else if(a[i]%3 == 2) a2++;
	}
	aa0=a0;
	aa1=a1;
	aa2=a2;

	while(1){
      // cout<<endl<<a0<<" "<<a1<<" "<<a2<<" "<<count<<" "<<sum<<" .";
	
		if(suma==0 && aa2 >= 2){
			counta += 2; aa2 -= 2; suma+=4;
            counta+=aa0;
            aa0=0;
		}else if(suma==0 && aa1>=2){
			counta+=2; aa1 -= 2;suma+=2;
			counta+=aa0;
            aa0=0;
		}else if(suma==0 && aa2>=1){
			counta++; aa2--; suma+=2;
			counta+=aa0;
			aa0=0;
		}else if(suma==0 && aa1>=1){
			counta++; aa1--; suma+=1;
			counta+=aa0;
			aa0=0;
		}else if(suma==0 && aa1<=0 &&aa2<=0){counta++; break;}

		if(suma>0&&suma%3==2&&aa2>0){
			counta++; aa2--; suma+=2;
		}else if(suma>0&&suma%3==1&&aa1>0){
			counta++; aa1--; suma++;
        }else if(aa0!=0||aa1!=0||aa2!=0){
            counta++;
            break;
		}
		
		if(aa0<=0&&aa1<=0&&aa2<=0){break;}
	}
    if(counta>=n)counta=n;

	while(1){
      // cout<<endl<<a0<<" "<<a1<<" "<<a2<<" "<<count<<" "<<sum<<" .";
	
		if(sum==0 && a1 >= 2){
			count += 2; a1 -= 2; ;sum+=2;
            count+=a0;
            a0=0;
		}else if(sum==0 && a2>=2){
			count+=2; a2 -= 2;sum+=4;
			count+=a0;
            a0=0;
		}else if(sum==0 && a2>=1){
			count++; a2--; sum+=2;
			count+=a0;
			a0=0;
		}else if(sum==0 && a1>=1){
			count++; a1--; sum+=1;
			count+=a0;
			a0=0;
		}else if(sum==0 && a1<=0 &&a2<=0){count++; break;}

		if(sum>0&&sum%3==2&&a2>0){
			count++; a2--; sum+=2;
		}else if(sum>0&&sum%3==1&&a1>0){
			count++; a1--; sum++;
        }else if(a0!=0||a1!=0||a2!=0){
            count++;
            break;
		}
		
		if(a0<=0&&a1<=0&&a2<=0){break;}
	}
    if(count>=n)count=n;
	
	if(counta>=count){count=counta;}
	cout<<count<<endl;
	return 0;
}
		




Measured memory_bytes: 5040
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int x = sc.nextInt();
		int y = sc.nextInt();

		int ans1 = a*x+b*y;
		int ans2 = x>y ? y*2*c+(x-y)*a : x*2*c+(y-x)*b;
		int ans3 = x>y ? x*2*c : y*2*c;

		System.out.println(Math.min(Math.min(ans1, ans2), ans3));
	}

}


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

int main() {
    long long n, k;
    cin >> n >> k;
    long long prev = n;
    long long m = 1LL << 60;
    if (n / k > 0) {
        n = n % k;
    }
    while (true) {
        n = abs(n - k);
        if (n < m) {
            m = min(m, n);
        } else if (m == n) {
            break;
        }
    }
    cout << m << endl;
    return 0;
}


Measured memory_bytes: 256
const SieveOfEratosthenes = (n) => {
    let flg = (new Array(n)).fill(0)/* set flg[i] to true when it is seived */
    let primes = []/* list of prime numbers */
    for(let i=2; i*i<=n; i++) {
        if(!flg[i]) {
            primes.push(i)
            for(let j=i; j*j<=n; j+=i) {
                flg[j] = 1
            }
        }
    }
    return primes
}

const factorizationBySoE = (n, primes) => {
    //const primes = SieveOfEratosthenes(n)
    let factors = {}
    primes.some(p => {
        if(n < p) return true
        while(n%p===0) {
            if(!factors[p])factors[p]=1
            else factors[p]++
            n/=p
        }
    })
    if(n>1)factors[n]=1
    return factors
}


const getGCD = (a,b) => {
    if(b===0)return a
    else if(a===0)return b
    return getGCD(b, a%b)
}

const main = (arg) => {
    const N = Number(arg.split("\n")[0])
    const a = arg.split("\n")[1].split(" ").map(Number)
    
    const MAX_A = 10**6+10
  //  const A = Math.max(...a)
    
    //  check if p is in {a} (paircoprime)
    //const primes = SieveOfEratosthenes(A)
//    return
    let set = [...new Array(MAX_A)].fill(0)
    isPairCoprime = true
  /*
    for(let i=0; i<N; i++) {
        const factors = Object.keys(factorizationBySoE(a[i], primes))
        for(let j=0; j<factors.length; j++ ) {
            // console.log(`i=${i}, j=${j}, ${factors[j]}`)
            // console.log(factors)
            if(set[factors[j]] === 1) {
                isPairCoprime = false
            }
            set[factors[j]] = 1
        }
    }
*/
//  return
    for(let i=0; i<N; i++) {
        set[a[i]]++
    }
//  return
    for(let i=2; i<MAX_A; i++) {
         let cnt=0
         for(let j=i; j<MAX_A; j+=i) {
             cnt+=set[j]
         }
        if(cnt>1) {
             isPairCoprime = false
         }
     }
    
    if(isPairCoprime) {
        console.log("pairwise coprime")
        return
    }
     // return
    // setcoprime
    // let gcd = getGCD(a[0], a[1])
    let gcd = 0
    for(let i=0; i<a.length; i++) {
        gcd = getGCD(gcd, a[i])
        // console.log(gcd)
    }
    
    if(gcd===1) {
        console.log("setwise coprime")
        return
    }
    
    console.log("not coprime")
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 109836
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#define llint long long
#define inf 1e18

using namespace std;
typedef pair<llint, llint> P;

struct edge{
	llint to, cost;
	edge(){}
	edge(llint a, llint b){
		to = a, cost = b;
	}
};

llint x, y, z, n, m, s, t;
llint a[100005], b[100005];
llint c[100005], d[100005];
vector<edge> G[300005];
llint dist[300005];

void dijkstra(llint S)
{
	for(int i = 1; i <= x+y+z; i++) dist[i] = inf;
	dist[S] = 0;
	
	priority_queue< P, vector<P>, greater<P> > Q;
	Q.push( make_pair(0, S) );
	
	llint v, d;
	while(Q.size()){
		d = Q.top().first;
		v = Q.top().second;
		Q.pop();
		if(dist[v] < d) continue;
		for(int i = 0; i < G[v].size(); i++){
			if(dist[G[v][i].to] > d + G[v][i].cost){
				dist[G[v][i].to] = d + G[v][i].cost;
				Q.push( make_pair(dist[G[v][i].to], G[v][i].to) );
			}
		}
	}
}

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> x >> y >> z >> n >> m >> s >> t;
	for(int i = 1; i <= n; i++){
		cin >> a[i] >> b[i];
		G[a[i]].push_back(edge(x+b[i], 1));
		G[x+b[i]].push_back(edge(a[i], 1));
	}
	for(int i = 1; i <= m; i++){
		cin >> c[i] >> d[i];
		G[x+c[i]].push_back(edge(x+y+d[i], 1));
		G[x+y+d[i]].push_back(edge(x+c[i], 1));
	}
	if(b[s] == c[t]){
		cout << 1 << endl;
		return 0;
	}
	
	dijkstra(a[s]);
	llint ans = max(dist[x+c[t]], dist[x+y+d[t]]);
	dijkstra(x+b[s]);
	ans = min(ans, max(dist[x+c[t]], dist[x+y+d[t]]));
	
	if(ans > inf/2) cout << -1 << endl;
	else cout << ans << endl;
	
	return 0;
}


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

const int N = 200010;
typedef long long ll;

ll pre[N];
int n;

int main(){
	scanf("%d", &n);
	for (int i = 1, x; i <= n; ++ i){
		scanf("%d", &x);
		pre[i] = pre[i - 1] + x;
	}
	ll ans = LLONG_MAX;
	for (int i = 1; i < n; ++ i){
		ans = std::min(ans, std::abs(pre[i] - (pre[n] - pre[i])));
	}
	return printf("%lld\n", ans), 0;
}

Measured memory_bytes: 1792
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {
	
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		
		char[] s = sc.next().toCharArray();
		int count = 0;
		
		for (int i = 1; i < s.length; i++) {
			if (s[i - 1] != s[i]) count++;
		}
		
		out.println(count);
		out.flush();
	}
	
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
	
	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}
	
	private byte readByte() {
		if (hasNextByte()) {
			return buffer[ptr++];
		} else {
			return -1;
		}
	}
	
	private boolean isPrintableChar(int c) {
		return '!' <= c && c <= '~';
	}
	
	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
			ptr++;
		}
	}
	
	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}
	
	public String next() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		StringBuilder sb = new StringBuilder();
		byte b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
}


Measured memory_bytes: 9552
import java.util.*;

public class Main{
  public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    int a=sc.nextInt();
    int b=sc.nextInt();
    if (a<=8&&b<=8) {
      System.out.println("Yay!");
    }else{
      System.out.println(":(");
    }
  }
}


Measured memory_bytes: 23764
#coding: utf-8
def solve(a, b, c, d, e, f):
    agn = a*e - b*d
    x = (e*c - b*f)/float(agn)
    y = (-d*c + a*f)/float(agn)
    if x == 0.: x = 0.
    if y == 0.: y = 0.
    print "%.3f %.3f" % (x, y)
    
while 1:
    try:
        a,b,c,d,e,f = map(float, raw_input().split())
        solve(a,b,c,d,e,f)
    except EOFError:
        break

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

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

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

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

    int ans = 0;
    for(int i = 0; i < N; i++)
    {
        int tmp;
        tmp = V.at(i) - C.at(i);
        if(tmp > 0)
        {
            ans += tmp;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a, b, m = 0;
	cin >> a >> b;
	double arr[a][b];
	double ans[99999];
	for(int i=0; i<a; i++)
		for(int j=0; j<b; j++)
			cin >> arr[i][j];
	for(int i=0; i<a-1; i++)
	{
		for(int j=i+1; j<a; j++)
		{
			double temp = 0;
			for(int k=0; k<b; k++)
				temp += double(pow(arr[i][k] - arr[j][k], 2));
			temp = (double)sqrt(temp);
			ans[m++] = temp;
		}
	}
	int count = 0;
	for(int i=0; i<m; i++)
	{
//		cout << ans[i] << '\n'; 
		double temp = ans[i] * ans[i];
		temp = (int)sqrt(temp);
		if(temp == ans[i]) count++;
	}
	cout << count << '\n';
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a[100020],n,x;
int f[100020];
int main(){
    cin>>n;
    for(int i=0;i<n;i++){
    	cin>>a[i];
	}
    reverse(a,a+n);
    memset(f,0x3f,sizeof f);
    for(int i=0;i<n;i++){
        int p=upper_bound(f,f+n,a[i])-f;
        f[p]=a[i];
    }
    int ans2=lower_bound(f,f+n,0x3f3f3f3f)-f;
    cout<<ans2<<endl; 
}

Measured memory_bytes: 1024
N = int(input())
A = [int(i) for i in input().split()]

d = dict()

for a in A:
    if a in d.keys():
        d[a] += 1
    else:
        d[a] = 1

d2 = sorted(d.items(), reverse=1)

first = 0
for i,j in d2:
    if d[i] >= 2:
        if first == 0 and d[i] >= 4:
            print(i**2)
            exit()
        elif first != 0:
            print(first*i)
            exit()
        else:
            first = i
print(0)


Measured memory_bytes: 21028
#pragma GCC optimize("Ofast")
#include <cstring>
#include <iostream>
#include <bits/stdc++.h>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;
typedef long long ll;

int main() {
    ll A, B;
    int i, a, b;

    cin >> A >> B;

    for(i=1; i<=1009; i++) {
        a = i*0.08;
        b = i*0.10;
        if(A==a && B==b) {
            cout << i << endl;
            break;
        }
    }
    if(i==1010) {
        cout << -1 << endl;
    }
}

Measured memory_bytes: 256
n, a, b = map(int, input().split())
L = [int(i) for i in input().split()]

t = 0
for i in range(n-1):
  if (L[i+1] - L[i])*a > b:
    t += b
  else:
    t += (L[i+1] - L[i])*a

print(t)

Measured memory_bytes: 14252
def func(n):
  if n % 2 == 0:
    return n / 2
  else:
    return 3*n + 1

s = int(input())
ans = [s]
while True:
  s = func(s)
  if s in ans:
    ans.append(s)
    print(len(ans))
    break
  ans.append(s)

Measured memory_bytes: 3060
N, L = map(int, input().split())

apples = [L+i for i in range(N)]

# 絶対値がもっとも小さい値のインデックスを求める

min_apple = 99999999
for i in range(len(apples)):
    if min_apple > abs(apples[i]):
        min_apple = abs(apples[i])
        omit = i

ans = 0
for i in range(len(apples)):
    if i == omit:
        continue
    else:
        ans += apples[i]

print(ans)


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

int main() {
   int n;
   cin>>n;
   int a[n+1],ans[n+1];
   for(int i=1;i<=n;i++)cin>>a[i];
   for(int i=n;i>=1;i--){
       int sum = 0;
       bool flag = 0;
       for(int j=2*i;j<=n;j+=i){
           sum += ans[j];
           flag = 1;
       }
       if(flag == 0){
           ans[i] = a[i];
       }else{
           if(a[i] == 0){
               if(sum%2 == 0){
                   ans[i] = 0;
               }else{
                   ans[i] = 1;
               }
           }else{
               if(sum%2 == 0){
                   ans[i] = 1;
               }else{
                   ans[i] = 0;
               }
           }
       }
   }
   vector<int> v;
   for(int i=1;i<=n;i++){
       if(ans[i] == 1){
           v.push_back(i);
       }
   }
   cout<<(int)v.size()<<"\n";
   for(int i : v){
       cout<<i<<" ";
   }
   cout<<"\n";
   return 0;
}


Measured memory_bytes: 3064
#include <iostream>
#include <functional>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <queue>
using namespace std;
typedef long long ll;
// static const ll max_n = 200010;



int main(){
    // int u, v;
    // bool updated = false;
    ll L;
    scanf("%lld", &L);
    double length = (double) L/ 3.;

    printf("%lf\n", length * length * length);

    return 0;

}

Measured memory_bytes: 256
#include <stdio.h>

using namespace std;

int main() {
  int A,B,hour,clock,c;
hour=24;
scanf("%d %d",&A,&B);
clock=A+B;
if(clock<hour)

{
    printf("%d\n",clock);
}

else if(A==clock)
{
    printf("%d\n",clock);
}
else if(clock>hour)
{
    c=clock-hour;
    printf("%d\n",c);

}
else if(clock==hour)
{

    printf("0\n");

}
  return 0;
}




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

int main()
{
    string s;
    cin >> s; 
    int c = 0; 
    if (s[0] == 'R' && s[1] == 'R' && s[2] == 'R')c = 3; 
    else if (s[0] == 'R' && s[1] == 'R')c = 2; 
    else if (s[1] == 'R' && s[2] == 'R')c = 2; 
  	else if (s[0] == 'R' || s[1] == 'R' || s[2] == 'R')c = 1; 
    cout << c << endl; 
    return 0;
}


Measured memory_bytes: 3592
import 'dart:async';
import 'dart:io';
import 'dart:convert';

Stream<String> get lineStream =>
    stdin.transform(utf8.decoder).transform(const LineSplitter());

Future<List<String>> readLines() async {
  final lines = <String>[];
  await for (var line in lineStream) {
    lines.add(line);
  }
  return lines;
}

void main() async {
  final lines = await readLines();
  final k = int.parse(lines[0]);
  if (k % 2 == 0 && k % 5 == 0) {
    print('-1');
    return;
  }
  var i = 1;
  var x = 7 % k;
  var s = <int>{};
  while (!s.contains(x)) {
    if (x == 0) {
      print('$i');
      return;
    }
    s.add(x);
    x = (x * 10 + 7) % k;
    i++;
  }
  print('-1');
}

Measured memory_bytes: 44268
import java.io.*;
import java.util.*;
import static java.lang.Math.*;

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

    public void solve(String[] args) {
        MyScanner scanner = new MyScanner();
        int N = scanner.nextInt();
        System.out.println(lcm(2, N));
    }

    public static long gcd(long m, long n) {
        return java.math.BigInteger.valueOf(m).gcd(java.math.BigInteger.valueOf(n)).longValue();
    }

        public static long lcm(long... arr) {
        if (arr.length == 1) return arr[0];
        if (arr.length == 2) return lcmImpl(arr[0], arr[1]);
        long[] newArr = new long[arr.length -1];
        System.arraycopy(arr, 2, newArr, 1, arr.length - 2);
        newArr[0] = lcmImpl(arr[0], arr[1]);
        return lcm(newArr);
    }
    public static long lcmImpl(long m, long n) {
        return java.math.BigInteger.valueOf(m).multiply(java.math.BigInteger.valueOf(n)).divide(java.math.BigInteger.valueOf(gcd(m, n))).longValue();
    }



    private class MyScanner {
        String[] s;int i;BufferedReader br;String reg = " ";
        MyScanner () { s = new String[0];i = 0;br = new BufferedReader(new InputStreamReader(System.in)); }
        public String next() {
            try {
                if (i < s.length) return s[i++]; String line = br.readLine();
                while (line.equals("")) {line = br.readLine();}
                s = line.split(reg, 0); i = 0;return s[i++];
            } catch (Exception e) {e.printStackTrace();}
            return null;
        }
        public int nextInt() {
            try {return Integer.parseInt(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public double nextDouble() {
            try {return Double.parseDouble(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public long nextLong()  {
            try {return Long.parseLong(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
    }
}


Measured memory_bytes: 21460
N,Q=map(int,input().split())
S=input()
cs=[0]*N
cnt=0
for i in range(1,len(S)):
  if S[i-1]=="A" and S[i]=="C":
    cnt+=1
  cs[i]=cnt
for i in range(Q):
  l,r=map(int,input().split())
  print(cs[r-1]-cs[l-1])

Measured memory_bytes: 6084
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i <= (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;

int main(){
    ll n,d;
    cin>>n>>d;
    ll x,y;
    ll cnt=0;
    for(ll i=1; i<=n; i++){
        cin>>x>>y;
        if(x*x+y*y<=d*d) cnt++;
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
using namespace std;
typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> oset;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
using ll = long long;

void test_case(){
	vector<int> hash(5);
	for(auto &x : hash)
		cin >> x;
	for(int i = 0 ; i < 5 ; i++)
		if(hash[i] == 0){
			cout<<i+1;
			break;
		}
}
 
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int T=1;
	//~ cin >> T;
	while(T--){
		test_case();
	}
	return 0;
}


Measured memory_bytes: 3564
/*
Author- Aasav Badera
Time- Mon Sep 28 09:33:35 2020
*/
#include<bits/stdc++.h> 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#pragma GCC optimize("-O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma") 
using namespace std;
using namespace __gnu_pbds;
#ifdef LOCAL  
#include <sys/resource.h>
#define meminc             rlimit rlim;if (getrlimit(RLIMIT_STACK, &rlim)) return 1;rlim.rlim_cur = 268435456;if (setrlimit(RLIMIT_STACK, &rlim)) return 2;
#else
#define meminc      
#endif
#ifdef LOCAL
#define dbg(args...)       { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#else
#define dbg(args...)
#endif
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}
#define ll                 int
#define vi                 vector<int >
#define ordered_set        tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// -------------------Standard Traversal Moves---------------------
// vi fx = {1 ,-1 ,0, 0}, fy = {0, 0, -1, 1};
// vi fx = {2, -2, 2, -2,  1, -1, 1, -1}, fy = {1, 1, -1, -1, 2, 2, -2, -2};
// vi fx = {1, 1, 1, -1, -1 , -1, 0, 0}, fy = {1, -1, 0, 1, -1, 0, 1, -1};
// ----------------------------------------------------------------

#define rep(i, a, b)       for(int  i=a;i<b;i++)
#define all(a)             (a).begin(),(a).end()
#define sz(x)              (int )x.size()
#define yes                cout << "YES" << endl
#define no                 cout << "NO" << endl
#define endl               '\n' 
// const int hell = (int)998244353;
const int hell = (int)1e9 + 7;
const long long int inf = 3223372036854775807;
const double PI = 3.14159265;
const int N = (int) 1e6 + 5;
int n, m, k, a[N];


int32_t main()
{
    meminc;
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cerr.precision(10);
    cout.precision(25);
    cout << fixed;
    #ifdef LOCAL
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif
    int tests = 1;
    // cin >> tests;
    rep(test, 1, tests+1)
    {
    	string s = "ACL";
    	cin >> n;
    	string g;
    	rep(i, 0 ,n)g += s;
    	cout << g << endl;

    }
    #ifdef LOCAL
        // cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    #endif
    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

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

    int a[10][10];
    rep(i,10)rep(j,10)a[i][j] = 0;

    srep(i,1,n+1){
        int x, y;
        int ii = i;
        x = ii % 10;
        y = ii % 10;
        ii /= 10;
        while(ii > 0){
            x = ii % 10;
            ii /= 10;
        }
        a[x][y]++;
    }

    int ans = 0;

    rep(i,10){
        rep(j,10){
            ans += a[i][j] * a[j][i];
        }
    }

    cout << ans << endl;
    return 0;
}
 
 


Measured memory_bytes: 256
import java.util.*;
	import java.util.Map.Entry;
	 
	 
	 class Main {
//		 static int mod =  (int) (Math.pow(10,9)+7);
		 static int mod =  (int) 998244353;
		 static List<ArrayList<Integer>>  list = new ArrayList<ArrayList<Integer>>();
	    public static void main(String[] args) {
	    	
	        Scanner sc = new Scanner(System.in);
	        long N = sc.nextLong();	

	        for(long i=1;i<=3500;i++) {
	        	for(long j=i;j<=3500;j++) {
	        		long up=3501;
	        		long down=0;
	        		while(up>=down) {
	        			long mid = (up+down)/2;
		        		if(4*i*j*mid==N*(i*j+j*mid+mid*i)) {
	        				System.out.print(i);
	        				System.out.print(" ");
	        				System.out.print(j);
	        				System.out.print(" ");
	        				System.out.println(mid);
	        				return;
	        			} else if(4*i*j*mid<N*(i*j+j*mid+mid*i)) {
	        				down=mid+1;
	        			} else {
	        				up=mid-1;
	        			}
	        		}
	        	}
	        }
	        
	        
	        System.out.println("end");
	        

	    }
	    
	    

	}

Measured memory_bytes: 23380
#include<bits/stdc++.h>
 using namespace std;
#define INF 1000000000
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
typedef long long LL;
int main(){
    int A,B;
    cin>>A>>B;
    A*=10;
    B*=10;
    int D=(A+B)/2;
    int E=(A+3600+B)/2;
    if((abs(D-min(A,B))<abs(E-max(A,B)))){
       cout<<D/10.0<<endl;
    }else{
       if(E>=3600){
         E-=3600;
       }
       cout<<E/10.0<<endl;
    }

    
    return 0;
}

Measured memory_bytes: 3280
fun main(args: Array<String>) {
        var (n, m) = readLine()!!.split(' ').map { it.toInt() }
        val a = readLine()!!.split(' ').map { it.toInt() }

        a.forEach {
            n -= it
        }
        if (n >= 0) {
            println(n)
        } else {
            println(-1)
        }
    }


Measured memory_bytes: 39356
#include <bits/stdc++.h>
using namespace std;
 
using ll = int64_t;
constexpr ll mod = ll(1e9 + 7);
 
int main () {
  ios::sync_with_stdio(0); cin.tie(0);
 

  ll a,b,c;
  cin >> a >> b >> c;
  swap(a,b);
  swap(a,c);
  cout << a <<  " " << b << " "  << c << endl;

}


Measured memory_bytes: 3608
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cstring>
#include<numeric>
#include<vector>
#include<map>
#include<set>
#include<cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int>PII;
typedef pair<ll,ll>PLL;
#define X first
#define Y second
int dx[4]={-1,0,1,0};
int dy[4]={0,1,0,-1};
const int maxn=1e4+10;
int a[maxn];
//个人觉得这一题可以通过搜索去解决。。。。

ll ans;
ll n,k;
set<int>st;

vector<ll>solve(ll n){
	vector<ll>res;
	for(ll i=2;i*i<=n;i++){
		if(n%i==0){
			res.push_back(i);
			if(n/i!=i){
				res.push_back(n/i);
			}
		}
	}
	res.push_back(n);
	return res;
}


int main(){
	ll n;
	cin>>n;
	//下面分成是约数，与不是约数两种情况来讨论
	//不是约数的情况，那么那个数就是n-1的约数
	if(n==2){
		cout<<1<<endl;
		return 0;
	}
	ll ans=0;
	//不是约数，那么只要n%k==1就可以啦.所以n=k*x+1.所以(n-1)%x==k.
	vector<ll>a=solve(n-1);
	for(int i=0;i<a.size();i++){
		if(n%a[i]==1)ans++;
	}
	//下面就是是约数的情况
	vector<ll>b=solve(n);
	for(int i=0;i<b.size();i++){
		ll temp=n;
		while(temp%b[i]==0)temp=temp/b[i];
		if(temp%b[i]==1)ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i < n; i++)
#define repd(i, n) for (int i = n-1; i > -1; i--)
#define repran(i, a,b) for (int i = a; i<b;i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> P;

int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    set<int> p[26];
    rep(i, n){
        int v = s[i]-'a';
        p[v].insert(i);
    }
    int q;
    cin >> q;
    rep(i, q){
        int t;
        cin >> t;
        if (t == 1){
            int j;char c;
            cin >> j >> c;
            j--;
            p[s[j]-'a'].erase(j);
            p[c-'a'].insert(j);
            s[j] = c;
        }else{
            int l, r;
            cin >> l >> r;
            l--;r--;
            int ans = 0;
            rep(j, 26){
                auto it = p[j].lower_bound(l);
                if (*it <= r && it != p[j].end()) ans++;
            }
            cout << ans << endl;
        }
    }
    return 0;

}

Measured memory_bytes: 27252
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

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

  long long k;
  cin >> k;

  long long n = k / 50;
  long long m = k % 50;

  vector<long long> ans(50, n);
  for (int i = 0; i < 50; i++) {
    ans[i] += i;
  }
  for (int i = 0; i < m; i++) {
    ans[i] += 51;
    for (int i = 0; i < 50; i++) {
      ans[i] -= 1;
    }
  }

  cout << 50 << endl;
  for (int i = 0; i < 50; i++) {
    cout << ans[i];
    if (i != 49) cout << " ";
  }
  cout << endl;
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<ll,ll> pint;

int a[100001];
vector<int> v;
int main(){
    int n;
    cin>>n;
    rep(i,n) cin>>a[i];
    int cnt=1;
    rep(i,n-1){
        if(a[i]==a[i+1]) v.pb(cnt),cnt=1;
        else ++cnt;
    }
    v.pb(cnt);
    if(v.size()==1) cout<<v[0]<<endl;
    else if(v.size()==2) cout<<v[0]+v[1]<<endl;
    else{
        int mx=v[0]+v[1]+v[2];
        int cur=mx;
        FOR(i,0,v.size()-3){
            cur+=v[i+3]-v[i];
            mx=max(mx,cur);
        }
        cout<<mx<<endl;
    }
    return 0;
}


Measured memory_bytes: 3652
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC132
{
    class C
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            List<int> d = Console.ReadLine().Split(' ').Select(o => int.Parse(o)).ToList();
            d.Sort();

            int lowMax = d[N / 2 - 1];
            int highMin = d[N / 2];
            int r = highMin - lowMax;
            Console.WriteLine(r);
        }

    }
}


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

using namespace std;

constexpr int mod = 1000000007;

int vals[100005];
long long wynik = 1;

int main(void)
{

  ios_base::sync_with_stdio(0);

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

  int n;
  cin >> n;

  vals[0] = 3;

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

    int a;
    cin >> a;

    wynik = wynik * ( vals[a] - vals[a+1] ) % mod;
    vals[a+1]++;

  }

  cout << wynik;

  return(0);

}


Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Collections;

static class Extensions
{
    public static int ToInt(this string s) => int.Parse(s);
    public static long ToLong(this string s) => long.Parse(s);
    public static char ToChar(this string s) => char.Parse(s);
    public static double ToDouble(this string s) => double.Parse(s);
    public static int[] ToIntArray(this string s) => s.Replace(',', ' ').Split(' ').Select(x => x.ToInt()).ToArray();
    public static long[] ToLongArray(this string s) => s.Replace(',', ' ').Split(' ').Select(x => x.ToLong()).ToArray();
    public static double[] ToDoubleArray(this string s) => s.Replace(',', ' ').Split(' ').Select(x => x.ToDouble()).ToArray();
    public static Queue<T> ToQueue<T>(this IEnumerable<T> seq) => new Queue<T>(seq);
    public static Stack<T> ToStack<T>(this IEnumerable<T> seq) => new Stack<T>(seq);
    public static HashSet<T> ToHashSet<T>(this IEnumerable<T> seq) => new HashSet<T>(seq);
}
static class MyMath
{
    //static private long gcdInner(long a, long b) => (a % b == 0) ? b : gcdInner(b, a % b);
    static public long GCD(long a, long b) => (a < b) ? GCD(b, a) : ((b == 0) ? a : GCD(b, a % b));
    
    static public long LCM(long a, long b) => (a > b) ? (a / GCD(a, b) * b) : (b / GCD(a, b) * a);
    static private readonly long _m = 1000000000 + 7;
    static public long Mod(long val) => (val % _m + _m) % _m;
    static private long extGCD(long a, long b, ref long x, ref long y) => (b == 0) ? (a + (x = 1) * 0 + (y = 0) * 0) : (extGCD(b, a % b, ref y, ref x) + (y -= a / b * x) * 0);
    static public long ModInverse(long a, long dummy1 = 0, long dummy2 = 0) => extGCD(a, _m, ref dummy1, ref dummy2) * 0 + Mod(dummy1);    
}

class Program
{
    static string[] ReadLines(int n) => Enumerable.Range(0, n).Select(s => Console.ReadLine()).ToArray();

    static void Main()
    {
        int N = int.Parse(Console.ReadLine());
        int[] AList = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();

        int[] GCD_Ruiseki_L = new int[N];
        int[] GCD_Ruiseki_R = new int[N];

        //Lには、i番目よりも左側にある数のGCDをiに入れる。
        //Rには、i番目よりも右側にある数のGCDをiに入れる。

        for (int i = 1; i < N; i++)
        {
            GCD_Ruiseki_L[i] = (int)MyMath.GCD(GCD_Ruiseki_L[i - 1], AList[i - 1]);
            GCD_Ruiseki_R[N - 1 - i] = (int)MyMath.GCD(GCD_Ruiseki_R[N - 1 - i + 1], AList[N - 1 - i + 1]);
        }

        Console.WriteLine(Enumerable.Range(0, N).Max(n => MyMath.GCD(GCD_Ruiseki_R[n], GCD_Ruiseki_L[n])));
    }
}

Measured memory_bytes: 26972
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		for(int a = 1;a>0;a++){
			int n =scan.nextInt();
			int x = scan.nextInt();
			int H = 0;
			if(n == 0 && x == 0){
				break;
			}
			int k[] = new int[n];
			for(int b = 0;b<n;b++){
				k[b] = b+1;
			}
			for(int c = 0;c<n-2;c++){
				for(int d = 1;d+c<n;d++){
					for(int e = 1;e+d+c<n;e++){
						if(k[c] + k[d+c] + k[e+d+c] == x){
							H++;
						}
					}
				}
			}
			System.out.println(H);
		}
	}

}

Measured memory_bytes: 19952
#include <stdio.h>
#define count 10

int main(void) {
    int i, j, k, n, num, length;
    scanf("%d",&n);
    for(i = 1; i <= n; i++ ) {
        scanf("%d",&num);
        printf("Case %d:\n",i);
        for(j = 0; j < count; j++ ) {
            num *= num;
            num /= 100;
            num %= 10000;
            printf("%d\n",num);
        }
    }
    return 0;
}

Measured memory_bytes: 592
// Sky's the limit :)
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    int t = 1; 
    // cin >> t; 
    while (t--) {
        int n;
        cin >> n;
        int a[n], b[n];
        for(int i = 0; i < n; i++)
            cin >> a[i] >> b[i];

        sort(a, a + n);
        sort(b, b + n);

        int ma, mb;
        if(n % 2) {
            ma = a[n / 2];
            mb = b[n / 2];
        }
        else {
            ma = a[n / 2] + a[(n - 1) / 2];
            mb = b[n / 2] + b[(n - 1) / 2];
        }

        cout << mb - ma + 1 << '\n';
    }
    
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
    return 0;
}



Measured memory_bytes: 6916
#include <map>
#include <set>
#include <ctime>
#include <queue>
#include <stack>
#include <cmath>
#include <vector>
#include <bitset>
#include <cstdio>
#include <cctype>
#include <string>
#include <numeric>
#include <cstring>
#include <cassert>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std ;
#define int long long
#define rep(i, a, b) for (ll i = (a); i <= (b); ++i)
#define per(i, a, b) for (ll i = (a); i >= (b); --i)
#define loop(it, v) for (auto it = v.begin(); it != v.end(); it++)
#define cont(i, x) for (ll i = head[x]; i; i = edge[i].nex)
#define clr(a) memset(a, 0, sizeof(a))
#define ass(a, cnt) memset(a, cnt, sizeof(a))
#define cop(a, b) memcpy(a, b, sizeof(a))
#define lowbit(x) (x & -x)
#define all(x) x.begin(), x.end()
#define SC(t, x) static_cast <t> (x)
#define ub upper_bound
#define lb lower_bound
#define pqueue priority_queue
#define mp make_pair
#define pb push_back
#define pof pop_front
#define pob pop_back
#define fi first
#define se second
#define y1 y1_
#define Pi acos(-1.0)
#define iv inline void
#define enter putchar('\n')
#define siz(x) ((ll)x.size())
#define file(x) freopen(x".in", "r", stdin),freopen(x".out", "w", stdout)
typedef double db ;
typedef long long ll ;
typedef unsigned long long ull ;
typedef pair <ll, ll> pii ;
typedef vector <ll> vi ;
typedef vector <pii> vii ;
typedef queue <ll> qi ;
typedef queue <pii> qii ;
typedef set <ll> si ;
typedef map <ll, ll> mii ;
typedef map <string, ll> msi ;
const ll maxn = 2e6 + 100 ;
const ll inf = 0x3f3f3f3f ;
const ll iinf = 1 << 30 ;
const ll linf = 2e18 ;
const ll mod = 998244353 ;
const double eps = 1e-7 ;
template <class T = ll> T chmin(T &a, T b) { return a = min(a, b);}
template <class T = ll> T chmax(T &a, T b) { return a = max(a, b);}
template <class T = ll> T read()
{
	T f = 1, a = 0;
	char ch = getchar() ;
	while (!isdigit(ch)) { if (ch == '-') f = -1 ; ch = getchar() ; }
	while (isdigit(ch)) { a =  (a << 3) + (a << 1) + ch - '0' ; ch = getchar() ; }
	return a * f ;
}

ll n, flag;

char s[maxn], t[maxn];

ll ans;

qi q;

signed main()
{
	n = read();
	scanf("%s %s", s + 1, t + 1);
	rep(i, 1, n) flag |= s[i] != t[i];
	if(!flag) return puts("0"), 0;
	ll pos1 = n, pos2 = n;
	while(pos1)
	{
		while(pos1 > 1 && t[pos1 - 1] == t[pos1]) -- pos1;
		while(pos2 >= 1 && (pos2 > pos1 || s[pos2] != t[pos1])) -- pos2;
		// printf("%lld %lld\n", pos1, pos2);
		if(!pos2) return puts("-1"), 0;
		while(!q.empty() && q.front() - siz(q) >= pos1) q.pop();
		if(pos1 != pos2) q.push(pos2);
		chmax(ans, siz(q));
		-- pos1;
	}
	printf("%lld\n", ans + 1);
	return 0;
}

Measured memory_bytes: 10384
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    // 入力
    try (Scanner sc = new Scanner(System.in);) {
      String line = sc.nextLine();
      String tmp = line;
      int zero = 0;
      int one = 0;
      for (int i = 0; i < tmp.length(); i++) {
        if(tmp.charAt(i) == '0') {
          zero++;
        }
        if(tmp.charAt(i) == '1') {
          one++;
        }
      }
      System.out.println(2 * Math.min(zero, one));
    }
  }
}

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

int main()
{
  int n,ac,wa,tle,re;
  cin>>n;
  ac=wa=tle=re=0;
  vector<string> result(n);
  for(int i=0;i<n;i++)
  {
    cin>>result.at(i);
  }
  for(int i=0;i<n;i++)
  {
    if(result.at(i)=="AC")
      ac++;
    else if(result.at(i)=="WA")
      wa++;
    else if(result.at(i)=="TLE")
      tle++;
    else
      re++;
  }
  cout<<"AC x "<<ac<<endl;
  cout<<"WA x "<<wa<<endl;
  cout<<"TLE x "<<tle<<endl;
  cout<<"RE x "<<re<<endl;
}


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

int main(){
    int a,b;
    int i,j,k;
    int ans=0;
    while(1){
        cin>>a>>b;
        if(a==0&&b==0){
            break;            
        }
        for(i=1;i<=a;i++){
            for(j=1;j<=a&&j!=i;j++){
                for(k=1;k<=a&&k!=i&&k!=j;k++){
                    if(i+j+k==b){
                        ans++;
                    }
                }
            }
        }
        cout<<ans<<endl;
        ans=0;
    }
}


Measured memory_bytes: 3092