akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

typedef struct{
  int num,t;
}T;

bool comp(const T&l, const T&r){
  if(l.num == r.num) return l.t > r.t;
  return l.num < r.num;
}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N;cin >> N;
  const int M = 3;
  vector<T> v(M*N);
  rep(i,M){
    rep(j,N){
      cin >> v[i*N+j].num;
      v[i*N+j].t = i;
    }
  }
  sort(all(v),comp);
  ll counts[M];
  rep(i,M) counts[i] = 0;
  ll sum = 0;
  rep(i,N*M){
    if(v[i].t == 0) ++counts[0];
    else if(v[i].t == 1) sum += counts[0]*(N-counts[2]);
    else ++counts[2];
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 2560
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cout << #x << ": " << x << endl
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define endl '\n'
const int MAXN = 1e5;

int gcd(int a, int b){ return ((b == 0) ? a : gcd(b, a % b)); }

struct DSU{
	int S;
	struct node{
		int parent; ll sum;
	};
	vector<node> dsu;
	DSU(int n){
		S = n;
		rep(i, n){
			node tmp;
        		//set parent to itself
			tmp.parent = i; tmp.sum = 1;
			dsu.pb(tmp);
		}
	}
	void reset(int n){
		dsu.clear();
		S = n;
		rep(i, n){
			node tmp;
			tmp.parent = i; tmp.sum = 1;
			dsu.pb(tmp);
		}
	}
	int root(int u){
		if(dsu[u].parent == u) return u;
                //it works if a there is a subset of subset of a set (dfs)
		dsu[u].parent = root(dsu[u].parent);
		return dsu[u].parent;
	}
	void merge(int u, int v){
		u = root(u); v = root(v);
		if(u == v) return;
		//we choose to grow bigger sets over little sets (merge / unite by rank)
		//that alows us to use less memory and avoid MLE
		if(getsum(u) < getsum(v)) swap(u, v);
		//we don't erase the sum
		//it is fine since it is not pointing to itself
		dsu[v].parent = u;
		dsu[u].sum += dsu[v].sum;
	}
	bool sameset(int u, int v){
		if(root(u) == root(v)) return true;
		return false;
	}	
	ll getsum(int u){
		return dsu[root(u)].sum;
	}
};

ll a[2 * MAXN], b[2 * MAXN];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n;
	cin >> n;
	DSU dsu(2 * MAXN);
	memset(a, 0, sizeof(a));
	memset(b, 0, sizeof(b));
	rep(i, n){
		int x, y;
		cin >> x >> y;
		x-- , y--;
		dsu.merge(x, MAXN + y);
	}
	rep(i, MAXN){
		a[dsu.root(i)]++;
		b[dsu.root(i + MAXN)]++;
	}
	ll ans = 0;
	rep(i, 2 * MAXN) if(dsu.root(i) == i) ans += a[i] * b[i];
	cout << ans - n << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 7404
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <math.h>
#include <iostream>
struct xy
{
    char x[10];
    int y;
    int index;
};

void swap2(struct xy * a, struct xy * b)
{
    struct xy t = *a;
    *a = *b;
    *b = t;
}

void qsort(struct xy a[], int s, int e)
{
    int l, r, v;
    int low[30], high[30];
    int sp;

    low[0] = s;
    high[0] = e;
    sp = 1;

    while(sp > 0)
    {
        sp--;
        l = low[sp];
        r = high[sp];

        if(l >= r)
            continue;
        else
        {
            int i = l - 1, j = r;

            while(1)
            {
                while(a[++i].y > a[r].y)
                    continue;

                while(i < j-- && a[j].y < a[r].y)
                    continue;

                if(i >= j)
                    break;

                swap2(&a[i], &a[j]);
            }

            swap2(&a[i], &a[r]);
            v = i;

            if(v-l < r-v)
            {
                low[sp] = v + 1;
                high[sp++] = r;
                low[sp] = l;
                high[sp++] = v-1;
            }
            else
            {
                low[sp] = l;
                high[sp++] = v-1;
                low[sp] = v + 1;
                high[sp++] = r;
            }
        }
    }
}

void sort(struct xy a[], int n)
{
    int h, i, j;
 
    for(h = 1; h < n / 9; h = h * 3 + 1)
        continue;
 
    for(; h > 0; h /= 3)
    {
        for(i = h; i < n; i++)
        {
            j = i;
            while(j >= h && strcmp(a[j].x, a[j-h].x) < 0)
            {
                swap2(&a[j], &a[j-h]);
                j -= h;
            }
        }
    }
}



using namespace std;
int change[101];
int main(void)
{
    int n;
    scanf("%d", &n);
    struct xy tuple[n];
    for (int i = 0; i < n; i++)
    {
        scanf("%s %d", tuple[i].x, &tuple[i].y);
        tuple[i].index = i+1;
    }
    sort(tuple, n);
    int j = 0;
    for (int i = 1; i < n; i++)
    {
        if(strcmp(tuple[i].x,tuple[i-1].x) != 0)
        {
            j++;
            change[j] = i;
        }
    }
    change[++j] = n;
    for (int i = 1; i <= j; i++)
    {
        qsort(tuple, change[i-1], change[i]-1);
    }
    

    for (int i = 0; i < n; i++)
    {
        printf("%d\n", tuple[i].index);
    }
    
    
 
    return 0;
}
    



Measured memory_bytes: 256
/*
ID: espr1t
TASK: 
KEYWORDS: 
*/

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;
FILE* in = stdin; FILE* out = stdout;

const int MAX = 100001;

struct Dish {
    int val1, val2;
    bool operator < (const Dish& r) const {
        return (val1 + val2) != (r.val1 + r.val2) ? (val1 + val2) > (r.val1 + r.val2) : val1 > r.val1;
    }
};

int n;
Dish a[MAX];

int main(void) {
	// in = fopen("C.in", "rt");
	
	fscanf(in, "%d", &n);
	for (int i = 0; i < n; i++) {
	    fscanf(in, "%d %d", &a[i].val1, &a[i].val2);
    }
    sort(a, a + n);
	
	long long ans = 0;
	int left = 0, right = n - 1;
	while (left <= right) {
	    ans += a[left++].val1;
	    if (left <= right)
    	    ans -= a[left++].val2;
    }
    fprintf(out, "%lld\n", ans);
	
	return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)

using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;

using namespace std;

const long long MOD = 1000000007;

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

	int n;
	cin >> n;
	string s;
	cin >> s;
	int* a;
	a = new int[n];
	rep(i, n) a[i] = s[i] - '1';
	int num[3] = {0};
	rep(i, n) ++num[a[i]];

	int g = 1;
	if (num[1] == 0) {
		g = 2;
		rep(i, n) a[i] = a[i] >> 1;
	}
	else {
		rep(i, n) a[i] %= 2;
	}

	int ans = 0;
	rep(i, n) {
		int r = n - 1 - i;
		int c = 1;
		if (a[i] == 1) {
			rep(j, 32) {
				if (((n - 1) & (1 << j)) == 0 && (r & (1 << j)) != 0) {
					c = 0;
					break;
				}
			}

			ans = ans ^ c;
		}
	}

	cout << ans * g << "\n";

	return 0;
}


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

// int/long:		-2147483648 - 2147483648 (-2^31 <= int < 2^31)
// long/long long:	-9223372036854775808 - 9223372036854775807 (-2^63 <= long < 2^63)

#define	INF (1<<29)
//536870912

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// bit: &/and, |/or, ^/xor, ~/not

#define	MOD 1000000007

int	main() {
	vector<int> A(3);
	for (int i=0; i<3; i++)
		cin >>A.at(i);
	sort(A.begin(), A.end());
	if (A.at(0)+A.at(1)==A.at(2))
		cout <<"Yes" <<endl;
	else
		cout <<"No" <<endl;
	return 0;
}



Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;

#define all(a) (a).begin(), (a).end()

int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

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

    string s; cin>>s;
    int n = s.size();

    int p = 0, g = 0, ans = 0;
    for(int i=0; i<n; i++){
        if(s[i] == 'g'){
            if(p < g){
                p++;
                ans++;
            }
            else{
                g++;
            }
        }
        else{
            if(p < g){
                p++;
            }
            else{
                g++;
                ans--;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 512
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b,c;
    cin>>a>>b>>c;
    for(int i=0;i<b;i++){
        if(a*i%b==c){
            cout<<"YES"<<endl;
            return 0;
        }
    }
    cout<<"NO"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define pb push_back
#define mp make_pair
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 int INF = 1<<30;
const ll LINF = 1LL<<58;
const ll mod = 1000000007;

int main(){
    int n;
    cin >> n;
    vector<int> A(n), B(n+1, 0), ans;
    for(int i = 0; i < n; i++) cin >> A[i];
    for(int i = n; i > 0; i--){
        int a = 0;
        for(int j = i; j <= n; j+=i){
            a += B[j];
        }
        if(a%2 != A[i-1]) B[i]++;
    }
    for(int i = 1; i <= n; i++){
        if(B[i])ans.pb(i);
    }
    cout << ans.size() << endl;
    if(!ans.size())return 0;
    for(int i = 0; i < ans.size(); i++){
        cout << ans[i] << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3064
n = int(input())

def f(s):
	if int(s) > n: return 0
	p = 0
	if '7' in s and '5' in s and '3' in s:
		#print(s)
		p = 1
	return f(s + '3') + f(s + '5') + f(s + '7') + p

print(f('0'))

Measured memory_bytes: 2940
'''
    Auther: ghoshashis545 Ashis Ghosh
    College: jalpaiguri Govt Enggineerin College
    Date:23/03/2020
'''


from math import ceil
def main():
    
    
    
    n,m=map(int,input().split())
    
    a=list(map(int,input().split()))
    s=sum(a)
    if(n<=s):
        print('Yes')
    else:
        print('No')
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
if __name__ =="__main__":
    main()

Measured memory_bytes: 14012
S = input()
days = ["SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"]
index = days.index(S) + 1
count = 0
while index != 0:
    if index == 7:
        index = 0
    else:
        index += 1
    count += 1
print(count)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define pb push_back
#define mk make_pair
#define mod 1000000007
#define lb lower_bound
#define ub upper_bound
#define endl "\n"
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define prec(y,x) fixed<<setprecision(y)<<x
#define inf 1e18
#define pi 3.1415926535
typedef tree<int, null_type, less<int>, rb_tree_tag,                    //if using ll change int to ll
        tree_order_statistics_node_update> pbset;
#define fob(x) find_by_order(x)
#define ook(x) order_of_key(x)
vector<int> arr, vis, v;
int dfs(int x)
{

	v.pb(x);
	if (vis[arr[x]] == 0)
	{vis[arr[x]] = 1; dfs(arr[x]);}
	return 0;

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

	ll n, k;
	cin >> n >> k;
	arr.resize(n + 1, 0); vis.resize(n + 1, 0);
	for (int i = 1; i <= n; i++)
	{
		cin >> arr[i];
	}
	vis[1] = 1;
	dfs(1);
	int u = arr[v[v.size() - 1]]; //cout<<u<<endl;
	int l = 0;

	for (; l < v.size(); l++)
	{
		if (v[l] == u)
			break;
	}
	// cout<<l<<" "<<v.size()<<endl;
	if (k < l)
	{
		cout << v[k]; return 0;
	}
	k -= l;
	ll r = v.size() - l;
	k %= r; ll ans = 0;
	for (int i = 0; i <= k; l++, i++)
	{
		ans = v[l];
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 11728
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<array>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<unordered_map>
#include<queue>
#include<vector>
using namespace std;

//#define int long long
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define dump(o) {cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) {cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
const int MOD = 1e9 + 7;

signed main() {
	for (int n; cin >> n&&n;) {
		int a[10] = {};
		rep(i, 0, n) {
			int b; cin >> b;
			a[b]++;
		}
		rep(i, 0, 10) {
			if (a[i]) {
				rep(j, 0, a[i])cout << "*";
				cout << endl;
			}
			else cout << "-" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3052
#include<bits/stdc++.h>
#include <math.h>
#include <cmath>
#include <limits>
#include <iostream>
#include <assert.h>

#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
typedef pair<ll,Pi> P1i;
const ll INF=10000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};
struct pos{
	int x,y,sx,sy,total;
};
int ketasuu(int a){
	int t=0;
	while(a>0){
		a/=10;
		t++;
	}
	return t;
}
int x[20001][9]={};
int f[20001][9][4]={};
int main(){

	ll n;
	cin>>n;
	int s=1,s2=0;
	ll total=0;
	for(int i=1; i<ketasuu(n)+1; i++){
		rep(j,s){
			x[s2][i]=x[j][i-1]*10+3;
			f[s2][i][1]=1;
			f[s2][i][2]=f[j][i-1][2];
			f[s2][i][3]=f[j][i-1][3];
			if(x[s2][i]<=n&&f[s2][i][1]+f[s2][i][2]+f[s2][i][3]==3)total++;

			x[s2+1][i]=x[j][i-1]*10+5;
			f[s2+1][i][2]=1;
			f[s2+1][i][1]=f[j][i-1][1];
			f[s2+1][i][3]=f[j][i-1][3];
			if(x[s2+1][i]<=n&&f[s2+1][i][1]+f[s2+1][i][2]+f[s2+1][i][3]==3)total++;

			x[s2+2][i]=x[j][i-1]*10+7;
			f[s2+2][i][3]=1;
			f[s2+2][i][1]=f[j][i-1][1];
			f[s2+2][i][2]=f[j][i-1][2];
			if(x[s2+2][i]<=n&&f[s2+2][i][1]+f[s2+2][i][2]+f[s2+2][i][3]==3)total++;
			s2+=3;
		}
		s=s2;
		s2=0;
	}
	cout<<total<<endl;
	return 0;

}




Measured memory_bytes: 3712
#include <iostream>
#include <vector>
#include <map>
#include <string>

using namespace std;

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

int main()
{
  char s[4];
  std::map<char, int> m;
  for (int i=0;i<4;++i) {
    cin >> s[i];
    char key = s[i];
    if (m.find(key) == m.end()) {
      m[key] = 1;
    } else {
      m[key] = m[key]+1;
    }
  }
  
  if (m.size() != 2) {
    cout << "No" << endl;
    return 0;
  }
  
  for (auto & x:m) {
    if (x.second != 2) {
    cout << "No" << endl;
    return 0;
    }
  }
    
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define debug(x) cerr << #x << " " << (x) << endl
using namespace std;

const int N = 55;
const long long mod = 1000000007ll;

int n;
long long f[N][N][N], c[N][N], ans = 0ll;

int main () {
	scanf("%d", &n);
	for (int i = 0; i <= n; i++) c[i][0] = c[i][i] = 1ll;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j < i; j++) c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % mod;
	}
	
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= n; j++) {
			for (int k = 0; k <= n; k++) f[i][j][k] = 0ll;
		}
	}
	f[1][1][0] = 1ll;
	for (int i = 2; i <= n; i++) {
		for (int even1 = 0; even1 <= i; even1++) {
			for (int odd1 = 0; even1 + odd1 <= i; odd1++) {
				f[i][even1][odd1] = 0ll;
				if (!(even1 + odd1)) continue;

				int i_ = i - even1 - odd1;
				for (int even2 = 0; even2 <= i_; even2++) {
					for (int odd2 = 0; even2 + odd2 <= i_; odd2++) {
						int e = even2 + even1 - odd1, o = odd1 + odd2 - even1;
						if (e < 0 || o < 0) continue;
						f[i][even1][odd1] = (f[i][even1][odd1] + f[i_][even2][odd2] * c[i_][e] % mod * c[i_ - e][o]) % mod;
					}
				}
			}
		}
	}
	for (int even = 0; even <= n; even++) {
		for (int odd = 0; even + odd <= n; odd++) ans = (ans + f[n][even][odd] * c[n][even] % mod * c[n - even][odd]) % mod;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(long long)(n);++i)
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
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; }
  
const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};
 
const int MAX=510000;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
   
  int n;
  cin >> n;
  vector<int>a(n);
  rep(i,n) cin >> a[i];
  vector<int>ans(n);
  rep(i,n){
    a[i]--;
    ans[a[i]]=i+1;
  }
  rep(i,n) cout << ans[i] << " ";
  return 0;
}


Measured memory_bytes: 3960
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;

int main() {
  int N, M, X, Y;
  cin >> N >> M >> X >> Y;

  vector<int> x(N);
  for (int i = 0; i < N; i++) cin >> x.at(i);
  sort(x.begin(), x.end());
  int E = x.at(N - 1);

  vector<int> y(M);
  for (int i = 0; i < M; i++) cin >> y.at(i);
  sort(y.begin(), y.end());
  int W = y.at(0);

  bool flag = false;
  for (int i = X + 1; i <= Y; i++) {
    if (E < i && W >= i) flag = true;
  }

  if (flag)
    cout << "No War" << endl;
  else
    cout << "War" << endl;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
typedef vector<string> vstring;
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
const long double PI=3.14159265358979323846264338327950;
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  vint h(n);
  rep(i,n){
    cin>>h[i];
  }
  vint dp(n+5);
  dp[0]=0;
  dp[1]=abs(h[0]-h[1]);
  REP(i,2,n){
    dp[i]=min(abs(h[i]-h[i-2])+dp[i-2],abs(h[i]-h[i-1])+dp[i-1]);
  }
  cout<<dp[n-1]<<'\n';
  return(0);
}

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

int main(){
  int n; cin >> n;
  int a[n];
  for(int i=0;i<n;i++){
    cin >>a[i];
  }
  int max=0;
  int abst=0;
  for(int i=0;i<n-1;i++){
    for(int j=0;j<n;j++){
      abst=abs(a[i]-a[j]);
      if(abst>max)
        max = abst;
    }
  }
  
  cout << max << endl;
}  

Measured memory_bytes: 256
import numpy as np

N, W = map(int, input().split(' '))
items = [tuple(map(int, input().split(' '))) for _ in range(N)]
dp = np.zeros(shape=W + 1, dtype=np.int64)

for weight, value in items:
    dp[weight:] = np.maximum(dp[weight:], dp[:-weight] + value)

print(dp[-1])


Measured memory_bytes: 29620
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        l: usize
    }
    println!("{}", (l * l * l) as f64 / 27.0);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(a) (a).size() 
#define all(c) (c).begin(),(c).end()
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,n) for(int i=1;i<=n;i++)
#define ford(i,n) for(int i=n;i>=0;i--) 
#define REP(i,a,n) for(int i=a;i<n;i++)
#define foreach(c,itr) for(__typeof((c).begin(),(c).end())itr=c.begin();itr!=c.end();itr++) 
#define fill(a,b) memset(a,b,sizeof(a))
#define re return
#define INF 1e9
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef vector<pi > vpi; 
bool isprime[101000];
void findprime(){
	isprime[0]=isprime[1]=0;
	REP(i,2,101000){
		if(isprime[i]){
			for(int j=2;i*j<=101000;j++){
				isprime[i*j]=0;
			}
		}
	}
	re;
}
int main(){
	rep(i,101000){
		isprime[i]=1;
	}
	findprime();
	int x;
	cin>>x;
	while(!isprime[x]){
		x++;
	}
	cout<<x;
	re 0;
}

Measured memory_bytes: 3696
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;

ll cnt[10][10];
int N;
int res;

void dfs(ll l, ll r) {
    if (l + r <= N) res++;
    else return;
    rep(i, 10) {
        dfs((l + i) * 10, r);
    }
}
int main()
{
    cin >> N;
    ll ans = 0;

    repd(l, 1, 10) {
        repd(r, 1, 10) {
            dfs(r * 10, l);
            cnt[l][r] += res;
            res = 0;
            if (l == r) cnt[l][r] += 1;
        }
    }
/*
    repd(i, 1, 10) {
        repd(j, 1, 10) {
            cout << i << " " << j << " : " << cnt[i][j] << endl;
        }
    }
*/
    repd(i, 1, N + 1) {
        if (i <= 9) {
            ans += cnt[i][i];
        }
        else {
            int r = i % 10, tmp = i, l;
            while (tmp) {
                l = tmp % 10;
                tmp /= 10;
            }
            // cout << i << " >> " << l << " " << r << endl;
            ans += cnt[l][r];
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>  
using namespace std;  
typedef long long ll; 
typedef long double ld; 
const int INF = 0x3f3f3f3f;  
const int N = 200000 + 5;
int gcd(int a,int b){
	return b == 0?a:gcd(b,a%b);
}
int main()
{
	int n;
	cin >> n;
	ll sum = 0;
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= n; j++){
			int z = gcd(i,j);
			for(int k = 1; k <= n; k++){
				sum += gcd(z,k);
			}
		}
	}
	cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3636
def main():
    n = int(input())
    a = list(map(int,input().split()))
    ans = set(a)
    ma = max(a)
    from collections import Counter
    c = Counter(a)
    for i in range(n):
        t = a[i]
        if c[t] > 1 and t in ans:
            ans.remove(t)
            continue
        j = 2
        tmp = t*j
        while tmp <= ma:
            if tmp in ans:
                ans.remove(tmp)
            j += 1
            tmp = t*j
    print(len(ans))

if __name__ == '__main__':
    main()



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

typedef long long ll;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll a,b,c;
    cin>>a>>b>>c;
    if(a<c) {
        if((b+a-c)<=0) {
            cout<<0<<" "<<0<<endl;
        } else {
            cout<<0<<" "<<b+(a-c)<<endl;
        }
    } else {
        cout<<a-c<<" "<<b<<endl;
    }
    return 0;
}

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

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

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

  if (x >= 30)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <deque>
#include <cctype>
#include <cstdio>
#include <math.h>
using namespace std;
int main(){
    int n;
    long long ans=0;
    cin >> n;
    vector<int> l(2*n);
    for(int i=0;i<2*n;i++){
        cin >> l[i];
    }
    sort(l.begin(),l.end());
    for(int i=0;i<2*n;i=i+2){
        ans+=min(l[i],l[i+1]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,T;
	cin>>n>>T;
	int c[n],t[n];
	for(int i=0;i<n;i++){
		cin>>c[i]>>t[i];
		if(t[i]>T) c[i]=-1;
	}
	sort(c,c+n);
	if(c[n-1]==-1){
		cout<<"TLE"<<endl;
		return 0;
	}
	for(int i=0;i<n;i++){
		if(c[i]!=-1){
			cout<<c[i];
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 256
from fractions import gcd

A, B, C, D = map(int, input().split())
lcm = C * D // gcd(C, D)

N = B - (A-1)
M_C = (B // C) - ((A-1) // C)
M_D = (B // D) - ((A-1) // D)
M_CD = (B // lcm) - ((A-1) // lcm)
M = M_C + M_D - M_CD

print(N-M)

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

int n, cnt[5];

int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> n;
	string s;
	for (int i = 0; i < n; i++) {
		cin >> s;
		if (s[0] == 'A')  cnt[0]++;
		else if (s[0] == 'W')  cnt[1]++;
		else if (s[0] == 'T')  cnt[2]++;
		else  cnt[3]++;
	}
	cout << "AC x " << cnt[0] << endl;
	cout << "WA x " << cnt[1] << endl;
	cout << "TLE x " << cnt[2] << endl;
	cout << "RE x " << cnt[3] << endl;
	return 0;
}

Measured memory_bytes: 3684
#include <bits/stdc++.h>
#define L(i, m, n) for(int i(m);i < n;i++)
#define pb push_back
#define D(X) cout<<"  "<<#X": "<<X<<endl;
#define in(x) cin >> x
#define SZ(X) int(X.size())
#define ff first
#define ss second
#define RF(X) freopen(X, "r", stdin)
#define WF(X) freopen(X, "w", stdout)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef pair<int, string> pis;
typedef vector<string> vs;
typedef pair<pair<int, int>, pair<int, int > > piiii;

ll a[200006];
int main(){
	ll n,sum(0),s(0);in(n);L(i,0,n)in(a[i]),sum+=a[i];
	ll diff;
	s+=a[0];sum-=a[0];
	diff=abs(s-sum);
	L(i,1,n-1){
		s+=a[i];sum-=a[i];
		diff=min(diff, abs(sum-s));
	}
	cout << diff <<endl;
	
	return 0;
}


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

using namespace std;
using ull = unsigned long long;
using ll = long long;
using lli = long long int;
using ld = long double;
using pa = pair<int, int>;
using ppa = pair<pa, int>;
#define SORT(v, n) sort(v, v + n);
#define ALL(v) v.begin(), v.end()
#define VSORT(v) sort(ALL(v))
#define GRESORT(v) sort(ALL(v), greater<ll>())
#define REVERSE(v) reverse(ALL(v))
#define overlap(v) v.erase(unique(ALL(v)), v.end())
#define debug(x) cout << #x << ": " << x << endl
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for (int i = (b - 1); i >= a; i--)
#define rrep(i, n) RFOR(i, 0, n)
#define INF INT_MAX
#define SUP INT_MIN
#define mins(a, b) a = min(a, b)
#define maxs(a, b) a = max(a, b)

// 4近傍
int dy[]={0, 1, 0, -1};
int dx[]={1, 0, -1, 0};

// 8近傍
// int dy[]={0,0,1,-1,1,1,-1,-1};
// int dx[]={1,-1,0,0,1,-1,1,-1};

// const ll MOD = 1000000007;

ll pow_mod(ll a, ll b, ll mod) {
    ll tmp = 1;
    a %= mod;
    if (b > 0) {
        tmp = pow_mod(a, b / 2, mod);
        if (b % 2)
            tmp = (((tmp * tmp) % mod) * a) % mod;
        else
            tmp = (tmp * tmp) % mod;
    }
    return tmp;
}

void solve() {
    int w,h,n;
    cin >> w >> h >> n;
    vector<int> x(n), y(n), a(n);
    for(int i = 0; i < n; i++) cin >> x[i] >> y[i] >> a[i];
    vector<vector<int>> d(h,vector<int>(w));
    for(int i = 0; i < n; i++){
        if(a[i] == 1){
            for(int j = 0; j < h; j++){
                for(int k = 0; k < x[i]; k++){
                    d[j][k] = -1;
                }
            }
        }else if(a[i] == 2){
            for(int j = 0; j < h; j++){
                for(int k = x[i]; k < w; k++){
                    d[j][k] = -1;
                }
            }
        }else if(a[i] == 3){
            for(int j = 0; j < y[i]; j++){
                for(int k = 0; k < w; k++){
                    d[j][k] = -1;
                }
            }
        }else{
            for(int j = y[i]; j < h; j++){
                for(int k = 0; k < w; k++){
                    d[j][k] = -1;
                }
            }
        }
    }
    int count = 0;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            // if(j) cout << " ";
            // cout << d[i][j];
            if(d[i][j] == 0) count++;
        }
        // cout << endl;
    }
    cout << count << endl;
}

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

    solve();

    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

	private static String YES = "YES";
	private static String NO_ = "NO";

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";

		int[] sides = new int[3];

		while ((line = br.readLine()) != null) {
			if (line.length() > 4) {
				sides[0] = Integer.parseInt(line.split(" ")[0]);
				sides[1] = Integer.parseInt(line.split(" ")[1]);
				sides[2] = Integer.parseInt(line.split(" ")[2]);
				Arrays.sort(sides);
				if (Math.pow(sides[2], 2) == (Math.pow(sides[0], 2) + (Math
						.pow(sides[1], 2)))) {
					System.out.println(YES);
				} else {
					System.out.println(NO_);
				}
			}
		}
	}
}

Measured memory_bytes: 23692
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
const int LIMIT = 1e9 + 7;
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define all(v) (v).begin(), (v).end()

namespace /* debug */{
  #define DEBUG(...) do{cout<<#__VA_ARGS__<<" = ";debug(__VA_ARGS__);}while(0) //変数
  #define ldebug(...) do{cout<<"["<<setw(3)<<__LINE__<<"] ";debug(__VA_ARGS__);}while(0) //行数
  #define lDEBUG(...) do{cout<<"["<<setw(3)<<__LINE__<<"] "<<#__VA_ARGS__<<" = ";debug(__VA_ARGS__);}while(0) //変数, 行数
  template<class T>void show(T&x){cout<<x<<" ";} //出力
  template<class T>void showendl(T&x){cout<<x<<endl;} //出力改行
  template<class P,class Q>void show(pair<P,Q>&x){cout<<"("<<x.first<<", "<<x.second<<") ";} //pair出力
  template<class P,class Q>void showendl(pair<P,Q>&x){cout<<"("<<x.first<<", "<<x.second<<")"<<endl;} //pair出力改行
  template<class H>void debug(H&&h){showendl(h);} //引数1つ
  template<class H,class...Ts>void debug(H&&h,Ts&&...ts){show(h);debug(forward<Ts>(ts)...);} //可変引数
  template<class T>void debug(vector<T>&vt){int i=0;for(auto x:vt)++i!=vt.size()?show(x):showendl(x);} //vector出力
  template<class T>void debug(initializer_list<T>init){int i=0;for(auto x:init)++i!=init.size()?show(x):showendl(x);} //初期化子リスト出力
}

int main(){
	string s;cin>>s;
  ll ans = 0;
  for(char c: s){
    ans += c-'0';
  }
  cout<<(ans%9==0 ? "Yes" : "No")<<endl;
}

Measured memory_bytes: 3652
CHARS_LEN = 26
s = gets.strip.split('').map{ |c| c.ord - 'a'.ord }
k = gets.to_i

s.each.with_index do |c, i|
  next if s[i] == 0

  if s[i] + k >= CHARS_LEN
    d = CHARS_LEN - s[i]
    s[i] = 0
    k -= d
  end
end

s[s.size - 1] = (s[s.size - 1] + k) % CHARS_LEN

puts s.map{|c| (c + 'a'.ord).chr }.join('')


Measured memory_bytes: 15996
#include<stdio.h>
int MIN(int a,int b){return a<b?a:b;}
int ta[1010],to[1000010],nt[1000010],co[1000010],F[1010];
int MF(int s,int t,int e,int min){
  if(s==t||min==0)return min;
  int i,r;
  F[s]=1;
  for(i=ta[s];i+1;i=nt[i]){
    if(F[to[i]])continue;
    r=MF(to[i],t,e,MIN(min,co[i]));
    co[i]-=r;
    co[(i+e)%(2*e)]+=r;
    if(r)return r;
  }
  return 0;
}
int Flow(int s,int t,int v,int e,int min){
  while(v--)F[v]=0;
  return MF(s,t,e,min);
}
int maxf(int s,int t,int v,int e){
  int f=0,r;
  while(r=Flow(s,t,v,e,1e9))f+=r;
  return f;
}
int main(){
  int n,m,q,l,ans,e,r=0,i,a,b,k;
  scanf("%d %d %d",&n,&m,&q);
  e=m+q;
  for(i=0;i<=n;i++)ta[i]=-1;
  for(i=0;i<m;i++){
    scanf("%d %d",&a,&b);
    nt[r  ]=ta[to[r+e]=a];
    nt[r+e]=ta[to[r  ]=b];
    co[ta[b]=r+e]=co[ta[a]=r]=1;
    r++;
  }/*printf("a\n");
  for(i=0;i<=n;i++){printf("%d:",i);
    for(k=ta[i];k+1;k=nt[k])printf(" %d",to[k]);
    printf("\n");
    }//*/
  ans=maxf(1,n,n+1,e);//printf("%d\n",ans);
  while(q--){
    scanf("%d %d %d",&k,&a,&b);
    if(k==1){
      for(i=ta[a];i+1;i=nt[i]){
	if(to[i]==b)break;
      }
      if(i==-1){
	nt[r  ]=ta[to[r+e]=a];
	nt[r+e]=ta[to[r  ]=b];
	co[ta[b]=r+e]=co[ta[a]=r]=1;
	r++;
      }
      else co[i]=co[(i+e)%(2*e)]=1;
      ans+=Flow(1,n,n+1,e,1);
    }
    else{
      for(k=ta[a];to[k]-b;k=nt[k]);
      if(co[k]==2){
	i=a;
	a=b;
	b=i;
	k=(k+e)%(2*e);
      }
      if(co[k]==1);//co[i]=co[(i+e)%(2*e)]=0;
      else if(Flow(a,b,n+1,e,1)==0){
	Flow(n,b,n+1,e,1);
	Flow(a,1,n+1,e,1);
	ans--;
      }
      co[k]=co[(k+e)%(2*e)]=0;
    }
    printf("%d\n",ans);
  }
  return 0;
}



Measured memory_bytes: 2304
import re

def main(s):
    #文字列sに同じ文字がn個以上連続している部分文字列を見つける
    n = 2
    # カンマを取ると n 個ちょうどになる
    reg = re.compile("(.)\\1{%d,}" %(n-1))
    while True:
        m = reg.search(s)
        if not m:
            break
        yield m.group(0)
        s = s[m.end():]


if __name__ == "__main__":
    s = input()
    K = int(input())

    # 1文字の場合
    if len(s) == 1:
        print(K // 2)
        exit()

    t = list(main(s))

    # 全ての文字が同じ場合
    if len(t) == 1 and len(t[0]) == len(s):
        print((len(s) * K) // 2)
        exit()

    # 先頭と末尾が同じ場合
    ans1 = 0
    if len(s) >= 3 and s[0] == s[-1]:
        if len(t) >= 2 and t[0][0] == s[0] and t[-1][0] == s[-1]:
            ans1 = len(t[0]) // 2 + len(t[-1]) // 2 - ((len(t[0]) + len(t[-1])) // 2)
            ans1 *= K-1
        
        elif len(t) >= 1 and t[0][0] != s[0]:
            ans1 = len(t[-1]) // 2 - ((1 + len(t[-1])) // 2)
            ans1 *= K-1
        
        elif len(t) >= 1 and t[-1][0] != s[-1]:
            ans1 = len(t[0]) // 2 - ((len(t[0] + 1)) // 2)
            ans1 *= K-1
        
        else:
            ans1 = -1 * (K-1)

    # 先頭と末尾が異なる場合
    ans2 = 0
    for i in t:
        ans2 += len(i) // 2
    ans2 *= K

    ans = -ans1 + ans2
    print(ans)

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

typedef long long int ll;

const ll mxn = 100007;
ll n, k, dp[mxn], h[mxn];

int main() {
    cin >> n >> k;
    for(ll i = 0; i < n; ++i) cin >> h[i];
    memset(dp, -1, sizeof(dp));

    dp[0] = 0;

    for(ll i = 0; i < n; ++i) {
        for(ll j = i + 1; j <= i + k && j < n; ++j) {
            if(dp[j] == -1 || dp[j] > dp[i] + abs(h[j] - h[i])) dp[j] = dp[i] + abs(h[j] - h[i]);
        }
    }

    cout << dp[n - 1] << endl;
    return 0;
}

Measured memory_bytes: 5160
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=1<<30;
const int mod=1e9+7;
const int MOD=998244353;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;cin >> n;
    ll ans=1;
    for(ll i=1;i<=n;i++){
        (ans*=i)%=mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
"""from collections import *
from itertools import *
from bisect import *
from heapq import *

import math
from fractions import gcd
import sys
#input = sys.stdin.readline

import copy
"""
from collections import *
N,M=map(int,input().split())
AB=[list(map(int,input().split())) for i in range(N-1+M)]
data=[[] for i in range(N+1)]
lst=set()
came=[set() for i in range(N+1)]
for a,b in AB:
    data[a].append(b)
    lst.add(b)
    came[b].add(a)

st=list(set(range(1,N))-lst)[0]
stack=deque([st])
lst=[0 for i in range(N+1)]


while stack:
    a=stack.popleft()
    for p in data[a]:
        came[p].remove(a)
        if not came[p]:
            lst[p]=a
            stack.append(p)

for i in range(1,N+1):
    print(lst[i])


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

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

    ios_base::sync_with_stdio(false);cin.tie(NULL);

    string s,t;
    cin>>s>>t;
    int n=s.size(),m=t.size();
    int dp[n][m];
    fill(dp[0],dp[n-1]+m,0);

    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            if(i)   dp[i][j]=max(dp[i][j],dp[i-1][j]);
            if(j)   dp[i][j]=max(dp[i][j],dp[i][j-1]);
            // dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
            if(s[i]==t[j])
                dp[i][j]=max(dp[i][j],((i>0&&j>0)?dp[i-1][j-1]:0)+1);
        }
    }
    int i=n-1,j=m-1;
    int len=dp[n-1][m-1];
    string res;
    while(len && i>=0 && j>=0){
        if(i && dp[i-1][j]==dp[i][j]){
            i--;
            continue;
        }

        if(j && dp[i][j-1]==dp[i][j]){
            j--;
            continue;
        }

        res+=s[i];
        len--;
        i--;j--;
    }
    reverse(res.begin(),res.end());
    cout<<res<<"\n";
}

Measured memory_bytes: 38784
#include <iostream>
#include <vector>
#define REP(i,n) for (int i=0;i<(n);i++)

using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
	int w,d;
	while(cin >> w >> d,w){
		int ans = 0;
		vector<int> a(21,0);
		REP(i,w){
			int tmp;
			cin >> tmp;
			a[tmp]++;
			ans += tmp;
		}
		REP(i,d){
			int tmp;
			cin >> tmp;
			if(a[tmp] > 0){
				a[tmp]--;
			}else{
				ans += tmp;
			}
		}
		cout << ans << endl;
	}
  return 0;
}

Measured memory_bytes: 3136
#include <iostream>
using namespace std;
int main(void)
{
    int a,b,c;
    
    cin >> a >> b >> c;
    
    if(a > b)
    {
        swap(a,b);
    }
    
    if(b > c)
    {
        swap(b,c);
    }
    
    if(a > b)
    {
        swap(a,b);
    }
    
    cout << a << " " << b << " " << c <<endl;
    
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;


int main() {
    char s[10];
    cin>>s;
    sort(s,s+4);
    bool can=false;

    if(s[0]==s[1]&&s[1]!=s[2]&&s[2]==s[3]){
        can=true;
    }
        
    if(can){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }

}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

pair<int,ll> sum(string& s, int& i);
pair<int,ll> mul(string& s, int& i);
pair<int,ll> bracket(string& s, int& i);
pair<int,ll> num(string& s,int & i);
pair<int,ll> sum(string& s, int& i){
    pair<int,ll> ans = mul(s,i);
    while(i!=s.size()&&(s[i]=='+'||s[i]=='-')){
        if(s[i]!='+'&&s[i]!='-')return {0,0};
        if(s[i]=='+'){
            ++i;
            auto ret = mul(s,i);
            ans.first &= ret.first;
            ans.second += ret.second;
            ans.first|=2;
        }
        else if(s[i]=='-'){
            ++i;
            auto ret = mul(s,i);
            ans.first &= ret.first;
            ans.second -= ret.second;
            ans.first|=2;
        }
        if(ans.second<0||ans.second>=1024)return {0,0};
    }
    return ans;
}

pair<int,ll> mul(string& s, int& i){
    pair<int,ll> ans = bracket(s,i);
    while(i!=s.size()&&s[i]=='*'){
        ++i;
        auto ret = mul(s,i);
        ans.first &= ret.first;
        ans.second *= ret.second;
        ans.first|=2;
        if(ans.second<0||ans.second>=1024)return {0,0};
    }
    return ans;
}

pair<int,ll> bracket(string& s, int& i){
    if(i==s.size())return {0,0};
    if(s[i]=='('){
        ++i;
        auto ret = sum(s,i);
        if(i==s.size()||s[i]!=')'||ret.first<2)return {0,0};
        ++i;
        ret.first -= 2;
        return ret;
    }
    if('0'<=s[i]&&s[i]<='1')return num(s,i);
    return {0,0};
}

pair<int,ll> num(string& s,int& i){
    ll ret = 0;
    bool ok=true;
    while('0'<=s[i]&&s[i]<='1'){
        if(ret>=512)ok=false;
        else ret = 2 * ret + (s[i]-'0');
        ++i;
    }
    return {ok,ret};
}

int main(){
    string s;
    cin>>s;
    vector<int> dot;
    char c[]{'+','-','*','0','1','(',')'};
    rep(i,s.size()){
        if(s[i]=='.')dot.push_back(i);
    }
    int m = dot.size();
    int all = pow(7,m);
    ll ans=-1;
    rep(i,all){
        int mask = i;
        string t = s;
        rep(j,m){
            t[dot[j]]=c[mask%7];
            mask/=7;
        }
        int idx=0;
        auto ret = sum(t,idx);
        if((ret.first&1)&&idx==s.size()) ans = max(ans,ret.second);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3376
#include<iostream>
#include<cstdio>
#include<stack>
#include<queue>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<math.h>
#include<tuple>
#include<string.h>
#include <numeric> 
#include<unordered_map>
using namespace std; 
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define pp(...) "\033[94m [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m"
#define pp1(...) "\033[1;47;35m" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m"
#define dg(x) debug() << pp1(x)
#define dg1(x) debug() << "[line : " << __LINE__ <<"]"<< pp(x)
#define dg2(x,y) debug() << "[line : " << __LINE__ <<"]"<< pp(x) pp(y)
#define dg3(x,y,z) debug() << "[line : " << __LINE__ <<"]"<< pp(x) pp(y) pp(z)
#define dg4(w,x,y,z) debug() << "[line : " << __LINE__ <<"]"<< pp(w) pp(x) pp(y) pp(z)
template<typename T> void db(T x ){ debug() <<">>> " <<  x; }
template<typename T> void db(T x , T y){ debug() <<">>> " <<  x <<" , "<< y; }
template<typename T> void db(T x , T y , T z){ debug() <<">>> "<< x <<" , "<< y <<" , "<< z; }
template<typename T> void db(T x , T y , T z , T a){ debug() <<">>> "<< x <<" , " << y <<" , "<< z <<" , "<< a; }
#define int long long
#define all(x) x.begin() , x.end()
#define clr(x , y) memset(x , y , sizeof x);
#define sz(x) (int)x.size()

const int Mod = 1e9 + 7;
const int inf = 1e18;

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n , T;
  cin >> n >> T;
  int ans = 0;
  int r = 0;
  vector<int> a (n);
  for(int i = 0; i < n; i++) {
    cin >> a[i];
  }
  r = T;
  for(int i = 1;i < n; i++) {
    if(a[i] > r) {
      ans += T;
    }
    else if(a[i] <= r ) {
      ans += a[i] - a[i - 1];
    }
    r = a[i] + T;
  }
  ans += T;
  cout << ans << '\n';
}

Measured memory_bytes: 4728