akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>

int compare(const void *a, const void *b){
	return *(int *)b - *(int *)a;
}

int main(){
	int N, i, x = 0, ans = 0;
	scanf("%d", &N);
	int *a = (int *)malloc(sizeof(int) * N);
	for(i = 0; i < N; i++){
		scanf("%d", &a[i]);
		x ^= a[i];
		a[i] ^= a[i] - 1;
	}
	if(x == 0){
		printf("0\n");
		return 0;
	}
	qsort(a, N, sizeof(int), compare);
	for(i = 0; i < N; i++){
		if((x ^ a[i]) < x && (x ^ a[i]) < a[i]){
			x ^= a[i];
			ans++;
			if(x == 0){
				printf("%d\n", ans);
				return 0;
			}
		}
	}
	printf("-1\n");
	return 0;
}

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

bool island_sort(const pair<int, int>&a,  const pair<int, int>&b) {
	if (a.second==b.second) return (a.first<b.first);
	return (a.second<b.second);
}


int main(void) {
	int N, M;
	cin >> N >> M;

	vector <pair <int, int> > battle;
	for (int i = 0; i < M; i++) {
		int a, b;
		cin >> a >> b;
		battle.push_back(make_pair(a, b));
	}
	sort(battle.begin(), battle.end(), island_sort);


	int ans = 0;
	int vpos = 0;
	int bpos = battle[vpos].second;

	while (vpos<M) {
		int apos = battle[vpos].first;
		if (apos >= bpos) {
			ans++;
			bpos = battle[vpos].second;
		}
		vpos++;
	}
	ans++;
	cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1528
def create_table(m, n=[], result=[]):
    if n and int(''.join(map(str,n))) > m: return result
    r = [3, 5, 7]
    if 3 in n and 7 in n and 5 in n: result.append(n)
    for x in r:
        create_table(m, n+[x], result)
    return result

n = int(input())
print(len(create_table(n)))

Measured memory_bytes: 6912
#include <cstdio>
#include <vector>
using namespace std;

#define iter(i, n) for (int i = 1; i <= n; ++i)
#define NR 201000

int t[NR], n, m, ans[NR];
vector<int> fac[NR], s[NR];

void inc(int x) { for (++x; x; x -= x & -x) ++t[x]; }
int sum(int x) { int s = 0; for (++x; x <= n + 10; x += x & -x) s += t[x]; return s; }

int main() {
	scanf("%d%d", &m, &n);
	iter(i, m) {
		int l, r;
		scanf("%d%d", &l, &r);
		s[r + 1].push_back(l - 1);
		//if (0<=l-1&&r+1<=9) printf("[%d %d]\n", l-1, r+1);
	}
	iter(i, 2 * n) for (int j = i; j <= 2 * n; j += i) fac[j].push_back(i);
	iter(i, 2 * n) {
		for (int l : s[i]) inc(l);
		for (int d : fac[i]) {
			ans[d] -= sum(i - d);
			//if (d == n - 1) printf("[%d %d %d]\n", i-d, i, sum(i-d));
		}
	}
	iter(i, n) printf("%d\n", ans[i] + m);
	return 0;
}


Measured memory_bytes: 31360
#include <iostream>
#include <string>
using namespace std;
int main(){
 string str;
 cin>>str;
 int len=str.size();
 int ans=len;
 for(int i=0;i<len/2;++i){
  if(str[i]==str[(len-1)-i]) ans-=2;
 }
 if(len%2==1) ans--;
 if(ans) ans/=2;
 cout<<ans<<endl;
 return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cmath>
#include<string>
#include<set>
#include<map>
#include<stdlib.h>
#include<stdio.h>
#include<vector>
#include<utility>
#include<stdbool.h>
using namespace std;
typedef long long ll;
#define N (1000000000+7)

int main(void) {
	ll n;
	cin >> n;
	vector<ll>x(n), y(n), h(n);
	for (ll i = 0;i < n;i++)cin >> x[i] >> y[i] >> h[i];
	for (ll k = 0;k < n;k++) {
		if (h[k] > 0) {
			for (ll i = 0;i <= 100;i++) {
				for (ll j = 0;j <= 100;j++) {
					ll H = h[k] + abs(x[k] - i) + abs(y[k] - j);
					bool flag = true;
					for (ll l = 0;l < n;l++) {
						if (h[l] != max(H - abs(x[l] - i) - abs(y[l] - j), (ll)0))flag = false;
					}
					if (flag) {
						cout << i << " " << j << " " << H << endl;
						return 0;
					}
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long cxor(long a){
    if(a%4==1) return 1;
    else if(a%4==2) return a+1;
    else if(a%4==3) return 0;
    else return a;
}
int main(){
    long a,b,c;
    cin >> a >> b;
    c = cxor(b)^cxor(a-1);
    if(a==0) c = cxor(b);
    cout << c << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
using namespace std;
int main()
{
	int x, t;
	cin>>x>>t;
    if(x>t)
    {
    	cout<<x-t<<endl;
    }
    if(x<t)
    {
    	cout<<0<<endl;
    }
    if(x==t)
    {
    	cout<<0<<endl;
    }
    return 0;
}

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

int N;
vector<int> v_list;

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

  int ans   = 0;
  int pre_h = 0;
  for(int i=0;i<N;i++) {
    if (pre_h <= v_list[i]) {
      pre_h = v_list[i];
      ans++;
    }
  }
  cout << ans << "\n";

#if 0
  cout << N << " " << "\n";
  for(auto s: v_list) cout << s << " "; 
  cout << "\n" ;
#endif
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

vector<int> args(4);

int dfs(int now,vector<int>& ops){
    if(now == 4){
        int ret = args[0];
        for(int i=1;i<4;i++){
            if(ops[i-1] == 0){
                ret += args[i];
            }else{
                ret -= args[i];
            }
        }
        return ret;
    }

    for(int i=0;i<2;i++){
        ops[now]=i;
        if(dfs(now+1,ops)==7) return 7;
    }
}

int main(){
    string s; cin >> s;
    for(int i=0;i<4;i++) args[i] = s[i]-'0';
    
    vector<int> ops(3,0);
    dfs(0,ops);

    cout << args[0];
    for(int i=0;i<3;i++){
        if(ops[i]==0) cout << "+";
        else cout << "-";
        cout << args[i+1];
    }
    cout << "=7" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pii pair<ll, ll>
#define SZ(x) ((int)(x).size())
#define endl "\n"
ll mod = 1e9 + 7;
//const double pi = acos(-1.0);
/*
ll kmp(string x)
{
    ll n= x.length();
    //cout<<x<<endl;
    vector<ll> lcp(x.length(), 0);
    for(ll i=1;i<n;i++)
    {
        ll j=lcp[i-1];
        while(j>0 && x[j]!=x[i])
            j=lcp[j-1];
        if(x[i]==x[j])
            j++;
        lcp[i]=j;
    }
    return lcp[n-1];
}

int N = 1000002;
int ar[100002];
void sieve()
{
    for(int i=1;i<=N;i++)
        ar[i] = 1;
    ar[0] = 0;
    for(int i=2;i*i<=N;i++)
    {
        if(ar[i] && i*i<=N)
        {
            for(int j = i*i; j<=N;j+=i)
                ar[j] = 0;
        }
    }
}

ll modex(ll a,ll b){
    if(b<=0){
        return 1;
    }
    if(b%2==0)
    {
        ll x = modex(a, b/2);
        return ((x*x)%mod);
    }
    else
        return ((a%mod * modex(a, b-1))%mod);
}

ll c[1010][1010];

ll combina(ll i, ll j){
        for (int i=0;i<=1005;i++)
        for (int j=0;j<=i;j++)
        {
            if (j==i||j==0)
                c[i][j]=1;
            else
            c[i][j]=c[i-1][j-1]+c[i-1][j];
            c[i][j]%=mod;
        }
        return c[i][j];
}
void find_fac(int x){
    vector<ll> di;
    for(ll i = 2; i*i <= x; i++)
    {
        if(x%i==0){
            di.push_back(i);
            while(x%i==0)
                x/=i;
        }
    }
    if(x > 1)
        di.push_back(x);
}
*/
int n, x;
vector<vector<ll> > dp;
vector<int> w;
vector<int> v;
ll recur(int i, int j){
    if(i>=n)
        return 0;
    if(j<0)
        return 0;
    if(dp[i][j]!=-1)
        return dp[i][j];
    ll x = recur(i+1, j);
    if(w[i]<=j){
        x = max(x, v[i] + recur(i+1, j-w[i]));
    }
    dp[i][j] = x;
    return dp[i][j];
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cout<<fixed;
    cout.precision(12);
    cin>>n>>x;
    w.resize(n);v.resize(n);
    for(int i=0;i<n;i++)
        cin>>w[i]>>v[i];
    dp.resize(n);
    for(int i=0;i<n;i++){
        dp[i].resize(x+1);
        for(int j=0;j<=x;j++)
            dp[i][j]=-1;
    }
    ll an = recur(0, x);
    cout<<an<<endl;
    return 0;
}


Measured memory_bytes: 81584
#include<bits/stdc++.h>
using namespace std;
const int maxn=653000+10;
const int mod=1e9+7;
int c[maxn];
int dp[105][maxn];
int main(){
    int n,k; cin>>n>>k;
    int d=0;
    for(int l=1,r;l<=n;l=r+1){
        r=n/(n/l);
        c[++d]=(r-l+1);
    }
    for(int i=1;i<=d;i++){
        (dp[1][i]+=dp[1][i-1]+c[i])%=mod;
    }
    for(int i=2;i<=k;i++){
        for(int j=1;j<=d;j++){
            dp[i][j]=(1ll*c[j]*dp[i-1][d-j+1]%mod)+dp[i][j-1];
            dp[i][j]%=mod;
        }
    }
    cout<<dp[k][d]<<endl;
}


Measured memory_bytes: 233728
// #155
// 経路は未実装

#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>

#define sqr(x) (x)*(x)

using namespace std;

const int Size = 1100;
const int Limit = 999999;

typedef struct {
  int x;
  int y;
} Points;

int N; // # of Building
int M; // # of Move
Points Building[Size+1]; // 配列の大きさは限界より大きくする
int Ans[Size+1][Size+1];
double d[Size+1][Size+1];

void solve(void) {
  for(int k=1; k<N+1; k++) {
    for(int i=1; i<N+1; i++) {
      for(int j=1; j<N+1; j++) {
	if(d[i][j] > d[i][k]+d[k][j]) {
	  d[i][j] = d[i][k]+d[k][j];
	  Ans[i][j]=Ans[i][k];
	}
      }
    }
  }
}

int main(void) {

  while(1) {
    cin>>N;
    if(N==0) {
      break;
    }
    for(int i=0; i<N; i++) {
      Building[i].x=Building[i].y=Limit;
    }
    for(int i=0; i<N; i++) {
      int tmp;
      cin>>tmp;
      cin>>Building[tmp].x;
      cin>>Building[tmp].y;
      Ans[tmp][tmp]=tmp;
    }

    for(int i=1; i<Size+1; i++) {
      for(int j=1; j<Size+1; j++) {
	d[i][j]=hypot((Building[i].x-Building[j].x), (Building[i].y-Building[j].y));
	if(d[i][j]>50.0 || Building[i].x==Limit || Building[j].x==Limit) {
	  d[i][j]=Limit;
	}
        Ans[i][j]=j;
      }
    }

    //cout<<d[1][3]<<" "<<d[3][9]<<" "<<d[9][20]<<" "<<d[20][11]<<" "<<d[11][6]<<" "<<d[6][22]<<endl;

    solve();

    //cout<<d[1][3]<<" "<<d[1][9]<<" "<<d[1][20]<<" "<<d[1][11]<<" "<<d[1][6]<<" "<<d[1][22]<<endl;

    cin>>M;
    for(int i=0; i<M; i++) {
      int from, to;
      cin>>from;
      cin>>to;
      if(d[from][to] == Limit) {
	cout<<"NA"<<endl;
      }
      else {
	cout<<from;
	while(from!=to) {
	  cout<<" "<<Ans[from][to];
	  from=Ans[from][to];
	}
	cout<<endl;
      }
    }
  }
}

Measured memory_bytes: 15380
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <string>
const int INF = 1 << 30;
using namespace std;

int n, k;

short int pt[300][300][300];
int X1[50], X2[50], Y1[50], Y2[50], D1[50], D2[50];
unsigned long long int uX[300], uY[300], uD[300];

int compress(int *x1, int *x2, unsigned long long int *unzip){
	vector<int> vec;
	for (int i = 0; i < n; i++){
		for (int j = -1; j <= 1; j++){
			int a = x1[i] + j, b = x2[i] + j;
			if (0 <= a) vec.push_back(a);
			if (0 <= b) vec.push_back(b);
		}
	}
	sort(vec.begin(), vec.end());
	vec.erase(unique(vec.begin(), vec.end()), vec.end());
	for (int i = 0; i < n; i++){
		x1[i] = find(vec.begin(), vec.end(), x1[i]) - vec.begin();
		x2[i] = find(vec.begin(), vec.end(), x2[i]) - vec.begin();
	}
	for (int i = 0; i < vec.size(); i++)
		unzip[i] = vec[i];
	return vec.size();
}

int main(){
	int W, H, D;
	unsigned long long int ans = 0;
	cin >> n >> k;
	for (int i = 0; i < n; i++){
		cin >> X1[i] >> Y1[i] >> D1[i];
		cin >> X2[i] >> Y2[i] >> D2[i];
	}
	W = compress(X1, X2, uX);
	H = compress(Y1, Y2, uY);
	D = compress(D1, D2, uD);
	for (int i = 0; i < n; i++){
		for (int j = X1[i]; j < X2[i]; j++){
			for (int m = Y1[i]; m < Y2[i]; m++){
				for (int l = D1[i]; l < D2[i]; l++){
					pt[j][m][l]++;
				}
			}
		}
	}
	for (int m = 0; m <D; m++){
		for (int j = 0; j < H; j++){
			for (int i = 0; i < W;i++){
				if (pt[i][j][m] >= k&&uX[i + 1] && uY[j + 1] && uD[m + 1]){
						ans += (uX[i+1] - uX[i]) * (uY[j+1] - uY[j]) * (uD[m+1] - uD[m]);
					}
				}
			}
		}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 51624
/*
─────────────────────
───────────████████──
──────────███▄███████
──────────███████████
──────────███████████
──────────██████─────
──────────█████████──
█───────███████──────
██────████████████───
███──██████████──█───
███████████████──────
███████████████──────
─█████████████───────
──███████████────────
────████████─────────
─────███──██─────────
─────██────█─────────
─────█─────█─────────
─────██────██────────
─────────────────────
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

#define int long long
#define read(a) int a; cin >> a;
#define readarr(a, n) int a[(n) + 1] = {}; fori(i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; fori(i, 1, n) {fori(j, 1, m) cin >> a[i][j];}
#define pb push_back
#define fi first
#define se second
#define rz resize
#define fori(i, a, b) for (int i = (a); i <= (b); i++)
#define ford(i, a, b) for (int i = (a); i >= (b); i--)
#define sort1(v) sort(v.begin(), v.end()) 
#define endl '\n'

using namespace std;
using namespace __gnu_pbds; 

typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair <int, int>> vpi;
typedef vector < vector <int> > vvi;

const long long inf2 = (long long)1e18;
const long long mod = (long long)(1e9+7);
const long long inf1 =(long long)(1e6+1);
 
signed main() 
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    read(h);
    map <int, int> mp;

    mp[1] = 1;

    for(int i = 2; i <= 1e12; i = i*2)
    {
        mp[i] = 2*mp[i/2] + 1;
    }
    int x;
    for(int i = 1; i <= h; i *= 2) x = i;
    cout << mp[x];
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pli pair<ll, int>
#define pb push_back

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

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; }

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

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w){}
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, int>;

const int MAX = 1e6+1;

long long 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(ll n, ll k){
  if(n >= MAX){
    ll tmp = 1;
    rep(i,k){
      tmp *= (n-i);
      tmp %= MOD;
    }
    return tmp*finv[k]%MOD;
  }

  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll POW(ll x, ll n){
  ll ret = 1;

  if(n < 0){// n < 0 にも対応
    n *= -1;
    x = inv[x];
  }

  while(0 < n){
    if(n%2 == 0){
      x = x*x%MOD;
      n /= 2;
    }
    else{
      ret = ret*x%MOD;
      n--;
    }
  }

  return ret;
}

vi MP(string s){
  vi A(s.size()+1);
  A[0] = -1;
  int j = -1;
  rep(i,s.size()) {
    while(j >= 0 && s[i] != s[j]) j = A[j];
    j++;
    A[i+1] = j;
  }
  return A;
}

vi Manacher(string s){
  vi R(s.size());
  int i = 0, j = 0;
  while(i < s.size()){
    while(i-j >= 0 && i+j < s.size() && s[i-j] == s[i+j]) ++j;
    R[i] = j;
    int k = 1;
    while(i-k >= 0 && i+k < s.size() && k+R[i-k] < j) R[i+k] = R[i-k], k++;
    i += k; j -= k;
  }
  return R;
}

vi Z_algorithm(string &s){
  vi Z(s.size());
  Z[0] = s.size();
  int i = 1, j = 0;
  while(i < s.size()){
    while(i+j < s.size() && s[j] == s[i+j]) j++;
    Z[i] = j;
    if(j == 0){++i; continue;}
    int k = 1;
    while(i+k < s.size() && k+Z[k] < j) Z[i+k] = Z[k], ++k;
    i += k; j -= k;
  }
  return Z;
}

int main(){
  int a,b; cin >> a >> b;
  for(int i = 1; i < 10001; i++) {
    int A = i*0.08;
    int B = i*0.1;
    if(a == A && b == B){
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
}


Measured memory_bytes: 256
# include "bits/stdc++.h"
std::pair<int,int> DR[] = {{-1,0},{0,1},{1,0},{0,-1},{-1,1},{-1,-1},{1,1},{1,-1}};
# define ll long long
# define clock (clock() * 1000.0 / CLOCKS_PER_SEC)
# define rc(s) return cout << s,0
# define rcg(s) cout << s;exit(0)
# define _ ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
# define db(x) cerr << #x << " = " << x << '\n'
# define pb push_back
# define mp make_pair
# define all(s) s.begin(),s.end()
# define sz(x) (int)((x).size())
//# define int ll
using namespace std;

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# define LOCAL
# 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 show(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
int gcd(int a, int b)
{
if(b) return gcd(b,a%b);
return a;
}mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

int n,a,b,c,d;

int32_t main(){_
	//freopen("input","r",stdin);
	cin >> n >> a >> b >> c >> d;
	string s;
	cin >> s;
	a--;
	b--;
	c--;
	d--;
	for(int i = a;i < c;i++)
	{
		if(s[i] == '#' && s[i + 1] == '#') rc("No");
	}
	for(int i = b;i < d;i++)
	{
		if(s[i] == '#' && s[i + 1] == '#') rc("No");
	}
	if(c < d) rc("Yes");
	for(int i = max(0,b - 1);i <= d - 1;i++)
	{
		if(s[i] == '.' && s[i + 1] == '.' && s[i + 2] == '.') rc("Yes");
	}
	rc("No");
	return 0;
}


Measured memory_bytes: 592
import fractions

def lcm(a, b):
  return a*b // fractions.gcd(a,b)

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


num = 1
for i in nums:
    num = lcm(num, i)
print(sum([num // i for i in nums]) % (10 ** 9 + 7))

Measured memory_bytes: 264676
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  vector<int> p(5); 
  int k;
  rep(i,5) cin >> p[i];
  cin >> k;

  for(int i = 0; i<4; ++i) for(int j = i+1; j<5; ++j){
    if(p[j]-p[i]>k) {
      cout << ":(" << endl;
      return 0;
    }
  }
  cout << "Yay!" << endl;
}


Measured memory_bytes: 256
S = input()

if S[0]==S[1]==S[2]==S[3]:
    print("No")
elif S[0]==S[1] and S[2]==S[3] or S[0]==S[2] and S[1]==S[3] or S[0]==S[3] and S[1]==S[2]:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define MOD 1000000007
#define test int t; cin>>t; while(t--)
#define ull unsigned long long int
#define ll long long int
#define PLL pair<long long, long long>
#define PII pair<int, int>
#define PUU pair<unsigned long long int, unsigned long long int>
#define UM unordered_map
#define mp make_pair
#define pb push_back
#define pf push_front
#define MM multimap
#define F first
#define S second
#define IT iterator
#define RIT reverse_iterator
#define FAST ios_base::sync_with_stdio(false);cin.tie();cout.tie();
#define IO freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
#define all(a) a.begin(),a.end()
using namespace std;

const ll maxn = 1e5;
const ll inf = 1e18;
const double pi = acos(-1);

int main(){

    FAST;
    int n; cin >> n;
    int arr[3][n]; ll dp[3][n];
    for(int i=0; i<n; i++)
        cin >> arr[0][i] >> arr[1][i] >> arr[2][i];

    for(int i=0; i<n; i++)
        {dp[0][i]=0; dp[1][i]=0; dp[2][i]=0;}

    dp[0][n-1]=arr[0][n-1];
    dp[1][n-1]=arr[1][n-1];
    dp[2][n-1]=arr[2][n-1];

    for(int i=2; i<=n; i++)
        {    
            dp[0][n-i]=arr[0][n-i]+max(dp[1][n-i+1], dp[2][n-i+1]);
            dp[1][n-i]=arr[1][n-i]+max(dp[0][n-i+1], dp[2][n-i+1]);
            dp[2][n-i]=arr[2][n-i]+max(dp[0][n-i+1], dp[1][n-i+1]);
        }
    
    cout << max(dp[0][0], max(dp[1][0], dp[2][0]));
    return 0;
}

Measured memory_bytes: 3840
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
typedef long long ll;

int main() {
    string s; cin >> s;
    char bf=' ';
    bool flag = false;
    int cnt = 0;
    rep(i, 0, s.size()) {
        if (flag) {
            cnt++;
            flag = false;
            continue;
        }
        if(s[i] == bf) {
            bf = ' ';
            flag = true;
        }
        else {
            bf = s[i];
            cnt++;
        }
    }
    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 3780
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
using namespace std;
typedef long long ll;
int main(){
  ll n = 0;
  cin >> n;
  vector<ll> num(n + 1);
  for(int i = 0;i <= n;i++){
    cin >> num[i];
  }
  ll res = 0;
  for(int i = 0;i <= n - 1;i++){
    ll kazu = 0;
    cin >> kazu;
    if(num[i] >= kazu){
      num[i] -= kazu;
      res += kazu;
    }
    else{
      kazu -= num[i];
      res += num[i];
      //cout << kazu << " " << res << endl;
      num[i] = 0;
      if(num[i + 1] >= kazu){
        num[i + 1] -= kazu;
        res += kazu;
      }
      else{
        res += num[i + 1];
        num[i + 1] = 0;
      }
    }
    //cout << res << " i" << i << endl;
  }
  cout << res << endl;
  return 0;
}

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

using namespace std;

int main() {
  int N = 0;
  int X = 0;
  
  cin >> N >> X;
  
  int tmp = N * 500;
  if (N * 500 >= X) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  } 
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let mut ans: Vec<usize> = Vec::new();
    loop {
        let w: usize = read();
        let h: usize = read();
        if w == 0 || h == 0 {
            break;
        }
        let map: Vec<Vec<u8>> = (0..h).map(|_| (0..w).map(|_| read()).collect()).collect();
        let mut seen: Vec<Vec<bool>> = (0..h).map(|_| (0..w).map(|_| false).collect()).collect();
        let mut sum = 0;
        for hi in 0..h {
            for wi in 0..w {
                if dfs(&map, &mut seen, wi, hi, w, h) {
                    sum += 1;
                }
            }
        }
        ans.push(sum);
    }
    for i in ans {
        println!("{}", i);
    }
}

fn dfs(map: &Vec<Vec<u8>>, seen: &mut Vec<Vec<bool>>, x: usize, y: usize, w: usize, h: usize) -> bool {
    if seen[y][x] || map[y][x] == 0 {
        seen[y][x] = true;
        return false;
    }
    seen[y][x] = true;
    if x > 0 && y > 0 {
        dfs(map, seen, x-1, y-1, w, h);
    }
    if x > 0 {
        dfs(map, seen, x-1, y, w, h);
    }
    if y > 0 {
        dfs(map, seen, x, y-1, w, h);
    }
    if x < w-1 && y < h-1 {
        dfs(map, seen, x+1, y+1, w, h);
    } 
    if x < w-1 {
        dfs(map, seen, x+1, y, w, h);
    }
    if y < h-1 {
        dfs(map, seen, x, y+1, w, h);
    }
    if x > 0 && y < h-1 {
        dfs(map, seen, x-1, y+1, w, h);
    }
    if x < w-1 && y > 0 {
        dfs(map, seen, x+1, y-1, w, h);
    }
    return true;
}



Measured memory_bytes: 5224
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define FOR(n) for(int i=0;i<n;i++)
#define FORJ(n) for(int j=0;j<n;j++)
#define PRN(n) printf("%d\n",n)
#define PRF(n) printf("%lf\n",n)
#define PRL(n) printf("%lld\n",n)
#define PRS(s) printf("%s\n",s)
#define PRC(c) printf("%c",c)
#define INF 10000000000
#define mod 1000000007
typedef long long int ll;
ll u(const void *a, const void *b){return *(ll*)a-*(ll*)b;}
ll d(const void *a, const void *b){return *(ll*)b-*(ll*)a;}
ll min(ll a,ll b){
  if(a>b)return b;
  return a;
}
ll max(ll a,ll b){
  if(a>b)return a;
  return b;
}
ll gcd(ll a,ll b){
  if(!b)return a;
  return gcd(b,a%b);
}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
int kt(ll a){
  int sum=0;
  while(a){
    a/=10;
    sum++;
  }
  return sum;
}
int ks(ll a){
  int sum=0;
  while(a){
    sum+=a%10;
    a/=10;
  }
  return sum;
}
int main(void){
  int ans,n,m;
  scanf("%d %d",&n,&m);
  int a[n];
  ans=n-2*m;
  PRN(max(ans,0));
  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<string>
#include<string.h>
#include<algorithm>
#include<vector>
using namespace std;
const int maxn = 2e5+10;
int x[maxn],y[maxn];
vector <int> vec;
int ans;
struct Node
{
	int l,r;
	bool operator <(const Node &p)const
	{
		return r<p.r;
	}
}node[maxn];
int dp[maxn];
int n;
void add(int x,int y)
{
	while(x<maxn)
	{
		dp[x]=max(dp[x],y);
		x+=x&-x;
	}
}
int Max(int x)
{
	int res=0;
	while(x)
	{
		res=max(res,dp[x]);
		x-=x&-x;
	}
	return res;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d%d",&x[i],&y[i]);
	for(int i=1;i<=n;i++) node[i].l=x[i]-y[i],node[i].r=x[i]+y[i];
	for(int i=1;i<=n;i++) vec.push_back(node[i].l),vec.push_back(node[i].r);
	sort(vec.begin(),vec.end());
	vec.erase(unique(vec.begin(),vec.end()),vec.end());
	for(int i=1;i<=n;i++)
	node[i].l=lower_bound(vec.begin(),vec.end(),node[i].l)-vec.begin()+1,
	node[i].r=lower_bound(vec.begin(),vec.end(),node[i].r)-vec.begin()+1;
	sort(node+1,node+1+n);
	int tmp;
	for(int i=1;i<=n;i++)
	{
		tmp=Max(node[i].l)+1;
		ans=max(ans,tmp);
		add(node[i].r,tmp);
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 3444
N,M = [int(i) for i in input().split()] #Nがスイッチの数、Mは電球の数
sss = []
for i in range(M):
    buff = [int(i)-1 for i in input().split()][1:]
    onoff = [0 for i in range(N)]
    for j in buff:
        onoff[j]=1
    sss.append(onoff)

ppp = [int(i) for i in input().split()]

ct=0
for i in range(1<<N):
    bitcode = [int(i) for i in list(bin(i)[2:].zfill(N))]
    for s,p in zip(sss,ppp):
        if sum(j*k for j,k in zip(s,bitcode))%2!=p:
            break
    else:
        ct+=1

print(ct)

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
using LL = long long;

LL solve(LL N, LL X){
    LL t = N;
    N -= X;
    while (X > 0){
        LL q = N / X;
        LL r = N % X;
        t += 2 * q * X;
        N = X;
        X = r;
    }
    return t - N;
}

int main() {
    LL N, X;
    cin >> N >> X;
    cout << solve(N, X) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i = ((ll) a); i < ((ll) n); i++)
#define INF 1e20
using namespace std;
typedef long long ll;

struct edge {
  ll v;
  double dist;
};

struct state {
  ll v;
  double cost;

  bool operator>(const state s) const {
    return cost > s.cost;
  }
};

vector<double> dijkstra(vector< vector<edge> > &E, ll S) {
  vector<double> dp(E.size(), INF);
  priority_queue<state, vector<state>, greater<state> > q;
  q.push((state) { S, 0.0 });

  while(!q.empty()) {
    ll v = q.top().v;
    double cost = q.top().cost;
    q.pop();

    if(dp[v] <= cost) continue;
    dp[v] = cost;

    REP(i, 0, E[v].size()) {
      ll nv = E[v][i].v;
      double ncost = cost + E[v][i].dist;
      if(dp[nv] > ncost) q.push((state) { nv, ncost });
    }
  }

  return dp;
}

int main(void) {
  double SX, SY, GX, GY; cin >> SX >> SY >> GX >> GY;
  ll N; cin >> N;
  vector<double> X(N + 2), Y(N + 2), R(N + 2);
  REP(i, 0, N) cin >> X[i] >> Y[i] >> R[i];
  X[N] = SX; Y[N] = SY; R[N] = 0;
  X[N + 1] = GX; Y[N + 1] = GY; R[N + 1] = 0;

  vector< vector<edge> > E(N + 2);
  REP(i, 0, N + 2) REP(j, i + 1, N + 2) {
    double dx = (X[i] - X[j]);
    double dy = (Y[i] - Y[j]);
    double dist = sqrt(dx * dx + dy * dy);
    double d = max(dist - (R[i] + R[j]), 0.0);
    E[i].push_back((edge) { j, d });
    E[j].push_back((edge) { i, d });
  }

  vector<double> dp = dijkstra(E, N);
  printf("%.15lf\n", dp[N + 1]);
}


Measured memory_bytes: 26752
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{
    class Program
    {
        public static void Main()
        {
            new Program().Solve();
        }

        void Solve()
        {
            int x = int.Parse(Console.ReadLine());
            int a = int.Parse(Console.ReadLine());
            int b = int.Parse(Console.ReadLine());
            Console.WriteLine((x - a) % b);
        }
    }
}


Measured memory_bytes: 13140
from heapq import heappush, heappop
def dijkstra(graph:list, node:int, start:int) -> list:
    # graph[node] = [(cost, to)]
    inf = float('inf')
    dist = [inf]*node

    dist[start] = 0
    heap = [(0,start)]
    while heap:
        cost,thisNode = heappop(heap)
        for NextCost,NextNode in graph[thisNode]:
            dist_cand = dist[thisNode]+NextCost
            if dist_cand < dist[NextNode]:
                dist[NextNode] = dist_cand
                heappush(heap,(dist[NextNode],NextNode))
    return dist
    # dist = [costs to nodes]



from collections import defaultdict
from heapq import heappop, heappush

class Graph(object):

    def __init__(self):
        self.graph = defaultdict(list)

    def __len__(self):
        return len(self.graph)

    def add_edge(self, From, To, cost=1):
        self.graph[From].append((To,cost))

    def get_nodes(self):
        return self.graph.keys()

class Dijkstra(object):

    def __init__(self, graph, start):
        self.g = graph.graph
        self.dist = defaultdict(lambda:float('inf'))
        self.dist[start] = 0
        self.prev = defaultdict(lambda: None)
        self.Q = []
        heappush(self.Q,(self.dist[start], start))

        while  self.Q:
            dist_u, u = heappop(self.Q)
            if self.dist[u] < dist_u:
                continue
            for v, cost in self.g[u]:
                alt = dist_u + cost
                if self.dist[v] > alt:
                    self.dist[v] = alt
                    self.prev[v] = u
                    heappush(self.Q,(alt, v))

    def shortest_distance(self, goal):
        return self.dist[goal]

    def shortest_path(self, goal):
        path = []
        node = goal
        while node is not None:
            path.append(node)
            node = self.prev[node]

        return path[::-1]

g = Graph()
N = int(input())
for i in range(N-1):
    u,v,w = map(int,input().split())
    g.add_edge(u-1,v-1,w)
    g.add_edge(v-1,u-1,w)

dijkstra = Dijkstra(g,0)
for i in range(N):
    print(dijkstra.shortest_distance(i)%2)

Measured memory_bytes: 111960
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

pub fn read_n<T: FromStr>(n: usize) -> Vec<T> {
    read_n_logic::<T>(n, vec![])
}

pub fn read_n_logic<T: FromStr>(n: usize, mut a: Vec<T>) -> Vec<T> {
    match n {
        0 => a,
        _ => {
            a.push(read::<T>());
            read_n_logic(n - 1, a)
        }
    }
}
use std::cmp::{max, min};

fn main() {
    let s: String = read();
    let sa: Vec<char> = s.chars().collect();
    if sa[3] == sa[2] && sa[4] == sa[5] {
      println!("{}", "Yes");
    } else {
      println!("{}", "No");
    }

}


Measured memory_bytes: 4352
n=int(input())
A=list(map(int,input().split()))
ans=0
for i in range(n):
        for j in range(i):
                for k in range(j):
                        if A[i]!=A[j] and A[j]!=A[k] and A[k]!=A[i]:
                                if A[i]+A[j] > A[k] and  A[i]+A[k] > A[j] and  A[k]+A[j] > A[i]:
                                        ans+=1
print(ans)

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

#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
#define mod 1000000007
#define inf 1e18
#define endl "\n"

typedef pair<int,int> pi;
typedef pair<ll,ll> pl;

int main()
{
    fastio
    ll test=1,n,a,b,c,count;

    // cin >> test;

    while(test--)
    {
        cin >> a >> b>> c >> n ;
        count=0;
        while(a>=b)
        {
            b*=2;
            count++;
        }

        while(b>=c)
        {
            c*=2;
            count++;
        }

        cout << (count<=n ? "Yes\n" : "No\n");

    }


    return 0;
}

Measured memory_bytes: 3636
#include<cstring>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<ctime>
#define ll long long
using namespace std;
const int maxn=200005;
 
int n,a[maxn],lef[maxn];
ll ans=0;
 
int main(){
    scanf("%d",&n);
    for(int i=1,las=0;i<=n;i++){
        scanf("%d",a+i),lef[i]=las;
        if(a[i]) las=i;
    }
     
    for(int i=1,now,j;i<=n;i++){
        now=a[i];
         
        for(j=lef[i];j;now^=a[j],j=lef[j]) if(now&a[j]) break;
         
        ans+=(ll)(i-j);
         
    }
     
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 5324
#include <bits/stdc++.h>
#define per(i,a,n) for(int i=a;i<=n;i++)
#define ls l+mid>>1
#define rs mid+1+r>>1
using namespace std;
const int N=5e5+100;
deque<char>q;
string s;
int main()
{
  cin>>s;
  int qz;cin>>qz;
  for(int i=0;i<s.size();i++)
    q.push_back(s[i]);
  bool kk=1;
  while(qz--){
    int t,f;
    char c;
    cin>>t;
    if(t==1) kk=!kk;
    else {
        cin>>f>>c;
        if(f==1){
            if(kk)q.push_front(c);
             else q.push_back(c);
        }
        else
        {
            if(kk)q.push_back(c);
            else q.push_front(c);
        }
    }
  }
  string ans="";
  while(q.size()){
     ans.push_back(q.front());
     q.pop_front();
  }
  if(!kk) reverse(ans.begin(),ans.end());
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 1412
def is_prime(q, k=50):
    q = abs(q)
    if q == 0:
        return False
    elif q == 2:
        return True
    return pow(2, q-1, q) == 1


n = int(input())
result = 0
for i in range(n):
    x = int(input())
    if is_prime(x):
        result += 1

print(result)




Measured memory_bytes: 5608
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <set>
#include <queue>

using namespace std;
typedef long long ll;
#define MOD 1000000007

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

    int d = int(floor(log10(N)))+1, ans=0;

    for(int i=1; i<d+1; i+=2) {
        if(i == d) {
            if(i == 1) ans += N;
            else ans += N - int(pow(10, i-1)) + 1;
        } else {
            ans += int(pow(10, i)) - int(pow(10, i-1));
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
int main()
{
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    if((a==5&&b==5&&c==7)||(a==5&&b==7&&c==5)||(a==7&&b==5&&c==5))
    {
        printf("YES\n");
    }
    else{
        printf("NO\n");
    }
 return 0;
}


Measured memory_bytes: 1624
fun main(args: Array<String>) {
    val s = readLine()!!
    val n = s.length + 1
    val ansArray = Array(n) { 0L }

    var cur = 2L
    var j = 1
    if (s.first() == '<') {
        ansArray[0] = 0
        ansArray[1] = 1
        cur = 2L
        j = 1
        while (true) {
            if (j >= s.length || s[j] != '<') break
            ansArray[j + 1] = Math.max(cur, ansArray[j + 1])
            j++
            cur++
        }
    }

    if (s.last() == '>') {
        ansArray[n - 1] = Math.max(0,ansArray[n - 1])
        ansArray[n - 2] = Math.max(1,ansArray[n - 2])
        cur = 2L
        j = s.length - 2
        while (true) {
            if (j < 0 || s[j] != '>') break
            ansArray[j] = Math.max(cur, ansArray[j])
            j--
            cur++
        }
    }

    for (i in 0..(s.length - 2)) {
        if (s[i] == '>' && s[i + 1] == '<') {
            ansArray[i] = Math.max(1, ansArray[i])
            ansArray[i + 1] = Math.max(0, ansArray[i + 1])
            ansArray[i + 2] = Math.max(1, ansArray[i + 2])

            cur = 2L
            j = i - 1
            while (true) {
                if (j < 0 || s[j] != '>') break
                ansArray[j] = Math.max(cur, ansArray[j])
                j--
                cur++
            }
            cur = 2L
            j = i + 2
            while (true) {
                if (j >= s.length || s[j] != '<') break
                ansArray[j + 1] = Math.max(cur, ansArray[j + 1])
                j++
                cur++
            }
        }
    }

    println(ansArray.sum())
}

Measured memory_bytes: 51000
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main() {
	int n, m;
	cin >> n >> m;
	long long int ans = 1;
	if((m == n - 1)||(m == n + 1)||(n == m - 1)||(n == m + 1)||(m == n)) {
		for(int i = 1; i <= m; i++) {
			ans *= i;
			ans %= MOD;
		}
		for(int i = 1; i <= n; i++) {
			ans *= i;
			ans %= MOD;
		}
		if(n == m) {
			ans *= 2;
			ans %= MOD;
		}
	} else {
		ans = 0;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	char c[3][4];
	int i;
	for (i = 0; i < 3; i++) {
		if (scanf("%3s", c[i]) != 1) return 1;
	}
	for (i = 0; i < 3; i++) putchar((unsigned char)c[i][i]);
	putchar('\n');
	return 0;
}


Measured memory_bytes: 128
using System;

namespace ConsoleApplication4
{
    class Program
    {
        static void Main(string[] args)
        {
            int max = int.Parse(Console.ReadLine());

            for (int i = 3; i <= max; i++)
                if (i % 3 == 0 || i.ToString().Contains("3"))
                    Console.Write(" " + i.ToString());

            Console.WriteLine();
        }
    }
}



Measured memory_bytes: 9824
"""
int #整数
float #小数

#for
for name in fruits: #fruitの頭から操作
    print(name)
    
#リスト
list0 = [] #リスト生成
list0 = [1,2,3,4] #初期化
list0 = [0]*10 #[0,0,0,0,0,0,0,0,0,0]
list1= [i for i in range(10)] #>>> [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
list1 = list(map(int, input().split()))　# 複数の入力をリストに入れる
number=[int(input()) for i in range(int(input()))] #複数行の入力
list1 = list1 + [6, 7, 8] #リストの追加
list2.append(34) #リストの追加　最後に（）内が足される
list.insert(3,10) #リストの追加　任意の位置（追加したい位置,追加したい値）
len(list4) #リストの要素数
max(sa) #list saの最小値
list5.count(2) #リスト内の2の数
list1.sort() #並び替え小さい順
list1.sort(reverse=True)  #並び替え大きい順
set(list1) #list1内の重複している要素を削除し、小さい順に並べる

abs(a) #aの絶対値
max(a,b) min(a,b) #最大値　最小値
text1 = text1.replace("34","test") #text1内の"34"を"test"に書き換える(文字列内の文字を入れ替える)

exit(0) #強制終了
"""
N=input()
if N[-1]=="3":
    print("bon")
elif N[-1]=="0" or N[-1]=="1" or N[-1]=="6" or N[-1]=="8":
    print("pon")
else:
    print("hon")

Measured memory_bytes: 8984
from bisect import bisect_left, bisect_right

n = int(input())
al = list(map(int, input().split()))
al.sort()
ai = al[-1]
if ai%2 == 0:
    aj_best = ai//2
    ind = bisect_right(al, aj_best) - 1
    ind = ind if 0 <= ind < n else None
    val1 = al[ind] if ind is not None else 0

    ind = bisect_left(al, aj_best)
    ind = ind if 0 <= ind < n else None
    val2 = al[ind] if ind is not None else ai

    if abs(aj_best-val1) <= abs(aj_best-val2):
        aj = val1
    else:
        aj = val2


else:
    aj_best = ai//2
    ind = bisect_right(al, aj_best) - 1
    ind = ind if 0 <= ind < n else None
    val1 = al[ind] if ind is not None else 0

    ind = bisect_left(al, aj_best)
    ind = ind if 0 <= ind < n else None
    val2 = al[ind] if ind is not None else ai

    if abs(aj_best-val1) <= abs(aj_best+1-val2):
        aj = val1
    else:
        aj = val2

print(ai,aj)

Measured memory_bytes: 20520
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return;std::cout << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T> void DEBUG(string str, T e){if(DEBUG_OUT == false)return;std::cout <<str<<" ";DEBUG(e);};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }


//CODE
void solve(void)
{  
  int A,B,C,D;
  cin>>A>>B>>C>>D;
  if((abs(B-A) <= D && abs(C - B) <=D)|| abs(C - A) <= D)
  {
    cout<<"Yes"<<endl;
  }
  else
  {
    cout<<"No"<<endl;
  }
  
  
  
  return;
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();
  

 
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

	static int N, M, K;
	
	void run() {

		//
		// 画面入力
		//
		Scanner sc = new Scanner(System.in);
    	N = sc.nextInt();
    	M = sc.nextInt();
    	K = sc.nextInt();

    	//
    	// グラフ作成 i=0は使用しないのでN+1作成する
    	// Adjacency list representation 
    	// 0.05(s) 可読性悪
    	//
    	List<List<Integer>> graph_friends = new ArrayList<List<Integer>>();
    	List<List<Integer>> graph_block = new ArrayList<List<Integer>>();
    	for (int i=0; i<N+1; i++) {
    		graph_friends.add(new ArrayList<Integer>());
    		graph_block.add(new ArrayList<Integer>());
    	}
    	
    	
    	UnionFind fr = new UnionFind(N+1);
    	// 友達入力、UniongetRootの計算
    	for (int i=0; i<M; i++) {
        	int a=sc.nextInt();
        	int b=sc.nextInt();
        	graph_friends.get(a).add(b);
        	graph_friends.get(b).add(a);
        	fr.unite(a, b); // getRootTree作成
    	}
    	//System.out.println(graph_friends);

    	// ブロック入力
    	for (int i=0; i<K; i++) {
        	int a=sc.nextInt();
        	int b=sc.nextInt();
        	// ルートが同じものだけ数える
        	if(fr.sameRoot(a, b)){
            	graph_block.get(a).add(b);
            	graph_block.get(b).add(a);
        	}
    	}
    	//System.out.println(graph_block);

    	//
    	// getRoot Tree
    	//
    	for(int i=1; i<N+1; i++){

    		/* これが遅い
    		List<Integer> known_list =  new ArrayList<Integer>();
    		for(int j=0; j<N+1; j++){
    			if(fr.sameRoot(i, j)){
    				known_list.add(j);
    			}
    		}
     		
        	// known_listから友達とブロックを引く
        	known_list.removeAll(graph_friends.get(i));
        	known_list.removeAll(graph_block.get(i));
    		*/

           	System.out.print(fr.size(fr.getRoot(i)) - graph_friends.get(i).size() - graph_block.get(i).size() - 1 + (i!=N ? " ":""));
    	}
   	
    	sc.close();
	}

	public class UnionFind {
        int[] parents, sizes;
 
        UnionFind(int n) {
            parents = new int[n];
            sizes = new int[n];
            for(int i = 0; i < n; i++) {
                parents[i] = i;
                sizes[i] = 1;
            }
        }
 
        public int getRoot(int x) {
            if (x == parents[x]){
            	return x;
            }
            return parents[x] = getRoot(parents[x]);
        }
 
        public void unite(int x, int y) {
            x = getRoot(x);
            y = getRoot(y);
            // 同じツリーなので統合不要
            if (x == y) return;
            // 違うツリーを統合。サイズの小さい方を大きい方に統合する。
            if (size(x) < size(y)) {
                int temp = x;
                x = y;
                y = temp;
            }
        	sizes[getRoot(y)] += sizes[x];
            parents[x] = y;
        }
 
        public boolean sameRoot(int x, int y) {
            return getRoot(x) == getRoot(y);
        }
 
        public int size(int x) {
            return sizes[getRoot(x)];
        }
        
     }
	
    public static void main(String[] args) {
        new Main().run();
    }
}

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

int main(){
    ios::sync_with_stdio(false);
    
    int a, b, N, T, menor = 1001;
    cin >> N >> T;
    for(int i =0; i< N; i++){
        cin >> a >> b;
        if(a < menor && b <= T){
            menor = a;
        }
    }

    if(menor == 1001) {
        cout << "TLE" <<endl;
    }
    else{
        cout << menor << endl;

    }
}

Measured memory_bytes: 256