akhauriyash/Code-Regression huggingface dataset:
import java.io._
import java.util.StringTokenizer
import scala.util.control.Breaks.{breakable,break}
import scala.collection.mutable.{Map, Stack, Queue, PriorityQueue, Set}

object Main extends App {
  val in = new InputReader(System.in)
  val pw = new PrintWriter(System.out)

  val H, W = in.next().toInt
  val A = Array.ofDim[Int](H+1, W+1)
  val B = Array.ofDim[Int](H+1, W+1)
 
  for (y <- 1 to H; x <- 1 to W) {
    A(y)(x) = in.next().toInt
  }
  for (y <- 1 to H; x <- 1 to W) {
    B(y)(x) = in.next().toInt
  }


  //
  val V = 80*(H+W)

  val dp = Array.ofDim[Boolean](H+1, W+1, V*2+1)
  dp(0)(1)(V) = true
  dp(1)(0)(V) = true

  for {
    y <- 1 to H
    x <- 1 to W
    c = (A(y)(x) - B(y)(x)).abs
    v <- 0 to V*2
  } {
    if (dp(y-1)(x)(v) || dp(y)(x-1)(v)) {
      dp(y)(x)(v + c) = true
      dp(y)(x)(v - c) = true
    }
  }

  var ans = 0
  breakable {
    var i = 0
    val last = dp(H)(W)
    while (true) {
      if (last(V-i) || last(V+i)) {
        ans = i
        break
      }
      i += 1
    }
  }

  println(ans)
}

object Sub {
  def print2DimArray[A](mat: Array[Array[A]]): Unit = {
    mat.foreach(lin => println(lin.toList))
  }
}

class InputReader(stream: InputStream) {
  private[this] val reader = new BufferedReader(new InputStreamReader(stream))
  private[this] var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())
  def next(): String = {
    while (!tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine())
    }
    tokenizer.nextToken()
  }
}


Measured memory_bytes: 267116
'''
allinputs = iter(input().splitlines())
input = lambda : next(allinputs)
#'''
N = int(input())
A = list(map(int, input().split()))
total1 = [0] * (N + 1)
total2 = [0] * (N + 1)

for i in range(1, N + 1):
	total1[i] += total1[i - 1] + A[i - 1] * ((-1) ** (i % 2))
	total2[i] += total2[i - 1] + A[i - 1] * ((-1) ** (i % 2 + 1))

for i in range(N):
	ans = total1[N] - total1[i] + total2[i] - total2[0]
	print(abs(ans), end=' ')


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
	  for(auto &e:u) fill_v<T>(e,v...);
}

vector<PLL> G[310];

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

  int64 N, M, L;
  cin >> N >> M >> L;
  REP(i, M) {
    int64 a, b, c;
    cin >> a >> b >> c; a--; b--;
    G[a].emplace_back(c, b);
    G[b].emplace_back(c, a);
  }
  int64 Q;
  cin >> Q;
  vector<int64> res(Q, -1);
  map<int64, vector<PLL>> q;
  REP(_, Q) {
    int64 s, t;
    cin >> s >> t;
    q[s-1].emplace_back(t-1, _);
  }
  REP(i, N) {
    auto d = make_v<PLL>(N + 1);
    fill_v<PLL>(d, PLL(INF, 0));
    d[i] = PLL(0, -L);
    using T = tuple<int64, int64, int64>;
    priority_queue<T, vector<T>, greater<T>> pq;
    pq.emplace(0, -L, i);
    while (pq.size()) {
      int64 vv, dd, rr;
      tie(dd, rr, vv) = pq.top();
      pq.pop();
      if (d[vv].fs < dd || (d[vv].fs == dd && -d[vv].sc > -rr)) continue;

      REP(i, G[vv].size()) {
        int64 uu, cc;
        tie(cc, uu) = G[vv][i];
        if (-rr < cc && L >= cc && d[uu] > PLL(dd+1, -L+cc)) {
          d[uu] = PLL(dd+1, -L + cc);
          pq.emplace(dd+1, -L + cc, uu);
        } else if (-rr >= cc && d[uu] > PLL(dd, rr + cc)) {
          d[uu] = PLL(dd, rr + cc);
          pq.emplace(dd, rr + cc, uu);
        }
      }
    }
    for (auto &t: q[i]) {
      if (d[t.fs].fs != INF) res[t.sc] = d[t.fs].fs;
    }
  }
  REP(i, Q) {
    cout << res[i] << endl;
  }
}


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

#define ll long long
#define MAXN 3010

using namespace std;

ll dp[MAXN][MAXN];

int main() {

    string s, t;
    cin >> s >> t;
    
    int n = s.size(), m = t.size();

    for(int i = 0; i <= n; i++) {
        for(int j = 0; j <= m; j++) {
            if(i == 0 || j == 0) {
                dp[i][j] = 0;
                continue;
            }
            
            dp[i][j] = max(dp[i][j - 1], dp[i - 1][j]);
            if(s[i - 1] == t[j - 1])
                dp[i][j] = max(dp[i][j], dp[i - 1][j - 1] + 1);
        }
    }

    int i = n, j = m;
    stack<char> sol;
    while(i && j) {
        if(s[i - 1] == t[j - 1]) {
            sol.push(s[i - 1]);
            i--;
            j--;
            continue;
        }

        if(dp[i][j] == dp[i - 1][j])
            i--;
        else
            j--;
    }

    while(!sol.empty()) {
        cout << sol.top();
        sol.pop();
    }
    cout << endl;
    
    return 0;
}

Measured memory_bytes: 70784
#include<bits/stdc++.h>
#include <iterator>
#include <iostream>
#include <numeric>
#include <math.h>
#define ll long long
#define ull long
#define mpa make_pair
#define pb push_back
#define ff first
#define pii pair<ll,ll>
#define dd long long
#define trace(x) cerr << #x << " : " << x << endl
#define ss second
#define boost ios_base::sync_with_stdio(0)
#define forp(i,a,b) for(ll i=a;i<=b;i++)
#define rep(i,n)    for(ll i=0;i<n;++i)
#define ren(i,n)    for(ll i=n-1;i>=0;i--)
#define forn(i,a,b) for(ll i=a;i>=b;i--)
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c).begin()) i = (c).begin(); i != (c).end();
#define sc(x) scanf("%lld",&x)
#define clr(x,val) memset(x,val,sizeof(x))
#define pr(x) printf("%lld\n",x) 
#define gc getchar
#define pdd pair<dd,dd>
#define prec(x) cout<<fixed<<setprecision(x)
#define fre freopen("input.txt","r",stdin),freopen("output.txt","w",stdout)
using namespace std;
char a[300005];
ll mod=1e9+7;
ll modpow(ll a,ll n){
	ll res=1;
	while(n){
		if(n%2)res=(res*a)%mod;
		a=(a*a)%mod;
		n/=2;
	}
	return res;
}
ll dp[100005];
ll temp[100005];
int main(){
   
   ll n;
   cin>>n;
   dp[0]=1;
   
   for(ll i=3;i<=n;i++){
   	   for(ll j=0;j<=n;j++)temp[j]=dp[j];
   	   for(ll j=3;j<=i;j++){
   	   	     {
   	   	     	temp[i]=(temp[i]+dp[i-j])%mod;
			  } 
		}
		for(ll j=1;j<=n;j++)dp[j]=(temp[j])%mod;
   }
   cout<<dp[n]<<endl;
   
}
    
   
   

  
   
 

Measured memory_bytes: 3644
import math
import sys
s = input()
li=['']*len(s)
for i in range(len(s)):
    li[i] = s[i]
li.sort()
if (li[0] == li[1] and li[2] == li[3] and li[1] != li[2]):
    print('Yes')
else:
    print('No')

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

struct S{
  int h,p,q;
  S(){};
  S(int H,int P, int Q){ h=H; p=P; q=Q;};
};
int main(){
  int n,m,a;
  int h,p,q;
  S s[1000];
  while(cin>>n>>m>>a, n ){
    for( int i=0;i<m;i++ ){
      cin >> h >> p >> q;
      s[i] = S(h,p,q);
    }

    bool flag;
    do{
      flag = false;
      for( int i=1;i<m;i++ ){
	if( s[i-1].h < s[i].h ){
	  S tmp = s[i-1]; s[i-1] = s[i]; s[i] = tmp;
	  flag = true;
	}
      }
    }while(flag);


    int index=0;
    while( index<m ){
      for( ; index<m;index++ ){
	if( s[index].q == a || s[index].p == a )
	  break;
      }
      if( index==m )
	break;

      a = (s[index].q==a)?s[index].p:s[index].q;

      index++;
    }
    cout << a << endl;
  }
}

Measured memory_bytes: 1168
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include<set>
#include<map>
using namespace std;


int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if(a+b+c >= 22){
        cout << "bust";
    }
    else
    {
        cout << "win";
    }
    
    cout << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#define ull unsigned long long

int input[200005];
ull sum;
ull min = (ull)-1;

int main()
{
	int N;

	scanf("%d", &N);

	for (int i = 0; i < N; ++i)
	{
		scanf("%d", &input[i]);
		sum += input[i];
	}

	ull cur_sum = 0;

	for (int i = 0; i < N; ++i)
	{
		cur_sum += input[i];
		
		ull target;

		if (cur_sum > sum - cur_sum) target = cur_sum - (sum - cur_sum);
		else target = sum - cur_sum - cur_sum;

		if (target < min) min = target;
	}

	printf("%llu\n", min);

	return 0;
}

Measured memory_bytes: 896
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define ll int
#define cps CLOCKS_PER_SEC
#define bits_count __builtin_popcountll
#define endl '\n'
#define double long double
#define ld double
#define FOR(i,a,n) for (ll i=(a);i<=(n);++i)
#define RFOR(i,a,n) for (ll i=(n);i>=(a);--i)
#define ZERO(a) memset((a),0,sizeof((a)))
#define MINUS(a) memset((a),-1,sizeof((a)))
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define all(g) g.begin(),g.end()
#define sz(x) (ll)x.size()
#define pr pair<int,int>
int fastMax(int x, int y) { return (((y-x)>>(32-1))&(x^y))^y; }
int fastMin(int x, int y) { return (((y-x)>>(32-1))&(x^y))^x; }
 
// #include <ext/pb_ds/assoc_container.hpp> // Common file
// #include <ext/pb_ds/tree_policy.hpp>     // Including tree_order_statistics_node_updat
// using namespace __gnu_pbds;
// typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// const int RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
// struct chash { int operator()(int x) const { return x ^ RANDOM; }};
// cc_hash_table<int, int, hash<int>> cnt;

const int MAXN = 52;
const int INF = 1e15;
vector<pair<int,pair<int,int>>> graph[MAXN];
int c[MAXN],d[MAXN];
int maxx_coins = 0;
int dist[MAXN][MAXN*MAXN];

void solve(){
    int n,m,s; cin>>n>>m>>s;
    s = min(s,2500LL);

    FOR(i,1,m){
        int u,v,a,b; cin>>u>>v>>a>>b;
        graph[u].push_back(make_pair(v,make_pair(a,b)));
        graph[v].push_back(make_pair(u,make_pair(a,b)));
    }

    FOR(i,1,n) cin>>c[i]>>d[i];

    FOR(i,1,n) FOR(j,0,2500) dist[i][j] = INF;
    using T = pair<int,pr>;
    priority_queue<T,vector<T>,greater<T>> pq;
    pq.push({0,{1,s}});
    dist[1][s] = 0;
    
    while(!pq.empty()){
        auto top = pq.top(); pq.pop();
        int u = top.s.f,silver = top.s.s;
        if(silver < 2500){
            int n_silver = min(silver+c[u],2500LL);
            if(dist[u][n_silver] > dist[u][silver] + d[u]){
                dist[u][n_silver] = dist[u][silver] + d[u];
                pq.push({dist[u][n_silver],{u,n_silver}});
            }
        }

        for(auto vv:graph[u]){
            int v = vv.f,a = vv.s.f,b = vv.s.s;
            if(a <= silver){
                if(dist[v][silver-a] > dist[u][silver] + b){
                    dist[v][silver-a] = dist[u][silver] + b;
                    pq.push({dist[v][silver-a],{v,silver-a}});
                }
            }
        }
    }

    FOR(i,2,n){
        int ans = INF;
        for(int j=0;j<=2500;j++) ans = min(ans,dist[i][j]);
        cout<<ans<<endl;
    }
}
 
signed main(){

    FastRead; 

    int t = 1; 
    // cin>>t;
    FOR(i,1,t){
        // cout<<"Case #"<<i<<": ";
        solve();
    }
}


Measured memory_bytes: 7308
#include <bits/stdc++.h>
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
#define _all(arg) begin(arg),end(arg)
#define in(a,b,c) (b<=a&&a<=c)

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0; }
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0; }

using namespace std;

int decode(string e) {
	int res = 0;
	rep(i,e.size()) {
		switch(e[i]) {
			case 'm':
				if(i && in(e[i-1],'0','9')) res+=(e[i-1]-'0')*1000;
				else res += 1000;
				continue;
			case 'c':
				if(i && in(e[i-1],'0','9')) res+=(e[i-1]-'0')*100;
				else res += 100;
				continue;
			case 'x':
				if(i && in(e[i-1],'0','9')) res+=(e[i-1]-'0')*10;
				else res += 10;
				continue;
			case 'i':
				if(i && in(e[i-1],'0','9')) res+=(e[i-1]-'0')*1;
				else res += 1;
				continue;
		}
	}
	return res;
}

string encode(int n) {
	string res = "";
	if(n/1000) {
		if((n/1000)-1) {
			res += (n/1000)+'0';
		}
		res += "m";
		n%=1000;
	}
	if(n/100) {
		if((n/100)-1) {
			res += (n/100)+'0';
		}
		res += "c";
		n%=100;
	}
	if(n/10) {
		if((n/10)-1) {
			res += (n/10)+'0';
		}
		res += "x";
		n%=10;
	}
	if(n/1) {
		if(n-1) {
			res += n+'0';
		}
		res += "i";
	}
	return res;
}

int main(void){
	int n; cin >> n;
	while(n--) {
		string in1, in2; cin >> in1 >> in2;
		cout << encode(decode(in1)+decode(in2)) << endl;
	}
        
	return 0;
}

Measured memory_bytes: 3024
while True:
    H,W = map(int,input().split())
    if H == 0 and W == 0:
        break
    else:
        for i in range(H):
            if i == 0:
                print("#"*W,end="\n")
                continue
            elif i == H-1:
                print("#"*W,end="\n")
                continue
            else:
                for j in range(W):
                    if j == 0 or j == W-1:
                        print("#", end="")
                    else:
                        print(".", end="")
                else:
                    print()
        else:
            print()





Measured memory_bytes: 7008
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

ll dp[100100];

int main() {
	ll n;
  cin>>n;
  rep(i,0,100100)dp[i]=1000000000000000000LL;
  dp[0] = 0;
  vector<ll> v;
  rep(i,0,n){
    ll a;
    cin>>a;
    v.pb(a);
  }
  v.pb(0);
  v.pb(0);
  rep(i,0,n){
    dp[i+1] = min(dp[i+1],dp[i]+abs(v[i+1]-v[i]));
    dp[i+2] = min(dp[i+2],dp[i]+abs(v[i+2]-v[i]));
  }
  cout << dp[n-1] << endl;
	return 0;
}

Measured memory_bytes: 2168
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<queue>

using namespace std;

typedef pair<int, int> P;
typedef pair<int, P> T;
#define INF (1 << 30)
vector<P> edge[1050];
int dist[105][15];

void dijkstra(int s, int c){
    for(int i = 0;i < 15;i++)
	for(int j = 0;j < 105;j++)
	    dist[j][i] = INF;
    dist[s][c] = 0;
    priority_queue<T> pq;
    pq.push(T(0, P(s, c)));
    while(!pq.empty()){
	T tmp = pq.top();pq.pop();
	int from = tmp.second.first, tc = tmp.second.second;
	if(dist[from][tc] < tmp.first)continue;
	for(int i = 0;i < edge[from].size();i++){
	    int to = edge[from][i].first, d = edge[from][i].second;
	    if(dist[to][tc] > dist[from][tc] + d){
		dist[to][tc] = dist[from][tc] + d;
		pq.push(T(dist[to][tc], P(to, tc)));
	    }
	    if(tc > 0 && dist[to][tc - 1] > dist[from][tc] + d / 2){
		dist[to][tc - 1] = dist[from][tc] + d / 2;
		pq.push(T(dist[to][tc - 1], P(to, tc - 1)));
	    }
	}
    }
}

int main(){
    int c, n, m, s, d, a , b, f;
    while(cin >> c >> n >> m >> s >> d, d){
	for(int i = 1;i <= n;i++){
	    edge[i].clear();
	    edge[i].push_back(P(i, 0));
	}
	for(int i = 0;i < m;i++){
	    cin >> a >> b >> f;
	    edge[a].push_back(P(b, f));
	    edge[b].push_back(P(a, f));
	}
	dijkstra(s, c);
	cout << dist[d][0] << endl;
    }
    return 0;
}

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

using namespace std;
const int max_n = 1e5 + 20;
int n, m;
int a[max_n], DP[max_n];
int main() {
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    DP[1] = abs(a[1] - a[0]);
    for (int i = 2; i < n; i++)
        DP[i] = min(abs(a[i - 1] - a[i]) + DP[i - 1], abs(a[i] - a[i - 2]) + DP[i - 2]);
    cout << DP[n - 1];
    return 0;
}


Measured memory_bytes: 1024
k,n = map(int, input().split())

a = list(map(int, input().split()))

import numpy as np
a = np.array(a)

s = np.sort(a)
temae = 0
oku = 0
m = k
for i in range(n):
  if s[(i-1)%n] - s[i] < 0:
    c1 = k+s[(i-1)%n] - s[i]
  else:
    c1 = s[(i-1)%n] - s[i]
  if s[i] - s[(i+1)%n] > 0:
    c2= s[i] - s[(i+1)%n]
  else:
    c2 = k + s[i] - s[(i+1)%n]
  if m > c1:
    m = c1
  if m > c2:
    m = c2
print(m)

Measured memory_bytes: 26444
#include <iostream>
#include <cstdlib>
#include <algorithm>
using namespace std;
int main(void){
    int a[6];
    for(int i=0;i<6;i++){
        cin >> a[i];
    }
    
    bool flag=true;
    for(int i=0;i<5;i++){
        for(int j=0;j<5;j++){
            if(flag&&abs(a[i] - a[j])>a[5]){
                cout << ":(" << endl;
                flag = false;
            }
        }
    }
    
    if(flag){
        cout << "Yay!" << endl;
    }
    
    
}


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

using namespace std;

int main()
{
    int n;
    cin>>n;
    int del[n],sum=0;
    for(int i=0;i<n;i++)
    {
        cin>>del[i];
    }
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            sum=sum+(del[i] * del[j]);
        }
    }
    cout<<sum<<endl;
}

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

#define endl '\n'

typedef long long ll;

const int MAX = (int) 1e5 + 9;

int a[MAX];

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

	int n, k;
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int ans;
	if (k >= n) ans = 1;
	else {
		n -= k;
		ans = 1;
		ans += ceil(n/(double)(k-1));
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 640
//AUTHOR: *Akash Shrivastva*
//Birla Institute of Technology,Mesra,India
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define M 1000000007
#define mp make_pair
#define pb push_back
#define vll vector<ll>
#define pll vector< pair <ll,ll> >
#define F first
#define S second
#define PII pair <ll,ll>

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
  
	ll n;cin>>n;
	ll i,a[n],b[n],s=0,k;
	for (i=0;i<n;i++)	cin>>a[i],cin>>b[i];
	k=a[n-1]%b[n-1];
	if (k!=0) k=a[n-1]/b[n-1]+1, s+=k*b[n-1]-a[n-1];
	for (i=n-2;i>=0;i--)
	{
		a[i]+=s;
		if (a[i]%b[i]==0)	continue;
		else
		{
			k=a[i]/b[i]+1;
			s+=k*b[i]-a[i];
		}
	}
	cout<<s<<endl;	
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
using namespace std;
using lint = long long;
const int MAXN = 605;

int n;
char str[MAXN][MAXN];
int ps[MAXN][MAXN];

int gs(int sx, int ex, int sy, int ey){
	int ret = ps[ex][ey];
	if(sx>0) ret -= ps[sx-1][ey];
	if(sy>0) ret -= ps[ex][sy-1];
	if(sx>0&&sy>0) ret += ps[sx-1][sy-1];
	return ret;
}

int Do(){
	int ret = 0;
	for(int i=1; i<n; i++){
		memset(ps, 0, sizeof(ps));
		for(int j=0; j<2*n-i; j++){
			for(int k=0; k<2*n-i; k++){
				char p = str[j][k+i];
				char q = str[k][j+i];
				if(p == q){
					ps[j][k]++;
				}
			}
		}
		for(int j=0; j<2*n-i; j++){
			for(int k=0; k<2*n-i; k++){
				if(j) ps[j][k] += ps[j-1][k];
				if(k) ps[j][k] += ps[j][k-1];
				if(j && k) ps[j][k] -= ps[j-1][k-1];
			}
		}
		for(int j=0; j<n-i; j++){
			ret += (gs(j, j+n-1, j, j+n-1) == n*n);
		}
	}
	return ret;
}

int trial(int x, int y){
	for(int i=0; i<n; i++){
		for(int j=0; j<n; j++){
			char c = str[x+i][y+j];
			char d = str[x+j][y+i];
			if(c != d) return 0;
		}
	}
	return 1;
}

int main(){
	scanf("%d",&n);
	for(int i=0; i<n; i++){
		scanf("%s", str[i]);
	}
	for(int i=0; i<2*n; i++){
		for(int j=0; j<2*n; j++){
			str[i][j] = str[i%n][j%n];
		}
	}
	int ret = 0;
	for(int i=0; i<n; i++){
		ret += trial(i, i);
	}
	ret += Do();
	for(int i=0; i<n+n; i++){
		for(int j=0; j<i; j++){
			swap(str[i][j], str[j][i]);
		}
	}
	ret += Do();
	cout << ret << endl;
}


Measured memory_bytes: 5500
#include <stdio.h>
#include <string.h>

#define MAX (5000000)

char prime[MAX];

int main(void)
{
	memset(prime, 1, sizeof(prime));
	prime[0] = prime[1] = 0;

	for (int i = 2; i < MAX; i++){
		if (prime[i] == 1){
			for (int j = i * 2; j < MAX; j += i){
				prime[j] = 0;
			}
		}
	}

	while (1){
		int n;
		int ans;

		scanf("%d", &n);
		if (n == 0){
			break;
		}

		ans = 0;
		for (int i = n + 1; i <= n * 2; i++){
			ans += prime[i];
		}

		printf("%d\n", ans);
	}

	return (0);
}

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

int main() {
  int N, D; cin >> N >> D;
  vector<vector<int>> X(N, vector<int>(D));
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < D; ++j) {
    cin >> X[i][j];
    }
  }
  int ans = 0;
  for (int i = 0; i < N; ++i) {
    for (int j = i+1; j < N; ++j) {
    int norm = 0;
    for (int k = 0; k < D; ++k) {
      int diff = abs(X[i][k] - X[j][k]);
      norm += diff * diff;
    }
 // check whether norm = k for some k
    bool flag = false;
    for (int k = 0; k <= norm; ++k) {
      if (k * k == norm) {
      flag = true;
      }
    }
    if (flag) ++ans;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main() {
 int a,b,c;
 scanf("%d %d %d",&a,&b,&c);
 if (a < b&&b>c&&a>c){
  printf("%d %d %d\n",c,a,b);
   }
 else if(a<b&&b>c&&a<c){
  printf("%d %d %d\n",a,c,b);
  }
 else if(a>b&&b<c&&a<c){
  printf("%d %d %d\n",b,a,c);
  }
 else if(a>b&&b<c&&a>c){
  printf("%d %d %d\n",b,c,a);
  }
 else if(a>b&&b>c&&a>c){
  printf("%d %d %d\n",c,b,a);
  }
 else if(a<b&&b>c){
  printf("%d %d %d\n",a,c,b);
  }
 else if(a>c&&a>b){
  printf("%d %d %d\n",b,c,a);
  }
 else {
printf("%d %d %d\n",a,b,c);
}
return 0;
}

Measured memory_bytes: 2672
while 1:
    data=list(map(int,input().split()))
    
    if data[0]==0:break
    
    for i in range(data[0]):
        for j in range(data[1]):
            if i%2==0:
                if j%2==0:
                    print('#',end='')
                else:
                    print('.',end='')
            else:
                if j%2==0:
                    print('.',end='')
                else:
                    print('#',end='')
        print()
    print()


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

int main() {
    int n; cin >> n;
    vector<int> cnt(3);
    for(int i = 0; i < n; ++i) {
        int a; cin >> a;
        if(a % 4 == 0) cnt[2] += 1;
        else if(a % 2 == 0) cnt[1] = 1;
        else cnt[0] += 1;
    }
    cnt[0] += cnt[1];

    if(cnt[0] > cnt[2] + 1) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
}


Measured memory_bytes: 256
using System;
using System.Linq;

public class Test
{
	public static void Main()
	{
		// my code goes here
		
		var a = Console.ReadLine().Split().Select(nyan => int.Parse(nyan)).ToArray();
		int counter = 0;
		if(a[0]==a[1]){counter++;}
		if(a[1]==a[2]){counter++;}
		if(a[2]==a[0]){counter++;}
		if(counter == 1){
			Console.WriteLine("Yes");
		}else{
			Console.WriteLine("No");
		}
		
	}
}

Measured memory_bytes: 13268
#include <iostream>
#include <cstdio>

using namespace std;

bool checker[200000];

int main(){
	
	int N;
	
	cin >> N;
	
	for(int i = 0; i < 200000; i++){
		checker[i] = false;
	}
	
	for(int i = 0; i < N; i++){
		int num;
		cin >> num;
		checker[num] = true;
	}
	
	int ans = 0;
	
	for(int i = 0; i < 200000; i++){
		if(checker[i]){
			ans++;
		}
	}
	
	if(ans % 2 == 0){
		ans--;
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 384
#pragma region Macros

#include <bits/stdc++.h>
using namespace std;

using ll = long long;
#define int ll
using vi = vector<int>;
using vvi = vector<vi>;

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

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 T>
std::istream &operator>>(std::istream &is, std::vector<T> &vec) {
    for (T &element : vec) {
        is >> element;
    }
    return is;
}
template <class Ch, class Tr, class Container>
std::basic_ostream<Ch, Tr> &operator<<(std::basic_ostream<Ch, Tr> &os, Container const &x) {
    bool first = true;
    for (auto &y : x) {
        if (first) {
            first = false;
        } else {
            os << " ";
        }
        os << y;
    }
    return os;
}

// debug methods
// usage: debug(x,y);
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define debug_1(x1) cout << #x1 << ": " << x1 << endl
#define debug_2(x1, x2) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define debug_3(x1, x2, x3) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << endl
#define debug_4(x1, x2, x3, x4) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << endl
#define debug_5(x1, x2, x3, x4, x5) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#ifdef _DEBUG
#define debug(...)                                                        \
    CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) \
    (__VA_ARGS__)
#else
#define debug(...)
#endif

#pragma endregion

void Main(std::istream &in, std::ostream &out) {
    int K, N;
    in >> K >> N;
    vi a(N);
    cin >> a;

    int diff = K - a[N - 1] + a[0];
    REP(i, N - 1) {
        chmax(diff, a[i + 1] - a[i]);
    }
    out << K - diff;
}

#pragma region main
signed main() {
    ios::sync_with_stdio(false);
    //cin.tie(nullptr);
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    in.tie(nullptr);
    out << std::fixed;
    out.precision(20);
    Main(in, out);
    cout << flush;
}
#pragma endregion


Measured memory_bytes: 4764
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
#define REP(i, n) for ( int i = 0; i < (n); i++ )
 
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);

  int N, K;
  cin >> N >> K;

  vector<int> l(N);
  REP(i, N) cin >> l[i];

  sort(l.begin(), l.end(), greater<int>());
  int ans = 0;
  REP(i, K) ans += l[i];

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3600
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

int main(){
	ll a,b,c,d;
	scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
	printf("%.10f %lld",a*b/2.0,c*2==a&&d*2==b);
}

Measured memory_bytes: 128
while True :
  x,op,y = input().split()
  x=int(x)
  y=int(y)
  if op == '?' :
    break
  elif op == '+' :
    print(x+y)
  elif op == '-' :
    print(x-y)
  elif op == '*' :
    print(x*y)
  else :
    print(x//y)


Measured memory_bytes: 5592
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}


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

  double a,b,x;
  cin>>a>>b>>x;

  if(a*a*b==2*x){
    cout<<45<<endl;
  }else if(a*a*b<2*x){
    cout<<atan(2*(a*a*b-x)/(a*a*a))*180/M_PI<<endl;
  }else{
    cout<<90-atan(2*x/(b*b*a))*180/M_PI<<endl;
  }


}

Measured memory_bytes: 256
n = int(input())
a = []
for i in range(n):
  tmp = list(map(int, input().split()))
  a.append(tmp[2:])
ans = [-1 for _ in range(n + 1)]
ans[1] = 0
que = [1]
while len(que) > 0:
  current = que.pop(0)
  if len(a[current - 1]) == 0:
    continue
  for next in a[current - 1]:
    if ans[next] == -1:
      que.append(next)
      ans[next] = ans[current] + 1
for i in range(1, n + 1):
  print(i, ans[i])
    


Measured memory_bytes: 5624
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;

bool no_twins(const vi &xs, const int i) {
    const int sz = xs.size();
    const int l = i > 0 ? xs[i - 1] : -1;
    const int r = i < sz - 1 ? xs[i + 1] : -1;
    return l != xs[i] && r != xs[i];
}

void mark_multiples(const int max_a, vb &taken, const int x) {
    for (int y = x; y <= max_a; y += x) taken[y] = true;
}

int solve_on_sorted(const vi &xs) {
    if (xs.empty()) return 0;
    const int sz = xs.size();
    // if (sz == 1 || xs[0] == 1) return 1;

    vb taken(xs.back() + 1, false);
    int ans = 0;

    for (int i = 0; i < sz; ++i) {
        if (i > 0 && xs[i] == xs[i - 1]) continue;
        if (!taken[xs[i]] && no_twins(xs, i)) ++ans;
        mark_multiples(xs.back(), taken, xs[i]);
    }

    return ans;
}

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

    int sz;
    cin >> sz;
    vi xs(sz, 0);
    for (auto &x : xs) cin >> x;
    sort(xs.begin(), xs.end());
    cout << solve_on_sorted(xs) << '\n';

    return 0;
}


Measured memory_bytes: 4244
#include<stdio.h>
int main()
{
    int i,j,n,a[105],min,t,num=0;
    scanf("%d",&n);
    for(i=0;i<n;i++)
        scanf("%d",&a[i]);
    for(i=0;i<n;i++)
    {
        min=i;
        for(j=i;j<n;j++)
        {
            if(a[j]<a[min])
                min=j;
        }
        if(a[min]!=a[i])
        {
            t=a[i];
            a[i]=a[min];
            a[min]=t;
            num++;
        }
    }
    for(i=0;i<n-1;i++)
        printf("%d ",a[i]);
    printf("%d\n",a[i]);
    printf("%d\n",num);
    return 0;
}



Measured memory_bytes: 2132
// atcoder/abc178/D/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& i: v) is >> i; return is; }
template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "#{"; for (auto& i: s) os << i << ","; os << "}"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; for (auto& i: m) os << i << ","; os << "}"; return os; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

constexpr array<int, 8> di({0, 1, -1, 0, 1, -1, 1, -1});
constexpr array<int, 8> dj({1, 0, 0, -1, 1, -1, -1, 1});
constexpr lli mod = 1e9 + 7;

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.setf(ios_base::fixed);
  cout.precision(15);

  int s;
  while (cin >> s) {
    const int S = 2000 + 20;
    static lli dp[S];
    fill(dp, dp + S, 0);
    dp[0] = 1;
    for (int i = 0; i <= s; ++i) {
      for (int j = 3; j <= s - i; ++j) {
        (dp[i + j] += dp[i]) %= mod;
      }
    }
    cout << dp[s] << endl;
  }

  return 0;
}


Measured memory_bytes: 3648
# B Path
a1,b1 = map(int,input().split())
a2,b2 = map(int,input().split())
a3,b3 = map(int,input().split())

path = [a1,b1,a2,b2,a3,b3]

if path.count(1) <=2 and path.count(2) <=2 and path.count(3) <=2 and path.count(4) <=2 :
    print('YES')
else:
    print('NO')

Measured memory_bytes: 3064
import java.util.*;
 
public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		int n = sc.nextInt();
		int alice = 0;
		int bob = 0;
		Integer[] ar = new Integer[n];
		for (int i=0; i<n; i++) {
			ar[i] = sc.nextInt();
		}
		Arrays.sort(ar,Comparator.reverseOrder());
		for (int i=0; i<n; i++) {
			int a = ar[i];
			if (i%2==0) {alice += a;}
			else {bob += a;}
		}
		System.out.println(Math.abs(alice-bob));
	}
}

Measured memory_bytes: 25044
#include <stdio.h>


int right_side_table[ 6 ][ 6 ] =
{
	//front=
	// 1    2    3    4    5    6
	{ -1 ,  3 ,  5 ,  2 ,  4 , -1 },	//top=1
	{  4 , -1 ,  1 ,  6 , -1 ,  3 },	//2
	{  2 ,  6 , -1 , -1 ,  1 ,  5 },	//3
	{  5 ,  1 , -1 , -1 ,  6 ,  2 },	//4
	{  3 , -1 ,  6 ,  1 , -1 ,  4 },	//5
	{ -1 ,  4 ,  2 ,  5 ,  3 , -1 },	//6
};

int judge( const int* number_table1 , const int* number_table2 , int top , int front , int right )
{
	if( number_table1[ 0 ] != number_table2[ top ] )
	{
		return 0;
	}
	if( number_table1[ 1 ] != number_table2[ front ] )
	{
		return 0;
	}
	if( number_table1[ 2 ] != number_table2[ right ] )
	{
		return 0;
	}
	if( number_table1[ 3 ] != number_table2[ 5 - right ] )
	{
		return 0;
	}
	if( number_table1[ 4 ] != number_table2[ 5 - front ] )
	{
		return 0;
	}
	if( number_table1[ 5 ] != number_table2[ 5 - top ] )
	{
		return 0;
	}
	return 1;
}

int main( int argc , char** argv )
{

    int number_table1[ 6 ];
    scanf( "%d %d %d %d %d %d" ,
        &number_table1[ 0 ] ,
        &number_table1[ 1 ] ,
        &number_table1[ 2 ] ,
        &number_table1[ 3 ] ,
        &number_table1[ 4 ] ,
        &number_table1[ 5 ] );

	int number_table2[ 6 ];
    scanf( "%d %d %d %d %d %d" ,
        &number_table2[ 0 ] ,
        &number_table2[ 1 ] ,
        &number_table2[ 2 ] ,
        &number_table2[ 3 ] ,
        &number_table2[ 4 ] ,
        &number_table2[ 5 ] );
 
	for( int top = 0 ; top < 6 ; top++ )
	{
		for( int front = 0 ; front < 6 ; front++ )
		{
			int right = right_side_table[ top ][ front ] - 1;
			if( judge( number_table1 , number_table2 , top , front , right ) )
			{
				printf( "Yes\n" );
				return 0;
			}
		}
	}
	printf( "No\n" );
	return 0;
}

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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(); // 3add el arkam
		int[] arr = new int[n];
		int flag = 0;
		for (int i =0; i<n; i++) {
			arr[i]=sc.nextInt();
		}
		Arrays.sort(arr);
		for (int i = 0; i < n-1; i++) {
			if (arr[i] == arr[i + 1]) {
				flag = 1;
				break;

			}

		}
		if (flag == 1) {
			System.out.println("NO");
		} else {
			System.out.println("YES");
		}

	}

}


Measured memory_bytes: 67036
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
    ll X,a,b;
    cin >> X;
    a = X/500;
    b = (X-a*500)/5;
    cout << a*1000+b*5 << endl;
    return 0;    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1e7 + 1;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector < pair<ll, ll > > vp;
typedef vector <string> vs;
typedef vector <char> vc;
typedef list <ll> lst;

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

#define Endl endl


/*--------------------template--------------------*/


int main() {
    cin >> n;
    REP(i, n) {
        cin >> m >> k;
        ans += k - m + 1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
 
#define MAXLEN 20000
 
int garea,gareas[(MAXLEN/2)+1],gcnt;
 
 
int getArea( char *inputs, int start, int end )
{
    int i;
    int ravine,water;
    
    gareas[gcnt]=water=ravine=0;
    for( i=start; i<=end; i++ ) {//&& '\0'!=*(inputs+i)
        if( '\\'== *(inputs+i) ) {
            water+=(ravine*2);
            ravine++;
            water++;
        } else if( 0 < ravine && '/' == *(inputs+i) ) {   
            ravine--;
            if( 0 == ravine ) {
                gareas[gcnt]+=water;
                break;
            }           
        } else {
	     	gareas[gcnt]+=ravine;
        }       
    }
 
    return gareas[gcnt];
}
  
int checkRavine( char *inputs, int start )
{
    int i;
    int ravine;
    
    ravine=0;
    for( i=start; '\0'!=*(inputs+i); i++ ) {
        if( '\\'== *(inputs+i) ) {
            ravine++;
        } else if( 0 < ravine && '/' == *(inputs+i) ) {   
            ravine--;
            if( 0 == ravine ) {
            	garea+=getArea( inputs, start, i );
            	gcnt++;
                return i-start;
            }           
        }
    }
    return 0;
}
 
 
void getAreas( char *inputs )
{
    int i,next;
     
    next=0;
    for( i=0; '\0'!=inputs[i]; i++ ) {
        next=checkRavine( inputs, i );
        i+=next;
    }
 
    return;
}
 
int main( void ) 
{
    char inputs[MAXLEN+1];
    int i;
 
    scanf( "%s", inputs );
    garea=gcnt=0;
    getAreas( inputs );
     
    printf( "%d\n", garea );
    
    if( gcnt ) {
        printf( "%d ", gcnt );
        gcnt--;
        for( i=0; i<=gcnt; i++ ) {
            printf( "%d", gareas[i] );
            if( i < gcnt ) {
                printf( " " );  
            } else {
            	printf( "\n" ); 
            }
        }
    } else {
        printf( "0\n" );
    }
     
    return 0;
}

Measured memory_bytes: 572
#[allow(unused_imports)]
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::Chars;
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused)]
const ALPHA_SMALL: [char; 26] = [
    'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's',
    't', 'u', 'v', 'w', 'x', 'y', 'z',
];
#[allow(unused)]
const ALPHA: [char; 26] = [
    'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S',
    'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
];
#[allow(unused)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(unused)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(unused)]
fn read_touple<T: std::str::FromStr + Copy>() -> (T, T) {
    let v: Vec<T> = read_vec();
    assert_eq!(v.len(), 2);
    (v[0], v[1])
}
fn main() {
    input!(X: usize);
    let ans = match X {
        400..=599 => 8,
        600..=799 => 7,
        800..=999 => 6,
        1000..=1199 => 5,
        1200..=1399 => 4,
        1400..=1599 => 3,
        1600..=1799 => 2,
        _ => 1,
    };
    println!("{}", ans);
}


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

int arr[100001];
  

int main() {
int h,n;
cin>>h>>n;
int i=1;
int sum=0;
for(i=1;i<=n;i++)
{cin>>arr[i] ;
sum += arr[i];
}  

if (sum>=h)
cout<< "Yes";
else
cout<<"No";
    return 0;
}

Measured memory_bytes: 640
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <ios>
#include <iostream>
#include <vector>

#define ll long long

using namespace std;

ll N, M;
ll modulo = 1e9 + 7;

ll fact(ll a)
{
    return ((a == 1) ? 1 : (a * fact(a - 1) % modulo));
}

int main()
{
    cin >> N >> M;
    if (N == M) {
        cout << (fact(N) * fact(N) * 2 % modulo) << endl;
    } else if (abs(N - M) == 1) {
        cout << (fact(N) * fact(M) % modulo) << endl;
    } else {
        cout << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
using namespace std;
const long double EPS = 1e-8;
const long double INF = 1e12;
#define EQ(n,m) (abs((n)-(m)) < EPS)
typedef complex<long double> P;
typedef vector<P> VP;
#define X real()
#define Y imag()

vector<long double> solve_quadeq(long double a, long double b, long double c){
    vector<long double> ret;
    if(abs(a) < EPS){
        if(abs(b) > EPS) ret.push_back(-c/b);
        return ret;
    }
    long double d = b*b -4*a*c;
    if(abs(d) < EPS) d = 0;
    if(d < 0) return ret;
    if(d < 0) d = 0;
    ret.push_back((-b +sqrt(d))/(2*a));
    ret.push_back((-b -sqrt(d))/(2*a));
    return ret;
}

const long double g = 9.8;

int main(){
    int n;
    long double v;
    cin >> n >> v;
    VP p(n);
    for(int i=0; i<n; i++){
        long double x,y;
        cin >> x >> y;
        p[i] = P(x, y);
    }

    long double ans = abs(p[1] -p[0]);
    int pos = 1;
    while(pos < n-1){
        P launch = p[pos];
        P prevdir = p[pos] -p[pos-1];
        P nextdir = p[pos+1] -p[pos];
        //ジャンプしない
        if(arg(prevdir) < arg(nextdir) +EPS){
            ans += abs(nextdir);
            pos++;
            continue;
        }
        //ジャンプする
        //放物線の関数
        long double theta = arg(prevdir);
        long double vx = v *cos(theta);
        long double vy = v *sin(theta);
        for(; pos<n-1; pos++){
            //直線の式(y = rx+s)
            long double r,s;
            r = (p[pos+1].Y -p[pos].Y) /(p[pos+1].X -p[pos].X);
            s = -p[pos].X *r +p[pos].Y;
            //直線と放物線が交わる時間tの方程式(at^2 +bt +c = 0)
            long double a,b,c;
            a = g/2;
            b = r*vx -vy;
            c = r*launch.X -launch.Y +s;
            //交点をとる
            vector<long double> solt = solve_quadeq(a, b, c);
            bool solved = false;
            for(long double t: solt){
                if(t < EPS) continue;
                long double x = vx*t +launch.X;
                if(p[pos].X +EPS < x && x +EPS < p[pos+1].X){
                    P cp(x, -g*t*t/2 +vy*t +launch.Y);
                    ans += abs(cp -p[pos+1]);
                    pos++;
                    solved = true;
                    break;
                }
            }
            if(solved) break;
        }
    }
    cout << fixed << setprecision(10);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3648
n, a, b = map(int, input().split())
sum = 0
for i in range(0, n + 1):
    nlist = list(str(i))
    bflag = False
    keta_sum = 0
    for i2 in nlist:
        keta_sum += int(i2)
    if (a <= keta_sum and b >= keta_sum):
        sum += i
print(sum)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
 
using namespace std;
 
#define MAX 100010
#define INF LLONG_MAX/4
typedef long long ll;
 
struct State{
    ll v,cost;
 
    State(ll v,ll cost) :
	v(v),cost(cost) {}
 
    bool operator > (const State &s)const{
	return cost > s.cost;
    }
};
 
struct P{
    ll idx,cost;
    P(ll idx,ll cost) :
	idx(idx),cost(cost) {}
    bool operator < (const P &p)const{
	return cost < p.cost;
    }
};
 
struct Edge{
    ll to,cost;
 
    Edge(ll to,ll cost) :
	to(to),cost(cost) {}
};
 
ll N,M,d[MAX];
vector<Edge> G[MAX];
 
void dijkstra(){
    fill(d,d+N,INF);
    d[0] = 0;
    priority_queue<State,vector<State>,greater<State> > Q;
    Q.push(State(0,0));
    while(!Q.empty()){
	State s = Q.top(); Q.pop();
	ll v = s.v;
	if(d[v] < s.cost) continue;
	for(int i = 0 ; i < (int)G[v].size() ; i++){
	    Edge e = G[v][i];
	    if(d[v] + e.cost < d[e.to]){
		d[e.to] = d[v] + e.cost;
		Q.push(State(e.to,d[e.to]));
	    }
	}
    }
}
 
int main(){
    ll C,a,b,c,sum = 0;
    cin >> N >> M >> C;
    for(int i = 0 ; i < M ; i++){
	cin >> a >> b >> c;
	a--; b--;
	G[a].push_back(Edge(b,c));
	G[b].push_back(Edge(a,c));
	sum += c;
    }
    dijkstra();
    vector<P> v;
    for(int i = 0 ; i < N ; i++){
	v.push_back(P(i,d[i]));
    }
    sort(v.begin(),v.end());
    ll res = INF,dist = 0;
    set<ll> st;
    for(int i = 0 ; i < N ; i++){
	ll idx = v[i].idx;
	for(int j = 0 ; j < (int)G[idx].size() ; j++){
	    if(st.find(G[idx][j].to) != st.end()){
		dist += G[idx][j].cost;
	    }
	}
	st.insert(idx);
	res = min(res,sum-dist+v[i].cost*C);
    }
    cout << res << endl;
    return 0;
}

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

const int MAX = 510000;
const int MOD = 998244353;

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit()
{
    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;
    }
}

long long COM(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;
}
long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
int main()
{
    int N, M, K;
    cin >> N >> M >> K;
    COMinit();
    long long ans = 0;
    for (int i = 0; i <= K; i++)
    {
        long long tmp = COM(N - 1, i);
        long long tmp1 = M * modpow(M - 1, N - i - 1, MOD) % MOD;
        ans += (tmp1 * tmp) % MOD;
    }
    cout << ans % MOD << endl;
}


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

using namespace std;

int main(){
	int first=1,second=100000,n,m;
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int a,b;
		cin>>a>>b;
		
		first=max(a,first);
		second = min(b,second);
		}
		
		int ans = (second-first+1>0?second-first+1:0);
		cout<<ans;
	
	return 0;
	}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1 << 30;
#define MOD 1000000007LL
#define endl "\n"

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll A, B, N;
  cin >> A >> B >> N;
  if(A % B == 0){
    ll x;
    if(B == 1) x = 1;
    else x = min(B-1, N);
    cout << (A * x) / B - A * (x / B) << endl;
  }
  else{
    ll num = N;
    if(N % B == 0 && B != 1) num--;
    ll x = min(B-1, num);
    if(B == 1) x = 1;
    cout << (A * x) / B - A * (x / B) << endl;
  }
}

Measured memory_bytes: 3584