akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str[] = br.readLine().split(" ");

		int h = Integer.parseInt(str[0]);
		int w = Integer.parseInt(str[1]);

		String matrix[][] = new String[h][w];

		for (int i = 0; i < h; i++) {
			str = br.readLine().split("");
			for (int j = 0; j < w; j++) {
				matrix[i][j] = str[j];
			}
		}

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

		int dp[][] = new int[110][110];
		for (int i = 0; i < h; i++) {
			Arrays.fill(dp[i], Integer.MAX_VALUE);
		}

		if (matrix[0][0].equals("#"))
			dp[0][0] = 1;
		else
			dp[0][0] = 0;

		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				for (int k = 0; k < 2; k++) {
					int nx = j + dx[k];
					int ny = i + dy[k];

					if (ny >= h || nx >= w)
						continue;

					if (matrix[ny][nx].equals(".")) {
						dp[ny][nx] = Math.min(dp[ny][nx], dp[i][j]);
					} else {
						if (matrix[i][j].equals(".")) {
							dp[ny][nx] = Math.min(dp[ny][nx], dp[i][j] + 1);
						} else {
							dp[ny][nx] = Math.min(dp[ny][nx], dp[i][j]);
						}
					}
				}
			}
		}

		System.out.println(dp[h - 1][w - 1]);
	}
}


Measured memory_bytes: 34548
#include <bits/stdc++.h>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <cstring>
    #include <chrono>
    #include <complex>
    #define endl "\n"
    #define int long long int
    #define vi vector<int>
    #define vll vector<ll>
    #define vvi vector < vi >
    #define pii pair<int,int>
    #define pll pair<long long, long long>
    #define mod 1000000007
    #define inf 1000000000000000001;
    #define all(c) c.begin(),c.end()
    #define mp(x,y) make_pair(x,y)
    #define mem(a,val) memset(a,val,sizeof(a))
    #define eb emplace_back
    #define f first
    #define s second
    
    using namespace std;
int power(int base, int exp)
{
    if (exp == 0)
       return 1;
    else if (exp == 1)
       return base;
    else
    {
       int calc;
       if (exp % 2 == 0)
       {
         calc = power(base, exp/2);
         calc =(calc* calc)%mod;
       }
       else
       {
         calc = (base*power(base, exp-1))%mod;
       }
       return calc%mod;
    }
}
    int32_t main()
    {
        std::ios::sync_with_stdio(false);
        int a[5];
        int res=0;
        for(int i=0;i<5;i++)
        {
            
        
            cin>>a[i];
            if(a[i]==0)
            {
                res=i;
            }
        }
        cout<<res+1<<endl;
        return 0;
    }


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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	long long n;
	cin >> n;
	string ans;
	while (n > 0) {
		n--;
		ans += char('a' + n % 26);
		n /= 26;
	}
	reverse(ans.begin(), ans.end());
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 3600
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

int block2[64][64];
int block[64][64];
int ba[64][64];
int blocknum[64];               // isÌ^CÌ
int banum[64];

int main() {
  int t;
  cin >> t;
  while(t--) {
    int h,w;
    cin >> h >> w;
    REP(i, h) {
      REP(j, w) {
        char c; cin >> c;
        block2[i][j] = (c=='#');
      }
    }
    int h1 = -1, h2;
    REP(i, h) {
      bool f = 0;
      REP(j, w) if (block2[i][j]) f = 1;
      if (f) {
        if (h1 == -1) h1 = i;
        h2 = i;
      }
    }
    int w1 = -1, w2;
    REP(i, w) {
      bool f = 0;
      REP(j, h) if (block2[j][i]) f = 1;
      if (f) {
        if (w1 == -1) w1 = i;
        w2 = i;
      }
    }
    int cnth=0;
    for (int i=h1; i<=h2; ++i) {
      int cntw = 0;
      for (int j=w1; j<=w2; ++j) {
        block[cnth][cntw] = block2[i][j];
        cntw++;
      }
      cnth++;
    }
    h = cnth; w = w2-w1+1;
    
    int H, W;
    cin >> H >> W;
    REP(i, H) {
      banum[i] = 0;
      REP(j,W) {
        char c;
        cin >> c;
        ba[i][j] = (c == '#');
        if (c == '#') banum[i]++;
      }
    }
    int ans = -1;
    REP(i, 4) {
      // REP(j, h) {
      //   REP(k, w) cout << block[j][k];
      //   cout << endl;
      // }
      // esÌ^CÌvZ
      REP(j, h) {
        blocknum[j] = 0;
        REP(k, w) if (block[j][k]) blocknum[j]++;
      }
      
      for (int j=0; j<H-h+1; ++j) {
        for (int k=0; k<W-w+1; ++k) {
          bool dame = 0;
          for (int l=0; l<h; ++l) {
            for (int m=0; m<w; ++m) {
              if (block[l][m] && ba[j+l][k+m]) {
                dame = 1;
                break;
              }
            }
            if (dame) break;
          }
          if (!dame) {
            //cout << j << " " << k << endl;
            int hoge = 0;
            REP(l, h) {
              if (blocknum[l] + banum[j+l] == W) hoge++;
            }
            ans = max(ans, hoge);
          }
        }
      }
      // ñ]
      int next[64][64];
      REP(j, w) {
        REP(k, h) {
          next[j][k] = block[k][w-j-1];
        }
      }
      swap(w,h);
      memcpy(block, next, sizeof(next));
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
#define mod 998244353
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pi pair<ll,ll>
#define endl "\n"
using namespace std;
const ll N=500010;



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

    ll n;
    cin>>n;
    vector<ll> adj[n+1];
    for(ll i=2;i<=n;++i){
        ll x;
        cin>>x;
        adj[x].pb(i);
    }
    for(ll i=1;i<=n;++i){
        cout<<adj[i].size()<<endl;
    }

    return (0);
}


Measured memory_bytes: 14532
#include <cstdio>

using namespace std;

long long gcd(long long a, long long b)
{
	if (a<b) {
		long long tmp = a; a = b; b = tmp;
	}
	long long tmp;
	while (b!=0) {
		tmp = b;
		b = a%b;
		a = tmp;
	}
	return a;
}


int main()
{
	//freopen("in.txt", "r", stdin);

	long long a, b;

	while (scanf("%lld%lld", &a, &b)==2) {
		long long v1 = gcd(a, b);
		long long v2 = a*b/v1;

		printf("%lld %lld\n", v1, v2);

	}

	return 0;
}

Measured memory_bytes: 1024
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <set>
using namespace std;

#define INF (1ll<<60)

int n,k;
vector<int>dp;
vector<int>a;

long long M = 1000000007;

int solve(int i){
    if(dp[i]!=-1)return dp[i];
    bool res = false;
    for(int l=0;l<n;++l)if(i-a[l]>-1&&solve(i-a[l])==0)res = true;
    if(res)dp[i]=1;
    else dp[i]=0;
    return dp[i];
}

int main(int argc, char const *argv[]) {
    cin>>n>>k;
    dp = vector<int>(k+1,-1);
    a = vector<int>(n);
    for(int i=0;i<n;++i)cin>>a[i];
    if(solve(k)==1)cout<<"First"<<endl;
    else cout<<"Second"<<endl;
    return 0;
}

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

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

void fill(vector<vector<int> >& m, int y, int x, int from, int to){
    if(from==to) return;
    if(m[y][x]!=from) return;
    m[y][x] = to;
    for(int i=0; i<4; i++){
        fill(m, y+dy[i], x+dx[i], from, to);
    }
}

int _count(vector<vector<int> >& m, int y, int x, int color){
    if(m[y][x]!=color) return 0;
    m[y][x] = 0;
    int cnt=1;
    for(int i=0; i<4; i++){
        cnt += _count(m, y+dy[i], x+dx[i], color);
    }
    return cnt;
}

int count(vector<vector<int> > m, int color){
    return _count(m, 1, 1, color);
}

int search(vector<vector<int> > m, int step, int final){
    if(step==4){
        fill(m, 1, 1, m[1][1], final);
        return count(m, m[1][1]);
    }else{
        vector<vector<int> > tmp = m;
        int most=0;
        for(int i=1; i<=6; i++){
            m = tmp;
            fill(m, 1, 1, m[1][1], i);
            most = max(most, search(m, step+1, final));
        }
        return most;
    }
}
    

int main(){
    while(1){
        int h,w,c;
        cin >> h >> w >> c;
        if(h==0) break;

        vector<vector<int> > panel(h+2, vector<int>(w+2, 0));
        for(int i=1; i<=h; i++){
            for(int j=1; j<=w; j++){
                cin >> panel[i][j];
            }
        }

        int ans = search(panel, 0, c);
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3148
N = int(input())
A = [int(x) for x in input().split()]
i = 0
money = 1000
while i < N-1:
    today = i
    j = i + 1
    while A[i] <= A[j]:
        i += 1; j += 1
        if j == N:
            break
    money += (money // A[today]) * (A[i] - A[today])
    i = j
print(money)

Measured memory_bytes: 80332
#!/usr/bin/env python

def main():
    N, Z, W = map(int, input().split(" "))
    a = list(map(int, input().split(" ")))
    
    if N == 1:
        print(abs(a[0] - W))
    else:
        print(max(abs(a[N - 1] - W), abs(a[N - 2] - a[N - 1])))

if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<utility>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#define EPS 1e-9
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define LL long long
const int MOD = 1E9+7;
const int N = 200000+5;
const int dx[] = {-1,1,0,0,-1,-1,1,1};
const int dy[] = {0,0,-1,1,-1,1,-1,1};
using namespace std;
struct Edge{
    int x,y;
    int dis;
    Edge(){}
    Edge(int x,int y,int dis):x(x),y(y),dis(dis){}
    bool operator <(const Edge &rhs)const{
        return dis<rhs.dis;
    }
}edge[N];
int tot;
struct Node{
    int x,y;
}node[N];
int father[N];

bool cmpX(int a,int b){
    return node[a].x<node[b].x;
}
bool cmpY(int a,int b){
    return node[a].y<node[b].y;
}
int Find(int x){
    if(father[x]!=x)
        return father[x]=Find(father[x]);
    return x;
}
int n;
int Kruskal(){
    for(int i=1;i<=n;i++)
        father[i]=i;

    int mst=0;
    sort(edge+1,edge+1+tot);
    for(int i=1;i<=tot;i++){
        int x=Find(edge[i].x);
        int y=Find(edge[i].y);
        if(x!=y){
            mst+=edge[i].dis;
            father[x]=y;
        }
    }
    return mst;
}
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d%d",&node[i].x,&node[i].y);

    for(int i=1;i<=n;i++)
        father[i]=i;
    sort(father+1,father+1+n,cmpX);
    for(int i=1;i<n;i++){
        int x=father[i];
        int y=father[i+1];
        int dis=node[y].x-node[x].x;
        edge[++tot]=Edge(x,y,dis);
    }

    for(int i=1;i<=n;i++)
        father[i]=i;
    sort(father+1,father+1+n,cmpY);
    for(int i=1;i<n;i++){
        int x=father[i];
        int y=father[i+1];
        int dis=node[y].y-node[x].y;
        edge[++tot]=Edge(x,y,dis);
    }
    int mst=Kruskal();
    printf("%d\n",mst);

    return 0;
}


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

void swap(int *a, int *b);

int main() {
	int a;
	int b;
	int c;
	cin >> a >> b >> c;
	if (a > b) {
		swap(&a, &b);
	}
	if (a > c) {
		swap(&a, &c);
	}
	if (b > c) {
		swap(&b, &c);
	}
	cout << a << ' ' << b << ' ' << c << endl;
	return 0;
}

void swap(int *a, int *b) {
	int t;
	t = *a;
	*a = *b;
	*b = t;
}

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

using namespace std;

typedef long long ll;

int main() {
    int ans = 1;
    int n;
    cin >> n;
    vector<int> pos(n + 1);
    for (int i = 0; i < n; ++i) {
        int t;
        cin >> t;
        pos[t] = i;
    }
    int k = 1;
    for (int i = 2; i <= n; ++i) {
        if (pos[i] > pos[i - 1]) {
            ++k;
        } else {
            k = 1;
        }
        ans = max(ans, k);
    }
    cout << n - ans;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>
using namespace std;
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define print(x) cout<<(x)<<'\n'
#define print_vec(v) rep(i,v.size()){if(i!=0)cout<<" ";cout<<v[i];}cout<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<'\n'
#define pb push_back
#define mp make_pair
#define MOD 1000000007 //10^9+7
#define fi first
#define sc second
using ll=long long;
using pi=pair<int,int>;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
using vstr=vector<string>;
int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};
void Yes(bool c) { if (c)print("Yes"); else print("No"); };
void YES(bool c) { if (c)print("YES"); else print("NO"); };

void solve() {
    int n;
    cin >> n;
    vll a(n),b;
    rep(i,n){
        cin >> a[i];
    }


    for(int i=n-1;i>=0;i-=2){
        b.pb(a[i]);
    }
    for(int i=n%2;i<n;i+=2){
        b.pb(a[i]);
    }

    rep(i,n){
        if(i!=0) cout << " ";
        cout << b[i];
    }
    cout << '\n';
}
 
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
	cout<<fixed<<setprecision(20);
    //int q; cin >> q;
	//while (q--)
		solve();
    return 0;
}

Measured memory_bytes: 6868
#include <iostream>
#include <string>
 
using namespace std;
 
int main(){
  string s;
  int a[26] = {0};
  cin >> s;
  
  for(int i = 0; i < s.length(); i++){
    a[s[i] - 'a']++;
  }
  
  for(int i = 0; i < 26; i++){
    if(a[i] % 2 != 0){
      cout << "No" << endl;
      return 0;
    }
  }
  
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
# Atcoder necoak answer
# https://atcoder.jp/contests/abc126/tasks/abc126_c
from math import log2,ceil

intext1 = input()
[n, k] = map(int, intext1.split())

kakuritu = 0.0
for v in range(1, n+1):
    if v >= k:
        tmp_kakuritu = 1 / n
        kakuritu += tmp_kakuritu
    else:
        x = ceil(log2(k/v))
        #
        tmp_kakuritu = 1 / n / 2**x
        kakuritu += tmp_kakuritu

print(kakuritu)


Measured memory_bytes: 3060
N = int(input())
A = list(map(int, input().split()))
INF = 10 ** 18

if A.count(0) > 0:
    print(0)
    exit()
ans = A[0]
for i in range(1,N):
    ans = ans * A[i]
    if ans > INF:
        print(-1)
        exit()
print(ans)


Measured memory_bytes: 21668
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int N,M;
    cin >> N >> M;
    int ans=N*(N-1)/2+M*(M-1)/2;
    cout << ans << endl;



}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
using namespace std;
using ll = long long;




int main() {
	int n, a;
	cin >> n >> a;
	n %= 500;
	if (n <= a) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
class solver
{
	public:
		void solve()
		{
			int n;
			char C;
			cin>>C;
			n=C+1;
			printf("%c\n", n);
		}
};
int main()
{
	solver Solver;
	Solver.solve();
}

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

int main() {
  int n; cin >> n;
  double x[n], y[n]; for (int i = 0; i < n; ++i) cin >> x[i] >> y[i];

  vector<int> t(n); for (int i = 0; i < n; ++i) t[i] = i;
  int count = 0;
  double res = 0.0;
  do {
    for (int i = 1; i < n; ++i) {
      int j = t[i];
      int k = t[i - 1];
      res += sqrt((x[j] - x[k]) * (x[j] - x[k]) + (y[j] - y[k]) * (y[j] - y[k]));
    }
    count++;
  } while (next_permutation(t.begin(), t.end()));

  cout << fixed << setprecision(10);
  cout << res / count << endl;

}

Measured memory_bytes: 3732
#pragma region

#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define _rep3(i, begin, end) for (register int i = (begin), i##_end = (end); i < i##_end; i++)
#define _irep3(i, begin, end) for (register int i = (end)-1, i##_begin = (begin); i >= i##_begin; i--)
#define _rep2(i, n) _rep3(i, 0, n)
#define _irep2(i, n) _irep3(i, 0, n)
#define _overload3(_1, _2, _3, name, ...) name
#define rep(...) _overload3(__VA_ARGS__, _rep3, _rep2, )(__VA_ARGS__)
#define irep(...) _overload3(__VA_ARGS__, _irep3, _irep2, )(__VA_ARGS__)
#define out(x) cout << (x) << '\n';
#define debug(x) cerr << #x << " = " << (x) << " (line: " << __LINE__ << ") " << endl;

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<long long>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<long long>>;
using vvb = vector<vector<bool>>;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (auto &v : vec) is >> v;
  return is;
}
template <typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &pair) {
  cin >> pair.first >> pair.second;
  return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "[ ";
  rep(i, vec.size()) i == 0 ? os << vec[i] : os << ", " << vec[i];
  os << " ]";
  return os;
}

template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

template <class T>
bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

void init() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(16) << boolalpha;
}

#pragma endregion

#define MOD 1000000007
#define INF 2147483647

int main() {
  init();

  ll N, A, B;
  cin >> N >> A >> B;

  ll ans = N / (A + B) * A + min(N % (A + B), A);

  out(ans);
}


Measured memory_bytes: 256
import fractions
from functools import reduce

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
  
n = int(input())
a = list(map(int, input().split()))
ans = 0
x = lcm_list(a) - 1
for i in range(n):
  ans += x%a[i]
print(ans)

Measured memory_bytes: 5348
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner stdIn = new Scanner(System.in);
        int a = stdIn.nextInt();
        int b = stdIn.nextInt();
        if(a > b)
            System.out.println("a > b");
        else if(a < b)
            System.out.println("a < b");
        else
             System.out.println("a == b");
    }
}

Measured memory_bytes: 26104
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
typedef long long   ll;
#define pb                push_back
#define mp                make_pair
#define all(a)            (a).begin(), (a).end()
#define clr(a,h)          memset(a, (h), sizeof(a))
#define mem(a,h)          memset(a, (h), sizeof(a))
#define fi first
#define se second
#define por(a,b) (((a%MOD) * (b%MOD))%MOD)
#define forg(i, b, e, c)    for (ll i = (ll)b; i < (ll)e; i+=c)
#define forr(i, b, e)    for (ll i = b; i < e; i++)
 
 
using namespace std;
//using namespace __gnu_pbds;
typedef double lldb;
typedef pair<ll, ll>  ii;
typedef pair<ll, ii>  iii;
typedef vector<ll>     vi;
typedef vector<vi>     vvi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;
//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
const ll INF = 1e9;
const double PI = acos(-1);
#define tam 300000
#define offset 
const ll MOD= 1e9+7;



#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {

template < class c > struct rge { c b, e; };
template < class c > rge<c> range(c i, c j) { return rge<c>{i, j}; }
template < class c > auto dud(c* x) -> decltype(cerr << *x, 0);
template < class c > char dud(...);

struct debug {
    ~debug() { cerr << endl; }
    
    //     Part 1
    
    template < class c > typename \
    enable_if<sizeof dud<c>(0) != 1, debug&>::type operator<<(c i) {
        cerr << boolalpha << i;
        return * this;
    }
    
    //     Part 2
    
    template < class c > typename \
    enable_if<sizeof dud<c>(0) == 1, debug&>::type operator<<(c i) {
        return * this << range(begin(i), end(i)); 
    }
    
    //   Part 3
    
    template < class c, class b > debug & operator << (pair < b, c > d) {
        return * this << "(" << d.first << ", " << d.second << ")";
    }
    
    //   Part 4
    
    template < class c > debug & operator <<(rge<c> d) {
        *this << "[";
        for (auto it = d.b; it != d.e; ++it)
            *this << ", " + 2 * (it == d.b) << *it;
        return * this << "]";
    }
    
};
#define qwer(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

int main()
{
    ios::sync_with_stdio(false);cin.tie(0);
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    forr(i,0,1e9)
    {
        if (i%2==0)
            c-=b;
        else
            a-=d;
        //cout<<a<<' '<<c<<endl;
        if (a<=0)
        {
            cout<<"No\n";
            return 0;
        }
        if (c<=0)
        {
            cout<<"Yes\n";
            return 0;
        }
    }
    

}
// PLUS ULTRA!
    

Measured memory_bytes: 3640
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class A
{
	public static void Main()
	{
		HashSet<int> set = new HashSet<int>();
		set.Add(GetInt());
		set.Add(GetInt());
		set.Add(GetInt());
		Console.WriteLine(set.Count);
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}

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

using namespace std;

typedef long long ll;

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

int solve(const int N, const vector<int> &a) {
    int cur = 0;
    for (int i = 0; i < N; i++) {
        if (a[i] == cur + 1) {
            cur++;
        }
    }
    return cur;
}

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

    vector<int> a(N);
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }

    int rems = solve(N, a);
    if (rems == 0) {
        cout << -1 << endl;
    } else {
        cout << N - rems << endl;
    }

    return 0;
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
long n ;
 
int main() {
  cin >> n;
  string ans = "No";
  for(int i=1;i<10 ;i++){
    if(n%i==0){
      if(n/i <= 9)ans = "Yes";
    }
  }
  cout << ans << endl;
}

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

#define mp make_pair
#define pb push_back

#define int int64_t

const int MOD = 1e9+7;
 
int mpow(int x, int y)
{
	if(y==0)
		return 1;
	int temp=mpow(x,y/2);
	if(y&1)
	{
		return (((temp*temp)%MOD)*x)%MOD;
	}
	else
		return (temp*temp)%MOD;
}


int32_t main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);

 	int x,y;
 	cin>>x>>y;
 	if(x>2*y||y>2*x)
 	{
 		cout<<0;
 		return 0;
 	}
 	if(((2*y-x)%3)||((2*x-y)%3))
 	{
 		cout<<0;
 		return 0;
 	}

 	int a=(2*y-x)/3;
 	int b=(2*x-y)/3;

 	int ans=1;

 	for(int i=1;i<=a+b;i++)
 	{
 		ans*=i;
 		ans%=MOD;
 	}
 	for(int i=1;i<=a;i++)
 	{
 		ans*=mpow(i,MOD-2);
 		ans%=MOD;
 	}

 	for(int i=1;i<=b;i++)
 	{
 		ans*=mpow(i,MOD-2);
 		ans%=MOD;
 	}

 	cout<<ans;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
#define U 998244353
#define N 1000005
#define int long long
#define sz(c) (int)c.size()
#define fr first
#define ll long long 
#define sc second
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rep(i,a,n) for(int i=a ; i<n ; i++)
#define r0 return 0;
#define endl '\n'
#define INF (int)1e15

/* Debug Begins */ 
# define trace(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
  stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
string to_string(char c) { return "'" + string(1, c) + "'";}
string to_string(string s) { return '"' + s + '"';}
string to_string(bool f) { if(f) return "True"; else return "False";}
string to_string(const char* s) { return to_string((string) s);}
template<typename A> string to_string(A);
template<typename A, typename B> string to_string(pair<A, B> p){
  return "(" + to_string(p.first) + ": " + to_string(p.second) + ")";}
template<typename A> string to_string(A v) {bool f = false; string r = "{"; 
  for (auto x: v) {if (f) r += ", "; r += to_string(x); f = true;} return r += "}";}
template<typename A> string to_string(vector<vector<A>> v) {string r; 
  for (auto x: v) r += "\n" + to_string(x); return r;}
int Nerr;
template<typename A> string to_string(A *p) {return to_string(vector<A>(p, p + Nerr));}
void err(istream_iterator<string>) { cerr << endl; }
template<typename T,typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << to_string(a) << "; "; err(++it, args...); }
template<typename T> void kek(T ans) {cout << ans << endl; exit(0);}
#define Lu(...) [&] (auto &&u) { return __VA_ARGS__; }
#define Luv(...) [&] (auto &&u, auto &&v) { return __VA_ARGS__; }
/***************************************************************/



signed main()
{
	ios_base::sync_with_stdio(0);
	int TESTS=1;
	// cin>>TESTS;
	while(TESTS--)
	{   
		int n,k;
		cin >> n >> k;
		vector<int> a(n+1);
		rep(i,1,n+1) cin >> a[i];
		vector<string> ans;
		rep(i,k+1,n+1){
			if(a[i] > a[i-k]) ans.pb("Yes");
			else ans.pb("No");
		}
		for(auto j : ans) cout << j << endl;
	}
}

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
#define int ll

signed main(void)
{
  int n;
  while(cin >> n) {
    cout << (n*n+n+2)/2 << endl;
  }
  return 0;
}

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

int main()
{
	int a,b,c,d,e;
	cin>>a>>b>>c>>d>>e;
	if(a==0)cout<<1;
	if(b==0)cout<<2;
	if(c==0)cout<<3;
	if(d==0)cout<<4;
	if(e==0)cout<<5;
	return 0;
} 

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

#define ll long long
#define endl "\n"
#define ios ios_base::sync_with_stdio(0); cout.tie(0); cin.tie(0);

using namespace std;

const ll mod = 1e9 + 7;

int main() {
    ios
    int n;
    cin >> n;
    ll ans = 0, a[n], sum = 0;
    for (int i = 0; i < n; ++ i) {
        cin >> a[i];
        ans += sum * a[i];
        ans %= mod;
        sum += a[i];
        sum %= mod;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 5212
s = list(input())
out = ''

for i in range(len(s)):
    #print("s[{}] = {}".format(i, s[i]))
    if s[i] == "B":
        if out:
            out = out[:-1]
            
    elif s[i] == "0":
        out = out + "0"

    elif s[i] == "1":
        out = out + "1"

print(out)


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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    short h,w,ans = 0;
    cin >> h >> w;
    string ai;
    rep(i,h) {
        cin >> ai;
        rep(j,w) if (ai[j] == '#') ans ++;
    }
    if (ans == h+w-1) cout << "Possible\n";
    else cout << "Impossible\n";
}

Measured memory_bytes: 3632
#include <stdlib.h>
#include <cmath>
#include <cstdio>
#include <cstdint>
#include <string>
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
using namespace std;
using ll = long long;

int main(){
  int N;
  cin >> N;
  vector<ll> L;
  L.push_back(2);
  L.push_back(1);

  if(N<=1){
    cout << L.at(N) << endl;
    return 0;
  }

  for(int i=2;i<=N;i++){
    L.push_back(L.at(i-1)+L.at(i-2));
  }

  cout << L.at(N) << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long int;
constexpr int  mod = 1e9 + 1;
int main() {
	ll x; cin >> x;
	ll res = 100; int c = 0;
	for (ll i = 100; i <= x; ++i) {
		if (res >= x)break;
		res += (res / 100); c++;
	}
	cout << c;
	return 0;
}

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


int main() {
    int n;
    cin>>n;
    char s[n];
    cin>>s;

    char* adr = s;
    int ans = 0;

    while(strstr(adr,"ABC") != NULL){
        adr = strstr(adr,"ABC");
        adr += 3;
        ++ans;
    }

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

Measured memory_bytes: 256
object Main extends App {
  val src: List[Int] = io.Source.stdin.getLines.map(_.toInt).toList

  val maxVal: Int = src.max

  val countedList: List[Int] = (for (i <- 1 to maxVal) yield (src.count(_ == i))).toList

  val maxModes = countedList.max

  def countLiWithIndex(li: List[Int]): List[(Int, Int)] = li.zipWithIndex

  def pickModes(li: List[(Int, Int)]): List[Int] = {
    for { tup <- li
        if (tup._1 == maxModes)
    } yield {
      tup._2 + 1
    }
  }

  pickModes(countLiWithIndex(countedList)).foreach(println)
}

Measured memory_bytes: 44168
S = list(input())
if S[0] == "A" and S[2:-1].count("C") == 1:
    S.remove("A")
    S.remove("C")
    count = 0
    for i in range(len(S)):
        if S[i].islower():
            count += 1
    if count == len(S):
        print("AC")
    else:
        print("WA")
else:
    print("WA")

Measured memory_bytes: 3060
#include <stdio.h>

using namespace std;

int main(){
	int a,b;
	while(true){
		scanf("%d %d",&a,&b);
		if(a == 0 && b == 0) break;
		if(a > b) printf("%d %d\n",b,a);
		else{
			printf("%d %d\n",a,b);
		}
	}
}


Measured memory_bytes: 2692
import numpy as np
from numba import jit
N = int(input(''))
A1 = np.array(list(map(int, input('').split(' '))))

@jit(nopython=True)
def func(A):
    step = 0
    for k in range(0,N-1):
        if A[k] > A[k+1]:
            add = A[k] - A[k+1]
            step += add
            A[k+1] += add
    return step
        
print(func(A1))

Measured memory_bytes: 113232
# bfs?

def main():
    from collections import deque
    import sys
    input = sys.stdin.readline

    N, M = map(int, input().split())

    g = tuple(set() for _ in range(N))
    h = [0] * N  # 入り次数
    for _ in range(M):
        L, R, D = map(int, input().split())
        L -= 1
        R -= 1
        g[L].add((R, D))
        h[R] += 1

    dist = [-1] * N

    def bfs(s):
        dist[s] = 0
        dq = deque([s])
        while dq:
            v = dq.popleft()
            for u, d in g[v]:
                if ~dist[u]:
                    if dist[u] != dist[v] + d:
                        return False
                else:
                    dist[u] = dist[v] + d
                    dq.append(u)
        return True

    # 始点からのパスを処理
    for s in range(N):
        if h[s]: continue  # sに入ってくるパスがあるので、sを始点にしない
        # if ~dist[s]: continue
        if not bfs(s):
            print('No')
            return

    # サイクルを処理（どの点も入るパスがあり、処理できていない）
    for s in range(N):
        if ~dist[s]: continue
        if not bfs(s):
            print('No')
            return

    print('Yes')


if __name__ == '__main__':
    main()


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

int main() {
	double s;
	cin>>s;
	double length = double(double(s) / double(3)); 
  
    s -= length; 
  
    // finding breadth 
    double breadth = double(s / double(2)); 
  
    // finding height 
    double height = s - breadth; 
  	//cout
    cout<<fixed<<setprecision(12)<<height*length*breadth;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

void yes() {
  cout << "YES" << endl;
  exit(0);
}

void no() {
  cout << "NO" << endl;
  exit(0);
}

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  REP(i, n) cin >> a[i];
  ll sum = 0;
  REP(i, n) sum += a[i];
  if (sum % (n * (n + 1) / 2) != 0) {
    no();
  }
  auto idx = [&](ll i) { return (i + n) % n; };
  ll k = sum / (n * (n + 1) / 2);
  REP(i, n) {
    ll d = k + a[idx(i)] - a[idx(i + 1)];
    if (d % n != 0) no();
    ll t = d / n;
    if (t < 0 || k < t) no();
  }
  yes();
}

Measured memory_bytes: 1024
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return is_prime



n = 10 ** 5
prime_list = primes(n)
q = I()
C = [0] * (n + 1)
for i in range(n + 1):
    if i % 2 and prime_list[i] and prime_list[(i + 1) // 2]:
        C[i] = 1


for j in range(1, n + 1):
    C[j] += C[j - 1]

for i in range(q):
    l, r = LI()
    print(C[r] - C[l - 1])

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

typedef long long ll;
typedef pair<int,int> P;
int dx[] = {-1, 1, 0,  0};
int dy[] = { 0, 0, 1, -1};

 
int main(){
  int a[5];
  for(int i=0; i<5; i++){
    cin >> a[i];
  }
  int k;
  cin >> k;
  string ans = "Yay!";
  for(int i=0; i<5; i++){
    for(int j=0; j<5; j++){
      int tmp = abs(a[i]-a[j]);
      if(tmp>k) ans = ":(";
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3600
n,m,l = map(int,input().strip().split())

A,B,C = [],[],[]

for i in range(n):
    a = list(map(int,input().strip().split()))
    A.append(a)
    c = [0] * l
    C.append(c)
    
for j in range(m):
    b = list(map(int,input().strip().split()))
    B.append(b)
    
for i in range(n):
    for j in range(l):
        for k in range(m):
            C[i][j] += A[i][k] * B[k][j]
for x in C:
    print(*x)
        


Measured memory_bytes: 7052
n,m = map(int,input().split())
ab = [list(map(int,input().split())) for i in range(m)]

class UnionFind:
  def __init__(self, n):
    self.par = [-1] * (n+1)
    self.rank = [0] * (n+1)

  def find(self, x):
    if self.par[x] < 0:
      return x
    else:
      self.par[x] = self.find(self.par[x])
      return self.par[x]
  
  def same_check(self, x, y):
    return self.find(x) == self.find(y)
  
  def unite(self, x, y):
    x = self.find(x)
    y = self.find(y)
    
    if x == y:
      return False
    else:
      if self.par[x] > self.par[y]:
        x,y = y,x
        
      self.par[x] += self.par[y]
      self.par[y] = x

      return True

  def size(self, x):
    return -self.par[self.find(x)]

#
uni = UnionFind(n)
for i in range(m):
  uni.unite(ab[i][0],ab[i][1])

result = 0
for i in range(n):
  result = max(result, uni.size(i))
print(result)

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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin>>a[i];
  sort(a.rbegin(),a.rend());
  vector<int> point(2);
  
  rep(i,n){
    point[i%2]+=a[i];
  }
  cout << point[0]-point[1];
  return 0;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------


int N,M,Q;
int A[51],B[51],C[51],D[51];
int ma;

int V[11];

void dfs(int id,int v) {
	if(id==N+1) {
		int i,ret=0;
		FOR(i,Q) if(V[B[i]]-V[A[i]]==C[i]) ret+=D[i];
		ma=max(ma,ret);
		
		return;
	}
	
	int i;
	for(i=v;i<=M;i++) {
		V[id]=i;
		dfs(id+1,i);
	}
	
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>M>>Q;
	FOR(i,Q) {
		cin>>A[i]>>B[i]>>C[i]>>D[i];
	}
	dfs(1,1);
	cout<<ma<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 3656
#include<iostream>
#include<algorithm>
#include<math.h>
#include<string>
#include<set>
#include<map>
#include<stdlib.h>
#include<vector>
#include<utility>
#include<stdbool.h>
using namespace std;
typedef long long ll;
#define N (1000000000+7);

int main(void) {
	string s, t;
	cin >> s;
	for (int i = 0;i < s.length();i++) {
		if (s[i] == '0')t += "0";
		else {
			if (s[i] == '1')t += "1";
			else {
				if (t != "")t = t.substr(0, t.length() - 1);
			}
		}
	}
	cout << t << endl;
	return 0;

}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int main(){
  fastIO;
  int n;
  cin >> n;
  map<int,int> cnt;
  int a;
  ll ans = 0;
  for(int i = 1 ; i <= n ; i ++ ){
    cin >> a;
    ans += cnt[i-a];
    cnt[a+i]++;
  }
  cout << ans << "\n";
  return 0;
}

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

using namespace std;

int dp[21][(1 << 21)];
int can[21][21];
int n;

int main()
{
	 cin >> n;

	for (auto i = 0; i < n; i++)
		for (auto j = 0; j < n; j++)
			cin >> can[i][j];

	for (auto i = 0; i < n; i++)
		dp[0][1 << i] = can[0][i];

		for (auto mask = 1; mask < (1 << n); mask++)
		{
			auto i = __builtin_popcount(mask);
			if (i == 1) continue;
			for (auto j = 0; j < n; j++)
				if (can[i-1][j] && (mask & (1 << j))) {
					dp[i-1][mask] += dp[i - 2][mask ^ (1 << j)];
					dp[i-1][mask] %= (int)(1e9 + 7);
				}
		}
			

	cout << dp[n-1][(1<<n)-1] << endl;

}


Measured memory_bytes: 160000
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ll long long
#define vll vector<ll>
#define ld long double
#define pll pair<ll,ll>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define oset tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define osetll tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
#define ook order_of_key
#define fbo find_by_order
const int MOD=1000000007;
long long int inverse(long long int i){
    if(i==1) return 1;
    return (MOD - ((MOD/i)*inverse(MOD%i))%MOD+MOD)%MOD;
}
ll POW(ll a,ll b)
{
    if(b==0) return 1;
    if(b==1) return a%MOD;
    ll temp=POW(a,b/2);
    if(b%2==0) return (temp*temp)%MOD;
    else return (((temp*temp)%MOD)*a)%MOD;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n;
    cin>>n;
    string s[n];
    ll a[n],b[n];
    vector<pair<ll,ll> > v1,v2;
    for(int i=0;i<n;i++)
    {
        cin>>s[i];
        ll mx=0,temp=0;
        for(int j=0;j<s[i].size();j++)
        {
            if(s[i][j]==')') temp++;
            else temp--;
            mx=max(temp,mx);
        }
        a[i]=mx;
        temp=0;
        ll mn=0;
        for(int j=s[i].size()-1;j>=0;j--)
        {
            if(s[i][j]=='(') temp++;
            else temp--;
            mn=max(mn,temp);
        }
        b[i]=mn;
        //cout<<a[i]<<" "<<b[i]<<" ";
        if( (b[i]-a[i]) >0) v1.PB(MP(a[i],i));
        else v2.PB(MP(-b[i],i));
    }
    sort(v1.begin(),v1.end());
    sort(v2.begin(),v2.end());
    stack<ll> st;
    ll flag=0;
    for(int i=0;i<v1.size();i++)
    {
        string k=s[v1[i].S];
        for(int j=0;j<k.size();j++)
        {
            if(k[j]=='(') st.push(1);
            else
            {
                if(st.empty()) {flag=1; break;}
                else st.pop();
            }
        }
        if(flag==1) break;
    }
    if(flag==0)
    {
        for(int i=0;i<v2.size();i++)
        {
            string k=s[v2[i].S];
            for(int j=0;j<k.size();j++)
            {
                if(k[j]=='(') st.push(1);
                else
                {
                    if(st.empty()) {flag=1; break;}
                    else st.pop();
                }
            }
            if(flag==1) break;
        }
    }
    if(flag==0 && st.empty()) cout<<"Yes";
    else cout<<"No";
}


Measured memory_bytes: 69764
import java.util.*;
public class Main 
{
	public static void main(String[] args) 
	{
		Scanner stdIn = new Scanner(System.in);
		List<Double> list = new ArrayList<Double>();
		while(stdIn.hasNext())
		{
			double height = stdIn.nextDouble();
			if(height == 0)
			{
				break;
			}
			list.add(height);
		}
		Collections.sort(list);
		System.out.println(list.get(list.size() - 1) - list.get(0));
	}
}

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

int dx[]={0,1,-1,1};
int dy[]={1,0, 1,1}; //ツ可コツ右ツ偲篠づ淞債カツ偲篠づ淞右

int main()
{
	int N;
	while(scanf("%d", &N), N)
	{
		int f[256][256],ans=0;
		for(int i=0; i<N; i++)
		{
			getchar();
			for(int j=0; j<N; j++)
			{
				char t;
				scanf("%c", &t);
				f[j][i]=t-'0';
			}
		}
			
			
		for(int i=0; i<N; i++)
		for(int j=0; j<N; j++)
		{
			if(!f[j][i]) continue;
			
			for(int k=0; k<4; k++)
			{
				int cnt=1;
				int tx=j, ty=i;
				while(1)
				{
					tx+=dx[k], ty+=dy[k];
					if(tx<0||ty<0||tx>=N||ty>=N) break;
					if(!f[tx][ty]) break;
					
					cnt++;
				}
				
				ans=(cnt>ans?cnt:ans);
			}
		}
		
		printf("%d\n", ans);
	}
}

Measured memory_bytes: 1024
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
using namespace std;

typedef long long ll;

int main()
{
	ll n;
	cin >> n;
	cout << 3 * n*n;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <cstdio>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

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

typedef long long ll;

const int Inf = 100100100;
const double EPS = 1e-9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, a, b, c, d, e, ans, mini;
    cin >> n >> a >> b >> c >> d >> e;
    mini = min(a, min(b, min(c, min(d, e))));
    ans = (n + (mini - 1)) / mini + 4;
    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace ConsoleApplication2 {
    class Program {
        static void Main(string[] args) {

            TextReader input = Console.In;

            string str = "";

            while((str = input.ReadLine()) != null) {
                // スペースで区切る
                string[] works = str.Split(' ');
                // 2 個でない場合
                if (works.Length != 2) {
                    continue;
                }

                long a = long.Parse(works[0]);
                long b = long.Parse(works[1]);

                // 最大公約数
                long gcd = 0;

                // 1.入力を m, n (m ≧ n) とする。
                long m = a;
                long n = b;

                // m の方を大きくする
                if (m < n) {
                    m = b;
                    n = a;
                }

                while (true) {
                    // 2.n = 0 なら、 m を出力してアルゴリズムを終了する。
                    if (n == 0) {
                        gcd = m;
                        break;
                    }
                    // 3.m を n で割った余りを新たに n とし、更に 元のnを新たにm とし 2. に戻る。
                    long temp = n;
                    n = m % n;
                    m = temp;
                }

                // 最小公倍数
                if (gcd == 1) {
                    Console.WriteLine(gcd + " " + a * b);
                } else {
                    Console.WriteLine(gcd + " " + gcd * (a / gcd) * (b / gcd));
                }
            }
        }
    }
}

Measured memory_bytes: 5580
n = int(input())

words = {}
for i in range(n):
  word = input()
  if word in words:
    words[word] += 1
  else :
    words[word] = 1
words_sorted = sorted(words.items(), key=lambda x:x[1], reverse=True)    
score = words_sorted[0][1]
answers = []
for word in words_sorted:
  if score == word[1]:
    answers.append(word[0])
  else :
    break
    
for answer in sorted(answers) :
  print(answer)

Measured memory_bytes: 50056