akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define endl '\n'
#define pb push_back
#define fi first
#define se second
#define all(c) (c).begin(),(c).end()
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

const ll inf = 2e18;
const int mod = 998244353;
const int N = 1e6 + 10;

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

	int n, k;
	cin >> n >> k;
	int l[k], r[k];
	for(int i = 0; i < k; i++) {
		cin >> l[i] >> r[i];
	}
	int dp[n + 5] = {0};
	dp[1] = 1;
	for(int i = 1; i <= n; i++) {
		if(i >= 3) {
			dp[i] = (dp[i] + dp[i - 1]) % mod;
		}
		for(int j = 0; j < k; j++) {
			if(i + l[j] <= n) {
				dp[i + l[j]] = (dp[i + l[j]] + dp[i]) % mod;
			}
			if(i + r[j] + 1 <= n) {
				dp[i + r[j] + 1] = (dp[i + r[j] + 1] - dp[i] + mod) % mod;
			}
		}
	}
	cout << dp[n];

	return 0;
}

Measured memory_bytes: 5172
import sys
input = sys.stdin.readline
N, M, K = map(int, input().split())


class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


uf = UnionFind(N)

ab = []
for _ in range(M):
    a, b = map(int, input().split())
    uf.union(a - 1, b - 1)
    ab.append([a, b])

out = []
for x in range(N):
    out.append(uf.size(x)-1)
    # print(uf.size(x))

for x in ab:
    out[x[0] - 1] -= 1
    out[x[1] - 1] -= 1

cd = []
for _ in range(K):
    c, d = map(int, input().split())
    if uf.same(c - 1, d - 1):
        out[c - 1] -= 1
        out[d - 1] -= 1
print(" ".join(map(str, out)))


Measured memory_bytes: 34624
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+5,inf=0x3f3f3f3f;
#define mst(a) memset(a,0,sizeof a)
#define lx x<<1
#define rx x<<1|1
#define reg register
#define PII pair<int,int>
#define fi first 
#define se second
int H,W,K;
int d[4][2]={0,1,0,-1,1,0,-1,0};
int main(){
	scanf("%d%d%d",&H,&W,&K);
	vector<string>S(H);
	int sx,sy,ex,ey;
	scanf("%d%d%d%d",&sx,&sy,&ex,&ey);
	sx--,sy--,ex--,ey--;
	for(int i=0;i<H;i++) cin>>S[i];
	vector<vector<int> >a(H,vector<int>(W,1e9));
	queue<PII>q;
	a[sx][sy]=0;
	q.push({sx,sy});
	while(!q.empty()){
		 int x=q.front().fi,y=q.front().se;
		 q.pop();
		 for(int i=0;i<4;i++){
		 	 int nx=x,ny=y;
		 	 int tmp=a[x][y]+1;
		 	 for(int k=1;k<=K;k++){
		 	 	  nx+=d[i][0],ny+=d[i][1];
		 	 	  if(nx<0||nx>=H||ny<0||ny>=W||S[nx][ny]=='@'||a[nx][ny]<tmp) break;
		 	 	  if(a[nx][ny]>tmp){
		 	 	  		a[nx][ny]=tmp;
		 	 	  		q.push({nx,ny}); 
					}
			  }
		 }
	}
	printf(a[ex][ey]==1e9?"-1":"%d\n",a[ex][ey]);
	return 0;
}

Measured memory_bytes: 12232
n = int(input())
a = list(map(int,input().split()))
suma = sum(a)
sunuke = a[0]
minabso = tmpabso = abs(sunuke - (suma - sunuke))
for i in range (1,n-1):
         sunuke += a[i]
         tmpabso = abs(sunuke - (suma - sunuke))
         if minabso > tmpabso:
                  minabso = tmpabso
print(minabso)


Measured memory_bytes: 23800
#include <map>
#include <cstdio>

typedef std::pair<int, int> pii;

const int MAXN = 2e5;
int n, ecnt, head[MAXN + 5], fa[MAXN + 5], mx[MAXN + 5], ans[MAXN + 5];
std::map<pii, int> rch;

struct Edge { int to, nxt; } graph[MAXN * 2 + 5];

inline int max_ ( const int a, const int b ) { return a < b ? b : a; }

inline void link ( const int s, const int t ) {
	graph[++ ecnt] = { t, head[s] };
	head[s] = ecnt;
}

inline void init ( const int u ) {
	mx[u] = max_ ( u, mx[fa[u]] );
	for ( int i = head[u], v; i; i = graph[i].nxt ) {
		if ( ( v = graph[i].to ) ^ fa[u] ) {
			fa[v] = u, init ( v );
		}
	}
}

inline int reach ( const int u, const int lim ) {
	pii sta ( u, lim );
	if ( rch.count ( sta ) ) return rch[sta];
	int ret = 1;
	for ( int i = head[u], v; i; i = graph[i].nxt ) {
		if ( ( v = graph[i].to ) ^ fa[u] && v < lim ) {
			ret += reach ( v, lim );
		}
	}
	return rch[sta] = ret;
}

inline void solve ( const int u ) {
	for ( int i = head[u], v; i; i = graph[i].nxt ) {
		if ( ( v = graph[i].to ) ^ fa[u] ) {
			if ( mx[v] == v ) ans[v] = reach ( v, mx[u] );
			else if ( mx[u] == u ) {
				ans[v] = reach ( v, u ) - ( v > mx[fa[u]] ? 0 : reach ( v, mx[fa[u]] ) );
			}
			ans[v] += ans[u];
			solve ( v );
		}
	}
}

int main () {
	scanf ( "%d", &n );
	for ( int i = 1, u, v; i < n; ++ i ) {
		scanf ( "%d %d", &u, &v );
		link ( u, v ), link ( v, u );
	}
	init ( 1 );
	solve ( 1 );
	for ( int i = 2; i <= n; ++ i ) printf ( "%d%c", ans[i], i ^ n ? ' ' : '\n' );
	return 0;
}

Measured memory_bytes: 31328
import sys
from collections import deque
n = int(input())
q = deque()
for i in range(n):
    c = sys.stdin.readline()[:-1]
    if c[0] == 'i':
        q.appendleft(c[7:])
    elif c[6] == ' ':
        try:
            q.remove(c[7:])
        except:
            pass
    elif c[6] == 'F':
        q.popleft()
    else:
        q.pop()
print(*q)

Measured memory_bytes: 71848
dance = gets.chomp!
i = dance.length
judge = 0

for var in 1..i
  if var % 2 == 1
    if dance[var-1] == "L"
      judge += 1
    end
  else
    if dance[var-1] == "R"
      judge += 1
    end
  end
end

if judge == 0
  puts "Yes"
else
  puts "No"
end

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

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

int main(){
    ll n; cin >> n;
    vector<vector<bool>> a(n,vector<bool>(31));
    vector<ll> T(n);
    rep(i,n) cin >> T[i];
    ll sum=0;
    rep(i,n){
        sum ^= T[i];
    }
    rep(i,n){
        ll aaa=sum ^ T[i];
        cout << aaa;
        if(i<n-1) cout << " ";
        else cout << endl;
    }
}

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

using namespace std;

const int INF = 1e7;

struct Edge {
  int from, to, cap, flow, index;
  Edge(int from, int to, int cap, int flow, int index) :
  from(from), to(to), cap(cap), flow(flow), index(index) {}
};

struct Dinic {
  int N;
  vector<vector<Edge> > G;
  vector<Edge *> dad;
  vector<int> Q;
 
  Dinic(int N) : N(N), G(N), dad(N), Q(N) {}
 
  void AddEdge(int from, int to, int cap) {
    G[from].push_back(Edge(from, to, cap, 0, G[to].size()));
    if (from == to) G[from].back().index++;
    G[to].push_back(Edge(to, from, 0, 0, G[from].size() - 1));
  }
  long long BlockingFlow(int s, int t) {
    fill(dad.begin(), dad.end(), (Edge *) NULL);
    dad[s] = &G[0][0] - 1;
      
    int head = 0, tail = 0;
    Q[tail++] = s;
    while (head < tail) {
      int x = Q[head++];
      for (int i = 0; i < G[x].size(); i++) {
        Edge &e = G[x][i];
        if (!dad[e.to] && e.cap - e.flow > 0) {
          dad[e.to] = &G[x][i];
          Q[tail++] = e.to;
        }
      }
    }
    if (!dad[t]) return 0;

    long long totflow = 0;
    for (int i = 0; i < G[t].size(); i++) {
      Edge *start = &G[G[t][i].to][G[t][i].index];
      int amt = INF;
      for (Edge *e = start; amt && e != dad[s]; e = dad[e->from]) {
        if (!e) { amt = 0; break; }
        amt = min(amt, e->cap - e->flow);
      }
      if (amt == 0) continue;
      for (Edge *e = start; amt && e != dad[s]; e = dad[e->from]) {
        e->flow += amt;
        G[e->to][e->index].flow -= amt;
      }
      totflow += amt;
    }
    return totflow;
  }

  long long GetMaxFlow(int s, int t) {
    long long totflow = 0;
    while (long long flow = BlockingFlow(s, t))
      totflow += flow;
  return totflow;
  }
};

const int N = 111;

char ss[N][N];

int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; i++) {
    scanf("%s", ss[i]);
  }
  int s = n * m * 2 + n + m, t = s + 1;
  Dinic mf(t+1);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      int cur = i * m + j;
      if (ss[i][j] == 'S')
        mf.AddEdge(s, cur * 2 + 1, INF);
      if (ss[i][j] == 'T')
        mf.AddEdge(cur * 2, t, INF);
      if (ss[i][j] != '.') {
        mf.AddEdge(cur * 2, cur * 2 + 1, 1);
        mf.AddEdge(cur * 2 + 1, n * m * 2 + i, INF);
        mf.AddEdge(n * m * 2 + i, cur * 2,  INF);
        mf.AddEdge(cur * 2 + 1, n * m * 2 + n + j, INF);
        mf.AddEdge(n * m * 2 + n + j, cur * 2,  INF);
      }
    }
  }
  long long res = mf.GetMaxFlow(s, t);
  if (res >= INF) res = -1;
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 3840
#include<iostream>
using namespace std;
int main(){
  int n;
  int i;
  int card[4][13]={{}};
  cin >> n;
  char a;
  int b;
  for(i=0;i<n;i++) {
    cin >> a >> b;
    switch(a){
    case 'S':
      card[0][b-1]=1;
      break;
    case 'H':
      card[1][b-1]=1;
      break;
    case 'C':
      card[2][b-1]=1;
      break;
    case 'D':
      card[3][b-1]=1;
      break;
    }
  }
  for(i=0;i<52;i++) {
    switch(i/13){
    case 0:
      if(card[0][i%13]==0) cout << "S " << i+1 << endl;
      break;
    case 1:
      if(card[1][i%13]==0) cout << "H " << i%13+1 << endl;
      break;
    case 2:
      if(card[2][i%13]==0) cout << "C " << i%13+1 << endl;
      break;
    case 3:
      if(card[3][i%13]==0) cout << "D " << i%13+1 << endl;
      break;
    }
  }
  
  return 0;
}



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

int main()
{
    string s;
    cin>>s;
    int len = s.length();
    for(int i=1;i<len;i++)
    {
        string temp = s.substr(0 , len-i);
        if( temp.length()%2== 1)
        {
            continue;
        } else
        {
            int tl = temp.length();
            string temp2 = temp.substr(0 , tl/2);
            temp2 = temp2 + temp2;
            if( temp2 == temp)
            {
                cout<<temp2.length();
                return 0;
            }
        }
    }
}

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

using pii = pair<int,int>;
using ll = long long;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define repeat(i, j, k) for(int i = (j); i < (int)(k); i++)
#define all(v) v.begin(),v.end()
#define debug(x) cerr << #x << " : " << x << endl

template<class T> bool set_min(T &a, const T &b) { return a > b  ? a = b, true : false; }
template<class T> bool set_max(T &a, const T &b) { return a < b  ? a = b, true : false; }
// vector
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream& operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << "\t" << t; return os << endl; }
// pair
template<class T, class U> ostream& operator << (ostream &os , const pair<T, U> &v) { return os << "<" << v.first << ", " << v.second << ">"; }

const int INF = 1 << 30;
const ll INFL = 1LL << 60;


class Solver {
  public:
    bool solve() {
        string s; cin >> s;
        int ans = INF;
        rep(ii, 'z' - 'a' + 1) {
            char c = ii + 'a';
            vector<int> v;
            int left = 0;
            int ans2 = 0;
            bool ok = false;
            rep(i, s.size()) {
                if(s[i] == c) {
                    set_max(ans2, left);
                    ok = true;
                    left = 0;
                } else {
                    left++;
                }
            }
            if(not ok) continue;
            set_max(ans2, left);
            set_min(ans, ans2);
        }
        cout << ans << endl;
        return 0;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    Solver s;
    s.solve();
    return 0;
}


Measured memory_bytes: 256
#pragma region 宣言部分
#include <iostream>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
typedef long long ll;
#define REP(i,n) for(int i = 0;i < (n);i++)
#define rep(i,m,n) for(int i = (m);i < (n);i++)
#define P pair<int,int>
#define pb push_back
#define mk make_pair
using namespace std;
#define Vec(a) vector <int> a
const int INF = 1 << 20;
const int MOD = 1e9+7;

#pragma endregion



int main(){
  int n,k;
  cin >> n >> k;
  vector <int> a(n);
  int index;
  REP(i,n){
      cin >> a[i];
  }
  if(n == k){
    cout << 1 << endl;
    return 0;
  }
  int f,t;
  
  int cnt = 1;
  for(int i = k;i < n;i += k-1){
      //cout << i << endl;
      cnt++;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 640
# https://atcoder.jp/contests/abc170/tasks/abc170_b


X, Y = gets.split.map(&:to_i)

TL = 2
KL = 4

cond = false
(X+1).times do |tc|
  (X+1).times do |kc|
    leg = TL * tc + KL * kc
    total = tc + kc
    if leg == Y && total == X
      cond = true
    end
    #p "cond=#{cond}, tc=#{tc}, kc=#{kc}, leg=#{leg}, total=#{total}, X=#{X}, Y=#{Y}"
  end
end

puts cond ? 'Yes' : 'No'


Measured memory_bytes: 14376
#include <iostream>

using namespace std;

int main()
{
    char c1, c2;
    int dd, mm, yyyy;
    cin >> yyyy >> c1 >> mm >> c2 >> dd;
    if (yyyy >= 2019 && mm > 4)
    {
        cout << "TBD";
    }
    else
    {
        cout << "Heisei";
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
  int i,j,n,count=0;
  int G[101][101],color[101],d[101],pi[101],mincost,ii;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      scanf("%d",&G[i][j]);
    }
  }
  for(i=0;i<n;i++){
    color[i]=0;
    pi[i]=-1;
    d[i]=2001;
  }
  d[0]=0;

  while(1){
    mincost=2001;
    for(i=0;i<n;i++){
      if(color[i]!=2 && d[i]<mincost){
        mincost=d[i];
        ii=i;
      }
    }
    if(mincost==2001)break;
    color[ii]=2;
    for(i=0;i<n;i++){
      if(G[ii][i]!=-1 && color[i]!=2 && G[ii][i]<d[i]){
	pi[i]=ii;
	d[i]=G[ii][i];
	color[i]=1;
      }
    }
  }
  for(i=0;i<n;i++){
    if(pi[i]!=-1)count+=G[i][pi[i]];
    }
  printf("%d\n",count);
  return 0;
}



Measured memory_bytes: 2108
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

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

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

ll lcm(ll a, ll b){
    ll c = gcd(a, b);
    b /= c;
    return (a * b);
}

int main() {
    ll N;
    cin >> N;
    vector<ll> T(N);
    REP(i, N) cin >> T[i];
    ll hoge = T[0];
    REP(i, N-1) hoge = lcm(hoge, T[i+1]);
    cout << hoge << endl;


    return 0;
}

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

int main() {
  int n, T;
  cin >> n >> T;
  int mincost = 0x3f3f3f3f, mcid;
  for (int i = 1; i <= n; i++) {
    int c, t;
    cin >> c >> t;
    if (t <= T)
      mincost = min(mincost, c), mcid = i;
  }
  if (mincost == 0x3f3f3f3f) {
    cout << "TLE" << endl;
  } else {
    cout << mincost << endl;
  }
}

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

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

int main(){
    int k;
    cin >> k;
    int a, b, c, Ans = 0;
    for(a=1;a<=k;a++){
        for(b=1;b<=k;b++){
            int d = gcd(a, b);
            for(c=1;c<=k;c++){
                Ans += gcd(c, d);
            }
        }
    }
    cout << Ans << endl;
    return 0;
}

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

int main(){
  vector<vector<int> > graph;
  vector<int> master_node;
  vector<int> distance;
  vector<int> to_neighbor;
  int n;

  cin >> n;
  n++;
  graph.resize(n);
  master_node.resize(n);
  distance.resize(n);
  to_neighbor.resize(n);
  for(int i=1;i<n;i++){
    graph[i].resize(n);
    master_node[i]=0;
    distance[i]=INT_MAX;
    to_neighbor[i]=INT_MAX;
  }

  for(int i=1;i<n;i++){
    for(int j=1;j<n;j++){
      int input;

      cin >> input;
      graph[i][j]=(input!=-1?input:INT_MAX);
    }
  }


  int from=1;

  master_node[1]=1;
  distance[1]=0;
  for(int i=1;i<n;i++){
    to_neighbor[i]=(graph[1][i]<to_neighbor[i]?graph[1][i]:to_neighbor[i]);
  }
  while(true){
    int min_distance=INT_MAX,to;

    for(int i=1;i<n;i++){
      if((to_neighbor[i]<min_distance)&&(master_node[i]==0)){
        min_distance=to_neighbor[i];
	to=i;
      }
    }
    if(min_distance==INT_MAX){
      break;
    }else{
      master_node[to]=from;
      distance[to]=min_distance;
      from=to;
      to_neighbor[from]=INT_MAX;
      for(int i=1;i<n;i++){
        to_neighbor[i]=(graph[from][i]<to_neighbor[i]?graph[from][i]:to_neighbor[i]);
      }
    }
  }


  int sum=0;
  
  for(int i=1;i<n;i++){
    sum+=distance[i];
  }
  cout << sum << endl;
}


Measured memory_bytes: 3152
#include <bits/stdc++.h>
#include <string>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <bitset>
typedef long long ll;
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)

const int MAX = 510000;
const int MOD = 1000000007;
const int MAX_N = 200000;


int main(int argc, const char * argv[]) {
   double a,b,x;cin >> a >> b>>x;
   double ans;
   if((a*a*b)/2.0<x){
     ans = atan((2*a*a*b-2*x)/(a*a*a)) * 180 / M_PI;
   }else{
     ans = atan((a*b*b)/(2*x)) * 180 / M_PI;
   }

   cout <<fixed << setprecision(10)<< ans << endl;


   return 0;  
}


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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vint;
typedef vector<double> vd;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<int>> vvint;
typedef vector<pair<int, int>> vpii;
typedef vector<pair<ll, ll>> vpll;
typedef priority_queue<int, vector<int>, greater<int>> spqint; //小さい順に取り出し
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;     //小さい順に取り出し
typedef priority_queue<int, vector<int>, less<int>> bpqint;    //大きい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;        //大きい順に取り出し

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define FOR(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); i++)
#define FI first
#define SE second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define PF push_front
#define TS to_string
#define BS binary_search
#define LB lower_bound
#define UB upper_bound
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)


int INF = 1e9;
int NIL = -1;
ll MOD = 1000000007;
ll LINF = 1e18;
double EPS = 1e-9;
double PI = M_PI;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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; }     //最小公倍数

void yes(){ cout << "Yes" << endl;}
void no(){ cout << "No" << endl;}
//-----------------------------------------

//-----------------------------------------
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::chrono::system_clock::time_point start,end;
    start = std::chrono::system_clock::now();

    ll h, w ;
    cin >> h >> w ;
    queue<tuple<ll,ll,ll,ll>> que ;
    vector<vll> a(h,vll(w)) ;
    REP(i,h){
        REP(j,w){
            cin >> a[i][j] ;
        }
    }

    REP(i,h){
        REP(j,w){
            if(i==h-1 && j==w-1){
                break ;
            }
            if(a[i][j]%2==1){
                if(j!=w-1){
                    que.push(MT(i,j,i,j+1)) ;
                    a[i][j+1]++ ;
                }
                else{
                    que.push(MT(i,j,i+1,j)) ;
                    a[i+1][j]++ ;
                }
            }
        }
    }

    cout << SZ(que) <<endl;
    while(!que.empty()){
        tuple<ll,ll,ll,ll> t = que.front() ;
        que.pop() ;
        cout << get<0>(t)+1 << " " << get<1>(t)+1 << " " <<get<2>(t)+1 << " " <<get<3>(t)+1 << endl;
    }




    end = std::chrono::system_clock::now();
    auto elapsed = std::chrono::duration_cast< std::chrono::milliseconds >(end - start).count();
    //std::cout << elapsed <<"ms"<< std::endl;

    

    return 0;
}



Measured memory_bytes: 9300
import math
N, K = map(int, input().split())
p = [0 for i in range(N)]
for i in range(1,N+1):
    kaisu = max(0, math.ceil(math.log2(K/i)))
    #print(kaisu)
    p[i-1] = (1 / N) * 0.5 ** kaisu
print(sum(p))

Measured memory_bytes: 6296
n=int(input())
a=[int(input()) for _ in range(n)]
ans=0
for i in range(n):
    ans+=a[i]//2
    a[i]=a[i]%2
    if i<n-1 and a[i]>0 and a[i+1]>0:
        a[i]=0
        a[i+1]-=1
        ans+=1
print(ans)


Measured memory_bytes: 7072
n = int(input())
book = {}
for i in range(n):
  tmp = input().split()
  name = tmp[0]
  score = int(tmp[1])
  if name not in book:
    book[name] = {}
    book[name][score] = i + 1
  else:
    book[name][score] = i + 1

for key_city in sorted(book.keys()):
  for key_score in sorted(book[key_city].keys(), key=lambda x: -x):
  	print(book[key_city][key_score])

Measured memory_bytes: 3064
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors
import math
def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True  
a,b = map(int,input().split())
a_list = make_divisors(a)
b_list = make_divisors(b)
a_b_and = set(a_list) & set(b_list)
a_b_and = list(a_b_and)


count = 1
for a_b in a_b_and:
  if is_prime(a_b) == True:
    count += 1
    
print(count)

Measured memory_bytes: 41056
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, K;
    cin >> N >> K;
    vector<ll> A(N);
    ll S = 0;
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
        S += A[i];
    }
    vector<ll> divisor;
    for (ll i = 1; i * i <= S; ++i) {
        if (S % i != 0) continue;
        divisor.push_back(i);
        if (i * i != S) {
            divisor.push_back(S / i);
        }
    }
    ll ans = 0;
    for (int i = 0; i < divisor.size(); ++i) {
        vector<ll> mod;
        for (int j = 0; j < N; ++j) {
            if (A[j] % divisor[i] != 0) {
                mod.push_back(A[j] % divisor[i]);
            }
        }
        if (mod.size() == 0) {
            ans = max(ans, divisor[i]);
            continue;
        }
        sort(mod.begin(), mod.end());
        vector<ll> neg_cum(mod.size() + 2, 0), pos_cum(mod.size() + 2, 0);
        for (int j = 0; j < mod.size(); ++j) {
            neg_cum[j + 1] = neg_cum[j] + mod[j];
        }
        for (int j = mod.size() - 1; j >= 0; --j) {
            pos_cum[j + 1] = pos_cum[j + 2] + (divisor[i] - mod[j]);
        }
        bool is_ok = false;
        for (int j = 0; j <= mod.size(); ++j) {
            if (abs(neg_cum[j] - pos_cum[j + 1]) % divisor[i] != 0) continue;
            ll now_cnt = max(neg_cum[j], pos_cum[j + 1]);
            if (now_cnt <= K) {
                is_ok = true;
                break;
            }
        }
        if (is_ok) ans = max(ans, divisor[i]);
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
  int N;
  cin>>N;
  for(double i=1;i<50001;i++){
    if(int (i*1.08)==N){
      cout<<i<<endl;
      return 0;
    }
  }
  cout<<":("<<endl;
}

    
    

  


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();
    int[] a = new int[n];
    int[] b = new int[n - 1];

    for(int i = 0; i < n - 1;i++){
      b[i] = sc.nextInt();
    }

    // B[i] ≥ max ( A[i] , A[i + 1])
    // B[i + 1] ≥ max ( A[i + 1] , A[i + 2])
    // A[i] <= min(B[i - 1], B[i] )
    a[0] = b[0];
    int score = a[0];
    for(int i = 1; i < n - 1;i++){
      a[i] = Math.min(b[i - 1], b[i]);
      score += a[i];
    }
    if(n != 1){
      a[n - 1] = b[n - 2];
      score += a[n - 1];
    }

    System.out.println(score);
  }
}


Measured memory_bytes: 22100
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int n;
  while(cin>>n,n){
    bool used[n*2];
    memset(used,0,sizeof(used));
    vector<int> v[2];
    for(int i=0,k;i<n;i++){
      cin>>k;
      v[0].push_back(k);
      used[k-1]=1;
    }
    for(int i=0;i<n*2;i++){
      if(used[i]) continue;
      v[1].push_back(i+1);
    }
    sort(v[0].begin(),v[0].end());
    sort(v[1].begin(),v[1].end());
    bool card[2][n];
    memset(card,0,sizeof(card));
    bool f=0;
    int tmp=-1;
    while(1){
      bool ff=0;
      for(int i=0;i<n;i++){
	if(card[f][i]) continue;
	if(tmp<v[f][i]){
	  tmp=v[f][i];
	  card[f][i]=1;
	  ff=1;
	  break;
	}
      }
      if(!ff) tmp=-1;
      int cnt[2]={};
      for(int i=0;i<2;i++)
	for(int j=0;j<n;j++)
	  cnt[i]+=card[i][j];
      if(cnt[0]==n||cnt[1]==n){
	cout<<n-cnt[1]<<endl<<n-cnt[0]<<endl;
	break;
      }
      f=!f;
    }
  }
  return 0;
}

Measured memory_bytes: 3016
#include <bits/stdc++.h>
 
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e5)

#define PI (acos(-1))
#define print(x) cout << x << endl
 
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; }
typedef pair <ll,ll> P;

int main()
{
    ll L, R;
    cin >> L >> R;
    ll len = R - L + 1;
    if (len >= 2019) {
        print(0);
    } else {
        vector<ll> v(len);
        rep(i, len) {
            v[i] = (L+i) % 2019;
        }
        ll mi = MOD;
        rep(i, len) {
            rep(j, len) {
                if (i == j) continue;
                mi = min(mi, v[i] * v[j] % 2019);
            }
        }
        print(mi);
    }
    return 0;
}

Measured memory_bytes: 256
typedef long long ll;

#include <algorithm>
#include <numeric>
#define REP(i,n) for(int i=0; i<(int)(n); i++)

#include <queue>
#include <cstdio>
inline int getInt(){ int s; scanf("%d", &s); return s; }

#include <set>

using namespace std;

int main(){
  const int n = getInt();
  const int k = getInt();
  vector<int> a(n);
  REP(i,n) a[i] = getInt();

  const int sum = accumulate(a.begin(), a.end(), 0);

  for(int t = sum; t > 0; t--) if(sum % t == 0){
    vector<int> r(n);
    ll cnt = 0;
    REP(i,n){
      r[i] = a[i] % t;
      cnt += r[i];
    }

    if(cnt % t != 0) continue;

    sort(r.rbegin(), r.rend());

    ll ans = cnt;
    REP(i,n) if(cnt){
      ans -= r[i];
      cnt -= t;
    }
    if(ans <= k){
      printf("%d\n", t);
      break;
    }
  }

  return 0;
}

Measured memory_bytes: 256
import sys,collections,math,random;sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

qq = []
for i in range(1,10):
    for j in range(1,10):
        qq.append(i*j)
N = I()
if N in qq:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 4336
//
//  respect the past, embrace the future
//

#include  <algorithm>
#include  <iostream>
#include  <climits>
#include  <cstdlib>
#include  <cstring>
#include  <cmath>
#include  <cstdio>
#include  <unordered_map>
#include  <map>
#include  <set>
#include  <stack>
#include  <string>
#include  <vector>
#include  <queue>

using namespace :: std;

using vpll = vector <pair <long long, long long> >;
using pll = pair <long long, long long>;
using vll = vector <long long>;
using ll = long long;

#define W (ll) (5e3 + 7)
#define N (ll) (2e6 + 7)
#define M (ll) (1e9 + 7)
#define INF (ll) (2e18)
#define F first
#define S second

inline void fastInputOutput () {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
}

inline void ReadWriteFromFile () {
  freopen("../in.txt", "r", stdin);
  freopen("../out.txt", "w", stdout);
}

int a, b, c;

int32_t main (int argc, char *argv[]) {
  fastInputOutput();
  // ReadWriteFromFile();
  
  cin >> a >> b >> c;
  if (a + b + c >= 22)
    cout << "bust";
  else if (a + b + c < 22)
    cout << "win";
  else
    cout << "amk";
}

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

/*
提出前に確認!
- setとmultisetを間違えない
*/

int	main(void)
{
	int h, w;
	cin >> h >> w;
	vector<pair<int, int>> obstacle(h);
	for (int i = 0; i < h; i++) cin >> obstacle[i].first >> obstacle[i].second;
	multiset<int> values;
	multiset<pair<int, int>> dest_and_start;
	for (int i = 0; i < w; i++)
	{
		dest_and_start.insert({i + 1, i + 1});
		values.insert(0);
	}
	for (int i = 0; i < h; i++)
	{
		//destがAiのものから順に見ていく
		auto ptr = dest_and_start.lower_bound({obstacle[i].first, -1});
		int max_start = -1;
		while (ptr != dest_and_start.end())
		{
			if ((*ptr).first > obstacle[i].second) break ;
			max_start = max(max_start, (*ptr).second);
			values.erase(values.find((*ptr).first - (*ptr).second));
			ptr = dest_and_start.erase(ptr);
		}
		if (max_start != -1 && obstacle[i].second != w)
		{
			dest_and_start.insert({obstacle[i].second + 1, max_start});
			values.insert(obstacle[i].second + 1 - max_start);
		}
		if (values.size()) cout << *values.begin() + i + 1 << endl;
		else cout << -1 << endl;
	}
	return (0);
}


Measured memory_bytes: 23500
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
using namespace std;

vector<long long> lulu;

void dfs(long long now, int last) {
    now *= 10;
    if(now > 3234566668LL) return;
    lulu.push_back(now + last);
    dfs(now + last, last);
    if(last < 9) {
        lulu.push_back(now + last + 1);
        dfs(now + last + 1, last + 1);
    }
    if(last > 0) {
        lulu.push_back(now + last - 1);
        dfs(now + last - 1, last - 1);
    }
}

int main() {
    int x;
    scanf("%d", &x);
    for(int i = 1; i <= 9; i++) {
        dfs(i, i);
        lulu.push_back(i);
    }
    //printf("%d\n", (int)lulu.size());
    sort(lulu.begin(), lulu.end());
    //for(int i = 0; i < 30; i++) printf("%lld\n", lulu[i]);
    printf("%lld\n", lulu[x - 1]);

    return 0;
}


Measured memory_bytes: 1400
#include <iostream>
#include <vector>
#include <algorithm>
#include <list>
#include <iomanip>
#include <string>



using namespace std;



int main() {
    int n, m;
    int A[100][100] = { {} };
    int b[100] = {};
    int i, j;
    cin >> n >> m;
    for (i = 0; i < n; i++) {
        for (j = 0; j < m; j++) {
            cin >> A[i][j];
        }
    }
    for (j = 0; j < m; j++) {
        cin >> b[j];
    }
    for (i = 0; i < n; i++) {
        int x = 0;
        for (j = 0; j < m; j++) {
            x += A[i][j] * b[j];
            
        }
        cout << x << endl;
    }
    
}


Measured memory_bytes: 3140
#include<bits/stdc++.h>
using namespace std;
#define re register
int f[510],h[510],lb[510],rb[510];
int main()
{
    re int n,mod,ans=0;
    scanf("%d%d",&n,&mod);
    n*=2;
    for(re int i=0;i<n;i++)
    {
        rb[i]=(int)sqrt(n*n-i*i);
        if(rb[i]>=n)rb[i]=n-1;
        if(i<n/2)
        {
            lb[i]=(int)sqrt(n*n/4-i*i);
            if(lb[i]*lb[i]==n*n/4-i*i)lb[i]--;
        }//printf("***%d %d %d\n",i,lb[i],rb[i]);
    }
    for(re int ii=0;ii<=n/2;ii++)
    {
        re int i1=n-1,i2=n/2-1;
        memset(f,0,sizeof(f));f[0]=1;
        for(re int i=1;i<=n;i++)
		if(i2>=0&&lb[i2]<rb[i1])
        {
            for(re int j=ii;j;j--)f[j]=((long long)f[j]*(rb[i2]+1-(n-1-i2+ii-j))+(long long)f[j-1]*(lb[i2]+1-(n-i1-2+j)))%mod;
            f[0]=(long long)f[0]*(rb[i2]+1-(n-1-i2+ii))%mod;
            i2--;
        }else
        {
            for(re int j=0;j<=ii;j++)f[j]=(long long)f[j]*(rb[i1]+1-(n-i1-1+j))%mod;
            i1--;
        }//printf("**%d %d i1:%d i2:%d lb:%d rb:%d %d %d\n",ii,i,i1,i2,lb[i2],rb[i1],f[ii],rb[i1]+1-(n-i1-1));}
        //printf("**%d %d %d\n",ii,f[ii],ans);
        ans=(ans+((ii&1)?mod-f[ii]:f[ii]))%mod;
    }printf("%d",ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define drep(i,cc,n) for(int i=(cc);i<=(n);++i)
#define rep(i,n) drep(i,0,(n)-1)
#define drrep(i,cc,n) for(int i=(cc);i>=(n);--i)
#define rrep(i,n) drrep(i,0,(n)-1)
#define sz(s) (int)(s.size())
#define vecprint(v) rep(i,v.size())if(i==0)cout << v[i];else cout << " " << v[i]; cout << endl;
#define arrprint(v,n) rep(i,n)if(i==0)cout << v[i];else cout << " " << v[i]; cout << endl;
#define matprint(v,n,m) rep(i,n){rep(j,m){cout << v[i][j] << " ";}cout << endl;}
#define SORT(v) sort(v.begin(), v.end())
#define REV(v) reverse(v.begin(), v.end())
using namespace std;
const int mod=1000000007;
const int INF=1001001001;
using ll = long long;
using P = pair<int,int>;
template<typename T>
using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>; //小さいものから取り出す

int main(){
    int l,r,d;
    cin >> l >> r >> d;
    int ans = 0;
    drep(i,l,r)if(i%d == 0)ans++;

    cout << ans << endl;
//  printf("%.10f\n",ans);

    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>

using namespace std;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep(i,j,n) for(ll (i)=(j);(i)<(n);(i)++)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
#define pb push_back
#define mp make_pair
typedef pair<ll, ll> P;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;
typedef vector<ll> Array;
typedef vector<Array> Matrix;



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

//グラフ関連
struct Edge {//グラフ
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

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

	ll h, w, n;
	cin >> h >> w >> n;

	ll ans1 = n / h;
	if (n % h != 0) ans1++;
	ll ans2 = n / w;
	if (n % w != 0) ans2++;

	cout << min(ans1, ans2) << endl;

	return 0;
}


Measured memory_bytes: 256
import sys
from io import StringIO
import unittest
from collections import Counter

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

def resolve():
    # s = input()
    n = int(input())
    # a, b = map(int, input().split())
    # l = [list(map(int, input().split())) for _ in range(n)]

    n_list = Counter(prime_factorize(n))
    cnt = 0

    for key, v in n_list.items():
        tmp = 1
        while 1:
            if n_list[key] - tmp >= 0:
                n_list[key] -= tmp
                cnt += 1
                tmp += 1
            else:
                break

    print(cnt)


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """24"""
        output = """3"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """1"""
        output = """0"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """64"""
        output = """3"""
        self.assertIO(input, output)

    def test_入力例_4(self):
        input = """1000000007"""
        output = """1"""
        self.assertIO(input, output)

    def test_入力例_5(self):
        input = """997764507000"""
        output = """7"""
        self.assertIO(input, output)


if __name__ == "__main__":
    # unittest.main()
    resolve()


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

int n, m, c;
int B[30];
bool func(int A[30]) {
    int sum = c;
    rep(i, m)  sum += A[i] * B[i];
    if (sum > 0) return true;
    else return false;
}

int main() {
    cin >> n >> m >> c;
    rep(i, m) cin >> B[i];
    
    int A[30][30];
    rep(i, n) rep(j, m) cin >> A[i][j];
    
    int cnt = 0;
    rep(i, n) {
        if (func(A[i])) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+5;
int main()
{
	int n,k,ans=0,a[maxn];
	scanf("%d%d",&k,&n);
	for(int i=0;i<n;i++)
		scanf("%d",&a[i]);
	sort(a,a+n);
	for(int i=0;i<n-1;i++)
			ans=max(ans,a[i+1]-a[i]);
	ans=max(ans,k-a[n-1]+a[0]);
	printf("%d",k-ans);
}

Measured memory_bytes: 1024
N = gets.to_i
as = []
N.times do |i|
    as[i] = gets.split.map(&:to_i)
end

no_line = Array.new(N){Array.new(N, nil)}

(0...(N-2)).each do |a|
    ((a+1)...(N-1)).each do |b|
        ((b+1)...N).each do |c|
            max = as[a][b]
            max0 = a
            max1 = b
            bc = as[b][c]
            if bc > max
                lows = max
                max = bc
                max0 = b
                max1 = c
            else
                lows = bc
            end
            ac = as[a][c]
            if ac > max
                lows += max
                max = ac
                max0 = a
                max1 = c
            else
                lows += ac
            end
            if max > lows
                puts -1
                exit
            elsif max == lows
                no_line[max0][max1] = true
            end
        end
    end
end

sum = 0
(0...N).each do |i|
    ((i+1)...N).each do |j|
        sum += as[i][j] unless no_line[i][j]
    end
end

puts sum

Measured memory_bytes: 3836
a=int(input())
l=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51];
print(l[a-1])

Measured memory_bytes: 3316
import math
while True:
    x = int(input())
    h = int(input())
    if x == 0 and h == 0:
        break
    tei = x * x
    tor = x * (math.sqrt(h * h + (x / 2) ** 2) * 1 / 2)
    ans = tei + 4 * tor
    print("{0:.6f}".format(ans))

Measured memory_bytes: 7492
// -----------------------------------
// Author     : MatsuTaku
// Affiliation: Tokushima University
// Country    : Japan
// Date       : 04/05/2020
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  int n; cin>>n;
  vector<ll> A(n); for(auto& a:A) cin>>a;
  vector<ll> ans(n);
  for (int i = 0; ;) {
    int j = (i+1)%n;
    int k = (i+2)%n;
    ans[k] = ans[i]+(A[j]-A[i])*2;
    i = k;
    if (i == 0)
      break;
  }
  auto ans_sum = accumulate(ans.begin(), ans.end(), 0ll);
  auto sum = accumulate(A.begin(), A.end(), 0ll);
  auto d = (sum-ans_sum)/n;
  for (auto a : ans)
    cout << a+d << " ";
  cout << endl;

  return 0;
}


Measured memory_bytes: 2944
// failed to generate code

#include <algorithm>
#include <bitset>
#include <cassert>
#include <deque>
#include <fstream>
#include <iostream>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <sstream>
#include <stdio.h>
#include <string>
#include <vector>

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define POW(n) ((n) * (n))
#define ALL(a) (a).begin(), (a).end()
#define dump(v) (cerr << #v << ": " << v << endl)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<long long> vll;
typedef vector<unsigned long long> vull;
//
// 1234567894848 * 10
// 1234567891011
// 1234567900000
// 3800/10 = 380
//
// 7 * 3 = 21
// 27
//
// K * N
//
// N - (N-1) * K
// 50 - 49
// 50*10^16 -
//
// 1000+193+256+777+0+1+1192+1234567891011+48+425

// ll n = to_T<ll>("114514")
template <class T> T to_T(const string &s) {
  istringstream is(s);
  T res;
  is >> res;
  return res;
}
template <class T> string to_s(const T &a) {
  ostringstream os;
  os << a;
  return os.str();
}
ll K;
ll MAX = 1e16 + 1000L;

bool solve(ll N) {
  if (K == 0) {
    cout << "2" << endl;
    cout << "1 1" << endl;
    return true;
  } else if (K == 1) {
    cout << "2" << endl;
    cout << "3 0" << endl;
    return true;
  }

  ll sum = K * N;
  vll v(N, 0);

  if (K <= 50) {
    REP(i, N) { v[i] = i + 1; }
  } else {
    REP(i, N) v[i] = (N - 1) + K / N;
    REP(i, K % N) {
      v[i % N] += N;
      REP(j, N) if (i % N != j) { v[j]--; }
    }
    REP(i, N) {
      if (v[i]<0 | v[i]> MAX)
        return false;
    }
  }

  cout << N << endl;
  REP(i, N) {
    cout << v[i];
    if (i != N - 1)
      cout << " ";
  }
  cout << endl;
  return true;
}
int main() {
  ios::sync_with_stdio(false);

  cin >> K;

  if (K <= 50) {
    solve(K);
  } else {
    FOR(i, 2, 51) if (solve(i)) return 0;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+3;
vector<int> adj[N+1];
vector<int> dp(N+1,-1);
int go(int i){
 if(dp[i]!=-1) return dp[i];
 dp[i]=0;
 for(int v:adj[i]){
  dp[i]=max(dp[i],go(v)+1);
 }
 return dp[i];
}
int main(){
 int n,m;
 cin>>n>>m;
 for(int i=1;i<=n;i++){
  adj[0].push_back(i);
 }
 for(int i=0;i<m;i++){
  int u,v;
  cin>>u>>v;
  adj[u].push_back(v);
 }
 cout<<go(0)-1<<endl;
 return 0;
}

Measured memory_bytes: 8568
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <set>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

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

    int n, a;
    cin >> n;
    bool is_all_even = true;
    for (int i = 0; i < n; i++) {
        cin >> a;
        if (a % 2 == 1) {
            is_all_even = false;
        }
    }

    if (is_all_even) {
        cout << "second" << endl;
    } else {
        cout << "first" << 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 REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;

vector<int> table(101,0);

void prime_fact(int n){
    if (n <= 1) return;
    int n_origin = n;
    for(int i=2; i<=(int)sqrt(n_origin); i++){
        if (n%i == 0){
            int count = 0;
            while(n%i == 0){
                n/=i;
                count ++;
            }
            table[i] += count;
        }
    }
    if (n!=1){
        table[n] ++;
    }
}


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

    FOR(i,1,N+1) prime_fact(i);

    int count2 = 0;
    int count4 = 0;
    int count14 = 0;
    int count24 = 0;
    int count74 = 0;

    REP(i,N+1){
        if(table[i]>=2) count2 ++;
        if(table[i]>=4) count4 ++;
        if(table[i]>=14) count14 ++;
        if(table[i]>=24) count24 ++;
        if(table[i]>=74) count74 ++;
    }


    int ans = 0;
    if(count74 > 0) ans += count74;
    if(count2 > 0) ans += (count2-1)*count24;
    if(count4 > 0) ans += (count4-1)*count14;

    if(count2 > 2) ans += (count2-2)*count4*(count4-1)/2;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3584
s = input()
s_start = 0
s_end = 0
count = 0

# 文字列sを右から探索できるように逆順に変換する
s_reverse = s[::-1]
# print(s_reverse)

for i in s:
    if i == 'A':
        s_start = count
        break
    count += 1

# カウンタcountを逆順用に変更（降順）
count = len(s) - 1

for j in s_reverse:
    if j == 'Z':
        s_end = count
        break
    count -= 1

ans = s_end - s_start + 1
print(ans)


Measured memory_bytes: 9272