akhauriyash/Code-Regression huggingface dataset:
namespace ABC121 {
  class ProblemA {
    static void Main(string[] args) {
      string[] str1 = System.Console.ReadLine().Split(' '), str2 = System.Console.ReadLine().Split(' ');
      int height = int.Parse(str1[0]), width = int.Parse(str1[1]);
      int h = int.Parse(str2[0]), w = int.Parse(str2[1]);

      System.Console.WriteLine((height - h) * (width - w));
    }
  }
}

Measured memory_bytes: 13140
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<cstring>
#include<queue>
using namespace std;
char road[1010][1010];
int a[1010][1010];
int xx[10] = {0,1,-1,0,0};
int yy[10] = {0,0,0,1,-1};
int n,m;
struct node{
    int x;
    int y;
    int step;
    bool operator < (const node &x)const
    {
        return step>x.step;
    }
};
priority_queue<node>q;
void bfs(int stx,int sty)
{
    q.push({stx,sty,0});
    while(!q.empty())
    {
        node c = q.top();
        int x = c.x;
        int y = c.y;
        int step = c.step;
        q.pop();
        if(a[x][y]!=-1&&a[x][y]<step)   continue;
        a[x][y] = step;
        for(int i=1;i<=4;i++)
        {
            if(road[x+xx[i]][y+yy[i]]=='.'&&a[x+xx[i]][y+yy[i]]==-1&&(x+xx[i]>=1&&x+xx[i]<=n)&&(y+yy[i]>=1&&y+yy[i]<=m))
            {
                a[x+xx[i]][y+yy[i]] = step;
                q.push({x+xx[i],y+yy[i],step});
            }
        }
        for(int i=-2;i<=2;i++)
        {
            for(int j=-2;j<=2;j++)
            {
                if(road[x+i][y+j]=='.'&&(x+i>=1&&x+i<=n)&&(y+j>=1&&y+j<=m))
                {
                    q.push({x+i,y+j,step+1});
                }
            }
        }
    }
    return ;
}
int main()
{
    cin >> n >> m;
    int stx,sty,edx,edy;
    cin >> stx >> sty >> edx >> edy;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            cin >> road[i][j];
        }
    }
    memset(a,-1,sizeof(a));
    a[stx][sty] = 0;
    bfs(stx,sty);
    cout << a[edx][edy];
    return 0;
}

Measured memory_bytes: 32496
#include <cstdio>
#include <algorithm>    
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <cstring>
#include <cmath>
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long LL;
typedef long double LD;
typedef unsigned int uii;
typedef pair<int,int> pii;
typedef pair<int, pair<int, int> >piii;
typedef unsigned long long uLL; 
typedef vector<int> vii; 
//__int128
const int maxn = 5e5;
piii b[maxn];
int a[maxn];

int main(int argc, char const *argv[])
{
#ifndef ONLINE_JUDGE
	//freopen("in.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);
#endif
	int n, q;
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> q;
	for(int i = 0; i < n; ++i){
		cin >> b[i].se.fi >> b[i].se.se >> b[i].fi;
	}
	sort(b, b + n);
	set<pii> s;
	for(int i = 0; i < q; ++i){
		int x;
		cin >> x;
		s.insert(pii(x, i));	
		a[i] = -1;
	}
	for(int i = 0; i < n; ++i){
		auto it = s.lower_bound(pii(b[i].se.fi - b[i].fi, -1));
		// cout << it->fi << ' ' << it->se << endl;
		while(it != s.end() && it->fi < b[i].se.se - b[i].fi){
			a[it->se] = b[i].fi;
			s.erase(it++);
		}
	}
	for(int i = 0; i < q; ++i){
		cout << a[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 16256
#include <stdio.h>

int a[1000];

int main(void)
{
	int n, q, i, b, e, t, tmp;
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d", a + i);
	}
	scanf("%d", &q);
	while (q--) {
		scanf("%d%d%d", &b, &e, &t);
		e -= b;
		for (i = 0; i < e; i++) {
			tmp = a[b + i];
			a[b + i] = a[t + i];
			a[t + i] = tmp;
		}
	}
	for (i = 0; i < n; i++) {
		printf("%d%c", a[i], " \n"[i + 1 == n]);
	}
	return 0;
}



Measured memory_bytes: 2044
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include<bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define pii pair<int,int>
#define fr(i, a, b) for(int i = a; i < b; i++)
#define frb(i, a, b) for(int i = a; i > b; i--)
#define sz(s) (int)s.size()
#define all(v) (v).begin(), (v).end()
#define srt(v) sort(all(v))
#define srtGreat(v) sort(all(v), greater<ll>())
#define iset tree < int ,  null_type ,  less<int> ,  rb_tree_tag ,  tree_order_statistics_node_update >
#define oset tree < pair<int, int> ,  null_type ,  less<pair<int, int> > ,  rb_tree_tag ,  tree_order_statistics_node_update >
#define ll long long
using namespace std; 
using namespace __gnu_pbds; 


int  prg()
{
    ll n;
    cin>>n;
    ll m=n;
    int cnt1=0;
    fr(i,2,sqrt(m)+1)
    {
        int cnt2=0;
        while(n%i==0)
        {
            n=n/i;
            cnt2++;
        }
        fr(j,1,10000)
        {
            cnt2-=j;
            if(cnt2<0)
            break;
            cnt1++;
        }
    }
    if(n!=1)
    cnt1++;
    cout<<cnt1;
    return 0;
}
void multi()
{
    int t;
    cin>>t;
    for(int i=0;i<t;++i)
    {
       prg();
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    prg();
    return 0;
}

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

int main() {
    ll n,m,ans;
    cin>>n>>m;
    if (n<m/2) {
        ans=n;
        m-=2*n;
        ans+=m/4;
    }
    else ans=m/2;
    cout<<ans<<endl;
}


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

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define reps(i, n) for (int i = 1; i <= (n); ++i)
#define repd(i, n) for (int i = (n - 1); i >= 0; --i)
#define repds(i, n) for (int i = (n); i > 0; --i)
#define loop(i, x, n) for (int i = (x); i < (n); ++i)
#define loops(i, x, n) for (int i = (x); i <= (n); ++i)
#define loopd(i, x, n) for (int i = (x); i > (n); --i)
#define loopds(i, x, n) for (int i = (x); i >= (n); --i)
#define itrep(i, a) for (auto i = begin(a); i != end(a); ++i)
#define itrepd(i, a) for (auto i = rbegin(a); i != rend(a); ++i)
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
using ld = long double;
template <class T>
using priority_queuel = priority_queue<T, vector<T>, greater<T>>;
constexpr ll inf = static_cast<ll>(1e18);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e18;
constexpr double eps = 1e-9;
ll mod = static_cast<ll>(1e9 + 7);
template <class T>
constexpr int sz(const T &a) { return (int)a.size(); }
template <class T>
constexpr T pow2(const T a) { return a * a; }
template <class T, class... Args>
constexpr void mins(T &a, Args... args) { a = min<T>({a, args...}); }
template <class T, class... Args>
constexpr void maxs(T &a, Args... args) { a = max<T>({a, args...}); }
template <class A, int N, class T>
void fillArray(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }

int n, m;
ll p;
tuple<int, int, ll> e[5005];
ll d[2505];
bool bad[2505];
void solve() {
    cin >> n >> m >> p;
    rep(i, m) {
        int a, b;
        ll c;
        cin >> a >> b >> c;
        --a, --b;
        e[i] = make_tuple(a, b, c - p);
    }

    fillArray(d, -inf);
    d[0] = 0;
    rep(_, n) rep(i, m) {
        int from, to;
        ll cost;
        tie(from, to, cost) = e[i];
        if (d[from] != -inf)
            maxs(d[to], d[from] + cost);
    }

    rep(_, n) rep(i, m) {
        int from, to;
        ll cost;
        tie(from, to, cost) = e[i];
        if (d[to] != -inf && d[to] < d[from] + cost)
            bad[to] = true;
        if (bad[from]) bad[to] = true;
    }

    if (!bad[n - 1])
        cout << max<ll>(0, d[n - 1]) << endl;
    else
        cout << -1 << endl;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    return 0;
}


Measured memory_bytes: 384
s = input()
n = len(s)


for i in range(2**(n-1)):
  ans = int(s[0])
  f = s[0]
  for j in range(n-1):
    if i & (1<<j):
      f += '+'
      ans += int(s[j+1])
    else:
      f += '-'
      ans -= int(s[j+1])
    f += s[j+1]
    
  if ans == 7:
    print(f + '=7')
    exit()

Measured memory_bytes: 9164
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <climits>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <list>
#include <ext/rope>
#define rep(i,m,n) for(i=m;i<=n;i++)
#define rsp(it,s) for(set<int>::iterator it=s.begin();it!=s.end();it++)
#define vi vector<int>
#define pii pair<int,int>
#define mod 1000000007
#define inf 0x3f3f3f3f
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ll long long
#define pi acos(-1.0)
const int maxn=1e3+10;
const int dis[4][2]={{0,1},{-1,0},{0,-1},{1,0}};
using namespace std;
using namespace __gnu_cxx;
ll gcd(ll p,ll q){return q==0?p:gcd(q,p%q);}
ll qpow(ll p,ll q){ll f=1;while(q){if(q&1)f=f*p;p=p*p;q>>=1;}return f;}
int n,m;
int main()
{
    int i,j,k,t;
    scanf("%d%d",&n,&m);
    if(n<=0&&m>=0)puts("Zero");
    else if(n>0)puts("Positive");
    else
    {
        if((0LL+m-n+1)&1)puts("Negative");
        else puts("Positive");
    }
    //system ("pause");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
map<ll, ll> prime_factor(ll n) {
	map<ll, ll> ret;
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			ret[i]++;
			n /= i;
		}
	}
	if (n != 1) ret[n] = 1;
	return ret;
}

//const long long MOD = 1000000007;
const long long MOD = 998244353;
const long long INF = 1LL << 60;



const long double PI = 3.14159265359;
const int MAX_N = 100010;


signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	vector<pair<pair<string, int>, int>>tmp(n);
	rep(i, n) {
		string s; int t; cin >> s >> t;
		tmp[i] = make_pair(make_pair(s, -t), i);
	}
	sort(ALL(tmp));
	rep(i, n)cout << tmp[i].second + 1 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <numeric>
#include <random>
#include <vector>
#include <array>
#include <bitset>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
 
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;

int main() {
    int a,b;
    cin >> a >> b;
    if(a > 9 || b > 9){
        cout << "-1";
    } else{
        cout << a * b;
    }
    return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef vector < ll > vl;
typedef vector < int > vi;
typedef vector < bool > vb;
typedef vector < vl > vvl;
typedef vector < vi > vvi;
typedef pair < int, int > pii;
typedef pair < ll, ll > pll;
typedef vector < pll > vpll;
typedef vector < pii > vpii;
typedef vector < vpll > vvpll;
typedef vector < vpii > vvpii;

#define pb push_back
#define eb emplace_back
#define pf push_front
#define all(c) (c).begin(), (c).end()
#define ff first
#define ss second
#define mp(x,y) make_pair((x), (y))
#define boost ios_base::sync_with_stdio(false); cin.tie(NULL)



void solve(){
    
    int n; cin >> n;
    string s; cin >> s;
    int ans = 0, cnt = 0;
    for(int i = 0; i < n; i++){
        cnt += (s[i] == 'R');
    }
    for(int i = 0; i < cnt; i++){
        ans += (s[i] == 'W');
    }
    cout << ans << '\n';

}


int main(){
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    boost;

    int t = 1;
    // cin >> t;


    for(int i = 1; i <= t; i++){
        // cout << "Case #" << i << ": ";

        solve();

    }
    return 0;
}

Measured memory_bytes: 3712
#include <stdio.h>

#define max(a, b) ((a) > (b) ? (a) : (b))

int main(void)
{
    int l;
    int a, b;
    int c, d;

    scanf("%d", &l);
    scanf("%d %d", &a, &b);
    scanf("%d %d", &c, &d);

    printf("%d\n", l - max(a / c + (a % c != 0), b / d + (b % d != 0)));

    return 0;
}

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


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

   vector<int> p(n);
   rep(i,n) cin >> p[i];

   int count = 0;
   
    for (int i = 1; i < n - 1; ++i) {
        if(p[i] < p[i + 1] && p[i] > p[i - 1])count++;
        else if(p[i] < p[i - 1] && p[i] > p[i + 1])count++;
    }
    
    print(count);
}

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

int main() {
  long A;
  long B;
  long N;
  cin >> A >> B >> N;
  long ans;
  if( N>=B-1){
    
    ans = (A*(B-1))/B;
    
  }
  else{
    ans = (A*N)/B;
  }
  
  cout << ans <<  endl;
  
  
}


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

int main()
{
	int N;
	cin >> N;
	double ans = 0;
	for (int i = 0; i < N; ++i)
	{
		double x;
		string u;
		cin >> x >> u;
		if (u == "JPY")
		{
			ans += x;
		}
		else
		{
			ans += x * 380000.0;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
// package app;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Scanner;
import java.util.StringJoiner;
import java.util.stream.Stream;

public class Main {

    public static void main(final String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);

        int[] a = new int[4];
        for (int i = 0; i < 4; i++) {
            a[i] = System.in.read() - '0';
        }

        String result = "";
        for (int i = 0; i < 2; i++) {
            for (int j = 0; j < 2; j++) {
                for (int j2 = 0; j2 < 2; j2++) {
                    for (int k = 0; k < 2; k++) {
                    int a1 = i % 2 == 0 ? a[0] : -a[0];
                    String op1 = j % 2 == 0 ? "+" : "-";
                    int a2 = j % 2 == 0 ? a[1] : -a[1];
                    String op2 = j2 % 2 == 0 ? "+" : "-";
                    int a3 = j2 % 2 == 0 ? a[2] : -a[2];
                    String op3 = k % 2 == 0 ? "+" : "-";
                    int a4 = k % 2 == 0 ? a[3] : -a[3];

                        if (a1 + a2 + a3 + a4 == 7){
                        result = Objects.toString(a[0]) + op1 + Objects.toString(a[1]) + op2 + Objects.toString(a[2]) + op3 + Objects.toString(a[3]) +"=7";
                        System.out.println(result);
                        return;
                        }
                    }
                }
            }
        }
    }
}

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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = (n-1); i >= 0; --i)

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

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

const int MAX = 200005;
const int INF = 1001001001;
const int MOD = 1000000007;

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

    vector<int> A(N);
    rep(i, N) cin >> A[i];

    int ans = A[0];
    rep(i, N) {
        ans = __gcd(ans, A[i]);
    }

    cout << ans << endl;
}

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

int main(){
  ll a,b,n;
  cin>>a>>b>>n;
  ll x=min(n,b-1);
  cout<<floor(a*x/b)-a*floor(x/b)<<endl;
  return 0;
}

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

int N, M, G, D;

bool c (vector<string> m) {
    int y = M - 1;
    for (int x = 0; x < D; x++) {
        if (y < N-1 && m[x][y] == '1') {
            y++;
        } else if (0 < y && m[x][y-1] == '1') {
            y--;
        }
    }
    if (y == G-1) return true;
    else return false;
}

bool t (string g) {
    for (int i = 0; i < g.size() - 1; i++) {
        if (g[i] == '1' && g[i+1] == '1') return false;
    }
    return true;
}

int main ()
{
    while  (cin >> N, N) {
        cin >> M >> G >> D;
        vector<string> v (D);
        for (int i = 0; i < D; i++) {
            cin >> v[i];
        }
        if (c(v)) {
            cout << 0 << endl;
            goto escape;
        }
        for (int i = 0; i < D; i++) {
            for (int j = 0; j < N-1; j++) {
                if (v[i][j] != '1') {
                    v[i][j] = '1';
                    if (t(v[i])) {
                        if(c(v)) {
                            cout << i+1 << " " << j+1 << endl;
                            goto escape;
                        };
                    }
                    v[i][j] = '0';
                }
            }
        }
        cout << 1 << endl;
    escape:;
    }

    return 0;
}

Measured memory_bytes: 1216
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  ll N;
  ll D;
  cin >> N >> D;
  ll X[N];
  ll Y[N];
  int Sum=0;
  ll k;
  rep(i,N){cin >> X[i] >> Y[i];}
  rep(i,N){
    Sum += (X[i])*(X[i])+(Y[i])*(Y[i]) <= D*D;
  }
  cout << Sum << endl;
  return 0;
}


Measured memory_bytes: 6712
def solve(string):
    ins = string.split("\n")
    h, w = map(int, ins[0].split(" "))
    a = [list(map(lambda x: int(x) % 2 == 1, input().strip().split(" "))) for _i in range(h)]
    move = []
    for i in range(h):
        for j in range(w):
            if not a[i][j]:
                continue
            if j < w - 1:
                a[i][j + 1] ^= True
                move.append("{} {} {} {}".format(i + 1, j + 1, i + 1, j + 2))
            elif i < h - 1:
                a[i + 1][j] ^= True
                move.append("{} {} {} {}".format(i + 1, j + 1, i + 2, j + 1))
    move.insert(0, str(len(move)))
    return "\n".join(move)


if __name__ == '__main__':
    line = input().strip()
    print(solve(line))


Measured memory_bytes: 16344
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
constexpr int MOD = 1000000007;
constexpr int INF = 2000000000;
using namespace std;


//m^n%MOD
unsigned long long power(unsigned long long x, unsigned long long n, unsigned long long M) {
	unsigned long res = 1;
	if (n > 0) {
		res = power(x, n / 2, M);
		if (n % 2 == 0)res = (res*res) % M;
		else res = (((res*res) % M)*x) % M;
	}
	return res;
}


int main() {
	int m, n;
	cin >> m >> n;
	cout << power(m, n, MOD) << endl;
}

Measured memory_bytes: 3096
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#define MOD 1000000007
typedef long long ll;

using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    
    vector<int> v(n);
    priority_queue<int> que;
    for(int i = 0; i < n; i++) {
        cin >> v[i];
        que.push(v[i]);
    }
    
    for(int i = 0; i < m; i++) {
        int top = que.top();
        que.pop();
        
        top /= 2;
        que.push(top);
    }
    
    ll ans = 0;
    while(!que.empty()) {
        ans += que.top();
        que.pop();
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1276
#include <stdio.h>

int main(void)
{

 int S,h,m,s;
 scanf("%d",&S);
 
 h = S / 3600;
 m = (S - h*3600)/60;
 s = S - h*3600 - m*60;



 printf("%d:%d:%d\n",h,m,s);
 return 0;

}

Measured memory_bytes: 592
#include <stdio.h>
#include <string.h>
 
int main(void){
  char s[1001], order[8], ch[1001];
  int i, j, n, a, b;
 
  scanf("%s\n%d", s, &n);
 
  for(i=0;i<n;i++){
    scanf("%s %d %d", order, &a, &b);
     
    if(!strcmp(order, "reverse")){
      for(j=a;j<=b;j++)
        ch[b-j] = s[j];
      for(j=a;j<=b;j++)
        s[j] = ch[j-a];
    }
 
    if(!strcmp(order, "replace")){
      scanf("%s", ch);
      for(j=0;ch[j]!='\0';j++)
        s[a+j] = ch[j];
    }
 
    if(!strcmp(order, "print")){
      for(j=a;j<=b;j++)
        printf("%c", s[j]);
      printf("\n");
    }
  }
 
  return 0;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, s, n) for(int i = s; i < (int)n; i++)
#define per(i, n) for(int i = n; i >= 0; i--)
#define ROF(i, s, n) for(int i = s; i >= (int)n; i--)
#define FORIT(i, A) for (auto i : A)
#define PRINT(x) cout << (x) << "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define MP make_pair
#define EACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x) cout << #x << " = " << (x) << "\n";
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << "\n";
#define sq(n) (n) * (n)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef priority_queue<int> maxpq;
typedef priority_queue< int, vector<int>, greater<int> > minpq;
static const double EPS = 1e-10;
static const double PI = acos( -1.0 );
static const int mod = 10007;
static const int INF = 1 << 25;
static const LL LL_INF = 1152921504606846976;
static const int dx[] = { -1, 0, 1, 0,  1, -1,  1, -1 };
static const int dy[] = { 0, -1, 0, 1 , 1,  1, -1, -1 };

int n;
double x1, x2, x3, x4, y, y2, y3, y4;
complex<double> a, b, c, d;
int main() {
	scanf( "%d", &n );
	for ( int i = 0; i < n; i++ ) {
		scanf( "%lf %lf %lf %lf %lf %lf %lf %lf", &x1, &y, &x2, &y2, &x3, &y3, &x4, &y4 );
		if ( fabs( ( x2 - x1 ) * ( y4 - y3 ) - ( x4 - x3 ) * ( y2 - y ) ) < EPS ) {
			printf( "YES\n" );
		}
		else {
			printf( "NO\n" );
		}
	}
	return 0;
}

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

int main() {
	vector<int> ans;
	int now=0,ans_now=0;
	vector<int> dp(35);
	int tmp,tmp1,tmp2;
	int a[31];

	//入力
	dp[0] = 1;dp[1] = 1;dp[2] = 2;
	a[0] = a[1] = a[2] = 1;
	for (int i = 3; i <= 33; i++) {
		dp[i] = dp[i - 1] + dp[i - 2] + dp[i - 3];
		//cout <<i<< dp[i-1] <<" "<< dp[i - 2] << " "<< dp[i - 3] << " "<< " c" << endl;
		 //cout << dp[tmp]<<" a"<<endl;
		 //何年かかるか
		tmp1 = dp[i] % 3650;
		tmp2 = dp[i] / 3650;
		if (tmp1 != 0) {
			tmp2++;
		}
		ans.push_back(tmp2);
	}
	cin >> tmp;
	int i = 3;
	 do{
		a[i] = ans[tmp];
		 cin >> tmp;
		 i++;
	 } while (tmp!=0);
	for (int j = 0; j < 30; j++) {
		cout << a[j]<<endl;

	}

	return 0;
}


Measured memory_bytes: 3088
import java.util.*;
class Main
{
  public static void main(String args[])
  {
    int i,s=0;
    String n;
    Scanner sc= new Scanner(System.in);
    n=sc.next();
    for(i=0;i<n.length();i++)
      s+=n.charAt(i)-'0';
    if (s%9==0)
      System.out.println("Yes");
    else
      System.out.println("No");
  }
}
 

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

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

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

int main(){
  int N, K, v[SIZE];

  scanf("%d%d", &N, &K);

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

  int ans = -INF;

  for(int i=0;i<N;i++){
    for(int j=i;j<=N;j++){
      if(N - (j - i) > K) continue;

      int p = N - (j - i);
      int q = K - p;

      debug(p);

      vector<int> vec;

      for(int k=0;k<N;k++){
        if(k < i || j <= k) vec.push_back(v[k]);
      }

      sort(vec.begin(), vec.end(),greater<int>());

      int sum = 0;

      for(int i=0;i<p;i++){
        if(vec[i] < 0 && p - q <= i) break;
        sum += vec[i];
      }

      ans = max(sum, ans);
    }
  }


  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
#include<random>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef set<int> S;
#define rep(i, n) for(int i=0; i<n; i++)
const ll MOD=1e9+7;

int main(){

  string s;
  cin >> s;
  if(s[2]==s[3] && s[4]==s[5]){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef double du;
const ll inf=9223372036854775807ll;
struct line{
	ll k,b;//y=kx+b
	line(ll k=0,ll b=0):k(k),b(b){}
	ll get(ll x){return k*x+b;}
}st[300010],u;
int tp;
du its(line a,line b){
	return(b.b-a.b)/du(a.k-b.k);
}
int t[300010],n;
ll s[300010],f[300010],g[300010];
void dp(ll*f){
	int i;
	for(i=1;i<=n;i++)s[i]=s[i-1]+t[i];
	tp=1;
	st[1]=line(0,0);
	for(i=1;i<=n;i++){
		while(tp>1&&st[tp].get(i)<=st[tp-1].get(i))tp--;
		f[i]=max(st[tp].get(i)+((ll)i*i+i)/2-s[i],f[i-1]);
		u=line(-i,f[i]+((ll)i*i-i)/2+s[i]);
		while(tp>1&&its(u,st[tp-1])>=its(st[tp],st[tp-1]))tp--;
		st[++tp]=u;
	}
}
ll h[300010];
void solve(int l,int r){
	if(l==r){
		h[l]=1ll-t[l];
		return;
	}
	int mid,i,now;
	ll mx;
	mid=(l+r)>>1;
	solve(l,mid);
	solve(mid+1,r);
	tp=0;
	for(i=l-1;i<mid;i++){
		u=line(-i,f[i]+((ll)i*i-i)/2+s[i]);
		while(tp>1&&its(u,st[tp-1])>=its(st[tp],st[tp-1]))tp--;
		st[++tp]=u;
	}
	now=1;
	mx=-inf;
	for(i=r;i>mid;i--){
		while(now<tp&&its(st[now],st[now+1])>=i)now++;
		mx=max(mx,st[now].get(i)+((ll)i*i+i)/2-s[i]+g[i+1]);
		h[i]=max(h[i],mx);
	}
	tp=0;
	for(i=mid+1;i<=r;i++){
		u=line(-i,g[i+1]+((ll)i*i+i)/2-s[i]);
		while(tp>1&&its(u,st[tp-1])>=its(st[tp],st[tp-1]))tp--;
		st[++tp]=u;
	}
	now=tp;
	mx=-inf;
	for(i=l-1;i<mid;i++){
		while(now>1&&its(st[now],st[now-1])<=i)now--;
		mx=max(mx,st[now].get(i)+((ll)i*i-i)/2+s[i]+f[i]);
		h[i+1]=max(h[i+1],mx);
	}
}
int main(){
	int i,m,x,y;
	scanf("%d",&n);
	for(i=1;i<=n;i++)scanf("%d",t+i);
	dp(f);
	reverse(t+1,t+n+1);
	dp(g);
	reverse(t+1,t+n+1);
	reverse(g+1,g+n+1);
	for(i=1;i<=n;i++)s[i]=s[i-1]+t[i];
	solve(1,n);
	scanf("%d",&m);
	while(m--){
		scanf("%d%d",&x,&y);
		printf("%lld\n",max(f[x-1]+g[x+1],h[x]+t[x]-y));
	}
}

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

int main(void){
    ll n,k; cin >> n >>k;
    string s; cin >> s;
    ll cnt=0;
    for(int i=0;i<n;i++){
        if((s[i]=='L'&& 0<=i-1 && s[i-1]=='L') || (s[i]=='R' && i+1<n && s[i+1]=='R')) cnt++;
    }
    ll cnt_r = 0;
    int i=0;
    while(i<n){
        if(s[i]=='L'){
            while(i<n && s[i]=='L'){
                if(i+1<n && s[i+1]=='R'){
                    i++;
                    break;
                }else{
                    i++;
                }
            } 
            while(i<n && s[i]=='R'){
                if(i+1<n && s[i+1]=='L'){
                    i++;
                    cnt_r++;
                    break;
                }else{
                    i++;
                }
            }
        }else{
            i++;
        }
    }
    ll ans = cnt + min(k,cnt_r)*2;
    k -= cnt_r;
    if(0<k && s[0]=='R' && s[n-1]=='R' && ans < n-1) ans+=2;
    else if(0<k && s[0]=='R' && ans < n-1) ans++;
    else if(0<k && s[n-1]=='R' && ans < n-1) ans++;    
    cout << ans << endl;
    // cout << cnt << ' ' << cnt_r << endl;
    return 0;
}


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

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

const int N = 2e5+10 , mod = 1e9+7;

ll a[N] , b[N] , mx[N] , mn[N];
ll ps[N];

int32_t main(){
   ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
   int n;
   cin >> n;
   for(int i = 0 ; i <= n ; i++)
      cin >> a[i];
   for(int i = n ; i >= 0 ; i--){
      ps[i] = ps[i + 1] + a[i];
   }
   ll ans = 0;
   for(int i = 0 ; i <= n ; i++){
      if(i)
         mx[i] = min(ps[i] , 2ll * (mx[i - 1] - a[i - 1]));
      else
         mx[i] = 1;
      if(i)
         mn[i] = max(mn[i - 1] - a[i - 1] , a[i]);
      else
         mn[i] = 1;
      if(mx[i] < mn[i])
         return cout << -1 , 0;
      //cout << i << " " << mn[i] << " " << mx[i] << endl;
   }
   for(int i = n ; i >= 0 ; i--){
      if(i == n){
         if(a[i] < mn[i] || a[i] > mx[i])
            return cout << -1 , 0;
         b[i] = a[i];
      }
      else{
         b[i] = min(mx[i] , a[i] + b[i + 1]);
      }
      ans += b[i];
   }
   cout << ans;
   return 0;
}


Measured memory_bytes: 7616
const main = arg => {
  let [a,b,c,d] = arg.trim().split("\n")[0].split(" ").map(e => BigInt(e))
  let max = a*c
  if (a*d > max) max = a*d
  if (b*c > max) max = b*c
  if (b*d > max) max = b*d
  console.log(max.toString())
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29580
mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.buffer.readline

    N = int(input())
    X = set()
    Y = {}
    for _ in range(N):
        x, y = map(int, input().split())
        X.add(x)
        if x not in Y:
            Y[x] = {y}
        else:
            Y[x].add(y)
    X = sorted(list(X))
    NX = len(X)
    for x in X:
        Y[x] = sorted(list(Y[x]))

    ymin = Y[X[0]][0]
    ymax = Y[X[0]][-1]
    ans = 0
    for i in range(1, NX):
        x = X[i]
        dx = X[i] - X[i-1]
        ymin_new = Y[x][0]
        ymax_new = Y[x][-1]
        ans = max(ans, ymax - ymin_new + dx, ymax_new - ymin + dx)
        ymax = max(ymax + dx, ymax_new)
        ymin = min(ymin - dx, ymin_new)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 186732
//package AtCoder;
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int k=sc.nextInt();
		int c=0;
		while(n!=0)
		{
			n/=k;
			c++;
		}
		System.out.println(c);

	}

}


Measured memory_bytes: 21972
#include <algorithm>
#include <iostream>

using namespace std;

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

  int need = max({a, b, c}) * 3 - (a + b + c);
  if (need & 1) {
    cout << (need + 3) / 2 << endl;
  } else {
    cout << need / 2 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import sys

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

if 0 in A:
    print(0)
    sys.exit();

ans = 1
for a in sorted(A, reverse=True):
    ans *= a
    if ans > 10**18:
        print(-1)
        break
else:
    print(ans)

Measured memory_bytes: 21788
#pragma GCC optimize("-O3")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void Main();
#ifdef ConanYu
#include "local.hpp"
#else
#define debug(...) do { } while(0)
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  Main();
}
#endif

void Main() {
  int n, k; cin >> n >> k;
  string s; cin >> s;
  int ans = 0;
  for(int i = 1; i < n; i++) {
    if(s[i] == s[i - 1]) ans++;
  }
  ans += 2 * k;
  cout << min(ans, n - 1) << "\n";
}


Measured memory_bytes: 512
int_h, int_w = map(int, input().split())

masu = list()

for i in range(int_h):
    masu.append(list(input()))

conv = list()
for x in list(map(list, zip(*masu))):
    if "#" in x:
        conv.append(x)

result = list()

for y in list(map(list, zip(*conv))):
    if "#" in y:
        result.append(y)

for r in result:
    print("".join(r))


Measured memory_bytes: 3316
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

vector<int> x;
vector<int> a, b, c;
vector<vector<vector<int> > > memo;

bool solve(int i, int j, int f)
{
    if(i == j)
        return x[i] == a[f];
    if(memo[i][j][f] != -1)
        return memo[i][j][f] == 1;

    for(int k=i; k<j; ++k){
        if(solve(i, k, b[f]) && solve(k+1, j, c[f])){
            memo[i][j][f] = 1;
            return true;
        }
    }

    memo[i][j][f] = 0;
    return false;
}

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

    int m;
    cin >> m;
    a = b = c = vector<int>(m);
    for(int i=0; i<m; ++i){
        cin >> a[i] >> b[i] >> c[i];
        -- b[i];
        -- c[i];
    }

    memo.assign(n, vector<vector<int> >(n, vector<int>(m, -1)));
    if(solve(0, n-1, 0))
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}

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

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

ll N,M,L,R;
ll mo=1000000007;
ll ret;

ll comb(ll N_, ll C_) {
	const int NUM_=700001;
	static ll fact[NUM_+1],factr[NUM_+1],inv[NUM_+1];
	if (fact[0]==0) {
		inv[1]=fact[0]=factr[0]=1;
		for (int i=2;i<=NUM_;++i) inv[i] = inv[mo % i] * (mo - mo / i) % mo;
		for (int i=1;i<=NUM_;++i) fact[i]=fact[i-1]*i%mo, factr[i]=factr[i-1]*inv[i]%mo;
	}
	if(C_<0 || C_>N_) return 0;
	return factr[C_]*fact[N_]%mo*factr[N_-C_]%mo;
}
ll hcomb(int P_,int Q_) { return (P_==0&&Q_==0)?1:comb(P_+Q_-1,Q_);}


ll pat(int a,int b,int ma) {
	ll tot=0;
	for(int over=0;over*b+M*a<=ma && over<=N-M;over++) {
		ll pat=comb(N,M)*comb(N-M,over)%mo*hcomb(N+1,ma-(over*b+M*a))%mo;
		if(over%2==0) {
			tot+=pat;
		}
		else {
			tot+=mo-pat;
		}
	}
	return (tot%mo+mo)%mo;
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>M>>L>>R;
	
	for(i=L;i<=R;i++) ret+=hcomb(N,i);
	for(int la=1;la<=R;la++) {
		ret-=(pat(la,la,R)-pat(la+1,la,R))-(pat(la,la,L-1)-pat(la+1,la,L-1));
	}
	
	
	cout<<(ret%mo+mo)%mo<<endl;
	
}


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


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

vector<long long> fac, fac_inv;

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

long long inverse(long long a, long long p) {
  return modpow(a, p-2, p);
}

void comInit(int n, int p) {
  fac.resize(n+1);
  fac_inv.resize(n+1);
  fac.at(0) = fac.at(1) = 1;
  fac_inv.at(0) = fac_inv.at(1) = 1;
  for (int i = 2; i <= n; i++) {
    fac.at(i) = fac.at(i-1) * i % p;
    fac_inv.at(i) = fac_inv.at(i-1) * inverse(i, p) % p;
  }
}

long long com(int n, int k, int p) {
  if (n < k || n < 0 || k < 0) return 0;
  return fac.at(n) * (fac_inv.at(k) * fac_inv.at(n-k) % p) % p;
}

int main() {
  const int MOD = 1000000007;
  int n, k; cin >> n >> k;
  comInit(2*n, MOD);
  // { n, 0, 0, ..., 0 } は n-1 回の移動で可能
  if (k >= n-1) {
    // n 個のボール、n-1 個の仕切りの並べかえ
    cout << com(2*n-1, n-1, MOD) << endl;
  }
  else {
    long long ans = 0;
    // 0 は k 個以下、和は n となるような数列
    for (int i = 0; i <= k; i++) {
      ans = (ans + (com(n, i, MOD) * com(n-1, i, MOD) % MOD)) % MOD;
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 6528
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <iomanip>
#include <cmath>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
using ll = long long;
constexpr ll INF = 1LL << 60;
constexpr ll MOD = 1e9 + 7;

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    int N; cin >> N;
    if(N<=999) cout << "ABC" << endl;
    else cout << "ABD" << endl;
    return 0;
}

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

class Main{
    public static void main(String args[])throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int i;
        int j;
        while(true){
            String[] str = br.readLine().split(" ");
            int h = Integer.parseInt(str[0]);
            int w = Integer.parseInt(str[1]);
            if(h == 0 || w == 0) break;
            for(i=0;i<h; i++){
                System.out.print("");
                for(j=0; j<w-1; j++){
                    if((i%2!=0 && j%2==0) ^ (i%2==0 && j%2!=0)){
                        System.out.print(".");
                    }else{
                        System.out.print("#");
                    }
                   
                }
                if((i%2!=0 && j%2==0) ^ (i%2==0 && j%2!=0)){
                    System.out.println(".");
                }else{
                    System.out.println("#");
                }
                //int sum = i + j;
                //System.out.println(sum);
            }
            System.out.print("\n");
        }
    }
}

Measured memory_bytes: 25980
import sys
import math
si = sys.stdin.readline


def main():
    l = [int(e) for e in si().split()]
    a, b, h, m = l[0], l[1], l[2], l[3]
    h = h/12*360+m/60*360/12
    m = m/60*360
    if m > h:
        m, h = h, m
    ang = (h-m)/360*math.pi*2
    if a > b:
        a, b = b, a
    print(math.sqrt(b**2+a**2-2*a*b*math.cos(ang)))


if __name__ == '__main__':
    main()


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

#define INF (1LL << 31 - 1)
#define MOD int(1e9+7)
#define repi(i,j,n) for(int i = (j); i < (n); ++i)
#define rep(i,n) repi(i,0,n)
#define fi first
#define se second

inline void init() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

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

    int si = s.size();
    for (int i = 0; i < si; ++i) {
        if (i % 2 == 0) cout << s[i];
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 512
fn read_lines() -> Vec<String> {
    use std::io::Read;

    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    return buf.lines().map(|e| e.to_string()).collect::<Vec<_>>();
}

fn main() {
    let input = read_lines();
    let n: usize = input[0].parse().unwrap();
    let mut series = input[1].split_whitespace().map(|s| s.parse().unwrap()).collect::<Vec<u32>>();
    let cnt = merge_sort(&mut series, 0, n);

    println!("{}", cnt);
}

fn merge<T: Ord + Clone>(series: &mut Vec<T>, left: usize, mid: usize, right: usize) -> u64 {
    let ls = series[left..mid].to_vec();
    let rs = series[mid..right].to_vec();

    let mut inv_cnt = 0;
    let mut li = 0;
    let mut ri = 0;
    for i in left..right {
        if ls.len() <= li {
            series[i] = rs[ri].clone();
            ri += 1;            
        } else if rs.len() <= ri {
            series[i] = ls[li].clone();
            li += 1;
        } else if ls[li] > rs[ri] {
            series[i] = rs[ri].clone();
            ri += 1;
            inv_cnt += ls.len() - li;
        } else {
            series[i] = ls[li].clone();
            li += 1;
        }
    }
    return inv_cnt as u64;
}

fn merge_sort<T: Ord + Clone>(series: &mut Vec<T>, left: usize, right: usize) -> u64 {
    if left + 1 < right {
        let mid = (left + right) / 2;
        let c1 = merge_sort(series, left, mid);
        let c2 = merge_sort(series, mid, right);
        let c3 = merge(series, left, mid, right);
        return c1 + c2 + c3;
    } else {
        return 0;
    }
}


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

#define ll long long
#define ull unsigned long long
#define pb push_back
#define pii pair<ll, ll>
#define sz size()

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>void __f(const char* name, Arg1&& arg1){cout<<name<<" : "<<arg1<<"\n";}
template <typename Arg1, typename... Args>void __f(const char* names, Arg1&& arg1, Args&&... args)
{const char* comma=strchr(names+1,',');cout.write(names,comma-names)<<" : "<<arg1<<" , ";__f(comma+1, args...);} 
#define traceloop(x,a) { cerr<<#a<<": "; for(ll ix=0;ix<x;ix++) cerr<<a[ix]<<" "; cerr<<endl; }

int main()
{
	ios::sync_with_stdio(0);
	int i, n, j, k;
	cin>>n>>k;
	int a[n];
	vector<int> dp(n, 1e9+7);
	for(i=0;i<n;++i)
		cin>>a[i];

	dp[0] = 0;
	for(i=0;i<n;++i)
	{
		for(j=i+1;j<min(n,i+k+1);++j)
		{
			dp[j] = min(dp[j], dp[i] + abs(a[i] - a[j])) ;
		}
	}

	cout << dp[n-1] << "\n";

	return 0;
}

Measured memory_bytes: 1024
import collections
N=int(input())
V=list(map(int,input().split()))
a=[V[i] for i in range(N) if i%2==0]
b=[V[i] for i in range(N) if i%2==1]

a=collections.Counter(a)
b=collections.Counter(b)
a=a.most_common()
b=b.most_common()
if len(a)==len(b)==1:
    if a[0][0]==b[0][0]:
        print(int(N/2))
    else:
        print(0)
elif len(a)==1 and len(b)>=2:
    print(N-(b[0][1] if a[0][0]!=b[0][0] else b[1][1])-a[0][1])
elif len(a)>=2 and len(b)==1:
    print(N-(a[0][1] if a[0][0]!=b[0][0] else a[1][1])-b[0][1])
elif len(a)>=2 and len(a)>=2:
    print(min(N-(b[0][1] if a[0][0]!=b[0][0] else b[1][1])-a[0][1],N-(a[0][1] if a[0][0]!=b[0][0] else a[1][1])-b[0][1]))


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

int main() {
	int a, b, hy;
	scanf("%d %d", &a, &b);
	int x = a + b + 1;
	int y = a;
	
	char n[x];
	scanf("%s", &n);
	int length = strlen(n);
	
	for(int i = 0; i < x; i++) {
		if(n[i] == '-') {
			hy++;
		}
	}
	
	if(length == x && n[y] == '-' && hy == 1) {
		printf("Yes");
	} else {
		printf("No");
	}
	return 0;
}

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

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x) cerr << #x << " = " << x << endl
using namespace std;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;

const ld PI = 3.14159265359;

ll MOD = (ll) 1e9 + 9;
const ll MAXN = (ll) 2e5 + 10;
const ll INF = (ll) (LONG_LONG_MAX - 3ll) / 2ll;
const ld EPS = (ld) 1e-8;
const ll P = 104107;

ll mul(ll a, ll b){
	return (a * b) % MOD;
}

ll pw(ll b, ll p){
	if(p == 0) return 1;
	if(p & 1) return mul(b, pw(b, p - 1));
	return pw(mul(b, b), p / 2);
}
ll inv(ll x){
	return pw(x, MOD - 2);
}

ll n, a[MAXN];

ll val(ll x){
	for(int i = 0; i < n;i++) x = (x / a[i]) * a[i];
	return x;
}

int main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
	for(int i = 0; i < n; i++) cin >> a[i];
	
	ll l = 0, r = INF;
	ll mid;
	while(l + 1 < r){
		mid = (l + r) >> 1;
		if(val(mid) < 2) l = mid;
		else r = mid;
	}
	if(val(r) != 2) return cout << -1, 0;
	cout << r << ' ';
	l = 0, r = INF;
	while(l + 1 < r){
		mid = (l + r) >> 1;
		if(val(mid) <= 2) l = mid;
		else r = mid;
	}
	cout << l << ' ';
	return 0;
}




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

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

typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//定数
#define INF 1000000000 //10^9:極めて大きい値,∞
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

int main(){
    int n;
    cin>>n;
    vector<int> ans(n+1);
    for(int x=1;x<105;x++){
        for(int y=1;y<105;y++){
            for(int z=1;z<105;z++){
                int v=x*x+y*y+z*z+x*y+y*z+z*x;
                if(v<=n) ans[v]++;
            }
        }
    }
    for(int i=1;i<=n;i++){
        cout<<ans[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 3632
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
using namespace std;
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define rrep(i,a,n) for(ll i=n;i>=a;i--)
#define elif else if
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF = 1e+17;
const ll MODcdf = 998244353;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    ll a,b;cin>>a>>b;
    ll c,d;cin>>c>>d;
    ll ans=a*b-a*d-b*c+c*d;
    cout<<ans<<endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;

namespace C_GoHome {
    class Program {
        static void Main(string[] args) {
            int X = int.Parse(Console.ReadLine());
            int i = 0, x = 0;
            while(true) {
                x += i;
                if (x >= X) break;
                i++;
            }
            Console.WriteLine(i);
        }
    }
}


Measured memory_bytes: 13140