akhauriyash/Code-Regression huggingface dataset:
//Jay Shree Krishna

#include"bits/stdc++.h"
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define ll long long int
#define inf 1e18+5
#define sr string
#define M 1000000007
#define start int t;cin>>t;while(t--)
#define db(x) cout<<#x<<"="<<x<<"\n"
#define db2(a,b)cout<<#a<<": "<<a<<" , "<<#b<<": "<<b<< endl;
#define db3(a,b,c)cout<<#a<<": "<<a<<" , "<<#b<<": "<<b<<" , "<<#c<<": "<<c<<endl;
#define forr(i, n) for (int i = 0; i < n; i++)
#define fr(i, n) for (int i = 1; i <= n; i++)
#define rep(i,j,k) for(int i = j; i < k; i++)
#define rp(i,j,k) for(int i = j; i <=k; i++)
#define nn "\n"
#define en "\n"
#define vvi vector<vector<int>>
#define vi vector<int>
#define si set<int>
#define mlsi multiset<int>
#define vc vector<char>
#define vli vector<long long int>
#define vpii vector<pair<int,int>>
#define pii pair<int,int>
#define mii map<int,int>
#define msi map<string,int>
#define mci map<char,int>
#define umii unordered_map<int,int>
#define umsi unordered_map<string,int>
#define umci unordered_map<char,int>
#define mkp make_pair
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define sortv(x) sort(x.begin(),x.end())
#define sorta(x,n) sort(x,x+n)
#define sorted(x) is_sorted(x.begin(),x,end())
#define print_all(x) for(auto t:x) cout<<t<<" ";cout<<en;
#define mxe(x) *max_element(all(x))
#define mne(x) *min_element(all(x))
#define ub upper_bound
#define lb lower_bound
#define go(x) for(auto &[u,v]:x)
#define in(x) cin>>x
#define in2(x,y) cin>>x>>y
#define in3(x,y,z) cin>>x>>y>>z
#define in4(x,y,z,v) cin>>x>>y>>z>>v
#define oo(x) cout<<x<<endl
#define oo2(x,y) cout<<x<<" "<<y<<endl
#define oo3(x,y,z) cout<<x<<" "<<y<<" "<<z<<endl
#define ood(n,x) cout<<fixed<<setprecision(n)<<x<<"\n"
#define sz(x) x.size()
#define ff first
#define ss second
#define ooy cout<<"YES\n"
#define oon cout<<"NO\n" 
#define rr return
#define cc continue

using namespace std;

template<class T> bool ckmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<class T> bool ckmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
 
void read(vli &a,int n){
    a.resize(n);
    forr(i,n) cin>>a[i];
}

bool fine=0;
vli a;
ll n,m;


void solve(){

    sr s;
    in(s);
    if(s[sz(s)-1]=='s'){
        cout<<s<<"es";
    }
    else cout<<s<<"s";

}

int main(){
   #ifndef ONLINE_JUDGE 
    freopen("input1.txt", "r", stdin); 
    freopen("error.txt", "w", stderr); 
    freopen("output1.txt", "w", stdout); 
    #endif
    fast;
   if(fine){
        start{
            solve();
        }
   }
   else solve();
    return 0;
}


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

using namespace std;

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

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

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

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

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

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

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

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

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


int main(){
    int n;
    cin >> n;
    vi a(n);
    inrep(n,a);
    vsort(a);
    P(a[n-1]-a[0]);
    return  0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define rint register int
using namespace std;
// by piano
template<typename tp> inline void read(tp &x) {
  x = 0; char c = getchar(); int f = 0;
  for (; c < '0' || c > '9'; f |= c == '-', c = getchar());
  for (; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar());
  if (f) x = -x;
}
const int mo = 1e9 + 7;
const int N = 3e5 + 233;
struct Point {
  int x, v;
}p[N];
int n, v[N], v_cnt = 0, L[N], R[N], ord[N];

inline bool cmp_x(Point a, Point b) {
  return a.x < b.x || a.x == b.x && a.v < b.v;
}

namespace bit {
  int tr[N];
  inline void add(int x, int val) {
    for (; x <= n + 1; x += x & -x)
      tr[x] = (tr[x] + val) % mo;
  }
  inline int query(int x) {
    int ans = 0;
    for (; x; x -= x & -x)
      ans = (ans + tr[x]) % mo;
    return ans;
  }
  inline int get(int l, int r) {
    if (l > r) return 0;
    ++ l; ++ r;
    return (query(r) - query(l - 1) + mo) % mo;
  }
}

main(void) {
  read(n);
  for (int i = 1; i <= n; i ++) {
    read(p[i].x); read(p[i].v);
    v[++ v_cnt] = p[i].v;
  }
  sort(v + 1, v + v_cnt + 1);
  v_cnt = unique(v + 1, v + v_cnt + 1) - v - 1;
  for (int i = 1; i <= n; i ++)
    p[i].v = lower_bound(v + 1, v + v_cnt + 1, p[i].v) - v;
  sort(p + 1, p + n + 1, cmp_x);
  int mx = 0;
  for (int i = 1; i <= n; i ++) {
    R[i] = mx = max(p[i].v, mx);
  }
  int mn = n;
  for (int i = n; i >= 1; i --) {
    L[i] = mn = min(p[i].v, mn);
  }
  for (int i = 1; i <= n; i ++)
    ord[i] = i;
  auto cmp_LR = [] (int a, int b) {
                  return L[a] < L[b] || L[a] == L[b] && R[a] < R[b];
                };
  sort(ord + 1, ord + n + 1, cmp_LR);
  bit::add(0 + 1, 1);
  for (int i = 1; i <= n; i ++) {
    int p = bit::get(L[ord[i]] - 1, R[ord[i]]);
    bit::add(R[ord[i]] + 1, p);
  }
  cout << bit::get(n, n) << "\n";
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod (ll)(1e9+7)

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

vector<int> g[202];
int m[202], n;
bool use[202];
P a[101], b[101];

bool dfs(int v) {
  use[v] = true;
  rep(i, 0, g[v].size()) {
    int u = g[v][i];
    int w = m[u];
    if(w < 0 || !use[w] && dfs(w)) {
      m[v] = u;
      m[u] = v;
      return true;
    }
  }
  return false;
}

signed main() {
  cin >> n;

  rep(i, 0, n) cin >> a[i].first >> a[i].second;
  rep(i, 0, n) cin >> b[i].first >> b[i].second;

  rep(i, 0, n) rep(j, 0, n) {
    if(b[i].first > a[j].first && b[i].second > a[j].second) {
      g[i].pb(n + j);
      g[n + j].pb(i);
    }
  }

  int ans = 0;
  memset(m, -1, sizeof(m));
  rep(i, 0, n * 2) {
    if(m[i] < 0) {
      memset(use, 0, sizeof(use));
      if(dfs(i)) ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import math
n = 1
while n != 0:
 n = int(input())
 if n == 0:
  break
 else:
  s = list(map(int, input().split()))
  m = 0
  for i in range(n):
   m += s[i]
  m /= n
  si2 = 0
  for i in range(n):
   si2 += (s[i] - m)**2
  si2 /= n
  print(math.sqrt(si2))

 

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

#include <vector>

using namespace std;
using ll = long long;

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

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

    vector<int> visited;
    visited.push_back(1);
    int now = 1;
    int output = 1;
    while (1) {
        now = a[now - 1];
        if (now == 2) {
            cout << output << endl;
            return 0;
        }
        if (find(visited.begin(), visited.end(), now) != visited.end()) {
            cout << -1 << endl;
            return 0;
        }
        visited.push_back(now);
        output++;
    }

    return 0;
}


Measured memory_bytes: 4168
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP2(i, x, n) for(int i = x; i < (int)(n); i++)
#define ALL(n) begin(n), end(n)
//struct cww{cww(){ios::sync_with_stdio(false);cin.tie(nullptr);}}star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;

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

  vector<int> a(n);
  map<int, int> b;
  int arg;
  REP(i, n) {
    scanf("%d", &arg);
    a[i] = arg;
    if (b.count(arg) == 0) {
      b[arg] = 1;
    } else {
      b[arg] += 1;
    }
  }

  int count = n;
  int max = 0;
  int x;
  REP(i, n) {
    x = a[i];
    if (b[x] > 1) {
      --count;
      continue;
    }
    max = ceil(sqrt(x)) + 1;
    if (max > x) max = x;
    REP2(j, 1, max) {
      if (x % j != 0) continue;
      if (b[j] > 0) {
        if (j != x || b[j] != 1) {
          --count;
          break;
        }
      }
      if (b[x / j] > 0) {
        if (x / j != x || b[x / j] != 1) {
          --count;
          break;
        }
      }
    }
  }

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


Measured memory_bytes: 33052
import java.util.Scanner;
import java.util.ArrayList;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
     String S=sc.nextLine();
     char c[] = S.toCharArray();
      for(int i=0;i<c.length;i++){
        if(Character.isUpperCase(c[i])){
          c[i]=Character.toLowerCase(c[i]);
        }else{
          c[i]=Character.toUpperCase(c[i]);
        }
      }
      System.out.print(c);
    System.out.println();
  }
}


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

int main()
{
   int n,m;
   cin>>n>>m;
   vector<int> v(m);
   int sum =0;
   
   for(int i=0;i<m;i++)
   {
       cin>>v[i];
       sum = sum + v[i];
   }
   
   if(sum>n)
   {
       cout<<"-1"<<endl;
   }
   else
   {
       cout<<n - sum<<endl;
   }
  
  
}

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

#define MAX_N 101

int counter;
int d[MAX_N];
int f[MAX_N];

void DFS(list<int>* G, int n){
	counter++;
	d[n] = counter;
	list<int>::iterator it;
	for(it=G[n].begin(); it!=G[n].end(); it++){
		if(d[*it-1]==0) DFS(G, *it-1);
	}
	counter++;
	f[n] = counter;
}

int main()
{
	counter = 0;
	for(int i=0; i<MAX_N; i++) d[i]=f[i]=0;
	int n;cin>>n;
	list<int> G[n];
	
	// input Graph data
	for(int i=0; i<n; i++){
		int u, k, v;
		cin >> u >> k;
		for(int j=0; j<k; j++){
			cin >> v;
			G[u-1].push_back(v);
		}
	}
	// DFS
	for(int i=0; i<n; i++){
		if(d[i]==0){
			DFS(G, i);
		}
	}
	// Output Result
	for(int i=0; i<n; i++){
		cout << i+1 << " " << d[i] << " " << f[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
typedef long long ll;

ll modPow(ll a, ll n){
    if(n == 0)return 1;
    if(n == 1)return a % MOD;
    if(n%2 == 1)return (a * modPow(a, n-1))%MOD;
    ll m = modPow(a, n/2);
    return (m * m) % MOD;
}


int main() {
    ll n, a, b;cin >> n >> a >> b;
    ll cha, chb;
    ll x = n, y = a;
    for (int i = 1; i < a; i++)x = (x * (n-i)) % MOD;
    for (int i = 1; i < a; i++)y = (y * (a-i)) % MOD;
    cha = (x * modPow(y, MOD-2)) % MOD;
    x = n, y = b;
    for (int i = 1; i < b; i++)x = (x * (n-i)) % MOD;
    for (int i = 1; i < b; i++)y = (y * (b-i)) % MOD;
    chb = (x * modPow(y, MOD-2)) % MOD;
    ll ans = (modPow(2, n) - 1 - cha - chb + MOD * 2) % MOD ;
    cout << ans << endl;
    return 0;
}

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

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

const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;

#define rep(i, a, b) for(ll (i) = (a); (i) < (b);++i)

int main() {
  ll N, M;
  cin >> N >> M;
  ll X[M];
  rep(i,0,M)cin >> X[i];

  sort(X, X + M);
  ll diffX[M];
  diffX[0] = 0;
  rep(i,1,M)diffX[i] = X[i] - X[i-1];

  sort(diffX, diffX + M);
  ll ans = 0;
  rep(i,0,M - N + 1)ans += diffX[i];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <inttypes.h>

uint32_t N;
uint64_t K;
uint64_t A[114514];

uint32_t count[64][2];

uint64_t memo[64][2];

uint64_t asumikana(int pos, int sati) {
	uint64_t answer = 0;
	if (pos < 0) return 0;
	if (memo[pos][sati]) return ~memo[pos][sati];

	answer = asumikana(pos - 1, sati && ((K >> pos) & 1) == 0) +
		(UINT64_C(1) << pos) * count[pos][1];
	if (!sati || ((K >> pos) & 1) != 0) {
		uint64_t candidate = asumikana(pos - 1, sati) +
			(UINT64_C(1) << pos) * count[pos][0];
		if (candidate > answer) answer = candidate;
	}

	return ~(memo[pos][sati] = ~answer);
}

int main(void) {
	uint32_t i, j;
	if (scanf("%" SCNu32 "%" SCNu64, &N, &K) != 2) return 1;
	for (i = 0; i < N; i++) {
		if (scanf("%" SCNu64, &A[i]) != 1) return 1;
	}
	for (i = 0; i < 64; i++) {
		for (j = 0; j < N; j++) {
			count[i][(A[j] >> i) & 1]++;
		}
	}
	printf("%" PRIu64 "\n", asumikana(63, 1));
	return 0;
}


Measured memory_bytes: 896
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author cherrypi59
 */

#pragma GCC optimize ("O2")
#pragma GCC optimize ("tree-vectorize")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FFOR(i, a, b) FOR(i, a, b+1)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cerr<<__LINE__<<' '<<#x<<"="<<(x)<<endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

using namespace std;
using lint = long long;
using pii =  pair<int, int>;
using pll =  pair<lint, lint>;
template <typename T> using vc = vector<T>;
template <typename T> using vvc = vector<vector<T>>;
template <typename T> inline bool chmax(T &a, T b){if(a<b){a = b; return true;} return false;}
template <typename T> inline bool chmin(T &a, T b){if(a>b){a = b; return true;} return false;}

constexpr lint ten(int n) {return n==0 ? 1 : ten(n-1)*10;}

class BBuffet {
public:
    void solve(std::istream& in, std::ostream& out){
        ios_base::sync_with_stdio(false);
        in.tie(nullptr), out.tie(nullptr);
        int N;
        in>>N;
        vc<int> A(N), B(N), C(N-1);
        REP(i, N) in>>A[i], A[i]--;
        REP(i, N) in>>B[i];
        REP(i, N-1) in>>C[i];
        int ans = 0;
        REP(i, N){
            ans += B[A[i]];
            if(i<N-1 and A[i+1]==A[i]+1) ans += C[A[i]];
        }
        out<<ans<<'\n';
    }
};


int main() {
	BBuffet solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
#include <ctime>
#include <sstream>
#define weewoo ios::sync_with_stdio(false);cin.tie(0)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ld long double
#define ll long long
#define se second
#define fi first
#define ctoi(x) (x-'0')
#define pi (acos(-1))
#define llputin(a,n) for(int i=0;i<n;i++){ll x;cin >> x;a.push_back(x);}
#define iputin(a,n) for(int i=0;i<n;i++){int x;cin >> x;a.push_back(x);}

#define MOD ((ll) 1e9 + (ll) 7)
using namespace std;

ll pw(ll x,ll a){
    if(a==0)
        return 1;
    ll t = pw(x,a/2);
    if(a%2==0)
        return (t*t);
    else
        return (t*t*x);
}

bool prime(int x)
{
    if(x < 2) return false;
        for(int i=2; i<= sqrt(x); i++) {
            if ((x%i) == 0) return false;
        }
    return true;
}



int main()
{
    weewoo;
    char c;
    cin >> c;
    c++;
    cout << c<< endl;
    return 0;
}


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

using namespace std;

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

#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define pb push_back
#define ppb pop_back
#define mkp make_pair
#define F first
#define S second
#define show(a) cerr << #a <<" -> "<< a <<"\n"
#define fo(a, b, c, d) for(int (a) = (b); (a) <= (c); (a) += (d))
#define foo(a, b, c ,d) for(int (a) = (b); (a) >= (c); (a) -= (d))
//#define int ll

const int N = 2e5;
const int INF = 1e9;

string s;

int main () {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	string a[] = {"MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN"};
	cin >> s;
	fo(i, 0, 5, 1) {
		if(s == a[i]) {
			cout << 6 - i <<'\n';
			return 0;
		}
	}
	cout << 7;
	return 0;
}













Measured memory_bytes: 256
/* ex7_3
   cy_an  */

#include <stdio.h>
#include <stdlib.h>

int main(void){

    // 変数の宣言
    char **matrix;
    int num_r, num_c, i, j, r_flag, c_flag, printflag;

    // numの入力
    scanf("%d %d", &num_r, &num_c);

    // 二次元配列領域の動的確保
    matrix = (char**)calloc(num_r, sizeof(char*));
    if(matrix == NULL){
        fprintf(stderr, "memory allocation error.\n");
        exit(1);
    }
    for(i=0; i<num_r; i++){
        matrix[i] = (char*)calloc(num_c, sizeof(char));
        if(matrix[i] == NULL){
            fprintf(stderr, "memory allocation error.\n");
            exit(1);
        }
    }

    // raw,colの入力
    for(i=0; i<num_r; i++){
        for(j=0; j<num_c; j++){
            scanf(" %c", &matrix[i][j]);
        }
    }

    // 行の削除
    for(i=0; i<num_r; i++){
        r_flag = 1;
        for(j=0; j<num_c; j++){
            if(matrix[i][j] == '#'){
                r_flag = 0;
                break;
            }
        }
        // 全て'.'のとき
        if(r_flag){
            for(j=0; j<num_c; j++){
                matrix[i][j] = '-';
            }
        }
    }
    // 列の削除
    for(j=0; j<num_c; j++){
        c_flag = 1;
        for(i=0; i<num_r; i++){
            if(matrix[i][j] == '#'){
                c_flag = 0;
                break;
            }
        }
        // 全て'.'のとき
        if(c_flag){
            for(i=0; i<num_r; i++){
                matrix[i][j] = '-';
            }
        }
    }

    // matrixの出力
    for(i=0; i<num_r; i++){
        printflag = 0;
        for(j=0; j<num_c; j++){
            if(matrix[i][j] != '-'){
                printf("%c", matrix[i][j]);
                printflag = 1;
            }
        }
        if(printflag){
            printf("\n");
        }
    }

    // メモリの解法
    for(i=0; i<num_r; i++){
        free(matrix[i]);
    }
    free(matrix);

    return 0;
}

Measured memory_bytes: 1676
#include <iostream>

using namespace std;

int n, m;

long long int x[100005],y[100005];

long long int M = 1000000007;

long long int C(long long int j, long long int m) {

	return (long long int) (j*(m - j + 1)) % M;
}

int main(void) {

	cin >> n >> m;

	long long int tmp;
	for (int i = 1; i <= n; i++) {
		cin >> tmp; x[i] = tmp;
	}

	for (int j = 1; j <= m; j++) {
		cin >> tmp; y[j] = tmp;
	}

	long long int ans1 = 0;

	for (int i = 2; i <= n; i++) {
		ans1 += (x[i] - x[i - 1])*C(i - 1, n - 1) % M;
		ans1 %= M;
	}

	long long int ans2 = 0;
	for (int j = 2; j <= m; j++) {
		ans2 += (y[j] - y[j - 1])*C(j - 1, m - 1) % M;
		ans2 %= M;
	}

	long long int ans = ans1*ans2 %M;

	cout << ans << endl;

	//system("pause");
	return 0;
}

Measured memory_bytes: 1792
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define PB push_back
#define MP make_pair
#define ll long long

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

int main(){
    std::ios::sync_with_stdio(false);
    ll w, h, x, y;
    cin >> w >> h >> x >> y;

    bool is_center = (x * 2 == w) && (y * 2 == h);

    printf("%.9lf %d\n", (double)w * h / 2, is_center ? 1 : 0); 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define all(v) v.begin(),v.end()
#define mp make_pair
#define ff first
#define ss second
#define MAXN  1000005
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n,m;
    cin>>n>>m;
    if(n>m)
        swap(n,m);
    if(n==1&&m==1){
        cout<<1<<endl;
        return 0;
    }
    if(n==1){
        cout<<max(0LL,m-2)<<endl;
    }
    else cout<<max(0LL,(m-2)*(n-2))<<endl;


    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iomanip>
using namespace std;

int main() {
	int a1, a2, a3;
	cin >> a1 >> a2 >> a3;
	cout << max({a1, a2, a3})-min({a1, a2, a3}) << endl;
}

Measured memory_bytes: 256
n = int(input())
ts = [int(item)*2 for item in input().split()]
vs = [int(item) for item in input().split()]

time = sum(ts) + 1
speed_l = [0] * time
speed_r = [0] * time 

t_id = 0
speed = 0
ts_copy = ts[:]
# Forward
for i in range(time+1):
    ts_copy[t_id] -= 1
    speed_l[i] = speed
    if speed >= vs[t_id]:
        speed = vs[t_id]
    else:
        speed += 0.5 

    if ts_copy[t_id] == 0:
        if t_id + 1 >= n:
            break
        t_id += 1

# Backward
speed = 0
for i in range(time-1, -1, -1):
    ts[t_id] -= 1
    speed_r[i] = min(speed, speed_l[i])
    if speed >= vs[t_id]:
        speed = vs[t_id]
    else:
        speed += 0.5 

    if ts[t_id] == 0:
        if t_id <= 0:
            break
        t_id -= 1

print(sum(speed_r) / 2.0)

Measured memory_bytes: 3700
N = int(input())
s = [input() for i in range(N)]

a = 0
b = 0
b_a = 0
ab = 0
for j in range(N):
    if s[j][0] == 'B':
        b += 1
    if s[j][-1] == 'A':
        a += 1
    
    if s[j][0] == 'B' and s[j][-1] == 'A':
        b_a += 1

    ab += s[j].count('AB')

if b_a >= 1 and b_a == a and b_a == b:
    print(ab + a - 1)
else:
    print(ab + min(a,b))

Measured memory_bytes: 3700
#include <iostream>
#include <stdio.h>
using namespace std;

int main() { 
    int s;
    cin >> s;
    int h = s / (60 * 60);
    int r1 = s - (h * 60 * 60);
    int m = r1 / 60;
    int rs = r1 % 60;
    printf("%d:%d:%d\n", h, m, rs);
    // cout << h << ":" << m << ":" << rs << endl;
    return 0;
}


Measured memory_bytes: 3228
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<queue>
using namespace std;

long long N, A, X[103], dp[103][10005];

int main(){
	scanf("%lld %lld", &N, &A);
	for (int i = 0; i < N; i++) {
		scanf("%lld", &X[i]);
		X[i] -= A;
	}
	
	/*for (int i = 0; i < N; i++) {
	    printf("%lld\n", X[i]);
	}*/
	
	for (int i = 0; i < N; i++) {
	    if (i > 0) {
    	    for (int j = 1000; j < 7000; j++) {
    	        dp[i][j] = dp[i - 1][j];
    	    }
    	    for (int j = 1000; j < 7000; j++) {
    	        dp[i][X[i] + j] += dp[i - 1][j];    
    	    }
	    }
	    dp[i][X[i] + 3500]++;
	}
	/*for (int i = 0; i < 7000; i++) {
	    if (dp[N - 1][i] > 0) {
	        printf("%d %lld\n", i, dp[N - 1][i]);
	    }
	}*/
	
	printf("%lld\n", dp[N - 1][3500]);
	return 0;
}

Measured memory_bytes: 6348
h, w = gets.strip.split.map(&:to_i)
ss = readlines.map {|line| line.strip.split('') }

d = [0, 1, 0, -1]
@dd = 4.times.map {|i| [d[i], d[i^1]] }
def dirs(y, x)
  @dd.map {|dy, dx| [y+dy, x+dx] }
end

INF = 10**6
dist = Array.new(h) { [INF]*w }
dist[0][0]=0

q = [[0,0]]
until q.empty?
  cy, cx = c = q.shift
  dirs(*c).each do |y, x|
    next if y<0 || y>=h || x<0 || x>=w || ss[y][x]=='#' || dist[y][x] <= dist[cy][cx]+1

    dist[y][x] = dist[cy][cx]+1
    q.push( [y, x] )
  end
end

if dist[h-1][w-1] == INF
  p -1
else
  b_count = ss.flatten.count {|e| e=='#' }
  p h*w - (1+dist[h-1][w-1]+b_count)
end

#dist.each {|l|p l}
#ss.each {|l|p l}

Measured memory_bytes: 2172
import java.util.Scanner;

class Main {
    
    public static void main(String... args) {
        
        Scanner scanner = new Scanner(System.in);
        String[] numbers = scanner.nextLine().split(" ");
        
        boolean result = true;
        for (int i=0; i < numbers.length - 1; i++) {
            int current = Integer.parseInt(numbers[i]);
            int next = Integer.parseInt(numbers[i + 1]);
            
            if (current >= next) {
                result = false;
                break;
            }
        }
        
        System.out.println(result ? "Yes" : "No");
    }
}


Measured memory_bytes: 26316
n=int(input())
#x,n=map(int,input().split())
#pl=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]

res=''
#res+=chr(ord("a")+n%26-1)
#n//=26
while n>0:
    n-=1
    res+=chr(ord("a")+n%26)
    n//=26
print(res[::-1])


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

int main(){

  char str[1000];

  scanf("%s",str);

  int n;

  scanf("%d",&n);

  int a;

  char command[n][10];

  int s[n],t[n];

  char use[100][1000];

  for(a=0;a<=n-1;a++){

    scanf("%*c%s %d %d",&command[a],&s[a],&t[a]);

    if(strcmp(command[a],"replace")==0)

      scanf(" %s",use[a]);

  }

  int b,c[n];

  for(b=0;b<=n-1;b++){

    if(strcmp(command[b],"print")==0){

      for(c[b]=s[b];c[b]<=t[b];c[b]++){

	printf("%c",str[c[b]]);

      }

      printf("\n");

    }else if(strcmp(command[b],"replace")==0){

      for(c[b]=s[b];c[b]<=t[b];c[b]++){

	str[c[b]]=use[b][c[b]-s[b]];

      }

    }else{

      //りばーすしたい

      char alpha;

      double half=(t[b]-s[b])/2;

      for(c[b]=0;c[b]<=half;c[b]++){

	alpha=str[s[b]+c[b]];
	str[s[b]+c[b]]=str[t[b]-c[b]];
	str[t[b]-c[b]]=alpha;

      }

    }

  }

  return 0;

}

Measured memory_bytes: 652
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;

namespace AtCoderWorkspace
{
    public class Solver
    {
        public void Solve()
        {
            var cin = new Scanner();
            var n = cin.nextInt();
            
            Console.WriteLine((int)(n * n));
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public int[] DPArrayInt(int N, int ex)
        {
            int[] Array = new int[N+ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt();
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public long[] DPArrayLong(int N, int ex)
        {
            long[] Array = new long[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong();
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }   

    class Program
    {
        static void Main(string[] s) => new Solver().Solve();
    }
}


Measured memory_bytes: 13140
#include"bits/stdc++.h"

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int N;
	cin >> N;
	vector<int>A(N);
	int sum = 0;
	for (int i = 0; i < N; i++)
	{
		cin >> A[i];
		sum += A[i];
	}

	if (sum % 10 != 0) {
		cout << sum << endl;
		return 0;
	}
	else {
		sort(A.begin(), A.end());
		for (int i = 0; i < N; i++) {
			if (A[i] % 10 != 0) {
				sum -= A[i];
			}
			if (sum % 10 != 0) {
				cout << sum << endl;
				return 0;
			}
		}
	}
	cout << 0 << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ios ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define bit(x,j) ((x>>j)&1)
using namespace std;
// bitset<8>set1(p);
// __builtin_popcountll(x);
// bitset<100> b("1010");
ll int mod=998244353;
int mul(ll int x, ll int y)
{
    return (x * 1ll * y) % mod;
}

int add(int x, int y)
{
    x += y;
    while(x >= mod) x -= mod;
    while(x < 0) x += mod;
    return x;
}

long long power(long long a, long long b,ll m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = mul(res,a);
        a = mul(a,a);
        b >>= 1;
    }
    return res%m;
    }


  ll int binomial(ll int n, ll int k) 
{ 
    ll int C[k+1]; 
    memset(C, 0, sizeof(C)); 
  
    C[0] = 1;  // nC0 is 1 
  
    for (ll int i = 1; i <= n; i++) 
    { 
        // Compute next row of pascal triangle using 
        // the previous row 
        for (int j = min(i, k); j > 0; j--) 
            C[j] = add(C[j],C[j-1]); 
    } 
    return C[k]%mod; 
} 
  vector<int> pr;
  bool prime[10000000];
void Sieve(ll int n) 
{ 
    memset(prime, true, sizeof(prime)); 
    prime[1]=false;
  
    for (int p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            pr.push_back(p);
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
}
 


//It reurns Fn,Fn+1
pair<int, int> fib (int n) {
    if (n == 0)
        return {0, 1};

    auto p = fib(n >> 1);
    int c = p.first * (2 * p.second - p.first);
    int d = p.first * p.first + p.second * p.second;
    if (n & 1)
        return {d, c + d};
    else
        return {c, d};
}
int sum(int n)  
{  
    if (n == 0)  
    return 0;  
    return (n % 10 + sum(n / 10));  
}  
ll int factorial(ll int n,ll int m) 
{ 
    ll int fact = 1; 
    for(int i=2;i<=n;i++) { 
        fact = (fact * i)%m; 
    } 
    return fact%m; 
} 

int reduce(int x, int y) 
{ 
    int d; 
    d = __gcd(x, y); 
  
    x = x / d; 
    y = y / d; 
    return x; 
} 

int binarySearch(int arr[], int l, int r, int x) 
{ 
    if (r >= l) { 
        int mid = l + (r - l) / 2; 
  
        if (arr[mid] == x) 
            return mid; 
  
        if (arr[mid] > x) 
            return binarySearch(arr, l, mid - 1, x); 
  
        // Else the element can only be present 
        // in right subarray 
        return binarySearch(arr, mid + 1, r, x); 
    } 
  
    // We reach here when element is not 
    // present in array 
    return -1; 
} 

int main() {
  ios;
  ll int n;
  cin>>n;
  string s="ACL";
  string g="";
  for(int i=0;i<n;i++)
  {
      g+=s;
  }
  cout<<g<<endl;
}


Measured memory_bytes: 3616
// Created by sz
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int mod = 1e9+7;
struct modular {
    int value;
    modular(long long v = 0) { value = v % mod; if (value < 0) value += mod;}
    modular(long long a, long long b) : value(0){ *this += a; *this /= b;}
    modular& operator+=(modular const& b) {value += b.value; if (value >= mod) value -= mod; return *this;}
    modular& operator-=(modular const& b) {value -= b.value; if (value < 0) value += mod;return *this;}
    modular& operator*=(modular const& b) {value = (long long)value * b.value % mod;return *this;}
    //其他函数调用mexp(modular(10),3);
    friend modular mexp(modular a, long long e) {
        modular res = 1; while (e) { if (e&1) res *= a; a *= a; e >>= 1; }
        return res;
    }
    friend modular inverse(modular a) { return mexp(a, mod - 2); }
    modular& operator/=(modular const& b) { return *this *= inverse(b); }
    friend modular operator+(modular a, modular const b) { return a += b; }
    friend modular operator-(modular a, modular const b) { return a -= b; }
    friend modular operator-(modular const a) { return 0 - a; }
    friend modular operator*(modular a, modular const b) { return a *= b; }
    //除法只有在mod是素数可用;
    friend modular operator/(modular a, modular const b) { return a /= b; }
    friend ostream& operator<<(ostream& os, modular const& a) {return os << a.value;}
    friend istream& operator>>(istream& is, modular & a){long long value; is >> value;a.value = 0; a += value;  return is;}
    friend bool operator==(modular const& a, modular const& b) {return a.value == b.value;}
    friend bool operator!=(modular const& a, modular const& b) {return a.value != b.value;}
};




int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    int n,k;
    cin >> n >> k;
    vector<int> a(n);

    for (int i = 0; i < n; i++){
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    
    
    if(k == n){
        cout << a.back() - a.front() << "\n";
        return 0;
    }
    
    if(k == 1){
        cout << 0 << "\n";
        return 0;
    }
    

    
    vector<modular> fac(n);
    fac[0] = 1;
    fac[1] = 1;
    for (int i = 2; i < n; i++){
        fac[i] = fac[i-1] *i;
    }
    
    
    modular ans = 0;
    for (int i = k-1; i < n; i++){
        ans += fac[i] /(fac[i-k+1]* fac[k-1]) * a[i];
    }
    
    for (int i = 0; i < n-k+1; i++){
        ans -=  fac[n-i-1]/(fac[ k-1]* fac[n-i - k])* a[i];
    }
    
    cout << ans.value << "\n";
    
    return 0;
}


Measured memory_bytes: 1024
/*************************************************************************
>>> Author: WindCry1
>>> Mail: lanceyu120@gmail.com
>>> Website: https://windcry1.com
>>> Date: 12/30/2019 11:03:37 PM
*************************************************************************/
//#pragma GCC optimize(2)
//#pragma GCC diagnostic error "-std=c++11"
#include <cstring>
#include <cmath>
#include <cstdio>
#include <cctype>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <iostream>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <complex>
#include <stack>
#include <bitset>
#include <iomanip>
#include <list>
#include <sstream>
#include <fstream>
#if __cplusplus >= 201103L
#include <unordered_map>
#include <unordered_set>
#endif
#define endl '\n'
#define ALL(x) x.begin(),x.end()
#define MP(x,y) make_pair(x,y)
#define ll long long
#define ull unsigned long long
#ifdef WindCry1
#define DEBUG(x) cout<<#x<<" : "<<x<<endl;
#endif
#define lowbit(x) x&(-x)
#define ls u<<1
#define rs u<<1|1
using namespace std;
template<typename T> inline T MIN(const T &a,const T &b) {return a<b?a:b;}
template<typename T> inline T MAX(const T &a,const T &b) {return a>b?a:b;}
template<typename T,typename ...Args> inline T MIN(const T &a,const T &b,Args ...args) {return MIN(MIN(a,b),args...);}
template<typename T,typename ...Args> inline T MAX(const T &a,const T &b,Args ...args) {return MAX(MAX(a,b),args...);}
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
const double eps = 1e-8;
const int INF = 0x3f3f3f3f;
const int mod = 1e9+7;
const int dir[4][2]={-1,0,1,0,0,-1,0,1};
int dp[1000010][2];
int main(){
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#ifdef WindCry1
	freopen("C:/Users/LENOVO/Desktop/in.txt","r",stdin);
#endif
	string s;cin>>s;
	dp[0][0]=s[0]-'0';
	dp[0][1]=11+'0'-s[0];
	for(int i=1;i<s.size();i++){
		dp[i][0]=min(dp[i-1][0],dp[i-1][1])+s[i]-'0';
		dp[i][1]=min(dp[i-1][0]+11+'0'-s[i],dp[i-1][1]+9+'0'-s[i]);
	}
	cout<<min(dp[(int)s.size()-1][0],dp[(int)s.size()-1][1])<<endl;
	return 0;
}



Measured memory_bytes: 9116
n, m = [int(i) for i in input().split()]
liked = [0 for _ in range(m)]
for _ in range(n):
    _input = [int(i) for i in input().split()]
    for i in _input[1:]:
        liked[i-1] += 1
count = 0
for i in range(len(liked)):
    if liked[i] == n:
        count += 1
print(count)

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

using ll = long long;
using vi = vector<int>;
using vi2 = vector<vector<int>>;
#define MP(a,b) make_pair((a),(b))
#define MT(...) make_tuple(__VA_ARGS__)

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

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl;
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl;

#define DCOUT(x,n) cout << fixed << setprecision(n) << (x) << endl;

#define sz(x) (int)(x).size()
#define HOGE cout << "hoge" << endl;
using P = pair<ll,ll>;

template<typename T>inline istream& operator>>(istream&i,vector<T>&v)
{REP(j,sz(v))i>>v[j];return i;}

const int INF = 1e9;

int main(){
    ll n;
    cin >> n;
    ll ans = 0;
    ll a;
    cin >> a;
    ll top = a;
    REP(i,n-1){
        ll b;
        cin >> b;
        if(b < top) ans += top-b;
        else top = b;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3648
#include <stdio.h>

int isPrime(int n)
{
	int i;
	
	if(n < 2) return(0);
	if(n == 2) return(1);
	if(n % 2 == 0) return(0);
	
	for(i = 3; i <= n / i; i += 2){
		if(n % i == 0) return(0);
	}
	
	return(1);
}

int main(void)
{
	int x, n, i, s;
	
	scanf("%d", &x);
	for(i = 0, s = 0; i < x; i++){
		scanf("%d", &n);
		s += isPrime(n);
	}
	printf("%d\n", s);
	
	return(0);
}



Measured memory_bytes: 2076
#include<stdio.h>
#define MAX 100000
main(){
  int n, i;
  int A[MAX+1];
  scanf("%d", &n);
  for ( i = 1; i <= n; i++ ) scanf("%d", &A[i]);

  for ( i = 1; i <= n; i++ ) {
    printf("node %d: key = %d, ", i, A[i]);
    if ( i / 2 >= 1 )printf("parent key = %d, ", A[i/2]);
    if ( i*2 <= n ) printf("left key = %d, ", A[i*2]);
    if ( i*2+1 <= n ) printf("right key = %d, ", A[i*2+1]);
    printf("\n");
  }
  
  return 0;
}



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

int main() {
  ll mod = 1'000'000'007;
  ll N, M;
  cin >> N >> M;

  if (1 < abs(N-M)) {
    cout << 0 << endl;
    return 0;
  }

  ll m = max(N, M);
  vector<ll> dp(m+1); dp[0] = 1;
  for (ll i = 1; i <= m; ++i) {
    dp[i] = (dp[i-1] * i) % mod;
  }

  ll ans = (dp[N] * dp[M]);
  if (N == M) ans *= 2;
  cout << ans % mod << endl;
  return 0;
}


Measured memory_bytes: 4032
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0;i < (int)n;i++)
#define repb(i, n) for(int i = (int)n;i >= 0;i--)
#define reps(i, m, n) for(int i = (int)m;i < (int)n;i++)
#define repsb(i, m, n) for(int i = (int)m;i >= (int)n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define INF 999999999999999999
using namespace std;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
int main(int argc, char const *argv[]) {
    int a;
    cin>>a;
    if(a==3 || a==7 ||a==5) cout<<"YES"<<endl;
    else  cout<<"NO"<<endl;
    return 0;
}


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

int main(){
    int n,r;
    cin >> n >> r;
    int ans = r;
    if(n < 10){
        ans += 100*(10-n);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3616
import java.util.Scanner;

/**
 * Created by labuser on 2016/04/19.
 */
public class Main {
    public static void main(String[] args) {
        new Main().run();
    }

    private void run() {

        int a, b;

        Scanner sc = new Scanner(System.in);
        while(true){
            String[] input = sc.nextLine().split(" ");
            a = Integer.parseInt(input[0]);
            b = Integer.parseInt(input[1]);
            if(a ==0 && b ==0){
                break;
            }
            System.out.println(Math.min(a,b)+" "+Math.max(a,b));
        }

    }
}

Measured memory_bytes: 34060
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include <sstream>
#include<map>
#include<cmath>
#include<queue>
#include <functional>
#define rep(i,n) for (int i = 0; i < n; ++i)


using namespace std;

int main() {
	vector<int> vNum(3, 0);
	rep(i, 3)
	{
		cin >> vNum[i];
	}
	sort(vNum.begin(), vNum.end());
	cout << (vNum[0] * vNum[1] / 2);
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N=sc.nextInt();
		double sum = 0;

		for(int i=0;i<N;i++) {
			sum+=1/sc.nextDouble();
		}
		System.out.println(1/sum);

	}
}


Measured memory_bytes: 23380
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<tuple>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
ll MOD=1e+9+7;
const int MAX = 100010;
ll fac[MAX], finv[MAX], inv[MAX];
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAX; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
long long COM(int n,int k){
    if(n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}
int main(){
	COMinit();
	int N;
	ll A[100001];
	scan(N);
	rep1(i,N){
		scan(A[i]);
	}
	ll kaisu[100001]={0};
	ll ans=0;
	rep1(i,N){
		if(i<=N/2+N%2){
			if(i==1){
				kaisu[i]+=fac[N];
				for(int k=2;k<=N;k++){
					kaisu[i]+=((COM(N,k)*fac[N-k])%MOD)*fac[k-1]%MOD;
					kaisu[i]%=MOD;
				}
			}
			else{
				kaisu[i]=kaisu[i-1]-(COM(N,N-i+2)*fac[N-(N-i+2)]%MOD)*fac[N-i+1]%MOD+(COM(N,i)*fac[N-i]%MOD)*fac[i-1]%MOD;
				while(kaisu[i]<0) kaisu[i]+=MOD;
				kaisu[i]%=MOD;
			}
		}
		else{
			kaisu[i]=kaisu[N-i+1];
		}
		//printf("kaisu[%d]:%lld\n",i,kaisu[i]);
	}
	rep1(i,N){
		ans+=A[i]*kaisu[i]%MOD;
		ans%=MOD;
	}
	prin(ans);
	return 0;
}


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

int main() {
	// your code goes here
	ll n;
	cin>>n;
	ll a[n];
	for(ll i=0;i<n;i++)
	    cin>>a[i];
	ll ma=a[0];
	ll c=0;
	for(ll i=0;i<n;i++)
	{
	    if(a[i]>ma)
	      ma=a[i];
	    else
	      c+=ma-a[i];
	}
	cout<<c<<endl;
}

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

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

int main()
{
    long long N, A, B;
    cin >> N >> A >> B;
    long long count = N / (A + B);
    long long tmp = N % (A + B);
    if(tmp > A)
    {
        tmp = A;
    }
    long long ans = count * A + tmp;
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	int x;
	
	public void solve(){
		Scanner sc = new Scanner(System.in);
		x = sc.nextInt();
		System.out.println(x*x*x);
		
		
	}
	
	public static void main(String[] args){
		Main obj = new Main();
		obj.solve();
	}
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  while (true) {
    int n, w, d;
    cin >> n >> w >> d;
    if (n + w + d == 0) break;
    
    vector<pair<int, int>> x;
    x.emplace_back(make_pair(w, d));
    
    for (int i = 0; i < n; i++) {
      int p, s;
      cin >> p >> s;
      p--;
      
      vector<pair<int, int>> y;
      pair<int, int> keep;
      for (int j = 0; j < x.size(); j++) {
        if (j == p) keep = x.at(j);
        else y.emplace_back(x.at(j));
      }
      
      int w1, d1, w2, d2;
      w1 = w2 = keep.first;
      d1 = d2 = keep.second;
      s %= (keep.first + keep.second) * 2;
      if (s < keep.first) {
        w1 = s;
        w2 = keep.first - s;
      }
      else if (s < keep.first + keep.second) {
        d1 = s - keep.first;
        d2 = keep.second - d1;
      }
      else if (s < keep.first * 2 + keep.second) {
        w1 = s - (keep.first + keep.second);
        w2 = keep.first - w1;
      }
      else {
        d1 = s - (keep.first * 2 + keep.second);
        d2 = keep.second - d1;
      }
      if (w1 * d1 > w2 * d2) {
        swap(w1, w2);
        swap(d1, d2);
      }
      y.emplace_back(make_pair(w1, d1));
      y.emplace_back(make_pair(w2, d2));
      
      x = y;
    }
    
    vector<int> z(x.size());
    for (int i = 0; i < x.size(); i++) {
      z.at(i) = x.at(i).first * x.at(i).second;
    }
    
    sort(z.begin(), z.end());
    
    for (int i = 0; i < z.size(); i++) {
      if (i) cout << " ";
      cout << z.at(i);
    }
    cout << '\n';
  }
}


Measured memory_bytes: 3032
import itertools
n,_=map(int,input().split())
b=map(int,input().split())
l=len(str(n))
c=set(b)^set([0,1,2,3,4,5,6,7,8,9])
for i in range(l,l+2):
    for x in itertools.product(c,repeat=i):
        d=''.join(map(str,x))
        if int(d)>=n:print(d);exit()

Measured memory_bytes: 3060
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;




int K;
vector<ll> V;

void recursive(ll num,ll last_digit,int num_digit){

	V.push_back(num);
	if(num_digit == 10)return;

	if(last_digit-1 >= 0){
		recursive(10*num+last_digit-1,last_digit-1,num_digit+1);
	}
	recursive(10*num+last_digit,last_digit,num_digit+1);

	if(last_digit+1 <= 9){

		recursive(10*num+last_digit+1,last_digit+1,num_digit+1);
	}
}

int main(){

	scanf("%d",&K);

	for(ll i = 1; i <= 9; i++){

		recursive(i,i,1);
	}

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

	printf("%lld\n",V[K-1]);

	return 0;
}


Measured memory_bytes: 2420