akhauriyash/Code-Regression huggingface dataset:
#include "vector"
#include "set"
#include "map"
#include "unordered_map"
#include "string"
#include "iostream"
#include "algorithm"
#include "queue"

using namespace std;

#define ll long long
#define INF 2e9
#define MOD 998244353

typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;


template<typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    bool first = true;
    for (const auto& j: v) {
        if (!first) {
            os << " ";
        }
        first = false;
        os <<j;
    }
    return os;
}

template<typename T>
istream& operator>>(istream& is, vector<T>& v) {
    for (auto& elem : v) {
        is >> elem;
    }
    return is;
}

vector<vi> g;
vi p;
vi h;
void dfs(int x, int prev) {
    p[x] = prev;
    h[x] = (prev == -1) ? 0 : h[prev] + 1;

    for (int y : g[x]) {
        if (y != prev) {
            dfs(y, x);
        }
    }
}

struct v {
    int a;
    int b;
    int c;
};

bool comp(const v& x, const v& y) {
    return x.c < y.c;
}

void solve() {
    int n;
    cin >> n;
    vll a(n);
    cin >> a;

    vll bef0(n+1, 0);
    vll bef1(n+1, 0);
    vll aft0(n+1, 0);
    vll aft1(n+1, 0);

    bef0[0] = a[0];
    for (int i=1; i<n; i++) {
        bef0[i] = bef0[i-1];
        bef1[i] = bef1[i-1];
        if (i % 2) {
            bef1[i] += a[i];
        } else {
            bef0[i] += a[i];
        }
    }
    for (int i=n-1; i>=0; i--) {
        aft0[i] = aft0[i+1];
        aft1[i] = aft1[i+1];
        if (i % 2) {
            aft1[i] += a[i];
        } else {
            aft0[i] += a[i];
        }
    }


    if (n % 2 == 0) {
        ll ma = max(aft0[0], aft1[0]);
        for (int i = 1; i < n-2; i++) {
            if (i % 2 ==  1) {
                ma = max(ma, bef0[i-1] + aft1[i+2]);
            }
        }
        cout << ma;
        return;
    }


    ll ma = max(aft0[2], aft1[1]);
    for (int i = 1; i < n-1; i++) {
        if (i % 2 == 0) {
            ma = max(ma, bef0[i-1] + aft0[i+2]);
            ma = max(ma, bef1[i-1] + aft0[i+2]);
        } else {
            ma = max(ma, bef0[i-1] + aft1[i+2]);
            ma = max(ma, bef0[i-1] + aft0[i+2]);
        }
    }

    for (int i = 1; i < n-2; i++) {
        if (i % 2 == 1) {
            ma = max(ma, bef0[i-1] + aft0[i+3]);
        }
    }

    ll cur0 = a[0];
    ll cur1 = a[0];
    for (int i = 3; i < n-1; i++) {
        if (i % 2 == 0) {
            ma = max(ma, cur0 + aft0[i+2]);
            cur0 = cur1;
        } else {
            cur0 += a[i];
            cur1 = max(cur1 + a[i], bef0[i-1]);
        }

        //cout << i << ' ' << cur0 << ' ' << cur1 << ' ' << ma << endl;
    }

    cout << ma;
}

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

    if (0) {
        int tests;
        cin >> tests;
        while (tests--) {
            solve();
            cout << "\n";
        }
    } else {
        solve();
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 11120
#include<iostream>
#include<cstring>
#include<algorithm>

using namespace std;

#define rep(i, n) for(int i = 0; i < int(n); ++i)

int wa[100][100];
int pe[100];
int ac[100];
int team[100];

int main() {
  int t, p, r;
  for (;;) {
    cin >> t >> p >> r;
    if (t == 0 && p == 0 && r == 0) break;
    memset(wa, 0, sizeof(wa));
    memset(pe, 0, sizeof(pe));
    memset(ac, 0, sizeof(ac));
    int tid, pid, time;
    string message;
    rep (i, r) {
      cin >> tid >> pid >> time >> message;
      --tid; --pid;
      if (message == "WRONG") ++wa[tid][pid]; 
      else {
	++ac[tid];
	pe[tid] += time + wa[tid][pid] * 1200;
      }
    }
    rep (i, t) team[i] = i;
    rep (i, t) for (int j = i + 1; j < t; ++j) {
      if (ac[team[i]] < ac[team[j]] || (ac[team[i]] == ac[team[j]] && pe[team[i]] > pe[team[j]]) || (ac[team[i]] == ac[team[j]] && pe[team[i]] == pe[team[j]] && team[i] > team[j])) swap(team[i], team[j]);
    }
    rep (i, t) cout << team[i]+1 << " " << ac[team[i]] << " " << pe[team[i]] << endl;
  }
}

Measured memory_bytes: 964
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        String[] firstLine = input.readLine().split(" ");
        int W = Integer.parseInt(firstLine[0]);
        int H = Integer.parseInt(firstLine[1]);
        int N = Integer.parseInt(firstLine[2]);

        int region = W * H;
        int top = H;
        int bottom = 0;
        int right = W;
        int left = 0;

        for (int i = 0; i < N; i++) {
            String[] line = input.readLine().split(" ");
            int x = Integer.parseInt(line[0]);
            int y = Integer.parseInt(line[1]);
            int a = Integer.parseInt(line[2]);


            if (a == 1) {
                left = Math.max(left, x);
            } else if (a == 2) {
                right = Math.min(right, x);
            } else if (a == 3) {
                bottom = Math.max(bottom, y);
            } else {
                top = Math.min(top, y);
            }
        }

        int area;

        if (right <= left) {
            area = 0;
        } else if (top <= bottom) {
            area = 0;
        } else {
            int height = (top) - (bottom);
            area = (right - left) * height;
        }

//        System.out.println("Left:" + left + " Right:" + right + " Top:" + top + " Bottom:" + bottom);
        System.out.println(area);


    }
}


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

using namespace std;

int n;

int main()
{
  cin >> n;

  unordered_map<int64_t, int> accum;
  accum[0] = 1;

  int64_t sum = 0;
  int64_t count = 0;
  int a;
  for (int i = 0; i < n; i++) {
    cin >> a;
    sum += a;
    count += accum[sum];
    accum[sum]++;
  }

  cout << count << endl;

  return 0;
}


Measured memory_bytes: 8520
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,d;
  cin>>n>>d;
  int arr[n+1][d+1];
  for(int i=0;i<n;i++)
      {
    for(int j=0;j<d;j++){
    cin>>arr[i][j];
    }
  }
  int ans=0;
  for(int i=0;i<n;i++)
      {
    for(int j=i+1;j<n;j++){
       double f=0.0;
   for(int k=0;k<d;k++){

     f=f+((arr[i][k]-arr[j][k])*(arr[i][k]-arr[j][k]));
    }
      double g=(double)sqrt(f);
    //  cout<<g<<endl;
      if(ceil(g)==g){
      ans++;
      }
    }
  }
cout<<ans<<endl;
}


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

int main() {
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	int n;
	cin>>n;
	string s;
	int ac=0,tle=0,wa=0,re=0;
	for(int i=0;i<n;i++){
		cin>>s;
		if(s == "AC")ac++;
		if(s == "TLE")tle++;
		if(s == "WA")wa++;
		if(s == "RE")re++;
	}
	cout<<"AC x "<<ac<<endl;
	cout<<"WA x "<<wa<<endl;
	cout<<"TLE x "<<tle<<endl;
	cout<<"RE x "<<re<<endl;
	return 0;
}

Measured memory_bytes: 3620
#include <iostream>

using namespace std;

int main(){
	int faces[1+6];

	for(int i = 1; i <= 6; i++){
		cin >> faces[i];
	}

	int f, tmp;
	char direction;
	while(cin >> direction){
		switch(direction){
		case 'N':
			f = 5;
			break;
		case 'E':
			f = 3;
			break;
		case 'S':
			f = 2;
			break;
		case 'W':
			f = 4;
			break;
		}

		tmp = faces[f];
		faces[f] = faces[1];
		faces[1] = faces[7-f];
		faces[7-f] = faces[6];
		faces[6] = tmp;
	}

	cout << faces[1] << endl;

	return 0;
}

Measured memory_bytes: 3080
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using E = System.Linq.Enumerable;
 
class Program
 {
  
        static long[] a;
        static long N;
        static long K;
        
        static void Main(string[] args)
        {
          //入力を受け取る
          int N = int.Parse(Console.ReadLine());
          int[] A = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
          int[] B = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
          
          var destroyed = 0L;
          
          for(int i = 0; i < N ; i++ ){
            //最小値を求める
            var x = Math.Min(A[i],B[i]);
            A[i] -= x;
            B[i] -= x;
            destroyed += x;
            
            var y = Math.Min(A[i+1],B[i]);
            A[i+1] -= y;
            B[i] -= y;
            destroyed += y;
          }
          
          //Console.WriteLine(String.Join(" ",A));
          Console.WriteLine(destroyed);
          
        }
 }

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

#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define mem(x,val) memset((x),(val),sizeof(x))
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define PI acos(-1.0) 
#define N 111111

const int INF = 1 << 30 ;
typedef long long ll ;
typedef pair < int , int > pii ;

ll a[N] ;
ll total[2] , cnt[2]  ;

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

  for(int i =1 ;i<=n ;i++)scanf("%lld", &a[i]) ;

  for(int i = 0 ;i<2 ;i++){
    for(int j = 1 ;j<=n ;j++){
      total[i] += a[j] ;
      if((i+j)% 2 == 0){
        if(total[i]>=0){
          cnt[i] += total[i]+1;
          total[i] = -1 ;
        }
      }
      else {
        if(total[i]<=0){
          cnt[i]+=(1-total[i]);
          total[i] = 1 ;
        }
      }
    }
  }
  cout << min(cnt[0], cnt[1]) << endl ;
  return 0 ;
}
 


Measured memory_bytes: 1024
f = readlines
N = f[0].to_i
ary = f[1].split(" ").map(&:to_i)

i = 0
ans = 0

while i < N
  if ary[i] != (i + 1)
    ans += 1
  end
  i += 1
end

if ans == 0 ||ans ==2
  puts "YES"
else
  puts "NO"
end


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using Int = int64_t;
using UInt = uint64_t;
using C = std::complex<double>;
#define rep(i, n) for(Int i = 0; i < (Int)(n); ++i)
#define guard(x) if( not (x) ) continue;
#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif

int main() {
   Int n, a;
   std::cin >> n >> a;
   Int t = n - n / 500 * 500;
   puts(t<=a?"Yes":"No");
}


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

class Point{
public:
    long double x;
	long double y;
	Point(long double x=0,long double y=0) :x(x),y(y){ }
	Point operator +(Point &p) {
		return Point(x + p.x, y + p.y);
	}
	Point operator-(Point &p) {
		return Point(x - p.x, y - p.y);
	}
	Point operator *(long double a) {
		return Point(x*a, y*a);
	}
};

typedef struct {
	Point p1, p2;
}Line;

int main() {

    
	Line s;
	cin >> s.p1.x; cin >> s.p1.y; cin >> s.p2.x; cin >> s.p2.y;
	int q;
	cin >> q;
	for (int i = 0;i < q;i++) {
		Point p,q,r;
		cin >> p.x; cin >> p.y;
		 double prod = ((s.p2.x - s.p1.x)*(p.x - s.p1.x)) + ((s.p2.y - s.p1.y)*(p.y - s.p1.y));
		q.x = s.p1.x +(s.p2.x - s.p1.x)*(prod/((s.p1.x-s.p2.x)*(s.p1.x - s.p2.x)+ (s.p1.y - s.p2.y)*(s.p1.y - s.p2.y)));
		q.y = s.p1.y + (s.p2.y - s.p1.y)*(prod / ((s.p1.x - s.p2.x)*(s.p1.x - s.p2.x) + (s.p1.y - s.p2.y)*(s.p1.y - s.p2.y)));
		r.x = p.x + (q.x - p.x) * 2; r.y = p.y + (q.y - p.y) * 2;
		cout << fixed << setprecision(10)<< r.x << " " << r.y << endl;
	}

}

Measured memory_bytes: 3260
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define all(v) v.begin(),v.end()
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
template<class T> void chmin(T &a,const T &b){if(a>b) a=b;}
template<class T> void chmax(T &a,const T &b){if(a<b) a=b;}

class DisjointSet{
public:
  vector<int> rank,p;
  vector<int> sz;
 
  DisjointSet(){}
  DisjointSet(int size){
    rank.resize(size,0);
    p.resize(size,0);
    sz.resize(size,0);
    for(int i=0;i<size;i++) makeSet(i);
  }
 
  void makeSet(int x){
    p[x]=x;
    rank[x]=0;
    sz[x]=1;
  }
 
  bool same(int x,int y){
    return findSet(x)==findSet(y);
  }
 
  void unite(int x,int y){
    if(same(x,y)) return;
    link(findSet(x),findSet(y));
  }
 
  void link(int x,int y){
    if(rank[x]>rank[y]){
      p[y]=x;
      sz[x]+=sz[y];
    }else{
      p[x]=y;
      sz[y]+=sz[x];
      if(rank[x]==rank[y]){
        rank[y]++;
      }
    }
  }
 
  int findSet(int x){
    if(x!=p[x]){
      p[x]=findSet(p[x]);
    }
    return p[x];
  }
 
  int findSize(int x){
    return sz[findSet(x)];
  }
};

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

  int N,M;
  cin>>N>>M;
  vector<int> A(M),B(M);
  rep(i,M) cin>>A[i]>>B[i];

  DisjointSet us(N);
  rep(i,M){
    A[i]--;B[i]--;
    if(us.same(A[i],B[i])==false) us.unite(A[i],B[i]);
  }

  int sz=1;
  rep(i,N) chmax(sz,us.findSize(i));
  cout<<sz<<endl;

  return 0;
}


Measured memory_bytes: 7156
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <numeric>
using namespace std;
using ll = long long;
const ll mod =  998244353;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REP_FROM(i, j, n) for (int i = (j); i < (n); ++i)
#define all(x) (x).begin(),(x).end()

ll power(ll base, ll exponent, ll module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ ll root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
ll inverse(ll x){ return power(x, mod - 2, mod);}
struct combination{ vector<ll> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } ll C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };

combination table(300);

ll sum_a;
ll lower_invalid;

ll dp[301][300*301];
ll dp2[301][300*301];

signed main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<ll> a(n);
  REP(i, n) cin >> a[i];
  REP(i, n) sum_a += a[i];
    // cout << sum_a << endl;
  lower_invalid = sum_a / 2 + (sum_a % 2 ==0? 0:1);
  ll db[301], tr[301];
  tr[0] = 1;
  db[0] = 1;
  REP(i, 300) {
    tr[i+1] = tr[i] * 3 % mod;
    db[i+1] = db[i] * 2 % mod;
  }
  ll ans = 0;
  dp[0][0] = 1;
  ll even = 0;
  // cout << lower_invalid << endl;
  REP(i, n) {
    REP(j, lower_invalid) {
      dp[i+1][j] += dp[i][j] * 2;
      dp[i+1][j] %= mod;
      dp[i+1][j+a[i]] += dp[i][j];
      dp[i+1][j+a[i]] %= mod;
      // if((j + a[i]) * 2 == sum_a) {
      //   ll tmp = ((tr[n-i-1] - 1) * dp[i][j]) % mod;
      //   ans += tmp;
      //   ans %= mod;
      // } else
       if(j + a[i] >= lower_invalid) {
        ll tmp = tr[n-i-1] * dp[i][j] % mod;
        // cout << tmp << " " << i << j << endl;
        ans += tmp;
        ans %= mod;
      }
    }
    // dp[i+1][lower_invalid] += dp[i][lower_invalid] * 2;
  }
  // if(sum_a % 2 == 0) even = dp[n][lower_invalid];
  if(sum_a % 2 == 0) {
    dp2[0][0] = 1;
    REP(i, n) {
      REP(j, sum_a / 2+1) {
        dp2[i+1][j] += dp2[i][j];
        dp2[i+1][j] %= mod;
        dp2[i+1][j+a[i]] += dp2[i][j];
        dp2[i+1][j+a[i]] %= mod;
      }
    }
    even = dp2[n][sum_a/2] * 3 % mod;
  }
  ans = tr[n] - (ans * 3) % mod + even;
  if(ans < 0) {
    ans += mod;
  }
  ans %= mod;

  cout << ans << endl;
  // REP(i, n+1) {
  //   REP(j, lower_invalid+10) {
  //     cout << dp[i][j] << " ";
  //   }
  //   cout << endl;
  // }
  // cout << "=====" << endl;
  // REP(i, n+1) {
  //   REP(j, lower_invalid+10) {
  //     cout << dp2[i][j] << " ";
  //   }
  //   cout << endl;
  // }
  return 0;
}


Measured memory_bytes: 423296
def gcd(a,b):
  if a<b:
    return gcd(b,a)
  elif a%b==0:
    return b
  else:
    return gcd(b,a%b)
N=int(input())
A=list(map(int,input().split()))
ans=A[0]
for a in A:
  ans=gcd(ans,a)
print(ans)

Measured memory_bytes: 62704
import Data.List

solve :: String -> String -> String
solve s p = if isInfixOf p s || check (slen - 1) then "Yes" else "No"
    where
        slen = length s
        plen = length p
        check l
            | l <= 0    = False
            | otherwise = if (take l p) == (drop (slen - l) s) && (drop l p) == (take (plen - l) s) then True else check (l - 1)

main :: IO ()
main = do
    s <- getLine
    p <- getLine
    putStrLn $ solve s p

Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long int ans=1,n,k;
	cin>>n>>k;
	for(int i=1;i<=n;i++){
		if(ans<k){
			ans+=ans;
		}
		else{
			ans+=k;
		}
	}
	cout<<ans;
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000000;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

///////////////////////////

int main() {
	ll N;
	cin >> N;
	ll ans = 0;
	repn(i, N) {
		ll a;
		cin >> a;
		ans += a - 1;
	}
	
	cout << ans;
	system("PAUSE");
}

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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;

const ll mod = 1e9+7;
const int maxn = 2e5;



ll fac[maxn], ifac[maxn], inv[maxn];

ll nck(ll n, ll k) {
    if (n<k) return 0;
    assert(n>=0);
    assert(k>=0);
    return fac[n]*ifac[k]%mod*ifac[n-k]%mod;
}

void gen_inv() {
    fac[0]=inv[0]=ifac[0]=1;
    fac[1]=inv[1]=ifac[1]=1;

    for (int i=2; i<maxn; i++) {
	fac[i]=fac[i-1]*i%mod;
	inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
	ifac[i]=ifac[i-1]*inv[i]%mod;
    }

    assert(nck(4,2)==6);
}

int n, m, k;
int r[maxn], c[maxn];


ll dp[maxn];//# paths that reach ith obstacle w/o hitting previous obstacles

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

    gen_inv();

    cin>>n>>m>>k;
    vector<pair<int,int>> sq;
    for (int i=0; i<k; i++) {
	int x, y; cin>>x>>y;
	sq.emplace_back(x,y);
    }

    sort(sq.begin(), sq.end());
    for (int i=0; i<k; i++) {
	r[i] = sq[i].first;
	c[i] = sq[i].second;
    }


    for (int i=0; i<k; i++) {
	int R = r[i];
	int C = c[i];
	ll &res = dp[i] = nck(R-1+C-1,R-1);

	for (int j=0; j<i; j++) {
	    int dr = R - r[j];
	    int dc = C - c[j];
	    if (dr<0 || dc<0) continue;
	    res += (mod - nck(dr+dc, dc)*dp[j]%mod);
	    res %= mod;
	}	
    }



    ll res = nck(n-1+m-1, n-1);

    for (int i=0; i<k; i++) {
	ll cur = dp[i]*nck(n-r[i]+m-c[i], n-r[i])%mod;
	res += (mod-cur);
	res %= mod;
    }


    res %= mod;
    res += mod;
    res %= mod;
    cout<<res<<endl;
    
    return 0;
}


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

using namespace std;

int main(int argc, const char *argv[]) {
  int n, k;
  cin >> n >> k;
  vector<int> vh(n);
  for (int i = 0; i < n; ++i) {
    cin >> vh[i];
  }

  sort(vh.begin(), vh.end());
  int ans = vh[k - 1] - vh[0];
  for (int i = 0; i < vh.size() - k + 1; ++i) {
    ans = min(ans, vh[i + k - 1] - vh[i]);
  }

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

Measured memory_bytes: 3780
import java.util.*;

public class Main {
    //Changing a Character
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        String s = sc.next();
        System.out.println(sln(k, s));
    }

    public static String sln(int k, String s) {
        String res = s.substring(0, k - 1) + (s.charAt(k - 1) + "").toLowerCase() + s.substring(k);
        return res;
    }
}

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

using namespace std;
typedef long long ll;
ll a[3];
int main() {

  for(int i = 0; i < 3; i++) cin >> a[i];

  ll M = 1e18;
  for(int i = 0; i < 3; i++) {
    if(a[i] % 2 == 0) {cout <<"0"<<endl; return 0;}
    ll tmp2 = a[i]/2+1;
    ll tmp = a[i]/2;
    M = min(M,tmp2*a[(i+1)%3]*a[(i+2)%3]-tmp*a[(i+1)%3]*a[(i+2)%3]);
  }
  cout << M <<endl;
}


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

int main()
{
  
  string s  ; 
  
  cin>>s ; 
  
  int max_1  = INT_MIN;
  
  int count =0 ; 
  for(int i=0 ; i<s.size() ; i++ )
  {
    if(s[i] == 'R')
      count++ ; 
    else 
    {
      count =0 ; 
    }
    max_1 = max(max_1 , count) ;     
  }
  
  cout<<max_1 ; 
  
}


Measured memory_bytes: 3576
#include<bits/stdc++.h>
using namespace std;
signed main(){
  int n,d,sum,ans=0;
  double num;
  int x[100][100];
  cin>>n>>d;
  for(int i=0;i<n;i++){
    for(int j=0;j<d;j++) cin>>x[i][j];
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      sum=0,num=0;
      if(i!=j){
        for(int k=0;k<d;k++){
          sum+=((x[i][k]-x[j][k])*(x[i][k]-x[j][k]));
        }
        num=sum;
        sum=sqrt(sum);
        if(sum==sqrt(num)) ans++;
      }
    }
  }
  cout<<ans/2<<"\n";
}

Measured memory_bytes: 256
import java.util.*
import java.io.PrintWriter

val pw = PrintWriter(System.out)

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val a = Integer.parseInt(readLine())

    val inputStringList = arrayListOf<String>()
    repeat(a) {
        inputStringList.add(readLine()!!)
    }

    pw.println(problem137_c(a, inputStringList))
    pw.flush()
}

fun problem137_c(a: Int, inputStringList: ArrayList<String>): Long {

    val sortedList = inputStringList.map {
        it.toCharArray().sortedArray().joinToString("")
    }.sortedBy { it }

    var result: Long = 0L

    val tmpList = mutableMapOf<String,Int>()
    for (str in sortedList) {

        var tmpCount = tmpList[str]

        if (tmpCount == null) {
            tmpList[str] = 0
        } else {
            tmpCount++
            result += tmpCount
            tmpList[str] = tmpCount
        }
    }

    return result
}



Measured memory_bytes: 68696
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] o = sc.next().toCharArray();
		char[] e = sc.next().toCharArray();
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < o.length; i++) {
			sb.append(o[i]);
			if (i != o.length - 1 || o.length == e.length) {
				sb.append(e[i]);
			}
		}
		System.out.println(sb);
	}
}


Measured memory_bytes: 21716
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<tuple>
#include<bitset>
#include<iomanip>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int N;
	scan(N);
	int flag=0;
	rep(i,50){
		rep(j,50){
			if(i*4+j*7==N) flag=1;
		}
	}
	if(flag) prin("Yes");
	else prin("No");
	return 0;
}


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

int main(){
    int a, b, c, x;
    cin >> a >> b >> c;

    if(a > b) x = a, a = b, b = x; 
    if(b > c) x = b, b = c, c = x; 
    if(a > b) x = a, a = b, b = x; 


    cout << a <<" ";
    cout << b <<" ";
    cout << c << endl;

    return 0;
  
}


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

int main(){
	ll n; cin >> n;
	vl a(n); rep(i,n)cin >> a[i];
	map<ll,ll> mp;
	rep(i,n)mp[a[i]]++;
	ll sum = 0;
	for(auto p : mp){
		sum += p.second * (p.second-1) / 2;
	}
	rep(i,n){
		cout << sum - mp[a[i]] + 1 << endl;
	}
}

Measured memory_bytes: 12160
package main

import (
	"fmt"
	"io"
	"os"
)

func calcA(a int) int {
	amin := (a * 25) >> 1
	if a%2 == 1 {
		amin++
	}
	return amin
}

func calcB(b int) int {
	return b * 10
}

func run(input io.Reader, output io.Writer) int {
	var a, b int
	fmt.Scanf("%d %d\n", &a, &b)

	amin := calcA(a)
	amax := calcA(a+1) - 1
	bmin := calcB(b)
	bmax := calcB(b+1) - 1
	if bmin <= amin && amin <= bmax {
		fmt.Println(amin)
		return 0
	}

	if amin <= bmin && bmin <= amax {
		fmt.Println(bmin)
		return 0
	}

	fmt.Println(-1)

	return 0
}

func main() {
	os.Exit(run(os.Stdin, os.Stdout))
}


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

int main()
{
  int W, H;
  std::cin >> H >> W;
  std::vector<char> m(W * H);
  for (int i = 0; i < H; ++i)
  {
    for (int j = 0; j < W; ++j)
    {
      char c;
      std::cin >> c;
      m[i * W + j] = c;
    }
    std::cin.ignore();
  }
  
  std::vector<int> v(m.size()), h(m.size());
  
  for (int i = 0; i < W; ++i)
  {
    for (int j = 0; j < H; ++j)
    {
      int x = j;
      while (j < H && m[i + W * j] == '.')
      {
        ++j;
      }
      for (int k = x; k < j; ++k)
      {
        v[i + W * k] = j - x;
      }
    }
  }
  
  for (int i = 0; i < H; ++i)
  {
    for (int j = 0; j < W; ++j)
    {
      int x = j;
      while (m[j + W * i] == '.' && j < W)
      {
        ++j;
      }
      for (int k = x; k < j; ++k)
      {
        h[k + W * i] = j - x;
      }
    }
  }
  for (int i = 0; i < m.size(); ++i)
  {
    h[i] = h[i] + v[i] - 1;
  }
  h.erase(std::remove(h.begin(), h.end(), -1), h.end());
  std::cout << *std::max_element(h.begin(), h.end()) << std::endl;
}

Measured memory_bytes: 35456
#include <cstdio>
#include <cmath>

using namespace std;

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

	scanf("%d", &a);
	scanf("%d", &b);
	scanf("%d", &c);
	scanf("%d", &d);
	
	if(abs(b-a) <= d && abs(c-b) <= d) printf("Yes\n");
	else if(abs(c-a) <= d) printf("Yes\n");
	else printf("No\n");

	return 0;
	
}

Measured memory_bytes: 128
#include <stdio.h>
int main(){
    int n,m,l;
    int a[128][128],b[128][128];
    long int c[128][128]={0};
    scanf("%d %d %d",&n,&m,&l);
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            scanf("%d",&a[i][j]);
        }
    }
    for(int i=0;i<m;i++){
        for(int j=0;j<l;j++){
            scanf("%d",&b[i][j]);
        }
    }
    for(int i=0;i<n;i++){
      for(int j=0;j<l;j++){
        for(int k=0;k<m;k++){
          c[i][j]+=a[i][k]*b[k][j];
        }
      }
    }
    for(int i=0;i<n;i++){
      for(int j=0;j<l;j++){
        printf("%ld",c[i][j]);
        if(j!=l-1)printf(" ");
      }
      printf("\n");
    }

    return 0;
}



Measured memory_bytes: 2016
import java.util.Scanner;

public class Main{
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n;
		int a[][] = new int[9][9];
		int b[][] = new int[9][9];
		String str;

		n = sc.nextInt();
		str = "";
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < 9; j++) {
				for (int k = 0; k < 9; k++) {
					a[j][k] = sc.nextInt();
					b[j][k] = 0;
				}
			}

			for (int j = 0; j < 9; j++) {
				for (int k = 0; k < 9; k++) {
					for (int l = 0; l < 9; l++) {
						if (l != k && a[j][k] == a[j][l]) {
							b[j][k] = 1;
						}
						if (l != j && a[j][k] == a[l][k]) {
							b[j][k] = 1;
						}
					}
					for (int l = (j / 3) * 3; l < (j / 3) * 3 + 3; l++) {
						for (int m = (k / 3) * 3; m < (k / 3) * 3 + 3; m++) {
							if ((j != l || k != m) && a[j][k] == a[l][m]) {
								b[j][k] = 1;
							}
						}
					}
				}
			}

			String s = "";
			System.out.print(str);
			for (int j = 0; j < 9; j++) {
				for (int k = 0; k < 9; k++) {
					if (b[j][k] == 0) {
						s = " ";
					} else {
						s = "*";
					}
					System.out.print(s + a[j][k]);
				}
				System.out.println();
			}
			str = "\n";
		}
	}
}

Measured memory_bytes: 13000
#include <algorithm>
#include <iostream>
#include <math.h>
#include <string>
using namespace std;
int main() {
  int m; cin>>m;
  int n=m;
  int a=n/100000000; n=n%100000000;
  int b=n/10000000; n=n%10000000;
  int c=n/1000000; n=n%1000000;
  int d=n/100000; n=n%100000;
  int e=n/10000; n=n%10000;
  int f=n/1000; n=n%1000;
  int g=n/100; n=n%100;
  int h=n/10; n=n%10;
  if(m%(a+b+c+d+e+f+g+h+n)==0) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

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

int main(){
	string s;
	string p;
	char c;

	getline(cin, s);
	s += s;
	
	cin >> p;

	if(s.find(p)!=-1){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
#include <cstdio>
#include <cstdlib>

#ifdef _MSC_VER
#include <Windows.h>
#else
#include <unistd.h>
#endif

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

const LL mod=1000000007;
LL T[100004],A[100004],h[100004];
int main(){
    int N;
    cin>>N;
    CLR(h);
    set<LL>st;
    LL maxi=0;
    REP(i,N){
        cin>>T[i];
        maxi=max(T[i],maxi);
        if(st.find(T[i])==st.end()){
            h[i]=T[i];
            st.insert(T[i]);
        }
    }
    REP(i,N)cin>>A[i];
    st.clear();
    for(long i=N-1;i>=0;i--){
        if(st.find(A[i])==st.end()){
            if(h[i]==0||h[i]==A[i]){
                h[i]=A[i];
            }else{
                cout<<0<<endl;
                return 0;
            }
            st.insert(A[i]);
        }
    }
    bool f=0;
    REP(i,N){
        if(T[i]==A[i]&&T[i]==maxi)f=1;
    }
    if(!f){
        cout<<0<<endl;return 0;
    }
    LL res=1LL;
    REP(i,N){
        if(h[i]==0){
            res=(res*min(A[i],T[i]))%mod;
        }
    }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair < ll, ll > PLL;
#define rep(i,n) for (int i = 0; i < (n); ++i)
ll MOD = 1e9+7;
int main() {
    int n;
    cin >> n;
    vector<int> a(n+1);
    vector<int> b(n+1, 0);
    rep(i, n) cin >> a[i+1];
    int cnt = 0;
    for ( int i = n; i >= 1; --i ) {
        int sum = 0;
        for ( int j = i + i; j <= n; j+= i) {
            sum ^= b[j];
        }
        b[i] = sum^a[i];
    }
//        cout << i << " " << tmp_sum << endl;
//        if (  (tmp_sum & 1) && a[i-1] == 0 ) b[i-1] = 1, ++cnt;
//        if ( !(tmp_sum & 1) && a[i-1] == 0 ) b[i-1] = 0;
//        if (  (tmp_sum & 1) && a[i-1] == 1 ) b[i-1] = 0;
//        if ( !(tmp_sum & 1) && a[i-1] == 1 ) b[i-1] = 1, ++cnt;
//    }
//    cout << cnt << endl;
    vector<int> ans;
    for ( int i = 1; i <= n; i++ ) {
        if ( b[i] ) ans.push_back(i);
    }
    cout << ans.size() << endl;
    rep(i, ans.size()) printf("%d ", ans[i]);
    printf("\n");
    return 0;
}


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) { a = b; return 1; }
  return 0; }
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) { a = b; return 1; }
  return 0; }
ll MOD = 1000000007;

int main(void){
  ll x,k,d; cin >> x >> k >> d;
  x = abs(x);
  ll dig = x/d;
  if(dig > k){
    cout << x - k*d << endl;
  }
  else if(dig % 2 == 0){
    if(k % 2 == 0){
      cout << x%d << endl;
    }
    else cout << abs(x%d-d) << endl;
  }
  else{
    if(k % 2 == 0){
      cout << abs(x%d-d) << endl;
    }
    else cout << x%d << endl;
  }
  return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <utility>
#include <string>
#include <map>
#include <algorithm>
#include <stdio.h>
#include <set>
#include <cmath>
#include <queue>

typedef long long ll;

using namespace std;


int main(){
    int n;
    cin >> n;
    set<string> st;
    map<string, int>  mp;
    int max = 1;
    for(int i = 0; i < n; i++){
        string s;
        cin >> s;
        if(st.find(s) != st.end()){
            mp[s] = mp[s] + 1;
            if(max < mp[s]){
                max = mp[s];
            }
        } else {
            st.insert(s);
            mp.insert(make_pair(s, 1));
        }
    }
    vector<string> ans;

    for (auto itr = st.begin(); itr != st.end(); ++itr) {
        if(mp[*itr] == max) ans.push_back(*itr);
    }

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

    for(int i = 0; i < ans.size(); i++){
        cout << ans[i] << endl;
    }
}


Measured memory_bytes: 36212
import Control.Monad (replicateM)

reachable :: [(Int,Int,Int)] -> Bool
reachable ps = and $ zipWith reach ps (tail ps)

reach :: (Int, Int, Int) -> (Int, Int, Int) -> Bool
reach (t0,x0,y0) (t1,x1,y1) = accessible && sameParity
  where
    tick = t1 - t0
    shortest = abs (x1 - x0) + abs (y1 - y0)
    accessible = shortest <= tick
    sameParity = even (tick - shortest)

readTriple :: IO (Int, Int, Int)
readTriple = do
  [t,x,y] <- map read . words <$> getLine
  return (t,x,y)

main :: IO ()
main = do
  n <- readLn
  ps <- replicateM n readTriple
  putStrLn $ if reachable ((0,0,0):ps) then "Yes" else "No"


Measured memory_bytes: 74748
#define _CRT_SECURE_NO_WARNINGS

/* include ***********************/
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

/* define *************************/
//for
#define REP(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define REPS(i,n) for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define RREPS(i,n) for(int i=(int)(n);i>0;i--)
#define FOR(i,s,n) for(int i=(int)(s),i##_len=(int)(n);i<i##_len;i++)
#define RFOR(i,s,n) for(int i=(int)(s)-1,i##_len=(int)(n);i>=i##_len;i--)

//printf
#define PRINTD(d) printf("%d\n",(d))
#define PRINTL(d) printf("%lld\n",(d))

//memset
#define m0(s) memset(s,0,sizeof(s))
#define ml(s) memset(s,63,sizeof(s))
#define fill(s,c) memset(s,c,sizeof(s))

#define INF 1e9
#define MOD 1000000007

typedef long long ll;
typedef unsigned long long ull;

int a[100000], b[100000];
int c[100000],in[100000];

int diff[4][2] = {
	{ 0, -1 },
	{ -1, 0 },
	{ 1, 0 },
	{ 0, 1 },
};

int Min(int a, int b) {
	return (a)<(b) ? (a) : (b);
}
int Max(int  a, int  b) {
	return (a) > (b) ? (a) : (b);
}
void Swap(int *a, int *b) {
	int tmp = *a;
	*a = *b;
	*b = tmp;
}
void hSwap(int x[], int i, int j)
{
	int temp;

	temp = x[i];
	x[i] = x[j];
	x[j] = temp;
}void ShowData(int x[], int left, int right)
{
	int i;
	for (i = left; i <= right; i++)printf("%d  ", x[i]);
	printf("\n");
}
void QSort(int x[], int y[],int left, int right, int n) {
	int i, j;	//左端,右端
	int pivot;	//軸

	i = left;
	j = right;
	pivot = x[(left + right) / 2];

	while (1) {
		if (n > 0) {				//n>0なら昇順、n<=0なら降順
			while ((x[i] < pivot) && (i <= right))i++;	//軸値より大きい要素
			while ((pivot < x[j]) && (i <= right))j--;	//軸値より小さい要素
		}
		else {
			while ((x[i] > pivot) && (i <= right))i++;	//軸値より小さい要素
			while ((pivot > x[j]) && (i <= right))j--;	//軸値より大きい要素
		}
		if (i >= j)	break;
		hSwap(x, i, j);
		hSwap(y, i, j);
		i++; j--;
	}
	//ShowData(x, left, right);

	if (left < i - 1)QSort(x, y,left, i - 1, n);
	if (j + 1 <  right)QSort(x, y,j + 1, right, n);
}

int main() {
	int t,x;
	scanf("%d%d", &t, &x);
	double ans = (double)t / x;
	printf("%f\n", ans);
}

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

int main() {
    int n = 0;
    cin >> n;
    vector<int> prob(n);
    
    for(int i = 0; i < n; i++) {
        cin >> prob.at(i);
    }
    sort(prob.begin(),prob.end());
    
    cout << prob.at(n/2) - prob.at(n/2 - 1) << endl;
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        double w = Double.parseDouble(sc.next());
        double h = Double.parseDouble(sc.next());
        int x = Integer.parseInt(sc.next());
        int y = Integer.parseInt(sc.next());
        
        double s = w*h/2;
        System.out.print(s);
        
        if((x*2 == w) && (y*2 == h)){
            System.out.println(" 1");
        }else{
            System.out.println(" 0");
        }
    }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<P, int> P3;
const ll MOD = ll(1e9)+7;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(1e5 + 5);
const double EPS = 1e-11;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define ALL(v) (v).begin(), (v).end()


int main() {
    int n, m, a[2005], ans = 0;
    cin >> n >> m;
    REP(i,n){
        cin >> a[i];
        a[i+n] = a[i];
    }
    for(int i=0;i!=n;i+=m){
        i %= n;
        int mi=IINF, ma=0;
        for(int j=0;j<m;j++){
            mi = min(mi, a[i+j]);
            ma = max(ma, a[i+j]);
        }
        ans += ma-mi;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3108
#include<iostream>

using namespace std;

int main()
{
    string s;
    cin >> s;
    int l = s.size();
    for(int i = 0; i < l; i++)
    {
        if(s[i] == '7') {cout << "Yes\n"; return 0;}
    }
    cout << "No\n";

    return 0;
}


Measured memory_bytes: 3628
import java.util.*;

class Main{

    int[] par, rank;
    int INF = Integer.MAX_VALUE;

    void init(int n){
        for(int i=0; i<n; i++){
            par[i] = i;
            rank[i] = 0;
        }
    }

    int find(int x){
        if(par[x]==x) return x;
        else return par[x] = find(par[x]);
    }

    void unite(int x, int y){
        x = find(x); y = find(y);
        if(x==y) return;
        if(rank[x] < rank[y]) par[x] = y;
        else{
            par[y] = x;
            if(rank[x]==rank[y]) rank[x]++;
        }
    }

    boolean same(int x, int y){
        return find(x) == find(y);
    }

    class Edge{
        int u, v, cost;
        Edge(int u, int v, int cost){
            this.u = u;
            this.v = v;
            this.cost = cost;
        }
    }

    void solve(){
        Scanner sc = new Scanner(System.in);
        while(true){
            int n = sc.nextInt(), m = sc.nextInt();
            if(n==0 && m==0) break;

            par = new int[n];
            rank = new int[n];
            Edge[] e = new Edge[m];
            for(int i=0; i<m; i++){
                int a = sc.nextInt()-1, b = sc.nextInt()-1;
                int w = sc.nextInt();
                e[i] = new Edge(a, b, w);
            }

            Arrays.sort(e, new Comparator<Edge>(){
                    public int compare(Edge e1, Edge e2){
                        return e1.cost - e2.cost;
                    }
                });

            int min = INF;
            for(int start=0; start<=m-n+1; start++){
                int ma = 0, mi = INF;
                init(n);
                int cnt = 0;
                for(int i=start; i<m; i++){
                    Edge ee = e[i];
                    if(!same(e[i].u, e[i].v)){
                        unite(e[i].u, e[i].v);
                        ma = Math.max(ma, e[i].cost);
                        mi = Math.min(mi, e[i].cost);
                        cnt++;
                    }
                }
                if(cnt!=n-1) continue;
                min = Math.min(min, ma-mi);
            }
            if(min==INF) min = -1;
            System.out.println(min);
        }
    }

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

Measured memory_bytes: 77760
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
        int A=scanner.nextInt();
        int B=scanner.nextInt();

        int noOfPortsOpen = 1,noOfSockets=0;
        while (noOfPortsOpen<B){
            noOfSockets++;
            noOfPortsOpen = A*noOfSockets - (noOfSockets-1);
        }

        System.out.println(noOfSockets);
    }
}

Measured memory_bytes: 21844
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int n,m,l;
    int i,j,r;
    int a[100][100],b[100][100];
    long sum=0;
    scanf("%d %d %d",&n,&m,&l);
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            scanf("%d",&a[i][j]);
        }
    }
    for(i=0;i<m;i++){
        for(j=0;j<l;j++){
            scanf("%d",&b[i][j]);
        }
    }
    for(i=0;i<n;i++){
       for(r=0;r<l;r++){
           sum=0;
            for(j=0;j<m;j++){
            sum = sum+a[i][j]*b[j][r];
                        }
           printf("%ld",sum);
           if(r+1!=l){
               printf(" ");
           }
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 680
package main

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

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)

	M := nextInt()

	fmt.Println(48 - M)
}

Measured memory_bytes: 640
#define _[2<<17]
n,i;A _,B _,T _,F _;long M,D _,P _,R _;
s(u,i,p){i?s(u,T[i],p),B[i]-p?s(B[i],F[B[i]],u),D[u]=D[u]*-~D[B[i]]%M:0,R[i]=R[T[i]]*(B[i]-p?-~D[B[i]]:1)%M:(D[u]=1);}
S(u,x,p,i,I){for(i=F[u];I=B[i];I-p?S(I,R[i]*x%M+1,u),x=x*-~D[I]%M:0)i=T[i];P[u]=x%M;}
//s(u,p,i,I){D[u]=1;for(i=F[u];I=B[i];i=T[i])I-p?s(I,u),D[u]=D[u]*-~D[I]%M:0;}
//S(u,x,p,i,I){for(m(i=F[u],p);I=B[i];I-p?S(I,R[i]*x%M+1,u,0,0),x=x*-~D[I]%M:0)i=T[i];P[u]=x%M;}
//m(i,p){i&&m(T[i],p);R[i]=R[T[i]]*(B[i]-p?printf("p: %d\n",p),-~D[B[i]]:1)%M;}
main(u,v){for(;~scanf("%d%d",&u,&v);)i++?A[i-1]=B[i]=u,B[i-1]=A[i]=v,i++:(n=u,M=v);for(;--i;F[A[i]]=i)T[i]=F[A[i]];
	s(*R=1,F[1]);
	//s(*R=1,0,0,0,0);
	for(S(1,1);i++<n;)printf("%d ",P[i]);
}

Measured memory_bytes: 14592
#include <iostream>
#include <iomanip>
#include <fstream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <cmath>

using namespace std;
typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(0);
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    if (a > c)
        swap (a, c);
    if (b > c)
        swap (b, c);

    for (int i = 0; i < k; i++)
        c *= 2;
    cout << a + b + c << "\n";
    return 0;
}

Measured memory_bytes: 256
n = gets.to_i
a,b,c = (0..2).map{gets.split.map(&:to_i)}
s = b.inject(:+)

before_num = -1
a.each do |num|
  if num == before_num + 1
    s = s + c[num - 2]
  end
  before_num = num
end

p s

Measured memory_bytes: 1788
#include<stdio.h>
int main(void)
{
	int x,y,z,cnt;
	while(scanf("%d %d",&x,&y)!=EOF) {
		cnt=1;
		z=x+y;
		while(!(z<10)) {
			z=z/10;
			cnt+=1;
		}
		printf("%d\n",cnt);
	}
	return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a, count = 0;
	cin >> a;
	int arr[a];
	for(int i=0; i<a; i++)
		cin >> arr[i];
	for(int i=1; i<a-1; i++)
		if((arr[i] > arr[i-1] && arr[i] < arr[i+1]) || (arr[i] < arr[i-1] && arr[i] > arr[i+1])) count++;
	printf("%d\n",count);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair

using namespace std;

int main()
{
   FAST/**/
   
   ll n,k;
   cin>>n>>k;
   
   pair<ll,ll> arr[n];
   ll dist = 0;
   unordered_map<ll,ll> ma;
   for(ll i=0;i<n;i++)
   {
       cin>>arr[i].second>>arr[i].first;
       arr[i].second--;
       ma[arr[i].second] = 1;
   }
   
   dist = ma.size();
   
   sort(arr,arr+n,greater<pair<ll,ll>>());        
   
   ll mcost[n];
   memset(mcost,-1,sizeof(mcost));
   
   for(ll i=0;i<n;i++)
        mcost[arr[i].second] = max(arr[i].first,mcost[arr[i].second]);
   
   unordered_map<ll,ll> mark;
   ll ans = 0;
   for(ll i=0;i<k;i++)
        ans+=arr[i].first, mark[arr[i].second]++;  
   
   ll ans1 = ans;
   
   ans+=mark.size()*mark.size();
   //cout<<"ans = "<<ans<<"\n";
   ll cnt = mark.size();
   
   multiset<pair<ll,ll>> st;
   set<pair<ll,ll>, greater<pair<ll,ll>>> res;
   for(ll i=0;i<k;i++)
   {
        st.insert(mp(arr[i].first,arr[i].second));
   }
   
   for(ll i=0;i<n;i++)
   {
       if(mark[i] == 0 && mcost[i]>-1)
            res.insert(mp(mcost[i],i));
   }
   
   while(cnt<min(k,dist))
   {
       while(st.size() > 0 && mark[st.begin()->second] < 2)
            st.erase(st.begin());
        auto it = st.begin();
        mark[it->second]--;
        ans1-=it->first;
        
        st.erase(st.begin());
        mark[res.begin()->second] = 1;
        ans1+=res.begin()->first;
        //st.insert(*res.begin());
        res.erase(res.begin());
        cnt++;
        
        ans = max(ans,ans1+cnt*cnt);
   }
   
   cout<<ans;
   
               
        
   return 0;
}

Measured memory_bytes: 17060