akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
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; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

bool dp[85][85][13000];

int main(){
    int h, w;
    cin >> h >> w;
    vector<vector<int>> a(h, vector<int>(w)), b(h, vector<int>(w));
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            cin >> a[i][j];
        }
    }
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            cin >> b[i][j];
        }
    }

    dp[1][1][abs(a[0][0] - b[0][0])] = true;
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            for (int k = 0; k < 13000; ++k) {
                int diff = abs(a[i][j] - b[i][j]);

                int l = k - diff;
                if (l < 0) l = -l;
                dp[i+1][j+1][l] |= dp[i+1][j][k];
                dp[i+1][j+1][l] |= dp[i][j+1][k];

                int r = k + diff;
                if (r < 13000) {
                    dp[i+1][j+1][r] |= dp[i+1][j][k];
                    dp[i+1][j+1][r] |= dp[i][j+1][k];
                }
            }
        }
    }

    int res = INF;
    for (int i = 0; i < 13000; ++i) {
        if (dp[h][w][i]) chmin(res, i);
    }
    cout << res << endl;
}

Measured memory_bytes: 85236
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#include<map>
#include<vector>
using namespace std;
int a,b;
string s; 
int main(){
	cin>>a>>b;
	cin>>s;
	for(int i=0;i<a+b;i++){
		if(i!=a&&(s[i]<'0'||s[i]>'9')){
			cout<<"No";
			return 0;
		}
		else if(i==a&&s[i]!='-'){
			cout<<"No";
			return 0;
		}
	}
	cout<<"Yes";
	return 0;
}
/*

*/

Measured memory_bytes: 256
#![allow(unused_imports)]
use proconio::{input, fastout};
use proconio::marker::*;

#[fastout]
fn main() {
    input! {
    n: usize,
    a: [usize; n]
    }
    let mut ans:usize = 1;
    if a.contains(&0){
        println!("0");
        return
    }
    for i in a{
        if let Some(x) = ans.checked_mul(i) {
            ans = x;
        } else {
            println!("-1");
            return
        }
        if ans > 10usize.pow(18){
            println!("-1");
            return
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4556
//By Krishna Yadav
#pragma GCC optimize("-O2")
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define forstl(i, v) for (auto &i : v)
#define forn(i, e) for (int i = 0; i < e; i++)
#define ln "\n"

#define dbg(x) cout << #x << " = " << x << ln
#define dbg2(x, y) cout << #x << " = " << x << " & " << #y << " = " << y << ln
typedef long long int ll;
typedef long double ld;
typedef pair<int, int> p32;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef map<int, int> m32;
const int LIM = 2e5 + 5, MOD = 1e9 + 7;
int t, n, m, k, x, y;

int main()
{
	int A[5];
	forn(i, 5) cin >> A[i];
	forn(i, 5)
	{
		if (A[i] == 0)
			cout << i + 1 << endl;
	}
}


Measured memory_bytes: 3412
#import sys
MOD = 10 ** 9 + 7
#input = sys.stdin.readline
import math

#import bisect

def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def kingaku(a,b,n):
    keta=len(str(n))
    return a*n+b*keta

def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default


def main():
#    h,w,a,b = map(int, input().split())
#    c = [[0 for j in range(n)] for i in range(n)]
    s=list(input())
    a = [s[i] for i in range(0,len(s)//2)]
    b = [s[i] for i in range(len(s)-1,(len(s)-1)//2,-1)]
    count=0
    for i in range(len(a)):
        if a[i]!=b[i]:
            count+=1
    print(count)




#  print(c)




            #    print(n,kingaku(a,b,x))

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
using namespace std;
#define int long long

signed main() {
  int a, b;
  cin >> a >> b;
  if (a * b <= 0) {
    cout << "Zero" << endl;
  } else if (a > 0) {
    cout << "Positive" << endl;
  } else {
    int count = b - a + 1;
    if (count % 2) cout << "Negative" << endl;
    else cout << "Positive" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
n=int(input())
b=True
l=[]
w=input()
l.append(w)
for i in range(n-1):
  w=input()
  if w in l or w[0]!=l[-1][-1]:
    b=False
    break
  else:
    l.append(w)
if b:
  print("Yes")
else:
  print("No")
    

Measured memory_bytes: 3060
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

int main()
{
	std::string S;
	in >> S;

	LL ans = 0, cnt = 0;
	rep(i, S.length())
	{
		if (S[i] == 'B') ++cnt;
		else ans += cnt;
	}
	out << ans << std::endl;
	return 0;
}


Measured memory_bytes: 640
using System;

namespace ARC063D{
    public class Program{
        public static void Main(string[] args){
            var sr = new StreamReader();
            //---------------------------------
            var N = sr.Next<int>();
            var T = sr.Next<int>();
            var A = sr.Next<int>(N);

            var maxProfit = 0;
            var min1 = int.MaxValue;
            foreach(var a in A){
                min1 = Math.Min(min1, a);
                maxProfit = Math.Max(maxProfit, a - min1);
            }

            var min2 = int.MaxValue;
            var tmp = 1;
            var minCount = 0;
            var maxCount = 0;
            foreach(var a in A){
                if(min2 == a){
                    tmp++;
                }
                if(min2 > a){
                    min2 = a;
                    tmp = 1;
                }
                if(a - min2 == maxProfit){
                    minCount += tmp;
                    maxCount++;
                }
            }

            Console.WriteLine(Math.Min(minCount, maxCount));
            //---------------------------------
        }
    }

    public class StreamReader{
        private readonly char[] _c = {' '};
        private int _index = -1;
        private string[] _input = new string[0];
        private readonly System.IO.StreamReader _sr = new System.IO.StreamReader(Console.OpenStandardInput());

        public T Next<T>(){
            if(_index == _input.Length - 1){
                _index = -1;
                while(true){
                    string rl = _sr.ReadLine();
                    if(rl == null){
                        if(typeof(T).IsClass) return default(T);
                        return (T)typeof(T).GetField("MinValue").GetValue(null);
                    }
                    if(rl != ""){
                        _input = rl.Split(_c, StringSplitOptions.RemoveEmptyEntries);
                        break;
                    }
                }
            }
            return (T)Convert.ChangeType(_input[++_index], typeof(T), System.Globalization.CultureInfo.InvariantCulture);
        }

        public T[] Next<T>(int x){
            var ret = new T[x];
            for(var i = 0; i < x; ++i) ret[i] = Next<T>();
            return ret;
        }

        public T[][] Next<T>(int y, int x){
            var ret = new T[y][];
            for(var i = 0; i < y; ++i) ret[i] = Next<T>(x);
            return ret;
        }
    }
}

Measured memory_bytes: 16468
#pragma region header
#include <bits/stdc++.h>
using namespace std;
#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 rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr ll inf = INT32_MAX/2;
constexpr ll INF = LLONG_MAX/2;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */

/* --------------------テンプレート------------------ */
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ----------------------end----------------------- */
#pragma endregion
int main() {
    int n;cin >> n;
    vi ans(n+1);
    map<int,int> mp;
    rep(i, n) {
        int a;cin >> a;
        mp[a]++;
    }
    int sum = 0;
    // rep1(i, n) sum+=(abs(ans[i]-i));
    for(auto p:mp) {
        // sum += min(p.second-p.first,p.second);
        if(p.second-p.first<0) sum+=p.second;
        else sum += p.second-p.first;
        // cout << p.first << ' ' << p.second << endl;
    }
    cout << sum << endl;
    return 0;
}

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

using namespace std;

int main() {
    int N;
    cin >> N;
    vector<long long int> A(N);
    long long int ans=0;
    for(int n=0; n<N; n++) {
        cin >> A[n];
    }
    
    for(int n=0; n<N; n++) {
        ans += A[n]/2;
        if(A[n]%2==1) {
            if(n+1<N && A[n+1]!=0) {
                A[n+1]++;
            }
        }
    }
    
    cout << ans << endl;


    return 0;
    
    
}

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

#define int long long

signed main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int x,k,d;
    cin>>x>>k>>d;
    if(x>=0){
        int ans=1e15;
        int t=min(x/d,k);
        int t1=x-t*d;
        if((t-k)%2==0){
            ans=min(ans,abs(t1));
        }
        else{
            ans=min(ans,abs(t1+d));
            ans=min(ans,abs(t1-d));
        }
        cout<<ans;
    }
    else{
        int ans=1e15;
        int t=min(-x/d,k);
        int t1=x+t*d;
        if((t-k)%2==0){
            ans=min(ans,abs(t1));
        }
        else{
            ans=min(ans,abs(t1+d));
            ans=min(ans,abs(t1-d));
        }
        cout<<ans;
    }
    return 0;
}

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

template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}

template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << endl; }

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

#ifndef STOP_DEBUG
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

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

template <typename T> lint gcd(T a, T b) {return b?gcd(b, a%b):a;}
template <typename T> lint lcm(T a, T b) {return a * b / gcd(a, b);};
template <typename T> bool chmax(T &a, const T& b) {if (a < b) {a = b;return true;}return false; }
template <typename T> bool chmin(T &a, const T& b) {if (a > b) {a = b;return true;}return false; }

struct IoSetup{
 IoSetup(){
   ios::sync_with_stdio(false);
   cin.tie(0);
   cout << fixed << setprecision(20);
   cerr << fixed << setprecision(20);
 }
} IoSetup;

int main() {
  lint a, b, c;
  cin >> a >> b >> c;
  if (a + b  + 1 >= c) {
    cout << b + c << '\n';
  }
  else {
    cout <<  b + a + b + 1<< '\n';
  } 
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map> //map<string, int> cnt; key とvalue
#include <set>//  set<int> s;
#include <cstdlib>  // abs() for integer
#include <vector>
#define rep(i,n) for(int i = 0 ; i < (n); ++i)
using namespace std;
using ll = long long;
/*
g++ -std=c++11
*/
int main(){
  string s;
  cin >> s;
  if(s == "ABC") cout << "ARC" << endl;
  else cout << "ABC" << endl;
  return 0;
}

Measured memory_bytes: 2928
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
#define endl '\n';
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;



int main() {
    
    int a,b,c;
    cin>>a>>b>>c;
    if(b-a==c-b)fin("YES");
    else fin("NO");
}


Measured memory_bytes: 256
#include <stdio.h>

int bubbleSort(int a[], int n) {
  int flag = 1;
  int done = 0, count = 0;
  while (flag) {
    flag = 0;
    int j;
    for (j = n - 1; j > done; j--) {
      if (a[j] < a[j - 1]) {
        int temp = a[j];
        a[j] = a[j - 1];
        a[j - 1] = temp;
        flag = 1;
        count += 1;
      }
    }
    done++;
  }
  return count;
}

int main() {
  int n;
  scanf("%d", &n);
  int i, a[n];
  for (i = 0; i < n; i++)
    scanf("%d", a + i);
  int count = bubbleSort(a, n);
  for (i = 0; i < (n - 1); i++)
    printf("%d ", a[i]);
  printf("%d\n%d\n", a[n - 1], count);
  return 0;
}

Measured memory_bytes: 600
#include <stdio.h>

#define N 2000

int n,m;
int S[N],T[N];

int solve(int num,int key){
	if(key == 0){
		return 1;
	}
	if(num >= n || key < 0){
		return 0;
	}
	return solve(num+1,key) || solve(num+1,key - S[num]);
}


int main(){

	scanf("%d",&n);

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

	scanf("%d",&m);

	for(i=0;i<m;i++){
		scanf("%d",&T[i]);
	}

	for(i=0;i<m;i++){
		if(solve(0,T[i])) printf("yes\n");
		else printf("no\n");
	}

	return 0;
}

Measured memory_bytes: 2604
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define All(a) a.begin(),a.end()
#define INF 1000000007
const int MOD = 1000000007;
//accumulate(vec.begin(), vec.end(), 0)
//std::sort(v.begin(), v.end(), std::greater<Type>());
//set_intersection(x, x+7, y, y+6, back_inserter(v));
//set_union(x, x+7, y, y+6, back_inserter(v));
//set_difference(x, x+7, y, y+6, back_inserter(v));

int gcd(int x,int y){
  if(x%y==0) return y;
  else return gcd(y,x%y);
}

bool isPrime(int n){
  if(n < 2) return false;
  else if(n == 2) return true;
  else if(n%2==0) return false;

  for(int i=3;i<=sqrt(n);i++){
    if(n%i==0) return false;
  }
  return true;
}

int main(){
  int w,h,n;
  cin >> w >> h >> n;
  int low_w=0,low_h=0,high_w=w,high_h=h;
  for(int i=0;i<n;i++){
    int a,x,y;
    cin >> x >> y >> a;
    if(a==1 && low_w<x)low_w = x;
    else if(a==2 && x<high_w) high_w = x;
    else if(a==3 && low_h<y) low_h = y;
    else if(a==4 && y<high_h) high_h = y;
  }

  if(low_w>=high_w) cout<< 0 <<endl;
  else cout<< (high_w-low_w)*(high_h-low_h) <<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define sort(vec) sort(vec.begin(),vec.end())
#define reverse(vec) reverse(vec.begin(),vec.end())
#define unsort(vec); sort(vec);reverse(vec);
#define int long long
long long ans;

int gcd(int x,int y){
	if(y==0) return x;
	else return gcd(y,x%y);
}

int lcm(int x,int y){
	return x*y/gcd(x,y);
}
 
signed main(){
	string s;
	int o=0,t=0;
	cin>>s;
	for(int i=0;i<s.size();i++){
		if(s[i]=='1')o++;
		else t++;
	}
	cout<<min(o,t)*2<<endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define REP(i,i_len) for (ll i = 0, i##_len = (i_len); i < i##_len; i++)

int main() {

    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    ll t, d, l;
    while (cin >> t >> d >> l, t) {

        vector<ll> x(t);
        REP(i, t) cin >> x[i];
        vector<int> wet(t, 0);
        REP(i, t) {
            if (x[i] >= l) {
                wet[i]++;
                if (i+d < t) wet[i+d]--;
            }
        }
        REP(i, t-1) {
            wet[i+1] += wet[i];
        }
        ll ans = 0;
        REP(i, t-1) {
            if (wet[i]) ans++;
        }
        cout << ans << endl;

    }

}


Measured memory_bytes: 4296
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
//#include <unordered_set> //unordered_set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
#define endl "\n";
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const long long INF = 100100100100100;
const long long MOD = 1000000007;
typedef pair<long long,int> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

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

vector<vector<long long>> dist(205,vector<long long>(205));

int main() {
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    
    int N,M,R;cin >> N >> M >> R;
    vector<int> target(R);
    for(int i = 0;i<R;i++){
        cin >> target.at(i);
        target.at(i)--;
    }
  	std::sort(target.begin(),target.end());
    for(int i = 0;i<205;i++)for(int j = 0;j<205;j++) dist.at(i).at(j) = INF;
    for(int i = 0;i<M;i++){
        int a,b;long long c;cin >> a >> b >> c;
        a--;b--;
        dist.at(a).at(b) = c;
        dist.at(b).at(a) = c;
    }

    //warshall_floyd
    //頂点iを経由してj→kに行く
    for(int i = 0;i<N;i++){
        for(int j = 0;j<N;j++){
            //そもそも辺が存在しないとcontinue
            if(dist.at(j).at(i) == INF) continue;
            for(int k = 0;k<N;k++){
                if(dist.at(i).at(k) == INF) continue;
                dist.at(j).at(k) = min(dist.at(j).at(k),dist.at(j).at(i)+dist.at(i).at(k));
            }
        }
    }

    long long ans = INF;
    //目的地を訪れる順を全探索
    do{
        long long sum = 0;
        for(int i = 0;i<R-1;i++){
            sum += dist.at(target.at(i)).at(target.at(i+1));
        }
        ans = min(ans,sum);
    }
    while(next_permutation(target.begin(),target.end()));
    
    cout << ans << endl;
}


Measured memory_bytes: 3932
//RITIK RAI:
//#pragma GCC optimize("O3")
//#define ritik ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
//vector<vector<ll>> 2Darray(rows,vector<ll>(col,val));
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define ull unsigned long long int
#define ld long double
 #define pb push_back

#define mp make_pair
#define fir first
#define sec second
 
#define all(x) x.begin(),x.end()
#define ub upper_bound
#define lb lower_bound
#define bin binary_search

#define intg INT_MAX
#define ints INT_MIN
#define endl '\n'
 
/*----------------------------------------------------------------------------------------------------------*/
 
#define f(i,a,b) for(ll i=a;i<b;i++)
#define rf(i,a,b) for(ll i=a;i>b;i--)
 
/*----------------------------------------------------------------------------------------------------------*/
 
#define print1(arr,a,b) for(ll i=a;i<b;i++) cout<<arr[i]<<" "; cout<<endl
#define print(arr,a,b)  for(ll i=a;i<b;i++) cout<<arr[i]<<endl
#define print2d(dp,r,c) for(ll i=0;i<r;i++){for(ll j=0;j<c;j++) cout<<dp[i][j]<<" "; cout<<endl;}

/*--------------------------------------------FUNCIONS--------------------------------------------------------------*/
 
ll power(ll x,ll y,ll p)
{
    ll res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}

/*-----------------------------------------------write your code here-----------------------------------------------------------*/

ll mod=1000000007;

int main()
{
    ll h,w; cin>>h>>w;
    vector<vector<char>> graph(h+3,vector<char>(w+3,'*'));
    vector<vector<ll>> dp(h+3,vector<ll>(w+3,0ll));
    f(i,1,h+1)
        f(j,1,w+1)
            cin>>graph[i][j];
    dp[h][w]=1ll;
    rf(i,h,0)
        rf(j,w,0)
            if(i*j!=h*w) dp[i][j]=( (graph[i][j]=='.') ? (dp[i][j+1]+dp[i+1][j])%mod : 0ll );
    cout<<dp[1][1]%mod<<endl;
}

Measured memory_bytes: 9216
list = list(map(int,list(input())))
odds =[list[i] for i in range(0,len(list),2)]
evens =[list[i] for i in range(1,len(list),2)]
a = odds.count(0)
b = len(odds) - a
c = evens.count(0)
d = len(evens) - c
print(min(a+d,b+c))

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

ll ara[]={100000, 200000,300000};

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	
	reverse(ara,ara+3);

	ll x,y;
	cin>>x>>y;
	
	x--;y--;
	
	ll tot=0;
	if(x<3) tot+=ara[x];
	if(y<3) tot+=ara[y];
	
	if(x==0 && y==0) tot+=400000;
	
	cout<<tot;
	
	
					                                				
	cerr<<"\nTime elapsed: " << 1000.0 * clock() / CLOCKS_PER_SEC << " ms\n";
	
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<set>

int main(){
  int n;
  std::cin >> n;
  std::string a,b,c;
  std::cin >> a >> b >> c;
  int cnt = 0;
  for(int i = 0; i < n; i++){
    std::set<char> st;
    st.insert(a[i]);
    st.insert(b[i]);
    st.insert(c[i]);
    cnt += st.size() - 1;
  }
  std::cout << cnt << std::endl;
}


Measured memory_bytes: 3612
a = list(input())
b = list(input())
c = list(input())
a.append('a')
a.append('a')
b.append('b')
b.append('b')
c.append('c')
c.append('c')
A = []
init = a[0]
j = 1
k = 0
l = 0
for i in range(len(a) + len(b) + len(c) + 3):

    A.append(init)
    if(init == 'a'):
        init = a[j]
        j+=1
    elif(init == 'b'):
        init = b[k]
        k+=1
    else:
        init = c[l]
        l+=1
    if(A.count('a') == len(a)-1):
        print("A")
        break
    elif(A.count('b') == len(b)-1):
        print("B")
        break
    elif(A.count("c") == len(c)-1):
        print("C")
        break

Measured memory_bytes: 3192
#include <bits/stdc++.h>
#define fast ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define N  100000
#define mod 998244353


typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;

using namespace std;


int main() {
	fast;
	int a,b;
	char c;
	cin>>a>>c>>b;
	if(c=='+') cout<<a+b;
	else cout<<a-b;
	
}


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

int main() {
  int A, B, C, K; bool flag = false;
  cin >> A >> B >> C >> K;
 
  for (int i = 0; i <= K; i++) {
  for (int j = 0; j <= K; j++) {
  for (int k = 0; k <= K; k++) {
   int x = A * (1 << i), y = B * (1 << j), z = C * (1 << k);
  if (i + j + k <= K && x < y && y < z) flag = true;
  }

 }
 }

 if (flag == true) cout << "Yes" << endl;
 else cout << "No" << endl;
 return 0;

    
}


Measured memory_bytes: 3608
n=int(input())
arr=list(map(int,input().split()))
tmp=arr[0]
cnt=0
ans=0
for i in range(1,n):
  if tmp>=arr[i]:
    cnt+=1
  else:
    ans=max(ans,cnt)
    cnt=0
  tmp=arr[i]
ans=max(ans,cnt)
print(ans)

Measured memory_bytes: 14252
#include<stdio.h>
#include<math.h>

int main(void){

	double x1,x2,x3,xp,y1,y2,y3,yp,l12,l23,l13,l1p,l2p,l3p,S123,S12p,S23p,S13p;

	while(scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3,&xp,&yp)!=EOF){

		l12=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
		l23=sqrt((x2-x3)*(x2-x3)+(y2-y3)*(y2-y3));
		l13=sqrt((x1-x3)*(x1-x3)+(y1-y3)*(y1-y3));
		l1p=sqrt((x1-xp)*(x1-xp)+(y1-yp)*(y1-yp));
		l2p=sqrt((x2-xp)*(x2-xp)+(y2-yp)*(y2-yp));
		l3p=sqrt((x3-xp)*(x3-xp)+(y3-yp)*(y3-yp));
		S123=(sqrt((l12+l23+l13)*(-l12+l23+l13)*(l12-l23+l13)*(l12+l23-l13)))/4;
		S12p=(sqrt((l12+l2p+l1p)*(-l12+l2p+l1p)*(l12-l2p+l1p)*(l12+l2p-l1p)))/4;
		S13p=(sqrt((l1p+l3p+l13)*(-l1p+l3p+l13)*(l1p-l3p+l13)*(l1p+l3p-l13)))/4;
		S23p=(sqrt((l2p+l23+l3p)*(-l2p+l23+l3p)*(l2p-l23+l3p)*(l2p+l23-l3p)))/4;
		if(fabs(S123-(S12p+S13p+S23p))<0.1){
			puts("YES");
		}
		else{
			puts("NO");
		}
	}

	return 0;
}

Measured memory_bytes: 1040
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1001001001;
const ll LINF = 1001001001001001;
const int MOD = 1000000007;

template <typename T>
void print(const T &v);

vector<pair<ll, ll>> factorization(ll num)
{
    map<ll, ll> mp;

    ll tmp = num;
    for (ll i = 2; i * i <= num; i++)
    {
        while (tmp % i == 0)
        {
            mp[i]++;
            tmp /= i;
        }
    }
    if (tmp != 1)
    {
        mp[tmp]++;
    }
    vector<pair<ll, ll>> ret;
    for (auto m : mp)
    {
        ret.push_back(make_pair(m.first, m.second));
    }
    return ret;
}

int main()
{
    ll n;
    cin >> n;
    auto fac = factorization(n);
    cout << n << ':';
    for (auto f : fac)
    {
        for (int i = 0; i < f.second; i++)
        {
            cout << ' ';
            cout << f.first;
        }
    }
    cout << endl;
    return 0;
}

// Use For Debug
template <typename T>
void print(T const &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << ' ';
        cout << v[i];
    }
    cout << endl;
}


Measured memory_bytes: 3092
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <functional>
#include <random>
#include <time.h>
#include <chrono>
#include <sstream>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define mod 1000000007
#define sort(s) sort(s.begin(), s.end());
#define reverse(s) reverse(s.begin(), s.end());
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
using namespace std;
int POW(int x, int y) { return int(pow(double(x), double(y))); }
double log(double a, double b) { return log(b) / log(a); }

unsigned int randxor()
{
	static unsigned int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
	unsigned int t;
	t = (x ^ (x << 11)); x = y; y = z; z = w; return(w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}

vector<int> h;
int f(int a, int b) {
	int mi=101;

	FOR(i, a, b) {
		mi = min(mi, h[i]);
	}
	int ans = mi;
	int index = 0;
	FOR(i, a, b) {
		h[i] -= mi;
		if (h[i] == 0) {
			if (index != i) {

				ans += f(index, i);
			}
			index = i + 1;
		}
	}
	if (h[b-1] != 0) {
		ans += f(index, b);
	}
	return ans;
}

int main() {
	int n;
	cin >> n;
	h.resize(n);
	rep(i, n) {
		cin >> h[i];
	}
	cout << f(0, n) << endl;
	return 0;

}





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

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define sz(a) ((int)a.size())
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijoMOD(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i<=n;i++){
    num*=yakusu[i];
  }
  return num;
}

int H,W;
vs s(50);
vi dv ={-1,0,1,0};vi du={0,-1,0,1};
int cnt=1;
int dfs(int u,int v){
  s[u][v]='.';
  
  rep(i,4){
   
      int nu =u +du[i],nv=v+dv[i];
      if(nu<0||nu>=H||nv<0||nv>=W)continue;
      if(s[nu][nv]=='.')continue;
      cnt ++;
      dfs(nu,nv);
    
  }
  return cnt;

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

//vc alp ={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
//vc Alp ={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
//cout<<""<<endl;
int main(){
  string A,s,C;cin>>A>>s>>C;
  cout<<"A"<<s[0]<<"C"<<endl;
  
}





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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

const ll mod = 1000000007;

static const ll INF = 1e15;

int main(void)
{
	ll  a, b, c;
	cin >> a >> b >> c;
	set<ll> s;
	s.insert(a);
	s.insert(b);
	s.insert(c);
	if (s.size() == 2) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int mod = 1000000007;
const int INF = 1001001001;

int main(){
    int k,t,a; cin >> k >> t;
    a=0;
    rep(i,t){
        int b; cin >> b;
        a = max(a,b);
    } 
    cout << max(a-1-(k-a),0) << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

    static long gcd(long a, long b) {
        if (a == 0) {
            return b;
        }
        return gcd(b % a, a);
    }

    static long lcm(long a, long b) {
        return (a*b)/gcd(a, b);
    }

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long A = sc.nextInt();
        long B = sc.nextInt();
        System.out.println(lcm(A,B));
    }
}


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

#define REP(i, n) for (int i = 0; i < n; i++)
#define INF 1000000000

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef long double ld;

//ある値がvector内の要素に含まれているか否か判定する
int vector_finder(std::vector<int> vec, int number) {
    auto itr = std::find(vec.begin(), vec.end(), number);
    size_t index = std::distance(vec.begin(), itr);
    if (index != vec.size()) { // 発見できたとき
        return 1;
    } else { // 発見できなかったとき
        return 0;
    }
}

////////////////////////// let's code! /////////////////////////////

int i, j, k;

///// variables frequent to use /////

struct node {
    vector<int> childs;
    int count = 0;
};

void dfs(vector<node> &nodes, int label, int addcount) {

    nodes[label].count += addcount;
    for (int child : nodes[label].childs) {
        dfs(nodes, child, nodes[label].count);
    }
}

int main() {

    int N, Q;

    cin >> N >> Q;

    vector<node> nodes(N);
    int a, b;

    REP(i, N - 1) {
        cin >> a >> b;
        nodes[a - 1].childs.push_back(b - 1);
    }

    int p, x;
    REP(i, Q) {
        cin >> p >> x;
        nodes[p - 1].count += x;
    }

    dfs(nodes, 0, 0);

    REP(i, N) {
        cout << nodes[i].count << " ";
    }

    cout << endl;
};

Measured memory_bytes: 24320
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

void run(void){
  int n,m;
  scanf("%d%d",&n,&m);
  int *a=(int *)calloc(n*m,sizeof(int));
  int i,j,k;
  for(i=0;i<n*m;i++){
    scanf("%d",a+i);
    a[i]--;
  }
  int *cnt=(int *)calloc(m,sizeof(int));
  int min=n;
  for(i=0;i<m;i++){
    memset(cnt,0,sizeof(int)*m);
    for(j=0;j<n;j++){
      for(k=0;k<m;k++){
	if(a[j*m+k]>=0){
	  cnt[a[j*m+k]]++;
	  break;
	}
      }
    }
    int max=0;
    for(j=1;j<m;j++) if(cnt[max]<cnt[j]) max=j;
    if(min>cnt[max]) min=cnt[max];
    for(j=0;j<n*m;j++) if(a[j]==max) a[j]=-1;
  }
  printf("%d\n",min);
}

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


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

const int maxn=1e5+2;

struct ball{
	int s;
	int red;
}ball[maxn];

void move(int x,int y){
	if(ball[x].s<1)return;
	if(ball[x].s==1){
		ball[x].s--;
		ball[y].s++;
		if(ball[x].red){
			ball[y].red=true;
			ball[x].red=0;
		}
//		cout<<x<<":"<<ball[x].red<<endl;
//		cout<<y<<":"<<ball[y].red<<endl;
	}
	else{
		ball[x].s--;
		ball[y].s++;
		if(ball[x].red)
			ball[y].red=1;
//		cout<<x<<":"<<ball[x].red<<endl;
//		cout<<y<<":"<<ball[y].red<<endl;
	}
}

int main(){
	int n,m,x,y;
	cin>>n>>m;
	
	ball[1].red=1;
	ball[1].s=1;
	for(int i=2;i<=n;i++){
		ball[i].s=1;
		ball[i].red=0;
	}
	
	for(int i=0;i<m;i++){
		
		cin>>x>>y;
		move(x,y);
		
	}
	int cnt=0;
	for(int i=1;i<=n;i++)
		if(ball[i].red==1)cnt++;
	cout<<cnt<<endl;
	
	return 0;
}

Measured memory_bytes: 1024
#ABC085C/Otoshidama
N, Y = map(int, input().split())
flag = False
for x in range(0, N+1):
    for y in range(0, N+1):
        z = N - x - y
        z_yen = Y - 10000 * x - 5000 * y
        if  z_yen == 1000 * z and z >= 0 and z <= N:
            ans_x = x
            ans_y = y
            ans_z = z
            flag = True
            break

def ans(flag):
    if flag:
        print(ans_x, ans_y, ans_z)
    else:
        print(-1, -1, -1)
        
ans(flag)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m; i<n; i++)
#define co(n) cout << n << endl
using namespace std;
int main(){
  long a, b, c=0, d=0, e, f, g, h, n;
  string s, t, ans="EQUAL";
  cin >> s >> t;
  
  if(s.size()>t.size()) co("GREATER");
  else if(s.size()<t.size()) co("LESS");
  else{
    rep(i,0,s.size()){
      if(s[i]==t[i]) continue;
      else if(s[i]>t[i]){
        ans="GREATER";
        break;
      }
      else{
        ans="LESS";
        break;
      }
    }
    co(ans);
  }
  
}

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

using namespace std;

#define MAX 1000
#define INF 1e9
typedef pair<int,int> pii;

int H,W[MAX];
string s[MAX];
bool visited[MAX][80];
vector<pii> vec[10000];
const int dx[8] = {-1,0,0,1,-1,-1,1,1};
const int dy[8] = {0,-1,1,0,-1,1,-1,1};

bool inField(int x,int y){
  if(0 > y || y >= H){
    return false;
  }
  if(0 > W[y] || W[y] <= x){
    return false;
  }
  return true;
}

void dfs(int x,int y,int idx){
  if(s[y][x] != '*') return;
  s[y][x] = ' ';
  vec[idx].push_back(pii(x,y));

  for(int i = 0 ; i < 8 ; i++){
    int nx = x + dx[i];
    int ny = y + dy[i];
    if(!inField(nx,ny)) continue;
    dfs(nx,ny,idx);
  }
}

int getArea(vector<pii> &v){
  int px[4] = {INF,0,INF,0};
  int py[4] = {INF,INF,0,0};
  for(int i = 0 ; i < (int)v.size() ; i++){
    int x = v[i].first,y = v[i].second;
    if(y < py[0]){
      px[0] = px[1] = x;
      py[0] = py[1] = y;
    }else if(y == py[0]){
      if(x < px[0]){
        px[0] = x;
      }else if(px[1] < x){
        px[1] = x;
      }
    }
    if(py[2] < y){
      px[2] = px[3] = x;
      py[2] = py[3] = y;
    }else if(py[2] == y){
      if(x < px[2]){
        px[2] = x;
      }else if(px[3] < x){
        px[3] = x;
      }
    } 
  }
  return ((px[1]-px[0]+1)+(px[3]-px[2]+1))*(py[2]-py[0]+1)/2;
}

int main(){
  bool flg = false;
  while(cin >> H,H){
    if(flg){
      cout << "----------" << endl;
    }
    flg = true;
    cin.ignore();
    for(int i = 0 ; i < 10000 ; i++){
      vec[i].clear();
    }
    for(int i = 0 ; i < H ; i++){
      getline(cin,s[i]);
      W[i] = s[i].size();
    }
    int idx = 0;
    for(int i = 0 ; i < H ; i++){
      for(int j = 0 ; j < W[i] ; j++){
        if(s[i][j] == '*'){
          dfs(j,i,idx); idx++;
        }
      }
    }
    map<int,int> cnt;
    for(int i = 0 ; i < idx ; i++){
      int area = getArea(vec[i]);
      cnt[area]++;
    }
    map<int,int>::iterator it;
    for(it = cnt.begin() ; it != cnt.end() ; ++it){
      cout << it->first << " " << it->second << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

int main(){
    fast;
    string s;
    cin>>s;
    ll q;
    cin>>q;
    
    ll l =s.length(), rev = 0;
    
    deque<char> dq;
    for(ll i=0;i<l;i++)
        dq.push_back(s[i]);
    
    while(q--){
        ll t,f;
        char c;
        
        cin>>t;
        if(t==1)
            rev = rev^1;
        else{
            cin>>f>>c;
            if(f==1){
                if(rev==0)
                    dq.push_front(c);
                else
                    dq.push_back(c);
            } else {
                if(rev==0)
                    dq.push_back(c);
                else
                    dq.push_front(c);
            }
        }
    }
    
    string ans;
    ll p = dq.size();
    
    if(rev==0){
        for(ll i=0;i<p;i++){
            char val = dq.front();
            ans += val;
            dq.pop_front();
        }
    } else {
        for(ll i=0;i<p;i++){
            char val = dq.back();
            ans += val;
            dq.pop_back();
        }
    }
    
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 1368
from itertools import product
N=int(input())
XYs = []
for i in range(N):
    A = int(input())
    XYs.append([tuple(map(int, input().split())) for _ in range(A)])

n=0
for ts in product(*[[1, 0] for _ in range(N)]):
    for i, t in enumerate(ts):
        if t:
            if not all(ts[x-1] == y for x, y in XYs[i]):
                break
    else:
        n=max(n,sum(ts))
print(n)


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

bool isP(ll x){
  if(x<2)return false;
  for(ll i=2;i*i<=x;i++)
    if(x%i==0)return false;

  return true;
}

ll check(ll n){
  return ( (n%2==1&& isP(n) && isP( (n+1)/2 ) ) ? 1: 0 );
}

ll a[100005];

int main(){
  for(ll i=1;i<=100000;i++){
    a[i]=a[i-1]+check(i);
  }
  ll q;
  cin>>q;
  while(q--){
    ll l,r;
    cin>>l>>r;
    cout<<a[r]-a[l-1]<<endl;
  }
  return 0;
}


Measured memory_bytes: 1408
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

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

            int intN = int.Parse(Console.ReadLine());

            double dblAns = 0;

            for (int i = intN; i > 0; i--) {
                dblAns = Math.Sqrt(i) % 1;
                if (dblAns == 0) {
                    Console.WriteLine(i);
                    return;
                }else{
                    continue;
                }
            }

        }
    }
}


Measured memory_bytes: 13140
import java.util.Scanner;

public class Main{

  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
int t;
    for(int i = 0;i<10000;i++){
      t = sc.nextInt();
      if(t == 0) break;
      System.out.println("Case "+(i+1)+": "+t);
    }

  }
}


Measured memory_bytes: 42500
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;
using ll = long long;

struct UnionFind {
  vector<int> d;
  UnionFind(int n = 0) : d(n, -1) {}
  int find(int x) {
    if (d[x] < 0) {
      return x;
    }
    return d[x] = find(d[x]);
  }
  bool unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) {
      return false;
    }
    if (d[y] < d[x]) {
      swap(x, y);
    }
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return find(x) == find(y); }
  int size(int x) { return -d[find(x)]; }
};

int deg[100005];
vector<int> to[100005];

int main() {
  int n, m, k;
  cin >> n >> m >> k;
  UnionFind uf(n);
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    --a;
    --b;
    deg[a]++;
    deg[b]++;
    uf.unite(a, b);
  }
  rep(i, k) {
    int a, b;
    cin >> a >> b;
    --a;
    --b;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  rep(i, n) {
    int ans = uf.size(i) - 1 - deg[i];
    for (int u : to[i]) {
      if (uf.same(i, u)) {
        --ans;
      }
    }
    printf("%d%c", ans, i == n - 1 ? '\n' : ' ');
  }
  return 0;
}


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

int main() {
	int n,count=0;
  string str;
	cin >> n;
	for (int i=1;i<=n;i++){
		str=to_string(i);
		if(str.size()%2==1) count++;
	}
	cout << count << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
const long long MX = 1e18;
int main() {
  long long n;
  cin >> n;
 
  long long ans = 1;
  bool ng = false;
  for (long long i = 0; i < n; i++) {
    long long a;
    cin >> a;
    if (a == 0) {
      cout << 0 << endl;
      return 0;
    }
    if (ng || MX / ans < a) {
      ng = true;
    }
    ans *= a;
  }
 
  if (ng) {
    cout << -1 << endl;
  } else {
    cout << ans << endl;
  }
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
 
int main(){
    string s;
    cin>>s;
    if(s[0]!='A'||s.back()=='C'||s[1]=='C'){
        cout<<"WA";
        return 0;
    }
    int c=0;
    for(int i=2;i<s.size();i++){
        if(s[i]=='C')c++;
    }
    if(c!=1){
        cout<<"WA";
        return 0;
    }
    for(int i=1;i<s.size();i++){
        if(s[i]!='C' && isupper(s[i])){
            cout<<"WA";
            return 0;
        }
    }
    cout<<"AC";
    return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
A_list = list(map(int, input().split()))
cost_Dict = {1:2, 2:5, 3:5, 4:4, 5:5, 6:6, 7:3, 8:7, 9:6}
A_Dict = {}
for x in A_list:
    A_Dict[x] = cost_Dict[x]
#def A_cost(x):
#    return A_Dict[x]
dp = [-float('inf')] * (N+1)
dp[0] = 0

A_list = list(A_Dict.keys())
A_list.sort(reverse=True)

for i in range(N+1):
    _list = []
    for x in A_list:
        if i - A_Dict[x] < 0:
            continue
        else:
            dp[i] = max(dp[i], dp[i-A_Dict[x]]+1)

ans = ""
cost = N
while cost > 0:
    for x in A_list:
        if cost - A_Dict[x] < 0:
            continue
        elif dp[cost - A_Dict[x]] == dp[cost] - 1:
            ans += str(x)
            cost -= A_Dict[x]
            break

print(ans)

Measured memory_bytes: 3420