akhauriyash/Code-Regression huggingface dataset:
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(),x=sc.nextInt();
    int[] a=new int[n+1];
    for(int i=0;i<n;i++)a[i]=sc.nextInt();
    a[n]=x;
    Arrays.sort(a);
    if(n==1) {
    	System.out.println(a[1]-a[0]);
    	System.exit(0);
    }
    int[] b=new int[n];
    for(int i=1;i<n+1;i++) {
    	b[i-1]=a[i]-a[i-1];
    }
    Arrays.sort(b);
    int g=GCD(b[0],b[1]);
    for(int i=2;i<n;i++) {
    	g=GCD(g,b[i]);
    }
    System.out.println(g);
  }
	public static int GCD(int min,int max) {
		if(max%min==0)return min;
		else return GCD(max%min,min);
	}
}


Measured memory_bytes: 49524
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 1, 0, -1, 0 }, dy[4] = { 0, 1, 0, -1 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)

struct INIT{
    INIT(){
        std::ios::sync_with_stdio(false);
        std::cin.tie(0);
        cout << fixed << setprecision(13);
    }
}INIT;

int h, n;
int a[101010], b[101010];
LL dp[20202];

int main(){
    cin >> h >> n;
    REP(i, n){
        cin >> a[i] >> b[i];
    }
    REP(i, 20202)dp[i] = HINF<LL>();
    dp[0] = 0;
    REP(i, n){
        for(int j = a[i];j < 20202;j++){
            dp[j] = min(dp[j], dp[j - a[i]] + b[i]);
        }
    }
    LL ans = HINF<LL>();
    for(int i = h;i < 20202;i++){
        ans = min(ans, dp[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
#include<stdio.h>
int a,b,n,t[20];
R(int r,int s,int j){
int i=j,o;
if(!r)if(b>abs(a-2*s))b=abs(a-2*s);
if(r<=0||n<=j)return;
for(;i<=n-r;i++)R(r-1,s+t[i],i+1);
}
main(){
int i;
while(scanf("%d",&n)&&n){
for(i=a=0;i<n;i++){scanf("%d",&t[i]);a+=t[i];}
b=a;
for(i=0;i<=n;i++)R(i,0,0);
printf("%d\n",b);
}
return 0;
}

Measured memory_bytes: 408
import java.util.Scanner;

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

	private static final void solve() {
		try (Scanner cin = new Scanner(System.in)) {
			int A = cin.nextInt();
			int B = cin.nextInt();
			int C = cin.nextInt();
			int D = cin.nextInt();
			int E = cin.nextInt();
			int F = cin.nextInt();

			int sugar = 0;
			int water = 0;

			double rate = 0;
			double rateMax = 0;
			double rateLimit = 100 * E / (double) (100 + E);

			int ans1 = 0;
			int ans2 = 0;

			int dx = -1;

			for (int ax = 0; ax <= F / 100; ax++) {
				for (int bx = 0; bx <= F / 100; bx++) {
					if (ax + bx == 0) {
						continue;
					}
					for (int cx = 0;; cx++) {
						for (dx = 0;; dx++) {
							water = 100 * A * ax + 100 * B * bx;
							sugar = C * cx + D * dx;
							rate = sugar * 100 / (double) (water + sugar);
							if (sugar + water > F || rate > rateLimit) {
								break;
							}
							if (rate >= rateMax) {
								rateMax = rate;
								ans1 = water + sugar;
								ans2 = sugar;
							}
						}
						if (dx == 0) {
							dx = -1;
							break;
						}
					}
				}
			}

			System.out.println(ans1 + " " + ans2);

		} finally {
		}
	}

}


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


int main ()
{
   cout<<fixed<<setprecision(10);
   int N,K,p;
   cin >>N>>K;
      double s=0;
      for(int i=1;i<=N;i++){
         int a=i;
         double t=1;
         while(a<K){
            a = a*2;
            t=t*2;
         }
      (double)N;
      s+=1.0/(N*t);
      }
    cout<<s<<endl;
   
}

Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define db long double
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()

void dout() { cerr << '\n'; }

template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << " " << H;
    dout(T...);
}

#ifdef LOCAL
    #define dbg(...) cerr << #__VA_ARGS__, dout(__VA_ARGS__)
#else
    #define dbg(...) ;
#endif

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair <int, int> pii;

int n;
map <int, int> q;

int main() {
    ios_base::sync_with_stdio(false), cin.tie(NULL);
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
    #endif

    cin >> n;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        q[-x]++;
    }
    int a = -1, b = -1;
    for (auto i : q) {
        if (i.se >= 4) {
            if (a == -1 && b == -1) {
                a = -i.fi;
                b = -i.fi;
            }
        }
        if (i.se >= 2) {
            if (a == -1) {
                a = -i.fi;
            }   else if (b == -1) {
                b = -i.fi;
            }
        }
    }
    if (b == -1) {
        cout << 0;
        return 0;
    }
    cout << (ll)a * b;
}


Measured memory_bytes: 4992
#include<iostream>
#include<cstdio>
#include<cmath>

using namespace std;

int main(){
    int a, b, C;
    double S, L, h, d;
    cin >> a >> b >> C;
    
    d = (acos(-1.0) * C) / 180.0;
    S = a * b * sin(d) / 2.0;
    L = a + b + sqrt(a*a + b*b -2 * a * b*cos(d));
    h = b * sin(d);
    
    printf("%lf\n%lf\n%lf\n", S, L, h);
    return 0;
}


Measured memory_bytes: 3480
//Lower
#include <iostream>
using namespace std;
int main() {
	int n;
	cin >> n;
	int a[n];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}

	int mc = 0, cp = a[0], cc = 0;
	for (int i = 0; i < n - 1; i++) {
		if (a[i] >= a[i + 1]) {
			cc += 1;
		}
		if (a[i] < a[i + 1]) {
			cc = 0;
		}
		mc = max (mc, cc);
	}
	cout << mc << endl;
	return 0;
}

Measured memory_bytes: 640
from collections import Counter

N = int(input())
L = list(map(int, input().split()))

c = Counter(L)
L = list(set(list(L)))

L.sort()

res = 0

for i in range(len(L) - 2):
  k = i
  for j in range(i + 1, len(L) - 1):
    while k < len(L) and L[k] < L[i] + L[j]:
      k += 1
    #print(i, j, k)
    for p in range(j + 1, k):
      res += c[L[i]] * c[L[j]] * c[L[p]]

print(res)

Measured memory_bytes: 9396
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <iterator>
#include <numeric>
#include <cstdint>
#include <cmath>
#include <bitset>
#include <string>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <random>
#include <chrono>

#define N_TIMES(i, n)     for ( uint64_t i = 0;     i <  n; ++i )
#define N_TIMES_REV(i, n) for (  int64_t i = n - 1; i >= 0; --i )

template<typename T> using maximum_heap = std::priority_queue<T, std::vector<T>, std::less<T>>;
template<typename T> using minimum_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<typename T>
std::istream& operator>>(std::istream &is, std::vector<T> &v)
{
  for (typename std::vector<T>::size_type i = 0; i < v.size(); ++i) {
    is >> v[i];
  }
  return is;
}

template<typename ID_TYPE = uint64_t>
class UnionFindTreeBase
{
private:
  std::vector<ID_TYPE> root, rank;

public:
  UnionFindTreeBase(ID_TYPE N)
  {
    root = std::vector<ID_TYPE>(N);
    for (ID_TYPE n = 0; n < N; ++n) { root[n] = n; }
    rank = std::vector<ID_TYPE>(N, 0);
  }

  ID_TYPE find(ID_TYPE x)
  {
    if (root[x] == x) { return x; }

    root[x] = find(root[x]);

    return root[x];
  }

  void unite(ID_TYPE x, ID_TYPE y)
  {
    ID_TYPE x_root = find(x), y_root = find(y);

    if (rank[x_root] > rank[y_root]) {
      root[y_root] = x_root;
    } else if (rank[x_root] < rank[y_root]) {
      root[x_root] = y_root;
    } else if (x_root != y_root) {
      root[y_root] = x_root;
      ++rank[x_root]; 
    }
  }

  bool is_same(ID_TYPE x, ID_TYPE y)
  {
    return find(x) == find(y);
  }

  ID_TYPE operator[](ID_TYPE x) {
    return find(x);
  }
};

typedef UnionFindTreeBase<uint64_t> UnionFindTree;

using namespace std;

int main()
{
  uint64_t N, M;
  cin >> N >> M;

  vector<uint64_t> A(M), B(M);
  N_TIMES(m, M) {
    cin >> A[m] >> B[m];
    --A[m]; --B[m];
  }

  UnionFindTree uf_tree(N);
  N_TIMES(m, M) {
    uf_tree.unite(A[m], B[m]);
  }

  vector<uint64_t> cnt(N, 0);
  N_TIMES(n, N) { ++cnt[ uf_tree[n] ]; }
  cout << (*max_element(cnt.cbegin(), cnt.cend())) << endl;

  return 0;
}

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

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

int date(int y,int m, int d){

  int ans=0;
  rep(i,y,1000){
    rep(j,m,10+1){
      if( i % 3 == 0)
	rep(k,d,20+1){
	  ans++;
	}
      else if( j % 2 != 0)
	rep(k,d,20+1){
	  ans++;
	}
      else
	rep(k,d,19+1){
	  ans++;
	}
      d = 1;
    }
    m = 1;
  }
  return ans;
}

int main(){

  int n;
  cin >> n;
  rep(i,0,n){
    int y,m,d;
    cin >> y >> m >> d;
    cout << date(y,m,d) << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int T = sc.nextInt();
		
		System.out.println(T / A * B); 
	}

}


Measured memory_bytes: 22608
use std::io;
use std::str::FromStr;

fn input<T:FromStr>() -> T {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.trim().parse().ok().unwrap()
}

fn input_i32_vec() -> Vec<i32> {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.split_whitespace().map(|s| s.parse().unwrap()).collect()
}

fn main() {
    let _: i32 = input();
    let mut a_vec = input_i32_vec();

    let mut sum = 0i32;
    for a in &a_vec {
        sum += *a;
    }
    sum /= 2;

    // calc mountain 1 
    for i in 1..a_vec.len()-1 {
        if i % 2 != 0 {
            sum -= a_vec[i];
        }        
    }
    
    print!("{} ", sum * 2);
    let mut pre = sum;    
    let mut i = a_vec.len();
    for a in a_vec {
        if i == 1 {
            break;
        }
        print!("{} ", (a - pre) * 2);
        pre = (a - pre);
        i -= 1;
    }
}


Measured memory_bytes: 6396
using System;

namespace ConsoleApplication3
{
    class Program
    {
        static void Main(string[] args)
        {
            string N = Console.ReadLine();
            string a = Console.ReadLine();
            int n = int.Parse(N);
            string[] ab = a.Split(' ');

            int[] num = new int[n];     //n???????????????????????±?????????
            for (int i = 0; i < n; i++)
            {
                num[i] = int.Parse(ab[i].ToString());       // string???int?????????
            }

            for (int i = num.Length - 1; i >= 0; i--)          //Length - 1????????£????????????
            {
                if (i == 0)
                {
                    Console.WriteLine(num[i]);      //??????
                }
                else
                {
                    Console.Write(num[i] + " ");
                }
            }
          
        }
    }
}

Measured memory_bytes: 9140
import java.util.*;
import java.io.*;

class Main {
	static PrintStream out = System.out;
	static Scanner in = new Scanner(System.in);

	public static void main(String[] args) {
		char[] cs = in.nextLine().toCharArray();
		int[] xs = new int[cs.length+1];
		for (int i = 0; i < cs.length; i++) {
			if (cs[i] == '\\') {
				xs[i+1] = xs[i] - 1;
			} else if (cs[i] == '/') {
				xs[i+1] = xs[i] + 1;
				if (xs[i+1] > 0) {
					xs[i+1] = 0;
					cs[i] = '_';
				}
			} else {
				xs[i+1] = xs[i];
			}
		}
		xs[xs.length - 1] = 0;
		for (int i = cs.length - 1; i >= 0; i--) {
			if (cs[i] == '\\') {
				xs[i] = xs[i+1] + 1;
				if (xs[i] > 0) {
					xs[i] = 0;
					cs[i] = '_';
				}
			} else if (cs[i] == '/') {
				xs[i] = xs[i+1] - 1;
			} else {
				xs[i] = xs[i+1];
			}
		}
		xs[0] = 0;
		int k = 0;
		for (int i = 0; i < cs.length; i++) {
			if (cs[i] == '\\') {
				xs[i+1] = xs[i] - 1;
			} else if (cs[i] == '/') {
				xs[i+1] = xs[i] + 1;
			} else {
				xs[i+1] = xs[i];
			}
			if (xs[i+1] == 0 && xs[i] < 0) k++;
		}

		int a = 0;
		int[] l = new int[k];
		int index = 0;
		for (int i = 1; i < cs.length; i++) {
			if (xs[i] < 0) {
				a -= xs[i];
				l[index] -= xs[i];
			}
			if (xs[i] == 0 && xs[i-1] < 0) index++;
		}

		out.println(a);
		StringBuilder sb = new StringBuilder();
		sb.append(k);
		for (int n : l) {
			sb.append(' ').append(n);
		}
		out.println(sb.toString());
	}
}

Measured memory_bytes: 24612
def main():
    S = input()
    if len(S) % 2 == 0:
        l = S[:len(S)//2]
        r = S[len(S)//2:]
    else:
        l = S[:len(S)//2]
        r = S[len(S)//2 + 1:]
    r = r[::-1]
    count = 0
    for i in range(len(r)):
        if l[i] != r[i]:
            count += 1
    print(count)
main()

Measured memory_bytes: 3064
#include <iostream>

int gcd(long unsigned int a, long unsigned int b) {
	if (a % b == 0)
		return b;

	return gcd(b, a%b);
}


int main() {
	{
		using namespace std;
		
		long unsigned int a, b;
		cin >> a >> b;
		{
			if (a < b) {
			long unsigned int temp;
			temp = a;
			a = b;
			b = temp;
		}
		}
		long unsigned int g;
		g = gcd(a, b);

		cout << g << endl;
	}
	return 0;
}

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

using namespace std;

double p[3010];
double dp[3010][3010]; /// dp table

double go(int pos, int heads) {
    if(heads < 0) return 0;
    if(pos < 0) {
        return (heads == 0 ? 1 : 0);
    }

    if(dp[pos][heads] != -1.0) return dp[pos][heads];

    double op1 = (1 - p[pos]) * go(pos - 1, heads);
    double op2 = p[pos] * go(pos - 1, heads - 1);

    return dp[pos][heads] = op1 + op2;
}

int main() {
    ios_base::sync_with_stdio(false);

    int n;
    cin >> n;

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

    for(int i = 0; i <= n; i++) {
        for(int j = 0; j <= n; j++) dp[i][j] = -1.0;
    }

    double ans = 0.0;

    for(int i = n / 2 + 1; i <= n; i++) {
        ans += go(n - 1, i);
    }

    printf("%.10f\n", ans);
}

/*
 * I
**/


Measured memory_bytes: 71040
import java.util.*

var keta = 0

fun main(args: Array<String>) {
  val (n, k) = readLine()!!.split(" ").map(String::toInt)
  divide(n, k)
  println(keta+1)
}

fun divide(origin: Int, divider: Int) {
  if((origin / divider) > 0 ) {
    keta++
    divide(origin / divider, divider)
  }
}

Measured memory_bytes: 37836
#include <iostream>
#include <iomanip>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#define MP(a, b) make_pair(a, b)
#define POWER9 1000000000
#define MOD POWER9+7
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483647
#define INT_MAX 2147483647
#define LL_MIN (LL)-9223372036854775807
#define LL_MAX (LL)9223372036854775807
#define PI 3.14159265359

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << setprecision(9);

	int N,x;
	cin >> N >> x;
	vector<int> a;
	for(int i=0; i<N; i++){
		int tmp;
		cin >> tmp;
		a.push_back(tmp);
	}
	sort(a.begin(), a.end());
	int now = 0;
	while(now < N && x >= a[now]){
		x -= a[now];
		now++;
	}
	if(now == N){
		if(x == 0) cout << N << endl;
		else cout << N-1 << endl;
	}
	else if(x == 0) cout << now << endl;
	else cout << max(now,0) << endl;

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <string>
#include <iostream>
#include <math.h>

#define rep(i,n) for(int i = 0; i <(n); i++)
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;

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



int main(void) {
	ll i, j, k, ans = 0, cnt = 0, N, tmp, at, M = 0;
	
	scanf("%lld", &N);
	for (i = 1; i <= N -1; i++) {
			M += i;
	}
	printf("%lld", M);



	return 0;
}

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

int main(int argc, char *argv[]){
  long long int n;
  while(cin >> n, n){
    long long int p[n], joint[n], sum = 0;
    for (long long int i = 0; i < n; i++) {
      cin >> p[i];
      sum += p[i];
    }
    for (long long int i = 0; i < n - 1; i++) {
      cin >> joint[i];
    }
    sort(joint, joint+ n - 1, greater<long long int>());
    long long int ans = sum*n;
    for (long long int i = 0; i < n - 1; i++) {
      sum += joint[i];
      ans = max(ans, sum*(n - i - 1));
    }
    std::cout << ans << std::endl;
  }
  return 0;
}

Measured memory_bytes: 2188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, N) for (int i = 0; i < (N); ++i)
#define ALL(x) (x).begin(), (x).end()
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll div_ceil(ll, ll);

int main() {
  int A, B;
  std::cin >> A >> B;
  int res = 0;
  int index;
  if (A == B) {
    res = A * 2;
  } else {
    REP(i, 2) {
      if (A > B) {
        res += A;
        A--;
      } else {
        res += B;
        B--;
      }
    }
  }
  std::cout << res << '\n';
}

ll div_ceil(ll a, ll b) {
  ll quotient = a / b;
  ll remainder = a % b;
  if (remainder == 0) {
    return quotient;
  } else {
    return quotient + 1;
  }
}


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

namespace ABC122B
{
    class Program
    {
        static void Main(string[] args)
        {
            if (args.Length > 0)
            {
                Console.SetIn(new StreamReader(args[0]));
            }

            new Program().Solve();
        }

        void Solve()
        {
            var S = Console.ReadLine();
            var length = 0;
            var max = 0;

            for (int i = 0; i < S.Length; i++)
            {
                if (isACGT(S[i]))
                {
                    length++;
                    max = Math.Max(max, length);
                }
                else {
                    length = 0;
                }
            }

            Console.WriteLine(max);
        }

        bool isACGT(char letter)
        {
            if (letter == 'A' || letter == 'C' || letter == 'G' || letter == 'T')
            {
                return true;
            }
            else
            {
                return false;
            }
        }
    }
}


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

#ifdef _DEBUG
#define debug(x) cerr << "line: " << __LINE__ << ", func: " << __func__ << " ->  " << #x << " = " << x << endl
#else
#define debug(x)
#endif

#define all(s) begin(s), end(s)
#define rall(s) rbegin(s), rend(s)
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = ((a)-1); i >= (b); i--)
#define pb push_back
#define sz(a) int((a).size())
#define put(a) ((cout) << (a) << (endl))
#define putf(a, n) ((cout) << (fixed) << (setprecision(n)) << (a) << (endl))
#define deg2rad(x) (((x)*PI) / (180.0))
#define rad2deg(x) (((x) * (180.0)) / PI)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_ll = pair<ll, ll>;
using d_ll = pair<double, ll>;
using ll_d = pair<ll, double>;
using d_d = pair<double, double>;

static constexpr ll LL_INF = 1LL << 60;
static constexpr int I_INF = 1 << 28;
static constexpr double PI = static_cast<double>(3.14159265358979323846264338327950288);
static constexpr double EPS = numeric_limits<double>::epsilon();

static map<type_index, const char* const> scanType = {
    {typeid(int), "%d"}, {typeid(ll), "%lld"}, {typeid(double), "%lf"}, {typeid(char), "%c"}};

template <class T> static void scan(vector<T>& v);
[[maybe_unused]] static void scan(vector<string>& v, bool isWord = true);
template <class T> static inline bool chmax(T& a, T b);
template <class T> static inline bool chmin(T& a, T b);
template <class T> static inline T gcd(T a, T b);
template <class T> static inline T lcm(T a, T b);
template <class A, size_t N, class T> static void Fill(A (&arr)[N], const T& val);
template <class T> T mod(T a, T m);

int main(int argc, char* argv[]) {
  long long n;
  scanf("%lld", &n);
  std::vector<long long> a(n);
  for (int i = 0; i < n; i++) {
    scanf("%lld", &a[i]);
  }

  sort(all(a));
  ll x = a[n - 1];
  a.pop_back();

  double mid = double(x) / 2.0;
  ll y = a[0];
  double diff = abs(a[0] - mid);
  rep(i, 1, n - 1) {
    if (abs(double(a[i]) - mid) > diff) continue;
    diff = abs(double(a[i]) - mid);
    y = a[i];
  }

  cout << x << " " << y << endl;
  return 0;
}

template <class T> static void scan(vector<T>& v) {
  auto tFormat = scanType[typeid(T)];
  for (T& n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string>& v, bool isWord) {
  if (isWord) {
    for (auto& n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}

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

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

template <class T> inline T gcd(T a, T b) { return __gcd(a, b); }

template <class T> inline T lcm(T a, T b) { return (a * b) / gcd(a, b); }

template <class A, size_t N, class T> void Fill(A (&arr)[N], const T& val) {
  std::fill((T*)arr, (T*)(arr + N), val);
}

template <class T> T mod(T a, T m) { return (a % m + m) % m; }


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int h = scanner.nextInt();
        int w = scanner.nextInt();
        while (h + w > 0) {
            
            
            for(int i=0; i<h; i++){
                for(int j=0; j<w; j++){
                   if(j==0||j==w-1||i==0||i==h-1)
                    System.out.print("#");
                   else
                   System.out.print("."); 
                   
                }
                System.out.println();
            }
            System.out.println();
            
            
            
            h = scanner.nextInt();
            w = scanner.nextInt();
        }
    }
}



Measured memory_bytes: 34328
#include "bits/stdc++.h"

typedef long long ll;
using namespace std;

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if (abs(a - c) <= d || (abs(a - b) <= d && abs(b - c) <= d)) cout << "Yes";
    else cout << "No";
    return 0;
}


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

int main(){
  string  s; cin>>s;
  if(s[0]=='M'){
    cout<<6;
  }else if(s[0]=='T'){
    if(s[1]=='U'){
      cout<<5;
    }else{
      cout<<3;
    }
  }else if(s[0]=='W'){
    cout<<4;
  }else if(s[0]=='S'){
    if(s[1]=='A'){
      cout<<1;
    }else{
      cout<<7;
    }
  }else{
    cout<<2;
  }
  cout<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
	long long n, a;
	scanf("%lld", &n);
	long long Max, Min, Sum;
	scanf("%lld", &a);
	Max=a;
	Min=a;
	Sum=a;
	int i;
	for (i=1; i<n; i++){
		scanf("%lld", &a);
		if(a>Max){
			Max=a;
		}
		if(a<Min){
			Min=a;
		}
		Sum=Sum+a;

	}
	printf("%lld %lld %lld\n", Min, Max, Sum);
	return 0;
}

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

using namespace std;

using ll = long long;


int main(){
    string a, b;
    cin >> a >> b;
    ll cnt = 0;
    for(ll i = 0; i < a.length(); ++i){
        if(a[i] != b[i]){
            cnt++;
        }
    }
    cout << cnt;
    return 0;

}


Measured memory_bytes: 3936
A = int(input())
B = int(input())

if A==1 and B==2:
    print(3)
elif A==1 and B == 3:
    print(2)
elif A == 2 and B == 1:
    print(3)
elif A ==2 and B ==3:
    print(1)
elif A == 3 and B == 1:
    print(2)
else:
    print(1)

Measured memory_bytes: 3060
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;

int main()
{
    ll n; scanf("%lld", &n);
    char f[300000]; scanf("%s", f);
    ll ans = 300000;
    ll right = 0;
    ll left = 0;

    // 位置xのときの左側のWの数 + 右側のEの数
    for (ll i=0; i<n; i++) {
        if (f[i] == 'E') right++;
    }

    for (ll i=0; i<n; i++) {
        if (f[i] == 'E') {
            right--;
        }
        if (left + right < ans) {
            ans = left + right;
        }
        if (f[i] == 'W') {
            left++;
        }
    }
    printf("%lld", ans);

    return 0;
}


Measured memory_bytes: 512
# -*- coding: utf-8 -*-

h,w = map(int,input().split())
a = [[0 for i in range(w)] for j in range(h)]
for i in range(h):
    temp = list(input())
    for j in range(w):
        a[i][j] = temp[j]


for i in range(h):
    a[i] = ["#"] + a[i] + ["#"]

a = [["#" for i in range(w+2)]] + a + [["#" for i in range(w+2)]]

for i in range(h+2):
    a[i] = "".join(a[i])
    print(a[i])


Measured memory_bytes: 3064
n,g[11][11],C[11];D(S){int f[11]={0},i,T,t;memset(C,1,sizeof(C));C[S]=0;T=S;for(;T;){f[T]=1;for(i=1;i<=n;i++){t=C[T]+g[T][i];if(t<C[i])C[i]=t;}T=0;for(i=1;i<=n;i++){if(!f[i]&&(!T||C[i]<C[T]))T=i;}}}int main(){int m,a,b,c,d;for(;scanf("%d",&m),m;){memset(g,1,sizeof(g));n=0;for(;m--;){scanf("%d%d%d",&a,&b,&c);a++,b++;g[a][b]=g[b][a]=c;if(a>n)n=a;if(b>n)n=b;}d=1e9;for(a=1;a<=n;a++){c=0;D(a);for(m=1;m<=n;m++)c+=C[m];if(c<d){d=c;b=a;}}printf("%d %d\n",b-1,d);}exit(0);}

Measured memory_bytes: 0
/******************************************
* AUTHOR : Lokesh goel*
* NICK : InsaneNerd *
* INSTITUTION : NIT Kurukshetra *
******************************************/
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define MAX 1000000000
#define N 100005
#define pii pair<int,int>
#define vp vector<pair<int,int > >
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define gsz(x) ((int)(x).size())
#define F first
#define S second
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);cerr.tie(NULL);
#define endl "\n"
#define ms(x,v) memset(x,v,sizeof(x))

int main()
{
	fastio;
	ll n,i,j,k;
	cin>>n;
	string str;
	cin>>str;
	//multimap<int,int>m1,m2;
	ll totalR=0,totalG=0,totalB=0,CR=0,CG=0,CB=0;
	for(i=0;i<n;i++)
	{
		if(str[i]=='R')
			totalR++;
		else if(str[i]=='G')
			totalG++;
		else if(str[i]=='B')
			totalB++;
	}
	ll res=0;
	for(i=0;i<n;i++){
		// m2.erase(m2.find(str[i]-'A'));
		// m1=m2;
		if(str[i]=='R')
			totalR--;
		else if(str[i]=='G')
			totalG--;
		else if(str[i]=='B')
			totalB--;

		CR=totalR;
		CG = totalG;
		CB = totalB;
		for(j=i+1;j<n;j++){
			// m1.erase(m1.find(str[j]-'A'));
			if(str[j]=='R')
				CR--;
			else if(str[j]=='G')
				CG--;
			else if(str[j]=='B')
				CB--;
			if(str[i]!=str[j]){
				if(str[i]=='R'&&str[j]=='G'){
					ll curr = CB;
					if(2*j-i<n){
						if(str[2*j-i]=='B'){
							curr--;
						}
					}
					res+=curr;
				}
				else if(str[i]=='G'&&str[j]=='R'){
					ll curr = CB;
					if(2*j-i<n){
						if(str[2*j-i]=='B'){
							curr--;
						}
					}
					res+=curr;
				}
				else if(str[i]=='B'&&str[j]=='G'){
					ll curr = CR;
					if(2*j-i<n){
						if(str[2*j-i]=='R'){
							curr--;
						}
					}
					res+=curr;
				}
				else if(str[i]=='R'&&str[j]=='B'){
					ll curr = CG;
					if(2*j-i<n){
						if(str[2*j-i]=='G'){
							curr--;
						}
					}
					res+=curr;
				}
				else if(str[i]=='G'&&str[j]=='B'){
					ll curr = CR;
					if(2*j-i<n){
						if(str[2*j-i]=='R'){
							curr--;
						}
					}
					res+=curr;
				}
				else if(str[i]=='B'&&str[j]=='R'){
					ll curr = CG;
					if(2*j-i<n){
						if(str[2*j-i]=='G'){
							curr--;
						}
					}
					res+=curr;
				}
			}
		}	
	}
	cout<<res<<endl;


	return 0;
}

Measured memory_bytes: 3656
#include <iostream>
#include <vector>

using namespace std;
typedef long long ll;

constexpr ll MOD = 1000000007;

int n;
vector<int> g[100005];

ll dp[100005][2];

void solve(int s, int p) {
	dp[s][0] = dp[s][1] = 1;

	for (int a : g[s]) {
		if (a == p) continue;
		solve(a, s);
		dp[s][0] *= dp[a][0]+dp[a][1];
		dp[s][0] %= MOD;

		dp[s][1] *= dp[a][0];
		dp[s][1] %= MOD;
	}
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> n;
	if (n == 1) {
		cout << "2\n";
		return 0;
	}
	for (int i = 0; i < n-1; ++i) {
		int a, b;
		cin >> a >> b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	solve(1, -1);
	cout << (dp[1][0]+dp[1][1])%MOD << "\n";
	return 0;
}

/*
	dp[s][0] = ways to paint subtree of s so that s is white, dp[s][1] = s is black

	if s is white, children can be black or white
	is s is black, all children must be white
*/


Measured memory_bytes: 14208
import sys
sys.setrecursionlimit(1000000)
def dfs(now,color):
    col[now]=color
    for n,w in nodes[now]:
        if col[n]!=-1:
            continue
        if w%2==0:
            dfs(n,color)
        else:
            dfs(n,1-color)

n=int(input())

nodes=[]
for i in range(n+1):
    nodes.append([])
for i in range(n-1):
    s,e,w = map(int,input().split())
    nodes[s].append((e,w))
    nodes[e].append((s,w))

col=[-1]*(n+1)

dfs(1,1)

for i in range(1,n+1):
    print(col[i])

Measured memory_bytes: 79408
//Utkarsh.25dec
#include <bits/stdc++.h>
#include <chrono>
#include <random>
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define loop(i,a,b) for(ll i=a;i<=b;i++)
#define vi vector <int>
#define vs vector <string>
#define vc vector <char>
#define vl vector <ll>
#define all(c) (c).begin(),(c).end()
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define deb(x) cerr<<#x<<' '<<'='<<' '<<x<<'\n'
using namespace std;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll modInverse(ll a){return power(a,mod-2);}
const int N=500023;
bool vis[N];
vector <int> adj[N];
void solve()
{
    string s;
    cin>>s;
    if(s[2]==s[3] && s[4]==s[5])
        cout<<"Yes\n";
    else
        cout<<"No\n";
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int T=1;
    //cin>>T;
    int t=0;
    while(t++<T)
    {
        //cout<<"Case #"<<t<<":"<<' ';
        solve();
        //cout<<'\n';
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}


Measured memory_bytes: 12032
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mmax(a,b,c) max(a,max(b,c))
#define mmin(a,b,c) min(a,min(b,c))
#define M 1000000007
#define V vector
#define F(a,b,c) for (a=b;a<=c;++a)
#define I cin
#define O cout
#define pb push_back
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define umap unordered_map

bool isPowerOfTwo (ll x) {
    return x && (!(x&(x-1)));
}

ll binpow(ll a, ll b) {
    a %= M;
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % M;
        a = a * a % M;
        b >>= 1;
    }
    return res;
}

int main() {
    I.sync_with_stdio(false);
    I.tie(0);
    ll t,n,q,i,j,k;
    I>>n>>k;
    V<ll> p(n);
    F (i, 0, n - 1)
        I >> p[i];
    sort(all(p));
    ll s = 0;
    F (i, 0, k - 1)
        s += p[i];
    O << s << '\n';
    return 0;
}


Measured memory_bytes: 3624
/*
　　　　 ∧＿∧　にっぽんちゃちゃちゃ
　／＼（　・∀・）／ヽ
（ ●　と　　　つ　● ）　にっぽんちゃちゃちゃ
　＼/⊂、 ノ　　＼ノ
　　　　　し'
*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define MOD 1000000007
#define INF 9223372036854775807

signed main(){
int x=0,y=0,z=0,w=0;
std::cin >> x>>y;
std::cout << x/y+x%y << '\n';
}



Measured memory_bytes: 3100
n, m = gets.split.map(&:to_i)

require 'prime'

class Integer
  def my_divisor_list2
    return [1] if self == 1
    Prime.prime_division(self).map do |e|
      Array.new(e[1]+1).map.with_index do |element, i|
        e[0]**i
      end
    end.inject{|p,q| p.product(q)}.map do |a|
      [a].flatten.inject(&:*)
    end.sort
  end
end

a = m.my_divisor_list2
b = 1
a.each do |i|
  if i >= n
    b = i
    break
  end
end

puts m/b


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

string s, t;

bool find(int s_i)
{
	int i;
	for (i = 0; i < t.size(); i++) {
		if (s_i+i >= s.size())
			break;
		if (s[s_i+i] != '?' && s[s_i+i] != t[i])
			break;
	}
	if (i != t.size())
		return false;

	return true;
}

int main(void)
{
	cin >> s >> t;

	vector<int> t_pos;

	int j = 0;
	for (int i = 0; i < s.size(); i++) {
		if (find(i)) {
			t_pos.push_back(i);
		}
	}
	if (t_pos.size() == 0) {
		cout << "UNRESTORABLE" << endl;
		return 0;
	}

	string min = "";
	for (int i = 0; i < t_pos.size(); i++) {
		string cur = s;
		cur.replace(t_pos[i], t.size(), t);
		for (int j = 0; j < cur.size(); j++) {
			if (cur[j] == '?')
				cur[j] = 'a';
		}
		if (i == 0 || cur < min)
			min = cur;
	}
	cout << min << endl;


	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <regex>
#include <numeric>
using namespace std;

/*--- Macro ---*/
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define rep1(i, n) for(int i=1; i<(int)n; i++)
#define mp make_pair
#define pb push_back
#define all(a) a.begin(), a.end()

/*---  Type ---*/
typedef long long ll;

/*--- Constants ---*/
template <typename T> const T INF = numeric_limits<T>::max() / 10;
const int MOD = (int)1e9 + 7;

// Floating
const double EPS = 1e-11;
#define EQ0(x) (abs(x) < EPS)
#define EQ(x, y) (abs(a-b) < EPS)

// Util
int max(int a, int b, int c) {return max(a, max(b, c));}
int min(int a, int b, int c) {return min(a, min(b, c));}
ll max(ll x, ll y) {return x > y ? x : y;}
ll min(ll x, ll y) {return x < y ? x : y;}
ll max(ll a, ll b, ll c) {return max(a, max(b, c));}
ll min(ll a, ll b, ll c) {return min(a, min(b, c));}

// -------------------------------------------------------------------------------------



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

  int ans = 0;
  rep1(i, n+1) {
    int _sum = 0, tmp = i;
    while(tmp > 0) {
      _sum += (tmp % 10);
      tmp /= 10;
    }
    // cout << i << ", " << _sum << endl;
    if(a <= _sum && _sum <= b) ans += i;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

        int v[] = new int[n];
        for (int i = 0; i < n; i++) {
            v[i] = in.nextInt();
        }

        int total = 0;
        for (int i = 0; i < n; i++) {
            int c = in.nextInt();

            if (v[i] > c) {
                total += v[i] - c;
            }
        }

        System.out.println(total);
    }
}


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

int main(){
  int N; cin >> N;
  int ans = 0;
  int digit = 0;
  for(int i=1; i<=N; i++){
    digit =0;
    int a=i;
    while(a!=0){
      digit++;
      a/=(10);
      
    }
    if(digit%2 == 1){
      ans++;
    }
  }
  cout << ans << endl;
}


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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define repr(i, n, m) for (int i = (int)(n) - 1; i >= (int)(m); i--)
using namespace std;
using ll = int64_t;
const int MOD = 1000000007; // 10^9+7

int main() {
    int n, m; cin >> n >> m;
    vector<vector<int>> cave(n);
    rep(i, 0, m) {
        int a, b; cin >> a >> b;
        cave[a - 1].push_back(b - 1);
        cave[b - 1].push_back(a - 1);
    }

    vector<int> ans(n, -1);
    vector<bool> seen(n, false);
    queue<int> q;

    seen[0] = true; q.push(0);
    while (!q.empty()) {
        int room = q.front(); q.pop();
        vector<int> adj = cave[room];
        for (auto &&i : adj)
        {
            if (seen[i]) continue;
            seen[i] = true;
            q.push(i);
            ans[i] = room;
        }
    }

    cout << "Yes" << endl;
    rep(i, 1, n) {
        cout << ans[i] + 1 << endl;
    }
}


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

int gcd(int a, int b){
	if (a%b == 0){
		return b;
	} else {
		return gcd(b, a%b);
	}
}

int main() {
	int N, K;
	cin >> N >> K;
	vector<int> a(N);
	set<int> st;
	for (int i = 0; i < N; i++) {
		cin >> a[i];
		st.insert(a[i]);
	}

	sort(a.begin(), a.end());
	int g = a[0];
	for (auto it = st.begin(); it != st.end(); it++) {
		g = gcd(g, *it);
	}

	if ((K <= a[N - 1]) && (K%g == 0)) {
		cout << "POSSIBLE" << endl;
	} else {
		cout << "IMPOSSIBLE" << endl;
	}

	return 0;
}


Measured memory_bytes: 5376
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <cmath>
#include <cstring>

#define fi first
#define se second
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = 1; i < (n); ++i)
#define drep(i,n) for (int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define all(x) (x).begin(), (x).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T> >

using namespace std;
typedef long long ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;

const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

const int mod = 1000000007;

vector<ll> a;

bool c(int d, int v, int p, int n, ll m) {
    if (d<p) return true;
    if (a[p-1]>a[d]+m) return false;

    ll rest = m * v;
    rep(i,n) {
        if (i == d) rest -= m;
        else if (i < p-1) rest -= m;
        else {
            rest -= min(max<ll>(a[d]+m-a[i], 0),m);
        }
    }
    return rest <= 0;
}

int main() {
    int n;
    ll m;
    int v, p;
    cin >> n >> m >> v >> p;
    a.resize(n);
    rep(i,n) cin >> a[i];

    int ub = n;
    int lb = 0;
    sort(all(a), greater<ll>());
    while (ub-lb>1) {
        int mid = (ub+lb) / 2;
        if (c(mid, v, p, n, m)) lb = mid;
        else ub = mid;
    }
    cout << ub << endl;
    return 0;
}


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

int main() {
  string str;
  cin >> str;
  
  bool hFlag = false;
  bool iFlag = false;
  int count = 0;
  for(int i=0; i < str.length(); i++){
    if(count == 0 && str[i] == 'h'){
      hFlag = true;
      iFlag = false;
      count++;
    } else if(count == 1 && str[i] == 'i'){
      iFlag = true;
      count = 0;
    } else {
      hFlag = false;
      iFlag = false;
      break;
    }  
  }
  
  if (hFlag && iFlag) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  

  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){

  int i,j,k,n,A[101],count;

  count = 0;
  
  scanf("%d", &n );
  
  for ( i = 0 ; i < n ; i++ ){
    scanf("%d", &A[i] );
  }

  for ( i = 0 ; i < n - 1 ; i++ ){
    
    for ( j = 0 ; j < n - 1 ; j++ ){

      if ( A[j] > A[ j + 1 ] ) {
	k = A[j];
	A[j] = A[ j + 1 ];
	A[ j + 1 ] = k;
	count += 1;
      }
      
    }
    
  } 

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

    if ( i < n - 1 ){
      printf("%d ", A[i] );
    } else {
      printf("%d\n", A[i] );
    }
  }

  printf("%d\n", count );

  return 0;
  
}

Measured memory_bytes: 600
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;


int main(){
    int N; cin >> N;
    vector<int> A(N);
    rep(i,N) cin >> A[i];
    int red = 0,blue = 0,yellow = 0;
    ll ans = 1;
    rep(i,N){
        int now = 0;
        bool ok = false;
        if(red == A[i]){
            now++;
            red++;
            ok = true;
        }
        if(blue == A[i]){
            now++;
            if(!ok){
                blue++;
                ok = true;
            }
        }
        if(yellow == A[i]){
            now++;
            if(!ok){
                yellow++;
            }
        }
        ans *= now;
        ans %= MOD;
    }
    //ans *= 6;
    ans %= MOD;
    cout << ans << endl;
}


Measured memory_bytes: 640
#include<algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cmath>
#include <string>
#include <map>
using namespace std;

int main()
{
	int n,negatives=0;
	long long Sum=0,mini=10000000000,tmp;
	cin >>n;
	for(int i=0;i<n;i++){
	    cin >> tmp;
	    mini=min(mini,abs(tmp));
	    if(tmp<0)negatives++;
	    Sum+=abs(tmp);
	}
	Sum-=mini;
	if(negatives %2==1 ) Sum-=mini;
	else Sum+=mini;
	cout <<Sum<<"\n";
	return 0;
}


Measured memory_bytes: 384
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            int N = cin.ReadInt;
            var d = cin.ReadIntArray(N);
            Array.Sort(d);
            int result = 0;
            for(int i = 0; i < N; i++)
            {
                if (i == 0)
                {
                    result++;
                }
                else if (d[i] > d[i - 1])
                {
                    result++;
                }
            }
            WriteLine(result);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}

Measured memory_bytes: 13268
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

using namespace std;

//----------------------- Print Function ----------------------//

inline void print() {
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest) {
    cout << first << ' ';
    print(rest...);
}

template <typename T>
void print(const vector<T> &v) {
    for (auto e : v) cout << e << ' ';
    cout << endl;
}

//------------------------- Libraries -------------------------//

//--------------------------- Solve ---------------------------//

void solve() {
    int N; cin >> N;
    long long t = 1, a = 1;

    for (int i = 0; i < N; i++) {
        long long T, A; cin >> T >> A;
        long long mul = max((t + T - 1) / T, (a + A - 1) / A);
        t = T * mul;
        a = A * mul;
    }
    
    cout << t + a << '\n';
}

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

    solve();

    return 0;
}

Measured memory_bytes: 3620
from collections import deque
h, w = map(int, input().split())
field = [input() for _ in range(h)]
d = [(1, 0), (-1, 0), (0, 1), (0, -1)]
white = 0
for i in range(h):
    white += field[i].count(".")
cnt = [[-1]*w for _ in range(h)]
cnt[0][0] = 0
q = deque([[0, 0]])

while q:
    y, x = q.pop()
    for dy, dx in d:
        ny = y + dy
        nx = x + dx
        if 0 <= ny < h and 0 <= nx < w and field[ny][nx] == "." and cnt[ny][nx] < 0:
            cnt[ny][nx] = cnt[y][x] + 1
            q.appendleft([ny, nx])
        if ny == h-1 and nx == w-1:
            print(white - cnt[h-1][w-1] - 1)
            exit()

print(-1)

Measured memory_bytes: 9420
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()

using namespace std;

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

int nextInt() {int a; cin >> a; return a;}
char nextChar() {char a; cin >> a; return a;}
double nextDouble() {double a; cin >> a; return a;}
string nextString() {string a; cin >> a; return a;}

void inputVector(vector<int> &v, int &n) {rep(i,n){v.push_back(nextInt());}}
void inputVector(vector<double> &v, int &n) {rep(i,n){v.push_back(nextDouble());}}
void inputVector(vector<string> &v, int &n) {rep(i,n){v.push_back(nextString());}}

signed main() {
    int n, r;
    while (cin >> n >> r) {
	if (n == 0) break;

	deque<int> v;
	for (int i = n; i >= 1; i--) {
	    v.push_back(i);
	}

	int p, c;
	deque<int> w;
	rep(i, r) {
	    cin >> p >> c;
	    p--;
	    for (int j = p; j < p + c; j++) {
		w.push_back(v[j]);
	    }
	    rep(i, c) {
		v.erase(v.begin() + p);
	    }
	    v.insert(v.begin(), all(w));
	    w.clear();
	}

	cout << v[0] << endl;
    }

    return 0;
}

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

int main(void)
{
  bool a, b, c;
  cin >> a >> b >> c;
  if ( (a and b) or c)
  {
    cout << "Open" << endl;
  }
  else
  {
    cout << "Close" << endl;
  }
  return 0;
}

Measured memory_bytes: 1156
N=int(input())
h=list(map(int,input().split()))
DP=[0]*N
DP[0]=0
DP[1]=abs(h[0]-h[1])
for i in range(1,N-1):
  DP[i+1]=min(DP[i]+abs(h[i]-h[i+1]),DP[i-1]+abs(h[i-1]-h[i+1]))
print(DP[N-1])
  

Measured memory_bytes: 13928