akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.util.ArrayList;
import java.util.List;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    List<Long> list = new ArrayList<>();
    int n = sc.nextInt();
    for(int i = 0; i < n; i++){
      list.add(sc.nextLong() - i);
    }
    
    Collections.sort(list);
    long size = list.get((int)(list.size() / 2));
	
    long ans1 = 0L;
    for(int i = 0; i < n; i++){
       ans1 += Math.abs(list.get(i) - size);
    }
    
    System.out.println(ans1);
    return;
  }
}


Measured memory_bytes: 96540
#include <algorithm>
#include <array>
#include <vector>
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <functional>
#include <queue>

//AtCoderC++.cpp

using namespace std;

void Show(vector<vector<int>> Ns) {
	for (int i = 0; i < Ns.size(); i++) {
		for (int j = 0; j < Ns[i].size(); j++) {
			if (j == Ns[i].size() - 1) {
				cout << Ns[i][j] << endl;
			} else {
				cout << Ns[i][j] << ",";
			}			
		}
	}
}

void Show(vector<int> N) {
	for (int i = 0; i < N.size(); i++) {
		cout << N[i];
		if (i != N.size() - 1) {
			cout << " ";
		} else {
			cout << endl;
		}
	}
}


int main() {
	int A, B, K;
	cin >> A >> B >> K;
	for (int i = 0; i < K; i++) {
		if (i % 2 == 0) {
			if (A % 2 != 0)A--;
			B += A / 2;
			A /= 2;
		} else {
			if (B % 2 != 0)B--;
			A += B / 2;
			B /= 2;
		}
	}
	cout << A << " " << B << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<bitset>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#define LL long long

using namespace std;

LL read()
{
	LL ans=0,f=1;
	char c=getchar();
	while(c>'9'||c<'0'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){ans=ans*10+c-'0';c=getchar();}
	return ans*f;
}

LL h,ans,dp[1000005];

LL b(LL x);

int main()
{
	h=read();
	ans=b(h);
	printf("%lld",ans);
}

LL b(LL x)
{
	if(x<=1000000)
	{
		if(dp[x])
			return dp[x];
		if(x==1)
			return dp[x]=1;
		LL res=0;
		res=b(x/2)*2+1;
		return dp[x]=res;
	}
	else
		return b(x/2)*2+1;
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define lli  long double
#define mod 1000000007

lli min(lli a,lli b)
{
    if(a<b)
    {
        return a;
    }
    return b;

}
lli n,m;

lli power(lli x,lli n)
{
    lli res=1;
    while(n>0)
    {
        if((long long)n%2==1)
        {
            res=(res*x);
        }
        x=(x*x);
        n=n/2;
    }
    return res;
}

int main()
{
    cin>>n;
    lli ans=n/3;
    //cout<<ans<<"\n";
    ans=power(ans,3);
    cout<<fixed<<setprecision(12)<< ans<<"\n";
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <tuple>
#include <stack>
#include <bitset>

using namespace std;
typedef long long ll;

#define MAX_H 1000
#define MAX_W 1000
#define INF 1000000

typedef pair<int, int> Pij;
typedef pair< Pij, int> P;

char A[MAX_H][MAX_W];

int main() {

  // ---------------------
  // Input
  
  cin.tie(nullptr);
  ios::sync_with_stdio(false);

  int H, W;
  cin >> H >> W;

  vector<Pij> v_start;

  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> A[i][j];
      if (A[i][j] == '#') v_start.push_back( Pij(i, j) );
    }
  }

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

  int di[4] = {0, 1, 0, -1};
  int dj[4] = {1, 0, -1, 0};

  queue<P> que;
  
  for (int i = 0; i < v_start.size(); i++) {
    que.push( P(v_start[i], 0) );
  }

  int cnt_max = 0;
  
  while (que.size() != 0) {

    P p = que.front();
    que.pop();

    int i_now = p.first.first;
    int j_now = p.first.second;
    int cnt_now = p.second;

    cnt_max = max(cnt_max, cnt_now);
    
    for (int k = 0; k < 4; k++) {

      int ni = i_now + di[k];
      int nj = j_now + dj[k];

      if (ni >= 0 && ni < H && nj >= 0 && nj < W && A[ni][nj] != '#') {
	  que.push( P(Pij(ni, nj), cnt_now + 1) );
	  A[ni][nj] = '#';
      }
    }
  }
  
  cout << cnt_max << endl;
    
  return 0;
  
}


Measured memory_bytes: 21096
import java.util.*;

class Main{
    public static void main(String[] args){
	int alpha[] =new  int[26];
	Scanner sc = new Scanner(System.in);
	String bun = sc.next();
	char[] block = bun.toCharArray();

	for(int i = 0;i<bun.length();i++){
	    alpha[(int)block[i]-'a'] +=1; 
	    
	}
	int even = 0;
	for(int i = 0;i<26;i++){
	    if(alpha[i]%2 !=0){
		even = 1;
	    }
	}

	if(even == 0){System.out.println("Yes");}else{System.out.println("No");}
	
    }

}


Measured memory_bytes: 9680
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd_(ll a,ll b){if(a%b==0)return b;return gcd_(b,a%b);}
ll lcm_(ll a,ll b){ll c=gcd_(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))
//tie(a,b,c) = make_tuple(10,9,87);
#define pop_(a) __builtin_popcount((a))
ll keta(ll a){ll r=0;while(a){a/=10;r++;}return r;}
class comb{
  vector<ll> f,fr;
  ll MOD_;
  public:
  //a^(p-1) = 1 (mod p)(p->Prime numbers)
  //a^(p-2) = a^(-1)
  ll calc(ll a,ll b,ll p){//a^(b) mod p   
    if(b==0)return 1;
    ll y = calc(a,b/2,p);y=(y*y)%p;
    if(b & 1) y = (y * a) % p;
    return y;
  }
  void init(ll n,ll mod){//input max_n
    MOD_ = mod;
    f.resize(n+1);
    fr.resize(n+1);
    f[0]=fr[0]=1;
    for(ll i=1;i<n+1;i++){
      f[i] = (f[i-1] * i) % mod;
    }
    fr[n] = calc(f[n],mod-2,mod);
    for(ll i=n-1;i>=0;i--){
      fr[i] = fr[i+1] * (i+1) % mod;
    }
  }
  ll nCr(ll n,ll r){
    if(n<0||r<0||n<r)return 0;
    return f[n] * fr[r] % MOD_ * fr[n-r] % MOD_;
  }//nHr = n+r-1Cr
};



int main(){
	ll K,L;
  string s;
  cin >> K >> s;
  ll len = K + s.size();
  L = s.size();
  comb co;
  co.init(len+7,MOD);
  
  ll ans = 0;
  FOR(i,L,len+1){
  	ll c = co.nCr(len,i) * co.calc(25,len-i,MOD) % MOD;
  	(ans += c) %= MOD;
  }
  cout << ans << endl;
}



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

void str_U(string s){
	string S="";
	for(int i=0;i<s.size();i++){
		if(s[i]=='_'){
			i++;
			if('a'<=s[i]&&s[i]<='z'){
				S+=(s[i]-'a'+'A');
			}
			else{
				S+=s[i];
			}
		}
		else{
			S+=s[i];
		}
	}
	if('a'<=S[0] && S[0]<='z'){
		S[0]-='a';
		S[0]+='A';
	}
	cout<<S<<endl;
}
void str_L(string s){
	string S="";
	for(int i=0;i<s.size();i++){
		if(s[i]=='_'){
			i++;
			if('a'<=s[i]&&s[i]<='z'){
				S+=(s[i]-'a'+'A');
			}
			else{
				S+=s[i];
			}
		}
		else{
			S+=s[i];
		}
	}
	if('A'<=S[0] && S[0]<='Z'){
		S[0]-='A';
		S[0]+='a';
	}
	cout<<S<<endl;
}
void str_D(string s){
	string S="";
	for(int i=0;i<s.size();i++){
		if('A'<=s[i]&&s[i]<='Z'){
			if(i!=0)S+="_";
			S+=(s[i]-'A'+'a');
		}
		else{
			S+=s[i];
		}
	}
	cout<<S<<endl;
}


int main(){
	
	string s;
	char c;
	
	while(cin>>s>>c){
		if(c=='X')break;
		if(c=='U')str_U(s);
		if(c=='L')str_L(s);
		if(c=='D')str_D(s);
		
	}
	
	
	return 0;
}


Measured memory_bytes: 1200
#include <iostream>
#include <vector>
#include <algorithm>

#define REP(i,a,b) for(int i=int(a);i<int(b);i++)

using namespace std;

typedef long long int lli;

int main () {
    int m, n;
    while (cin >> m >> n, m + n) {
        vector<bool> nlist(7777777, false);
        REP (i, 0, m) nlist[i] = true;
        int ans = 0;
        REP (i, m, nlist.size()) {
            if (!nlist[i]) {
                if (n-- == 0) {
                    ans = i;
                    break;
                }
                for (int j = i; j < (int)nlist.size(); j += i) nlist[j] = true;
            }
        }
        cout << ans << endl;
    }
    return 0;
}

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

int main()
{
  	int n; cin >> n;
  int g = 0;
  for (int i = 0; i < n; ++i)
  {
    int x; cin >> x;
    g = __gcd(g, x);
  }
  cout << g;
  return 0;
}

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

int AB,BC,CA;

int main()
{
    cin >> AB>>BC>>CA;

    int m = min(AB+BC,BC+CA);
    int n = min(m,CA+AB);

    cout << n<< endl;

    

    return 0;    
}

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

int main()
{
    string s[2];
    string c;
    ll n[2];

    cin >> s[0] >> s[1];
    cin >> n[0] >> n[1];
    cin >> c;

    if (c==s[0]) {
        cout << n[0] - 1 << " " << n[1];
    } else {
        cout << n[0] << " " << n[1] - 1;
    }
}

Measured memory_bytes: 3608
// Jai Sai Ram
//Always help me!
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
vector<ll> adj[300001];
ll vis[100001];
ll dis[100001];
vector<ll> levels[100001];

void solve()
{
    ll i,j,k,l,m,n,o,p,q,r,t,a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<max({a*c,b*d,a*d,b*c});
    
}
int main()
{
    ios_base::sync_with_stdio(false);
     cin.tie(0);
    ll t=1;
   // cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}


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

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999

using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

int iy[]={0, 0, 1, -1};
int ix[]={1, -1, 0, 0};

long long int n, s[100], ans, dp[10001], dpa[10001], i, j;

int main(){
	dp[0] = 1;
	cin >> n;
	for(i=0;i<n;i++){
		cin >> s[i]; 
	}
	sort(s, s+n);
	for(i=0;i<n;i++){
		for(j=0;j<10001;j++){	
			if(dp[j]==1){
				dpa[j+s[i]] = 1;
			}
		}
		for(j=1;j<10001;j++){
			dp[j] = dpa[j];
		}
	}
	for(i=10000;i>-1;i--){
		if(i%10!=0&&dp[i]==1){
			break;
		}else if(i==0){
			break;
		}
	}
	
	cout << i << endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define SZ(s) ((int)(s.size()))
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair<int,int> PI;

int main(int argc, char *argv[])
{
  int k;
  cin >> k;
  vector<PI> tlist;
  rep(i, k){
    int h1, m1, h2, m2;
    scanf("%02d:%02d-%02d:%02d", &h1, &m1, &h2, &m2);
    m1 += h1 * 60;
    m2 += h2 * 60;
    tlist.pb(mp(m1,m2));
  }
  
  int n,m;
  vector<vector<PI> > tea,stu;
  cin >> n;
  rep(i, n){
    int k;
    cin >> k;
    vector<PI> tlist;
    rep(j, k){
      int h1, m1, h2, m2;
      scanf("%02d:%02d-%02d:%02d", &h1, &m1, &h2, &m2);
      m1 += h1 * 60;
      m2 += h2 * 60;
      tlist.pb(mp(m1,m2));
    }
    tea.pb(tlist);
  }  
  
  cin >> m;

  rep(i, m){
    int k;
    cin >> k;
    vector<PI> tlist;
    rep(j, k){
      int h1, m1, h2, m2;
      scanf("%02d:%02d-%02d:%02d", &h1, &m1, &h2, &m2);
      m1 += h1 * 60;
      m2 += h2 * 60;
      tlist.pb(mp(m1,m2));
    }
    stu.pb(tlist);
  }    

  

  int ans = 0;
  rep(i, k){
    int tn = 0, sn = 0;
    rep(j, n){
      bool fl = 0;
      for(auto e : tea[j]){
        //cout << tlist[i].F << ' ' << e.F << ' ' << e.S << ' ' << tlist[i].S << endl;
        fl |= e.F <= tlist[i].F && tlist[i].S <= e.S;
      }
      tn += fl;
    }
    
    rep(j, m){
      bool fl = 0;
      for(auto e : stu[j]){
        fl |= e.F <= tlist[i].F && tlist[i].S <= e.S;        
        //fl |= tlist[i].F <= e.F && e.S <= tlist[i].S;
      }
      sn += fl;      
    }
    //cout << tn << " " << sn << endl;
    ans += min(tn, sn);
  }
  cout << ans  << endl;
  return 0;
}

Measured memory_bytes: 1400
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }



int main() {
    int A, B, K;
    while (cin >> A >> B >> K) {
        vector<int> res;
        for (int i = 1; i <= max(A, B); ++i) {
            if (A % i == 0 && B % i == 0) res.push_back(i);
        }
        reverse(res.begin(), res.end());
        //COUT(res);
        cout << res[K-1] << endl;
    }
}










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

int main(){
	LL n, m, up, ans = 3000;
	cin >> n >> m;
	up = min(m, n + 2019);
	for(LL i = n; i < up; i++)
		for(LL j = i + 1; j <= up; j++)
			ans = min(ans, (i % 2019 * j % 2019) % 2019);
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int MAX = 510000;
const int INF = 1e9;
const double pi=acos(-1);

int main(){
  int a,b,c,x,y;
  cin >> a >> b >> c >> x >> y;
  ll ans=INF;
  for(ll i=0;i<=max(x,y);i++){
    ans = min(ans,i*2*c+max(x-i,0ll)*a+max(y-i,0ll)*b);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
// " --- IN THE NAME OF ALLAH --- " // ;)
// ------------sphr_agz------------ // ;)
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;

typedef long double ld;
typedef long long int lli;
typedef pair <lli, lli> pii;
#define pb push_back
#define recout(x) return cout << (x), 0
#define f first
#define s second
#define fast ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define stp(x) cout << setprecision(x) << fixed
#define mk make_pair
#define all(x) x.begin(), x.end()
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
//#pragma GCC optimize("no-stack-protector,fast-math")
const lli N = 1e5 + 10, N2 = 2e5, delta = 46639, mod = 1e9 + 7, oo = 1e18, LOG = 20, SQ = 300;
const ld PI = 3.141592653589793;

lli dp[N];

int32_t main() {
	fast;
	lli n, W, ans = 0;
	cin >> n >> W;
	lli w, v;
	cin >> w >> v;
	dp[w] = v;
	ans = v;
	for (lli i = 1; i < n; i++) {
		cin >> w >> v;
		for (lli j = W; j >= w; j--) {
			if (dp[j - w] || !(j - w))
				dp[j] = max (dp[j], dp[j - w] + v);
			ans = max (ans, dp[j]);
		}
	}
	cout << ans << '\n';
	return 0;
}


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

#define rep(i,x,y) for(int (i)=(x);i<(y);(i)++)

int main()
{
	int n, m, a;

	while (true) {
		cin >> n >> m >> a;
		if (n == 0 && m == 0 && a == 0) {
			break;
		}

		vector<int> num;
		rep(i, 0, n + 1) {
			num.push_back(i);
		}

		int h, p, q;
		vector<int> H, P, Q;
		rep(i, 0, m) {
			cin >> h >> p >> q;
			H.push_back(h);
			P.push_back(p);
			Q.push_back(q);
		}

		for (int i = m - 1; i >= 0; i--) {
			for (int j = 0; j < i; j++) {
				if (H[j] < H[j + 1]) {
					swap(H[j], H[j + 1]);
					swap(P[j], P[j + 1]);
					swap(Q[j], Q[j + 1]);
				}
			}
		}

		rep(i, 0, m) {
			swap(num[P[i]], num[Q[i]]);
		}

		rep(i, 0, n + 1) {
			if (a == num[i]) {
				cout << i << endl;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 3188
#ifdef ONLINE_JUDGE
    #define NDEBUG
#endif
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <queue>
#include <stack>
#include <bitset>
#include <cctype>
#include <cstdio>
#include <string>
#include <vector>
#include <cstring>
#include <cassert>
#include <cstdlib>
#include <climits>
#include <fstream>
#include <sstream>
#include <iostream>
#include <algorithm>
#define itn int
#define scnaf scanf
#define pritnf printf
#ifndef NDEBUG
    #define QWQ(...) (\
        fprintf (stderr, "QwQ in %d:", __LINE__),\
        fprintf (stderr, __VA_ARGS__),\
        fprintf (stderr, "\n")\
    )
#else
    #define QWQ(...)
#endif
using namespace std;
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
template<typename T>
inline void rei (T &x) {
    register bool f = false;
    register int ch;
    for (ch = getchar (); !isdigit (ch); ch = getchar ()) {
        if (ch == '-') {
            f = true;
        }
    }
    for (x = 0; isdigit (ch); ch = getchar ()) {
        x = (x << 3) + (x << 1) + (ch & 15);
    }
    if (f) {
        x = -x;
    }
}
const int MAXN = 55;
int u[MAXN];
int v[MAXN];
int fa[MAXN];
int n, m;
inline void init () {
    for (register int i = 1; i <= n; ++i) {
        fa[i] = i;
    }
}
inline int get (int x) {
    if (x == fa[x]) {
        return x;
    }
    return fa[x] = get (fa[x]);
}
inline void mange (int x, int y) {
    fa[get (x)] = get (y);
}
int main () {
    rei (n);
    rei (m);
    for (register int i = 1; i <= m; ++i) {
        rei (u[i]);
        rei (v[i]);
    }
    int ans = 0;
    for (register int i = 1; i <= m; ++i) {
        init ();
        for (register int j = 1; j <= m; ++j) {
            if (i != j) {
                mange (u[j], v[j]);
            }
        }
        for (register int j = 2; j <= n; ++j) {
            if (get (1) != get (j)) {
                ++ans;
                break;
            }
        }
    }
    printf ("%d\n", ans);
    return 0;
}


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

int main(){
    int n, a, b;
    cin >> n >> a >> b;
    int ans = min(n*a, b);
    cout << ans << endl;
    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>
// *テンプレート*
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
#define sz(x) x.size()
#define EPS (1e-10)
// aよりbの方が小さかったら、aの値をbの値に置き換える。(swapではない！)
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
// aよりbの方が大きかったら、aの値をbの値に置き換える。
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
//最大公約数
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
//最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
// 素数かどうか判定
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}

const long long MOD = 1000000007;
const long long INF = 1LL << 60;
// *テンプレートここまで*

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))

int h, w;
char s[410][410];
vector<pair<int, int>>vec;
bool used1[410][410], used2[410][410];
int f[] = { 0,1,0,-1,0,-1,0,1 };
int g[] = { 1,0,-1,0,1,0,-1,0 };
void init(){
	memset(used1, false, sizeof(used1));
}
int bl, wh;

void dfs(int x, int y) {
	init();
	used1[x][y] = true;
	used2[x][y] = true;
	if (s[x][y] == '#')bl++;
	else wh++;
	rep(i, 8) {
		if (x + f[i] < 0 || x + f[i] >= h || y + g[i] < 0 || y + g[i] >= w) {
			continue;
		}
		if (s[x][y] != s[x + f[i]][y + g[i]] && !used2[x + f[i]][y + g[i]]) {
			dfs(x + f[i], y + g[i]);
		}
	}
}
signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> h >> w;
	rep(i, h)rep(j, w) {
		cin >> s[i][j]; if (s[i][j] == '#')vec.push_back({ i,j });
	}
	int ans = 0;
	for (pair<int, int> i : vec) {
		if (used2[i.first][i.second])continue;
		bl = 0, wh = 0;
		dfs(i.first, i.second);
		ans += bl * wh;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 9584
#include <cstdio>
#include <cstdlib>
#define fo(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
const int N=3500,mo=1e9+7;
int read(int &n)
{
	char ch=' ';int q=0,w=1;
	for(;(ch!='-')&&((ch<'0')||(ch>'9'));ch=getchar());
	if(ch=='-')w=-1,ch=getchar();
	for(;ch>='0' && ch<='9';ch=getchar())q=q*10+ch-48;n=q*w;return n;
}
int m,n,ans;
int f[N][N],g[N][N];
int main()
{
	int q,w;
	read(n),read(m);
	fo(i,1,n)f[0][i]=1;
	g[0][0]=1;
	fo(i,1,m)
	{
		fo(j,0,n)
		{
			if(j<n)((f[i][j]+=f[i-1][j+1])>=mo?f[i][j]-=mo:0),((g[i][j]+=g[i-1][j+1])>=mo?g[i][j]-=mo:0);
			if(j)
			{
				if(j>1)((f[i][j]+=f[i-1][j])>=mo?f[i][j]-=mo:0);
				((g[i][j]+=g[i-1][j])>=mo?g[i][j]-=mo:0);
			}
			if(j<n)((f[i][j]+=f[i-1][j])>=mo?f[i][j]-=mo:0),((g[i][j]+=g[i-1][j])>=mo?g[i][j]-=mo:0);
			if(j)((f[i][j]+=f[i-1][j-1])>=mo?f[i][j]-=mo:0),((g[i][j]+=g[i-1][j-1])>=mo?g[i][j]-=mo:0);
		}
		((g[i][0]+=f[i][0])>=mo?g[i][0]-=mo:0);f[i][0]=0;
		((g[i][1]+=f[i-1][1])>=mo?g[i][1]-=mo:0);

	}
	fo(i,0,n)((ans+=g[m][i])>=mo?ans-=mo:0);
	printf("%d\n",ans);
	return 0;
} 

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

int main()
{
  int n;
  string s;
  cin >> n >> s;
  int flag = 1;
  if (n % 2 == 1)
  {
    flag = 0;
  }
  else
  {
    for (int i=0; i < n/2 ; i++)
    {
      if (s[i] != s[i+n/2])
      {
        flag = 0;
        break;
      }
    }
  }
  if(flag == 0)
  {
    cout << "No" << endl;
  }
  else
  {
    cout << "Yes" << endl;
  }
}

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

void solve() {
    int k, a, b; cin >> k >> a >> b;
    if (a % k == 0 || ((a / k) + 1) * k <= b) {
        cout << "OK" << '\n';
    } else {
        cout << "NG" << '\n';
    }
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    solve();
    return 0;
}


Measured memory_bytes: 3664
#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;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
#define dame { printf("No\n"); return 0;}
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)


signed main(){
    string s;
    cin >> s;
    int n = s.length();
    string t = "";
    REP(i,n){
        if(s[i] != 'x'){
            t += s[i];
        }
    }

    int t_n  = t.length();

    REP(i,t_n){
        if(t[i] != t[t_n - 1 - i]){
            cout << -1 << endl;
            return 0;
        }
    }


    int res = 0;


    int id = 0,id2 = n-1;

    while(id < id2){
        if(s[id] != s[id2]){
            res ++;
            if(s[id] =='x'){
                id ++;
            }
            else id2--;
        }
        else{
            id ++;
            id2 --;
        }

    }
    cout << res << endl;


}


Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<map>
#include<algorithm>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
int main(void){
    int a,b;
    vector<int> v(3,0);
    string s;
    cin>>a>>b;
    cin>>s;
    if(s.size()==a+b+1 && s[a]=='-') {
        rep(j,s.size()){
            if(j!=a && s[j]=='-' ){
                cout<<"No"<<endl;
                return 0;
            }
        }
        cout<<"Yes"<<endl;
    }    
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
/******
	~site:    atcoder.jp
	~user:    Turkhuu
	~problem: AtCoder Beginner Contest 176 - A (abc176_a)
** **/

#include<bits/stdc++.h>

#define FFOR(i,s,e,k) for(int i=s;(k==1?i<=e:i>=e);i+=k)
#define FOR(i,n) FFOR(i,0,n-1,1)
#define FORR(i,s,e) FFOR(i,s,e,1)
#define ll long long
#define PQ priority_queue
#define pb push_back
#define ppb pop_back()
#define pp push
#define MIN(v) *min_element(v.begin(),v.end())
#define MAX(v) *max_element(v.begin(),v.end())
#define SORT(v) sort(v.begin(),v.end())
#define TROS(v) sort(v.rbegin(),v.rend())
#define CNT(v,x) count(v.begin(),v.end(),x)

using namespace std;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,x,t;
	cin>>n>>x>>t;
	cout<<t*((n-1)/x+1);
}

Measured memory_bytes: 3632
#include <iostream>
#include <deque>
#include <algorithm>

using namespace std;

int main(){
	deque<int> Mt_meter;
	for(int i = 0;i < 10;i++){
		int meter;
		cin >> meter;
		Mt_meter.push_front(meter);
	}
	sort(Mt_meter.rbegin(),Mt_meter.rend());
	for(int i = 0;i < 3;i++){
		cout << Mt_meter[i] << endl;
	}

	return 0;
}

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

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

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

	ll s;
	cin >> s;

	ll t = floor(sqrt(ld(s)));
	while ((t+1)*(t+1) <= s)
		t++;
	while (t*t > s)
		t--;

	ll a, b, x, y;

	if (s == t*t) {
		a = b = t;
		x = y = 0;
	} else if (s < t*t+t) {
		a = t;
		b = t+1;
		x = 1;
		y = t*t+t-s;
	} else {
		a = t+1;
		b = t+1;
		x = 1;
		y = (t+1)*(t+1) - s;
	}

	cout << "0 0 " << x << ' ' << a << ' ' << b << ' ' << y << '\n';
}

Measured memory_bytes: 384
import numpy as np
n = int(input())
x = list(map(int, input().split()))

x = np.array(x)

d = x - int(np.mean(x))
a = np.sum(d ** 2)

d = x - int(np.mean(x)) - 1
b = np.sum(d ** 2)


print(min(a, b))

Measured memory_bytes: 21664
#include<bits/stdc++.h>
using namespace std;
int n,l[110],ans=0;
int main()
{
	cin>>n;
	for (int i=1;i<=n;i++) cin>>l[i];
	for (int i=1;i<=n-2;i++) for (int j=i+1;j<=n-1;j++) for (int k=j+1;k<=n;k++) if (l[i]!=l[j]&&l[j]!=l[k]&&l[i]!=l[k]&&l[i]+l[j]>l[k]&&l[i]+l[k]>l[j]&&l[k]+l[j]>l[i]) ans++;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <string>
#include <list>
#include <algorithm>

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef list<ll> listl;
typedef string str;

#define min(A, B) min(static_cast<ll>(A), static_cast<ll>(B))
#define max(A, B) max(static_cast<ll>(A), static_cast<ll>(B))

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

void in(ll& I)
{
	cin >> I;
}

void in(vl& I)
{
	for (auto& i : I)
	{
		cin >> i;
	}
}

void in(listl& I)
{
	for (auto& i : I)
	{
		cin >> i;
	}
}

void in(str& s)
{
	cin >> s;
}

void out(ll O)
{
	cout << O;
}

void out(vl& O)
{
	for (auto& o : O)
	{
		cout << o;
	}
}

bool comp(const pair<ll, ll> lh, const pair<ll, ll> rh)
{
	return lh.first < rh.first;
}

int main()
{
	ll N;
	ll L;
	in(N);
	in(L);
	
	list<pair<ll,ll>> List;

	ll Max = 0;

	for (int i = 1; i <= N; i++)
	{
		Max += L + i - 1;
		List.push_back(make_pair(abs(L + i - 1), i));
	}

	List.sort(comp);

	ll n = List.begin()->second;

	Max -= L + n - 1;

	out(Max);

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>

int main(){
	char b[10], a[3][3];
	while(~scanf("%9s\n", b)){
		char r = 0;
		for(int i = 0; i < 9; i++)
			a[i%3][i/3] = b[i];
		for(int i = 0, j, f; i < 3; i++){
			if(a[i][0] == 's') continue;
			for(j = 0, f = 1; j < 3; j++)
				if(a[i][0] != a[i][j]) f = 0;
			if(f) r = a[i][0];
		}
		for(int i = 0, j, f; i < 3; i++){
			if(a[0][i] == 's') continue;
			for(j = 0, f = 1; j < 3; j++)
				if(a[0][i] != a[j][i]) f = 0;
			if(f) r = a[0][i];
		}
		if(a[0][0] != 's' && a[0][0] == a[1][1] && a[0][0] == a[2][2]) r = a[0][0];
		if(a[2][0] != 's' && a[2][0] == a[1][1] && a[2][0] == a[0][2]) r = a[2][0];
		printf("%c\n", r?r:'d');
	}
	return 0;
}

Measured memory_bytes: 972
#include <bits/stdc++.h>
#include <cstring>
#include <limits>
using namespace std;
#define ll long long int
#define lli long long int
#define fw(i, s, e) for (ll i = s; i < e; ++i)
#define fe(i, s, e) for (ll i = s; i <= e; ++i)
#define fb(i, e, s) for (ll i = e; i >= s; --i)
#define L(T)  \
    ll T;     \
    cin >> T; \
    while (T--)
#define FASTIO                   \
    ios::sync_with_stdio(false); \
    cin.tie(nullptr);            \
    cout.tie(nullptr);
#define mem(a, i) memset(a, i, sizeof(a))
#define ld long double
#define endl "\n"
#define in(P) \
    ll P;     \
    cin >> P;
int main()
{
    FASTIO
    // L(T)
    // {
    // }
    in(l);
    in(r);
    in(d);
    ll cnt = 0;
    fw(i, l, r + 1)
    {
        if (i % d == 0)
        {
            cnt++;
        }
    }
    cout << cnt << endl;

    return 0;
}

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

int main() {
	rep(i, 7) {
		int a, b; cin >> a >> b;
		cout << a - b << endl;
	}
}

Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define rnfor(i,a,b) for(ll (i) = (a) - 1; (i) >= (b); --(i))
#define ll long long
#define mod (1000000007)
#define pf(x) cout << (x) << endl
#define all(x) (x).begin(),(x).end()

ll gcd(ll a,ll b){
    if(a < b)swap(a, b);
    if(b == 0) return a;
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

ll factorial(ll n){
    ll t = 1;
    rep1(i, n)t *= i;
    return t;
}

ll combinations(ll n, ll k) {
    ll r = 1;
    rep1(i, k)r = r * n-- / i;
    return r;
}

int main(){
    int h,w;
    ll ans = 0;
    int x[] = {1,-1,0,0},y[] = {0,0,1,-1};
    cin >> h >> w;
    vector<vector<bool> > g(h + 2,vector<bool>(w + 2,false));
    rep1(i, h)rep1(j, w){
        char s;
        cin >> s;
        if(s == '.'){
            g[i][j] = true;
            ++ans;
        }
    }
    
    queue<pair<int, int>> to,del;
    ll cnt = 1;
    to.push(make_pair(1, 1));
    while (!to.empty()) {
        ++cnt;
        queue<pair<int, int>> from;
        from = to;
        to = del;
        while (!from.empty()) {
            g[from.front().first][from.front().second] = false;
            rep0(i, 4){
                if(g[from.front().first + x[i]][from.front().second + y[i]]){
                    if(from.front().first + x[i] == h && from.front().second + y[i] == w){
                        pf(ans - cnt);
                        return 0;
                    }else{
                        to.push(make_pair(from.front().first + x[i], from.front().second + y[i]));
                        g[from.front().first + x[i]][from.front().second + y[i]] = false;
                    }
                }
            }
            from.pop();
        }
    }
    pf(-1);
    return 0;
}


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

int main ()
{
    double a, b, c, d, e, f, x, y;
    while (scanf("%lf %lf %lf %lf %lf %lf", &a, &b, &c, &d, &e, &f)!=EOF){
        x= (c*e - b*f) / (a*e - b*d);
        y= (a*f - c*d) / (a*e - b*d);
        if (x==0){
            x=abs(x);
        }
            if (y==0){
            y=abs(y);
        }
        printf ("%0.3lf %0.3lf\n", x, y);
    }
    return 0;
}

Measured memory_bytes: 1860
import java.util.*;

class Main{

    public static void main(String[] args){

	Scanner sc = new Scanner(System.in);

	int K = sc.nextInt();

	int X = sc.nextInt();

	for(int i = 0; i<2*K-1; i++){

	if((X-K+i+1)<=1000000 && (X-K+i+1)>=-1000000){

	System.out.println(X-K+i+1);	

   }
  }
 }
}

Measured memory_bytes: 22740
//I have to work harder than anyone else to make it! I’ll never catch up otherwise…
//Don’t worry about what other people think. Hold your head up high and plunge forward.

#include<bits/stdc++.h>
using namespace std;

#define P pair<int,int>
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define str std::string 
#define pb push_back
#define itrt(yo) for(auto x:yo){std::cout<<x<<nl;} 
#define vec(x) std::vector<x> 
#define nl '\n'
#define F first
#define S second
#define ll long long int
#define ALL(x) x.begin(),x.end() 
#define BN(x) x.begin()
#define ED(x) x.end()
#define MAP_traverse(it,x)  for(auto it = BN(x); it!= ED(x); it++)
#define PI 3.14159265358979323846264338327950L
const unsigned int M = 1000000007;

int main(){
	int n; cin>>n;
	int a[n];
	int ans=0;
	for (int i = 0; i < n; i++)
	{
		cin>>a[i];
		while (a[i]%2==0)
		{
			a[i]/=2;
			ans++;
		}
		
	}
	cout<<ans;
	

}

Measured memory_bytes: 3632
# -*- coding: utf-8 -*-
from collections import deque
def inpl(): return tuple(map(int, input().split()))

K = int(input())
visited = [False for _ in range(K)] 
dq = deque([(1, 1)]) # cost, mod

while True:
    c, m = dq.popleft()
    visited[m] = True
    if m == 0:
        print(c)
        break
    else:
        if not visited[(m*10)%K]:
            dq.appendleft((c, (m*10)%K))
        if not visited[(m+1)%K]:
            dq.append((c+1, (m+1)%K))


Measured memory_bytes: 10956
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5;
typedef pair<int,int>pii;
inline void upa(int&a,const int&b){a<b?a=b:0;}
struct atom{
	int mx,mx2;
	inline void ins(int x){if(x>mx)mx2=mx,mx=x;else if(x>mx2)mx2=x;}
	inline int ask(int x){return x==mx?mx2:mx;}
}f[N];
struct edge{
	int to,next;
}e[N*2];
int n,a,b,md[N*2],sz[N*2],h[N],ecnt=1,i,j,al,mn[N];
char s[N];
long long ans=1;
inline void addedge(int x,int y){
	e[++ecnt]=(edge){y,h[x]};h[x]=ecnt;
	e[++ecnt]=(edge){x,h[y]};h[y]=ecnt;
}
void dfs(int u,int fe){
	sz[fe]=s[u]-'0';
	for(int i=h[u];i;i=e[i].next)if(i^fe^1)
		dfs(e[i].to,i),f[u].ins(md[i]+1),sz[fe]+=sz[i];
	md[fe]=f[u].mx;sz[fe^1]=al-sz[fe];
}
void dfs2(int u,int fe){
	for(int i=h[u];i;i=e[i].next)if(i^fe^1)
		md[i^1]=f[u].ask(md[i]+1),f[e[i].to].ins(md[i^1]+1),dfs2(e[i].to,i);
}
inline void solve(int x){
	static pii a[N];int xb=0,i,j,su=s[x]-'0';
	for(i=h[x];i;i=e[i].next)a[++xb]=pii(md[i]+1,i);
	sort(a+1,a+xb+1);
	for(i=1;i<=xb;){
		for(j=i;j<=xb && a[j].first==a[i].first;++j);
		if(su){if(i<xb)ans+=a[i].first-a[i-1].first;else ans+=2-(a[i].first==a[i-1].first+1);}
		for(;i<j;)su+=sz[a[i++].second];
	}
}
int main(){
	scanf("%d",&n);
	for(i=1;i<n;++i)scanf("%d%d",&a,&b),addedge(a,b);
	scanf("%s",s+1);for(i=1;i<=n;++i)al+=s[i]=='1';
	dfs(1,0);dfs2(1,0);
	for(i=1;i<=n;++i)for(j=h[i],mn[i]=s[i]=='1'?0:N;j;j=e[j].next)
		if(sz[e[j].to])mn[i]=min(mn[i],md[e[j].to]+1);
	for(i=1;i<=n;++i)solve(i);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 17664
import java.io.*;
import java.lang.*;
import java.util.*;


public class Main{

public static void main(String[] args) {

            Scanner s = new Scanner(new BufferedInputStream(System.in));
            int N = s.nextInt();
            int W = s.nextInt();
            int[] wg = new int[N];
            int[] v = new int[N];
            long[][] dp = new long[N][W+1];

            for (int i = 0;i < N;i++) {
                wg[i] = s.nextInt();
                v[i] = s.nextInt();
            }

            for (int i = 0;i < N;i++) {
                for (int j = 1;j <= W;j++) {
                    if (i > 0 && j - wg[i] >= 0)
                    dp[i][j] = Math.max(dp[i-1][j],dp[i-1][j-wg[i]]+v[i]);
                    else if (i == 0) {
                        if (j - wg[i] >= 0) {
                            dp[i][j] = v[i];
                        }
                    } else {
                        dp[i][j] = dp[i-1][j];
                    }
                }
            }

            System.out.println(dp[N-1][W]);
        }


}

Measured memory_bytes: 125524
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cmath>
#include <string>

using namespace std;

typedef vector <int> VI;
typedef vector <VI> VVI;
typedef vector <string> VS;
typedef pair<int,int> PII;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair <int, LL> PIL;
typedef vector <PIL> VPIL;


#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define sort(c) sort((c).begin(),(c).end())

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

#define MAX_INT 2147483647

typedef struct Coor{
	int x;
	int y;
	Coor(int cx,int cy){
		x = cx;
		y = cy;
	}
} Coor;

Coor dxy[] = {Coor(1,0), Coor(0,1), Coor(-1,0), Coor(0,-1)};
string field[20];
int dfs(Coor here, Coor lb, Coor ub){
	int result = 0;
	if(field[here.y][here.x] != '#'){
		result++;
		field[here.y][here.x] = '#';
		rep(i,4){
			Coor nxt = Coor(here.x + dxy[i].x, here.y + dxy[i].y);
			if (lb.x <= nxt.x && nxt.x < ub.x && lb.y <= nxt.y && nxt.y < ub.y)
				result += dfs(nxt, lb, ub);
		}
	}
	return result;
}
int main(){
	int W, H;
	while (1){
		cin >> W >> H;
		if (!(W and H)) break; 
		rep(i,H) cin >> field[i];
		rep(i,H) 
			rep(j,W) 
			if (field[i][j] == '@') 
				cout << dfs(Coor(j,i),Coor(0,0),Coor(W,H)) << endl; 
	}
	return 0;
}

Measured memory_bytes: 1232
#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>

using ll = long long int;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

ll l[111];

int main(void){
	int n,i,j,k;
	ll ans = 0ll;
	std::cin >> n;
	for(i=0; i<n; ++i){
		std::cin >> l[i];
	}
	for(i=0; i<n; ++i){
		for(j=0; j<i; ++j){
			if(l[i]==l[j]){
				continue;
			}
			for(k=0; k<j; ++k){
				if(l[i]==l[k] || l[j]==l[k]){
					continue;
				}
				if(l[i] < l[j]+l[k] && l[j] < l[k]+l[i] && l[k] < l[i]+l[j]){
					++ans;
				}
			}
		}
	}
	std::cout << ans << std::endl;
	return 0;
}


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


int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if (max(a,c) > min(b,d)) cout << 0 << endl;
  else cout << min(b,d) - max(a,c) << endl;
 }

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<vector>
#include<deque>
#include<stack>
#include<queue>
#include<string>
#include<iostream>
#include<tuple>
#include<utility>
#include<set>
#include<queue>
#include<iomanip>
#include<iterator>
#include<map>
//#include<chrono>
//cout<<setprecision(12)
//fixed
//#include<random>
using namespace std;
typedef long long int llint;
typedef long double lldo;
const int big=1e8+100000;
const int mod=1e9+7;
const lldo eps=1e-9;
const long double pai=3.141592653589793238462643;
#define mt make_tuple
#define mp make_pair
#define fir first
#define sec second
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define res resize
#define ins insert
#define era erase
#define dme(in) cout<<in<<endl;return 0
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
int main(void){
	int ans=0,n,i;cin>>n;
	while(n--){
		int l,r;cin>>l>>r;
		ans+=1+r-l;
	}
	cout<<ans<<endl;
	return 0;
}

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

int main(){
	int P[102],sortP[102],n,a,b,c,d;
	scanf("%d",&n);
	for(int i=0;i<102;i++)P[i]=1000;
	for(int i=0;i<(n*(n-1))/2;i++){
		scanf("%d%d%d%d",&a,&b,&c,&d);
		if(c>d)P[a]-=3;
		if(c==d){P[a]--; P[b]--;}
		if(c<d)P[b]-=3;
	}
	for(int i=0;i<102;i++)sortP[i]=P[i];
	sort(sortP,sortP+102);
	for(int i=1;i<n+1;i++){
		for(int j=0;;j++){
			if(P[i]==sortP[j]){
				printf("%d\n",j+1);
				break;
			}
		}
	}
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 10000000000000000



int main(){
	
	long long H,W;
	cin>>H>>W;
	
	if(H==1||W==1){
		cout<<1<<endl;
		return 0;
	}
	
	long long ans = (H/2)*(W/2);
	
	ans += ((H+1)/2)*((W+1)/2);
	
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 256
(defn formula [ X Y x y]
  (unchecked-add-int (Math/abs (unchecked-subtract-int X x)) (Math/abs (unchecked-subtract-int Y y))))

(def formula (memoize formula))

(defn zero-case [X Y zs]
  (apply min (map (fn [[x y _]] (formula X Y x y)) zs)))

(defn Pyramid [ls]
  (let [{lsn false zs true} (group-by (fn [[_ _ h]] (zero? h)) ls)
        ^const range_it (range (unchecked-int 0) (unchecked-int 101))]
    (first
      (for [X range_it
            Y range_it
            :let [Hs (map (fn [[x y h]] (unchecked-add-int h (formula X Y x y))) lsn)
                  H  (first Hs)]
            :when (and (apply = Hs)
                    (if (nil? zs)
                      (<= 1 H)
                      (>= (zero-case X Y zs) H)))]
        (format "%d %d %d" X Y H)))))

(defn input [N]
  (when-not (zero? N)
    (let [x (unchecked-int (read)) y (unchecked-int (read)) h (unchecked-int (read))]
      (cons [x y h] (input (unchecked-dec-int N))))))

(-> (read) int input Pyramid println) 

Measured memory_bytes: 224740
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mod 1000000007
#define f(i,a,b) for(ll i=a;i<b;i++)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ii pair<ll,ll>
#define vii vector<ii>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define MAX 1e9
 
ll modpow(ll base, ll exp, ll modulus) {base %= modulus;ll result = 1;while (exp > 0) {if (exp & 1) result = (result * base) % modulus;base = (base * base) % modulus;exp >>= 1;}return result;}
const ld pi=acos(-1);


int main(){
    IOS;
    // ll t;cin>>t;
    // while(t--){
    ll k;cin>>k;
    queue<ll>q;
    f(i,1,10){
        q.push(i);
    }
    ll x;
    while(k--){
        x=q.front();
        q.pop();
        if(x%10!=0)q.push(10*x+x%10-1);
        q.push(10*x+x%10);
        if(x%10!=9)q.push(10*x+x%10+1);
    }
    cout<<x<<"\n";
    // }
    return 0;  
} 





Measured memory_bytes: 1792
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

X = INT()

ans = 1
for b in range(1, X+1):
	for p in range(2, 10):
		if b**p <= X:
			ans = max(ans, b**p)
print(ans)


Measured memory_bytes: 5588
import java.util.*;
import java.io.*;
import java.lang.reflect.Array;

import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main{
    static final long mod=1000000007;
//    static int dx[]={-1,0,1,0};
//    static int dy[]={0,-1,0,1};

    public  static void main(String[] args)   throws Exception, IOException{        
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);

        int n=sc.nextInt();
        int m=sc.nextInt();
        char c[] = sc.nextString().toCharArray();
        int d[]=new int [n+1];
        
        for (int i = 2; i <= n; i++) {
			if(c[i-2]=='A' && c[i-1]=='C')d[i]++;
			d[i]+=d[i-1];
		}
        db(d);
        for (int i = 0; i < m; i++) {
			int a=sc.nextInt();
			int b=sc.nextInt();
	        out.println(d[b]-d[a]);			
		}


//        out.println();
        out.flush();
    }



    static boolean validpos(int x,int y,int r, int c){
        return x<r && 0<=x && y<c && 0<=y;
    }

    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }  
}

//class P {
//    int id, d;
//    P(int  id, int d) {
//        this.id=id;
//        this.d=d;
//    }
//}

class P implements Comparable<P>{
    int id,T;
    P(int id, int T) {
        this.id=id;
        this.T=T;
    }
    public int compareTo(P p){
        return id-p.id; //des
    }
}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public int[] nextIntArray(int size) throws IOException{
    	int r[] = new int[size];
    	for (int i = 0; i < size; i++) {
			r[i] = this.nextInt(); 
		}
    	return r;
    }
    public long[] nextLongArray(int size) throws IOException{
    	long r[] = new long[size];
    	for (int i = 0; i < size; i++) {
			r[i] = this.nextLong(); 
		}
    	return r;
    }
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}


Measured memory_bytes: 48204
import java.util.Scanner;
public class Main {
	private static Scanner sc;

	public static void main(String[] args) {
		sc = new Scanner(System.in);
		String input_str = sc.next();
		String before_fix = "2017";
		String after_fix = "2018";
		if(input_str.startsWith(before_fix)) {
			input_str = input_str.replaceFirst(before_fix,after_fix);
		};
		System.out.println(input_str);
	}
}


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

int main()
{
  string s;
  cin >> s;
  if (	 s == "hi"
      || s == "hihi"
      || s == "hihihi"
      || s == "hihihihi"
      || s == "hihihihihi" ) cout << "Yes" << endl;
  else						 cout << "No"  << endl;
}

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

int main() {
    int N;
    cin >> N;
    vector<int> h;
    for(int i = 0; i < N; i++) {
        int val;
        cin >> val;
        h.push_back(val);
    }
    int dp[N];
    dp[0] = 0;
    dp[1] = abs(h[1]- h[0]);
    for(int i = 2; i < N; i++) {
        dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
    }
    cout << dp[N-1] << endl;
    return 0;
}

Measured memory_bytes: 1144