akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include<stack>
#include <queue>
#include<map>
#include <set>
using namespace std;
#define int long long
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793
#define INF 1000000007
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2)*pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int jo(int n) {
	int ans = 1;
	rep(i, n) {
		ans *= 2;
	}
	return ans;
}

signed main() {
	int n;
	string s;
	cin >>s>>n;
	rep(i, s.size()) {
		if (n<0) { cout << s << endl; ggr; }
		else if (123 - s[i] <= n&&s[i]!='a') {
			n -= 123 - s[i];
			s[i] = 'a';
		}
	}
	s[s.size()- 1] += n%26;
	cout << s << endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
const int MAX=1e6+9;
int par[MAX], low[MAX], vis[MAX], dis[MAX];
vector<int>adj[MAX];
int cnt=0,n ,m;
vector<pair<int, int> >ans;
void dfs(int vertex ,int p ){
	low[vertex]=dis[vertex]=cnt++;
	vis[vertex]=1;
	par[vertex]=p;
	for(int i=0;i<adj[vertex].size();i++){
		if(!vis[adj[vertex][i]]){
			par[adj[vertex][i]]=vertex;
			dfs(adj[vertex][i], vertex);
			low[vertex]=min(low[vertex], low[adj[vertex][i]]);
		}
		else if(p!=adj[vertex][i])
			low[vertex]=min(low[vertex] , dis[adj[vertex][i]]);
	}

}
void bridges(){
	par[0]=-1;
	dfs(0, -1);
	for(int i=0;i<n;i++){
		if(dis[par[i]]<low[i]){
			ans.push_back(make_pair(min(i ,par[i]), max(i, par[i])));
		}
	}
	sort(ans.begin(), ans.end());
	for(int i=0;i<ans.size();i++){
		cout<<ans[i].first<<" "<<ans[i].second<<endl;
	}
}
int main(){
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int x,y;
		cin>>x>>y;
		adj[x].push_back(y);
		adj[y].push_back(x);
	}
	bridges();

}


Measured memory_bytes: 27868
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <map>
#include <functional>
#include <set>
#include <iterator>

using namespace std;
typedef long long ll;
int N;
int t[100010];
int x[100010];
int y[100010];

int main() {
   string S;
   cin >> S;
   ll ans = 0;
   for (int bit=0; bit <( 1 << (S.size() - 1)); bit++) {
      // bit-DP
      int before_bit = 0;
      for (int i=0; i<=S.size() - 1;i++) {
         if (i == S.size() - 1 || bit & (1 << i)) {
            for (int j=before_bit;j <= i;j++) {
               ans += (S[j] - '0')*pow(10, i-j);
            }
            before_bit = i+1;
         }
      }
   }
   cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#include <chrono>
#include <random>
#include <time.h>
#include <fstream>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define all(c) begin(c),end(c)
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}

#define INF 1e9+7
#define LLINF 1e18+7
#define N 250000
ll MOD=998244353;

main(){
    int a=in(),b=in();
    if(abs(a-b)%2){
        cout<<"IMPOSSIBLE";
    }
    else{
        cout<<(a+b)/2;
    }
}



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

using namespace std;

typedef long long int llint;

string S;

llint sum[2019];

llint mod_pow(llint x, llint n) {
	llint res = 1;
	while (n > 0) {
		if (n & 1) { res = res * x; }
		x = x * x;
		n >>= 1;
	}
	return res;
}

llint func(llint n) {
	//if (n <= 1) { return 0; }
	llint res = 1;
	//while (n > 0) {
	//	res *= n;
	//	n--;
	//}
	return n * (n - 1) / 2;
}

int main() {
	cin >> S;
	//cout << 10095 % 2019 << endl;
	int N = (int)S.size();
	vector<llint> a(N);

	a[N - 1] = S[N - 1] - '0';
	sum[a[N - 1]]++;
	//cout << a[N - 1] << endl;
	llint ans = 0;
	llint now = 10;
	for (int i = 1; i < N; i++) {
		llint v = now;
		a[N - 1 - i] = ((S[N - 1 - i] - '0') * v + a[N - i]) % 2019;
		now = (now * 10) % 2019;
		sum[a[N - 1 - i]]++;
		//cout << a[N - 1 - i] << endl;
	}

	for (int i = 0; i < 2019; i++) {
		//if(sum[i] != 0)
		//cout << "sum[" << i << "=" << sum[i] << endl;
		ans += func(sum[i]);
	}

	cout << ans + sum[0] << endl;
}


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

int main(){
	int n,ans=0;
	bool bisa=true;
	cin>>n;
	int arr[n+4];
	for(int i=1;i<=n;i++){
		cin>>arr[i];
	}
	for(int i=1;i<=n;i++){
		bisa=true;
		for(int j=i;j>=1;j--){
			if(arr[i]<arr[j]){
				bisa=false;
			}	
		}
		if(bisa==true){
			ans++;
		
		
	}
}
cout<<ans<<endl;
}

Measured memory_bytes: 256
function main(input) {
  const a = input.split('\n')[1].split(' ').map(Number);

  if(a.some(x => x == 0)){
    console.log('0');
    return;
  }

  let c = 1;
  for(let i=0; i< a.length; i++){
    if(( BigInt(a[i]) * BigInt(c) ) > 1000000000000000000) {
      console.log('-1');
      return;
    }
    c = BigInt(a[i]) * BigInt(c);
  }

  console.log(c.toString());
}

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


Measured memory_bytes: 45972
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int main() 
{
	int X;
	cin >> X;
	int ans = 0;
	ans += (X / 500) * 1000;
	X %= 500;
	ans += (X / 5) * 5;
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#define INF 10000000000000000
#define MOD 1000000007
using namespace std;

int sum(int x){
    int s=0;
    while(x>0){
        s+=x%10;
        x/=10;
    }
    return s;
}

int main(){
    int N;
    cin >> N;
    
    int ans=N;
    for(int A=1; A<N; A++){
        int B=N-A;
        
        ans=min(ans,sum(A)+sum(B));
    }
    
    cout<<ans<<endl;
    return 0;
}




Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<vector>
#include<deque>
#include<map>
#include<set>

using namespace std;

#define ll long long

int N;
ll C;
vector<ll> x;
vector<ll> v;
ll maxc = 0, c = 0;
vector<ll> cr, cl;
ll maxcr=0, maxcl=0;

int input(){
  cin >> N >> C;
  x.resize(N+2);
  v.resize(N+2);
  cr.resize(N+2);
  cl.resize(N+2);
  x[0]=0;v[0]=0;cr[0]=0;cl[0]=0;
  x[N+1]=0;v[N+1]=0;cr[N+1]=0;cl[N+1]=0;
  for( int i = 1; i <= N; i++ ){
    cin >> x[i] >> v[i];
  }
  return 0;
}

int run(){
  c = 0;
  for( int i = 1; i <= N; i++ ){
    c += v[i];
    cr[i] = c-x[i];
    if( c-x[i] > maxcr ){ maxcr = c-x[i]; }
    cr[i] = maxcr;
  }
  c = 0;
  for( int i = N; i >= 1; i-- ){
    c += v[i];
    cl[i] = c-(C-x[i]);
    if( c-(C-x[i]) > maxcl ){ maxcl = c-(C-x[i]); }
    cl[i] = maxcl;
  }
  maxc = (maxcr>maxcl ? maxcr : maxcl);
  c = 0;
  for( int i = 1; i <= N; i++ ){
    // cout << "i:" << i << endl;
    c = cr[i]+cl[i+1]-x[i];
    // cout << c << endl;
    if( c > maxc ){ maxc = c; }
    c = cl[i]+cr[i-1]-(C-x[i]);
    if( c > maxc ){ maxc = c; }
    // cout << c << endl;
  }
  cout << maxc << endl;
  return 0;
}

int main(){
  input();
  run();
  return 0;
}

Measured memory_bytes: 3328
#include<stdio.h>

int main(void)
{
    long int n,a[200001],i,sum = 0;
    scanf("%ld",&n);
    for(i = 1 ; i <= n ; i++)
    {
        scanf("%ld",&a[i]);
    }
    for(i = 1 ; i <= n-1 ;i++)
    {
        if(a[i] > a[i + 1])
        {
            sum += a[i] - a[i + 1] ;
            
            a[i + 1] = a[i];
        }
    }
    printf("%ld\n",sum);
    return 0;
}

Measured memory_bytes: 3296
import java.io.IOException;
import java.util.Scanner;

public class Main {

public static void main(String[] args) throws IOException {
		Scanner scan = new Scanner(System.in);
		String s = scan.next();
  		String t = scan.next();
  	int cnt = 0;
  		for(int i=0; i<s.length(); i++){
          if(s.charAt(i) != t.charAt(i)){
            cnt++;
          }
          
        }
  
		System.out.println(cnt);
}
}


Measured memory_bytes: 41260
#include <iostream>
#include <algorithm>
#include <string>
#include <set>

#include <regex>
#include <locale>
#include <iomanip>

using namespace std;
using ll = long long;

#define OVERLOAD3(_1,_2,_3,name,...) name
#define REP(i,n) REPI(i,0,n)
#define REPI(i,a,b) for(int i=int(a),i##_Len=int(b);i<i##_Len;++i)
#define rep(...) OVERLOAD3(__VA_ARGS__,REPI,REP,)(__VA_ARGS__)
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())

int main () {
  string s, t, sr, tr;
  cin >> sr >> tr;
  s = sr; reverse(ALL(sr));
  t = tr; reverse(ALL(tr));
  cout << (s==tr && t==sr ? "YES" : "NO") << endl;
}

Measured memory_bytes: 3096
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<array>
#include<map>
#include<bitset>
#include<iomanip>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
//ios::sync_with_stdio(false);
//std::cin.tie(0);
//<< setprecision(20)
const int mod=1e9+7;
const llint big=1e15+100;
const long double pai=3.141592653589793238462643383279502884197;
const long double ena=2.71828182845904523536;
const long double eps=1e-7;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
template <class T> void soun(T& ar)
{sort(ar.begin(),ar.end());ar.erase(unique(ar.begin(),ar.end()),ar.end());}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){return a/gcd(a,b)*b;}
int main(void){
	int i,n,q;cin>>n>>q;
	llint gen=0,gu=0;
	vector<llint>a(2*n);for(auto &it:a){cin>>it;}
	vector<llint>b(2*n);for(auto &it:b){cin>>it;}
	multiset<int>aki;
	gen=a[0]+a[2*n-1];
	for(i=1;i<2*n-1;i++){
		gen+=max(a[i],b[i]);
		aki.ins(abs(a[i]-b[i]));
		if(a[i]>b[i]){gu++;}
	}
	while(q--){
		int p,x,y;cin>>p>>x>>y;p--;
		if(p==0||p==2*n-1){gen-=a[p];a[p]=x;b[p]=y;gen+=a[p];}
		else{
			if(a[p]>b[p]){gu++;}
			aki.erase(aki.lower_bound(abs(a[p]-b[p])));
			gen-=max(a[p],b[p]);
			a[p]=x;b[p]=y;
			if(a[p]>b[p]){gu++;}
			aki.ins(abs(a[p]-b[p]));
			gen+=max(a[p],b[p]);
		}
		if(gu%2==0){cout<<gen<<endl;}
		else{cout<<gen-(*aki.begin())<<endl;}
	}
	return 0;
}

Measured memory_bytes: 14208
#include<bits/stdc++.h>
#define fori(j,n) for(ll i=j;i<n;i++)
#define forb(n,j) for(ll i=n-1;i>=0;i--)
#define endl "\n"
#define pb push_back
#define ll long long
#define mp make_pair
#define ff first
#define ss second
#define vec vector<ll>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PI 3.141592653589793238
#define mod 1000000007
using namespace std;

void wldd()
{
	string s;
	cin >> s;
	if (s[s.size() - 1] == 's')
	{	s.pb('e');
		s.pb('s');
	}
	else
		s.pb('s');
	cout << s << endl;
}

int32_t main()
{
	IOS;
	// ll t;
	// cin >> t;
	// while (t--)
	wldd();
	return 0;
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
#define int long long
#define ll long long 
#define rep(i,a,b) for(signed i=a;i<(b);++i)
#define erep(i,a,b) for(signed i=a;i<=(b);++i)
#define per(i,a,b) for(signed i=(a);i>(b);--i)
#define eper(i,a,b) for(signed i=(a);i>=b;--i)
#define fore(i, x, a) for(auto &&x:a) 
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define pb push_back
#define mp make_pair
#define ALL(x) begin(x),end(x)
#define F first
#define S second
#define debug(x)  cout << #x << ": " << (x) << '\n';
const long long INF=1001001001001001001;
const int MOD=(int)1e9 + 7;
const double EPS=1e-9;
using namespace std;
using Pii = pair<int,int>;
using vii = vector<int>;
template<class T>using  PS_queue = priority_queue<T, vector<T>, greater<T> >;
template<class T>using vv = vector<T>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill( (T*)array, (T*)(array+N), val );}
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T>T gcd(T a, T b){ return b ? gcd(b, a % b) : a; }
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct edge { int from, to, cost; };
int dy[]={0, 1, -1, 0}; int dx[]={1, 0, 0, -1};
// cout << fixed;
// cout << setprecision(10) << val;

int s;
bool used[1010101];

int f(int s) {
  int res;
  if (s % 2 == 0) {
    res = s / 2;
  } else {
    res = s * 3 + 1;
  }
  return res;
}

signed main() {
 cin.tie(0);
 ios::sync_with_stdio(false);
  cin >> s;
  memset(used, false, sizeof(used));
  int cnt = 1;
  while (!used[s]) {
    used[s] = true;
    s = f(s);
    cnt++;
  }
  cout << cnt << endl;
  return 0;
}



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

using namespace std;

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

   vector<int> p(n);
   for(int i=0;i<n;++i) cin >> p[i];

   int answer = 0;
   for(int i=1;i<n-1;++i){
      if(p[i-1]< p[i] && p[i] < p[i+1]) answer++;
      else if(p[i-1] > p[i] && p[i] > p[i+1]) answer++;
   }

   cout << answer << endl;

   return 0;

}


Measured memory_bytes: 256
from collections import deque


H, W = map(int, input().split())
grid = [input() for _ in range(H)]

INF = 1000
path = [[INF] * W for _ in range(H)]

q = deque()
q.append((0, 0, 0))
path[0][0] = 0
while q:
    s, i, j = q.popleft()
    c = grid[i][j]
    for di, dj in [(1, 0), (0, 1)]:
        ni, nj = i + di, j + dj
        if 0 <= ni < H and 0 <= nj < W:
            nc = grid[ni][nj]
            ns = s + (c != nc)
            if path[ni][nj] > ns:
                path[ni][nj] = ns
                if c == nc:
                    q.appendleft((ns, ni, nj))
                else:
                    q.append((ns, ni, nj))

ans = path[-1][-1]
ans += (grid[0][0] == '#') + (grid[-1][-1] == '#')
print(ans // 2)


Measured memory_bytes: 3436
#include <bits/stdc++.h>
using namespace std;
//O(k)愚直,nは大きいがkがそうでもないときに思い出す
long long modpow(long long x,long long n,long long mod){
    long long res = 1;
    while(n>0){
        if(n&1)(res*=x)%=mod;
        (x*=x)%=mod;
        n>>=1;
    }
    return res;
}
long long modinv(long long x,long long mod){
    return modpow(x,mod-2,mod);
}
long long modcomb(long long n,long long r,long long mod){
    long long numerator=1;
    for(long long i=0;i<r;i++){
        (numerator*=(n-i))%= mod;
    }
    long long denominator=1;
    for (long long i=1;i<=r;i++){
        (denominator*=i) %= mod;
    }
    denominator=modinv(denominator,mod);
    return numerator*denominator%mod;
}
int main(){
long long n,m;
cin >> n >> m;
cout << modcomb(n,2,100000007)+modcomb(m,2,100000007);}


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

const int L = 102;
int n, m, dp[2][L];
char c;
bool a[2][L];

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n >> m;
	for(int i = 1; i <= n; ++i) {
		for(int j = 1; j <= m; ++j) {
			cin >> c;
			a[i & 1][j] = (c == '.');
			if(i > 1 && j > 1) {
				dp[i & 1][j] = min(dp[i & 1][j - 1] + (a[i & 1][j] != a[i & 1][j - 1] && a[i & 1][j] == 0), dp[i & 1 ^ 1][j] + (a[i & 1][j] != a[i & 1 ^ 1][j] && a[i & 1][j] == 0));
			} else if(i > 1) {
				dp[i & 1][j] = dp[i & 1 ^ 1][j] + (a[i & 1][j] != a[i & 1 ^ 1][j] && a[i & 1][j] == 0);
			} else if(j > 1) {
				dp[i & 1][j] = dp[i & 1][j - 1] + (a[i & 1][j] != a[i & 1][j - 1] && a[i & 1][j] == 0);
			} else {
				dp[i & 1][j] = (a[i & 1][j] == 0);
			}
		}
	}
	cout << dp[n & 1][m] << "\n";
	return 0;
}


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

int main() {
  string s;
  cin >> s;
  int a = s.at(0) - '0';
  int b = s.at(1) - '0';
  int c = s.at(2) - '0';
  int d = s.at(3) - '0';
  
  if (a+b+c+d==7) cout << a << "+" << b << "+" << c << "+" << d << "=7" << endl;
  else if (a+b+c-d==7) cout << a << "+" << b << "+" << c << "-" << d << "=7" << endl;
  else if (a+b-c+d==7) cout << a << "+" << b << "-" << c << "+" << d << "=7" << endl;
  else if (a-b+c+d==7) cout << a << "-" << b << "+" << c << "+" << d << "=7" << endl;
  else if (a-b-c+d==7) cout << a << "-" << b << "-" << c << "+" << d << "=7" << endl;
  else if (a+b-c-d==7) cout << a << "+" << b << "-" << c << "-" << d << "=7" << endl;
  else if (a-b+c-d==7) cout << a << "-" << b << "+" << c << "-" << d << "=7" << endl;
  else if (a-b-c-d==7) cout << a << "-" << b << "-" << c << "-" << d << "=7" << endl;
}

Measured memory_bytes: 256
// 2019/07/12
// AtCoder Beginner Contest 101 - A

import java.util.*;
public class Main {
     public static void main(String[] args){
         Scanner sc = new Scanner(System.in);
        // Input
        String s = sc.next();
        int ans = 0;
        for(int i=0; i<4; i++){
            if(s.charAt(i)=='+'){
                ans++;
            } else {
                ans--;
            }
        }
        // Output
        System.out.println(ans);
    }
}

Measured memory_bytes: 23124
#include<stdio.h>
int main(void){
	
	int a,b,c;
	int i;
	int m,n=0;
	
	scanf("%d %d %d",&a,&b,&c);
	
	m=b-a+1;
	
	for(i=0;i<m;i++){
		
		if(c%a==0)n++;
		
		a++;
		
	}
	
	printf("%d\n",n);
	
	return 0;
	
}


Measured memory_bytes: 2120
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int d = sc.nextInt();
        int[][] X = new int[n][d];
        for(int i = 0; i < n; i++){
            for(int j = 0; j < d; j++){
                X[i][j] = sc.nextInt();
            }
        }
        int[] dist = new int[n*(n-1)/2];
        int distsum = 0;
        int count = 0;
        int p = 0;
        for(int i = 0; i < n; i++){
            for(int j = i+1; j < n; j++){
                for(int k = 0; k < d; k++){
                    distsum = distsum + (X[i][k] - X[j][k]) * (X[i][k] - X[j][k]);
                }
                for(int l = 1; l <= distsum; l++){
                    if(distsum == l*l){
                        count++;
                    }
                }
                distsum = 0;
            }
        }
        System.out.print(count);
    }
}

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

using namespace std;
inline void prep ()
{
  cin.tie (0);
  cin.sync_with_stdio (0);
};
const double pi = acos(-1.);
//printf(%.12lf\n,mid);
// __builtin_popcount(int) count 1's in binary
// get decimal part of number
/*
double intpart;
double thiss = modf((double)(n*m)/(double)k, &intpart);
*/
// round = (int)(num+.5)
int mod = 20437;

long long mymod(long long num){
  if (num< 0 && !(num%mod == 0)){
    if (mod == 1){
      return 0;
    }
    return mod-abs(num)%mod;
  }else{
    return num%mod;
  }
}

/*string sentence = And I feel fine...;
    istringstream iss(sentence);
*/  


double eps = .00001;
int grid[1000][1000];

int main(){
    prep();
    int n, m, a, b;
    cin >> n >> m >> a >> b;
    if (a == 0 && b == 0){
        for (int i=0; i<n; i++){
            for (int j=0; j<m; j++){
                cout << 0;
            }
            cout << '\n';
        }
        return 0;
    }
    if (a > m/2 || b > n/2){
    
        cout << "-1";
        return 0;
    }
    int thing[m];
    for (int i=0; i<m; i++){
        if (i < a){
            thing[i] = 1;
        }else{
            thing[i] = 0;
        }
    }
    for (int i=0; i<b; i++){
        for (int j=0; j<m; j++){
            cout << thing[j];
        }
        cout << '\n';
    }
    for (int i=0; i<n-b; i++){
        for (int j=0; j<m; j++){
            cout << (1^thing[j]);
        }
        cout << '\n';
    }
    return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <algorithm>

using namespace std;
static const int MAX = 200000;

int main() {
	int R[MAX], n;

	cin >> n;
	for( int i = 0; i< n ; i++) cin >> R[i];

	int maxv = -2000000000;
	int minv = R[0];

	for (int i = 1; i < n; i ++) {
		maxv = max(maxv, R[i] - minv);
		minv = min(minv, R[i]);
	}

	cout << maxv << endl;

	return 0;
}

Measured memory_bytes: 3868
import java.util.*;

public class Main {
    private static final long INF = 1L<<60;
    private static long[] dp = new long[100010];
    public static void main(String[] args) throws Exception {
        Arrays.fill(dp,INF);
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        List<Integer> steps = new ArrayList<>();
        for(int i=0;i<N;i++){
            steps.add(Integer.parseInt(sc.next()));
        }
        dp[0] = 0;
        dp[1] = Math.abs(steps.get(0) - steps.get(1));
        for(int i=2;i<N;i++){
            dp[i] = Math.min(dp[i-1] + Math.abs(steps.get(i) - steps.get(i-1)) ,dp[i-2] + Math.abs(steps.get(i) - steps.get(i-2)));
        }
        System.out.println(dp[N-1]);
    }
}


Measured memory_bytes: 48180
import itertools

n = int(input())
p = [int(x)-1 for x in input().split()]
q = [int(x)-1 for x in input().split()]

L = list(itertools.permutations(range(n)))

P = L.index(tuple(p))
Q = L.index(tuple(q))
print(abs(P-Q))

Measured memory_bytes: 8052
s=input()
a=[]
for i in s:
    a.append(i)
if a[0]==a[1] and a[2]==a[3] and a[0]!=a[2]:
    print('Yes')
elif a[0]==a[2] and a[1]==a[3] and a[0]!=a[1]:
    print('Yes')
elif a[0]==a[3] and a[1]==a[2] and a[0]!=a[1]:
    print('Yes')
else:
    print('No')



Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <algorithm>
#include <math.h>
#include <fstream>
#include <vector>
using namespace std;

int main() {
   
               long long int n,x,i,a,k,j,c=0;  
               cin>>n>>x;
                for(i=0;i<n;i++)
                {
                        cin>>k>>j;
                        if(k*k+j*j<=x*x)
                                c++;
                }
              cout<<c<<endl;
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <set>
using namespace std;

const int N = 1000 * 1000 + 5;

int a[N];
int b[N];
//int outdeg[N];
int indeg[N];
//bool mark[N];
vector <int> vec;
vector <int> adj[N];
//vector <int> adjr[N];
set <int> s1;
set <int> s2;
set <int> s;
int ans[N];

/*void dfs(int v) {
	mark[v] = true;
	for (auto u : adj[v]) {
		if (!mark[u]) {
			dfs(u);
		}
	}
	vec.push_back(v);
}*/

int main() {
	int n, k;
	cin >> n >> k;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		b[a[i]] = i;
	}
//	if (n >= 5000) {
//		int x = 0;
//		n /= x;
//	}
	s1.insert(-N);
	s1.insert(N);
	s2.insert(-N);
	s2.insert(N);
/*	for (int i = 1; i <= n; i++) {
		set <int> :: iterator it = s.lower_bound(b[i]);
		int r = *it;
		it--;
		int l = *it;
		cout << "73 " << b[i] << " " << l << " " << r << endl;
		if (r - b[i] < k) {
			adj[b[i]].push_back(r);
		}
		if (b[i] - l < k) {
			adj[b[i]].push_back(l);
		}
		s.insert(b[i]);
	}*/
	for (int i = n; i; i--) {
		set <int> :: iterator it = s1.lower_bound(b[i]);
		while (*it - b[i] < k) {
		//	cout << "71 " << b[i] << " " << *it << endl;
			adj[*it].push_back(b[i]);
			s1.erase(it);
			it = s1.lower_bound(b[i]);
		}
		it = s2.lower_bound(b[i]);
		it--;
		while (b[i] - *it < k) {
		//	cout << "72 " << b[i] << " " << *it << endl;
			adj[*it].push_back(b[i]);
			s2.erase(it);
			it = s2.lower_bound(b[i]);
			it--;			
		}
		s1.insert(b[i]);
		s2.insert(b[i]);
	}
	while(s1.size()) {
		s1.erase(s1.begin());
	}
	while (s2.size()) {
		s2.erase(s2.begin());
	}
/*	for (int i = 1; i <= n; i++) {
		for (int j = i; j; j--) {
			if (b[j] > b[i] && b[j] - b[i] < k) {
				adj[b[i]].push_back(b[j]);
			//	break;
			}
		}
		for (int j = i; j; j--) {
			if (b[j] < b[i] && b[i] - b[j] < k) {
				adj[b[i]].push_back(b[j]);
			//	break;
			}
		}
	}*/
	for (int i = 1; i <= n; i++) {
	//	outdeg[i] = adj[i].size();
		for (auto u : adj[i]) {
		//	cout << "31 " << i << " " << u << endl;
		//	adjr[u].push_back(i);
			indeg[u]++;
		}
	}
	for (int i = 1; i <= n; i++) {
		if (indeg[i] == 0) {
			s.insert(-i);
		}
	}
	while (s.size()) {
		int v = -*s.begin();
		s.erase(s.begin());
	//	cout << "32 " << v << endl;
		for (auto u : adj[v]) {
			indeg[u]--;
			if (indeg[u] == 0) {
				s.insert(-u);
			}
		}
		vec.push_back(v);
	}
/*	for (int i = 1; i <= n; i++) {
		if (!mark[i]) {
			dfs(i);
		}
	}*/
	for (int i = n - 1; i >= 0; i--) {
	//	cout << vec[i] << endl;
		ans[vec[i]] = n - i;
	}
	for (int i = 1; i <= n; i++) {
		cout << ans[i] << endl;
	}
	return 0;
}



Measured memory_bytes: 89332
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep2(i, m, n) for(int i=int(m); i<int(n); i++)
#define rep(i, n) rep2(i, 0, n)
#define all(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
const int INF = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS = 1e-10;
const int MOD = int(1e9)+7;
template<typename T> inline bool chmin(T& a, T b) {if(a>b) {a=b; return true;} return false;}
template<typename T> inline bool chmax(T& a, T b) {if(a<b) {a=b; return true;} return false;}

// initialization
const int MAX = int(2e5)+10;
long long fac[MAX], finv[MAX], inv[MAX];
void binom_init() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// binom mod MOD
long long binom(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

map<ll, int> prime_factor(ll n) {
  map<ll, int> ret;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}


int main() {
  binom_init();

  ll n, m; cin >> n >> m;

  auto pf = prime_factor(m);

  ll ans = 1;
  for (auto e : pf) {
    ans *= binom(e.second+n-1, n-1);
    ans %= MOD;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4992
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <queue>
#pragma warning(disable : 4996)
#pragma warning(disable : 4996)

#define N_MAX 200000


struct Fox {
	int x;
	int h;
};
struct Bomb {
	int x;
	int n;
};

int min(int a, int b) {
	if (a < b) return a;
	return b;
}

Fox foxes[N_MAX];

class NearFox {
public:
	bool operator()(const Fox &l, const Fox &r) {
		return l.x < r.x;
	}
};

int main(void) {
	int N, D, A;
	scanf("%d %d %d", &N, &D, &A);
	for (int i = 0; i < N; ++i) {
		scanf("%d %d", &foxes[i].x, &foxes[i].h);
	}
	std::sort(foxes, foxes + N, NearFox());
	long long sum = 0;
	std::vector<Bomb> bombs;
	int bombIndex = 0;
	int damage = 0;
	for (int i = 0; i < N; ++i) {
		Fox fox = foxes[i];
		for(int j = bombIndex; j < bombs.size(); ++j) {
			if (bombs.empty()) break;
			Bomb bomb = bombs[j];
			if ((fox.x >= bomb.x - D) && (fox.x <= bomb.x + D)) {
				break;
			}
			else {
				++bombIndex;
				damage -= A * bomb.n;
			}
		}
		if (damage < fox.h) {
			Bomb bomb;
			bomb.n = (fox.h - damage - 1) / A + 1;
			bomb.x = fox.x + D;
			bombs.push_back(bomb);
			sum += bomb.n;
			damage += A * bomb.n;
		}
	}
	printf("%lld\n", sum);
	return 0;
}
 

Measured memory_bytes: 3956
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int n,m,k; cin>>n>>m>>k;
    vector<int> a(m);
    rep(i,m) cin>>a[i];
    int cnt=0;
    rep(i,m){
        if(k<a[i]) break;
        cnt++;
    }
    cout<<min(cnt,m-cnt);
}

Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String S = in.next();
		int ans = 0;
		for (int i = 0; i < S.length() / 2; i++) {
			if (S.charAt(i) != S.charAt(S.length() - (i + 1))) {
				ans++;
			}
		}
		System.out.println(ans);
		in.close();

	}
}

Measured memory_bytes: 23764
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>


using namespace std;

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

int main() {
	int n;

	cin >> n;
	vector<vector<pair<int,ll> > > vss(n);

	rep(i, n - 1) {
		int a,b,c;
		cin >> a >> b >> c;
		a--; b--;
		vss[a].push_back(make_pair(b, c));
		vss[b].push_back(make_pair(a, c));

	}

	vector<ll> d(n, -1);

	int q,k;
	cin >> q >> k;
	k--;

	d[k] = 0;

	queue<int> que;
	que.push(k);

	while(!que.empty()) {
		int v = que.front();
		que.pop();

		for(auto p : vss[v]) {
			int nv = p.first;
			ll nc = p.second;
			if (d[nv] != -1) {
				continue;
			} 
			d[nv] = nc + d[v];
			//cout << "v:" << nv << " d:" << d[nv] << endl; 
			que.push(nv);	
		}
	}

	rep(i, q) {
		int x , y;
		cin >> x >> y;
		x--; y--;
		cout << d[x] + d[y] << endl;

	}

	return 0;
}

Measured memory_bytes: 9984
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define repi(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,a) repi(i,0,a)
#define repd(i,a,b) for(int i=(a);i>=(b);i--)
#define repit(i,a) for(__typeof((a).begin()) i=(a).begin();i!=(a).end();i++)

#define all(u) (u).begin(),(u).end()
#define rall(u) (u).rbegin(),(u).rend()
#define UNIQUE(u) (u).erase(unique(all(u)),(u).end())

#define pb push_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9
#define PI acos(-1.0)

using namespace std;

typedef long long ll;
typedef vector<int> vi;

struct cp {
    int a, b;
    vector<int> ul;
};
struct circle {
    int x, y, r, c;
};
char done[1<<24];
vector<cp> pl;
int n;

bool intersect(circle &c1, circle &c2) {
    int dx = c1.x - c2.x;
    int dy = c1.y - c2.y;
    int dst2 = dx*dx + dy*dy;
    return dst2 < (c1.r + c2.r) * (c1.r + c2.r);
}

bool get(int state, int pos) {
    return (state>>pos)&1;
}

int dfs(int state) {
    int ret = n - __builtin_popcount(state);
    if(state == 0) return ret;
    if(done[state]) return 0;
    done[state] = 1;

    rep(i, pl.size()) {
        if(get(state, pl[i].a) and get(state, pl[i].b)) {
            bool ok = true;
            vector<int> &ul = pl[i].ul;
            rep(j, ul.size()) {
                if(get(state, ul[j])) ok = false;
            }
            if(ok) {
                int next_state = state;
                next_state -= (1<<pl[i].a);
                next_state -= (1<<pl[i].b);
                ret = max(ret, dfs(next_state));
            }
        }
    }
    return ret;
}

int main()
{
    while(cin >> n, n) {
        memset(done, 0, sizeof(done));
        vector<circle> cv;
        rep(i, n) {
            int x, y, r, c;
            cin >> x >> y >> r >> c;
            cv.pb((circle){x, y, r, c});
        }

        pl.clear();
        rep(i, n) repi(j, i+1, n) if(cv[i].c == cv[j].c && !intersect(cv[i], cv[j])){
            cp tcp;
            tcp.a = i, tcp.b = j;
            rep(k, n) if((k < i && intersect(cv[k], cv[i])) or
                         (k < j && intersect(cv[k], cv[j]))) tcp.ul.pb(k);
            pl.pb(tcp);
        }

        cout << dfs((1<<n) - 1) << endl;
    }

    
    return 0;
}

Measured memory_bytes: 17620
#include <iostream>
#include <cstring>
#include <cstdio>
#include<algorithm>
#include <queue>
#include <cmath>
#include <limits>
#include <map>
#include <iomanip>
using namespace std;
#define ll long long int

int main(){
  int r;
  cin >> r;
  cout << 2 * r * 3.1415926535;
  return 0;
}

Measured memory_bytes: 3228
#include <cstdio>

const int N = 10;

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

int f[N][N];

int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; ++i) scanf(" %s", s[i] + 1);
  f[1][0] = 1;
  int cnt = 0;
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j)
      f[i][j] = (s[i][j] == '#' ? (f[i - 1][j] + f[i][j - 1]) : 0), cnt += (s[i][j] == '#');
  puts(f[n][m] == 1 && cnt == n + m - 1 ? "Possible" : "Impossible");
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <numeric>

using namespace std;


int main()
{
    int a, b, k;
    cin >> a >> b >> k;

    vector<int> v;
    int i;
    for (i = 1; i <= 100; i++)
    {
        if(a % i == 0 && b % i == 0)
        {
            v.push_back(i);
        }
    }

    cout << v[v.size() - k] << endl;

    return 0;
}


Measured memory_bytes: 888
import java.awt.Point;
import java.awt.geom.Point2D;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	static final char WALL = '#';
	static final int ROAD = '.';
	static char[][] board;

	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String[] tmpArray = br.readLine().split(" ");
		int h = Integer.parseInt(tmpArray[0]);
		int w = Integer.parseInt(tmpArray[1]);
		
		board = new char[h][w];
		
		for(int i = 0; i < h; i++) {
			String str = br.readLine();
			
			for(int j = 0; j < w; j++) {
				board[i][j] = str.charAt(j);
			}
		}
		
		int result = 0;
		for(int i = 0; i < h; i++) {
			for(int j = 0; j < w; j++) {
				for(int k = 0 ; k < h ; k++) {
					for(int l = 0; l < w; l++) {
						result = Math.max(result, solve(j, i, l, k));					
					}
				}
			}
		}
		
		System.out.println(result);
	}

	static final int dx[] = {0,1,0,-1};
	static final int dy[] = {-1,0,1,0};
	
	static int solve(int startX, int startY, int goalX, int goalY) {

		if(board[startY][startX] == WALL || board[goalY][goalX] == WALL) { 
			return -1;
		}
//		System.out.println("from ("+startX+" "+startY+") to ("+goalX+" "+goalY+")");
		ArrayList<Point> queue = new ArrayList<Point>();
		int h = board.length;
		int w = board[0].length;
		
		int dist[][] = new int[h][w];
		
		dist[startY][startX] = 0;
		
		queue.add(new Point(startX, startY));
		
		int maxLen = 0;
		while(!queue.isEmpty()) {
			Point p = queue.remove(0);
			
			if(p.x == goalX && p.y == goalY) {
				break;
			}
			
			for(int i = 0; i < 4; i++) {
				int tmpX = p.x + dx[i];
				int tmpY = p.y + dy[i];
				
				if(tmpX >= 0 && tmpX < w && tmpY >= 0 && tmpY < h) {
					if(board[tmpY][tmpX] == ROAD && dist[tmpY][tmpX] == 0) {
						dist[tmpY][tmpX] = dist[p.y][p.x] + 1;
						maxLen = Math.max(maxLen, dist[tmpY][tmpX]);
						queue.add(new Point(tmpX, tmpY));
					}
				}
			}
//			printArray(dist);
		}
		return maxLen;
	}
	
	static void printArray(int[][] array) {
		for(int i = 0; i < array.length; i++) {
			for(int j = 0; j < array[0].length; j++) {
				System.out.print(array[i][j]+" ");
			}
			System.out.println();
		}
	}
}


Measured memory_bytes: 220172
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ll mod = 1e9 + 7;
//const ll mod = 998244353;
#define REP(i,n) for(int i=0;i<(int)n;++i)
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
string num2bit(ll num, ll len){
    string bit = "";
    REP(i, len){
    bit += char('0'+(num>>i & 1));
    }
    return bit;
}

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

    ll N;
    cin >> N;
    set<string> st;
    REP(i, N){
        string s;
        cin >> s;
        st.insert(s);
    }

    cout <<(int)st.size() << endl;

    return 0;
}

Measured memory_bytes: 19204
"use strict";

function main(input) {
  input = input.trim().split("\n");
  const line1 = Number(input[0]);
  let count = 0;
  for (let i = 1; i <= line1; i++) {
    const tmp = input[i].split(" ");
    if (tmp[0] == tmp[1]) {
      count++;
    } else {
      count = 0;
    }
    if (count >= 3) {
      console.log("Yes");
      return;
    }
  }

  console.log("No");
}

function numberSort(array) {
  array.sort(f);
  return array;
}

var f = function (a, b) {
  return a - b;
};

main(require("fs").readFileSync("/dev/stdin", "utf-8"));


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

int main(){
  int x = 0;
  string N;
  cin >> N;
  for(int i = 0; i < (int(N.size()) - 1); i++){
    if (N[i] == N[i+1]){
      x++;
      if(x == 2){
        cout << "Yes" << endl;
        break;
      }
    }
    else {
      x = 0;
    }
  }
  if(x < 2){
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3612
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int solve(int n , int k) {
  vector<int> h(n);
  for (int i = 0; i < n ; i ++) {
    cin >> h[i];
  }
  sort(h.begin(), h.end());
  long diff = 100000000000 , tmp = 0;
  for (int i = 0 ; i < n - k + 1 ; i ++) {
    tmp = h[k + i - 1] - h[i];
    diff = min(diff , tmp);
  }
  return diff;
}

int main(){
  int n , k;
  cin >> n >> k;
  cout << solve(n , k) << endl;
}

Measured memory_bytes: 640
#include <iostream>
using namespace std;
int N, M;
int main()
{
    cin >> N >> M;
    while((N<1||N>100)&&(M<0||M>N))
        cin >> N >> M;
    if (N == M)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int N; long long A;

int main()
{
	scanf("%d", &N);
	int l = 0;
	for (int i=0;i<N;i++){
		int x; scanf("%d", &x);
		if (x){
			if (l){
				A++;
				x--;
			}
		}
		A += x / 2;
		x %= 2;
		l = x;
	}
	printf("%lld\n", A);

	return 0;
}

Measured memory_bytes: 128
import sys

n, k, c = map(int, sys.stdin.readline().split())
s = sys.stdin.readline().rstrip()

def make(s):
    dp = [[0] * 2 for _ in range(n + 2)]
    for i in range(n):
        dp[i+1][0] = max(dp[i][0], dp[i][1])
        if s[i] == 'o':
            if i + 1 - c < 0:
                dp[i+1][1] = 1 
            else:
                dp[i+1][1] = dp[i+1-c][0] + 1
    return dp

def main():
    dp_l = make(s)
    dp_r = make(s[::-1])[::-1]

    for i in range(1, n + 1):
        if s[i-1] == 'o':
            if dp_l[i][0] + dp_r[i][0] < k:
                print(i)

if __name__ ==  '__main__':
    main()

Measured memory_bytes: 58700
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define repeat(i,a,b) for(int i=(a),i##__end=(b);i<i##__end;i++)
#define repeat_back(i,a,b) for(int i=(b)-1,i##__end=(a);i>=i##__end;i--)
#define mst(a,x) memset((a),(x),sizeof(a))
#define pii pair<int,int>
#define maxn 1000010
#define mod 2147483647
signed main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int a,b;
	cin>>a>>b;
	if(a<=9 && b<=9)cout<<a*b<<endl;
	else cout<<-1<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int[] num = new int[s.length()];
        for (int i=0;i<s.length();i++){
            num[i]=s.charAt(i)-'1'+1;
        }
        long ans = 0;
        for (int i=0;i<Math.pow(2,s.length()-1);i++){
            String index = Integer.toBinaryString(i);
            while (index.length()<s.length()-1)index="0"+index;
            long count=0;
            long instance=num[0];
            for (int j=1;j<s.length();j++){
                if (index.charAt(j-1)=='0'){
                    instance*=10;
                    instance+=num[j];
                }else {
                    count+=instance;
                    instance=num[j];
                }
            }
            ans += count+instance;
        }
        System.out.println(ans);
    }

}


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

#define ll long long
using namespace std;

ll x, y, z, a, b, c, _ap, _bp, _cp, N, ans, ara[ 200000 + 3 ], hi, flag;
vector <ll> adj[ 2003 ];
ll _a[ 100003 ], _b[ 100003 ], _c[ 100003 ], _t[ 200005 ];

int main()
{
  cin >> x >> y >> a >> b >> c;
  z = c;
  
  for (ll i=0; i<a; i++)
    cin >> _a[ i ];
  
  for (ll i=0; i<b; i++)
    cin >> _b[ i ];
  
  for (ll i=0; i<c; i++)
    cin >> _c[ i ];
 
  sort( _a, _a + a, greater< ll >());
  sort( _b, _b + b, greater< ll >());
  sort( _c, _c + c, greater< ll >());
  
  ll i = 0;
  for ( ; i<x; i++) {
    _t[ i ] = _a[ i ];
    ans += _a[ i ];
  }
  
  ll j = i;
  for (i=0; i<y; i++) {
    _t[ j + i ] = _b[ i ];
    ans += _b[ i ];
  }
  
  sort( _t, _t + x + y );
  
  i = 0;
  while ( _t[ i ] < _c[ i ] ){
    ans += _c[ i ] - _t[ i ];
    i++;
  }
  
  cout << ans << "\n";
  
  return 0;
}
//inzamam

Measured memory_bytes: 4224
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <tuple>
#include <bitset>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
#include <cassert>
#include <random>
int main() {
	double a, t, r; std::cin >> a >> t >> r;
	std::cout << std::setprecision(15) << std::fixed << t / a * r << '\n';
}


Measured memory_bytes: 3280
use std::io::*;
use std::str::FromStr;
use utils::*;

pub fn main() {
    let i = stdin();
    let mut o = Vec::new();
    run(i.lock(), &mut o);
    stdout().write_all(&o).unwrap();
}

fn run<R: BufRead, W: Write>(i: R, o: &mut W) {
    let mut i = CpReader::new(i);
    let (n, m, x, y) = i.read4::<usize, usize, isize, isize>();
    let xs = i.read_vec::<isize>(n);
    let ys = i.read_vec::<isize>(m);

    let x_max = xs.into_iter().max().unwrap();
    let y_min = ys.into_iter().min().unwrap();

    let r = if x_max < y_min && x_max < y && x < y_min {
        "No War"
    } else {
        "War"
    };

    writeln!(o, "{}", r).unwrap();
}

mod utils {
    use super::*;

    pub struct CpReader<R: BufRead> {
        r: R,
        s: String,
    }

    macro_rules! fn_read {
        { $f:ident($($t:ident),*) } => {
            #[allow(dead_code)]
            pub fn $f<$($t: FromStr),*>(&mut self) -> ($($t),*) {
                let i = &mut self.read_line().split(' ');
                ($(read_next::<$t,_>(i)),*)
            }
        };
    }

    impl<R: BufRead> CpReader<R> {
        pub fn new(r: R) -> Self {
            CpReader {
                r: r,
                s: String::new(),
            }
        }
        pub fn read_line(&mut self) -> &str {
            self.s.clear();
            self.r.read_line(&mut self.s).unwrap();
            self.s.trim()
        }

        fn_read! { read2(T1, T2) }
        fn_read! { read3(T1, T2, T3) }
        fn_read! { read4(T1, T2, T3, T4) }
        fn_read! { read5(T1, T2, T3, T4, T5) }

        pub fn read_vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
            self.read_line()
                .split(' ')
                .take(n)
                .map(|x| x.parse().ok().unwrap())
                .collect()
        }
    }
    fn read_next<'a, T: FromStr, I: Iterator<Item = &'a str>>(i: &mut I) -> T {
        i.next().unwrap().parse().ok().unwrap()
    }
}


Measured memory_bytes: 4352
#include<stdio.h>
int main(void)
{
  int i,j,n,no,trump[4][14];
  char shurui,dummy;

  for(i=0;i<4;i++)
    for(j=1;j<=13;j++)trump[i][j]=j;

  scanf("%d",&n);

//  for(i=1;i<=n;i++) scanf("%d %d",&no,&no);
  for(i=1;i<=n;i++){
    scanf("%c",&dummy);
    scanf("%c %d",&shurui,&no);
// printf("p=%d %c %d\n",i,shurui,no);
    if(shurui=='S')trump[0][no]=0;
    else if(shurui=='H')trump[1][no]=0;
    else if(shurui=='C')trump[2][no]=0;
    else if(shurui=='D')trump[3][no]=0;
  }

  for(i=1;i<=13;i++)if(trump[0][i]!=0)printf("S %d\n",trump[0][i]);
  for(i=1;i<=13;i++)if(trump[1][i]!=0)printf("H %d\n",trump[1][i]);
  for(i=1;i<=13;i++)if(trump[2][i]!=0)printf("C %d\n",trump[2][i]);
  for(i=1;i<=13;i++)if(trump[3][i]!=0)printf("D %d\n",trump[3][i]);

  return 0;
}

Measured memory_bytes: 1852
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	int n;
	cin >> n;
	
	vector< pair< pair<string, int>,  int> > p(n);
	for(int i = 0; i < n; ++i) {
		string s;
		int a;
		cin >> s >> a;
		
		p[i] = make_pair(make_pair(s, -a), i);
	}
	
	sort(p.begin(), p.end());
	
	for(int i = 0; i < n; ++i) {
		cout << p[i].second + 1 << endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
package main

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

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func main() {
	io := newIo()
	defer io.Flush()

	N := io.NextInt()
	A := make([]int, N)
	B := make([]int, N)

	for i := range make([]struct{}, N) {
		A[i] = io.NextInt()
		B[i] = A[i] - i
	}
	sort.Ints(B)
	b := (B[(N-1)/2] + B[(N/2)]) / 2

	ans := 0
	for i := range make([]struct{}, N) {
		ans += abs(B[i] - b)
	}
	io.Println(ans)
}

type io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func newIo() *io {
	return &io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *io) Flush() {
	_ = io.writer.Flush()
}

func (io *io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, _ := io.reader.ReadLine()
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

func (io *io) NextWord() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

func (io *io) NextInt() int {
	i, _ := strconv.Atoi(io.NextWord())
	return i
}

func (io *io) Print(a ...interface{}) {
	fmt.Fprint(io.writer, a...)
}

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

func (io *io) Printf(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format, a...)
}


Measured memory_bytes: 14972