akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vl vector<ll>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvl vector<vector<ll>>
#define print(n) cout<<n<<endl
const int M=100010;
const int inf=1000000007;
const long long INF=1000000000000000007;
using ll=long long;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};


int main(){
	ll h,w,ans=0,cnt=0;
	char c[2020][2020];
	ll dp[2020][2020]={};
	cin>>h>>w;
	rep(i,0,h){
		cnt=0;
		rep(j,0,w){
			cin>>c[i][j];
			if(c[i][j]=='.')cnt++;
			else if(c[i][j]=='#'){
				rep(k,0,cnt)dp[i][j-k-1]+=cnt;
				cnt=0;
			}
			if(j==w-1){
				rep(k,0,cnt)dp[i][j-k]+=cnt;
				cnt=0;
			}
		}
	}
	
	rep(j,0,w){
		cnt=0;
		rep(i,0,h){
			if(c[i][j]=='.')cnt++;
			if(c[i][j]=='#'){
				rep(k,0,cnt){
					dp[i-k-1][j]+=cnt;
				}
				cnt=0;
			}if(i==h-1){
				rep(k,0,cnt){
					dp[i-k][j]+=cnt;
				}
				cnt=0;
			}	
		}
	}
	rep(i,0,h)rep(j,0,w)if(dp[i][j]!=0)ans=max(ans,dp[i][j]-1);
//	rep(i,0,h){
//		rep(j,0,w)cout<<dp[i][j]<<" ";
//		cout<<endl;
//	}
	print(ans);
}

Measured memory_bytes: 36096
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  auto a = {2,3,5,7};
  for(int i = 1; i <= 9; ++i){
    if(N % i == 0 && (N/i) < 10){ cout << "Yes"; return 0;}
  }
  cout << "No";
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <string.h>
#include <vector>

using namespace std;

namespace {

class Dictionary {
 private:
  struct Node {
    Node* a;
    Node* c;
    Node* g;
    Node* t;
    char flags[4];

    Node() : a(NULL), c(NULL), g(NULL), t(NULL) {
      flags[0] = 0;
      flags[1] = 0;
      flags[2] = 0;
      flags[3] = 0;
    }
  };

 public:
  Dictionary()
      : root_(new Node),
        block_size_(4096),
        pool_index_(0),
        block_index_(0) {
    pool_.push_back(new Node[block_size_]);
  }

  ~Dictionary() {
    for (size_t i = 0; i < pool_.size(); ++i) {
      delete[] pool_[i];
    }
    delete root_;
  }

  void insert(const char* k, size_t n) {
    Node* p = root_;
    int id = 0;
    for (size_t i = 0; i < n; ++i) {
      const char c = k[i];
      switch (c) {
        case 'A':
          if (!p->a) {
            p->a = Alloc();
          }
          p = p->a;
          id = 0;
          break;
        case 'C':
          if (!p->c) {
            p->c = Alloc();
          }
          p = p->c;
          id = 1;
          break;
        case 'G':
          if (!p->g) {
            p->g = Alloc();
          }
          p = p->g;
          id = 2;
          break;
        case 'T':
          if (!p->t) {
            p->t = Alloc();
          }
          p = p->t;
          id = 3;
          break;
      }
    }
    p->flags[id] = 1;
  }

  bool find(const char* k, size_t n) {
    Node* p = root_;
    int id = 0;
    for (size_t i = 0; i < n; ++i) {
      const char c = k[i];
      switch (c) {
        case 'A':
          p = p->a;
          id = 0;
          break;
        case 'C':
          p = p->c;
          id = 1;
          break;
        case 'G':
          p = p->g;
          id = 2;
          break;
        case 'T':
          p = p->t;
          id = 3;
          break;
      }
      if (!p) {
        return false;
      }
    }
    if (!p) {
      return false;
    }
    return p->flags[id];
  }

 private:
  Node* root_;

  Node* Alloc() {
    if (block_index_ >= block_size_) {
      pool_.push_back(new Node[block_size_]);
      pool_index_++;
      block_index_ = 0;
    }
    Node* r = &pool_[pool_index_][block_index_];
    block_index_++;
    return r;
  }

  size_t block_size_;
  size_t pool_index_; // pos in pool
  size_t block_index_; // pos in the block
  vector<Node* > pool_;
};

} // namespace

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

  Dictionary d;
  char op[7];
  char str[13];
  for (int i = 0; i < n; ++i) {
    scanf("%s ", op);
    scanf("%s", str);
    const char c = op[0];
    const size_t len = strnlen(str, 13);
    if (c == 'i') {
      d.insert(str, len);
      continue;
    }

    if (d.find(str, len)) {
      printf("yes\n");
    } else {
      printf("no\n");
    }
  }

  return 0;
}

Measured memory_bytes: 14808
using System;
using System.Linq;
using System.Collections.Generic;

namespace d
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var s = Console.ReadLine().ToCharArray();

            var r = 0L;
            var g = 0L;
            var b = 0L;
            for(var i = 0; i < n; i++){
                if(s[i] == 'R'){
                    r++;
                }else if(s[i] == 'G'){
                    g++;
                }else if(s[i] == 'B'){
                    b++;
                }
            }
            var total = r * g * b;

            var count = 0L;
            for(var i = 0; i < n; i++){
                for(var j = i + 1; j < n; j++){
                    if(s[i] != s[j]){
                        var k = j * 2 - i; // j - i == k - jを変形
                        if(k < n && s[i] != s[k] && s[j] != s[k]){
                            count++;
                        }
                    }
                }
            }

            Console.WriteLine(total - count);
        }
    }
}


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

int main(){
  int n, m;
  int dp[50001];
  int c[20];

  //??\???
  cin >> n >> m;
  for(int i = 0; i < m; i++) cin >> c[i];

  //dp?????????
  memset(dp, 0, sizeof(dp));
  for(int i = 0; i <= n; i++) dp[i] = i;

  //???????¨?????????§?§£???
  for(int i = 1; i < m; i++){
    for(int j = 0; j <= n; j++){
      if(j-c[i] >= 0) dp[j] = min(dp[j], dp[j-c[i]]+1);
    }
  }

  cout << dp[n] << endl;

  return 0;
}

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

#define ll long long int

using namespace std;

int main(){
    int a,b;
    cin>>a>>b;
    int ans = a+b;
    ans = max(ans,a-b);
    ans = max(ans,a*b);
    cout<<ans<<'\n';
    return 0 ;
}



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

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

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

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


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

bool solve(){
  int n[2];
  int sum[2] = {};
  int card[2][SIZE];
  
  scanf("%d%d",n+0,n+1);

  if(n[0] == 0){
    return false;
  }
  
  for(int i=0;i<2;i++){
    for(int j=0;j<n[i];j++){
      scanf("%d",card[i]+j);
      sum[i] += card[i][j];
    }
  }

  int ans1 = -1, ans2 = -1, t_sum = INF;

  for(int i=0;i<n[0];i++){
    for(int j=0;j<n[1];j++){

      if(sum[0] - card[0][i] + card[1][j] ==
         sum[1] - card[1][j] + card[0][i]){

        if(t_sum > card[0][i] + card[1][j]){
          t_sum = card[0][i] + card[1][j];
          ans1 = card[0][i];
          ans2 = card[1][j];
        }
      }
      
    }
  }
  
  if(ans1 == -1){
    puts("-1");
  }else{
    printf("%d %d\n",ans1, ans2);
  }

  return true;
}

int main(){

  while(solve());
  
  return 0;
}

Measured memory_bytes: 3084
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <iomanip>
#include <iostream>
#include <limits>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = int64_t;
using ull = uint64_t;

template<typename T>
vector<T> make_vec_nd(T init, size_t size) {
    return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, size_t size, Args... rest) {
    auto inner = make_vec_nd(init, rest...);
    return vector<decltype(inner)>(size, inner);
}

int main() {
    ll N, K;
    cin >> N >> K;
    vector<ll> ais;
    for (ll i = 0; i < N; i++) {
        ll ai;
        cin >> ai;
        ais.push_back(ai);
    }
    vector<bool> dp(K+1);
    for (ll i = 0; i <= K; i++) {
        bool found = false;
        for (ll j = 0; j < N && ais[j] <= i; j++) {
            if (!dp[i - ais[j]]) {
                found = true;
                break;
            }
        }
        dp[i] = found;
    }
    if (dp[K]) {
        cout << "First" << endl;
    } else {
        cout << "Second" << endl;
    }
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#include<algorithm>
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n;
	cin>>n;
	vector<ll>ch,p,q;
	for(ll i=0;i<n;i++){
		ch.push_back(i+1);
	}
	for(ll i=0;i<n;i++){
		ll x;
		cin>>x;
		p.push_back(x);
	}
	for(ll j=0;j<n;j++){
		ll x;
		cin>>x;
		q.push_back(x);
	}
	ll a=0;ll b=0;ll j=0;
	do {
		j++;
		bool ch2=true;
		for(ll i=0;i<n;i++){
			if(ch[i]!=p[i]){
				ch2=false;
			}
		}
		if(ch2){
			a=j;
		}
    } while (std::next_permutation(ch.begin(), ch.end()));
    j=0;
	do {
		j++;
		bool ch2=true;
		for(ll i=0;i<n;i++){
			if(ch[i]!=q[i]){
				ch2=false;
			}
		}
		if(ch2){
			b=j;
		}
    } while (std::next_permutation(ch.begin(), ch.end()));	 
    cout << abs(a-b);
	// your code goes here
	return 0;
}

Measured memory_bytes: 3616
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

//numberが素数ならば1，そうでなければ0を返す関数
int primality(int number);

int main(void){
  int N;
  int i, j, k;
  int count = 0;

  scanf("%d", &N);

  for(i = 3; i <= N; i++){
    if(primality(i) == 1){
      if(((double) i) <= pow((double) N, 1.0/7.0)){
        count++;
      }
    }
  }

  for(i = 3; i <= N; i++){
    for(j = i+1; j <= N; j++){
      if(primality(i) == 1 && primality(j) == 1){
        if((i*j*j*j) <= N){
          count++;
        }
        if((i*i*i*j) <= N){
          count++;
        }
      }
    }
  }

  for(i = 3; i <= N; i++){
    for(j = i+1; j <= N; j++){
      for(k = j+1; k <= N; k++){
        if(primality(i) == 1 && primality(j) == 1 && primality(k) == 1){
          if((i*j*k) <= N){
            count++;
          }
        }
      }
    }
  }

  printf("%d\n", count);
  return 0;
}

int primality(int number){
  int i;

  if(number <= 1){
    return 0;
  }
  else{
    for(i = 2; i < number; i++){
      if(number%i == 0){
        return 0;
      }
    }
    return 1;
  }
}


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

using namespace std;

int main()
{
	vector<int> cooking_time(5);
	for (int i = 0; i < 5; i++)
	{
		cin >> cooking_time.at(i);
	}

	int ans = INT_MAX;
	vector<int> p = { 0,1,2,3,4 };
	do
	{
		int tmp = 0;
		for (int i = 0; i < p.size(); i++)
		{
			while (tmp % 10 != 0)
			{
				tmp++;
			}
			tmp += cooking_time.at(p.at(i));
		}
		ans = min(ans, tmp);
	} while (next_permutation(p.begin(), p.end()));

	cout << ans << endl;
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define fs first
#define fst first
#define sc second
#define snd second
#define sz(X) (int)(X).size()
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define fornr(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define forab(i, a, b) for(int i = int(a); i < int(b); i++)
#define all(X) X.begin(), X.end()

typedef long long ll;
typedef pair<int, int> pii;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef double dbl;
typedef long double ld;
typedef vector<int> vi;

const int N = 1e5;
const int LOG = 61;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LLMOD = 1e9 + 7;
const ll LLINF = 1e16;

ll dp[N][13];

void add(ll &a, ll b) {
    a += b;
    if (a > LLMOD) a -= LLMOD;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string s;
    cin >> s;
    int n = sz(s);
    if (s[0] == '?') forn(i, 10) dp[0][i] = 1;
    else dp[0][s[0] - '0'] = 1;
    forab(i, 1, n) {
        if (s[i] == '?') {
            forn(j, 10) {
                forn(k, 13) add(dp[i][(j + k*10) % 13], dp[i - 1][k]);
            }
        } else {
            int num = s[i] - '0';
            forn(j, 13) add(dp[i][(j * 10 + num) % 13], dp[i - 1][j]);
        }

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


Measured memory_bytes: 10604
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define P pair<int, int>
#define debug(x) cout << #x << ": " << x << ", "
#define debugln(x) cout << #x << ": " << x << '\n'

using namespace std;
using ll = long long;
const int mod = 1e9+7;

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

  vector<int> a(3);
  cin >> a.at(0) >> a.at(1) >> a.at(2);
  sort(a.begin(), a.end());

  cout << a.at(0) + a.at(1) + (10*a.at(2)) << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
int main()
{
   long long n;
   while(scanf("%lld",&n)!=EOF)
   {  long long sum=0;
       for(int i=1;i<=n;i++)
       {
           sum=sum+i;
       }
   printf("%lld\n",sum);
   }
}


Measured memory_bytes: 256
function knapsack(){
   var C=[];
   for(var i=0;i<=N;i++)C[i]=[];
   for(var i=0;i<=W;i++)C[0][i]=0;
   for(var i=0;i<=N;i++)C[i][0]=0;
   for(var i=1;i<=N;i++){
      for(var j=1;j<=W;j++){
         var ww=items[i].w;
         var vv=items[i].v;
         if(ww<=W){
            if(Math.max(C[i-1][j],vv+C[i-1][j-ww],vv+C[i][j-ww])>C[i-1][j]){
               C[i][j]=Math.max(C[i-1][j],vv+C[i-1][j-ww],vv+C[i][j-ww]);
            }else{
               C[i][j]=C[i-1][j];
            }
         }else{
            C[i][j]=C[i-1][j];
         } 
      }  
   }
   return C[N][W];
}   
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
var NW=(Arr.shift()).split(" ").map(Number);
var N=NW[0];
var W=NW[1];
var items=[null];
for(var i=1;i<=N;i++){
   var arr=(Arr.shift()).split(" ").map(Number);
   items[i]={v:arr[0], w:arr[1]};
}
var max=knapsack();
console.log(max);

Measured memory_bytes: 31784
#include<bits/stdc++.h>
#include <unistd.h>
using namespace std;
#define nl cout<<"\n"
#define endl '\n'
#define pb push_back
#define se second
#define fi first
#define int long long 
#define pi pair<int,int>
#define vpi vector<pi>
#define vvpi vector<vpi>
#define fio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define For(i,n) for(int i=0;i<n;i++)
#define Forn(i,a,n) for(int i=a;i<n;i++)
#define pie =3.14159265358979323846264338327950;
const int mod= 998244353;


void solve(){
	fio;
	string s,t;
	cin>>s>>t;
	int n=s.length();
	int ans=INT_MAX;
	for(int i=0;i<=n-t.length();i++){
		int cnt=0;
		for(int j=0;j<t.length();j++){
			if(s[i+j]!=t[j]){
				cnt++;
			}
		}
		ans=min(ans,cnt);
	}
	cout<<ans<<endl;
}

int32_t main(){
	fio;
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int t=1;
	//cin>>t;
	for(int i=1;i<=t;i++){ 
		//cout<<"Case #"<<i<<": ";
		solve();
	}
	return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() 
{  
    int sum=0;
    int mn=1e9;
    int n,total;
    cin>>n>>total;
    for(int i=0; i<n; i++)
    {
        int x;
        cin>>x;
        sum+=x;
        mn=min(mn,x);
    }
    cout<<n+max(0,(total-sum)/mn)<<endl;
    
	return 0;
}

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

int main() {
	long int r,d,x[2011];
	cin >> r >> d >> x[2000];
	for(int i=0;i<10;i++){
		x[2000+i+1] = x[2000+i] * r - d;
		cout << x[2000+i+1] << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#define debug(x) cerr << #x << ':' << x << '\n'
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
constexpr int inf = 1000000010;
constexpr ll INF = 1000000000000000010;
constexpr ld eps = 1e-12;
constexpr ld pi = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }

ll modpow(ll a, ll b, ll mod) {
	ll ans = 1;
	a %= mod;
	while (b) {
		if (b & 1) ans = ans * a % mod;
		a = a * a % mod;
		b >>= 1;
	}
	return ans;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);

	ll n;
	cin >> n;
	string s;
	cin >> s;
	ll one = 0;
	rep(i, n) if (s[i] == '1') one++;
	ll x = 0, y = 0; ll basex = 1, basey = 1;
	for (int i = s.size() - 1; i >= 0; i--) {
		if (s[i] == '1') {
			x += basex;
			y += basey;
		}
		if (one >= 2) { basex <<= 1; basex %= (one - 1); }
		basey <<= 1; basey %= (one + 1);
	}
	vector<int> dp(200010);
	rep(i, n + 5) {
		if (i == 0) continue;
		int pcnt = 0;
		rep(j, 30) {
			if ((i >> j) & 1) pcnt++;
		}
		dp[i] = dp[i % pcnt] + 1;
	}
	vector<int> ans(n);
	rep(i, n) {
		int d = n - 1 - i;
		if (s[i] == '0') {
			ll val = y + modpow(2, d, one + 1);
			val %= one + 1;
			ans[i] = dp[val] + 1;
		}
		else {
			if (one == 1) ans[i] = 0;
			else {
				ll val = x - modpow(2, d, one - 1);
				val %= one - 1;
				if (val < 0) val += one - 1;
				ans[i] = dp[val] + 1;
			}
		}
	}
	rep(i, n) cout << ans[i] << '\n';
}

Measured memory_bytes: 5188
#include<stdio.h>
#include<string.h>
#include<math.h>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define SWAP(a,b) {a+=b;b=a-b;a-=b;}

ll t1[102][2], t2[102][2], t3[102][2], t4[102][2];
/*main内に入れるとスタック領域から溢れる。*/

int main(){
	ll N,W,wi,vi,w1 = -1;
	ll maxv = 0;
	int t1n = 0,t2n = 0,t3n = 0,t4n = 0;

	//input
	scanf("%lld %lld",&N,&W);

	FOR(i,0,N){
		scanf("%lld %lld",&wi,&vi);
		if(w1 == -1) w1 = wi;

		if(wi == w1)	{ t1[t1n][0] = wi; t1[t1n][1] = vi; t1n++; }
		if(wi == w1 + 1){ t2[t2n][0] = wi; t2[t2n][1] = vi; t2n++; }
		if(wi == w1 + 2){ t3[t3n][0] = wi; t3[t3n][1] = vi; t3n++; }
		if(wi == w1 + 3){ t4[t4n][0] = wi; t4[t4n][1] = vi; t4n++; }
	}

	//価値0も加える
	t1[t1n][0] = w1; 		t1[t1n][1] = 0; t1n++;
	t2[t1n][0] = w1 + 1; 	t2[t1n][1] = 0; t2n++;
	t3[t1n][0] = w1 + 2; 	t3[t1n][1] = 0; t3n++;
	t4[t1n][0] = w1 + 3; 	t4[t1n][1] = 0; t4n++;

	//価値の大きい順にソート
	FOR(i,0,t1n-1){
		FOR(j,i+1,t1n){
			if(t1[i][1] < t1[j][1]) SWAP(t1[i][1],t1[j][1]);
		}
	}
	FOR(i,0,t2n-1){
		FOR(j,i+1,t2n){
			if(t2[i][1] < t2[j][1]) SWAP(t2[i][1],t2[j][1]);
		}
	}
	FOR(i,0,t3n-1){
		FOR(j,i+1,t3n){
			if(t3[i][1] < t3[j][1]) SWAP(t3[i][1],t3[j][1]);
		}
	}
	FOR(i,0,t4n-1){
		FOR(j,i+1,t4n){
			if(t4[i][1] < t4[j][1]) SWAP(t4[i][1],t4[j][1]);
		}
	}

	//t1~t4それぞれから入れる数を決定
	ll tw = 0, tv= 0;

	FOR(i,0,t1n){
		FOR(j,0,t2n){
			FOR(k,0,t3n){
				FOR(l,0,t4n){

					tw = w1*i + (w1+1)*j + (w1+2)*k + (w1+3)*l;
					if(tw <= W){
						FOR(m,0,i) tv += t1[m][1];
						FOR(m,0,j) tv += t2[m][1];
						FOR(m,0,k) tv += t3[m][1];
						FOR(m,0,l) tv += t4[m][1];
						if(tv > maxv) maxv = tv;
					}
					tw = 0; tv = 0;

				}
			}
		}
	}

	//出力
	printf("%lld\n",maxv);
	return 0;
}

Measured memory_bytes: 128
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define mp make_pair
#define ALL(obj) (obj).begin(),(obj).end()
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n) 
#define SIZE(x) ((int)(x).size())
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef pair<int, int> pint;
typedef pair<lint, lint> plint;
typedef vector<lint> vec;
typedef vector<vector<lint>> matrix;
typedef priority_queue<lint> p_que;
typedef priority_queue<lint, vector<lint>, greater<lint>> p_que_rev;
const lint INF = INT_MAX;
const lint LINF = LLONG_MAX;
const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};

lint gcd(lint a, lint b) {
    lint r;
    while (b != 0) {
        r = a % b;
        a = b; 
        b = r;
    }
    return a;
}

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

lint power(lint x, lint n, lint mod = MOD) {
    lint ret = 1;
    while(n > 0) {
        if(n & 1){
            (ret *= x) %= mod;
        }
        (x *= x) %= mod;
        n >>= 1;
    }
    return ret;
}

vector<lint> make_power(int n, lint base){
    lint num = 1;
    vector<lint> ret;
    for (int i=0; i<=n; ++i){
        ret.push_back(num);
        num *= base;
    }
    return ret;
}

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<lint> a(n);
    REP(i, n){
        cin >> a[i];
    }
    lint sum1 = 0;
    lint sum2 = 0;
    lint ans1 = 0;
    lint ans2 = 0;
    for (int i=0; i<n; ++i){
        sum1 += a[i];
        sum2 += a[i];
        if(i % 2 == 1 && sum1 >= 0){
            ans1 += abs(-1 - sum1);
            sum1 = -1;
        }
        else if(i % 2 == 0 && sum1 <= 0){
            ans1 += abs(1 - sum1);
            sum1 = 1;
        }
        if(i % 2 == 0 && sum2 >= 0){
            ans2 += abs(-1 - sum2);
            sum2 = -1;
        }
        else if(i % 2 == 1 && sum2 <= 0){
            ans2 += abs(1 - sum2);
            sum2 = 1;
        }
    }
    cout << min(ans1, ans2) << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;

ll dp[10002][2][100];

int main() {
    string s;
    int d, n;
    cin >> s >> d;
    int sn = s.length();

    dp[0][1][0] = 1;
    for(int i=0;i<sn;++i) {
        n = s[i] - '0';
        for(int j=0;j<d;++j) {
            if(dp[i][0][j]) {
                for(int k=0;k<10;++k) {
                    dp[i+1][0][(j+k)%d] += dp[i][0][j];
                    dp[i+1][0][(j+k)%d] %= MOD;
                }
            }
            if(dp[i][1][j]) {
                for(int k=0;k<n;++k) {
                    dp[i+1][0][(j+k)%d] += dp[i][1][j];
                    dp[i+1][0][(j+k)%d] %= MOD;
                }
                dp[i+1][1][(j+n)%d] += dp[i][1][j];
                dp[i+1][1][(j+n)%d] %= MOD;
            }
        }
    }

    cout << (dp[sn][0][0] + dp[sn][1][0] + MOD - 1) % MOD << "\n";
}

Measured memory_bytes: 15872
def main():
    import sys
    input = sys.stdin.buffer.readline
    N, M = (int(i) for i in input().split())
    edge = [[] for _ in range(N)]
    deg = [0]*N
    for _ in range(N-1+M):
        a, b = (int(i)-1 for i in input().split())
        edge[a].append(b)
        deg[b] += 1  # 入次数
    from collections import deque
    que = deque()

    ans = []
    for i in range(N):
        if deg[i] == 0:
            que.append(i)  # root
            ans.append((i, 0))
    # print(que)
    while que:
        u = que.popleft()
        # print(u, ":", edge[u])
        for v in edge[u]:
            deg[v] -= 1
            if deg[v] == 0:
                que.append(v)
                ans.append((v, u + 1))
    ans.sort()
    ans = [p[1] for p in ans]
    print(*ans, sep="\n")


if __name__ == '__main__':
    main()


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

int main() {
  int N, D = 0;
  cin >> N;
  vector<int> V(N), C(N);
  for (int i = 0; i < N; i++) {
    cin >> V[i];
  }
  for (int i = 0; i < N; i++) {
    cin >> C[i];
  }
  for (int i = 0; i < N; i++) {
    D += max(V[i] - C[i], 0);
  }
  cout << D << endl;
  return 0;
}


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

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

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

    int S = 0;
    for(int i = 0; i < n; i++){
        S ^= A[i];
    }

    for(int i = 0; i < n; i++){
        cout << (S ^ A[i]) << ' ';
    }
    cout << endl;

    return 0;
}

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

using namespace std;
#define int long long
set<int> st;

bool divisors(int x) {
    for(int i = 1; i * i <= x; i++) {
        if(x % i == 0) {
            if(x / i == i) {
                if(st.count(i)) return false;
            } else {
                if(st.count(i) || st.count(x / i)) return false;
            }
        }
    }
    return true;
}

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);

    int n;
    cin >> n;
    vector<int> v(n);
    map<int, int> cnt2;
    for(int i = 0; i < n; i++) {
        cin >> v[i];
        cnt2[v[i]]++;
    }
    sort(v.begin(), v.end());
    int cnt = 0;
    for(int i = 0; i < n; i++) { 
        if(cnt2[v[i]] > 1) {
            st.insert(v[i]);
            continue;
        }
        bool lol = divisors(v[i]);
        st.insert(v[i]);
        if(lol) {
            cnt++;
        }
    }
    cout << cnt << "\n";

    return 0;
}


Measured memory_bytes: 26688
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int n,d,x;
	int ans=0;
	cin >>n>>d>>x;
	Vi a(n);
	rep(i,n){
		cin>>a[i];
	}
	rep(i,n){
		ans+=(d+a[i]-1)/a[i];
	}
	cout<<ans+x<<endl;
}

Measured memory_bytes: 3624
K = int(input())
L = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

print(L[K-1])

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main () {
  int N;
  cin >> N;
  vector<long> data(N, 100001);
  long a;
  for(int i = 0; i < N - 1; i++){
    cin >> a;
    data.at(i) = min(a, data.at(i));
    data.at(i + 1) = min(a, data.at(i + 1));
  }
  long sum = 0;
  for(int i = 0; i < N; i++)sum += data.at(i);
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 256
import java.io.PrintWriter

fun main(args: Array<String>) {
    PrintWriter(System.out).use { out ->
        solve(out)
        out.flush()
    }
}

fun solve(out: PrintWriter) {
    val s = readLine()!!
    for (i in s.indices) {
        if (s[i] != s[s.length - 1 - i]) {
            println("No")
            return
        }
    }
    
    val last = ((s.length - 1) / 2)
    for (i in 0 until last) {
        if (s[i] != s[last - 1 - i]) {
            println("No")
            return
        }
    }
    
    val first = ((s.length + 3) / 2)
    for (i in first until s.length) {
        if (s[i] != s[s.length - 1 - i]) {
            println("No")
            return
        }
    }
    println("Yes")
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)
fun readDoubleList() = readStringList().map(String::toDouble)


Measured memory_bytes: 33500
#include <bits/stdc++.h>
#define rep2(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) rep2(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
using namespace std;
using ll = long long;
template <typename T>
T sq(T x) {
  return x * x;
}

signed main() {
  int n;
  cin >> n;
  cout << (int)sqrt(n) * (int)sqrt(n) << endl;
  return 0;
}


Measured memory_bytes: 3684
#include <algorithm>
#include <iostream>
#include <map>
#include <string>
#include <vector>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

int main() {
  std::string c[2];

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

  std::reverse(c[0].begin(), c[0].end());

  if (c[0] == c[1]) {
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }

  return 0;
}


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

int main(){
    int n,m;
    cin >> n >> m;
    vector<vector<long long>> value(n, vector<long long>(3));
    for (int i = 0; i<n; i++){
        cin >> value[i][0] >> value[i][1] >> value[i][2];
    }
    long long ans = 0;
    long long pss;
    vector<long long> tmp(n);
    vector<vector<int>> d = {{1, 1, 1}, {1, 1, -1}, {1, -1, 1}, {1, -1, -1}, {-1, 1, 1}, {-1, 1, -1}, {-1, -1, 1}, {-1, -1, -1}};
    for (int i = 0; i<8; i++){
        for (int j = 0; j<n; j++){
            tmp[j] = d[i][0]*value[j][0] + d[i][1]*value[j][1] + d[i][2]*value[j][2];
        }
        sort(tmp.begin(), tmp.end(), greater<long long>());
        pss = 0;
        for (int k = 0; k<m; k++){
            pss += tmp[k];
        }
        ans = max(ans, pss);
    }
    cout << ans << endl;
}




Measured memory_bytes: 256
from bisect import*
(N,),A,B,C=[sorted(map(int,input().split()))for _ in range(4)]
w,i=[0]*(N+1),N
while i:i-=1;w[i]=w[i+1]+N-bisect(C,B[i])
print(sum(w[bisect(B,a)]for a in A))

Measured memory_bytes: 22720
#include<stdio.h>
int gcd(int a, int b) {
  if (a == 0) return b; else return gcd(b % a, a);
}
int main() {
  int a, b;
  long m, n;
  while (scanf("%d %d", &a, &b) != EOF) {
    m = (long) gcd(a, b); n = a / m * b;
    printf("%ld %ld\n", m, n);
  }
  return 0;
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

typedef pair<ll, ll> P;

vector<P> ops;

ll solve(vector<ll> A) {
  int N = A.size();
  ll res = 0;
  REP(i, N) res += abs(A[i]);
  vector<ll> zero, pos, neg;
  REP(i, N) {
    if (A[i] == 0) zero.push_back(A[i]);
    else if (A[i] > 0) pos.push_back(A[i]);
    else neg.push_back(A[i]);
  }
  REP(_, N-1) {
    if (zero.size() >= 2) {
      zero.pop_back();
      ops.push_back({0, 0});
    } else if (zero.size() == 1 && pos.size() > 0) {
      ll m1 = pos.back(); pos.pop_back();
      zero.pop_back();
      if (_ == N-2) ops.push_back({m1, 0}); else ops.push_back({0, m1});
      neg.push_back(-m1);
    } else if (zero.size() == 1 && neg.size() > 0) {
      ll m1 = neg.back(); neg.pop_back();
      zero.pop_back();
      ops.push_back({0, m1});
      pos.push_back(-m1);
    } else {
      ll m1 = neg.back(); neg.pop_back();
      ll m2 = pos.back(); pos.pop_back();
      if (pos.size() <= neg.size()) {
        ops.push_back({m2, m1});
        pos.push_back(m2 - m1);
      } else {
        ops.push_back({m1, m2});
        neg.push_back(m1 - m2);
      }
    }
  }
  return res;
}

int main2() {
  ops.clear();

  int N = nextInt();
  vector<ll> A(N);
  REP(i, N) A[i] = nextInt();
  sort(ALL(A));
  ll res = 0;
  if (A[0] * A.back() <= 0) {
    res = solve(A);
  } else if (A[0] < 0) {
    ll m1 = A[N-1];
    ll m2 = A[N-2];
    A.pop_back();
    A.pop_back();
    A.push_back(m1 - m2);
    ops.push_back({m1, m2});
    res = solve(A);
  } else {
    ll m1 = A[0];
    ll m2 = A[1];
    A.erase(A.begin());
    ops.push_back({m1, m2});
    A[0] = (m1 - m2);
    res = solve(A);
  }
  cout << res << endl;
  REP(i, ops.size()) {
    cout << ops[i].first << " " << ops[i].second << endl;
  }

  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}


Measured memory_bytes: 5748
#include<bits/stdc++.h>
using namespace std;
int main(){
  int X,Y;
  cin>>X>>Y;
  for(int i=0;i<=X;i++){
    int t=X-i;
    int asi=i*2+t*4;
    if(asi==Y){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
using namespace std;
#define int long long

int sqrtb(int a) {
	int l = 1, u = (int)2e+9;
	while(u - l > 1) {
		int c = (l + u) / 2;
		if (c * c <= a) {
			l = c;
		} else {
			u = c;
		}
		// cout << l << "," << u << endl;
	}
	return l;
}

signed main(){
	int Q;
	cin >> Q;
	for(int i = 0; i < Q; ++i) {
		int A, B;
		cin >> A >> B;
		if(A > B) swap(A,B);
		if(B == 1) {
			cout << 0 << endl;
			continue;
		}
		int M = A * B - 1;
		int L = (int)sqrtb(M);
		// cout << L * L << "," << M << "," << (L + 1) * (L + 1);
		// cerr << L << "," << sqrt(M) << endl;
		int t = 2 * L - (M / L == L);
		if(A <= L) {
			--t;
		}
		cout << t << endl;
	}
	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.*;

class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(in, out);
        out.close();
    }

    static class Task {
        long A, B, C, K;

        void solve(InputReader in, PrintWriter out) {
            A = in.nextLong();
            B = in.nextLong();
            C = in.nextLong();
            K = in.nextLong();
            out.println(K % 2 == 0 ? A - B : B - A);
        }
    }

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            tokenizer = null;
        }

        String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        int nextInt() { return Integer.parseInt(next()); }

        long nextLong() { return Long.parseLong(next()); }

        int[] nextIntArray(int n) {
        	int[] arr = new int[n];
        	for (int i = 0; i < n; ++i) {
        		arr[i] = nextInt();
        	}
        	return arr;
        }
    }
}


Measured memory_bytes: 21332
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int h,a;
	cin>>h>>a;
	int ans=h/a;
	if(h%a==0)
		cout<<ans;
	else
	cout<<ans+1<<endl;
//	for(int i=0;i<n;i++)
//	{
//		
//	}
}

Measured memory_bytes: 256
from itertools import permutations

k = int(input())
r = [0] * k; c = [0] * k;
for i in range(k):
    r[i], c[i] = [int(a) for a in input().split()]

r_avail = list(range(8))
c_avail = list(range(8))

for i in range(k):
    r_avail.remove(r[i])
    c_avail.remove(c[i])

cperms = list(permutations(c_avail, 8 - k))

for perm in cperms:
    Q = [(r[i], c[i]) for i in range(k)] + list(zip(r_avail, perm))
    for a in range(8):
        for b in range(a + 1, 8):
            rdiff = Q[a][0] - Q[b][0]
            cdiff = Q[a][1] - Q[b][1]
            if abs(rdiff) == abs(cdiff):
                break # 斜めの線上にある
        else:
            continue
        break
    else: # 斜めの線上にあるQueenは無い
        break

ans = [['.' for _ in range(8)] for _ in range(8)]
for i in range(8):
    ans[Q[i][0]][Q[i][1]] = 'Q'

for i in range(8):
    print("".join(ans[i]))


Measured memory_bytes: 5736
import bisect
import math
n,d,a=map(int,input().split())
xh=[list(map(int,input().split())) for i in range(n)]
xh.sort()
x=[xh[i][0] for i in range(n)]
h=[xh[i][1] for i in range(n)]
g=[0]*n
cnt=0
for i in range(n):
    #print(h)
    if h[i]>0:
        m=math.ceil(h[i]/a)
        cnt+=m
        k=bisect.bisect_right(x,x[i]+2*d,lo=i)
        if i!=n-1:
            h[i]-=m*a
            g[i]-=m*a
            if k<n:
                g[k]+=m*a
            g[i+1]+=g[i]
            h[i+1]+=g[i+1]
    else:
        if i!=n-1:
            g[i+1]+=g[i]
            h[i+1]+=g[i+1]
print(cnt)


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

#define F first
#define S second
#define FOR(i,a,b) for (int i = (a); i <= (b); ++i)
#define NFOR(i,a,b) for(int i = (a); i >= (b); --i)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
typedef long long ll; typedef pair <int, int> ii; typedef vector <int> vi; const int inf = 1e9 + 7;
#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
template <class T> void dbs(string str, T t) {cout << str << " : " << t << endl;}
template <class T, class... S> void dbs(string str, T t, S... s) {int idx = str.find(','); cout << str.substr(0, idx) << " : " << t << ","; dbs(str.substr(idx + 1), s...);}
template <class S, class T>ostream& operator <<(ostream& os, const pair<S, T>& p) {return os << "(" << p.first << ", " << p.second << ")";}
template <class T>ostream& operator <<(ostream& os, const vector<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const set<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T> void prc(T a, T b) {cout << "["; for (T i = a; i != b; ++i) {if (i != a) cout << ", "; cout << *i;} cout << "]";cout<<endl;}

const int N = 2020;
int a[N][N], b[N][N];

int solve(const vector<int>& A) {
	int n = sz(A);
	vector<int> L(n, -1), R(n, n);
	stack<int> s;
	FOR (i, 0, n - 1) {
		while (!s.empty() and A[s.top()] >= A[i]) s.pop();
		if (!s.empty()) L[i] = s.top();
		s.push(i);
	}
	while (!s.empty()) s.pop();
	NFOR (i, n - 1, 0) {
		while (!s.empty() and A[s.top()] >= A[i]) s.pop();
		if (!s.empty()) R[i] = s.top();
		s.push(i);
	}
	int ans = 0;
	FOR (i, 0, n - 1) {
		ans = max(ans, (R[i] - L[i]) * A[i]);
	}
	return ans;
}

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

	int n, m; cin >> n >> m;
	FOR (i, 0, n - 1) {
		string s; cin >> s;
		FOR (j, 0, m - 1) {
			a[i][j] = s[j] == '.';
		}
	}

	--n;

	FOR (i, 0, n - 1) {
		FOR (j, 0, m - 1) {
			a[i][j] = a[i][j] != a[i + 1][j];
		}
	}

	FOR (i, 0, n - 1) {
		b[i][m - 1] = 1;
		NFOR (j, m - 2, 0) {
			b[i][j] = 1 + ((a[i][j] == a[i][j + 1]) ? b[i][j + 1] : 0);
		}
	}

	int ans = m;

	FOR (j, 0, m - 1) {
		vector<int> A;
		FOR (i, 0, n - 1) {
			A.push_back(b[i][j]);
		}
		ans = max(ans, solve(A));
	}

	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 32000
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <numeric>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
using ll=long long;
#define int ll
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) ((int)x.size())
#define fi first
#define se second
const int INF = 1e15;
using namespace std;

template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;

using pi=pair<int,int>;
using vi=vc<int>;

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

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    double R; cin >> R;
    cout << R*2.0*M_PI << endl;
}

Measured memory_bytes: 3764
import itertools

n,m,r_ = map(int, input().split( ))

r = list(map(int, input().split( )))
for i in range(r_):
  	r[i] -=1
d = [[10**10 for _ in range(n)] for i in range(n)]

for i in range(m):
    ai,bi,ci = map(int, input().split( ))
    ai-=1
    bi-=1
    d[ai][bi] = d[bi][ai] = ci
###他を回っていけないわけではない
for k in range(n):
    for i in range(n):
        for j in range(n):
            d[i][j] = min(d[i][k]+d[k][j],d[i][j])
ans= 10**10
for l in itertools.permutations(r,r_):
    tmp = 0
    for i in range(r_-1):
        tmp += d[l[i]][l[i+1]]
    ans = min(ans, tmp)

print(ans)

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

int main(void) {
  int a,b;
  scanf("%d %d",&a,&b);
  if (a > 8) {
    printf(":(");
  } else if (b > 8) {
    printf(":(");
  } else {
    printf("Yay!");
  }
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ifor(i,n) for(i=0;i<n;i++)
#define ll long long
int main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     ll int i,n,t,p=INT_MAX,j=0,x,a=0,b,l=0,r=0;
     string s,m;
     cin>>n>>a>>b;
     p=a+b;
     l=n/p;
     r=a*l;
     if(n%p!=0){
        t=n%p;
        j=min(a,t);
        r+=j;
     }
     cout<<r<<endl;

     return EXIT_SUCCESS;
}




Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef pair<int, int> P;
const int c_INF = 111111111;
const int c_mINF = -111111111;
const int c_YET = -1;
const int c_Dx[4] = { 0,0,1,-1 };
const int c_Dy[4] = { 1,-1,0,0 };
const int c_div = 1000000007; //10^9 + 7


int main() {

	char C[10][10];

	for (int i = 0; i < 2; i++) {
		scanf("%s", C[i]);
	}

	if (C[0][0] == C[1][2] && C[0][1] == C[1][1] && C[0][2] == C[1][0]) {
		printf("YES");
	}
	else {
		printf("NO");
	}




}

Measured memory_bytes: 128
#include <stdio.h>

int main(void)
{
	char alp1, alp2;
	char tmp = 'A';
	
	while (scanf("%c,%c", &alp1, &alp2) != EOF){
		if (alp1 == tmp){
			tmp = alp2;
		}
		else if (alp2 == tmp){
			tmp = alp1;
		}
	}
	
	printf("%c\n", tmp);
	
	return (0);
}

Measured memory_bytes: 544
#include <iostream>
    
 using namespace std; int main(void){
    int a,b;
    cin>>a>>b;
    int c[b];
    for(int i=0;i<b;i++){
        cin>>c[i];
    }
    
    for(int i=0;i<b;i++){
        a-=c[i];
    }
    if(a<=0){
    cout<<"Yes";
}
   else{
    cout<<"No";
}
  

    return 0;
    }
        
   

Measured memory_bytes: 640
/**
 * @Author:      H S-J
 * @DateTime:    2018-01-07 20:01:27
 * @Description: 
 */
#include <bits/stdc++.h>
using namespace std;
#define MST(a, b) memset(a, b, sizeof(a));
#define CLR(a) MST(a, 0);
#define DBG(x) cout << '#' << " = " << (x) << endl;
#define ALL(x) x.begin(), x.end()
#define INS(x) inserter(x, x.begin())
#define lson(x) (x) << 1
#define rson(x) (x) << 1|1
#define pb push_back
#define rep(x, y, z) for (int x = y; x < z; ++x)
#define ech(x, y, z) for (auto x = z.begin(), y = z.end(); x != y; ++x)
#define lowbit(x) (x & (-x))
#define opr operator
#define _st first
#define _nd second
#define prior_q1(x) priority_queue<x>
#define prior_q2(x) priority_queue<x, vector<x>, greater<x> >
typedef long long LL;
typedef stringstream strstm;
struct FastIO {
    static const int S = 1310720;
    int wpos;
    char wbuf[S];
    FastIO() : wpos(0) {}
    inline int xchar() {
        static char buf[S];
        static int len = 0, pos = 0;
        if (pos == len)
            pos = 0, len = fread(buf, 1, S, stdin);
        if (pos == len) return -1;
        return buf[pos ++];
    }
    inline int xuint() {
        int c = xchar(), x = 0;
        while (c <= 32) c = xchar();
        for (; '0' <= c && c <= '9'; c = xchar()) x = x * 10 + c - '0';
        return x;
    }
    inline int xint() {
        int s = 1, c = xchar(), x = 0;
        while (c <= 32) c = xchar();
        if (c == '-') s = -1, c = xchar();
        for (; '0' <= c && c <= '9'; c = xchar()) x = x * 10 + c - '0';
        return x * s;
    }
    inline LL xlongint() {
        LL s = 1, c = xchar(), x = 0;
        while (c <= 32) c = xchar();
        if (c == '-') s = -1, c = xchar();
        for (; '0' <= c && c <= '9'; c = xchar()) x = x * 10 + c - '0';
        return x * s;
    }
    inline void xstring(char *s) {
        int c = xchar();
        while (c <= 32) c = xchar();
        for (; c> 32; c = xchar()) * s++ = c;
        *s = 0;
    }
    inline void wchar(int x) {
        if (wpos == S) fwrite(wbuf, 1, S, stdout), wpos = 0;
        wbuf[wpos ++] = x;
    }
    inline void wint(LL x) {
        if (x < 0) wchar('-'), x = -x;
        char s[24];
        int n = 0;
        while (x || !n) s[n ++] = '0' + x % 10, x /= 10;
        while (n--) wchar(s[n]);
    }
    inline void wstring(const char *s) {
        while (*s) wchar(*s++);
    }
    ~FastIO() {
        if (wpos) fwrite(wbuf, 1, wpos, stdout), wpos = 0;
    }
} io;
string s;
int main(int argc, char const *argv[]) {
	ios::sync_with_stdio(0);cin.tie(0);
	while(getline(cin, s)) {
		++s[3];
		cout << s << endl;
	}
	return 0;
}

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

int main() {
    ll n,m,ans;
    cin >> n >> m;
    if (n==2 or m==2) ans = 0;
    else if (n==1 or m==1) {
        if (n!=1) ans=n-2;
        else if (m!=1) ans=m-2;
        else ans=1;
    }
    else ans=(n-2)*(m-2);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3564