akhauriyash/Code-Regression huggingface dataset:
/*=======================
Author    : Shounak Dey
Filename  : b.cpp
=======================	*/

#include<bits/stdc++.h>

using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;

#define PB push_back
#define MK make_pair 
#define SZ(a) (int)(sizeof(a))
#define F first
#define S second
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,n) for(int i=0;i<n;i++)
#define read(n) scanf("%d",&n)
#define readl(n) scanf("%lld",&n)
#define readul(n) scanf("%llu",&n);


#define SORTV(a) sort(a.begin(),a.end())
#define TEST int Test;cin >> Test;while(Test--)
#define gcd(a,b) __gcd(a,b)
#define ffs(a) __builtin_ffs(a) // find first set
#define clz(a) __builtin_clz(a) // count leading zeroes
#define ctz(a) __builtin_ctz(a) // count trailing zeroes
#define popc(a) __builtin_popcount(a) // count set bits
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)


#define error(args...) { vector<string> _v = split(#args, ','); err(_v.begin(), args); }

vector<string> split(const string& s, char c) {
	vector<string> v;
	stringstream ss(s);
	string x;
	while (getline(ss, x, c))
		v.emplace_back(x);
	return move(v);
}

void err(vector<string>::iterator it) {}
template<typename T, typename... Args>
void err(vector<string>::iterator it, T a, Args... args) {
	cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << '\n';
	err(++it, args...);
}

int check(string s){
	string r = s;
	reverse(r.begin(),r.end());
	return (r==s);
}

int main()
{
	fast_io;
	string s;
	cin >> s;
	int f1 = check(s);
	string x = "";
	string y = "";
	REP(i,(s.length()-1)/2)
		x += s[i];
	int f2=check(x);
	FOR(i,(s.length()+3)/2 - 1,s.length())
		y += s[i];
	int f3 = check(y);
	if(f1 && f2 && f3)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <cstring>

#define FOR(i, a, b) for (int i = a; i < b; i++)
#define FORN(i, a, b) for (int i = a; i <= b; i++)
#define P(s) cout << s << endl
#define PC(condition, _true, _false) if (condition) _true; else _false;

using namespace std;
//
// Created by karayuu on 2019-3-28.
//


int main() {
    int n;
    cin >> n;

    double x[101] = {0};
    double y[101] = {0};
    FOR(i, 0, n) {
        cin >> x[i];
    }
    FOR(i, 0, n) {
        cin >> y[i];
    }

    double d1 = 0.0;
    FOR(i, 0, n) {
        d1 += abs(x[i] - y[i]);
    }

    double d2 = 0.0;
    FOR(i, 0, n) {
        d2 += pow(abs(x[i] - y[i]), 2.0);
    }
    d2 = sqrt(d2);

    double d3 = 0.0;
    FOR(i, 0, n) {
        d3 += pow(abs(x[i] - y[i]), 3.0);
    }
    d3 = pow(d3, 1.0 / 3.0);

    double dinf = 0.0;
    FOR(i, 0, n) {
        dinf = max(dinf, abs(x[i] - y[i]));
    }

    printf("%.6f\n", d1);
    printf("%.6f\n", d2);
    printf("%.6f\n", d3);
    printf("%.6f\n", dinf);
}


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

bool check(vector<int>& vec)
{
  int a,b,c;
  a = vec[0],b = vec[1],c = vec[2];
  if(a >= b+c || b >= a+c || c >= a+b)
    return false;
  return true;
}

int main()
{
  int _1,_2,_3,_4;
  _1 = _2 = _3 = _4 = 0;
  while(true)
    {
      vector<int> vec;
      for(int i=0;i<3;i++)
	{
	  int a;
	  cin >> a;
	  vec.push_back(a);
	}
      sort(vec.begin(),vec.end());
      if(!check(vec))      
	break;
      int a,b,c;
      a = vec[0],b = vec[1],c = vec[2];

      _1++;
      if(c*c == a*a+b*b)
	_2++;
      if(c*c < a*a+b*b)
	_3++;
      if(c*c > a*a+b*b)
	_4++;

    }
  cout << _1 << " " << _2 << " " << _3 << " " << _4 << endl;
  return 0;
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define PI 3.14159265358979
#define MOD 1000000007 // = 10^9 + 7

using namespace std;
using ll = long long;

int n;
string s;
ll ans = 0;

int toIndex(string str)
{
	if (str == "R")return 0;
	if (str == "G")return 1;
	if (str == "B")return 2;

	if (str == "GB" || str == "BG")return 0;
	if (str == "RB" || str == "BR")return 1;
	if (str == "RG" || str == "GR")return 2;

	cout << "nazo : " << str << endl;
	return 0;
}

int toIndex(char c)
{
	string str = { c };
	return toIndex(str);
}

void solve()
{
	cin >> n >> s;

	ll cnt[3] = { 0, 0, 0 };
	for(const auto& c : s)
	{
		cnt[toIndex(c)]++;
	}

	ans = cnt[0] * cnt[1] * cnt[2];

	for(int diff = 1; diff <= n / 2; ++diff)
	{
		for(int i = 0; i <= n - 1 - diff * 2; ++i)
		{
			int j = i + diff;
			int k = j + diff;
			// cout << i << " " << j << " " << k << endl;
			if(s[i] != s[j] && s[i] != s[k] && s[j] != s[k])
			{
				ans--;
			}
		}
	}


	cout << ans << endl;
}

int main()
{
	fastio;
	solve();

	return 0;
}

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

const int MOD = (int)1e9+7;

int main(){
	int N;
	cin >> N;
	vector<int> A(N);
	vector<vector<pair<int,int>>> Ax(N);
	for(int i=0;i<N;i++){
		cin >> A.at(i);
		for(int j=0;j<A.at(i);j++){
			int x,y;
			cin >> x >> y;
			x--;
			Ax.at(i).push_back(make_pair(x,y));
		}
	}
/*
	for(int i=0;i<N;i++){
		cout << i << endl;
		for(int j=0;j<A.at(i);j++){
			cout << Ax.at(i).at(j).first << "," << Ax.at(i).at(j).second << endl;
		}
	}*/
 	int ans=0;
	for(int bit=0;bit<(1<<N);bit++){
		bool flag=true;
		int count=0;
		vector<int> xx(N,0);
		for(int i=0;i<N;i++){
			if(bit&(1<<i)){//正直者
				xx.at(i)=1;
				count++;
			}
		}
		for(int i=0;i<N;i++){
			if(bit&(1<<i)){//正直者
				for(int j=0;j<A.at(i);j++){
					int a=Ax.at(i).at(j).first;
					int b=Ax.at(i).at(j).second;
					if(b==1){
						if(xx.at(a)!=1)	flag=false;
					}
					else{
						if(xx.at(a)!=0)	flag=false;
					}
				}
			}
		}
		if(flag)	ans=max(ans,count);
	}
	cout << ans << endl;
	
	return 0;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

vi num;
void countfactor(int N){
    int p=2;
    while (N != 1){
        if (N % p == 0) {
            if (num[p] == 0) num[p] = 1;
            N /= p;
            num[p]++;
        }else{
            p++;
        }
    }

    return;
}

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

    num = vi(N+1, 0);
    num[1] = 1;

    // countfactor(N);
    for (int i = 2; i <= N; i++) {
        countfactor(i);
    }

    // for (int i = 1; i <= N; i++) {
    //     cout << num[i] << endl;
    // }


    ll ans=1;
    for (int i = 1; i <= N; i++) {
        if (num[i] != 0) {
            ans *= num[i];
            ans %= 1000000007;
        }
    }
    cout << ans << endl;

    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}


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

int N;
int A[210];         // 最大 200 個なので余裕を持って 210 に --- 200 以上ならなんでもよいです

int main() {
    cin >> N;
    for (int i = 0; i < N; ++i) cin >> A[i];

    int res = 0;

    // 操作が行える限り操作を繰り返す
    while (true) {
        bool exist_odd = false;  // A[i] がすべて偶数かどうかを判定するフラグ
        for (int i = 0; i < N; ++i) {
            if (A[i] % 2 != 0) exist_odd = true;  // 奇数があったらフラグを立てる
        }

        if (exist_odd) break;  // 奇数があったら break

        // 操作を行えるなら操作を実際に行う
        for (int i = 0; i < N; ++i) {
            A[i] /= 2;
        }
        ++res;  // 操作回数をインクリメント
    }

    cout << res << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
 ll n;
 cin>>n;
 ll h[n];
 for(ll i=0;i<n;i++) cin>>h[i];
 ll dp[n];
 ll INF=1e18;
 memset(dp,INF,sizeof dp);
 dp[n-1]=0;
 if(n>=2) dp[n-2]=abs(h[n-1]-h[n-2]);
 for(ll i=n-3;i>=0;i--){
  dp[i]=min(dp[i+1]+abs(h[i+1]-h[i]),dp[i+2]+abs(h[i+2]-h[i]));
 }
 cout<<dp[0]<<endl;
 return 0;
}

Measured memory_bytes: 1792
S = input()
con = 10**9 + 7

T = [s if s != "?" else "0" for s in S]
T = int(''.join(T))
SS = T % 13

def get_mod(S):
    c = {}
    iii = 1
    for i in range(len(S)):
        if S[len(S) - i - 1] != "?":
            iii *= 10
            iii %= 13
            continue
        c[i] = {(j * iii) % 13: 1 for j in range(0, 10)}
        iii *= 10
        iii %= 13
    return c
c = get_mod(S)

def get_tdp(pdp):
    tdp = {i: 0 for i in range(13)}
    for r in v.keys():
        for _r, _v in pdp.items():
            i = (_r + r) % 13
            tdp[i] += _v
    for i in range(13):
        tdp[i] %= con
    return tdp

pdp = {i: 0 for i in range(13)}
pdp[SS] += 1
for k, v in c.items():
    pdp = get_tdp(pdp)

ans = pdp[5]
print(ans)

Measured memory_bytes: 137120
#include<iostream>
#include<vector>
#define INF 1000000000
#define nmax 500005
using namespace std;

int n;
int cnt = 0;
vector<int> a;

void merge(int left, int mid, int right){
  int n1 = mid -left;
  int n2 = right - mid;
  vector<int> l(n1+5);
  vector<int> r(n1+5);

  int i, j;
  
  for(i = 0; i < n1; i++) l[i] = a[left + i];
  for(i = 0; i < n2; i++) r[i] = a[mid + i];

  l[n1] = INF;
  r[n2] = INF;

  i = 0;
  j = 0;

  for(int k = left; k < right; k++){
    if(l[i] <= r[j]) a[k] = l[i++];

    else a[k] = r[j++];

    cnt++;
    
  }
}

void mergeSort(int left, int right){
  if(left+1 < right){
    int mid = (left + right) / 2;

    mergeSort(left, mid);
    mergeSort(mid, right);
    merge(left, mid, right);
  }
}

int main()
{
  cin >> n;
  a.resize(n);
  
  for(int i = 0; i < n; i++) cin >> a[i];

  mergeSort(0, n);

  for(int i = 0; i < n; i++){
    if(i) cout << " ";

    cout << a[i];
  }

  cout << endl;
  cout << cnt << endl;
  

  return 0;

}



Measured memory_bytes: 6808
#include <stdio.h>

int main( int argc, char* argv[] )
{
		int i,j;

		for( i=1; i<=9; i++ ){
				for( j=1; j<=9; j++ ){
						printf("%dx%d=%d\n",i,j,i*j );
				}
		}
		return 0;
}

Measured memory_bytes: 524
#include <stdio.h>
int main(void)
{
        int a,b,e;
        double sum;
        for (;;)
        {
                a=0;
                b=0;
                scanf("%d %d",&a,&b);
                if (a==EOF)
                {break;}
                sum=a+b;
                if (sum<10)
                  {
                    break;
                  }
                for(e=1;sum>=10;e++)
                {
                        sum=sum/10;
                }
        printf("%d\n",e);
        }
        return 0;
}

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

using namespace std;

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

typedef long long ll;

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

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

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

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, ans;
    cin >> a >> b;
    ans = (b - a) * (b - a + 1) / 2 - b;
    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

#define inp 1000000
#define check exit(0)
#define nl cout<<endl;
#define mod 1000000007 
#define ll long long int
#define trace(x) cerr<<#x<<" : "<<x<<endl;
#define deb(v) for(int i=0;i<v.size();i++) {cout<<v[i]; (i==v.size()-1) ? cout<<"\n":cout<<" "; }
#define jaldi ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ordered_set tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>

using namespace __gnu_pbds;
using namespace std;

// Pick yourself up, 'cause...

vector<bool> dp(inp,false);

int main()
{
    jaldi
    
    int n,k;
    cin>>n>>k;

    vector<int> v(n+1);
    for(int i=1;i<=n;i++) cin>>v[i];

    for(int i=0;i<=k;i++)
    {
        for(int j=1;j<v.size();j++)
        {
            if(i-v[j]>=0 && !dp[i-v[j]]) { dp[i]=true; }
        }
        //deb(dp);
    }

    cout<<(dp[k]?"First":"Second");
    return 0;
}


Measured memory_bytes: 3728
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<queue>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1001001001;

int main() {
  string S;
  cin >> S;

  string r = S;
  reverse(r.begin(), r.end());
  int ans = 0;
  rep(i,S.size()) {
    if (S[i] != r[i]) {
      ans++;
    }
  }
  cout << ans/2 << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<cmath>
#include<cstring>
#include<set>
#include<climits>
#include<deque>
#include <iomanip>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define all(a) a.begin(),a.end()
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define size(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
llfor;ll mod=1000000007;
/*pi*/double pi=acos(-1);
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll ans=1;rep(i,0,n){ans*=x;}return ans;}
/*階乗*/ll fact(ll x){ll ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){ll ans=1,l=2;rep(i,0,min(n-r,r)){ans*=(n-i);while(ans%l==0&&l<=min(r,n-r)){ans/=l;l++;}}return ans;}
/*nPr*/ll npr(ll n,ll r){ll ans=1;rep(i,0,r)ans*=(n-i);return ans;}
/*primejudge*/bool prime(ll a){if(a<=1)return false;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
/*Fibonacci数列*/ll fib(ll x){ll fibo[x+10];fibo[0]=1;fibo[1]=1;fibo[2]=1;rep(i,3,x+1)fibo[i]=fibo[i-1]+fibo[i-2];return fibo[x];}
/*桁数*/ll dig(ll n){ll d=1,tmp=n;while(tmp/10>0){tmp/=10;d++;}return d;}
ll ans=0;
////////////////////////////////////////////////////////////
int main(){
 ll n,p;
 cin>>n>>p;
 ll cnt[3]={};
 ll a;
 rep(i,0,n){
  sc(a);
  cnt[a%2]++;
 }
 ll tmp=1;

 rep(i,0,cnt[0])tmp*=2;

 ans=0;
 ll k,l,sm;

 if(cnt[1]==0&&p==1){
  pr(ans);return 0;
 }
 rep(j,0,cnt[1]/2+1){
  k=2*j;
  if(p==1)k++;
  if(k>cnt[1])break;
  ans+=ncr(cnt[1],k);
  //cout<<k<<" "<<sm<<endl;
 }
// pnn;cout<<cnt[0]<<" "<<cnt[1]<<" "<<tmp<<" "<<ans<<endl;
 ans*=tmp;
 pr(ans);
return 0;}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
int main(){
  	int n,a,b;cin>>n>>a>>b;
	string s;cin>>s;
  
  int pass=0;int num_over_pass=0;
  //pass<a+b,num_over_pass<b
  for(int i=0;s[i]!='\0';i++){
  	if(s[i]=='c'){cout<<"No"<<'\n';continue;}
    if(s[i]=='a'){
    	//japansee
      	if(pass<(a+b)){
        	pass+=1;
          	cout<<"Yes"<<'\n';
        }
      	else cout<<"No"<<'\n';
    }
    else{
    	if(num_over_pass<b){
        	if(pass<(a+b)){
            	pass+=1;
              	num_over_pass+=1;
              cout<<"Yes\n";
            }
          else cout<<"No\n";
        }
      	else cout<<"No\n";
    }
  }
}

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

using namespace std;



int main() 
{
    int a, b, k, ans, i, counter=0, tmp, total, last, su=0, ones=0,zeros=0;
    int m[102];
    string s;

    getline(cin, s);
    //cout << s << endl;

    //string to num
    vector<int> vec;
    for (i=0;i<s.size();i++) 
    {   
        tmp = s[i] - '0';   
        vec.push_back(tmp);
    }
    total = vec.size();

    for (i=0;i<vec.size();i++)
    {
        ones += vec[i];
    }
    zeros = total - ones;
    last = abs(zeros-ones);
    
    cout << total-last;
    

    return 0;
}

Measured memory_bytes: 1020
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int N,M;
    int a[1002]={0},vt[1002]={0};
    cin>>N>>M;
    for(int i=1;i<=N;i++)cin>>a[i];
    for(int i=0;i<M;i++){
        int b;
        cin>>b;
        for(int j=1;j<=N;j++){
            if(a[j]<=b){
                vt[j]++;
                break;
            }
        }
    }
    int ans=0,ansvt=0;
    for(int i=1;i<=N;i++)if(ansvt<vt[i])ans=i,ansvt=vt[i];
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1168
N = int(input())
A = list(map(int, input().split()))

flag = 1
for i in range(N):
    if(A[i] % 2 == 0):
        if(A[i] % 3 != 0 and A[i] % 5 != 0):
            flag = 0

if(flag == 0):
    print("DENIED")
else:
    print("APPROVED")

Measured memory_bytes: 3060
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////

ll n,h,w;

int main(){
    
    cin >> n >> h >> w;

    P((n-h+1)*(n-w+1));
    
    
	return  0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a,b,sum=1;
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	cin>>a>>b;
	if(a>0&&b>0) cout<<"Positive";
	else if(abs(b)-abs(a)%2==1)  cout<<"Positive";
	else if(a==0||(a<0&&b>0)) cout<<"Zero";
	else cout<<"Negative";;
	return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

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

	sum := 0
	for i := 0; i < m; i++ {
		var a int
		fmt.Scan(&a)
		sum = sum + a
	}

	if sum <= n {
		fmt.Println(n - sum)
	} else {
		fmt.Println("-1")
	}
}


Measured memory_bytes: 2484
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
#define yes cout<<"YES"<<"\n"
#define no cout<<"NO"<<"\n"

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int x,y,z,k;
	cin>>x>>y>>z>>k;
	vvi in(3);
	rep(i,x){
		int a;cin>>a;
		in[0].pb(a);
	}
	rep(i,y){
		int a;cin>>a;
		in[1].pb(a);
	}
	rep(i,z){
		int a;cin>>a;
		in[2].pb(a);
	}
	vi t;
	rep(i,x)rep(j,y)t.pb(in[0][i]+in[1][j]);
	sort(all(t));
	vi nt;
	rep(i,min((ll)t.size(),k))nt.pb(t[t.size()-1-i]);
	vi out;
	rep(i,nt.size())rep(j,z)out.pb(nt[i]+in[2][j]);
	sort(all(out));
	rep(i,k)cout<<out[out.size()-1-i]<<endl;
}







Measured memory_bytes: 43152
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  // 一年の秒数
  int edge_length, white_cell;
  int black_cell;
  cin >> edge_length >> white_cell;
  black_cell = pow(edge_length, 2) - white_cell;
  cout << black_cell << endl;
}

Measured memory_bytes: 256
N = int(input())
A = [int(a) for a in input().split()]
X = [0] + [1<<100] * N
X[1] = abs(A[1] - A[0])
for i in range(2, N):
    X[i] = min(X[i], X[i-1] + abs(A[i] - A[i-1]), X[i-2] + abs(A[i] - A[i-2]))
print(X[N-1])

Measured memory_bytes: 13780
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << x << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 3100

int dfs(int k, int i, int *dif, int sum_add, int *add, int add_size=0){
  int ret = INF;

  //debug(i);
  
  if(k==i) return 0;
  
  //add
  int t = (dif[i]+1000-sum_add)%10;
  if(t==0){
    ret = min(ret,dfs(k,i+1,dif,sum_add,add,add_size));
  }else{
    add[add_size++] = t;
    ret = min(ret,dfs(k,i+1,dif,sum_add+t,add,add_size)+1);
    add_size--;
  }
  
  //rm
  for(int j=0;j<(1<<add_size);j++){
    //debug(j);
    int add2[11], add2_size=0,sum_add2=0;
    for(int l=0;l<add_size;l++){
      if(j & (1<<l)){
        add2[add2_size++] = add[l];
        sum_add2 += add[l];
      }
    }
    if((dif[i]+1000-sum_add2)%10 == 0){
      ret = min(ret,dfs(k,i+1,dif,sum_add2,add2,add2_size));
    }
  }
  
  return ret;
}

void calc(int k){
  char s1[11],s2[11];
  int dif[11],add[11];
  
  scanf("%s%s",s1,s2);

  for(int i=0;i<k;i++){
    dif[i] = (s1[i]+10-s2[i])%10;
  }

  printf("%d\n",dfs(k,0,dif,0,add));
}

int main(){

  int x;
  
  while(1){
    scanf("%d",&x);

    if(x == 0) break;

    calc(x);
  }
  
  return 0;
}

Measured memory_bytes: 3112
def quick_sort(arr):
    left = []
    right = []
    if len(arr) <= 1:
        return arr

    # データの状態に左右されないためにrandom.choice()を用いることもある。
    # ref = random.choice(arr)
    ref = arr[0]
    ref_count = 0

    for ele in arr:
        if ele < ref:
            left.append(ele)
        elif ele > ref:
            right.append(ele)
        else:
            ref_count += 1
    left = quick_sort(left)
    right = quick_sort(right)
    return left + [ref] * ref_count + right


if __name__ == "__main__":
    x = int(input())
    points = 0
    tmp = int(x/500)
    points += tmp * 1000
    x -= tmp*500

    tmp = int(x/5)
    points += tmp*5

    print(points)
    





      
# for i in range(10):
#     print(i)
#     if i%5==4:
#         break

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

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))
#define rep(i,a,b) for(int (i)=int(a);(i)<int(b);(i)++)
#define rrep(i,a,b) for(int (i)=int(a);(i)>=int(b);(i)--)

#define put(a) cout << (a) << endl
#define puts(a) cout << (a) << " "

#define llint long long int

#define INF (long long)(1e9+1)
#define MOD (long long)(1e9+7)
#define INF64 (long long)(1e18+1)

#define F first
#define S second

#define Pii  pair<int,int>
#define Pll  pair<long long,long long>
#define Piii pair<int,pair<int,int>>
#define Plll pair<long long,pair<long long,long long>>

#define Vll(a,b,c)    vector<vector<long long>> (a)((b),vector<long long>((c))
#define Vlll(a,b,c,d) vector<vector<vector<long long>>> (a)((b),vector<vector<long long>>((c),vector<long long>((d)))

#define MAX_N 1000000

llint my_binary_search(llint ary[], llint key, llint left, llint right) {
	llint middle;
	if (right < left) {
		return -(INF64);
	} else {
		middle = left + (right - left) / 2;
		if (ary[middle] > key) {
			return my_binary_search(ary, key, left, middle - 1);
		} else if (ary[middle] < key) {
			return my_binary_search(ary, key, middle + 1, right);
		} else {
			return middle;
		}
	}
}

struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for(int i = 0; i < N; i++) par[i] = i;
	}

	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}

	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};

int main (void)
{
	//INPUT
	llint N,M;
	cin >> N;


	llint a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

	cout << a[N-1] << endl;

	return 0;
}


Measured memory_bytes: 256
// This amazing code is by Eric Sunli Chen.
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;
template<typename T> void get_int(T &x)
{
	char t=getchar();
	bool neg=false;
	x=0;
	for(; (t>'9'||t<'0')&&t!='-'; t=getchar());
	if(t=='-')neg=true,t=getchar();
	for(; t<='9'&&t>='0'; t=getchar())x=x*10+t-'0';
	if(neg)x=-x;
}
template<typename T> void print_int(T x)
{
	if(x<0)putchar('-'),x=-x;
	short a[20]= {},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1; i>=0; i--)putchar('0'+a[i]);
}
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define get1(a) get_int(a)
#define get2(a,b) get1(a),get1(b)
#define get3(a,b,c) get1(a),get2(b,c)
#define printendl(a) print_int(a),puts("")
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;
const int inf=0x3f3f3f3f;
const LL Linf=1ll<<61;
const double pi=acos(-1.0);

const int mod=1e9+7;

char s[3111];
int n,m,p0[3111],p1[3111],l[3111],r[3111],c0,c1,tl[3111],tr[3111];
int dp[3111][3111];
int main()
{
	get2(n,m);scanf("%s",s+1);
	for(int i=1;i<=n;i++)
	{
		if(s[i]=='0')p0[++c0]=i;
		else p1[++c1]=i;
	}
	for(int i=1;i<=m;i++)get2(l[i],r[i]);
	for(int i=1;i<=n;i++)
	{
		int mn=i,mx=i;
		for(int j=1;j<=m;j++)
		{
			if(l[j]<=mn&&mn<=r[j])mn=l[j];
			if(l[j]<=mx&&mx<=r[j])mx=r[j];
		}
		tl[i]=mn;tr[i]=mx;
	}
	dp[1][0]=1;
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<i&&j<=c0;j++)
		{
			int k=i-1-j;
			if(j<c0&&tl[p0[j+1]]<=i&&i<=tr[p0[j+1]])
			{
				dp[i+1][j+1]+=dp[i][j];
				if(dp[i+1][j+1]>=mod)dp[i+1][j+1]-=mod;
			}
			if(k<c1&&tl[p1[k+1]]<=i&&i<=tr[p1[k+1]])
			{
				dp[i+1][j]+=dp[i][j];
				if(dp[i+1][j]>=mod)dp[i+1][j]-=mod;
			}
		}
	}
	printendl(dp[n+1][c0]);
	return 0;
}

Measured memory_bytes: 35840
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

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

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

def main():
    N, M = map(int, input().split())
    uni = UnionFind(N)
    for _ in range(M):
        A, B = map(int, input().split())
        A -= 1
        B -= 1
        uni.union(A,B)
    cnt = 0
    for i in range(N):
        cnt = max(cnt,uni.size(i))

    print(cnt)
    



if __name__ == "__main__":
    main()

Measured memory_bytes: 75344
import java.util.*;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        HashMap<Integer, Integer> mapEven = new HashMap<>();
        HashMap<Integer, Integer> mapOdd = new HashMap<>();
        for (int i = 0; i < n; i++) {
            int num = sc.nextInt();
            if (i % 2 == 0) {
                mapEven.put(num, mapEven.getOrDefault(num, 0)+1);
            } else {
                mapOdd.put(num, mapOdd.getOrDefault(num, 0)+1);
            }
        }
        List<Map.Entry<Integer, Integer>> odd = new ArrayList<>(mapOdd.entrySet());
        List<Map.Entry<Integer, Integer>> even = new ArrayList<>(mapEven.entrySet());
        odd.sort((o1, o2) -> o2.getValue() - o1.getValue());
        even.sort((e1, e2) -> e2.getValue() - e1.getValue());

        int o1 = odd.get(0).getValue();
        int o2 = odd.size() == 1 ? 0 : odd.get(1).getValue();
        int e1 = even.get(0).getValue();
        int e2 = even.size() == 1 ? 0 : even.get(1).getValue();
        if (!odd.get(0).getKey().equals(even.get(0).getKey())) {
            System.out.println(n - o1 - e1);
        }
        else {
            System.out.println(n - Math.max(o1 + e2, o2 + e1));
        }
    }
}

Measured memory_bytes: 62308
#include <stdio.h>

int main(void){
    int c1,c5,c10,c50,c100,c500,sum=0;
    scanf("%d %d %d %d %d %d",&c1,&c5,&c10,&c50,&c100,&c500);
    sum=c1+c5*5+c10*10+c50*50+c100*100+c500*500;
    if(sum >= 1000)
        printf("1\n");
    else
        printf("0\n");
    return 0;
}

Measured memory_bytes: 584
#![allow(non_snake_case)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!(
        n: usize,
        an: [usize; n],
        bn: [usize; n],
        cn: [usize; n-1],
    );
    let mut sum = 0usize;
    let mut pre_i = 21usize;
    for a in an {
        let i = a - 1;
        sum += bn[i];
        if i == (pre_i + 1) {
            sum += cn[pre_i];
        }
        pre_i = i;
        // println!("ai:{} i:{} bi:{} sum:{}", a, i, bn[i], sum);
    }
    println!("{}", sum);
}


Measured memory_bytes: 4352
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<unordered_map>
#define ll long long
using namespace std;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin >> n;

	vector<int>dp(3,0);
	for (int day = 0; day < n; day++) {
		vector<int>v(3, 0);		

		vector<int>new_dp(3, 0);
		cin>>v[0]>>v[1]>>v[2];
		for (int i = 0; i < 3; i++) {
			for (int j = 0; j < 3; j++) {
				if (j != i) {
					new_dp[j] = max(new_dp[j], dp[i] + v[j]);
				}
			}
		}
		dp = new_dp;
	}
	cout << max({ dp[0],dp[1],dp[2] });
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

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


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

using namespace std;

typedef long long ll;
#define mod 998244353

ll dp[3005][3005];
int main()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    dp[a][b]=1;
        for(ll i = a; i <= c; i++) 
        {
            for(ll j = b; j <= d; j++) 
            {
            if(i == a) 
            {
                if (j == b) 
                    continue;
                
                dp[i][j] = dp[i][j - 1] * a % mod;
            }
            if(j == b) 
            {
                dp[i][j] = dp[i - 1][j] * b % mod;
            } 
            else 
            {
                dp[i][j] = ((dp[i - 1][j] * j + dp[i][j - 1] * i - dp[i - 1][j - 1] * (i - 1) * (j - 1)) % mod + mod) % mod;
            }
        }
    }
    cout << dp[c][d];
    return 0;
}


Measured memory_bytes: 74016
#include<stdio.h>
#include<algorithm>
#include<string.h>
using namespace std;
struct mm
{
	int x,y;
}f[1000];
int main()
{
	int n,a[51],i,j,ma=-1000000,mi=1000000,x,m=0,p=0,q=0,l=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		if(ma<a[i])
		{
			ma=a[i];
			p=i;
		}
		if(mi>a[i])
		{
			mi=a[i];
			q=i;
		}
	}
	if(ma<0)
	{
		x=1;
	}
	else if(mi>=0)
	{
		x=2;
	}
	else if(-mi>ma)
	{
		x=3;
	}
	else
	{
		x=4;
	}
	if(x==3)
	{
		for(i=0;i<n;i++)
		{
			if(a[i]>0)
			{
				a[i]+=mi;
				f[l].x=q;
				f[l++].y=i;
			}
		}
		x=1;
	}
	else if(x==4)
	{
		for(i=0;i<n;i++)
		{
			if(a[i]<0)
			{	
				a[i]+=ma;
				f[l].x=p;
				f[l++].y=i;
			}
		}
		x=2;
	}
	if(x==1)
	{
		for(i=n-2;i>=0;i--)
		{
			if(a[i+1]<a[i])
			{
				a[i]+=a[i+1];
				f[l].x=i+1;
				f[l++].y=i;
			}
		}
	}
	else if(x==2)
	{
		for(i=1;i<n;i++)
		{
			if(a[i-1]>a[i])
			{
				a[i]+=a[i-1];
				f[l].x=i-1;
				f[l++].y=i;
			}
		}
	}
	printf("%d\n",l);
	for(i=0;i<l;i++)
	printf("%d %d\n",f[i].x+1,f[i].y+1);
}

Measured memory_bytes: 128
M = ['^','<','v','>']

while True:
    n = list(map(int,input().split()))
    if n == [0,0]:
        break
    D = {}
    for r in range(n[0]):
        s = 0
        C = input()
        for c in C:
            D[(r,s)] = [c,0]
            s += 1
    now = [0,0]
    while True:
        if D[tuple(now)][1] == 0:
            D[tuple(now)][1] += 1
            if D[tuple(now)][0] == '.':
                now.reverse()
                break
            else:
                m = M.index(D[tuple(now)][0])
                now[m%2] += (m//2)*2-1
        else:
            now = ['LOOP']
            break
    print (' '.join(list(map(str,now))))



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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

vector<pair<ll,ll>> bg(55);

ll rec(ll N, ll X){
    if(X <= 0) return 0;
    else if(N == 0) return 1;
    if(X < (bg[N].first+1)/2) return rec(N-1, X-1);
    else if(X == (bg[N].first+1)/2) return bg[N-1].second + 1;
    else return rec(N-1, X-2-bg[N-1].first) + bg[N-1].second + 1;
}

int main(void){
    ll N,X; cin >> N >> X;
    bg[0].first = 1; bg[0].second = 1;
    REP(i,N){
        bg[i+1].first = 2*bg[i].first + 3;
        bg[i+1].second = 2*bg[i].second + 1;
    }
    ll ans = rec(N,X);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import datetime

if __name__ == "__main__":
    H1, M1, H2, M2, K = [int(a) for a in input().split()]
    dt_start = datetime.datetime(year=2020, month=5, day=30, hour=H1, minute=M1, second=00)
    dt_end= datetime.datetime(year=2020, month=5, day=30, hour=H2, minute=M2, second=00)
    up_time = dt_end - dt_start
    sec = up_time.total_seconds()  - K * 60
    print(int(sec/60))


Measured memory_bytes: 9436
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <sstream>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <functional>
#include <cmath>
#include <array>

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI;
typedef pair<int,int> pii;
const int mod = (int)1e9+7;


int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	ll n,l;
	cin >> n >>l;
	vector<ll> a(n);
	rep(i,n) cin>>a[i];
	int sf=-1;
	rep(i,n-1) if(a[i]+a[i+1] >= l){ sf=i; break;}
	if(sf==-1){puts("Impossible"); return 0;}
	
	//cout <<"sf="<< sf <<endl;
	cout <<"Possible\n";
	rep(i,sf) cout << i+1 <<"\n";
	repr(i,n-1,sf+1) cout << i <<"\n";
	return 0;
}


Measured memory_bytes: 1664
#include <iostream>
#include <string>
#include <string.h>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <stdio.h>
#include <vector>
#define int long long
#define endre getchar();getchar();return 0
#define moder 1000000007
#define inf 1000000000000000000
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x%mod;
		}
		x = x * x%mod;
		y >>= 1;
	}
	return res;
}
int kai(int x) {
	if (x == 0)return 1;
	return (kai(x - 1)*x) % moder;
}
int comb(int x, int y) {
	return kai(x)*mod_pow(kai(x - y), moder - 2, moder) % moder*mod_pow(kai(y), moder - 2, moder) % moder;
}
struct edge { int to, cost; };
int dx[5] = { 0,1,0,-1 }, dy[5] = { 1,0,-1,0 };
map<int, int>factor(int x) {
	map<int, int>res;
	for (int i = 2; i*i <= x; i++) {
		while (x%i == 0) {
			x /= i;
			res[i]++;
		}
	}
	if (x != 1)res[x]++;
	return res;
}
/*--------Library Zone!--------*/


signed main() {
	int k, a, b;
	cin >> k >> a >> b;
	if (a >= b)cout << 1 + k << endl;
	else {
		if ((k - a) % 2 == 0)cout << max(a + (k - a) / 2 * (b - a) + 1, 1 + k) << endl;
		else cout << max(a + ((k - a) / 2 + 1) * (b - a), 1 + k) << endl;
	}
	endre;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
typedef long long ll;

using namespace std;

int d[110];

int main() {
   int n;
   cin >> n;
   set<int> s;
   rep(i,n){   
   cin >> d[i];
   s.insert(d[i]);
   }
   cout << s.size() << endl;
}

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

int main() {
  int n;
  cin >> n;
  int s = 0;
  int x;
  for (int i = 0; i < n; i++) {
    cin >> x;
    s += (x-1);
  }
  cout << s << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void){
	ll h,w; cin>>h>>w;
	ll H;
	if(h%2==0){
		H=h/2;
	}else{
		H=h/2+1;
	}
	ll W=w/2;
	ll a;
	if(w%2==0){
		a=0;
	}else{
		a=1;
	}
	if(h==1||w==1){
		cout<<1<<endl;
		return 0;
	}
	cout<<h*W+H*a<<endl;
	
	    
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define FOR(n) for(int i=0;i<n;i++)
#define FORJ(n) for(int j=0;j<n;j++)
#define PRN(n) printf("%d\n",n)
#define PRF(n) printf("%lf\n",n)
#define PRL(n) printf("%lld\n",n)
#define PRS(s) printf("%s\n",s)
#define PRC(c) printf("%c",c)
#define INF 10000000000
#define mod 1000000007
typedef long long int ll;
ll u(const void *a, const void *b){return *(ll*)a-*(ll*)b;}
ll d(const void *a, const void *b){return *(ll*)b-*(ll*)a;}
ll min(ll a,ll b){
  if(a>b)return b;
  return a;
}
ll max(ll a,ll b){
  if(a>b)return a;
  return b;
}
ll gcd(ll a,ll b){
  if(!b)return a;
  return gcd(b,a%b);
}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
int kt(ll a){
  int sum=0;
  while(a){
    a/=10;
    sum++;
  }
  return sum;
}
int ks(ll a){
  int sum=0;
  while(a){
    sum+=a%10;
    a/=10;
  }
  return sum;
}
int main(void){
  int n;
  scanf("%d",&n);
  for(int i=1;i<10;i++){
    if(n%i<1&&n/i<10){
      PRS("Yes");
      return 0;
    }
  }
  PRS("No");
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
    int A, B, K;
    cin >> A >> B >> K;
    int ans = 0, c = 0;
    for (int i = 100; i > 0; i--)
    {
        if (A % i == 0 && B % i == 0)
        {
            c++;
            if (c >= K)
            {
                ans = i;
                break;
            }
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll a7=1000000007;
ll inf=1000000000000000;
typedef pair<ll,ll> l_l;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back


ll min(ll a,ll b){
    if(a<b)return a;
    return b;
}
ll max(ll a,ll b){
    if(a>b)return a;
    return b;
}

int main(){
    string s;cin>>s;
    string w[7]={"SUN","MON","TUE","WED","THU","FRI","SAT"};
    rep(i,0,6){
        if(s==w[i]){
            if(i==0){
                cout<<7<<endl;
            }else{
                cout<<7-i<<endl;
            }
        }
    }
    
    return 0;
}




Measured memory_bytes: 256
import sys
import math

input = sys.stdin.readline
n, a, b = map(int, input().split())
v_list = list(map(int, input().split()))
v_list.sort(reverse=True)
mean = sum(v_list[:a]) / a
check = v_list[a-1]
before = 0
after = 0
before_list = v_list[:a-1]
before_list.sort()
after_list = v_list[a:]
for num in before_list:
    if check == num:
        before += 1
    else:
        break
for num in after_list:
    if check == num:
        after += 1
    else:
        break
ans = 0
comb_n = before + after + 1
if a - 1 == before:
    for i in range(min(after+1, b-a+1)):
        comb_r = before + i + 1
        ans += math.factorial(comb_n) // (math.factorial(comb_n - comb_r) * math.factorial(comb_r))
else:
    comb_r = before + 1
    ans += math.factorial(comb_n) // (math.factorial(comb_n - comb_r) * math.factorial(comb_r))
print(mean)
print(ans)


Measured memory_bytes: 3064