akhauriyash/Code-Regression huggingface dataset:
parseInt(x) = parse(Int,x)
parseMap(x::Array{SubString{String}, 1}) = map(parseInt, x)

function main()
    N,M = parseMap(split(readline()))
    H = parseMap(split(readline()))
    A = zeros(Int,M)
    B = zeros(Int,M)
    for i = 1:M
        A[i],B[i] = parseMap(split(readline()))
    end
    C = zeros(Int, N) .+ 1  
    for i = 1:M
        if H[A[i]] > H[B[i]] 
            C[B[i]] = 0
        elseif H[A[i]] < H[B[i]] 
            C[A[i]] = 0
        else
            C[A[i]] = 0
            C[B[i]] = 0
        end
    end
    println(sum(C))
end

main()

Measured memory_bytes: 208056
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <stdio.h>
#include <vector>
#include <map>

using namespace std;
typedef long long ll;

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

int main() {

    ll N,M;
    cin >> N >> M;
    ll L[N];
    rep(i,N) L[i] = 0;
    rep(i,M){
        ll a,b;
        cin >> a >> b;
        if(a==1) L[b-1]++;
        else if(b==N) L[a-1]++;
    }
    string out = "IMPOSSIBLE";
    rep(i,N){
        if(L[i]==2){
            out = "POSSIBLE";
            break;
        }
    }
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
void solve()
{
	ll l,r,d;
	cin>>l>>r>>d;
	ll c=0;
	for(ll i=l;i<=r;++i)
	{
		if(!(i%d))
			c++;
	}
	cout<<c;
}
int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
        solve();
    return 0;
}

Measured memory_bytes: 3592
n = gets.to_i

counts = []

n.times do
	count = {}
	gets.strip.each_char do |c|
		count[c] = 0 unless count[c]
		count[c] += 1
	end
	counts << count
end

char = []
counts.map{|c|c.keys}.flatten.uniq.each do |c|
	counts.map{|_|_[c] || 0}.min.times{char << c}
end

puts char.sort.join


Measured memory_bytes: 1916
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll W, H, x, y, mul;
double ans;
int main() {
	scanf("%lld %lld %lld %lld", &W, &H,&x,&y);
	double ans = (double)(W*H) / 2;

	if (W == x*2 && H == y*2) {
		mul = 1;
	}
	printf("%.6lf %d\n", ans, mul);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++) 
#define rep(i,n) for(int i = 0; i < (n); i++)
#define chmin(a,b) if((a)>(b)) (a)=(b); 
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define pi pair<int,int>
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={0,1,0,-1,1,-1,-1,1};
int dy[]={1,0,-1,0,1,1,-1,-1};
const int MOD = 1e9+7;
const int INF = 1e18+10;

/*----------------------------------------------*/

signed main(){
  int n;
  cin>>n;
  map<string,int> mp;
  rep(i,n){
    string s;
    cin>>s;
    mp[s]++;
  }
  int ans=0;
  for(auto m:mp){
    ans++;
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 19100
#include<iostream>
using namespace std;long long p[1<<17],N,Q,A,R,sum,cnt,i;main(){cin>>N>>Q;for(i=0;i<N;i++)cin>>p[i];while(Q--){sum=0,R=0;cin>>A;cnt=0;for(i=0;i<N;i++){while(R<N&&sum+p[R]<=A)sum+=p[R++];if(sum>0)sum-=p[i];cnt+=R-i;if(R<i+1)R=i+1;}cout<<cnt<<endl;}}

Measured memory_bytes: 3832
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define mod ((int)1e9+7)
#define lim 1000000000000000007
#define lim1 18446744073709551615  //Unsigned
#define sq(a) ((a)*(a))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define mms(v,i) memset(v,i,sizeof(v))
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define REPN(i,a,b) for (int i = a; i >= b; i--)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int,int> pi;
typedef pair<ll,ll> PL;
typedef pair<ll,int> PLI;
typedef pair<int,ll> PIL;
typedef pair<int,pair<int,int> > pii;
typedef pair<double,double> pdd;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
ll power(ll a,ll b) {
   ll res=1;
   while(b){
      if(b%2==1) res=(res*a)%mod;
      a=(a*a)%mod;
      b>>=1;
   }
   return res;
}
ll gcdll(ll a,ll b) {
    if (b==0) return a;
    return gcdll(b,a%b);
}
int gcd(int a,int b) {
    if (b==0) return a;
    return gcd(b,a%b);
}

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

const int N = (int)1e6+5;
const int M = (int)3e3+5;
const int Q = 301;
const int logN = 19;

void solve() {
    string s;
    cin>>s;
    s[1] = (s[1]=='R')?'B':'R';
    cout<<s;
}
int main() {
    //freopen("output.txt","r",stdin);
    //freopen("output.txt","w",stdout);

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int T=1;
    //cin>>T;
    REP(TC,1,T) {
        //cout<<"Case #"<<TC<<": ";
        solve();
        cout<<"\n";
    }
}


Measured memory_bytes: 3620
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    test_a();
}

fn test_a() {
    let a1: i32 = read();
    let a2: i32 = read();
    let a3: i32 = read();
    if (a1 + a2 + a3) >= 22 {
        println!("bust");
    } else {
        println!("win");
    }
}


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

int main() {
  int N, T;
  cin >> N >> T;
  vector<pair<int, int>> V(N);
  for (int i = 0, a, b; cin >> a >> b; i++) V.at(i) = {a, b};
  sort(V.begin(), V.end());
  vector<int> DP(T, -1);
  DP.at(0) = 0;
  int ans = 0;
  for (int i = 0; i < N; i++) {
    auto[a, b] = V.at(i);
    for (int i = T - 1; i >= 0; i--) {
      if (DP.at(i) != -1) {
        if (i + a < T) DP.at(i + a) = max(DP.at(i + a), DP.at(i) + b);
        else ans = max(ans, DP.at(i) + b);
      }
    }
  }
  cout << max(*max_element(DP.begin(), DP.end()), ans) << "\n";
}

Measured memory_bytes: 3596
A = int(input())
B = int(input())
C = int(input())
X = int(input())
count = 0
for i in range(A+1):
  for j in range(B+1):
    for k in range(C+1):
      if 500*i + 100*j + 50*k == X:
        count+=1
print(count)


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

int main() {
  int N;
  cin>>N;
  int A[N];
  priority_queue<int>q;
  rep(i,N){
    int kazu;
    cin>>kazu;
    A[i]=kazu;
    q.push(kazu);
  }
  int atai=0;
  rep(i,N){
    atai=q.top();q.pop();
    if(A[i]==atai){
      int atai2=atai;
      atai=q.top();q.pop();
      cout<<atai<<endl;
      q.push(atai2);
      q.push(atai);
    }else{
      cout<<atai<<endl;
      q.push(atai);
    }
  }
  return 0;
}

Measured memory_bytes: 3316
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30
#define pb push_back
#define mp make_pair

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

int main() {
	int n;

	while(cin >> n && n) {
		vector< vector<int> > v(n, vector<int>(n));
		rep(i,n) {
			rep(j,n) {
				cin >> v[i][j];
			}
		}

		int ans = -1;
		rep(i,n) {
			rep(j,n) {
				int vmin = v[i][j], vmax = v[i][j];
				rep(k,n) {
					vmin = min(vmin, v[i][k]);
					vmax = max(vmax, v[k][j]);
				}

				if(vmin == v[i][j] && vmax == v[i][j]) {
					ans = v[i][j];
				}
			}
		}

		if(ans == -1) cout << 0 << endl;
		else cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 1212
#include<iostream>
#include<cstdio>
#include<cstring>
int n,m,k;
void inc(int &x){if(x<k-2 || x>k+1)x++;else x=k+2;}
int main()
{
	scanf("%d%d",&n,&k),m=n*2-1;
	if(m==1){printf("Yes\n1\n");return 0;}
	if(k==1 || k==m){printf("No\n");return 0;}
	printf("Yes\n");
	int ind=0;
	for(int i=1;i<n-1;i++)inc(ind),printf("%d\n",ind);
	printf("%d\n%d\n%d\n",k-1,k,k+1);
	for(int i=1;i<n-1;i++)inc(ind),printf("%d\n",ind);
	return 0;
}


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

int main(void){
  string A,B;
  cin >> A >> B;
  if(A.length() > B.length())
    cout << "GREATER" << endl;
  else if(A.length() < B.length())
    cout << "LESS" << endl;
  else{
    if(A > B)
      cout << "GREATER" << endl;
    else if(A < B)
      cout << "LESS" << endl;
    else
      cout << "EQUAL" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <stack>

using namespace std;

long long int not_1(long long int a) {
	stack<int> stk;
	while (a != 1) {
		if (a % 2 == 0) {
			stk.push(0);
		}
		else {
			stk.push(1);
		}
		a /= 2;
	}
	long long int c = 0;
	while (!stk.empty()) {
		c *= 2LL;
		int b = stk.top();
		stk.pop();
		if (b == 0) {
			c++;
		}
	}
	c++;
	return c;
}

int main() {

	long long int n;
	cin >> n;
	
	vector<long long int> a(n);
	vector<int> a2(n, 0);

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

	sort(a.begin(), a.end());

	long long int ans = 0;

	for (long long int i = n-1; i >= 0; i--) {
		if (a2[i] == 1) {
			continue;
		}
		long long int b = not_1(a[i]);//a[i]の否定+1
		//cout << b << endl;
		vector<long long int>::iterator ite = lower_bound(a.begin(), a.end(), b);
		long long int nn = ite - a.begin();
		//cout << nn << endl;
		if (nn != n && a2[nn] == 0 && a[nn] == b && nn != i) {
			//cout << a[i] << ' ' << b << endl;
			ans++;
			a2[nn] = 1;
			a[nn] = a[nn] - 1;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 2560
//////////////////////////// ⛎🎱💲♏☢🤘(NOOB 383)
//////////////////////////// 🇨🇸🇪 48
//////////////////////////// 🇯🇦🇭🇦🇳🇬🇮🇷🇳🇦🇬🇦🇷 🇺🇳🇮🇻🇪🇷🇸🇮🇹🇾((JU))

#include<bits/stdc++.h>
using namespace std;
#define LL long long int
#define DL double
#define MLL map<LL,LL>::iterator
#define MSL map<string,L>::iterator
#define MLS map<LL,string>::iterator
#define MSS map<string,string>::iterator
#define MCL map<char,LL>::iterator
#define SL set<LL>::iterator
#define SS set<string>::iterator sl
#define G getline
#define SZ size()
#define IN insert
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define endl "\n"
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
V< LL >u,v;
int main()
{
    FAST;
    LL n,m,i,j,k,p,q,o,l,s,t,z;

    cin>>n>>m>>s;
    for(i=0;i<n;i++)
    {
        cin>>o;
        u.PSB(o);
    }
    for(i=0;i<m;i++)
    {
        cin>>o;
        v.PSB(o);
    }
    k=99999999999999;
    for(i=0;i<s;i++)
    {
        cin>>p>>q>>o;
        if(u[p-1]+v[q-1]-o<k)
        {
            k=u[p-1]+v[q-1]-o;
        }

    }
    sort(u.B,u.E);
    sort(v.B,v.E);
    k=min(k,u[0]+v[0]);
    cout<<k<<endl;


    return 0;

}


Measured memory_bytes: 2548
def e(x,y):
 A[y][x]='0'
 for dx,dy in[[-3,0],[-2,0],[-1,0],[1,0],[2,0],[3,0],[0,-3],[0,-2],[0,-1],[0,1],[0,2],[0,3]]:
  if 0<=x+dx<8 and 0<=y+dy<8 and A[y+dy][x+dx]=='1':e(x+dx,y+dy)

for i in range(int(input())):
 print(f'Data {i+1}:')
 input()
 A=[list(input())for _ in[0]*8]
 e(int(input())-1,int(input())-1)
 for r in A:print(''.join(r))


Measured memory_bytes: 5648
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double

ll process(ll x){
  int cnt = 0;
  for (int i = 0; i <= 60; ++i){
    if (x & (1LL << i))
      ++cnt;
  }
  return x % cnt;
}

ll string_ll(string& N, int mod){
  ll res = 0;
  for (int i = 0; i < N.size(); ++i){
    res = (res * 2 + (N[i] - '0')) % mod;
  }
  return res;
}

ll modpow(ll a, ll b, ll mod){
  if (b == 0) return 1;
  ll tmp = modpow(a, b / 2, mod);
  if (b % 2)
    return tmp * tmp % mod * a % mod;
  return tmp * tmp % mod;
}

int main(void){
  vector<ll> res(200001, 0);
  for (int i = 1; i <= 200000; ++i){
    res[i] = res[process(i)] + 1;
  }
  
  int N; cin >> N;
  string X; cin >> X;

  int cnt1 = 0;
  for (auto xi : X)
    if (xi == '1') ++cnt1;

  int cnt0 = N - cnt1;

  ll X_0_1 = cnt1 > 1 ? string_ll(X, cnt1 - 1) : 0;
  ll X_1_0 = string_ll(X, cnt1 + 1);

  // cout << X_0_1 << " " << X_1_0 << endl;

  for (int i = 0; i < N; ++i){
    if (X[i] == '1'){
      if (cnt1 == 1){
        cout << 0 << endl;
      }
      else{
        ll x = X_0_1 - modpow(2, N - i - 1, cnt1 - 1) + cnt1 - 1;
        x %= cnt1 - 1;
        // cout << "  " << x << endl;
        cout << res[x] + 1 << endl;
      }
    }
    else{
      ll x = X_1_0 + modpow(2, N - i - 1, cnt1 + 1);
      x %= cnt1 + 1;
      // cout << "  " << x << endl;
      cout << res[x] + 1 << endl;
    }
  }

  return 0;
}

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

int main() {
	int d, ans;
	while (cin >> d) {
		ans = 0;
		for (int i = d; i < 600; i += d) ans += pow(i, 2) * d;
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 3004
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#define initdp(a, b)  for (int i = 0; i <= a; i++)   for (int j = 0; j <= b; j++) dp[i][j] = -1;
#define pb push_back
#define mpr make_pair
#define pii pair<int, int>
#define ll long long
#define pll pair<ll, ll>
#define all(arr) arr.begin(), arr.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repd(i, n) for (int i = n - 1; i >= 0; i--)
#define fo(i, l, r) for (int i = l; i <= r; i++)
#define INF 1000000001
#define inf1 1000000000000000001
#define mod 1000000007
#define pie 3.14159265358979323846264338327950L
#define N 1000005
#define mid(l, r) l + (r - l) / 2
#define vec vector<int>
#define vecl vector<ll>
#define umap unordered_map<ll,ll>
#define yes cout << "YES" << endl;
#define no cout << "NO" << endl;
#define endl "\n"
using namespace std;


 
 
 
 
 
void solve(){
 
   
   
 int k,a,b;
 cin>>k>>a>>b;

 for(int i=a; i<=b; i++) {
     if(i%k ==0 ) {
         cout<<"OK";
         return;
     }
 }

 cout<<"NG";
 
    
 
 
}
 
 
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout<<fixed<<setprecision(20);
    int t = 1;
   //  cin >> t;
    while (t--)
    {
        solve();
    }
}

Measured memory_bytes: 3656
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	ans := 0
	var a int
	for i := 1; i <= n; i++ {
		fmt.Scan(&a)
		if i%2 == 1 && a%2 == 1 {
			ans++
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1768
#include<bits/stdc++.h>
using namespace std;
 
#define online_judge            freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define fastio                    ios::sync_with_stdio(false);cin.tie(0);
#define ll                      long long
#define pii                     pair<int, int>
#define pli                     pair<ll, int>
#define pil                     pair<int, ll>
#define pll                     pair<ll, ll>
#define vi                      vector<int>
#define vll                     vector<ll>
#define vb                      vector<bool>
#define vd                      vector<double>
#define vs                      vector<string>
#define ff                      first
#define ss                      second
#define pb                      push_back
#define eb                      emplace_back
#define ppb                     pop_back
#define pf                      push_front
#define ppf                     pop_front
#define vpii                    vector<pii>
#define vpll                    vector<pll>
#define umap                    unordered_map
#define all(x)                  x.begin(),x.end()
#define clr(a,b)                memset(a,b,sizeof a)
#define fr(i, n)                for(ll i=0; i<n;++i)
#define fr1(i, n)               for(ll i=1; i<=n; ++i)
#define rfr(i, n)               for(ll i=n-1; i>=0; --i)
#define precise(x)              cout<<fixed<<setprecision(x)
#define wh                      while
#define mp                      make_pair
#define le                      length()
#define endl                    "\n"
#define sf                        scanf    
 
const ll M=1e9+7; 
 
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
 
ll lcm(ll a,ll b)
{ return (a*b)/__gcd(a,b); }
 
 
ll power(ll x, ll y, ll p)  
{  
    ll res = 1;    
 
    x = x % p;
   
    if (x == 0) return 0;
 
    while (y > 0)  
    {  
       
        if (y & 1)  
            res = (res*x) % p;  
 
       
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;  
}  
bool inside(ll x,ll y,ll n,ll m)
{
    return(x>=0&&x<n&&y>=0&&y<m);
}  

ll powmod(ll n)
{
    ll ret = 1;
    ll a = 2;
    while (n > 0) {
        if (n & 1) ret = ret * a % M;
        a = a * a % M;
        n >>= 1;
    }
    return ret;
}
 
ll modfact(ll n, ll p)
{
    if (n >= p)
        return 0;
 
    ll result = 1;
    for (int i = 1; i <= n; i++)
        result = (result * i) % p;
 
    return result;
}

long long binpower(long long a, long long b) {
    if (b == 0)
        return 1;
    long long res = binpower(a, b / 2);
    if (b % 2)
        return res * res * a;
    else
        return res * res;
}

///////////// TEMPLATE END /////////////////////////////////



void solve()
{
	vll a(4);
	
	fr(i,4)
	{
		cin>>a[i];
	}
	ll ans=a[0]*a[2];
	fr(i,2)
	{
		for(ll j=2;j<4;j++)
		{
			ans=max(a[i]*a[j],ans);
		}
	}
	cout<<ans<<endl;
}



int main()
{
    fastio

//    int t;
//    cin>>t;
//    fr1(i,t)
    {
//        cout<<"Case #"<<i<<": ";
        solve();
    }
   
    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1000000007;
const int INF = INT_MAX / 2;

int main(){
    string a, b; cin >> a >> b;
    a += b;
    int c = stoi(a);
    int d = round(sqrt(c));

    if(d*d==c){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
// TLE

#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

typedef pair<int,int> pii;

vector<pii> refresh(vector<pii> v) {
  int n = v.size();
  vector<bool> f(n, true);
  REP(i, n) {
    REP(j, n) {
      if (i == j || !f[j]) continue;
      if (v[i].first <= v[j].first && v[i].second <= v[j].second) {
        f[i] = false;
        break;
      }
    }
  }
  vector<pii> res;
  REP(i,n)
    if (f[i])
      res.push_back(v[i]);
  return res;
}

int main() {
  int h,w;
  while(cin>>h>>w,w+h) {
    char ba[w][h];
    REP(y,h)
      REP(x,w) 
        cin >> ba[x][y];
    vector<pii> dp[w][h];
    int ans = 0;
    REP(y,h) {
      REP(x,w) {
        if (ba[x][y]=='.') {
          int ue = 0, hidari = 0;
          for (int i = y-1; i>=0 && ba[x][i]=='.'; i--) ue++;
          for (int i = x-1; i>=0 && ba[i][y]=='.'; i--) hidari++;
          vector<pii> v;
          if (ue>0&&hidari>0) {
            FOR(it,dp[x-1][y]) {
              v.push_back(pii(it->first+1, min(ue+1,it->second)));
            }
            FOR(it,dp[x][y-1]) {
              v.push_back(pii(min(hidari+1,it->first), it->second+1));
            }
            v.push_back(pii(1,ue+1));
            v.push_back(pii(hidari+1,1));
          } else {
            v.push_back(pii(hidari+1,ue+1));
          }
          dp[x][y] = refresh(v);
          //  cout << hidari << " "<<ue;
          
          FOR(it,dp[x][y]) {
            //  printf("(%d,%d)",it->first,it->second);
            ans = max(ans, it->first * it->second);
          }
        }
        //    cout << "_";
      }
      //cout << endl;
    }
    cout << ans << endl;
  }
}

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

struct Point{
	long long X,Y;
	inline void read(){scanf("%lld%lld",&X,&Y);}
	inline long long plength(){return X*X+Y*Y;}
	Point(){X=Y=0;}
	Point(long long X_,long long Y_){X=X_,Y=Y_;}
};
struct Line{
	Point A,B;
	inline void read(){A.read(),B.read();}
	Line(){}
	Line(const Point &A_,const Point &B_){A=A_,B=B_;}
};
typedef Point Vector;
inline Vector operator - (const Point &A,const Point &B){return Vector(A.X-B.X,A.Y-B.Y);}
inline long long operator ^ (const Point &A,const Point &B){return A.X*B.X+A.Y*B.Y;}
inline long long operator * (const Point &A,const Point &B){return A.X*B.Y-A.Y*B.X;}
inline Point operator + (const Point &A,const Vector &B){return Point(A.X+B.X,A.Y+B.Y);}
inline Vector operator * (const Vector &A,long long k){return Vector(A.X*k,A.Y*k);}

int Q;

inline long long sqr(long long k){return k*k;}

Point Projection(const Line &L,const Point &P){
	long long len=((P-L.A)^(L.B-L.A))/(L.B-L.A).plength();
	return L.A*(1-len)+L.B*len;
}

Point Reflection(const Line &L,const Point &P){
	Point projection=Projection(L,P);
	return projection+(projection-P);
}

int CCW(const Point &P0,const Point &P1,const Point &P2){
	long long cro=(P1-P0)*(P2-P0);
	if (cro) return cro>0?0:1;
	long long dot=(P1-P0)^(P2-P0);
	if (dot<0) return 2;
	else return (P1-P0).plength()<(P2-P0).plength()?3:4;
}

Point P0,P1,P2;

const char result[5][20]={"COUNTER_CLOCKWISE","CLOCKWISE","ONLINE_BACK","ONLINE_FRONT","ON_SEGMENT"};

int main(){
	P0.read(),P1.read();
	scanf("%d",&Q);
	while (Q--){
		P2.read();
		puts(result[CCW(P0,P1,P2)]);
	}
}



Measured memory_bytes: 3168
#include<iostream>
#include<vector>
#include<string>
#include<set>
#include<algorithm>
#include<cstring>

using namespace std;

// 二部グラフ最大マッチング
vector<int> G[200];
int match[200];
bool used[200];

void add_edge(int u, int v) {
	G[u].push_back(v);
	G[v].push_back(u);
}

bool dfs(int v) {
	used[v] = true;
	for (int i = 0; i < G[v].size(); i++) {
		int u = G[v][i], w = match[u];
		if (w < 0 || !used[w] && dfs(w)) {
			match[v] = u;
			match[u] = v;
			return true;
		}
	}
	return false;
}

int bipartite_matching(int n) {
	int res = 0;
	memset(match, -1, sizeof(match));
	for (int v = 0; v < n; v++) {
		if (match[v] < 0) {
			memset(used, 0, sizeof(used));
			if (dfs(v)) res++;
		}
	}
	return res;
}




int main() {
	int n;
	int k, l;
	cin >>n;
	vector<int> a(n);
	vector<int> b(n);
	vector<int> c(n);
	vector<int> d(n);
	for (int i = 0; i < n; ++i) {
		cin >> k >> l;
		a[i] = k;
		b[i] = l;
	}
	for (int i = 0; i < n; ++i) {
		cin >> k >> l;
		c[i] = k;
		d[i] = l;
	}
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < n; ++j) {
			if (a[i] < c[j] && b[i] < d[j]) {
				add_edge(i, j + n);
			}
		}
	}

	int ans = bipartite_matching(n);
	
	cout << ans << endl;


	return 0;
}


Measured memory_bytes: 256
/*double p =log(a);
    p=p-floor(p);
    int x=pow(10,p);    m s di
 int x =floor(log10(a)) + 1;  d co
 a=ceil(log2(n)) == floor(log2(n)); pow of 2
       cin>>a;
     vector<int> c(a);*/
#include<bits/stdc++.h>
#include<iostream>
#include<math.h>
#include<string>
using namespace std;
int main()
{
    long long int a,b,d,e,i,j,n=0,m,c[1000],p=0,x,y,z,xx,pp;
    string s;
    cin>>a;
   cin>>s;
   if(a>=3200) cout<<s<<endl;
   else cout<<"red"<<endl;

}


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

int main() {
    int64_t n;
    vector<int64_t> time(5);
    cin >> n;
    for(auto& e : time) {
        cin >> e;
    }
    sort(time.begin(), time.end());
    cout << 5 + n / time[0] + (n % time[0] != 0 ? 1 : 0) - 1 << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);
	static int N;
	static int[] hi, lo;
	static int[] pow10 = new int[8];

	public static void main(String[] args) {
		pow10[0] = 1;
		for (int i = 1; i < pow10.length; ++i) {
			pow10[i] = pow10[i - 1] * 10;
		}
		while (sc.hasNext()) {
			N = sc.nextInt();
			if (N == 0) break;
			hi = new int[N];
			lo = new int[N];
			for (int i = 0; i < N; ++i) {
				lo[i] = sc.nextInt();
				hi[i] = sc.nextInt();
			}
			long ans = solve();
			System.out.println(ans);
		}
	}

	static long solve() {
		boolean[] first = new boolean[1000000];
		boolean[] second = new boolean[1000000];
		enumerate(0, 0, N / 2, first);
		enumerate(0, N / 2, N, second);
		long ret = 0;
		for (int i = N; i <= 2 * N; ++i) {
			ret += solveDigits(i, first, second);
		}
		return ret;
	}

	static void enumerate(int cur, int idx, int ei, boolean[] bitmap) {
		if (idx == ei) {
			bitmap[cur] = true;
			return;
		}
		for (int i = lo[idx]; i <= Math.min(hi[idx], 9); ++i) {
			enumerate(cur * 10 + i, idx + 1, ei, bitmap);
		}
		for (int i = Math.max(10, lo[idx]); i <= hi[idx]; ++i) {
			enumerate(cur * 100 + i, idx + 1, ei, bitmap);
		}
	}

	// 全体がdigits桁あるパターン数を数える
	static long solveDigits(int digits, boolean[] first, boolean[] second) {
		long ret = 0;
		int fFix = Math.max(N / 2, digits - (N - N / 2) * 2); // 必ず前半部になる桁数
		int sFix = Math.max(N - N / 2, digits - (N / 2) * 2); // 必ず後半部になる桁数
		int center = digits - fFix - sFix;
		if (center == 0) {
			long fc = 0;
			long sc = 0;
			for (int i = pow10[fFix - 1]; i < pow10[fFix]; ++i) {
				if (first[i]) ++fc;
			}
			for (int i = pow10[sFix - 1]; i < pow10[sFix]; ++i) {
				if (second[i]) ++sc;
			}
			return fc * sc;
		}

		for (int i = 0; i < pow10[center]; ++i) {
			int[] fb = new int[pow10[fFix]];
			int[] sb = new int[pow10[sFix]];
			for (int j = 0; j <= center; ++j) { // 中央部の値がiであり、うち初めのj桁が前半部に含まれる場合
				int cf = i / pow10[center - j];
				int cs = i % pow10[center - j];
				int fd = fFix + j;
				for (int k = pow10[fd - 1] + cf; k < pow10[fd]; k += pow10[j]) {
					if (first[k]) {
						fb[k / pow10[j]] |= 1 << j;
					}
				}
				if (j != center && cs < pow10[center - j - 1]) {
					continue; // 後半部がleading zeroになっている
				}
				for (int k = (j == center ? pow10[sFix - 1] : 0); k < pow10[sFix]; ++k) {
					if (second[k + cs * pow10[sFix]]) {
						sb[k] |= 1 << j;
					}
				}
			}

			// inclusion-exclusion
			for (int j = 1; j < (1 << (center + 1)); ++j) {
				long fc = 0;
				long sc = 0;
				for (int k = 0; k < fb.length; ++k) {
					if ((fb[k] & j) == j) ++fc;
				}
				for (int k = 0; k < sb.length; ++k) {
					if ((sb[k] & j) == j) ++sc;
				}
				long count = fc * sc;
				ret += Integer.bitCount(j) % 2 == 0 ? -count : count;
			}
		}
		return ret;
	}

}

Measured memory_bytes: 323620
#include <bits/stdc++.h>
using namespace std;
#define ll long long int 
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define mx *max_element
#define mn *min_element
#define fo(i,n) for(ll i=0;i<n;i++)
#define loop(i,a,b) for(ll i=a;i<=b;i++)
#define rfo(i,n) for(ll i=n-1;i>=0;i--)
#define rloop(i,a,b) for(ll i=a;i>=b;i--)
#define all(x) x.begin(),x.end()
#define sortall(x) sort(all(x))
#define precision cout<<fixed<<setprecision(50)
#define mem(x,p) memset(x,p,sizeof(x))
#define w(t) ll t;cin>>t;while(t--)
#define kk "\n"
#define setbits(x) __builtin_popcountll(x)
const double pi=3.1415926535897932384626;
//const ll mod = 998244353;
const ll mod=1e9+7;
int main()
{
  IOS
  ll n;
  cin>>n;
  vector <ll> p(n),q(n);
  fo(i,n)
  cin>>p[i];
  fo(i,n)
  cin>>q[i];
  ll c=1;
  for(ll i=1;i<=n;i++)
  	c=c*i;
  vector <ll> a(n);
  for(ll i=1;i<=n;i++)
  	a[i-1]=i;
  vector <vector <ll>> ans(c,vector<ll>(n));
  ll r=0;
  do
  {
  	ans[r++]=a;
  }while(next_permutation(all(a)));
  ll u=0,v=0;
  fo(i,c)
  {
  	ll f=0;
  	fo(j,n)
  	{
  		if(ans[i][j]!=p[j])
  		{
  			f=1;
  			break;
  		}
  	}
  	if(!f)
  		u=i;
  	f=0;
  	fo(j,n)
  	{
  		if(ans[i][j]!=q[j])
  		{
  			f=1;
  			break;
  		}
  	}
  	if(!f)
  		v=i;
  }
  cout<<abs(u-v);
  return 0;
}

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

#define ll long long
#define pb push_back
#define endl "\n"

using namespace std;
const ll maxn=4e5+100;
const ll mod = 998244353;
vector<ll> adj[maxn];
bool dd[maxn];
ll gt[maxn];
ll mu (ll a, ll n,ll mod )
{
    if (n==1) return a;
     if (n==0) return 1;
      ll t= mu(a,n/2, mod );
      t=( t%mod *t%mod )%mod ;
      if (n%2==0)
      {
          return t;
      }
      else
      {
          return (t*a) %mod;
      }
}
ll nck (ll n,ll k )
{
    return (gt[n]%mod * mu(gt[k],mod-2,mod )%mod * mu(gt[n-k],mod-2,mod )%mod )%mod ;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //freopen("test.txt","r",stdin);
  //  freopen("WEDDING.INP", "r", stdin);
   //  freopen("WEDDING.OUT", "w", stdout)

    ll n, m,k ;
     cin>> n>> m>> k;
     gt[0]=1;
      for (int i=1;i<maxn;i++)
      {
   gt[i]=(gt[i-1]* i)%mod ;
      }
      ll ans=0;
      for (int i=0;i<=k;i++)
      {
          ll t= ( (m%mod * (nck(n-1,i))%mod ) %mod * mu(m-1,n-1-i,mod ))%mod;
          ans=( ans+t)%mod;
      }
      cout <<ans;



}


Measured memory_bytes: 16092
#include "stdio.h"

void merge(int matrix[], int left, int mid, int right, int* pcnt){

  int n1 = mid - left;
  int n2 = right - mid;

  int* Left  = new int [n1+1];
  int* Right = new int [n2+1];

  for(int i=0;i<n1;i++){
    Left[i] = matrix[left+i];
  }

  for(int i=0;i<n2;i++){
    Right[i] = matrix[mid+i];
  }
  
  int max = 2000000000;
  Left[n1] = max;
  Right[n2] = max;

  int j,k;
  j=0;
  k=0;
  for(int i=left;i<right;i++){
    *pcnt =  *pcnt + 1;
    if(Left[j] <= Right[k] ){
      matrix[i] = Left[j];
      j++;
    }else{
      matrix[i] = Right[k];
      k++;
    }
  }
 
  delete [] Left;
  delete [] Right;

}

void mergeSort(int matrix[], int left, int right, int* pcnt){

  int mid = (int)( ( left+right)/2.0 );
  
  if(left + 1 >= right){
    return;
  }else{
    mergeSort(matrix, left, mid, pcnt);
    mergeSort(matrix, mid, right, pcnt);
    merge(matrix, left, mid, right, pcnt);
  }

}


void outputMatrix(int matrix[], int N){
  for(int i=0;i<N;i++){
    if(i>0){
      printf(" ");
    }
    printf("%d", matrix[i]);
  }
  printf("\n");
}

int main(void){
  
  int N;
  scanf("%d", &N);

  int* matrix = new int [N];
  for(int i=0;i<N;i++){
    scanf("%d", &matrix[i]);
  }
  
  int cnt = 0;
  mergeSort(matrix, 0, N, &cnt);
  outputMatrix(matrix, N);
  printf("%d\n", cnt);

  delete [] matrix;

  return 0;
}


Measured memory_bytes: 6340
c = []
for _ in range(3):
    c.append([int(x) for x in input().split()])

a = [0]
b = [c[0][i] for i in range(3)]

for j in range(1, 3):
    a.append(c[j][j] - b[j])
ans = 'Yes'
for k in range(3):
    for m in range(3):
        if c[k][m] != a[k] + b[m]:
            ans = 'No'
            break
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <tuple>
#include <queue>
#include <bitset>
#include <unordered_map>
#include <tuple>
#include <utility>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <sys/time.h>

using namespace std;

void solve(long long n, long long x, vector<long long> a){
  sort(a.begin(), a.end());
  long long ret = 0;
  long long idx = 0;
  while (x > 0 && idx < a.size()) {
    x -= a[idx];
    ret++;
    idx++;
  }
  if (x != 0) {
    ret--;
  }
  std::cout << ret << std::endl;
}

int main(){
  long long n;
  long long x;
  scanf("%lld",&n);
  vector<long long> a(n);
  scanf("%lld",&x);
  for(int i = 0 ; i < n ; i++){
    scanf("%lld",&a[i]);
  }
  solve(n, x, a);
  return 0;
}


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

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

int main()
{
    char s[30];
    scanf("%27s", s);
    int a[30];
    int i = 0;
    int cnt = 0;
    for (i = 0; i < 30; i++)
    {
        if (s[i] == '\0')
        {
            cnt = i;
            break;
        }
        a[i] = s[i];
    }
    int changed = 1;
    while (changed == 1)
    {
        changed = 0;
        for (i = 0; i < cnt - 1; i++)
        {
            if (a[i] > a[i + 1])
            {
                swap(&a[i], &a[i+1]);
                changed = 1;
            }
        }
    }
    int diffed = 1;
    for (i = 0; i < cnt - 1; i++)
    {
        if (i == 0)
        {
            if (a[i] == a[i + 1])
            {
                diffed = 0;
            }
        }
        else
        {
            if (a[i - 1] == a[i])
            {
                diffed = 0;
            }
            else if (a[i] == a[i + 1])
            {
                diffed = 0;
            }
        }
    }
    if (diffed)
    {
        printf("yes\n");
    }
    else
    {
        printf("no\n");
    }
    return 0;
}


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

const int INF = 1000000000;
const int MOD = 1000000007;

int main () {
	int x1, y1, x2, y2, x3, y3, x4, y4;
	cin >> x1 >> y1 >> x2 >> y2;
	int dx = x2 - x1, dy = y2 - y1;
	x3 = x2 - dy;
	y3 = y2 + dx;
	x4 = x1 - dy;
	y4 = y1 + dx;
	cout << x3 << ' ' << y3 << ' ' << x4 << ' ' << y4 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod=1000000007;
int q[100009],w[100009];

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

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

using namespace std;
using lint = long long;

int main() {
    lint x;
    cin >> x;

    for (lint i = -200; i <= 2000; i++) {
        for (lint j = -200; j <= 200; j++) {
            if (pow(i, 5) - pow(j, 5) == x) {
                cout << i << ' ' << j << '\n';
                return 0;
            }
        }
    }
}


Measured memory_bytes: 4040
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{

	public static void main(String[] args){

		BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));
		int num, key;
		String str;
		String[] str_array;
		try{
		num=Integer.parseInt(reader.readLine());
		str=reader.readLine();
		str_array=str.split(" ");

		int[] array=new int[num];
		for(int i=0;i<num;i++){
			array[i]=Integer.parseInt(str_array[i]);
		}

		for(int i=0;i<num;i++){
			key=array[i];
			int j=i-1;
			while(j>=0&&array[j]>key){
				array[j+1]=array[j];
				j--;
			}
			array[j+1]=key;

			for(int k=0;k<num;k++){
				System.out.print(array[k]);
				if(k!=num-1)System.out.print(" ");
			}
			System.out.println();
		}


		}catch(IOException e){
			//????????????
		}


	}

}

Measured memory_bytes: 30084
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=1e9+7;
vector<ll>dp(200010,-1);
vector<ll>c(200010);
vector<ll>nxt(200010,inf);
ll solve(ll i){
    if(dp[i]>=0)return dp[i];
    if(nxt[i]==i+1){
        dp[i]=solve(i+1);
    }
    else if(nxt[i]==inf){
        dp[i]=solve(i+1);
    }else{
        dp[i]=(solve(i+1)+solve(nxt[i]))%inf;
    }
    return dp[i];
}
int main(){
    ll n;cin>>n;
    rep(i,n){
        cin>>c[i];
    }
    dp[n-1]=1;
    vector<ll>last(200010,inf);
    for(int i=n-1;i>=0;i--){
        nxt[i]=last[c[i]];
        last[c[i]]=i;
    }
    ll ans=solve(0);
    cout<<ans<<endl;
}

Measured memory_bytes: 12928
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        m: usize,
        ps: [(usize1, String); m],
    }

    let mut solved = vec![false; n];
    let mut penalty = vec![0; n];

    for (p, s) in ps.into_iter() {
        if !solved[p] && s == "WA" {
            penalty[p] += 1;
        }
        if s == "AC" {
            solved[p] = true;
        }
    }

    let solved_num = solved.iter().filter(|r| **r).count();
    let penalty_num = solved.iter().zip(penalty.iter()).map(|(s, p)| if *s {*p} else {0}).sum::<usize>();

    println!("{} {}", solved_num, penalty_num);
}

Measured memory_bytes: 10492
import sys
input = sys.stdin.readline

N = int(input())
A = [int(input()) for _ in range(N)]

check = [True] * (N + 1)

count = 0
tmp = 1
while check[tmp]:
    count += 1
    check[tmp] = False
    if A[tmp - 1] == 2:
        print (count)
        exit()
    tmp = A[tmp - 1]

print (-1)

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> p(m), y(m);
  for (int i = 0; i < m; i++) {
    cin >> p[i] >> y[i];
    p[i]--;
  }

  vector<vector<pair<int, int>>> arr(n);

  map<int, int> ma;
  for (int i = 0; i < m; i++) {
    arr[p[i]].push_back(make_pair(y[i], i));
  }

  for (int i = 0; i < n; i++) {
    sort(arr[i].begin(), arr[i].end());
    for (int j = 0; j < arr[i].size(); j++) {
      y[arr[i][j].second] = j + 1;
    }
  }

  for (int i = 0; i < m; i++) {
    int no = p[i];
    printf("%06d%06d\n", no + 1, y[i]);
  }
}

Measured memory_bytes: 7808
from fractions import gcd
 
n = int(input())
a = list(map(int, input().split()))
mod = 10 ** 9 + 7
l = 1
for i in a:
    l = i * l // (gcd(i, l))
 
cnt = 0
for i in a:
    cnt += l // i
print(cnt % mod)

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

using namespace std;

#define ll long long

const int N = 1e6 + 5;
const ll INF = 1e17;
ll n, c, dp[N], h[N];

struct Line{
	ll m, c;
	Line(){
		m = c = 1e9;
	}
} t[4*N];

ll eval(Line l, int x){
	return l.m * x + l.c;
}

void addLine(int node, int start, int end, Line l){
	// cout<<"start end "<<start<<" "<<end<<" "<<l.m<<" "<<l.c<<"\n";
	int mid = (start + end)/2;
	bool fleft = eval(l, start) < eval(t[node], start);
	bool fmid = eval(l, mid) < eval(t[node], mid);

	if(fmid)swap(t[node], l);
	if(start == end)return ;
	if(fleft != fmid)addLine(2*node, start, mid, l);
	else addLine(2*node + 1, mid + 1, end, l);
}

ll query(int node, int start, int end, int id){
	if(id < start || id > end)return INF;
	if(start == end)return eval(t[node], start);

	int mid = (start + end)/2;
	ll ret = min(query(2*node, start, mid, id), query(2*node + 1, mid + 1, end, id));
	return min(ret, eval(t[node], id));
}

int main(){
	cin>>n>>c;
	for(int i=1;i<=n;++i)cin>>h[i];

	Line l;
	for(int i=1;i<=n;++i){
		if(i != 1)dp[i] = (h[i]*h[i] + c) + query(1, 0, N - 1, h[i]);
		// cout<<"dp[i] "<<dp[i]<<"\n";
		l.m = -2*h[i];
		l.c = dp[i] + h[i]*h[i];
		addLine(1, 0, N - 1, l);
		// cout<<"-------------------\n";
	}
	cout<<dp[n]<<"\n";

	return 0;
}

Measured memory_bytes: 69888
#include <iostream>
#include <string>

using namespace std;

int main()
{
	int k;
	string s;

	scanf("%d",&k);
	cin >> s;	

	if(s.size() <= k){
		cout << s;
	}
	else{
		for(int i=0;i<k;i++){
			cout << s[i];
		}
		printf("...");
	}
	
	return 0;
}


Measured memory_bytes: 3784
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
	"strings"
	"unsafe"
)

func main() {
	ABM := sc.nextInts()
	M := ABM[2]

	a := sc.nextInts()
	b := sc.nextInts()

	minA := int(math.Pow10(5))
	for _, va := range a {
		if minA > va {
			minA = va
		}
	}
	minB := int(math.Pow10(5))
	for _, vb := range b {
		if minB > vb {
			minB = vb
		}
	}
	minTmp := minA + minB

	for i := 0; i < M; i++ {
		m := sc.nextInts()
		ia := m[0] - 1
		ib := m[1] - 1
		tmp := a[ia] + b[ib] - m[2]
		if minTmp > tmp {
			minTmp = tmp
		}
	}
	fmt.Println(minTmp)
}

var (
	sc scanner
)

func init() {
	sc = scanner{
		buf: make([]string, 0, 0),
		cur: 0,
		r:   bufio.NewReader(os.Stdin),
	}
}

type scanner struct {
	buf []string
	cur int
	r   *bufio.Reader
}

func (s *scanner) readln() {
	rbuf := make([]byte, 0, 0)
	for {
		line, prefix, err := s.r.ReadLine()
		if err != nil {
			panic(err)
		}
		rbuf = append(rbuf, line...)
		if prefix == false {
			break
		}
	}
	s.cur = 0
	s.buf = strings.Split(*(*string)(unsafe.Pointer(&rbuf)), " ")
}
func (s *scanner) isFull() bool {
	if s.cur == len(s.buf) {
		return true
	}
	return false
}
func (s *scanner) resetCur() {
	s.cur = 0
}
func (s *scanner) next() string {
	if s.cur == 0 {
		s.readln()
	}
	res := s.buf[s.cur]
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}
func (s *scanner) nexts() []string {
	s.readln()
	s.resetCur()
	return s.buf
}
func (s *scanner) nextInt() int {
	if s.cur == 0 {
		s.readln()
	}
	res, _ := strconv.Atoi(s.buf[s.cur])
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}
func (s *scanner) nextInts() []int {
	s.readln()
	res := make([]int, len(s.buf))
	for i := range s.buf {
		res[i], _ = strconv.Atoi(s.buf[i])
	}
	s.resetCur()
	return res
}
func (s *scanner) nextFloat() float64 {
	if s.cur == 0 {
		s.readln()
	}
	res, _ := strconv.ParseFloat(s.buf[s.cur],
		64)
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}
func (s *scanner) nextFloats() []float64 {
	s.readln()
	res := make([]float64, len(s.buf))
	for i := range s.buf {
		res[i], _ = strconv.ParseFloat(s.buf[i],
			64)
	}
	s.resetCur()
	return res
}
func digits(x int) int {
	return len(strconv.Itoa(x))
}
func powInt(x, p int) (result int) {
	result = 1
	for i := 0; i < p; i++ {
		result *= x
	}
	return
}
func max(x, y int) int {
	return int(math.Max(float64(x), float64(y)))
}
func min(x, y int) int {
	return int(math.Min(float64(x), float64(y)))
}
func abs(x int) int {
	return int(math.Abs(float64(x)))
}
func varDump(value ...interface{}) {
	for _, v := range value {
		fmt.Fprintf(os.Stderr, "%#v\n", v)
	}
}
func yes() {
	fmt.Println("Yes")
}
func no() {
	fmt.Println("No")
}

// Pair a
type Pair struct {
	first  int
	second int
}

// Queue a
type Queue struct {
	v []Pair
}

// Push for queue
func (q *Queue) Push(v Pair) {
	q.v = append(q.v, v)
}

// Pop for queue
func (q *Queue) Pop() Pair {
	r := q.v[0]
	q.v = q.v[1:]
	return r
}

// Front for queue
func (q Queue) Front() Pair {
	return q.v[0]
}

// Empty return true if empty
func (q Queue) Empty() bool {
	return len(q.v) == 0
}


Measured memory_bytes: 10880
M=99;main(n,i,j,k,a,b,c){
	float p=atan(1)*4,X[100],Y[100],x,y;
	for(;scanf("%d",&n),n;printf("%d\n",a)){
		for(i=0;i<n;i++)scanf("%f,%f",X+i,Y+i);
		for(a=i=0;i<n;a=a>b?a:b,i++)for(b=k=0;k<M;b=b>c?b:c,k++)for(x=X[i]+cos(p*k/M),y=Y[i]+sin(p*k/M),c=0,j=i;j<n;j++)
			if((X[j]-x)*(X[j]-x)+(Y[j]-y)*(Y[j]-y)<1+1e-3)c++;
	}
exit(0);}

Measured memory_bytes: 640
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner((System.in));
		int n = sc.nextInt();
		int[] a = new int[n + 1];
		HashMap<Integer, Integer> b = new HashMap<Integer, Integer>();
		int ans = 0, max = 0;

		for (int i = 1; i <= n; i++) {
			a[i] = sc.nextInt();
			if (b.get(a[i]) != null) {
				b.put(a[i], b.get(a[i]) + 1);
			} else {
				b.put(a[i], 1);
			}
			if (max < a[i]) {
				max = a[i];
			}
		}

		for (Map.Entry<Integer, Integer> i : b.entrySet()) {
			if (i.getKey() < i.getValue()) {
				ans += i.getValue() - i.getKey();
			} else if (i.getValue() < i.getKey()) {
				ans += i.getValue();
			}
		}

		System.out.println(ans);

		sc.close();
	}
}


Measured memory_bytes: 62116
def solve(n, m, X):
    if n >= m:
        return 0
    X.sort()
    distances = sorted(X[i + 1] - X[i] for i in range(0, m - 1))
    return sum(distances[:m - n])

_n, _m = map(int, input().split())
_X = list(map(int, input().split()))
print(solve(_n, _m, _X))


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

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;

	if (a < c) {
		if (b <= c) cout << 0 << endl;
		else if (b <= d) cout << b - c << endl;
		else cout << d - c << endl;
	}
	if (c < a) {
		if (d <= a) cout << 0 << endl;
		else if (d <= b) cout << d - a << endl;
		else cout << b - a << endl;
	}
	if (a == c) {
		if (b <= d) cout << b - a << endl;
		else cout << d - c << endl;
	}

	return 0;
}

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

int main() {
    std::string s;
    std::cin >> s;
    
    const auto find_A = std::find(s.cbegin(), s.cend(), 'A') - s.cbegin();
    const auto find_Z = s.crend() - std::find(s.crbegin(), s.crend(), 'Z');
    const auto ret = find_Z - find_A;

    std::cout << ret << std::endl;
}


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

const bool DEBUG = false;

string S;

void input() { cin >> S; }

bool is_palindrome(string str) {
  if (str.size() == 0 || str.size() == 1) {
    return true;
  } else if (str.size() == 2) {
    return str[0] == str[1];
  } else {
    if (str[0] != str[str.size() - 1])
      return false;
    else
      return is_palindrome(str.substr(1, str.size() - 2));
  }
}

int main(int argc, char const *argv[]) {
  input();
  const int N = S.size();
  if (is_palindrome(S.substr(0, (N - 1) / 2))) {
    if (S.substr(0, (N - 1) / 2) == S.substr((N + 3) / 2 - 1, (N - 1) / 2)) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#C問題 together
 
N = int(input())
a = list(map(int,input().split(" ")))
 

 
minval = min(a)
maxval = max(a)
l = (maxval - minval +1)
 
num = [0]*(l+2)

for i in a:
	num[i-minval] += 1

ans = 0
for i in range(1,l+1):
	ans = max(ans,num[i-1]+num[i]+num[i+1])

print(ans)

Measured memory_bytes: 13964