akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define FIN         ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ii          pair<int,int>
#define F           first
#define S           second
#define pb          push_back
#define all(x)      (x).begin(),(x).end()
#define rall(x)     (x).rbegin(),(x).rend()
#define fore(i,a,b) for(int i = a;i < b; i+= 1)
#define forr(i,a)   for(int i = a; i >= 0; i--)
#define fori(i,m)   for(auto i = m.begin(); i != m.end(); i++) 
#define w(t)        while(t--)
#define sz(s)       int(s.size())
#define cls(a,car)  memset(a,car,sizeof (a))
#define db(x)       cerr << #x << " is " << x << '\n'
#define FL          freopen("input.txt", "r", stdin),freopen("output.txt", "w", stdout);
#define EjecuteTime cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"
#define angle(x)    double(x * acos(-1) / 180.0)
using namespace std;
typedef long long   ll;
typedef vector<int> vi;
typedef vector<ii>  vii;
const int N = 1 * 1e5 + 5;
const ll mod = 1e9 + 7;
const double EPS = 1e-9;
int dx[] = {1, 0}, dy[] = {0, 1};
//int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
//int dx[] = {2, 1, -1, -2, -2, -1, 1, 2}, dy[] = {1, 2, 2, 1, -1, -2, -2, -1};
//int dx[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy[] = {0 ,1, 1, 1, 0, -1, -1, -1};
// fflush(stdout)
// cout << flush
// a + b = a ^ b + 2 * (a & b)
int sumMod(int a, int b){return 0LL + a + b > mod ? a + b - mod : a + b;}
int n;
double v[3010];
double dp[3010][3010];
double f(int i, int tail){
    if(i == n){
        return 1;
    }
    double &ans = dp[i][tail];
    if(ans < 0){
        ans = 0;
        int head = n - tail;
        if(head > tail + 1)
            ans += f(i + 1, tail + 1) * (1.0 - v[i]);
    
        ans += f(i + 1, tail) * v[i];
    }
    return ans;
}
int main(){
    //FL;
    FIN;
    cin >> n;
    for(int i = 0; i < n; i++)
        cin >> v[i];
    for(int i = n; i >= 0; i--){
        for(int tail = 0; tail < n; tail++){
            double &ans = dp[i][tail];    
            if(i == n){
                ans = 1;
                continue;
            }
            ans = 0;
            ans += dp[i + 1][tail] * v[i];
            int head = n - tail;
            if(head > tail + 1)
                ans += dp[i + 1][tail + 1] * (1.0 - v[i]);
        }
    }
    
    cout << fixed << setprecision(9) << dp[0][0] << '\n';
    EjecuteTime;
    return 0;
}       

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

#define int long long
using ll = long long;
using ld = long double;
using intpair = pair<int, int>;
using intmap = map<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
const int MOD = 1e9 + 7;
inline int mod (ll a, int m = MOD) { return (a % m + m) % m; }
inline bool bit (ll b, ll i) { return b & (1 << i); }
inline ll ceiv (ll a, ll b) { return (a + b - 1) / b; }
//struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;

#define debug(x) cerr << #x << ": " << x << '\n'
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()

signed main() {
    bool x; cin >> x;
    cout << !x << endl;
}

Measured memory_bytes: 3588
#include <algorithm>
#include <iostream>
#include <queue>
#include <map>

using namespace std;

int main() {
	int n, k;
	cin >> n >> k;
	map<int, int> m;
	for (int i = 0; i < n; ++i) {
		int a;
		cin >> a;
		++m[a];
	}
	if (m.size() <= k) {
		cout << 0;
		return 0;
	}
	priority_queue<int> q;
	for (auto p: m) {
		q.push(p.second);
	}
	int ans = n;
	for (int i = 0; i < k; ++i) {
		ans -= q.top();
		q.pop();
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 10748
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<long, long>;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
#define rep(i, n) for(int i = 0; i<n; i++)
#define rep_s(i, start, n) for(int i= start;  i<n; i++)
#define ALL(a) (a).begin(), (a).end()
string alphabet_upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alphabet_lower  = "abcdefghijklmnopqrstuvwxyz";

/*
using edge = struct {int to; ll cost;};
vector<edge> tree[limit];
ll depth[limit];

void dfs(int v, int p, ll d){
  depth[v] = d;
  //cout <<"v: " << v << endl;
  for (auto &e: tree[v]){
    //cout << "e.to: " << e.to << endl;
    if (e.to == p) continue;
    dfs(e.to, v, d+e.cost);
  }
}
*/
int keta_sum(int num){
  int dig, sum = 0;
  while(num){
    dig = num % 10;
    sum = sum + dig;
    num = num / 10;
  }
  return sum;
}


int main(void){
  ll N, A, B, W, H, C, D;
  cin >> A >> B;
  int grid[102][102];
  rep(i, 102) rep(j, 102) grid[i][j] =-1;
  rep_s(i, 1, 51) rep_s(j, 1, 101) grid[i][j] = 1;
  rep_s(i, 1, 51) rep_s(j, 1, 101) grid[i+50][j] = 0; 
  int count_a = 0, count_b = 0;
  rep_s(i,1, 50) {
    rep_s(j, 1, 101) {
      if (count_a == A-1) goto Next;
      if (grid[i-1][j]!=0 && grid[i][j-1]!=0 && grid[i+1][j]!=0 && grid[i][j+1]!=0){
        if (grid[i-1][j-1]!=0 && grid[i-1][j+1]!=0 && grid[i+1][j-1]!=0 && grid[i+1][j+1]!=0){
          grid[i][j] = 0;
          count_a++;
         
        }
      }
    }
  }
  Next:
  rep_s(i,52, 101) {
    rep_s(j, 1, 101) {
      if (count_b == B-1) goto finished;
      if (grid[i-1][j]!=1 && grid[i][j-1]!=1 && grid[i+1][j]!=1 && grid[i][j+1]!=1){
        if (grid[i-1][j-1]!=1 && grid[i-1][j+1]!=1 && grid[i+1][j-1]!=1 && grid[i+1][j+1]!=1){
          grid[i][j] = 1;
          count_b++;
        }
      }
    }
  }
  finished:
  cout << 100 << " " << 100 << endl;
  rep_s(i, 1, 101){
    rep_s(j, 1, 101){
      if (grid[i][j] == 0) cout << ".";
      else if (grid[i][j] == 1) cout <<"#";
    }
    cout << endl;
  }
}


Measured memory_bytes: 256
A[9999],B[9999];z(int*a,int*b){return*b-*a;}main(n,i,j){for(;scanf("%d",&n),n;puts(i>n?"No":"Yes")){for(i=0;i<n;i++)scanf("%d",A+i);for(i=0;i<n;i++)scanf("%d",B+i);for(i=qsort(A,n,4,z);i<n;A[i++]?i=n+1:1)for(j=0;j<n;j++)if(B[j])A[i]--,B[j]--;}exit(0);}

Measured memory_bytes: 732
a,b,c=map(int,input().split())
a1=(abs(a)-0)%c
if(a==0):
    if(b%2==0):
        print(0)
    else:
        print(c)
if(a>0):
    a2=a1-c
    ma1=int(a/c)
    ma2=ma1+1
    a3=abs(a2)
    if(b>=ma2 and b>ma1):
        if((b-ma1)%2==0):
            print(a1)
        else:
            print(abs(a2))
    if(b==ma1):
        print(a1)
    if(b<ma1):
        print(a-(b*c))
if(a<0):
    a2=abs(a1-c)
    ma1=((a1-(2*a1))-(a))
    ma1=int(ma1/c)
    ma2=ma1+1
    if(b>=ma2 and b>ma1):
        if((b-ma1)%2==0):
            print(a1)
        else:
            print(abs(a2))
    if(b==ma1):
        print(a1)
    if(b<ma1):
        print(abs(a+(b*c)))
    
    
        

Measured memory_bytes: 9244
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <iomanip>
#include <math.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define repf(i, a, b) for (int i = (int)a; i < (int)b; i++)
#define repr(i, a, b) for (int i = (int)a; i > (int)b; i--)
#define all(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int infi = 1147483600;
const ll infl = 4e18 + 5;
const char ENDL = '\n';
//cout << fixed << setprecision(17) << res << endl;
const ll MOD = 998244353;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    cout << (a + b - 1) / a << ENDL;
}

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

using ll = long long;

int n, k;
ll r;

int main(){
    scanf("%d%d", &n, &k);
    if(!k){ printf("%lld\n", 1LL * n * n); return 0; }
    for(int i = k + 1; i <= n; i++){
        r += n / i * (i - k) + max(0, n % i + 1 - k);
    }
    printf("%lld\n", r);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
		#include <bitset>
		using namespace std;
		#define ll long long 
		#define ld long double
		#define MOD 1000000007
		#define mod9 1000000009
		#define mod 1000003
		#define fast ios_base :: sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
		#define mp make_pair
		#define pb push_back
		#define ct ll t;cin>>t;while(t--)
		#define bi begin()
		#define ei end()
		#define fi first 
		#define se second   	
		bool isPrime(ll n) 
		{ 
			// Corner case 
			if (n <= 1) 
				return false; 
			
			// Check from 2 to n-1 
			for (ll i = 2; i*i <= n; i++) 
				if (n % i == 0) 
					return false; 
			
			return true; 
		}
		long long binpow(long long a, long long b) {
			long long res = 1;
			while (b > 0) {
				if (b & 1)
					res = (res%mod) * (a%mod);
				a = (a%mod) * (a%mod);
				b >>= 1;
			}
			return res%mod;
		}

		bool compare(const pair<ll,ll>&a,const pair<ll,ll>&b)
		{
			return (a.se<b.se);
		}
		ll lcm(ll a,ll b)
		{
			return(a*b)/__gcd(a,b);
		}
		// vector<ll>s;
		void SieveOfEratosthenes() 
		{  
			ll n=10005;
			bool prime[1000005]; 
			memset(prime, true, sizeof(prime)); 
			// s[0]=1;
			// s[1]=1;
			for (int p=2; p*p<=n; p++) 
			{ 
				
				if (prime[p] == true) 
				{   
					for (int i=p*p; i<=n; i += p) {
						prime[i] = false; 
						// s[i]=1;
						}
				} 
			} 
			for(ll i=2;i<10005;i++)
			{
				if(prime[i])
				{
					// s.pb(i);
				}
			}
		} 
		void eea(ll a, ll b, ll & x, ll & y) {
		if (a == 0) {
			x = 0;
			y = 1;
			return ;
		}
		ll x1, y1;
		eea(b % a, a, x1, y1);
		x = y1 - (b / a) * x1;
		y = x1;
		return ;
	}
	ll modinverse(ll a,ll m)
	{
		ll x, y;
		eea(a, m, x, y);
		if (__gcd(a,m) != 1) {
		return -1;
		}
	else {
		x = (x % m + m) % m;
		cout << x << endl;
		return x;
	}
	}
		ll fact[1000007]={0};
		ll expo(ll x, ll y) {ll res=1;x=x%MOD;while(y>0){if(y&1)res=(1ll*res*x)%MOD;
		y=y>>1;x=(1ll*x*x)%MOD;} return res;}
		void facto() {fact[0]=1;fact[1]=1;for(ll i=2;i<100007;i++)fact[i]=(fact[i-1]*i)%MOD;}
		ll npr(ll n,ll r) {facto(); ll res=1; res=fact[n]; res=(res*(expo(fact[n-r],MOD-2)))%MOD; return res; }
		ll ncr(ll n,ll r){ ll res=1; if(r>n-r)r=n-r; for(ll i=0;i<r;i++) {  res*=n-i;  res/=i+1; } return res;}
			ll C(ll n, ll k) {
    ll res = 1;
    for (ll i = 1; i <= k; ++i)
        res = ((res) * (n - k + i) / i)%MOD;
    return (ll)(res + 0.01)%MOD;
}
				
		int main()
		{
			fast
			ll n,k;
			cin>>n>>k;
			ll ans=0;
			for(ll i=k;i<=n+1;i++)
			{
				ll m1=(i-1)*i/2;
				ll m2=(2*n-i+1)*i/2;
				ans=(ans+m2-m1+1)%MOD;
			}
			cout<<ans%MOD;
			}

 

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

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


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


const int NMAX = 1000;
const int MMAX = 1000;

int N,M;
bool edge[NMAX][MMAX];
int from[MMAX];
int visited[NMAX];

bool Add(int p) {
  if( visited[p] )return false;
  visited[p] = true;
  for(int i = 0; i < M; ++i) {
    if(!edge[p][i]) continue;
    if(from[i] < 0 || Add(from[i])) {
      from[i] = p;
      return true;
    }
  }
  return false;
}

int Matching() {
  memset(from,-1,sizeof(from));
  int cnt = 0;
  for(int i = 0; i < N; ++i) {
    memset(visited,0,sizeof(visited));
    if(Add(i))
      ++cnt;
  }
  return cnt;
}

int main2() {
  CLR(edge,0);
  CLR(edge,0);

  vector<int> a, b, c, d;
  N = M = nextInt();
  REP(i, N) {
    a.push_back(nextInt());
    b.push_back(nextInt());
  }
  REP(i, N) {
    c.push_back(nextInt());
    d.push_back(nextInt());
  }
  REP(i, N) {
    REP(j, N) {
      if (a[i] < c[j] && b[i] < d[j]) {
        edge[i][j] = true;
      }
    }
  }
  ll ans = Matching();
  cout << ans << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


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

int main() {
  int n; string s; cin >>n >>s;
  string ans = "Yes";
  if (n%2!=0) ans = "No";
  else{
    string t,u;
    for (int i=0; i<n/2; i++){
      t = t + s.at(i);
      u = u + s.at(i+n/2);
    }
    if (t!=u) ans = "No";
  }
  cout <<ans <<endl;
}


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

int main(){
  long long N;
  cin >> N;
  long long s[5];
  for(int i=0;i<5;i++){
    cin >> s[i];
  }
  long long mini = s[0];
  for(int i=0;i<5;i++){
    mini = min(s[i],mini);
  }
  
  long long ans = 5;
  if(N > mini){
    if(N%mini == 0){
      ans += N/mini -1;
    }else{
      ans += N/mini;
    }
  }
  cout << ans << endl;
}
  

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <bitset>

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

using namespace std;


int main() {
    int n, k; cin >> n >> k;
    vector<int> a(n); rep(i, n) cin >> a[i];
    sort(a.begin(), a.end());

    // 単調性が成り立つことを示す。
    // k - a[i] <= S < k となるSが存在するとすると、
    // a[j] > a[i] を満たす任意のa[j]について、k - a[j] <= S' < k が成り立つようなS'が存在することが示せる。
    // (Sに a[j]が含まれる場合と、a[j]が含まれない場合に分けると示せた。)

    // bitset高速化を付け加えてみた。

    int left = -1;
    int right = n;
    int mid;
    while (right - left > 1) {
        mid = (left + right) / 2;
        bitset<5010> dp;
        dp[0] = 1;

        rep(i, n) {
            if (i != mid) {
                dp |= (dp << a[i]);
            }
        }

        bool flag = 0;
        for (int j = max(0, k - a[mid]); j < k; j++) {
            flag |= dp[j];
        }
        if (flag) right = mid;
        else left = mid;
    }

    cout << left + 1 << endl;

    return 0;
}


    


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
 
#define mod 1000000007
#define FOR(x,to) for(int x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define long long long
inline int rei(){int x;cin>>x;return x;}
inline long rel(){long x;cin>>x;return x;}
inline string res(){string x;cin>>x;return x;}
//------------------------------------------------------- 
long DP1[25000000];
long buffer[5000];
int dp1[5000];
int DP2[5000];
int child[5000];
long A[5000];
vector<int> G[5000];
void Calc(){
	int N = rei();
	for(int i=0;i<N;i++){
		A[i] = rel();
	}
	for(int i=0;i<N-1;i++){
		int v = rei()-1;
		int u = rei()-1;
		G[v].push_back(u);
		G[u].push_back(v);
	}
	stack<pair<int,int>> sp;
	sp.push({0,-1});
	while(!sp.empty()){
		int v = sp.top().first;
		int f = sp.top().second;
		sp.pop();
		if(v >= N){
			v -= N;
			if(A[v] > 0){
				int c = 0;
				for(int t:G[v]){
					if(t != f){
						c += min(DP2[t],dp1[t]+1);
					}
				}
				DP2[v] = c;
			}
			else{
				DP2[v] = 10000;
			}
			{
				int ch = 1;
				DP1[v*5000] = A[v];
				for(int t:G[v]){
					if(t != f){
						for(int i=0;i<ch+child[t];i++){
							buffer[i] = 100000000000000000;
						}
						for(int i=ch-1;i>=0;i--){
							buffer[i+dp1[t]+1] = min(buffer[i+dp1[t]+1],DP1[v*5000+i]);
						}
						for(int i=ch-1;i>=0;i--){
							for(int j=child[t]-1;j>=0;j--){
								buffer[i+j] = min(buffer[i+j],DP1[v*5000+i]+DP1[t*5000+j]);
							}
						}
						for(int i=0;i<ch+child[t];i++){
							DP1[v*5000+i] = buffer[i];
						}
						ch += child[t];
					}
				}
				int cm = DP2[v];
				for(int i=0;i<ch;i++){
					if(DP1[v*5000+i] < 0){
						cm = min(cm,i);
					}
				}
				dp1[v] = cm;
				child[v] = ch;
			}
		}
		else{
			sp.push({v+N,f});
			for(int t:G[v]){
				if(t != f){
					sp.push({t,v});
				}
			}
		}
	}
	cout << dp1[0] << endl;
}
int main(int argc,char** argv){
	ios::sync_with_stdio(false), cin.tie(0);
	cout.tie(0); Calc(); return 0;
}

Measured memory_bytes: 194688
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 100000 + 10;
const int M = 1000000007;
const double eps = 1e-9;
const double PI = acos(-1);
const int oo = 1000000000;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<ll, int> ii;
#define pb push_back 
#define all(c) (c).begin(),(c).end()
int n;
ll c,dp[2][N];
ii v[N];

int main(){
	cin>>n>>c;
	for(int i=1; i<=n; ++i)
		scanf("%lld%d",&v[i].first, &v[i].second);
	ll pos=c,right=0;
	for(int i=n; i; --i){
		right+=v[i].second-(pos-v[i].first);
		pos=v[i].first;
		dp[0][i]=max(dp[0][i+1], right);
	}
	right=0;pos=0;
	for(int i=1; i<=n; ++i){
		right+=v[i].second-(v[i].first-pos);
		pos=v[i].first;
		dp[1][i]=max(dp[1][i-1], right);
	}
	ll ans=0;
	for(int i=1; i<=n; ++i){
		ans=max(ans, max(dp[0][i], dp[1][i]));
		ans=max(ans, dp[0][i]-(c-v[i].first)+dp[1][i-1]);
		ans=max(ans, dp[1][i]-v[i].first+dp[0][i+1]);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3328
#include "bits/stdc++.h"
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }

int A, B, K;
set<int> st;

void _main() {
  cin >> A >> B >> K;

  rep(i, A, A+K) {
    if (i > B) break;
    st.insert(i);
  }
  rrep(i, B, B-K+1) {
    if (i < A) break;
    st.insert(i);
  }

  for (const auto& x : st) {
    cout << x << "\n";
  }
}

Measured memory_bytes: 256
//Author: Rahul Purohit

#include<bits/stdc++.h>
#define vi vector<int>
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define ll  long long int
#define pi pair<ll,ll>
#define f first
#define mp make_pair
#define mod 1000000007
#define s second
#define pb push_back
#define mp make_pair
#define N 100001
using namespace std;
int gcd(int a, int b)
{
	if(b==0)
		return a;
	else
		return (b,a%b);
}
/*ll isp[N]={1};
void sieve(int n)
{
	isp[0]=isp[1]=0;
	for(int i=2;i<=n;i++)
	{
		if(isp[i]==1)
		{
			for(int j=i*i;j<=n;j+=i)
			{
				isp[j]==0;
			}
		}
	}
}*/
ll pow(int x,int  y,int m)
{
	ll ans=1;
	while(y!=0)
	{
		if(y%2==1)
		{
			ans=(ans*x)%m;
		}
		x=(x*x)%m;
		y/=2;
	}
	return ans;
}
template <class x>
void swap(x &a,x &b)
{
	x tp;
	tp=a;
	a=b;
	b=tp;
}
template <class x>
void max(x &a,x &b)
{
	return (a>=b?a:b);
}
template <class x>
void min(x &a,x &b)
{
	return (a>=b?b:a);
}
int main(void)
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

    char a;
    cin>>a;
    if(a=='A')
    {
        cout<<"T";
    }
    else if(a=='T')
    {
        cout<<"A";
    }
    else if(a=='C')
    {
        cout<<"G";
    }
    else
    {
        cout<<"C";
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
#include<string>
#include<time.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define fi first    
#define se second 
void solve()
{   
    ll k;
    cin>>k;
    ll i,j,q;
    ll ans = 0;
    for(i=1;i<=k;i++)
    {
        for(j=1;j<=k;j++)
        {
            for(q=1;q<=k;q++)
                ans+=__gcd(i,__gcd(j,q));
        }
    }
    cout<<ans;
}
int main(){ 
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    // # ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // #endif  
    // clock_t tStart = clock();
    // ll t;
    // cin>>t;
    // while(t--)
        solve();
    //printf("\nTime taken: %.2fs\n", (double)(clock() - tStart)/CLOCKS_PER_SEC);
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <queue>
#include <utility>
using namespace std;

int main(){
  int N,X;
  cin >> N >> X;
  int L[N];
  for(int i = 0;i<N;i++){
      cin >> L[i];
  }
  int sum = 0,c = 0;

  for(int i = 0;i<=X;){
    i = i + L[c];
    c++;
  }

  cout << c << endl;

    return 0;
}

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

int main()
{
  int r,c,x,sum,i,j;
  char ch;
  while (1){
    ch=getchar();
    if (ch=='\n'){
      printf("\n");
      break;
    }else if islower(ch){
        printf("%c",toupper(ch));
      }else if isupper(ch){
        printf("%c",tolower(ch));
      }else{
      printf("%c",ch);
    }

  }

  return 0;
}

Measured memory_bytes: 524
n = int(input())
a = list(map(int, input().split()))
ans = 1
if 0 in a:
  print(0)
else:
  for i in range(n):
    ans *= a[i]
    if ans > pow(10,18):
        ans = -1
        print(ans)
        break
  if ans != -1:
    print(ans)

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

#define int unsigned long long int

struct Item{
	int a,b,c,d;
};

vector<int> V;

int32_t main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);

	int n,m,q,res,maxi=0;
	cin>>n>>m>>q;
	Item A[q];
	for(int i=0;i<q;i++)
		cin>>A[i].a>>A[i].b>>A[i].c>>A[i].d;
	for(int p1=1;p1<=m;p1++){
		for(int p2=p1;p2<=m;p2++){
			for(int p3=p2;p3<=m;p3++){
				for(int p4=p3;p4<=m;p4++){
					for(int p5=p4;p5<=m;p5++){
						for(int p6=p5;p6<=m;p6++){
							for(int p7=p6;p7<=m;p7++){
								for(int p8=p7;p8<=m;p8++){
									for(int p9=p8;p9<=m;p9++){
										for(int p10=p9;p10<=m;p10++){
											V.clear();
											V.push_back(p1);
											V.push_back(p2);
											V.push_back(p3);
											V.push_back(p4);
											V.push_back(p5);
											V.push_back(p6);
											V.push_back(p7);
											V.push_back(p8);
											V.push_back(p9);
											V.push_back(p10);
											int val = 0;
											for(int i=0;i<q;i++){
												if(V[A[i].b-1]-V[A[i].a-1] == A[i].c)
													val += A[i].d;
											}
											maxi = max(maxi,val);
										}
									}
								}
							}
						}
					}
				}
			}
		}
	}
	cout<<maxi;

	return 0;
}

Measured memory_bytes: 3624
#include <stdio.h>

int main(void){
	int n;
	int a,b,c,d;
	
	int count = 0;
	
	while(scanf("%d",&n) != EOF){	
		for(a = 0;a < 10;a++){
			for(b = 0;b < 10;b++){
				for(c = 0;c < 10;c++){
					for(d = 0;d < 10;d++){
						if(a + b + c + d == n){
							count++;
						}
					}
				}
			}
		}
		printf("%d\n",count);
		count = 0;
	}
	return 0;
}

Measured memory_bytes: 1024
n=int(input())
a=list(map(int,input().split()))
count4=0
count2=0

for i in a:
  if i%4==0:
    count4+=1
  elif i%2==0:
    count2+=1

if count2<1:
  count1=len(a)-count4
else:
  count1=len(a)-count4-count2+1
if count1-count4<=1:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 14252
/*
 * a.cpp
 *
 *  Created on: 2019/06/08
 *      Author: MEIP-users
 */




#include <bits/stdc++.h>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <locale>
#include <queue>
#include <tuple>
#include <map>
#include <fstream>

using namespace std;


#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1e9+10)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))




int main() {
	int x,y;
	cin >> x >> y;
	if(y%2 == 1){
		cout << "No" << endl;
	}else{
		y = y/2;
		if(y > 2*x || y<x){
			cout << "No" <<endl;
		}else{
			cout << "Yes"<<endl;
		}
	}
	return 0;
}


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

int main(){
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    while(true){
        C -= B;
        if(C <= 0){
            cout << "Yes" << endl;
            break;
        }
        A -= D; 
        if(A <= 0){
            cout << "No" << endl;
            break;
        }
    }
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	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.at(i) >> y.at(i) >> a.at(i);
	}

	vector<int> num(4);
	num.at(0) = 0;
	num.at(1) = w;
	num.at(2) = 0;
	num.at(3) = h;
	for (int i = 0; i < n; i++) {
		if (a.at(i) == 1) {
			num.at(0) = max(x.at(i), num.at(0));
		} else if (a.at(i) == 2) {
			num.at(1) = min(x.at(i), num.at(1));
		} else if (a.at(i) == 3) {
			num.at(2) = max(y.at(i), num.at(2));
		} else {
			num.at(3) = min(y.at(i), num.at(3));
		}
	}

	if (num.at(1) - num.at(0) >= 0 && num.at(3) - num.at(2) >= 0) {
		cout << (num.at(1) - num.at(0)) * (num.at(3) - num.at(2)) << endl;
	} else {
		cout << 0 << endl;
	}

 	return 0;
 }

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

int main() {
  int H,W;
  cin >> H >> W;
  
  vector<vector<char>> map(H);
  
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      char c;
      cin >> c;
      map.at(i).push_back(c);
    }
  }
  
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      char c = map.at(i).at(j);
      if(c=='.'){
        int count = 0;
        if(i!=0 && map.at(i-1).at(j)=='#'){
          count++;
        }
        if(i!=H-1 && map.at(i+1).at(j)=='#'){
          count++;
        }
        if(j!=0 && map.at(i).at(j-1)=='#'){
          count++;
        }
        if(j!=W-1 && map.at(i).at(j+1)=='#'){
          count++;
        }
        if(i!=0 && j!=0 && map.at(i-1).at(j-1)=='#'){
          count++;
        }
        if(i!=0 && j!=W-1 && map.at(i-1).at(j+1)=='#'){
          count++;
        }
        if(i!=H-1 && j!=0 && map.at(i+1).at(j-1)=='#'){
          count++;
        }
        if(i!=H-1 && j!=W-1 && map.at(i+1).at(j+1)=='#'){
          count++;
        }
        cout << count;
      }
      else{
        cout << map.at(i).at(j);
      }
    }
    cout << endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<numeric>
#define rec(n,i) for(int i=0;i<n;i++)
using namespace std;
int main() {
	int r, g;
	cin >> r >> g;
	int ans = r + ((g - r) * 2);
	cout << ans << endl;

	return 0;
}

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

#define endl '\n'
#define fi first
#define se second
#define pb push_back
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
const int MOD = 1e9 + 7;
const int maxn = 1e6 + 5;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-8;

int a[maxn];

int main() {
    int n, f = 1;
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        scanf("%d", &a[i]);
        if (a[i] % 2 == 0 && a[i] % 3 != 0 && a[i] % 5 != 0) f = 0;
    }
    printf("%s\n", (f ? "APPROVED" : "DENIED"));
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <cassert>
#include <random>

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

using namespace std;
typedef long long int ll;
const ll INF = 1e18;
const double PI = acos(-1);
const ll mod = 1000000007;

int main()
{
    int s;
    cin >> s;
    vector<ll> dp(s+1, 0);
    dp[0] = 1;
    for(int i = 3; i <= s; i++) {
        dp[i] = (dp[i-1] + dp[i-3]) % mod;
    }
    cout << dp[s] << endl;
    return 0;
}


Measured memory_bytes: 3628
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
 
#define PI 3.1415926535
 
typedef struct{
  double x;
  double y;
}Point;
 
void KochCurve(Point,Point,int);
 
int main(void){
  int n;
  Point p1={0,0};
  Point p2={100,0};
 
  scanf("%d", &n);
 
  printf("%.8f %.8f\n", p1.x, p1.y);
  KochCurve(p1,p2,n);
  printf("%.8f %.8f\n", p2.x, p2.y);
 
  return 0;
}
 
void KochCurve(Point p1, Point p2, int n){
  Point p3,p4,p5;
 
  if(n==0) return;
 
  p3.x=(2*p1.x+p2.x)/3.0;
  p3.y=(2*p1.y+p2.y)/3.0;
  p4.x=(p1.x+2*p2.x)/3.0;
  p4.y=(p1.y+2*p2.y)/3.0;
  p5.x=(p4.x-p3.x)*cos(PI/3)-(p4.y-p3.y)*sin(PI/3)+p3.x;
  p5.y=(p4.x-p3.x)*sin(PI/3)+(p4.y-p3.y)*cos(PI/3)+p3.y;
 
  KochCurve(p1,p3,n-1);
  printf("%.8f %.8f\n", p3.x, p3.y);
  KochCurve(p3,p5,n-1);
  printf("%.8f %.8f\n", p5.x, p5.y);
  KochCurve(p5,p4,n-1);
  printf("%.8f %.8f\n", p4.x, p4.y);
  KochCurve(p4,p2,n-1);
 
  return;
}

Measured memory_bytes: 644
#include <stdio.h>
#include <string.h>
 
int main(void){
    int i;
    char day[10];
    char week[7][10] = {"SAT","FRI","THU","WED","TUE","MON","SUN"};
    
    scanf("%s",day);
    for(i = 0;i < 7;i++){
        if(!strcmp(day,week[i]))break;
    }
    printf("%d\n",i + 1);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 100000 + 10;
const int M = 1000000007;
const double PI = atan(1) * 4;
const int oo = 1000000000;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
#define pb push_back 
#define all(c) (c).begin(),(c).end()


int main(){
	int n,v[101];
	cin>>n;
	for(int i=0; i<n; ++i)
		cin>>v[i];
	sort(v,v+n);
	cout<<*max_element(v,v+n)-*min_element(v,v+n);
	
}




Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int a[] = new int[n];
		int b[]= new int[n];
		int c[]= new int[n];
		for (int i = 0 ; i < n ; i++) {
			a[i] = Integer.parseInt(sc.next());
		}
		for (int i = 0 ; i < n ; i++) {
			b[i] = Integer.parseInt(sc.next());
		}
		for (int i = 0 ; i < n - 1 ; i++) {
			c[i] = Integer.parseInt(sc.next());
		}

		int ans = 0;
		
		for (int i = 0 ; i < n ; i++) {
			ans +=  b[a[i] -1];
			
			if(i != 0) {
				if(a[i -1] +1 == a[i]) {
					ans += c[a[i] -2];
				}
			}
			
			
		}
		
		
		System.out.println(ans);
		
	}
}

Measured memory_bytes: 21716
#include <iostream>

constexpr int MAX=(int)1e5,mod=(int)1e9+7;

using ll=long long int;

int n,m;

ll X[MAX],Y[MAX];

int main() {
    std::cin>>n>>m;
    for(int i=0;i<n;++i)
        std::cin>>X[i];
    for(int i=0;i<m;++i)
        std::cin>>Y[i];
    ll nAns=0,Ans=0;
    for(int i=0;i<n;++i){
        nAns+=i*X[i]-X[i]*(n-1-i);
        nAns%=mod;
    }
    std::cout<<std::endl;
    for(int i=0;i<m;++i){
        Ans+=i*Y[i]-Y[i]*(m-1-i);
        Ans%=mod;
    }
    std::cout<<std::endl;
    std::cout<<nAns*Ans%mod<<std::endl;
    return 0;
}

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

#define debug(x) cout << #x << " = " << x << endl;
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define FOR(it, b, e) for (typeof(b) it = (b); it != (e); ++it)
#define MSET(c, v) memset(c, v, sizeof(c))

const int INF = 0x3F3F3F3F; 
const int NEGINF = 0xC0C0C0C0;
const int NULO = -1;
const double EPS = 1e-10;
const ll mod = 998244353;

inline int cmp(double x, double y = 0) 
{  
  if(fabs(x - y) < EPS)
    return 0;
  return x > y ? 1 : -1;
}

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

const int maxn = 2000 + 10;

ll a[maxn];

ll dp[maxn][maxn];

int main()
{

  MSET(dp, 0);

  ios::sync_with_stdio(0);
  int n;
  cin >> n;
  
  vector<pair<ll, int> >ord;

  for(int i = 0; i < n ; i++)
  {
    cin >> a[i];
    ord.push_back({a[i], i});
  }

  sort(ord.begin(), ord.end(), greater<pair<ll, int>>());

  ll ans = 0;
  dp[0][0] = 0;

  for(int sum = 0; sum < n; sum++)
  {
    for(int i = 0; i <= sum; i++)
    {
      int j = sum - i;
      dp[i+1][j] = max(dp[i+1][j], dp[i][j] + ord[sum].first * abs(ord[sum].second - i));
      dp[i][j+1] = max(dp[i][j+1], dp[i][j] + ord[sum].first * abs( (n-1-j) - ord[sum].second ));
      // debug(dp[i+1][j]);
      // debug(dp[i][j+1]);
      // cout << "\n\n\n";
    }
  }

  for(int i = 0; i <= n; i++)
  {
    ans = max(ans, dp[i][n-i]);
  }

  

  cout << ans << endl;


  return 0;
} 

Measured memory_bytes: 35232
;; -*- coding: utf-8 -*-
(eval-when (:compile-toplevel :load-toplevel :execute)
  (sb-int:defconstant-eqx OPT
    #+swank '(optimize (speed 3) (safety 2))
    #-swank '(optimize (speed 3) (safety 0) (debug 0))
    #'equal)
  #+swank (ql:quickload '(:cl-debug-print :fiveam) :silent t)
  #-swank (set-dispatch-macro-character
           #\# #\> (lambda (s c p) (declare (ignore c p)) (read s nil (values) t))))
#+swank (cl-syntax:use-syntax cl-debug-print:debug-print-syntax)
#-swank (disable-debugger) ; for CS Academy

;; BEGIN_INSERTED_CONTENTS
(defmacro dbg (&rest forms)
  #+swank
  (if (= (length forms) 1)
      `(format *error-output* "~A => ~A~%" ',(car forms) ,(car forms))
      `(format *error-output* "~A => ~A~%" ',forms `(,,@forms)))
  #-swank (declare (ignore forms)))

(defmacro define-int-types (&rest bits)
  `(progn
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "UINT~A" b)) () '(unsigned-byte ,b))) bits)
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "INT~A" b)) () '(signed-byte ,b))) bits)))
(define-int-types 2 4 7 8 15 16 31 32 62 63 64)

(declaim (inline println))
(defun println (obj &optional (stream *standard-output*))
  (let ((*read-default-float-format* 'double-float))
    (prog1 (princ obj stream) (terpri stream))))

(defconstant +mod+ 1000000007)

;;;
;;; Body
;;;

(defun main ()
  (let* ((n (read))
         (as (make-array n :element-type 'uint8))
         (d 0))
    (declare (uint16 n d))
    (dotimes (i n)
      (setf (aref as i) (read))
      (setq d (max d (aref as i))))
    (write-line
     (if (and (loop for x from (+ 1 (ceiling d 2)) to d
                    always (>= (count x as) 2))
              (if (evenp d)
                  (= 1 (count (ceiling d 2) as))
                  (= 2 (count (ceiling d 2) as))))
         "Possible"
         "Impossible"))))

#-swank (main)


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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

template<typename T>
constexpr T inf = static_cast<T>(pow(10, static_cast<int>(log10(numeric_limits<T>::max())))) + 7;
constexpr llong mod = 1e9+7;

int main() {
  llong H, W, N;
  cin >> H >> W >> N;

  cout << N/max(H, W) + (N%max(H,W) > 0 ? 1 : 0) << endl;

  return 0;
}

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

using namespace std;

typedef long long	ll;
const int N = int(2e5 + 10);
ll p[N];
const double eps = 1e-8;

int main(){
	int n, k;

	scanf("%d %d", &n, &k);

	double ans = 0.0;

	for(int i = 0 ; i < n ; i++){
		scanf("%lld", &p[i]);
	}

	double tmp = 0;

	for(int d = 0 ; d < k ; d++){
		tmp += ((p[d] + 1LL)) / 2.0;
	}

	ans = tmp;

	int i = 0;
	int j = k - 1;

	while(j < n){
		if(tmp - ans > eps){
			ans = tmp;
		}

		tmp -= ((p[i] + 1LL)) / 2.0;
		tmp += ((p[j + 1] + 1LL)) / 2.0;
		j++;
		i++;
	}

	printf("%.8lf\n", ans);

	return 0;
}

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

vector<bool> primes_create(int n){
  vector<bool> primes(n+1, true);
	primes[0] = primes[1] = false;
  for(int i=2; i*i<=n; ++i)
		if(primes[i]) for(int j=i+i; j<=n; j+=i) primes[j] = false;
  return primes;
}

int main(){
	vector<bool> primes = primes_create(100000+1);

	vector<int> C(primes.size());//Cumulative sum
	for(int n=1; n<primes.size(); ++n)
		C[n] += C[n-1] + (primes[n] && (n+1)%2==0 && primes[(n+1)/2]);

	int Q; cin>>Q;
	while(Q--){
		int l,r; cin>>l>>r;
		cout<< C[r] - C[l] + (C[l]!=C[l-1]) <<endl;
	}
}

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

int main() {
  int n;
  cin>>n;
  int64_t a1, a2, a3;
  a1=2; a2=1;
  if(n==1){
    a3=1;
  }
  if(n>1){
    for(int i=1;i<n;i++){
      a3=a1+a2;
      a1=a2;
      a2=a3;
    }
  }
  cout<<a3<<endl;
}


Measured memory_bytes: 256
n,a,b=map(int,input().split())
m=10**9+7

# 強化版cmb
def cmb(x,y):
    r=1
    for i in range(1,y+1):
        # 5C3なら
        # 5 * 4 * 3 / 3 * 2 * 1
        # = 5(mod m) * 1 / 3(mod m) * 4 (mod m) * 1 / 2(mod m) * 3(mod m) * 1 / 1(mod m)
        # (x- i + 1): 5 - 1 + 1...
        # pow(i,m-2,m):
        # フェルマーの小定理 a ** (m - 2) (mod m) = 1 / a (mod d)
        # 1 / a (mod m) はaで掛けると1 (mod m)になる数
        # 1 / 2なら500000004
        r=(r*(x-i+1)*pow(i,m-2,m))%m
    return r
# powでmod累乗を楽にできる
print((pow(2,n,m)-1-cmb(n,a)-cmb(n,b))%m)


Measured memory_bytes: 40300
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <random>
#include <complex>
#include <assert.h>

using namespace std;
typedef long long ll;
#define endl '\n'

const ll mod = 1000000007LL;

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

	constexpr int K = 16;

	constexpr ll v_e[] = { 869418286, 727008098, 660103155, 183023413, 471090892, 417297686, 237315285, 542573865, 444014759, 927321758, 184117322, 5655049, 347662323, 346175634, 765144583, 0};
	constexpr ll v_o[] = { 869418286, 727008098, 660103155, 183023413, 471090892, 417297686, 237315285, 542573865, 444014759, 927321758, 184117322, 962779130, 404391958, 700407153, 729548371, 539588932 };

	ll T, N; cin >> T;
	for (int _t = 0; _t < T; _t++) {
		cin >> N;
		ll ans = v_e[0];
		if (N & 1) {// odd
			for (int i = 1; i < K; i++) {
				ans *= N;
				ans += v_o[i];
				ans %= mod;
			}
		}
		else {// even
			for (int i = 1; i < K; i++) {
				ans *= N;
				ans += v_e[i];
				ans %= mod;
			}
		}
		cout << ans << endl;
	}

	return 0;
}


Measured memory_bytes: 3184
#include<stdio.h>
int main(void){
  int a,b;
  scanf("%d%d",&a,&b);
  if(a==1&&b==2){
    printf("%d\n",3);
    return 0;
  }
   if(a==1&&b==3){
    printf("%d\n",2);
    return 0;
  }
   if(a==2&&b==1){
    printf("%d\n",3);
    return 0;
  }
   if(a==2&&b==3){
    printf("%d\n",1);
    return 0;
  }
   if(a==3&&b==1){
    printf("%d\n",2);
    return 0;
  }
   if(a==3&&b==2){
    printf("%d\n",1);
    return 0;
  }
}
  

Measured memory_bytes: 128
import numpy as np


def main():
    n, m, c = map(int, input().split())
    B = list(map(int, input().split()))
    As = [list(map(int, input().split())) for _ in range(n)]

    B_arr = np.array(B)
    ans = 0
    for A in As:
        A_arr = np.array(A)
        judge = np.sum((B_arr*A_arr)) + c
        if judge > 0:
            ans += 1
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 20492
#include<stdio.h>
int main()
{
	int h, w, k;
	scanf("%d %d %d", &h, &w, &k);
	char s[11][1003];
	int i, j;
	for (i = 0; i < h; i++)
		scanf("%s", s[i]);
	int ans = h + w;
	int v, cnt[10][1003];
	int n, m = 1;
	for (i = 0; i < h; i++)
		m *= 2;
	int a[10], l;
	for (n = 0; n < m; n++)
	{
		for (i = 0; i < h; i++)
			cnt[i][0] = 0;
		v = 0;
		a[0] = 0;
		j = n;
		for (i = 1; i < h; i++)
		{
			if (j % 2 > 0)
			{
				a[i] = a[i - 1] + 1;
				v++;
			}
			else
				a[i] = a[i - 1];
			j /= 2;
		}
		for (j = 0; j < w; j++)
		{
			for (i = 0; i <= a[h - 1]; i++)
				cnt[i][j + 1] = cnt[i][j];
			for (i = 0; i < h; i++)
				if (s[i][j] == '1')
					cnt[a[i]][j + 1]++;
		}
		for (i = 0; i <= a[h - 1]; i++)
		{
			for (j = 0; j < w; j++)
			{
				if (cnt[i][j + 1] - cnt[i][j] > k)
				{
					v = -1;
					i = h;
					break;
				}
			}
		}
		if (v < 0)
			continue;
		l = 0;
		for (j = 1; j <= w; j++)
		{
			for (i = 0; i <= a[h - 1]; i++)
			{
				if (cnt[i][j] - cnt[i][l] > k)
				{
					v++;
					l = j - 1;
				}
			}
		}
		if (ans > v)
			ans = v;
	}
	printf("%d\n", ans);
	return 0;
}

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

int main(void) {
	int n;
	int a[100000];
	
	scanf("%d",&n);
	for (int i = 0;i < n;i++) {
		scanf("%d",&a[i]);
	}
	
	bool isUp;
	int p = 0,i = 0,cnt = 0;
	while(i < n) {
		cnt++;
		for (;i < n;i++) {
			if (a[p] != a[i]) {
				isUp = (a[p] < a[i]);
				break;
			}
		}
		for (;i < n-1;i++) {
			if (isUp && a[i] > a[i+1]) {
				p = i+1;
				break;
			} else if(!isUp && a[i] < a[i+1]) {
				p = i+1;
				break;
			}
		}
		i++;
	}
	printf("%d\n",cnt);
	
	return 0;
}


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

int main() {
    int n;
    cin >> n;
    int p[n];
    for(int i = 0; i < n; i++){
        cin >> p[i];
    }
    int count = 0;
    for(int i = 1; i < n - 1; i++){
        if((p[i - 1] < p[i] && p[i] < p[i + 1]) || (p[i - 1] > p[i] && p[i] > p[i + 1])){
            count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#define MAX_N 101
#define INF (1<<28);
 
int N;
int G[MAX_N][MAX_N];
 
int main() {
  int i, j, k;
  int id, v, c;
  int tmp;
  for(i = 0; i < MAX_N; ++i) {
    for(j = 0; j < MAX_N; ++j) {
      G[i][j] = i == j ? 0 : INF;
    }
  }
  scanf("%d", &N);
  for(i = 0; i < N; ++i) {
    scanf("%d %d", &id, &k);
    while(k--) {
      scanf("%d %d", &v, &c);
      G[id][v] = c;
    }
  }
 
  for(k = 0; k < N; ++k) {
    for(i = 0; i < N; ++i) {
      for(j = 0; j < N; ++j) {
        tmp = G[i][k] + G[k][j];
        if(tmp < G[i][j]) G[i][j] = tmp;
      }
    }
  }
 
  for(i = 0; i < N; ++i) {
    printf("%d %d\n", i, G[0][i]);
  }
 
  return 0;
}



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

num = [1]*55556

for i in range(2,55556):
    if num[i]==1:
        k=2
        while i*k<=55555:
            num[i*k]=0
            k+=1

ans = []

l=2
for i in range(n):
    for j in range(l,11111):
        if num[j*5+1]==1:
            ans.append(str(j*5+1))
            l=j+1
            break
print(' '.join(ans))


Measured memory_bytes: 9320
#include <iostream>
using namespace std;
int a[1000];
int main()
{
  int n;
  cin >> n;
  for(int i=0;i<n;i++)
    cin >> a[i];
  for(int i=0;i<n;i++)
  {
    if(a[i]%2==0)
      if(!(a[i]%3==0 || a[i]%5==0))
      {
        cout << "DENIED";
        return 0;
      }
  }
  cout << "APPROVED";
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define int long long
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

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

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(11);
	}
};
initializer _____;
int compress(vector< int > &x1, int W) {
	vector< int > xs;
	int N = x1.size();
	for (int i = 0; i < N; i++) {
		for (int d = -2; d <= 2; d++) {
			int tx1 = x1[i] + d;
			if (0 <= tx1 && tx1 < W)
				xs.push_back(tx1);
		}
	}
	sort(xs.begin(), xs.end());
	xs.erase(unique(xs.begin(), xs.end()), xs.end());
	for (int i = 0; i < N; i++) {
		x1[i] = lower_bound(xs.begin(), xs.end(), x1[i]) - xs.begin();
	}
	return xs.size();
}
int N, M, K, T, Q;
signed main() {
	int H, W, N;
	cin >> H >> W >> N;
	vector< int > y(N), x(N);
	rep(i, N) {
		cin >> y[i] >> x[i];
		--y[i];
		--x[i];
	}
	map< pii, int > M;
	vector< int > ans(10, 0);
	ans[0] = (W - 2) * (H - 2);
	rep(k, N) {
		int i = y[k], j = x[k];
		for (int di = -2; di <= 0; di++)
			for (int dj = -2; dj <= 0; dj++) {
				int ni = i + di, nj = j + dj;
				if (0 <= ni && ni < H - 2 && 0 <= nj && nj < W - 2) {
					//cout << M[pii(ni, nj)] << " ";
					ans[M[pii(ni, nj)]]--;
					M[pii(ni, nj)]++;
					ans[M[pii(ni, nj)]]++;
				}
			}
		//cout << endl;
	}
	for (int i = 0; i <= 9; i++)
		cout << ans[i] << endl;
	return 0;
}

Measured memory_bytes: 58112