akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

const int N = 2004;

int a[N][N];

int up[N][N];
int dw[N][N];
int lf[N][N];
int rt[N][N];

int n, m;
	
void init() {
	for (int j = 0; j < m; j++) {
		up[0][j] = (a[0][j] == 0);
		for (int i = 1; i < n; i++) {
			if (a[i][j]) up[i][j] = 0;
			else up[i][j] = 1 + up[i - 1][j];
		}
	}
	for (int j = 0; j < m; j++) {
		dw[n - 1][j] = (a[n - 1][j] == 0);
		for (int i = n - 2; i >= 0; i--) {
			if (a[i][j]) dw[i][j] = 0;
			else dw[i][j] = 1 + dw[i + 1][j];
		}
	}
	for (int i = 0; i < n; i++) {
		lf[i][0] = (a[i][0] == 0);
		for (int j = 1; j < m; j++) {
			if (a[i][j]) lf[i][j] = 0;
			else lf[i][j] = 1 + lf[i][j - 1];
		}
	}
	for (int i = 0; i < n; i++) {
		rt[i][m - 1] = (a[i][m - 1] == 0);
		for (int j = m - 2; j >= 0; j--) {
			if (a[i][j]) rt[i][j] = 0;
			else rt[i][j] = 1 + rt[i][j + 1];
		}
	}
}

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);

	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			char c;
			cin >> c;
			a[i][j] = (c == '#');
		}
	}
	init();
	int ans = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			ans = max(ans, up[i][j] + dw[i][j] + lf[i][j] + rt[i][j] - 3);
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 78720
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef set <int> :: iterator sitr;
typedef set <ll> :: iterator sltr;
#define mset multiset
typedef mset <int> msi;
typedef mset <ll> msll;
typedef mset <int> :: iterator msitr;
typedef mset <ll> :: iterator msltr;
#define mp make_pair
#define pb push_back
#define pob pop_back
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
int n,xmax,ymin,m,x,y;
int main(){
    xmax = -101;
    ymin = 101;
    cin>>n>>m>>x>>y;

    for(int i=1;i<=n;i++){
        int temp;
        cin>>temp;
        xmax = max(temp,xmax);
    }

    for(int i=1;i<=m;i++){
        int temp;
        cin>>temp;
        ymin = min(temp,ymin);
    }

    bool has=false;
    for(int i=x+1;i<=y;i++){
        if(i<=ymin && i>xmax){
            has=true;break;
        }
    }
    if(has)cout<<"No War\n";
    else cout<<"War\n";




}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define inv(n, a) for(int i = 0; i < n; i++) cin >> a[i]
#define MOD 1000000007
#define INF 1e7
#define LINF 1e15
typedef long long ll;
typedef long double ld;
using Graph = vector<vector<int>>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
// 'a' = 97 'z' = 122 => 'a' = 0 'z' = 25

int main() {
    int n, k; cin >> n >> k;
    vector<bool> b(n, false);
    rep(i, k){
        int d; cin >> d;
        rep(j, d){
            int a; cin >> a;
            a--;
            b[a] = true;
        }
    }
    int ans = 0;
    rep(i, n){
        if(!b[i]) ans++;
    }
    cout << ans << endl;
}


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

#include <iostream>
#include <fstream>

#include "bits/stdc++.h"

using namespace std;
#define int long long
#define FOR(i, a, b) for(int i=(int)(a);i<(int)(b);++i)
#define RFOR(i, a, b) for(int i = (int)(b-1);i>=(int)(a);--i)
#define REP(i, n)  FOR(i,0,(n))
#define RREP(i, n) RFOR(i,0,(n))
typedef vector<int> vec;


class CAllGreen {
public:
    vector<int> ans;
    int g, d;
    vec p, c;

    void dfs(int v, vector<bool> f, int sum, int cnt) {
      if (sum >= g) {
        ans.push_back(cnt);
        return;
      }
      if (v == d) {
        RREP(i, f.size()) {
          REP(j, p[i]) {
            if (!f[i]) {
              cnt++;
              sum += 100 * (i + 1);
              if (sum >= g) {
                ans.push_back(cnt);
                return;
              }
            }
          }
          if (!f[i]) sum += c[i];
        }
        return;
      }
      //全完しない
      dfs(v + 1, f, sum, cnt);
      //全完する
      vector<bool> tf = f;
      tf[v] = true;
      dfs(v + 1, tf, sum + 100 * (v + 1) * p[v] + c[v], cnt + p[v]);

      return;
    }

    void solve(std::istream &in, std::ostream &out) {
      in >> d >> g;
      p = c = vec(d);
      REP(i, d) {
        in >> p[i] >> c[i];
      }
      vector<bool> f(d, false);
      dfs(0, f, 0, 0);
      int m = *min_element(ans.begin(), ans.end());
      out << m << endl;
    }
};


signed main() {
  ios::sync_with_stdio(false);
  cout.tie(0);
  cout << fixed;
  CAllGreen solver;
  std::istream &in(std::cin);
  std::ostream &out(std::cout);
  solver.solve(in, out);
  return 0;
}


Measured memory_bytes: 256
//sajeedreefy
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int d,t,s;
    cin >> d >> t >> s;
    if(s*t>=d)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}


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

int W, H;
vector<vector<char>> s;

// 最短経路[y][x]
vector<vector<int>> cost;

// 最短経路を求めるためのキューを使った幅優先探索
int bfs() {
    // 上下左右
    int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};

    // 座標キュー
    queue<pair<int, int>> que;
    // スタート: (0, 0)
    que.push(make_pair(0, 0));
    cost[0][0] = 0;

    while (!que.empty()) {
        // 現在地
        pair<int, int> p = que.front();
        que.pop();

        if(p == make_pair(H-1, W-1)) return cost[p.first][p.second];
        for (int i = 0; i < 4; i++) {
            // 現在地から上下左右、次にどこに行くか
            int n_y = p.first + dy[i], n_x = p.second + dx[i];
            // 壁より外側ならcontinue
            if (n_x < 0 || n_y < 0 || n_x >= W || n_y >= H) continue;
            // 元々黒ならそこは通れないのでcontinue
            if (s[n_y][n_x] == '#') continue;
            // すでに探索済みならcontinue
            if (cost[n_y][n_x] != -1) continue;

            cost[n_y][n_x] = cost[p.first][p.second] + 1;
            que.push(make_pair(n_y, n_x));
        }
    }
    return -1;
}


// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    cin >> H >> W;
    s = vector<vector<char>>(H, vector<char>(W));
    int white = 0;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cin >> s[i][j];
            if (s[i][j] == '.') white++;
        }
    }

    // 全てのマスを-1で初期化
    cost = vector<vector<int>>(H, vector<int>(W, -1));
    int min_cost = bfs();
    if (min_cost == -1) {
        cout << -1 << endl;
    } else {
        // ゴール分の白カウントは入ってるが、スタート分の白カウントがmin_costに入ってないので+1する
        cout << white - (min_cost + 1) << endl;
    }
    return 0;
}


Measured memory_bytes: 256
n = int(input())
xy = [[int(i) for i in input().split()]for j in range(n)]

ans = 0

for i in range(n):
    for j in range(i+1,n):
        ans += ((xy[i][0] - xy[j][0]) ** 2 + (xy[i][1] - xy[j][1]) ** 2) ** 0.5
        
print(ans*4/(n*2))

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using bint = boost::multiprecision::cpp_int;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repSE(i,s,n) for (int i = (s); i < (n); i++)
#define rrepSE(i,s,e) for (int i = (s); i > (e); i--)
#define ssort(v) sort(v.begin(), v.end())
#define gsort(v) sort(v.rbegin(), v.rend())
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }
#define DEBUG_PRINT(var) std::cout << #var << " = " << var << "\n";

int main()
{
    int n;
    cin >> n;
    vector<ll> a(n+1);
    rep(i,n) cin >> a[i+1];
    ssort(a);
    // ll ans = a[0];
    // repSE(i,1,(n - 2)/2+1) {
    //     ans += 2*a[i];
    // }
    // if (n % 2 == 1) ans += a[(n-2)/2 + 1];
    ll ans = 0;
    repSE(i,1,n) {
        ans += a[n - i/2];
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 4840
#include <iostream>
#include<sstream>
#include<string>
#include<vector>
#include <cmath>
#include <limits>
#include <queue>
#include<algorithm>
#include<cstring>
#include <cstdlib>
#include <cstdio>
#include <set>
#include <iomanip>
#include <map>
#include <stack>
#include <memory>
 
using namespace std;
 
#define rep(i,n) for (int (i)=0;(i)<(n);i++)
const long long MAX = 1e9;
const int NIL = -1;


int getNot0(int h[], int n){
    int i = 0;
    bool flag;
    while(h[i] == 0 && i < n){
        i++;
    }
  	if (i >= n) return NIL;
    else if (h[i] != 0) return i;
    else return NIL;
}


int main(){
    int n;
    cin >> n;
    int h[n];
    rep(i,n) cin >> h[i];
    int res = 0;
    int counter = 0;
    while (getNot0(h,n) != NIL && counter < 1e8){
        res++;
        int i = getNot0(h,n);
        while(h[i+1] >= h[i] && i < n){
            --h[i];
            i++;
        }
        --h[i];
        counter++;
        if (getNot0(h,n) == NIL) break;
    }
    cout << res << endl;

    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

const ll INF = 1LL << 60;

vector<int> G[(int)1e5 + 5];

int color[(int)1e5 + 5];
ll N, M;

bool dfs(int v, int c) {
    color[v] = c;
    for (int i = 0; i < G[v].size(); i++) {
        // 隣接している頂点が同じ色
        if (color[G[v][i]] == c) return false;

        // 隣接している頂点がまだ塗られていない
        if (color[G[v][i]] == 0 && !dfs(G[v][i], -c)) return false;
    }

    return true;
}
int main() {
    cin >> N >> M;
    rep(i, M) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    bool nibu = true;
    for (int i = 0; i < N; i++) {
        if (color[i] == 0) {
            if (!dfs(i, 1)) {
                nibu = false;
                break;
            }
        }
    }

    if (nibu) {
        // ll black = N / 2;
        // if (N % 2 == 1) {
        //     black++;
        // }
        // ll white = N / 2;

        // ll ans = black * white - M;
        ll b = 0, w = 0;
        rep(i, N) {
            if (color[i] == 1) {
                b++;
            } else {
                w++;
            }
        }
        ll ans = b * w - M;
        cout << ans << endl;
    } else {
        // 全部の辺 - M
        ll ans = N * (N - 1) / 2;
        ans -= M;

        cout << ans << endl;
    }
}

Measured memory_bytes: 9928
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"

int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long long x, y,i=1;
    cin>>x;
    while(i<=9)
    {
       if(x%i==0 && x/i>=1 && x/i<=9)
       {
          cout<<"Yes"<<endl;
       return 0;
       }
       i++;


    }
              cout<<"No"<<endl;

    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <cmath>   
#include<cctype>
#include<string>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <utility> 

#define rep(i,m,n) for(int i = m;i < n;++i)
using namespace std;
using ll = long long;
using R = double;
const ll inf = 1LL << 50;
const int MOD = 1e9 + 7;



int main() {	
	int d, g;
	cin >> d >> g;


	vector< vector<int> > v(d,vector<int>(3,0));
	rep(i, 0, d) {
		int p, c;
		cin >> p >> c;
		v[i] = { p,c,(i+1)*100 };
	}
	reverse(v.begin(),v.end());


	vector<int> ans;



	for (int bit = 0; bit < (1 << d); bit++) {
		int tempnum = 0;
		int temptotal = 0;
		bool fl = 0;
		rep(i, 0, d) {
			if (bit & (1 << i)) {
				tempnum += v[i][0];
				temptotal += v[i][1] +  v[i][2]* v[i][0];
			}
		}
		
		if (temptotal < g) {
			rep(i, 0, d) {
				if (!(bit & (1 << i))) {
					rep(j, 0, v[i][0]){
						if (temptotal >= g) {
							break;
						}
						tempnum++;
						temptotal += v[i][2];
					}
				}
				if (fl)break;
			}
		}

		if (temptotal >= g) {
			ans.push_back(tempnum);
		}
	}

	int a = 1010;
	rep(i, 0, ans.size()) {
		a = min(a, ans[i]);
	}
	cout << a << endl;

	return 0;

}


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

#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define OUT(a) cout << (a) << "\n"
#define ll long long
#define uint unsigned int
#define ushort unsigned short
#define ulong unsigned long

ll MOD = 10e9 + 7;

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

    int ruiseki[n];
    ruiseki[0] = 1;
    for(int i=1; i<n; i++) {
        if (s[i] == s[i-1]) ruiseki[i] = ruiseki[i-1] + 1;
        else ruiseki[i] = 1;
    }
    int rmax = 0;
    for(int i=n-1; i>=0; i--) {
        if (s[i] == 'R') {
            if (rmax == 0) rmax = ruiseki[i] + 1;
            ruiseki[i] = rmax - ruiseki[i];
        } else {
            rmax = 0;
        }
    }


    vector<int> hito(n, 0);
    REP(i, n) {
        hito[i] = i;
        if (ruiseki[i]%2==0) {
            if (s[i] == 'R') {
                hito[i] += ruiseki[i];
            } else {
                hito[i] -= ruiseki[i];
            }
        } else {
            if (s[i] == 'R') {
                hito[i] += ruiseki[i] - 1;
            } else {
                hito[i] -= ruiseki[i] - 1;
            }
        }
        hito[i] = max(0, hito[i]);
        hito[i] = min(n-1, hito[i]);
    }
    vector<int> ans(n, 0);
    REP(i, n) {
        ans[hito[i]]++;
    }
    REP(i, n) {
        printf("%d", ans[i]);
        if(i!=n-1) printf(" ");
    }
    printf("\n");
    return 0;
}



Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include "math.h"
#include <set>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define VI vector<int>
#define debug(x) cout<<#x<<": "<<x<<endl
#define DEBUG(x) cout<<#x<<": "<<x<<endl
int N;
vector <int > a,b;





int main()
{

	cin >> N;

	a.resize(N);
	b.resize(N);
	double suma=0,sumb=0;
	REP(i,N){
		cin >> a[i];
	}
	REP(i,N){
		cin >> b[i];
	}
	double sub = 0;
	double sub1 = 0;
	REP(i,N){
		if(a[i]>b[i])
			sub += a[i] - b[i];
		else if(a[i]<b[i]){
			sub1 += b[i]-a[i];
			if((b[i]-a[i])%2==1)
				sub1--;
		}
	}

	if(sub*2 > sub1 ){
		cout << "No";
	} else {
		cout << "Yes";
	}
}





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

int n;
int x[25],y[25],r[25],c[25];
int cover[25];
double d[25][25];
bool check[1<<25];
int cnt,comb,a,b;
int m,ans;
int u;

double dis(int i,int j){
  return sqrt( (x[i]-x[j])*(x[i]-x[j]) + (y[i]-y[j]) * (y[i]-y[j]) );
}

void cov(int a){
  cover[a] = -1;
  for(int j=a-1;j>=0;j--){
    if(d[j][a]<r[a]+r[j] && u>>j & 1){
      cover[a] = j;
      break;
    }
  }
} 

  
void rec(void){
  int cnt;

  if(check[u])return;
  check[u] = true;

  for(int i=1;i<=4;i++){
    cnt = 0;
    /*
    for(int j=0;j<n;j++){
      if( (u>>j & 1) && cover[j]<0 && c[j] == i)cnt++;
    }
    if(cnt==6){
      for(int j=0;j<n;j++){
	if(c[j] == i)u -= 1<<j;
      }
      for(int j=0;j<n;j++)cov(j);

      ans += 6;
      m = max(m,ans);
      if(!check[u]){
        check[u] = true;
	rec();
	if(!u)return;
      }
      ans -= 6;

      for(int j=0;j<n;j++){
	if(c[j] == i)u += 1<<j;
      }
      for(int j=0;j<n;j++)cov(j);
    }else{
    */
      for(int j=0;j<n;j++){
	if( (u>>j & 1) && cover[j]<0 && c[j] == i){
	  for(int k=j+1;k<n;k++){
	    if( (u>>k & 1) && cover[k]<0 && c[k] == i){
	      u -= 1<<j;
	      u -= 1<<k;
	      for(int l=0;l<n;l++)cov(l);

	      ans += 2;
	      m = max(m,ans);
	      rec();
	      if(!u)return;
	      ans -= 2;

	      u += 1<<j;
	      u += 1<<k;
	      for(int l=0;l<n;l++)cov(l);
	    }
	  }
	}
      }
      //}
  }
}



int main(){
  while(1){
    cin >> n;
    if(!n)break;

    for(int i=0;i<n;i++)cin >> x[i] >> y[i] >> r[i] >> c[i];

    for(int i=0;i<n;i++){
      for(int j=i+1;j<n;j++)d[i][j] = dis(i,j);
    }

    u = (1<<n) - 1;
    for(int i=0;i<(1<<n);i++)check[i] = false;
    for(int i=0;i<n;i++)cov(i);

    
    m = 0;
    ans = 0;
    rec();

    cout << m << endl;
  }
}

Measured memory_bytes: 16000
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<cmath>

using namespace std;

long long dp[3][100100] = {};
const long long INF = 1LL << 60;
#define MOD 1000000007

template<class T> inline bool chmin(T & a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

/**
* @fn
* 最大値を取ります.Vector<int>を渡すこと.
*/
long long int imax(vector<int> a) {
	int MAX = -10000000;
	for (int i = 0; i < a.size(); i++) {
		if (MAX < a.at(i)) MAX = a.at(i);
	}
	return MAX;
}

/**
* @fn
* 最小値を取ります.Vector<int>を渡すこと.
*/
long long int imin(vector<int> a) {
	int MIN = 1000000000;
	for (int i = 0; i < a.size(); i++) {
		if (MIN > a.at(i)) MIN = a.at(i);
	}
	return MIN;
}


long long int absmin(vector<int> a, long long int b) {
	int mini = 100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (mini > abs(a.at(i) - b)) {
			mini = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}

int gcd(int a, int b)
{
	if (a < b) swap(a, b);
	if (b < 1) return -1;
	if (a % b == 0) return b;
	return gcd(b, a % b);
}

//ここまでライブラリ
//ここから本文

long long int tpimin(vector<int> a) {
	int MIN = 1000000000;
	int number = 0;
	for (int i = 0; i < a.size(); i++) {
		if (MIN > a.at(i)) MIN = a.at(i);
		number = i;
	}
	return number;
}



int main() {
	int m, n;
	cin >> n >> m;
	vector<string> a(m + 2);
	vector<string> b(n + 2);
	/*for (int i = 0; i < m + 2; i++) {
		a.at(i) = string(1000, 'a');
	}
	for (int i = 0; i < n + 2; i++) {
		b.at(i) = string(1000, 'a');
	}*/

	for (int i = 0; i < n; i++) {
		cin >> b.at(i);
	}
	for (int i = 0; i < m; i++) {
		cin >> a.at(i);
	}
	if (m == 1) {
		for (int i = 0; i < n; i++) {
			if (b.at(i).find(a.at(0).at(0)) != string::npos) {
				cout << "Yes" << endl;
				return 0;
			}
		}
		cout << "No" << endl;
		return 0;
	}

	for (int i = 0; i <= n - m; i++) {
		for (int j = 0; j <= n - m; j++) {
			for (int p = 0; p < m + 1; p++) {
				if (p == m) {
					cout << "Yes" << endl;
					return 0;
				}
				//				cout << b.at(i + p).substr(j, n) << "|" << a.at(i + p) << endl;
				if (b.at(i + p).substr(j, m) != a.at(p)) break;
			}
		}
	}
	cout << "No" << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

int N;
vector<ll> a(100001, 0);

int main(void){
	
	scanf("%d", &N);
	for(int i = 0; i < N; ++i) scanf("%lld", &a[i]);
	
	ll a_sum = 0, b_sum = 0, a_ans = 0, b_ans = 0;
	for(int i = 0; i < N; ++i){
	    a_sum += a[i], b_sum += a[i];
	    if(i % 2 == 0){ //偶数番目
	        if(a_sum < 1)  a_ans += abs(1 - a_sum), a_sum = 1;  //正の数がほしい
	        if(b_sum > -1) b_ans += abs(-1 - b_sum), b_sum = -1;//負の数がほしい
	    }
	    else{   //奇数番目
	        if(a_sum > -1) a_ans += abs(-1 - a_sum), a_sum = -1;//負の数がほしい
	        if(b_sum < 1)  b_ans += abs(1 - b_sum), b_sum = 1;  //正の数がほしい
	    }
	}
	
	ll ans = min(a_ans, b_ans);
	printf("%lld\n", ans);
	
    return 0;
}


Measured memory_bytes: 1024
#C - Distinct or Not
#最初の要素数(n)と重複を取り除いた後の要素数(after_set)を比較する

#操作前の要素数(n)とリスト(numbers)
n = int(input())
numbers = list(map(int,input().split()))

#重複を取り除く(set()を使う)
unique_numbers = list(set(numbers))
after_set = len(unique_numbers)

#一致していれば'YES'、一致していなければ'NO'を出力
if(n == after_set):
    print('YES')
else:
    print('NO')

Measured memory_bytes: 25172
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n,k=map(int, input().split())
    l=[list(map(int,input().split())) for i in range(n)]
    l.sort(key=lambda x:x[0])
    kosu=0
    for i in range(n):
        kosu+=l[i][1]
        if kosu>=k:
            print(l[i][0])
            break
resolve()

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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = (n-1); i >= 0; --i)

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

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

const int MAX = 200005;
const int INF = 1001001001;
const int MOD = 1000000007;

struct mint {
    long long x;
    mint(long long x=0):x(x % MOD + (0 <= x ? 0 : MOD)) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint& a) { if ((x += a.x) >= MOD) x -= MOD; return *this; }
    mint& operator-=(const mint& a) { if ((x -= a.x) < 0) x += MOD; return *this; }
    mint& operator*=(const mint& a) { (x *= a.x) %= MOD; return *this; }
    mint operator+(const mint& a) const { return mint(x) += a; }
    mint operator-(const mint& a) const { return mint(x) -= a; }
    mint operator*(const mint& a) const { return mint(x) *= a; }

    // for prime mod
    mint inv() const {
        long long a = x, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        return mint(u);
    }
    mint& operator/=(const mint& a) { return *this *= a.inv(); }
    mint operator/(const mint& a) const { return mint(x) /= a; }
};
istream& operator>>(istream& is, const mint& a){ return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a){ return os << a.x; }

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

    vector<string> a(H);
    rep(i, H) cin >> a[i];

    vector<vector<mint>> dp(H, vector<mint>(W));
    dp[0][0] = 1;

    queue<P> q;
    q.emplace(0, 0);
    vector<vector<bool>> used(H, vector<bool>(W));
    while (!q.empty()) {
        P p = q.front(); q.pop();
        int y = p.first, x = p.second;

        if (0 <= y-1) dp[y][x] += dp[y-1][x];
        if (0 <= x-1) dp[y][x] += dp[y][x-1];

        if (y+1 < H && !used[y+1][x] && a[y+1][x] != '#') {
            q.emplace(y+1, x);
            used[y+1][x] = true;
        }
        if (x+1 < W && !used[y][x+1] && a[y][x+1] != '#') {
            q.emplace(y, x+1);
            used[y][x+1] = true;
        }
    }

    cout << dp[H-1][W-1] << endl;
}

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

#pragma comment(linker, "/stack:200000000")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define FASTIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define IN freopen("input.txt", "r", stdin);
#define OUT freopen("output.txt", "w", stdout);
#define LL long long
#define MOD 1000000007
#define INF 1000000000000000000
#define all(x) (x).begin(), (x).end()
#define pb(x) push_back(x)

using namespace std;

const int N=3000;
int n;
double p[N], f[N][N];

int main()
{
// 	IN;OUT;
	FASTIO;
	cin >> n;
	for (int i=1; i<=n; i++) cin >> p[i];
	for (int i=0; i<n; i++)
		for (int j=i+1; j<=n; j++) f[i][j] = 0;
	f[1][1] = p[1];
	f[1][0] = 1-p[1];
	for (int i=2; i<=n; i++) {
		f[i][0] = f[i-1][0]*(1-p[i]);
		for (int j=1; j<=i; j++) 
			f[i][j] = f[i-1][j]*(1-p[i]) + f[i-1][j-1]*p[i];
	}
	double ans=0;
	for (int i=n/2+1; i<=n; i++) ans += f[n][i];
	cout << fixed;
	cout << setprecision(10);
	cout << ans;
	return 0;
}


Measured memory_bytes: 70656
#include<bits/stdc++.h>
using namespace std;
int A[300005];
int main()
{
    int N,i;
    scanf("%d", &N);
    for(i=0; i<3*N; i++)   scanf("%d", &A[i]);
    sort(A, A+ (3*N));
    long long ans = 0;
    
    for(i=N; i<3*N; i+=2)   ans += A[i];
    cout<<ans<<endl;
    return 0;
}

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

int main() {
	int N; cin >> N;
	string ans = "";
	while (N != 0) {
		if (N % 2 != 0) {
			N--;
			ans = "1" + ans;
		}
		else ans = "0" + ans;
		N /= -2;
	}
	if (ans == "") ans = "0";
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
double get()
{
	int p,a,b,c,d,e,f,s,m;
	cin>>p>>a>>b>>c>>d>>e>>f>>s>>m;
	p=f*s*m-p;
	int time=a+b+c,use=d+e;
	time+=use*m;
	return 1e5*p/time;
}
int n;
main()
{
	while(cin>>n,n)
	{
		vector<pair<double,string> >a;
		for(int i=0;i<n;i++)
		{
			string s;cin>>s;
			a.push_back(make_pair(-get(),s));
		}
		sort(a.begin(),a.end());
		for(int i=0;i<n;i++)cout<<a[i].second<<endl;
		cout<<"#\n";
	}
}



Measured memory_bytes: 3180
#include<iostream>
#include<algorithm>
#include<cmath>
#define INF 1<<28
using namespace std;

int a[222], b[222], c[222];
int d, n;
int t[222];
int memo[222][222];

int solve(int p, int q){
  if(p == d-1) return 0;
  if(memo[p][q]) return memo[p][q];
  
  int ret = -INF;
  for(int i=0;i<n;i++) 
    if(a[i] <= t[p+1] && t[p+1] <= b[i])
      ret = max(solve(p+1, i)+abs(c[q]-c[i]), ret);
  
  return memo[p][q] = ret;
}

int main(){
  
  cin >> d >> n;
  for(int i=0;i<d;i++) cin >> t[i];
  for(int i=0;i<n;i++) cin >> a[i] >> b[i] >> c[i];
  
  int ans = -INF;
  for(int i=0;i<n;i++)
    if(a[i] <= t[0] && t[0] <= b[i])
      ans = max(solve(0, i), ans);
  
  cout << ans << endl;
}

Measured memory_bytes: 1352
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <list>
#include <string>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <iomanip> // setprecisionを使用するのに必要 cout << fixed << setprecision(15) << p でpを小数点以下15桁表示
using namespace std;
#define REPD(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) REPD(i, 0, n)
typedef long long ll;
#define fin(ans) cout << (ans) << '\n'
/*

*/
int main()
{
    int K,N;
    cin >> N >> K;
    int temp;
    map<int,int>numbers;
    REP(i,N){
        cin >> temp;
        numbers[temp]++;
    }
    int count = 0;
    int nullity = numbers.size() -K;
    if(nullity <= 0){
        fin(0);return 0;
    }
    //printf("numbers.size = %d\n",numbers.size());
    //printf("nullty = %d\n",nullity);
    REPD(i,1,200000){
        for (const auto &p : numbers)
        {
            if(p.second == i){
                //printf("%dを書き換え\n",p.first);
                count += p.second;
                nullity--;
            }
            if(nullity == 0){
                fin(count);return 0;
            }
        }
    }
    fin("!!");
    return 0;
}

Measured memory_bytes: 9600
def ans_xyz(x, y, z):
    return ((x ** 2) + (y ** 2) + (z ** 2) + (x * y) + (y * z) + (z * x))

N = int(input())
ans = [0] * (10 ** 5)
for x in range(1, 101):
    for y in range(1, 101):
        for z in range(1, 101):
            ans[ans_xyz(x, y, z)] += 1
print(*ans[1:N + 1], sep='\n')



Measured memory_bytes: 10024
<?php
fscanf(STDIN, '%d %d %d', $N, $K, $S);
$A = explode(' ', trim(fgets(STDIN)));
$alt = ($S + 1) % 100000;
$ans = [];
for ($i = 0; $i < $N; $i++) {
    $ans[$i] = $i < $K ? $S : $alt;
}
echo implode(' ', $ans);


Measured memory_bytes: 11892
#include <bits/stdc++.h>
//#include <tr1/unordered_map>
//#include "Bignum/bignum.h"
//#define big bignum
#define lowbit(x) (x & -x)
#define debug(x) (cout << "#x = " << (x) << endl)
#define Set(x, i) memset (x, i, sizeof(x))
#define R register
#define For(i, j, k) for(R int i = (j); i <= (int) (k); ++i)
#define Rep(i, j, k) for(R int i = (j); i >= (int) (k); --i)
#define Cross(i, j, k) for(R int i = (j); i; i = (k))
using namespace std;
typedef long long ll;
const ll N = 100011;
const ll INF = 5e16;

namespace IO {

	inline char gc() {
		static char buf[100000], *p1 = buf, *p2 = buf;
		return (p1 == p2) && (p2 = (p1 = buf) +
			fread(buf, 1, 100000, stdin), p1 == p2)? EOF: *p1++;
	}

	#define dd ch = getchar()
	inline ll read() {
		R ll x = 0; R int f = 0; R char dd;
		for (; !isdigit(ch); dd) f ^= (ch == '-');
		for (; isdigit(ch); dd)  x = x * 10 + (ch ^ 48);
		return f? -x: x;
	}
	#undef dd

	inline void write ( ll x ) {
		if (x < 0) x = -x, putchar('-');
		if (x > 9) write(x / 10); putchar(x % 10 | 48);
	}

	inline void wrn ( ll x ) { write(x), putchar(' '); }

	inline void wln ( ll x ) { write(x), putchar('\n'); }

	inline void wlnn ( ll x, ll y ) { wrn(x), wln(y); }

}

using IO::wln;
using IO::read;

int main()
{
//	freopen(".in", "r", stdin);
//	freopen(".out", "w", stdout);
	
	ll A = read(), B = read();
	if (A <= 9 && B <= 9 && A >= 1 && B >= 1) return wln(A * B), 0;
	return puts("-1"), 0;
}

/*

*/






Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
template <typename T>
bool isPrime(T n){
  
  for(T i = 2; n >= i*i; i++){
    if(!(n%i)){return false;}
  }
  return true;
}
int main(){
	int n;cin>>n;
	vector<int> A;
	for(int i = 11; 55555 > i && A.size() != n; i+=10){
		if(isPrime(i))A.push_back(i);
	}
	for(int i = 0; n > i; i++){
		cout << A[i];
		if(i+1 != n)cout << " ";
	}
	cout << endl;
}

Measured memory_bytes: 256
#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++)
#define co(x) cout << x <<endl
#define cs(x) cout << x <<" "
#define ALL(a) (a).begin(),(a).end()
#define MOD 1e9+7
typedef long long ll;
using namespace std;

int main()
{
	int x, y;
	cin >> x >> y;
	int ans = 0;
	if (abs(x) == abs(y)) ans = 1;
	else if (abs(x) < abs(y))
	{
		if (y >= 0)
		{
			ans = min(y - x, y + x + 1);
		}
		else
		{
			ans = min(-y - x + 1, -y + x + 2);
		}
	}
	else
	{
		if (x > 0)
		{
			ans = min(y + x + 1, -y + x + 2);
		}
		else
		{
			ans = min(y - x, -y - x + 1);
		}
	}
	co(ans);
	return 0;
}

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

using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(c) (c).begin(), (c).end()
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
const int MOD = 1000000007;

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

    vector<int> a(n);
    bool zzz = true;
    REP(i, n) {
        cin >> a[i];
        if (a[i] != 0) {
            zzz = false;
        }
    }
    if (zzz) {
        cout << "Yes" << endl;
        return 0;
    }

    if (n % 3 == 0) {
        sort(ALL(a));
        if (a[0] == a[n / 3 - 1] && a[n / 3] == a[n * 2 / 3 - 1] && a[n * 2 / 3] == a[n - 1]) {
            vector<int> b{a[0], a[n / 3], a[n * 2 / 3]};
            if ((b[0] ^ b[2]) != b[1]) {
                cout << "No" << endl;
                return 0;
            }
            if ((b[1] ^ b[0]) != b[2]) {
                cout << "No" << endl;
                return 0;
            }
            if ((b[2] ^ b[1]) != b[0]) {
                cout << "No" << endl;
                return 0;
            }
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    } else {
        cout << "No" << endl;
    }

}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
using namespace std;
int main(){
    int n,m,k;
    unsigned long int t=0;
    cin >> n >> m >> k;
    vector<int> a(n);
    vector<int> b(m);
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    for(int i=0;i<m;i++){
        cin >> b[i];
    }
    for(int i=0;i<m;i++){
        t = t + b[i];
    }
    int j = m;
    int ans = 0;
    for(int i=0;i<n+1;i++){
        while(j > 0 && t > k){
            --j;
            t -= b[j];
        }
        if(t > k){
            break;
        }
        ans = max(ans, i+j);
        if(i==n){
            break;
        }
        t += a[i];
    }
    cout << ans << endl;
}

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

int n;
char s[10055];
int d;

const int MOD = 1e9 + 7;

int dp[10055][155][2];

inline void add(int &a, int b) {
	a += b;
	
	if (a >= MOD) {
		a -= MOD;
	}
}
int rec(int id, int rem, int less) {
	if (id == n) {
		return rem == 0;
	}
	if (dp[id][rem][less] >= 0) return dp[id][rem][less];
	
	int res = 0;
	
	for (int i = 0; i < 10; i++) {
		if (i + '0' > s[id] && less == 0) {
			break;
		}
		
		add(res, rec(id + 1, (rem + i) % d, less || i + '0' < s[id]));
	}
	
	return dp[id][rem][less] = res;
}
int main() {
	scanf("%s", s);
	scanf("%d", &d);
	
	n = strlen(s);
	
	memset(dp, -1, sizeof(dp));
	
	printf("%d\n", (rec(0, 0, 0) - 1 + MOD) % MOD);
}


Measured memory_bytes: 13184
use std::vec::Vec;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn read_touple<T: std::str::FromStr + Copy>() -> (T, T) {
  let v: Vec<T> = read_vec();
  assert_eq!(v.len(), 2);
  (v[0], v[1])
}

fn main() {
    let n: usize = read();
    let ans = (n + 1) / 2;
    println!("{}", ans);
}


Measured memory_bytes: 4352
//@author :  |< U $ |-|
#include<cmath>
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<deque>
#include<queue>
#include<algorithm>
#include<list>
#include<cstring>
#include<unordered_map>
#define ll long long
// #define pb push_back
// #define pop pop_back
#define in(i,n) for(i=0;i<n;i++)
#define pi pair<long long ,long long>
#define mp make_pair
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define jaldi ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define inm1(b)  memset(b,-1,sizeof(b))
#define in0(b) memset(b,0,sizeof(b))
#define ininf(b) memset(b,1000000001,sizeof(b))
#define MOD 1e9+7
#define inf 10000000001
#define d1(a) cout<<a<<" "<<endl
#define d2(a,b) cout<<a<<" "<<b<<endl
#define d3(a,b,c) cout<<a<<" "<<b<<" "<<c<<endl
#define TakeInput freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
using namespace std;

int main(){
    jaldi
    #ifndef ONLINE_JUDGE
    TakeInput
    #endif

    ll i,j,k,n,m;
    ll t;
    
    string a,b;
    cin>>a>>b;

    n = a.length();
    m = b.length();

    ll mini = 1e9;
    for(i=0;i<n - m+1;i++){
        ll temp = i;
        ll count=0;
        for(j=0;j<m;j++){
            if(a[temp]!=b[j]){
                count++;
            }
            temp++;
        }
        // d1(count);
        mini = min(mini,count);
    }
    cout<<mini;
    
}


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

int main() {
    string s;
    cin>>s;
    int cnt=0;
    if(s[0]=='o') cnt++;
    if(s[1]=='o') cnt++;
    if(s[2]=='o') cnt++;
    cout<<700+100*cnt<<endl;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

static const int MAX_SIZE = 1 << 17;
const int INF=1001001001001001001ll;
int segMin[2 * MAX_SIZE ], segAdd[2 * MAX_SIZE ];

void init(){
    memset(segMin,0,sizeof(segMin));
    memset(segAdd,0,sizeof(segAdd));
}

void add(int a, int b, int x, int k = 0, int l = 0, int r = MAX_SIZE)
{
	if (r <= a || b <= l) return;

	if (a <= l && r <= b){
		segAdd[k] += x;
		return;
	}

	add(a, b, x, k * 2 + 1, l, (l + r) / 2);
	add(a, b, x, k * 2 + 2, (l + r) / 2, r);

	segMin[k] = min(segMin[k * 2 + 1] + segAdd[k * 2 + 1], segMin[k * 2 + 2] + segAdd[k * 2 + 2]);
}

int getMin(int a, int b, int k = 0, int l = 0, int r = MAX_SIZE)
{
	if (r <= a || b <= l) return INF;

	if (a <= l && r <= b) return (segMin[k] + segAdd[k]);

	int left = getMin(a, b, k * 2 + 1, l, (l + r) / 2);
	int right = getMin(a, b, k * 2 + 2, (l + r) / 2, r);

	return (min(left, right) + segAdd[k]);

}

int N,MM;
int LL[222222],RR[222222];

bool C(int x){
    int M=x+MM;
    if(M<N)return false;

    vint L(N),R(N);
    rep(i,N){
        L[i]=LL[i]+x;
        R[i]=RR[i]+x;
    }

    vector<pint>v;
    rep(i,N)v.pb({L[i],R[i]});
    sort(all(v));

    priority_queue<int,vint,greater<int>>que;
    int num=0;
    vint lis;
    for(int i=0;i<N;i++){
        int l,r;
        tie(l,r)=v[i];
        num++;
        que.push(r);

        if(l<num){
            int tmp=que.top();
            que.pop();
            lis.pb(tmp);
            num--;
        }
    }
    rep(i,lis.size()){
        chmax(lis[i],num+1);
    }

    vint latte(M+1);
    for(int i=0;i<M;i++)latte[i]=-1;
    for(auto r:lis)latte[r-1]++;
    for(int i=M;i>0;i--){
        if(latte[i]>0)return false;
        latte[i-1]+=latte[i];
    }
    return true;
}

signed main(){
    cin>>N>>MM;
    rep(i,N)cin>>LL[i]>>RR[i];

    int lb=-1,ub=N;
    while(ub-lb>1){
        int mid=(ub+lb)/2;
        if(C(mid))ub=mid;
        else lb=mid;
    }
    cout<<ub<<endl;
    return 0;
}


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

int grid[110][110];

int main(){
  int h,w,n;
  cin>>h>>w>>n;
  vector<int> a;
  rep(i,n){
    int A; cin>>A;
    rep(j,A){
      a.push_back(i+1);
    }
  }
  rep(hi,h){
    if(hi%2==0){
      rep(wi,w){
        grid[hi][wi]=a[a.size()-1];
        a.pop_back();
      }
    }else{
      for(int wi = w-1; wi>=0; wi--){
        grid[hi][wi]=a[a.size()-1];
        a.pop_back();
      }
    }
  }
  //answer
  rep(hi,h){
    rep(wi,w){
      cout<<grid[hi][wi]<<" ";
    }
    cout<<endl;
  }
}



Measured memory_bytes: 3752
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <valarray>
#include <vector>

#define EPS 1e-9
#define INF 1070000000LL
#define MOD 1000000007LL
#define fir first
#define foreach(it,X) for(auto it=(X).begin();it!=(X).end();it++)
#define ite iterator
#define mp make_pair
#define mt make_tuple
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define pb push_back
#define sec second
#define sz(x) ((int)(x).size())

using namespace std;

struct timer{
	time_t start;
	timer(){start=clock();}
	~timer(){cerr<<1.*(clock()-start)/CLOCKS_PER_SEC<<" secs"<<endl;}
};

typedef istringstream iss;
typedef long long ll;
typedef pair<ll,ll> pi;
typedef stringstream sst;
typedef vector<ll> vi;

int a[]={0,6000,4000,3000,2000};

int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	
	rep(i,4){
		int t,n;
		cin>>t>>n;
		cout<<a[t]*n<<endl;
	}
}

Measured memory_bytes: 1192
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
#define FOR(i,a,b) for (int i=(a),for_##i##_max=(b);i<=(for_##i##_max);++i)
#define RFOR(i,a,b) for (int i=(a),rfor_##i##_min=(b);i>=(rfor_##i##_min);--i)
#define REP(i,n) for (int i=0,rep_##i##_len=(n);i<(rep_##i##_len);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

namespace { // Basics

template<typename T>
void chmin(T &x, T y) {
  x = std::min(x, y);
}

template<typename T>
void chmax(T &x, T y) {
  x = std::max(x, y);
}

template<typename T>
__attribute__((unused))
const auto minimum = static_cast<T const &(*)(T const &, T const &)>(std::min);

template<typename T>
__attribute__((unused))
const auto maximum = static_cast<T const &(*)(T const &, T const &)>(std::max);

template<typename T>
__attribute__((unused))
T constexpr infty = std::numeric_limits<T>::max / 3;
template<>
__attribute__((unused))
auto constexpr infty<int> = 1'100'100'100;
template<>
__attribute__((unused))
auto constexpr infty<long long int> = 100'500'400'300'200'100LL;

using lli = long long int;
using ld = long double;

} // namespace

using namespace std;

int main() {
  // cout << fixed << setprecision(10);

  int A, B;
  cin >> A >> B;
  cout << max(A+B, max(A-B, A*B)) << endl;
  return 0;
}


Measured memory_bytes: 256
from collections import Counter


N = int(input())
S = input()


"""
異なる位置から取り出されたものは、同じものがあっても区別する
→各S[i]を入れるか入れないかみたいな話 : 2^N
→たとえば文字aについて、aが複数Sに入っていても、一つしか使えないが、使ったaが異なるなら出来上がりの部分列も区別する
→aを使わないorいずれかのaを一つだけ使う
"""

c = Counter(S)
ans = 1
MOD = 10**9 + 7
for v in c.values():
    ans *= v+1
    ans %= MOD

ans -= 1 # いずれの文字も使わないと空文字になるので
print(ans)

Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define printYes() cout << "Yes" << endl;
#define printNo() cout << "No" << endl;
#define printVector(v) rep(i, v.size()) cout << v[i] << endl;

int main()
{
  int N;
  cin >> N;
  vector<int> X(N);
  rep(i, N)
  {
    cin >> X[i];
  }
  int ans = INT32_MAX;
  rep(i, 100)
  {
    int P = i + 1;
    int HP = 0;
    rep(j, N)
    {
      HP += pow(X[j] - P, 2);
    }
    ans = min(ans, HP);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
from math import ceil
def solve():
    N = int(input())
    T = []
    A = []
    for _ in range(N):
        t, a = map(int,input().split())
        T.append(t)
        A.append(a)
    
    now_t = T[0]
    now_a = A[0]

    for i in range(1,N):
        mul = f(now_t,now_a,T[i],A[i])
        now_t = T[i] * mul
        now_a = A[i] * mul
    
    print(now_t + now_a)

def f(now_t, now_a, t, a):
    left = 0
    right = 10 ** 18
    while right - left > 1:
        mid = (right + left) // 2
        if now_t > t * mid or now_a > a * mid:
            left = mid
        else:
            right = mid
    
    return right

if __name__ == '__main__':
    solve()

Measured memory_bytes: 72676
N, T = map(int, input().split())
food1 = []
for _ in range(N):
    a, b = map(int, input().split())
    food1.append((a, b))
dp1 = [[0]*T for _ in range(N+1)]
dp2 = [[0]*T for _ in range(N+1)]
food2 = food1[::-1]
for i in range(N):
    a1, b1 = food1[i]
    a2, b2 = food2[i]
    for t in range(T):
        dp1[i+1][t] = max(dp1[i+1][t], dp1[i][t])
        if t+a1<T:
            dp1[i+1][t+a1] = max(dp1[i+1][t+a1], dp1[i][t]+b1)
        dp2[i+1][t] = max(dp2[i+1][t], dp2[i][t])
        if t+a2<T:
            dp2[i+1][t+a2] = max(dp2[i+1][t+a2], dp2[i][t]+b2)
ans = 0
for i in range(N):
    res = max(food1[i][1]+dp1[i][t]+dp2[N-i-1][T-t-1] for t in range(T))
    ans = max(ans, res)
print(ans)
    

        






Measured memory_bytes: 184708
//AC
#include <stdio.h>

#define rep(i,r,l) for(int i = r; i < l; i++)

int nextint(void){int n;scanf("%d",&n);return n;}
void printint(int d){printf("%d\n",d);}


int code_1(void){

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

    for(int n=1;n<=N;n++){ 

        int count=0;
        for(int i=1;i*i+2*i<=n;i++){
            for(int j=1;j*j+2*j<=n&&j<=i;j++){
                for(int k=1; k*k+2*k<=n&&k<=j;k++){
                    if(i*i+j*j+k*k+i*j+j*k+k*i==n){
                        if(i==j&&i==k){count++;}
                        else if(i!=j&&j!=k&&k!=i){count+=6;}
                        else{count+=3;}
                    }
                }
            }
        }

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

}

int code_2(void){

    int N=nextint();
    int n[10005]={0};

    rep(x,1,101){
        rep(y,1,101){
            rep(z,1,101){
                int k = x*x+y*y+z*z+x*y+y*z+z*x;
                if(k<=N) n[k]++;
            }
        }
    }

    rep(i,0,N){
        printf("%d\n",n[i+1]);
    }
}

int main(void){

    //code_1();
    code_2();

}


Measured memory_bytes: 1708
#include <bits/stdc++.h>
#define rep(i,x,n) for(int i=x; i<(int)(n); i++)
#define rep_eq(i,x,n) for(int i=x; i<=(int)(n); i++)
#define all(vec) vec.begin(),vec.end()
using namespace std;

using ll=long long;

using vi=vector<int>;
using vll=vector<ll>;
using vvi=vector<vi>;
using vs=vector<string>;
using vb=vector<bool>;

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

  int N,K; cin >>N >>K;
  vi x(N);
  rep(i,0,N) {cin >>x[i];}
  int ans=INT_MAX;
  rep_eq(i,0,N-K) {
    int temp1=abs(x[i])+abs(x[i+K-1]-x[i]);
    int temp2=abs(x[i+K-1])+abs(x[i+K-1]-x[i]);
    ans=min(ans,min(temp1,temp2));
  }
  cout <<ans <<'\n';
  return 0;
}


Measured memory_bytes: 3660
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>

int main()
{   int i,j;
    int h,w;
    
    while(1){
        scanf("%d %d",&h,&w);
        if (h==0 && w ==0) break;
        for(i=0; i < h; i++){
            for(j=0; j < w; j++) putchar('#');
            putchar('\n');
        }
        putchar('\n');
    }
    return 0; 
}



Measured memory_bytes: 2004
using System;
using System.Collections.Generic;

namespace ABC138_B
{
    class Program
    {
        static void Main(string[] args) {
            int n = int.Parse(Console.ReadLine());
            string[] input = Console.ReadLine().Split();

            List<int> list = new List<int>();
            double bunbo = 0;
            for (int i = 0; i < n; i++) {

                list.Add(int.Parse(input[i]));
                bunbo += (1 / (double)list[i]);
            }

            double ans = 1 / bunbo;

            //Console.WriteLine(bunbo);

            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 13140