akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stdio.h>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//　ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1000000007;
const ll mod=1000000007;
const double PI=3.14159265358979323846;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

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


// ll memo[2020][2020];
// int pascal_triangle(){
//   for(int i = 0; i < 1000; i++){
//     for(int j = 0; j < i+1; j++){
//       if(j == 0 || j == i) memo[i][j] = 1;
//       else{
// 	memo[i][j] = (memo[i-1][j-1]+memo[i-1][j])%mod;
//       }
//     }
//   }
//   return 0;
// }


// int factorial(int n){
//   if(n == 0) return 1;
//   return n*factorial(n-1);
// }

// int divisor(int a){
//   int cnt = 0;
//   for(int i=1; i <= a; i++) if(a%i == 0) cnt++;
//   return cnt;
// }

// int comb(int n, int k){
//   pascal_triangle();
//   return memo[n][k];
// }

int cans(bool f){
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}







//二項係数(mod剰余)----------------------------

// const int MAX = 3000010;
// const int M = 1000000007;

// vector<ll> fac(MAX); //n!(mod M)
// //a,bの範囲的にこれだけ配列を用意していけば十分
// vector<ll> ifac(MAX); //k!^{M-2} (mod M)

// ll mpow(ll x, ll n){ //x^n(mod M) ←普通にpow(x,n)では溢れてしまうため，随時mod計算
//     ll ans = 1;
//     while(n != 0){
//         if(n&1) ans = ans*x % M;
//         x = x*x % M;
//         n = n >> 1;
//     }
//     return ans;
// }

// ll COMinit(){
//   //大した量ではないので，先にfax[i]とifax[i]を全て計算しておく
//   fac[0] = 1;
//   ifac[0] = 1;
//   for(ll i = 0; i<MAX; i++){
//     fac[i+1] = fac[i]*(i+1) % M; // n!(mod M)
//     ifac[i+1] = ifac[i]*mpow(i+1, M-2) % M; // k!^{M-2} (mod M) ←累乗にmpowを採用
//   }
//   return 0;
// }

// ll COM(ll a, ll b){ //aCbをmod計算
//   if(a == 0 && b == 0)return 1;
//   if(a < b || a < 0)return 0;
//   ll tmp = ifac[a-b]* ifac[b] % M;
//   return tmp * fac[a] % M;
// }

//-----------------------------------------


int main(){

  int N,X;
  cin >> N >> X;
  int m[N];
  int ans = N;

  int sum = 0;
  int mi = inf;
  rep(i,N){
     cin >> m[i];
     sum += m[i];
     mi = min(m[i],mi);
  }
  ans = ans + (X-sum)/mi;
  cout << ans << endl;
  return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define FOR(i,a,b) for(ll i=a; i<= b; ++i)
#define all(v) (v).begin(), (v).end()
#define ff first
#define ss second
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define mp make_pair
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define MOD 1000000007
typedef long long ll;


int main(){
    optimize();
    ll T=1;
    //cin>>T;
    while(T--)
    {
        ll n,d;
        cin>>n>>d;
        ll ans=0;

        FOR(i,1,n)
        {
            ll a,b;
            cin>>a>>b;
            if(a*a+b*b<=d*d) ans++;
        }
        cout<<ans<<endl;
    }
    return 0;
}


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

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

int n;
vector<int> g[200010];
int vis[200010];
vector<int> vs;
int gr[200010];
int res[200010];

bool dfs(int v){
  vis[v]=1;
  vs.push_back(v);
  for(int nv : g[v]){
    if(vis[nv]==1||(vis[nv]==0&&dfs(nv))){
      return true;
    }
  }
  vs.pop_back();
  vis[v]=2;
  return false;
}

void dfs2(int v,int pre){
  set<int> st;
  rep(i,g[v].size()+1)st.insert(i);
  for(int nv : g[v]){
    if(nv==pre)continue;
    dfs2(nv,v);
    if(st.find(gr[nv])!=st.end()&&(*st.find(gr[nv]))==gr[nv]){
      st.erase(gr[nv]);
    }
  }
  gr[v]=*st.begin();
  return ;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>n;
  rep(i,n){
    int a;
    cin>>a;
    a--;
    g[a].push_back(i);
  }
  rep(i,n){
    if(dfs(i))break;
  }
  memset(gr,-1,sizeof(gr));
  rep(i,vs.size()){
    int prv=vs[(i-1+vs.size())%vs.size()];
    int nxt=vs[(i+1)%vs.size()];
    for(int nv : g[vs[i]]){
      if(nv==prv||nv==nxt)continue;
      dfs2(nv,vs[i]);
    }
  }
  int x[2];
  {
    set<int> st;
    rep(i,g[vs[0]].size()+3)st.insert(i);
    for(int v : g[vs[0]]){
      if(v==vs[1]||v==vs[vs.size()-1])continue;
      if(st.count(gr[v])){
        st.erase(gr[v]);
      }
    }
    auto it=st.begin();
    x[0]=*it;
    it++;
    x[1]=*it;
  }

  rep(k,2){
    rep(i,n)res[i]=gr[i];
    res[vs[0]]=x[k];
    for(int i=vs.size()-1;i>=0;i--){
      set<int> st;
      int v=vs[i];
      rep(j,g[v].size()+1)st.insert(j);
      for(int nv : g[v]){
        if(st.count(res[nv])){
          st.erase(res[nv]);
        }
      }
      ll ng=*st.begin();
      if(i==0){
        if(res[v]==ng){
          cout<<"POSSIBLE"<<endl;
          return 0;
        }
      }else{
        res[v]=ng;
      }
    }
  }
  cout<<"IMPOSSIBLE"<<endl;

  return 0;
}


Measured memory_bytes: 21108
#include <cstdio>
#include <algorithm>

using namespace std;

typedef unsigned int uint;

const uint ini=(1u<<31)-1;
const int MAXN=4e5+10;
int N,Q;

uint seg[MAXN];

uint init(int cur,int l,int r){
    if (r-l==1)
        return seg[cur]=ini;
    else{
        auto mid=(l+r)/2;
        return seg[cur]=min(
            init(cur*2,l,mid),
            init(cur*2+1,mid,r)
        );
    }
}

uint find(int ql,int qr,int l,int r,int cur){
    if (ql==l&&qr==r) return seg[cur];

    auto mid=(l+r)/2;
    if (qr<=mid) return find(ql,qr,l,mid,cur*2);

    if (ql>=mid) return find(ql,qr,mid,r,cur*2+1);

    return min(
        find(ql,mid,l,mid,cur*2),
        find(mid,qr,mid,r,cur*2+1)
    );
}

uint update(int i,int x,int l,int r,int cur){
    if (r-l==1) return seg[cur]=x;

    auto mid=(l+r)/2;
    if (i>=mid) return seg[cur]=min(seg[cur*2],update(i,x,mid,r,cur*2+1));
    else return seg[cur]=min(update(i,x,l,mid,cur*2),seg[cur*2+1]);
}

int main(){

    scanf("%d%d",&N,&Q);

    init(1,1,N+1);

    for(int i=0;i<Q;i++){
        int c,x,y;
        scanf("%d%d%d",&c,&x,&y);
        if (c==1)
            printf("%u\n",find(x+1,y+2,1,N+1,1));
        else 
            update(x+1,y,1,N+1,1);

    }

    return 0;
}


Measured memory_bytes: 3648
#include<stdio.h>
int main(){
    int n,k,l,F;
    int DOKOKARA[101];
    int NANKO[101];
    int j,i;
    int Toplace[101][101];
    int A[101][101];
    scanf("%d",&n);
    for(k=1;k<=n;k++){
        scanf("%d %d",&DOKOKARA[k],&NANKO[k]);
        for(l=1;l<=NANKO[k];l++){
            scanf("%d",&Toplace[k][l]);
        }
    }

    for(i = 1;i <= n;i++){
      for(j=1;j<=n;j++){
         A[i-1][j-1] = 0;
         }
    }

         for(i=1;i<=n;i++){
             for(j = 1;j<=n;j++){
                 for(k=1;k<=n;k++){
                     for(l=1;l<=NANKO[k];l++){
                         if(i == DOKOKARA[k] && j == Toplace[k][l])
                 A[i-1][j-1] = 1;
             }
         }
     }
}
     for(i=1;i<=n;i++){
             for(j = 1;j<=n;j++){
                 printf("%d",A[i-1][j-1]);
                 if(j != n) printf(" ");
             }
             printf("\n");
     }

return 0;
}



Measured memory_bytes: 2148
t = gets.chomp

n = t.size
n.times do |i|
  if t[i] == '?'
    if i > 0 && t[i-1] == 'P'
      t[i] = 'D'
    elsif i < n-1 && (t[i+1] == 'D' || t[i+1] == '?')
      t[i] = 'P'
    else
      t[i] = 'D'
    end
  end
end
puts t


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

#define rep(i, first, to) for(ll i = first; i < to; ++i)

using namespace std;
typedef long long ll;

struct HashSet {
	string data[(int)1e6];
	const int MAXN = (int)1e6;
	const string INIT = "-1";
	HashSet(){
		rep(i, 0, MAXN) {
			data[i] = INIT;
		}
	}
	bool find(string s) {
		int j = h(s);
		//cout << "codefind : " << j << endl;
		rep(i, 0, MAXN) {
			if (data[j] == INIT) return false;
			if (data[j] == s) return true;
			j = (j + 1) % MAXN;
		}
		return false;
	}
	void insert(string s) {
		int j = h(s);
		//cout << "codeinsert : " << j << endl;
		rep(i, 0, MAXN) {
			if (data[j] == INIT || data[j] == s) {
				data[j] = s;
				return;
			}
			j = (j + 1) % MAXN;
		}
	}
	int h(string s) {
		int hashcode = 0;
		int j = 1;
		rep(i, 0, s.size()) {
			hashcode += j * h1(s[i]);
			j *= 5;
		}
		hashcode %= MAXN;
		//cout << "hashcode : " << hashcode << endl;
		return hashcode;
	}
	int h1(char c) {
		if ('A' == c) {
			return 1;
		} else if ('G' == c) {
			return 2;
		} else if ('C' == c) {
			return 3;
		} else if ('T' == c) {
			return 4;
		}
	}
};

int n;
HashSet *mySet = new HashSet();
void solve() {
	string op, s;
	cin >> n;
	rep(i, 0, n) {
		cin >> op >> s;
		if (op == "insert") {
			mySet->insert(s);
		} else {
			if (mySet->find(s)) {
				cout << "yes" << endl;
			} else {
				cout << "no" << endl;
			}
		}
	}
	delete mySet;
}
void test() {
	cout << pow(5, 12) << endl;
}

int main() {
	solve();
	//test();
	return 0;
}

Measured memory_bytes: 26860
#include <bits/stdc++.h>
using namespace std;
int main(){
  int d,n,c=1;cin>>d>>n;
  for(int i=0;i<d;i++){
      c*=100;
  }
  if(n==100) n++;
  c*=n;cout<<c<<endl;
  return 0;
}

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

using namespace std;

int bubbleSort(int A[],int N){
    int flag = 1;
    int count=0;
    while(flag){
        flag=0;
        for(int j=N-1;j>=1;j--){
            if(A[j] < A[j-1]){
                int tmp = A[j];
                A[j] = A[j-1];
                A[j-1] = tmp;
                flag=1;
                count++;
            }
        }
    }
    for(int i=0;i<N;i++){
        cout << A[i];
        if(i!=N-1)cout << " ";
    }
    cout << endl;
    return count;
}

int main(){
    int N;
    cin >> N;
    int A[N];
    for(int i=0;i<N;i++)cin >> A[i];
    int count = bubbleSort(A,N);
    cout << count << endl;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
#include <algorithm>
#include <map>
#include <cstdlib>
#include <cmath>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
static const double pi=3.141592653589793238462643383279;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
    int a,p;
    cin >> a >> p;
    cout << (a*3+p)/2 << endl;
}

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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

const int N = 1e5+23;
const long long inf = 1e15;

vector<pair<int, int>> g[N];
long long D[N];

void solve() {
  int n, m; scanf("%d%d", &n, &m);
  for (int i = 0; i < m; ++i) {
    int l, r, c; scanf("%d%d%d", &l, &r, &c);
    g[l-1].emplace_back(r-1, c);
  }
  for (int i = 1; i < n; ++i) {
    g[i].emplace_back(i-1, 0);
    D[i] = inf;
  }
  priority_queue<pair<long long, int>, vector<pair<long long, int>>, greater<pair<long long, int>>> pq;
  pq.emplace(0, 0);
  D[0] = 0;
  while (!pq.empty()) {
    long long d = pq.top().first, u = pq.top().second;
    pq.pop();
    if (d > D[u]) continue;
    for (const auto &p: g[u]) {
      if (D[p.first] <= D[u]+p.second) continue;
      pq.emplace(D[u]+p.second, p.first);
      D[p.first] = D[u]+p.second;
    }
  }
  if (D[n-1] == inf) D[n-1] = -1;
  printf("%lld", D[n-1]);
}

int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 10852
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <map>
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

// ------ Class ------ //
class UnionFind {
private:
	unsigned size_; std::vector<unsigned> par, rank;
public:
	UnionFind() : size_(0), par(std::vector<unsigned>()), rank(std::vector<unsigned>()) {};
	UnionFind(unsigned size__) : size_(size__) {
		par.resize(size_); rank.resize(size_);
		for (unsigned i = 0; i < size_; i++) par[i] = i, rank[i] = 0;
	}
	unsigned size() { return size_; }
	//unsigned root(unsigned x) { return par[x] == x ? x : par[x] = root(par[x]); }
	unsigned root(unsigned x) 
	{ 
		while( par[x] != x ) 
		{
			par[x] = par[par[x]];
			x = par[x];
		}
		return x;
	}
	bool same(unsigned x, unsigned y) { return root(x) == root(y); }
	void unite(unsigned x, unsigned y) {
		x = root(x), y = root(y);
		if (x == y) return;
		if (rank[x] < rank[y]) par[x] = y;
		else if (rank[x] == rank[y]) par[y] = x, rank[x]++;
		else par[y] = x;
	}
	bool operator==(const UnionFind &u) { return par == u.par; }
	bool operator!=(const UnionFind &u) { return par != u.par; }
};

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

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

	int N, K, L;
	
	cin >> N >> K >> L;

	UnionFind uf1(N), uf2(N);

	rep(i, K)
	{
		int p1, p2;
		cin >> p1 >> p2;
		uf1.unite(--p1, --p2);
	}

	rep(i, L)
	{
		int s, r;
		cin >> s >> r;
		uf2.unite(--s, --r);
	}

	map<pair<int, int>, int> cnt;

	for (int i = 0; i < N; i++) {
		cnt[make_pair(uf1.root(i), uf2.root(i))]++;
	}
	for (int i = 0; i < N; i++) {
		cout << cnt[make_pair(uf1.root(i), uf2.root(i))] << endl;
	}
	
	//cout << endl;

	return 0;
}

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

int main() {
	string s;
	cin >> s;
	int a[4];
	for(int i = 0; i < 4; i++) {
		a[i] = s[i]-'0';
	}

	int m = 3;
	for(int bit = 0; bit < (1<<m); bit++) {
		vector<int> s(m, -1);

		for(int i = 0; i < m; i++) {
			if(bit & (1<<i)) {
				s[i] = i;
			}
		}


		int num = 1;
		int ans = a[0];
		char flag[3];
		for(int i = 0; i < s.size(); i++) {
			
			if(s[i] == -1) {
				ans -= a[num];
				flag[i] = '-';	
			}
			else {
				ans += a[num];
				flag[i] = '+';
			}
			num++;
		}

		if(ans == 7) {
			cout << a[0] << flag[0] << a[1] << flag[1] << a[2] << flag[2] << a[3] << "=7" << endl;
			return 0;
		}

	}
}




Measured memory_bytes: 256
// Ho-kago Tea Time

#include <bits/stdc++.h>

using namespace std;

#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define fst first
#define snd second
#define SZ(u) ((int) (u).size())
#define ALL(u) (u).begin(), (u).end()

inline void proc_status()
{
	ifstream t("/proc/self/status");
	cerr << string(istreambuf_iterator<char>(t), istreambuf_iterator<char>()) << endl;
}

template<typename T> inline int chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline int chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
template<typename T> inline T read()
{
	register T sum(0), fg(1);
	register char ch(getchar());
	for(; !isdigit(ch); ch = getchar()) if(ch == '-') fg = -1;
	for(;  isdigit(ch); ch = getchar()) sum = sum * 10 - '0' + ch;
	return sum * fg;
}

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

const int MAXN = (int) 1e5;

int n;

inline void input()
{
	n = read<int>();
}

inline void solve()
{
	if(__builtin_popcount(n) == 1) { puts("No"); return; }

	static vector<pii> E;

	E.emplace_back(n + 1, 2);
	for(int i = 2; i + 1 <= n; i += 2)
	{
		E.emplace_back(i, i + 1);
		E.emplace_back(i + 1, 1);
		E.emplace_back(1, n + i);
		E.emplace_back(n + i, n + i + 1);
	}
	if(n % 2 == 0)
	{
		E.emplace_back(n, n - 1);
		E.emplace_back(n + (n ^ (n - 1) ^ 1), 2 * n);
	}

	puts("Yes");
	for(auto it : E) printf("%d %d\n", it.fst, it.snd);
}

int main()
{
#ifdef K_ON // K-ON!
	freopen("C.in", "r", stdin);
	freopen("C.out", "w", stdout);
#endif

	input();
	solve();

	return 0;
}



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

typedef long long int ll;
const ll MAX = 1e5+5;
const ll INF= 1e15+5;
const ll MOD = 1e9+7;
#define faster ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back

vector<ll>graph[MAX];
ll n;
ll dp[MAX][2];

void solve(ll rt,ll p)
{
    if(graph[rt].size()==1 && p!=0)
    {
        dp[rt][0]=1;
        dp[rt][1]=1;
        return ;
    }
    
    for(auto child: graph[rt])
    {
        if(child!=p)
        {
            solve(child,rt);
        }
    }
    ll mul1=1/*cur black*/,mul2=1/*cur white*/;
    for(auto child : graph[rt])
    {
        if(child!=p)
        {
            mul1=((mul1%MOD)*(dp[child][1]%MOD))%MOD;
            mul2=((mul2%MOD)*(dp[child][0]+dp[child][1])%MOD)%MOD;
        }
    }
    dp[rt][0]=mul1;
    dp[rt][1]=mul2;
    
}

int main()
{
    faster;
    memset(dp,0,sizeof(dp));
    cin>>n;
    ll q=n-1;
    while(q--)
    {
        ll x,y;
        cin>>x>>y;
        graph[x].pb(y);
        graph[y].pb(x);
    }
    solve(1,0);
    cout<<(dp[1][0]+dp[1][1])%MOD<<endl;
}

Measured memory_bytes: 12800
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <map>
#include <unordered_map>
#include <string.h>
#include<iomanip>
#include <iterator>
#include <locale>

#define all(a) a.begin(),a.end()
#define VV(T) vector<vector< T > >
#define rep(i,N) for(int i = 0; i <N; i++)
#define repsg(i,s,g) for(int i = s; i <g; i++)
#define name(x) #x
using namespace std;


const int INF = 10000000;
const long long INFL = (1LL<<40);
const int MOD = pow(10,9)+7;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

typedef long long ll,LL;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
typedef pair<int,int> pii;
typedef pair<LL, LL> pLL;


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) is >> x;
    return is;
}
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
    for(int i=0; i<vec.size(); i++){
        os << vec[i] << ( i+1 == vec.size() ? "" : " " );
    }
    return os;
}

template< typename T >
struct edge{
    int src, to;T cost;
    edge(int to,T cost) :src(-1),to(to),cost(cost){}
    edge(int src, int to, T cost) :src(src),to(to),cost(cost){}edge
    &operator=(const int &x){
        to =x;
        return *this;
    }
    operator int() const{ return to;}
};


int main() {
    int n;cin>>n;vector<int>d(n);cin>>d;sort(all(d),greater<>());
    d.erase(unique(all(d)),d.end());
    cout<<d.size()<<endl;
    return 0;
}







Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define bitCount(num)  __builtin_popcount(num)
#define pb push_back
#define ll long long
#define bye return 0;
#define f(i,a,b) for( long long i=a;i<b;i++)
#define testCases long long t;cin>>t; while(t--)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define newLine <<"\n"
#define all(x) (x).begin(), (x).end()
#define vll vector<long long>

int main()
{
    fast
    string n;
    cin>>n;
    ll sum=0;
    f(i,0,n.size()) sum+= n[i]-'0';
    if(sum%9==0) cout<<"Yes\n";
    else cout<<"No\n";
    bye
}

Measured memory_bytes: 3764
#include <iostream>
#include <vector>
#include <map>
#include <queue>
using namespace std;
struct edge{
    int to;
    int cost;
};
int main(){
    int L;
    cin >> L;
    int now = 0;
    int temp = L;
    int cnt = 0;
    int num = 0;
    while(temp > 0){
        if(temp & 1) num += (1 << cnt);
        temp >>= 1;
        cnt++;
    }
    vector<edge> G[cnt];
    int t = 1;
    int cntm = 0;
    while(L > 0){
        if(L & 1){
            num -= (1 << now);
            if(num != 0){
                G[now].push_back(edge{cnt - 1, num});
                cntm++;
            }
        }
        if(num != 0){
            G[now].push_back(edge{now + 1, 0});
            G[now].push_back(edge{now + 1, t});
            cntm += 2;
            now++;
            t *= 2;
        }
        L >>= 1;
    }
    queue<int> q;
    cout << cnt << ' ' << cntm << endl;
    q.push(0);
    vector<int> used(cnt, 0);
    while(!q.empty()){
        int v = q.front();
        q.pop();
        if(used[v] == 1) continue;
        used[v] = 1;
        for(edge e: G[v]){
            cout << v + 1 << ' ' << e.to + 1 << ' ' << e.cost << endl;
            q.push(e.to);
        }
    }
}

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

using namespace std;

using ll = long long;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vl = V<ll>;
using VVl = V<V<ll>>;
using Vs = V<string>;

template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pll = P<ll, ll>;
using Pdd = P<double, double>;

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Mii = M<int, int>;
using Msi = M<string, int>;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

const double PI = acos(-1);
const ll MOD = 1e9+7;

int n, q;
string s, t;

int main() {
    cin >> q;

    REP(i, q) {
        cin >> s >> t;
        int ss = s.size(), st = t.size();
        VVi dp(ss+1, Vi(st+1, 0));
        REP2(i, 1, ss+1) REP2(j, 1, st+1) {
            if (s[i-1] == t[j-1]) {
                dp[i][j] = max({dp[i-1][j-1]+1, dp[i-1][j], dp[i][j-1]});
            } else {
                dp[i][j] = max({dp[i-1][j-1], dp[i-1][j], dp[i][j-1]});
            }
        }

        std::cout << dp[ss][st] << '\n';
    }

    return 0;
}



Measured memory_bytes: 6768
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class C
{
	public static void Main() => (new Solver()).Solve();
}

public class Solver
{
	public void Solve()
	{
		int N = GetInt();
		int M = GetInt();

		bool[] ac = new bool[N];
		int[] wa = new int[N];
		for(int i = 0; i < M; i++)
		{
			int p = GetInt() - 1;
			if(GetString().Equals("AC"))
			{
				ac[p] = true;
			}
			else
			{
				if(!ac[p])
					wa[p]++;
			}
		}

		int cnt = 0;
		for(int i = 0; i < N; i++)
		{
			if(ac[i])
				cnt += wa[i];
		}

		WriteLine($"{ac.Count(x => x)} {cnt}");
	}
}

public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static decimal GetDecimal() => decimal.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(long N) => Enumerable.Range(0, (int)N).Select(_ => GetInt()).ToArray();
	public static long[] GetLongs(long N) => Enumerable.Range(0, (int)N).Select(_ => GetLong()).ToArray();
	public static double[] GetDoubles(long N) => Enumerable.Range(0, (int)N).Select(_ => GetDouble()).ToArray();
	public static decimal[] GetDecimals(long N) => Enumerable.Range(0, (int)N).Select(_ => GetDecimal()).ToArray();
	public static string[] GetStrings(long N) => Enumerable.Range(0, (int)N).Select(_ => GetString()).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) < 0)
			x = y;
	}

	public static void chmin<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) > 0)
			x = y;
	}

	public static void swap<T>(ref T x, ref T y)
	{
		T tmp = x;
		x = y;
		y = tmp;
	}
}

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

int main(){
    int h,w;
    cin>>h>>w;
    vector<string>s(h);
    rep(i,h)cin>>s[i];
    rep(i,h){
        bool ng=true;
        rep(j,w){
            if(s[i][j]=='#')ng=false;
        }
        if(ng){
            rep(j,w)s[i][j]='0';
        }
    }
    rep(i,w){
        bool ng=true;
        rep(j,h){
            if(s[j][i]=='#')ng=false;
        }
        if(ng){
            rep(j,h)s[j][i]='0';
        }
    }
    rep(i,h){
        rep(j,w){
            if(s[i][j]!='0')cout<<s[i][j];
        }
        bool ng=true;
        rep(j,w){
            if(s[i][j]!='0')ng=false;
        }
        if(!ng)cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
	int a=0,b=0,c=0,d=0;
	int tmp1=0,tmp2=0,tmp3=0;
	
	scanf("%d %d %d %d",&a,&b,&c,&d);
	
	tmp1=a-b;
	if(tmp1<0)
	{
		tmp1=-tmp1;
	}
	
	tmp2=b-c;
	if(tmp2<0)
	{
		tmp2=-tmp2;
	}
	
	tmp3=a-c;
	
	if(tmp3<0)
	{
		tmp3=-tmp3;
	}
	
	
	
	if(tmp1<=d)
	{
		if(tmp2<=d)
		{
			printf("Yes");
		}
	
		else if(tmp3<=d)
		{
			printf("Yes");
		}
		
		else
		{
			if(tmp3<=d)
			{
				printf("Yes");
			}
			
			else
			{
				printf("No");
			}
			
		}
	}
	
	else
	{
		if(tmp3<=d)
		{
			printf("Yes");
		}
		
		else
		{
			printf("No");
		}
	}
		
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define MOD2 998244353
#define vi vector<ll>
#define PB push_back
#define FOI(i, a, n) for( ll i = a; i <= n; i++)
#define FOD(i, a, n) for( ll i = a; i >= n; i--)
#define F0I(i, n) FOI(i,0,n)
#define F0D(i, n) FOD(i,n,0)
#define F1I(i, n) FOI(i,1,n)
#define F1D(i, n) FOD(i,n,1)
#define watch(x) cout << #x << ": " << x << endl;
#define cnl(d) cout<<d<<'\n'
#define cns(d) cout<<d<<' '
#define printcont(v) for (auto &i : v) cout << i << " "; cout << endl
#define printmat(mat,row,col) F0I(i,row-1)F0I(j,col-1)cout << mat[i][j] << " \n"[j == col-1];
#define PNS cout<<' '
#define PNL cout<<'\n'
#define inint(i) ll i;cin >> i
#define invec(n,v) vi v(n); F0I(i,n-1) cin >> v[i]
#define insvec(n,v) inint(n); vi v(n); F0I(i,n-1) cin >> v[i]
#define MK2DV(v,row,col,val) vector<vector<ll>> v(row, vector<ll>(col,val))
#define trvl(c,it) for(auto it=(c).begin();it!=(c).end();it++)
using namespace std;
ll findmin(ll a, ll b) { if(a < b) return a; return b; }
ll findmax(ll a, ll b) { if(a > b) return a; return b; }
ll fast_pow(ll base,ll exp){if (exp == 0) return 1;if (exp == 1) return base % MOD;ll t = fast_pow(base, exp / 2);t = ((t% MOD) * (t%MOD)) % MOD;if (exp % 2 == 0)return t;else return ((base %  MOD) * t) % MOD;}
MK2DV(dp,105,100005,-1);
ll knapsack(ll n, ll W, vi &w, vi &c, ll N)
{
	if(n < 0)
		return 0;
	if(dp[n][W] != -1)
		return dp[n][W];
	ll ans = findmax( (W-w[n]>=0) ? knapsack(n-1,W-w[n],w,c,N)+c[n] : INT_MIN , knapsack(n-1,W,w,c,N));
	dp[n][W] = ans;
	return ans;
}
int main()
{
	ll n, W;
	cin >> n >> W;
	vi c(n);
	vi w(n);
	for(ll i = 0; i < n; i++)
		cin >> w[i] >> c[i];
	ll ans = knapsack(n-1,W, w, c, n);
	cout << ans << '\n';
	return 0;
 }

Measured memory_bytes: 83328
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using System.Runtime.CompilerServices;
using static MyUtil;

class MyUtil
{
    public static int[] ReadIntArray()
    {
	return ReadLine().Split().Select(x => int.Parse(x)).ToArray();
    }
}

class Program
{
    public static void Main()
    {
	var tmp = ReadIntArray();
	int m = tmp[0], d = tmp[1];

	int ans = 0;

	for (int i = 1; i <= m; i++)
	{
	    for (int j = 2; j <= 9; j++)
	    {
		for (int k = 2; k <= 9; k++)
		{
		    int x = j*10 + k;
		    if (x <= d && i == j*k)
		    {
			ans++;
		    }
		}
	    }
	}

	WriteLine(ans);
    }
}


Measured memory_bytes: 13396
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(1000000)


# Debug output
def chkprint(*args):
    names = {
        id(v): k
        for k, v in inspect.currentframe().f_back.f_locals.items()
    }
    print(', '.join(
        names.get(id(arg), '???') + ' = ' + repr(arg) for arg in args))


# Binary converter
def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in input().split()]


def gcd(n, m):
    if n % m == 0:
        return m
    else:
        return gcd(m, n % m)


def gcd_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = gcd(v, L[i])

    return v


def lcm(n, m):
    return (n * m) // gcd(n, m)


def lcm_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = lcm(v, L[i])

    return v


# Width First Search (+ Distance)
def wfs_d(D, N, K):
    """
    D: 隣接行列(距離付き)
    N: ノード数
    K: 始点ノード
    """

    dfk = [-1] * (N + 1)
    dfk[K] = 0

    cps = [(K, 0)]
    r = [False] * (N + 1)
    r[K] = True
    while len(cps) != 0:
        n_cps = []
        for cp, cd in cps:
            for i, dfcp in enumerate(D[cp]):
                if dfcp != -1 and not r[i]:
                    dfk[i] = cd + dfcp
                    n_cps.append((i, cd + dfcp))
                    r[i] = True

        cps = n_cps[:]

    return dfk


# Depth First Search (+Distance)
def dfs_d(v, pre, dist):
    """
    v:  現在のノード
    pre: １つ前のノード
    dist: 現在の距離

    以下は別途用意する
    D: 隣接リスト(行列ではない)
    D_dfs_d: dfs_d関数で用いる，始点ノードから見た距離リスト
    """

    global D
    global D_dfs_d

    D_dfs_d[v] = dist

    for next_v, d in D[v]:
        if next_v != pre:
            dfs_d(next_v, v, dist + d)

    return


def sigma(N):
    ans = 0
    for i in range(1, N + 1):
        ans += i
    return ans


def comb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2, r + 1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p - 1, r, p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def bisearch(L, target):
    low = 0
    high = len(L) - 1
    
    while low <= high:
        mid = (low + high) // 2
        guess = L[mid]
        if guess == target:
            return True
        elif guess < target:
            low = mid + 1
        elif guess > target:
            high = mid - 1
    if guess != target:
        return False

# --------------------------------------------

dp = None


def main():
    N = int(input())
    D, X = li_input()

    eaten = 0

    for i in range(N):
        a = int(input())
        eaten += math.ceil(D / a)

    print(eaten + X)


main()


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

int main(void)
{
    int n;
    cin >> n;
    int abcn = 0;
    int c = 0;
    vector<int> r(100001, 0);
    for (int i = 0; i < n; i++) {
        int d;
        cin >> d;
        r[d]++;
    }
    for (size_t i = 0; i < r.size(); i++) {
        abcn += r[i];
        if (abcn == n / 2) c++;
    }
    cout << c << endl;

    return 0;
}



Measured memory_bytes: 640
#include<bits/stdc++.h>
#define Rep(i,a,b) for(register int i=(a);i<=(b);++i)
#define Repe(i,a,b) for(register int i=(a);i>=(b);--i)
#define pb push_back
#define mp make_pair
typedef unsigned long long uint64;
typedef unsigned int uint32;
using namespace std;

namespace IO
{
    const uint32 Buffsize=1<<15,Output=1<<23;
    static char Ch[Buffsize],*S=Ch,*T=Ch;
    inline char getc()
	{
		return((S==T)&&(T=(S=Ch)+fread(Ch,1,Buffsize,stdin),S==T)?0:*S++);
	}
    static char Out[Output],*nowps=Out;
    
    inline void flush(){fwrite(Out,1,nowps-Out,stdout);nowps=Out;}

    template<typename T>inline void read(T&x)
	{
		x=0;static char ch;T f=1;
		for(ch=getc();!isdigit(ch);ch=getc())if(ch=='-')f=-1;
		for(;isdigit(ch);ch=getc())x=x*10+(ch^48);
		x*=f;
	}

	template<typename T>inline void write(T x,char ch='\n')
	{
		if(!x)*nowps++='0';
		if(x<0)*nowps++='-',x=-x;
		static uint32 sta[111],tp;
		for(tp=0;x;x/=10)sta[++tp]=x%10;
		for(;tp;*nowps++=sta[tp--]^48);
		*nowps++=ch;
	}
}
using namespace IO;

inline void file()
{
#ifndef ONLINE_JUDGE
	FILE*WA=freopen("water.in","r",stdin);
	FILE*TER=freopen("water.out","w",stdout);
#endif
}

const int MAXN=1e5+7;

static int n,a[MAXN];

inline void init()
{
	read(n);
	Rep(i,1,n)read(a[i]);
}

const int mod=998244353;

static int ans=1;

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

inline void solve()
{
	sort(a+1,a+n+1);
	Rep(i,0,n-1)ans=1ll*ans*gcd(i,a[i+1])%mod;
	cout<<ans<<endl;
}

int main()
{
    init();
    solve();
    return 0;
}

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

using namespace std;

#define sp(x) cout<<setprecision(x);
#define all(a) (a).begin(), (a).end()
#define inf 10000000
#define linf INT64_MAX*0.99
#define print(s) cout<<(s)<<endl
#define lint long long
#define FOR(i,a,b) for(lint i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define yes "Yes"
#define no "No"
#define divs 1000000007
#define dive 1000000009

typedef pair<int, int> P;
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,k; cin>>n>>k;
    vector<double> p(n);
    REP(i,n){
        cin>>p[i];
        p[i]=(p[i]+1)/2;
    }
    vector<double> xp(n-k+1,0);
    REP(i,k) xp[0]+=p[i];
    FOR(i,1,n-k+1){
        xp[i]=xp[i-1]-p[i-1]+p[i+k-1];
    }
    sort(all(xp));
    cout<<fixed;
    cout<<setprecision(10)<<xp[n-k]<<endl;
    return 0;
}

Measured memory_bytes: 3328
#include <stdio.h>

int main()
{
    int a, b, c, d = 0;
    scanf("%d%d%d", &a, &b, &c);
    for (int i = a; i <= b; i++)
    {
        if (c % a == 0)
        {
            a++;
            d++;
        }
        else
        {
            a++;
        }
    }
    printf("%d\n", d);
    return 0;
}



Measured memory_bytes: 2104
#include<bits/stdc++.h>
#define H 1000
#define W 1000
using namespace std;
int grid[H][W];
typedef pair<int, int> pii;

pii dp[(int)1e6 + 1];//first cnt, second max
bool isprime[(int)1e6 + 1];
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};

void sieve(int n){
  isprime[0] = isprime[1] = true;
  for(int i = 2; i <= n; i++){
    if(isprime[i])continue;
    for(int j = 2*i; j <= n; j+=i)isprime[j] = true;
  }
}


bool renge(int x, int y){
  if(0 <= x && x < W &&
     0 <= y && y < H)return true;
  return false;
}
vector<int> inM(int y, int x, int m){
  vector<int> res;
  if(y + 1 >= H) return res;
  for(int i = -1; i < 2; i++){
    if(x + i < 0 || W <= x + i )continue;
    if(grid[y + 1][x + i] <= m)res.push_back(i);
  }
  return res;
}

int main(int argc, char *argv[]){
  sieve((int)1e6);
  int n = H*W, m, x = 0, y = 0, dir = 0;
  while(n > 0){
    for(;renge(x + dx[dir], y + dy[dir]) && 
	  grid[y + dy[dir]][x + dx[dir]] == 0;){
      grid[y][x] = n;
      n--;
      x += dx[dir], y += dy[dir];
    }
    grid[y][x] = n;
    n--;
    dir++;
    dir %= 4;
    x += dx[dir], y += dy[dir];
  }
  while(cin >> m >> n, n){
    memset(dp, 0, sizeof(dp));
    for(int i = H - 1; i >= 0; i--){
      for(int j = 0; j < W; j++){
	if(grid[i][j] <= m){
	  vector<int> cand = inM(i, j, m);
	  for(int k = 0; k < cand.size(); k++){
	    dp[grid[i][j]] = max(dp[grid[i][j]], dp[grid[i + 1][j + cand[k]]]);
	  }
	  if(!isprime[grid[i][j]]){
	    if(dp[grid[i][j]].first == 0)dp[grid[i][j]].second = grid[i][j];
	    dp[grid[i][j]].first++;
	  }
	}
      }
    }
    cout << dp[n].first << " " << dp[n].second << endl;
  }
  
  return 0;
}

Measured memory_bytes: 13920
#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

using namespace std;

int main(){
	
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	
	cout << max(0, min(b, d) - max(a, c)) << endl;
	
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int n;
string str;
typedef unsigned long long ull;

int main() {
	while(cin >> n, n)
	{
		char dice[7] = {0, 1, 2, 3, 4, 5, 6};
		ull sum = 1;
		for(int i=0; i<n; i++)
		{
			char t;
			cin >> str;
			if(!str.compare("North"))
			{
				t = dice[1];
				dice[1] = dice[2];
				dice[2] = dice[6];
				dice[6] = dice[5];
				dice[5] = t;
			}

			else if(!str.compare("East"))
			{
				t = dice[4];
				dice[4] = dice[6];
				dice[6] = dice[3];
				dice[3] = dice[1];
				dice[1] = t;
			}

			else if(!str.compare("West"))
			{
				t = dice[1];
				dice[1] = dice[3];
				dice[3] = dice[6];
				dice[6] = dice[4];
				dice[4] = t;
			}

			else if(!str.compare("South"))
			{
				t = dice[1];
				dice[1] = dice[5];
				dice[5] = dice[6];
				dice[6] = dice[2];
				dice[2] = t;
			}

			else if(!str.compare("Right"))
			{
				t = dice[2];
				dice[2] = dice[3];
				dice[3] = dice[5];
				dice[5] = dice[4];
				dice[4] = t;
			}

			else if(!str.compare("Left"))
			{
				t = dice[2];
				dice[2] = dice[4];
				dice[4] = dice[5];
				dice[5] = dice[3];
				dice[3] = t;
			}
			sum += dice[1];
		}

		printf("%llu\n", sum);
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;

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

    string s;
    int k;
    cin >> s >> k;

    ll over = 0;
    if(s.front() != s.back()){
        rep(i, s.size()-1){
            if(s[i]==s[i+1]){
                ++over;
                s[i+1] = '0';
            }
        }

        cout << over * k << endl;
    }

    else{
        ll front = s.size();
        ll back = s.size();
        rep(i, s.size()){
            if(s[i]!=s.back()){
                front = i;
                break;
            }
        }

        for(int i = s.size()-1; i >= 0; --i){
            if(s[i] != s.front()){
                back = s.size() - i - 1;
                break;
            }
        }

        //cout << front << " " << back << endl;

        if(front == s.size()){ // all same
            cout << k*s.size()/2 << endl;
        }

        else{
            // [front, back)
            ll res = 0;
            string tmp1 = s;
            rep(i, s.size()-back){
                if(tmp1[i]==tmp1[i+1]){
                    ++res;
                    tmp1[i+1] = '0';
                }
            }

            // [back+front, back]
            string tmp2 = s.substr(s.size()-back, back) + s.substr(0, s.size()-back);

            rep(i, tmp2.size()-1){
                if(tmp2[i]==tmp2[i+1]){
                    ++over;
                    tmp2[i+1] = '0';
                }
            }
            cout << res + over * (k-1) + back/2 << endl;
        }

    }


    return 0;
}

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

using namespace std;

#define sz(x) (int) x.size()
#define all(a) a.begin(), a.end()

const int MAXN = 2050;

int n;
pair<int, int> a[MAXN];
long long dp[MAXN][MAXN];

long long calc(int pos, int l) {
    long long& res = dp[pos][l];
    if (res != -1) 
        return res;

    res = 0;
    if (pos == n)
        return res;

    int r = n - 1 - (pos - l);
    res = 1ll * a[pos].first * abs(a[pos].second - l) + calc(pos + 1, l + 1);
    res = max(res, 1ll * a[pos].first * abs(a[pos].second - r) + calc(pos + 1, l));

    return res;
}

int main() {

    scanf("%d", &n);
    for (int i = 0; i < n; i++) { 
        scanf("%d", &a[i].first);
        a[i].second = i;
    }

    sort(a, a + n);
    reverse(a, a + n);

    memset(dp, -1, sizeof(dp));
    cout << calc(0, 0) << endl;

    return 0;
}


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

int main(){
	int n,m;
	cin >> n >> m;
	int num;
	vector<int> data;
	for(int i = 0; i < m * n; i++){
		cin >> num;
		data.push_back(num);
	}
	vector<int> data2;
	for(int i = 0; i < m; i++){
		cin >> num;
		data2.push_back(num);
	}
	int input = 0;
	for(int i = 0; i < m * n; i++){
		input += data[i] * data2[i%m];
		if(i%m == m-1){
			cout << input << endl;
			input = 0;
		}
	}
			
	return 0;
}

Measured memory_bytes: 3172
import java.math.BigInteger;
import java.util.*;

public class Main {
	
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int n = sc.nextInt();
			int ans = 0;
			for(int i = 0; i <= n; i++){
				if(i % 2 == 0) continue;
				int count = 0;
				for(int j = 1; j <= n; j++){
					if(i % j == 0) count++;
				}
				if(count == 8){
					ans++;
				}
			}
			System.out.println(ans);
		}
	}

	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

	public static void main(String[] args) {
		new Main().doit();
	}

}


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

int main() {
    int L, R, d;
    cin >> L >> R >> d;
    int a = d;
    int i=1;
    int ans =0;
    while(a<=R) {
        if (a>=L && a<=R) ans++;
        a += d;
    }
    cout << ans;
}

Measured memory_bytes: 3632
macro_rules !read_value {($iter :expr ,($($t :tt ) ,*) ) =>{($(read_value !($iter ,$t ) ) ,*) } ;($iter :expr ,[$t :tt ;$len :expr ] ) =>{(0 ..$len ) .map (|_ |read_value !($iter ,$t ) ) .collect ::<Vec <_ >>() } ;($iter :expr ,{chars :$base :expr } ) =>{read_value !($iter ,String ) .chars () .map (|c |(c as u8 -$base as u8 ) as usize ) .collect ::<Vec <usize >>() } ;($iter :expr ,{char :$base :expr } ) =>{read_value !($iter ,{chars :$base } ) [0 ] } ;($iter :expr ,chars ) =>{read_value !($iter ,String ) .chars () .collect ::<Vec <char >>() } ;($iter :expr ,char ) =>{read_value !($iter ,chars ) [0 ] } ;($iter :expr ,usize1 ) =>{read_value !($iter ,usize ) -1 } ;($iter :expr ,$t :ty ) =>{$iter .next () .unwrap () .parse ::<$t >() .unwrap () } ;}
macro_rules !input_inner {($iter :expr ) =>{} ;($iter :expr ,) =>{} ;($iter :expr ,mut $var :ident :$t :tt $($r :tt ) *) =>{let mut $var =read_value !($iter ,$t ) ;input_inner !{$iter $($r ) *} } ;($iter :expr ,mut $var :ident $($r :tt ) *) =>{input_inner !{$iter ,mut $var :usize $($r ) *} } ;($iter :expr ,$var :ident :$t :tt $($r :tt ) *) =>{let $var =read_value !($iter ,$t ) ;input_inner !{$iter $($r ) *} } ;($iter :expr ,$var :ident $($r :tt ) *) =>{input_inner !{$iter ,$var :usize $($r ) *} } ;}
macro_rules !input {(source =$s :expr ,$($r :tt ) *) =>{let mut iter =$s .split_whitespace () ;input_inner !{iter ,$($r ) *} } ;(iter =$iter :ident ,$($r :tt ) *) =>{let s ={use std ::io ::Read ;let mut s =String ::new () ;std ::io ::stdin () .read_to_string (&mut s ) .unwrap () ;s } ;let mut $iter =s .split_whitespace () ;input_inner !{$iter ,$($r ) *} } ;($($r :tt ) *) =>{let s ={use std ::io ::Read ;let mut s =String ::new () ;std ::io ::stdin () .read_to_string (&mut s ) .unwrap () ;s } ;let mut iter =s .split_whitespace () ;input_inner !{iter ,$($r ) *} } ;}
fn main() {
    input!(n, ab: [(usize, usize); n]);
    let (mut a, mut b): (Vec<_>, Vec<_>) = ab.iter().cloned().unzip();
    a.sort();
    b.sort();
    if n % 2 == 1 {
        let l = a[n / 2];
        let u = b[n / 2];
        println!("{}", u - l + 1);
    } else {
        let l2 = a[n / 2];
        let l1 = a[n / 2 - 1];
        let u2 = b[n / 2];
        let u1 = b[n / 2 - 1];
        let l = l1 + l2;
        let u = u1 + u2;
        println!("{}", u - l + 1);
    }
}


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

int main() {
  string S;
  cin >> S;
  
  if (S[0] != 'A')
    cout << "WA" << endl;
  else if (S[1] >= 'a' && S[1] <= 'z' && S[S.size()-1] >= 'a' && S[S.size()-1] <= 'z' ) {
    int Ccount = 0;
    int count = 0;
    for (int i = 2; i < S.size() - 1; i++) {
      if (S[i] >= 'A' && S[i] <= 'Z') {
        count++;
        if (S[i] == 'C')
          Ccount++;
      }
    }
    if (Ccount == 1 && count == 1)
      cout << "AC" << endl;
    else
      cout << "WA" << endl;
  } else
    cout << "WA" << endl;
  
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <stdio.h>
using namespace std;
int a,b,l;
int main(){
    cin>>a>>b>>l;
    double A,B;
    if(a*a*b>l*2){B=b; A=l*2.0/a/b;}
    else {
        A=a;
        B=(a*a*b-l)*2.0/a/a;
    }
    printf("%.08f\n",atan(B/A)*180.0/M_PI);
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int retu = scanner.nextInt();
        int gyou = scanner.nextInt();
        int[][] gyouretu1 = new int[retu][gyou];
        int[][] gyouretu2 = new int[gyou][1];
        for (int i = 0; i < retu; i++) {
            for (int j = 0; j < gyou; j++) {
                int r = scanner.nextInt();
                gyouretu1[i][j] = r;
            }
        }
        for (int j = 0; j < gyou; j++) {
            int b = scanner.nextInt();
            gyouretu2[j][0] = b;
        }
        int goukei = 0;
        for (int i = 0; i < retu; i++) {
            for (int j = 0; j < gyou; j++) {
                goukei += gyouretu1[i][j] * gyouretu2[j][0];
            }
            System.out.println(goukei);
            goukei=0;
        }
    }
}

Measured memory_bytes: 39880
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

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

#define MOD 1000000007

void solve(int test_case) {//227
	int i;
	cin>>i;
	for(;i<=999;i++) {
		if(i%10==(i%100)/10&&i%10==i/100){
			cout<<i;
			return;
		}
	}
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 3512
#!/usr/bin/env python3
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def solve():
    X, N = map(int, input().split())
    if N == 0:
        P  =[]
    else:
        P = list(map(int, input().split()))

    b = [0] * 1000
    for p in P:
        b[p] = 1

    ans = 0
    for i in range(len(b)):
        if b[i] == 0:
            if abs(X - i) < abs(X - ans):
                ans = i
    print(ans)


def main():
    solve()


if __name__ == '__main__':
    main()


Measured memory_bytes: 9912
n  = int(input())
a = []
for i in range(n-1):
    a.append([int(i) for i in input().split()])
a.append([0,0,1])
#print(a)

for i in range(n):
    time = a[i][0]+a[i][1]
    for j in range(i+1, n):
        if(time < a[j][1]):
            time = a[j][0]+a[j][1]
        else:
            while(True):
                if(time%a[j][2] == 0):
                    time += a[j][0]
                    break
                else:
                    time += 1
    print(time)

Measured memory_bytes: 3188