akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
using Graph = vector<vector<int>>;
inline int in() { int x; cin >> x; return x; }

int counte;
vector<bool> seen;
vector<bool> watch;
vector<int> member;
void dfs(const Graph &G, int v) {
  if (!seen[v]) {
    counte++;
    member.push_back(v);
  }
  seen[v] = true;
  watch[v] = true;
  for (auto next_v : G[v]) {
    if (seen[next_v]) continue;
    dfs(G, next_v); // 再帰的に探索
  }
}

int main(){
  int N = in(), M = in(), K = in();
  watch.assign(N,false);
  vector<int> answer(N);
  Graph F(N),B(N);
  REP(i,M) {
    int a = in()-1, b = in()-1;
    F[a].push_back(b);
    F[b].push_back(a);
  }
  REP(i,K) {
    int a = in()-1, b = in()-1;
    B[a].push_back(b);
    B[b].push_back(a);
  }
  REP(i,N) {
    if (watch[i] == 0) {
      counte = 0;
      seen.assign(N,false);
      member.assign(0,0);
      dfs(F,i);
      REP(l,member.size()){
        int counter = 0;
        REP(k,B[member[l]].size()){
          if(seen[B[member[l]][k]] == 1)counter++;
        }
        REP(k,F[member[l]].size()){
          if(seen[F[member[l]][k]] == 1)counter++;
        }
        answer[member[l]] = counte - counter - 1;
      }
    }
  }
  REP(i,N) cout << answer[i] << endl;
}


Measured memory_bytes: 13564
import java.util.*;
public class Main
{
 public static void main(String[] args)
  {
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int k=sc.nextInt();
    int p[]=new int[n];
    for(int i=0;i<n;i++)
    {
      p[i]=sc.nextInt();
    }
   Arrays.sort(p);
   int sum=0;
   for(int i=0;i<k;i++)
     sum+=p[i];
   System.out.println(sum);
  }
}

Measured memory_bytes: 38908
# import sys
# input = sys.stdin.readline


def solve():
    N = int(input())
    brackets_gen = (input() for _ in range(N))

    grads_positive = list()
    grads_negative = list()

    total = 0
    for brackets in brackets_gen:

        elevation, bottom = 0, 0

        for bk in brackets:

            elevation += 1 if bk == '(' else -1
            bottom = min(bottom, elevation)

        if elevation >= 0:
            grads_positive.append((bottom, elevation))
        elif elevation < 0:
            grads_negative.append((bottom - elevation, -elevation))

        total += elevation

    if total != 0:
        return False

    grads_positive.sort(reverse=True)
    grads_negative.sort(reverse=True)

    def is_good(grads):
        elevation, bottom = 0, 0
        for grad in grads:
            bottom = elevation + grad[0]
            if bottom < 0:
                return False
            elevation += grad[1]

        return True

    if is_good(grads_positive) and is_good(grads_negative):
        return True
    else:
        return False


def main():
    ok = solve()
    if ok:
        print('Yes')
    else:
        print('No')


if __name__ == "__main__":
    main()


Measured memory_bytes: 80268
#include<cstdio>
    const int MAXN = 100;
    int dp[3][MAXN + 5];
    int max(int a,int b) {
    	return a>b?a:b;
    }
    int main() {
    	int N;
    	scanf("%d",&N);
    	for(int i=1;i<=N;i++)
    		scanf("%d",&dp[1][i]);
    	for(int i=1;i<=N;i++)
    		scanf("%d",&dp[2][i]);
    	for(int i=1;i<=N;i++)
    		dp[1][i] += dp[1][i-1];
    	for(int i=1;i<=N;i++)
    		dp[2][i] += max(dp[1][i], dp[2][i-1]);
    	printf("%d",dp[2][N]);
    }

Measured memory_bytes: 128
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    int n;
    cin>>n;
    vector<int> v(n+1,0);
    for(int i=1;i<n;i++)
    {
        int in;
        cin>>in;
        v[in]++;
    }
    for(int i=1;i<=n;i++)
        cout<<v[i]<<"\n";
    return 0;
}


Measured memory_bytes: 3992
l = list(map(int, input().split()))

k = l[-1]
l.pop()

if abs(l[0] - l[2]) <= k:
    print('Yes')
else:
    if abs(l[0] - l[1]) <= k and abs(l[1] - l[2]) <= k:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 3060
// iketyun08 

#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<cstdlib>
#include<cstdio>
#include<utility>
using namespace std;
int dfs(int, int, int, int, int );
char field[50][50 + 1];
int main() {
	int H, W, cnt = 0;
	cin >> H >> W;

	/*for(int i=0;i<H;i++){
	for(int j=0;j<W;j++)field[i][j]=" ";
	}*///初期化
	for (int i = 0; i<H; i++) {
		for (int j = 0; j<W; j++)cin >> field[i][j];
	}
	for (int i = 0; i<H; i++) {
		for (int j = 0; j<W; j++) {
			if (field[i][j] == '#') {
				int large = dfs(i, j, 1, H, W);
				// cout << large << endl;
				if (large < 2) {
					cout << "No" << endl;
					return 0;
				}
			}
		}
	}
	cout << "Yes" << endl;

	return 0;
}
int dfs(int y, int x, int cnt, int H, int W) {
	field[y][x] = '.';
	int dx[4] = { 1, 0, -1, 0 }, dy[4] = { 0, 1, 0, -1 };//移動4方向のベクトル
	for (int i = 0; i<4; i++) {
		int nx = x + dx[i], ny = y + dy[i];
		if (0 <= ny && ny < H && 0 <= nx && nx < W) {
			// cout << ny << " " << nx << " " << field[ny][nx] << " " << cnt << endl;
			if (field[ny][nx] == '#') dfs(ny, nx, cnt++, H, W);
		}
	}
	return cnt;
}


Measured memory_bytes: 512
#include<iostream>
#include<queue>
#include<algorithm>

using namespace std;

int main()
{
    int N,C,K; cin >> N >> C >> K;
    int cnt =0;
    priority_queue<int,vector<int>,greater<int> > Q;
    for(int i=0;i<N;++i)
    {
        int t;
        cin >> t;
        Q.push(t);
    }

    while(!Q.empty())
    {
        int b =1;
        int s = Q.top();Q.pop();
        int e = s + K;
        while(b < C)
        {
            if(Q.top() > e || Q.empty()) break; //時間外
            else
            {
                b++;Q.pop();
            }
        }
        cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 892
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <ctime>
#include <string>
#include <cstring>
#include <complex>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
#define mp make_pair

const int N = 200200;
int n;
int a[N];

int gcd(int x, int y)
{
    return (y == 0 ? x : gcd(y, x % y));
}

bool solve()
{
    int even = 0;
    int ones = 0;
    for (int i = 0; i < n; i++)
    {
        if (a[i] == 1)
            ones++;
        if (a[i] % 2 == 0)
            even++;
    }
    if (even & 1) return true;
    if (even < n - 1) return false;
    if (ones > 0) return false;
    int g = 0;
    for (int i = 0; i < n; i++)
    {
        if (a[i] & 1)
            a[i]--;
        g = gcd(g, a[i]);
    }
    for (int i = 0; i < n; i++)
        a[i] /= g;
    return solve() ^ 1;
}

int main()
{
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

    scanf("%d", &n);
    for (int i = 0; i < n; i++)
        scanf("%d", &a[i]);
    if (solve())
        printf("First\n");
    else
        printf("Second\n");

    return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i = 0; i < N; i++){
    cin >> A.at(i);
  }
  sort(ALL(A));
  cout << abs(A.at(0) - A.at(A.size()-1)) << endl;
}

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

int main(){
  int n,t,c,tt,minx=10000;
  scanf("%d %d",&n,&t);
  for(int i=0;i<n;i++){
    scanf("%d %d",&c,&tt);
    if(tt<=t&&minx>c)
      minx=c;
  }
  if(minx==10000)
    printf("TLE\n");
  else
    printf("%d\n",minx);
}

Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <string>
#include <set>

using namespace std;

string s,s1,s2,s3,s4;
int m;

int main()
{
    cin >> m;
    for(int i=0;i<m;i++)
    {
        set<string> S;
        cin >> s;
        S.insert(s);
        for(int j=1;j<s.length();j++)
        {
            s1=s.substr(0,j);
            s2=s.substr(j);
            s3=s1;
            s4=s2;
            reverse_copy(s1.begin(),s1.end(),s3.begin());
            reverse_copy(s2.begin(),s2.end(),s4.begin());
            S.insert(s1+s4);
            S.insert(s2+s3);
            S.insert(s3+s4);
            S.insert(s2+s1);
            S.insert(s4+s1);
            S.insert(s3+s2);
            S.insert(s4+s3);
        }
        cout << S.size() << endl;
    }
    return 0;
}


Measured memory_bytes: 3232
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#define ll long long
#define MOD 1000000007
#define MAX 10000000
using namespace std;
ll dp[110][4][4][4];

int main(){
    ll n; cin >> n;
    ll ans = n*(n-1)/2;
    cout << ans;
}

Measured memory_bytes: 256
/* Simplicity and Goodness */
 
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update> indexed_set;

void my_dbg() { cout << endl; }
template<typename Arg, typename... Args> void my_dbg(Arg A, Args... B) 
{ cout << ' ' << A; my_dbg(B...); }
#define dbg(...)  cout << "(" << #__VA_ARGS__ << "):", my_dbg(__VA_ARGS__)

#define scn(n) scanf("%d", &n)
#define lscn(n) scanf("%lld", &n)
#define pri(n) printf("%d ", (int)(n))
#define prin(n) printf("%d\n", (int)(n))
#define lpri(n) printf("%lld ", n)
#define lprin(n) printf("%lld\n", n)
#define rep(i,a,b) for(int i=(int)(a); i<(int)(b); i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;

const int inf = INT_MAX;
const int ninf = INT_MIN;
const int mod = 1e9+7;
const int N = 2e5+2;

pair<int, int> pp[N];
int n;

int cost(int p, int q)
{
    int cnt = 0; vi mark(n, 0);
    rep(i, 0, n) {
        if(!mark[i]) {
            cnt ++; int px = pp[i].F, py = pp[i].S;
            rep(j, i, n) {
                if(pp[j].F == px+p and pp[j].S == py+q) {
                    mark[j] = 1;
                    px = pp[j].F; py = pp[j].S;
                }
            }
        }
    }
    return cnt;
}

void solve()
{
    scn(n);

    rep(i, 0, n) {
        scn(pp[i].F); scn(pp[i].S);
    }

    sort(pp, pp+n);

    set<pair<int, int>> collection;

    rep(i, 0, n) {
        rep(j, i, n) {
            int p = pp[j].F - pp[i].F, q = pp[j].S - pp[i].S;
            collection.insert(mp(p, q));
        }
    }

    int ans = inf;

    for(auto x : collection) {
        int p = x.F, q = x.S;
        ans = min(ans, cost(p, q));
    }

    prin(ans);
}

int main()
{
    int t = 1;
    // scn(t);

    while(t --) {
        solve();
    }
    return 0;
}

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

int n, c, p[100], sum;

int main() {
  scanf("%d%d", &n, &c);
  for (int i = 0; i < c; i++) scanf("%d", &p[i]), sum += p[i];
  printf("%d\n", (sum + n) / (n + 1));
}



Measured memory_bytes: 2748
#include <cstdio>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <stack>
#include <vector>
#include <algorithm>
#include <set>
#include <deque>
#include <utility>
#include <chrono>
#include <sstream>
#include <iomanip>

#define INF 1 << 30
#define MOD 1000000007
#define PI 3.14159265358979
#define rep(i, n) for (int (i) = 0; (i) < (int)(n); (i)++)
#define rer(i, l, r) for (int (i) = (int)(l); (i) <= (int)(r); (i)++)
#define reu(i, l, r) for (int (i) = (int)(l); (i) < (int)(r); (i)++)
#define D(x) cout << x << endl
#define d(x) cout << x
#define all(x) (x).begin(), (x).end()
#define pub(x) push_back(x)
#define pob() pop_back()
#define puf(x) push_front(x)
#define pof() pop_front()
#define mp(x, y) make_pair((x), (y))
#define fi first
#define se second
#define setp(x) setprecision(x)

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<long, long> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
template<typename T, typename U> inline void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if (x < y) x = y; }

static const int dx[] = {0, 0, 1, -1};
static const int dy[] = {-1, 1, 0, 0};

int main() { 
        int n;
        cin >> n;
        vi a(n);
        int sum = 0;
        rep(i, n) {
                cin >> a[i];
                sum += a[i];
        }
        int ave = sum / n;

        int ans = INF;
        int res;
        for (int j = -2; j <= 2; j++) {
                res = 0;
                rep(i, n) {
                        res += ((ave + j) - a[i]) * ((ave + j) - a[i]);
                }
                amin(ans, res);
        }
       
        D(ans);

        return 0;
}



Measured memory_bytes: 256
import heapq

class Dijkstra(object):
    def dijkstra(self, adj, start, goal=None):
        '''
        ダイクストラアルゴリズムによる最短経路を求めるメソッド
        入力
        adj: adj[i][j]の値が頂点iから頂点jまでの距離(頂点iから頂点jに枝がない場合，値はfloat('inf'))となるような2次元リスト(正方行列)
        start: 始点のID
        goal: オプション引数．終点のID
        出力
        goalを引数に持つ場合，startからgoalまでの最短経路を格納したリストを返す
        持たない場合は，startから各頂点までの最短距離を格納したリストを返す
        '''
        num = len(adj)          # グラフのノード数
        dist = [float('inf') for i in range(num)] # 始点から各頂点までの最短距離を格納する
        prev = [float('inf') for i in range(num)] # 最短経路における，その頂点の前の頂点のIDを格納する
        
        dist[start] = 0
        q = []                  # プライオリティキュー．各要素は，(startからある頂点vまでの仮の距離, 頂点vのID)からなるタプル
        heapq.heappush(q, (0, start)) # 始点をpush

        while len(q) != 0:
            prov_cost, src = heapq.heappop(q) # pop
            
            # プライオリティキューに格納されている最短距離が，現在計算できている最短距離より大きければ，distの更新をする必要はない
            if dist[src] < prov_cost:
                continue

            # 他の頂点の探索
            for dest in range(num):
                cost = adj[src][dest]
                if cost != float('inf') and dist[dest] > dist[src] + cost:
                    dist[dest] = dist[src] + cost # distの更新
                    heapq.heappush(q, (dist[dest], dest)) # キューに新たな仮の距離の情報をpush
                    prev[dest] = src                      # 前の頂点を記録
                    
        if goal is not None:
            return self.get_path(goal, prev)
        else:
            return dist

    def get_path(self, goal, prev):
        '''
        始点startから終点goalまでの最短経路を求める
        '''
        path = [goal]           # 最短経路
        dest = goal

        # 終点から最短経路を逆順に辿る
        while prev[dest] != float('inf'):
            path.append(prev[dest])
            dest = prev[dest]

        # 経路をreverseして出力
        return list(reversed(path))







H,W=map(int,input().split())
black=0
field=[["#"]*(W+2)]
for i in range(H):
    field.append(["#"] + list(input()) + ["#"])

field.append(["#"]*(W+2))

adj=[[float("inf")]*W*H for _ in range(H*W)]

for i in range(H):
    for j in range(W):
        if(field[i+1][j+1]=="#"):
            black+=1
            continue
        if(field[i+1][j+2]=="."):
            adj[W*i+j][W*i+j+1]=1
            adj[W*i+j+1][W*i+j]=1
        if(field[i+1][j]=="."):
            adj[W*i+j][W*i+j-1]=1
            adj[W*i+j-1][W*i+j]=1
        if(field[i][j+1]=="."):
            adj[W*i+j][W*(i-1)+j]=1
            adj[W*(i-1)+j][W*i+j]=1
        if(field[i+2][j+1]=="."):
            adj[W*i+j][W*(i+1)+j]=1
            adj[W*(i+1)+j][W*i+j]=1

d=Dijkstra()
kyori=d.dijkstra(adj,0)[-1]
if(kyori==float("inf")):
    print(-1)
else:
    print(H*W-black-kyori-1)

Measured memory_bytes: 54516
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main {

    private static final int DATA_SET = 200;

    public static void main(String[] args) {

        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        List<String> inputDataList = new ArrayList<String>(DATA_SET);
        String input = null;

        try {
            while((input = in.readLine()) != null) {
                inputDataList.add(input);
            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                in.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

        for (String inputData : inputDataList) {
            String[] data = inputData.split(" ");
            double result = Math.log10(Double.parseDouble(data[0]) + Double.parseDouble(data[1]));
            System.out.println(new Double(result).intValue() + 1);
        }
    }
}

Measured memory_bytes: 17032
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
    os << "{ ";
    REP(i, vec.size()) {
        os << vec[i] << " ";
    }
    os << "}";

    return os;
}

ll pow_mod(ll a, ll p) {
    ll res = 1;
    while(p) {
        if (p & 1) res = (res * a) % MOD;
        a = (a * a) % MOD;
        p >>= 1;
    }

    return res;
}


ll mod_inv(ll a, ll m) {
    ll b = m, u = 0, v = 1;
    while(a) {
        ll t = b / a;
        swap(b -= t * a, a);
        swap(u -= t * v, v);
    }

    return (u % m + m) % m;
}

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

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}


#ifdef LOCAL
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif


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

    int c[10] = {10, 2, 5, 5, 4, 5, 6, 3, 7, 6};
    
    int N, M;
    cin >> N >> M;


    int a[M];
    REP(i, M) {
        cin >> a[i];
    }

    vector<string> s(N+1);
    s.assign(N+1, "-1");
    s[0] = "";

    REP(i, N) {
        if(s[i] == "-1") continue;

        string t = s[i];
        REP(j, M) {
            int u = a[j];

            if (i + c[u] > N) continue;

            string v;
            if (u > t[0] - '0') v = to_string(u) + t;
            else v = t + to_string(u);

            if (v.size() > s[i + c[u]].size() ||  v > s[i + c[u]]) {
                s[i + c[u]] = v;
            }
        }
    }
    cout << fixed << setprecision(20);
    cout << s[N] << endl;

}


Measured memory_bytes: 33920
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

const int dx[4] = {-1, 0, 0, 1};
const int dy[4] = {0, -1, 1, 0};

// Self settings
// clang-format off
#define MAX_N 100
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1 << 31;
// clang-format on

int N;
int A[MAX_N];

int main(void)
{
  cin >> N;
  REP(i, N) cin >> A[i];
  // A[i] なのでソートして0 と N -1 の要素の差が一番大きい
  sort(A, A + N);
  cout << A[N - 1] - A[0] << endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
 
public class Main {
 
	void submit() {
	    
	    double L = nextDouble();
	    
	    out.println((L/3)*(L/3)*(L/3));
	    
	}
 
	void preCalc() {
 
	}
 
	void stress() {
 
	}
 
	void test() {
 
	}
 
	Main() throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		preCalc();
		submit();
		//stress();
		//test();
		out.close();
	}
 
	static final Random rng = new Random();
 
	static int rand(int l, int r) {
		return l + rng.nextInt(r - l + 1);
	}
 
	public static void main(String[] args) throws IOException {
		new Main();
	}
 
	BufferedReader br;
	PrintWriter out;
	StringTokenizer st;
 
	String nextToken() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return st.nextToken();
	}
 
	String nextString() {
		try {
			return br.readLine();
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}
 
	int nextInt() {
		return Integer.parseInt(nextToken());
	}
 
	long nextLong() {
		return Long.parseLong(nextToken());
	}
 
	double nextDouble() {
		return Double.parseDouble(nextToken());
	}
}

Measured memory_bytes: 21076
#include <iostream>
using namespace std;
int num[101], d, n, res = 0;
int main(void){
    // Your code here!
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> d;
        num[d] = 1;
    }
    for (int i = 1; i <= 100; i++) {
        res += num[i];
    }
    cout << res << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
#define LL long long
#define ld long double
const int MOD = 1000000007;
struct ModInt {
	unsigned int val;
	ModInt(): val(0) {}
	ModInt(int v) { norm(v % MOD); }
	ModInt(long long v) { norm(v % MOD); }
	ModInt& norm(long long v) {
		v = v < 0 ? v % MOD + MOD : v; // negative
		v = v >= MOD ? v - MOD : v; // mod
		val = (unsigned int)v;
		return *this;
	}
	explicit operator bool() const { return val != 0; }
	ModInt operator-() const { return ModInt(0) - *this; }
	ModInt &operator+=(ModInt that) { return norm((long long)val + that.val); }
	ModInt &operator-=(ModInt that) { return norm((long long)val - that.val); }
	ModInt &operator*=(ModInt that) { val = (unsigned long long)val * that.val % MOD; return *this; }
	ModInt &operator/=(ModInt that) { return *this *= that.inv(); }
	ModInt operator+(ModInt that) const { return ModInt(*this) += that; }
	ModInt operator-(ModInt that) const { return ModInt(*this) -= that; }
	ModInt operator*(ModInt that) const { return ModInt(*this) *= that; }
	ModInt operator/(ModInt that) const { return ModInt(*this) /= that; }
	ModInt pow(long long n) const {
		ModInt x = *this, res = 1;
		while (n > 0) {
			if (n & 1) res *= x;
			x *= x, n >>= 1;
		}
		return res;
	}
	ModInt inv() const { return (*this).pow(MOD - 2); }
	bool operator==(ModInt that) const { return val == that.val; }
	bool operator!=(ModInt that) const { return val != that.val; }
	friend ostream& operator<<(ostream& os, const ModInt& that) { return os << that.val; }
};
LL choose(LL n, LL k) {
	if (n < k) return 0;

	const int MAX_N = 3e6 + 1;
	assert(0 <= k && k <= MAX_N);
	static LL fact[MAX_N + 1], revfact[MAX_N + 1], rev[MAX_N + 1];

	if (rev[1] == 0) {
		rev[1] = 1;
		for (int i = 2; i <= MAX_N; i++) rev[i] = rev[MOD % i] * (MOD - MOD / i) % MOD;
		fact[0] = 1, revfact[0] = 1;
		for (int i = 1; i <= MAX_N; i++) {
			fact[i] = fact[i - 1] * i % MOD;
			revfact[i] = revfact[i - 1] * rev[i] % MOD;
		}
	}
	return fact[n] * revfact[n - k] % MOD * revfact[k] % MOD;
}
string S;
int K;

void solve() {
	int N = SZ(S);
	ModInt res = 0;
	REPE(i, K) {
		res += ModInt(26).pow(i) * ModInt(25).pow(K - i) * choose(K - i + N - 1, K - i);
	}
	cout << res << endl;
}
void sol() {

	cout << setprecision(12) << fixed;

	cin >> K >> S;
	solve();
}

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

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int t = 1;
	//cin >> t;
	while (t--) {
		sol();
	}

	return 0;
}

Measured memory_bytes: 74712
//by yjz
#include<bits/stdc++.h>
#define FF first
#define SS second
#define MP make_pair
#define PB push_back
typedef long long ll;
using namespace std;
const int mod = 998244353;
const int maxn = 5000111;
ll fac[maxn], inv[maxn], ifac[maxn];
ll C(int x, int y) {return fac[x]*ifac[y]%mod*ifac[x-y]%mod;}
ll F(int n, int m)
{
	ll ans = C(3*m+n-1, n-1);
	ll del = 0;
/*	for (int i=0; i<m; i++)
	{
		del = (del+C(i+n-2, n-2))%mod;
	}
*/
	del = C(m+n-2, n-1);
	ans = (ans-1ll*del*n)%mod;
	return (ans+mod)%mod;
}
ll S(int x, int y)
{
	if (y==0) return x==0;
	else
	{
		return C(x+y-1, y-1);
	}
}
int main()
{
	fac[0] = 1;
	for (int i=1; i<maxn; i++) fac[i] = fac[i-1]*i%mod;
	inv[1] = 1;
	for (int i=2; i<maxn; i++) inv[i] = mod-1ll*(mod/i)*inv[mod%i]%mod;
	ifac[0] = 1;
	for (int i=1; i<maxn; i++) ifac[i] = ifac[i-1]*inv[i]%mod;
	int n, m;
	cin>>n>>m;
	ll ans = F(n, m);
	for (int i=m+2; i<=3*m&&i<=n; i+=2)
	{
		ans = (ans-C(n, i)*S((3*m-i)/2, n))%mod; 
	}
	cout<<(ans+mod)%mod<<endl;
	return 0;
}

Measured memory_bytes: 117376
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <string>
#include <numeric>
using namespace std;

int main()
{
	int N;
	cin >> N;
	int c = 4;int d = 7;
	string res;
	for (int i = 0;4*i < N;i++) {
		int sum = 4 * i;
			if ((N - sum) % 7 == 0||N%4==0) {
				res = "Yes";
				break;
			}
			else {
				res = "No";
			}
	}

	cout << res << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#define mo 998244353
#define LL long long
#define N 1000005
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fod(i,a,b) for(int i=a;i>=b;i--)
using namespace std;
LL js[N],ny[N];
LL ksm(LL k,LL n)
{
	LL s=1;
	for(;n;k=k*k%mo,n>>=1) if(n&1) s=s*k%mo;
	return s;
}
LL C(LL n,LL m)
{
	return js[n]*ny[m]%mo*ny[n-m]%mo;
}
int main()
{
	int n,m;
	cin>>n>>m;
	if(n<m) swap(n,m);
	js[0]=1;
	fo(i,1,n*2) js[i]=js[i-1]*(LL)i%mo;
	ny[2*n]=ksm(js[2*n],mo-2);
	fod(i,2*n-1,0) ny[i]=ny[i+1]*(LL)(i+1)%mo;
	LL ans=0;
	fo(i,1,m) 
	{
		ans=(ans+C(n+m-i-i,n-i)*C(i+i,i)%mo)%mo;
	}
	ans=ans*ny[2]%mo*ksm(C(n+m,m),mo-2)%mo;
	printf("%lld\n",(ans+n)%mo);
}

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


//constant----------------------------------------
const double EPS=1e-8;
const double INF=1e9;
const int COUNTER_CLOCKWISE=1;
const int CLOCKWISE=-1;
const int ONLINE_FRONT=2;
const int ONLINE_BACK=-2;
const int ON_SEGMENT=0;


typedef complex<double>Point;
typedef vector<Point>Polygon;
struct Line{
    Point p1,p2;
    Line(const Point &p1=Point(),const Point &p2=Point()):p1(p1),p2(p2){}
};
struct Segment{
    Point p1,p2;
    Segment(const Point &p1=Point(),const Point &p2=Point()):p1(p1),p2(p2){}
};
struct Circle{
    Point p;
    int r;
    Circle(const Point &p=Point(),int r=0.0):p(p),r(r){}
};

double Dot(Point &p1,Point &p2){
    return (conj(p1)*p2).real();
    return real(p1)*real(p2)+imag(p1)+imag(p2);
}

double Cross(Point &p1,Point &p2){
    return (conj(p1)*p2).imag();
    return real(p1)*imag(p2)-real(p2)*imag(p1);
}

int CCW(Point &p1,Point &p2,Point &p3){
    Point a=p2-p1,b=p3-p1;
    if(Cross(a,b)>EPS)return COUNTER_CLOCKWISE;
    if(Cross(a,b)<-EPS)return CLOCKWISE;
    if(Dot(a,b)<-EPS)return ONLINE_BACK;
    if(norm(b)>norm(a))return ONLINE_FRONT;
    return ON_SEGMENT;
}

signed main(){
    double x,y;
    scanf("%lf%lf",&x,&y);
    Point p1(x,y);
    scanf("%lf%lf",&x,&y);
    Point p2(x,y);

    int q;scanf("%d",&q);
    while(q--){
        scanf("%lf%lf",&x,&y);
        Point p3(x,y);
        if(CCW(p1,p2,p3)==COUNTER_CLOCKWISE)puts("COUNTER_CLOCKWISE");
        if(CCW(p1,p2,p3)==CLOCKWISE)puts("CLOCKWISE");
        if(CCW(p1,p2,p3)==ONLINE_BACK)puts("ONLINE_BACK");
        if(CCW(p1,p2,p3)==ONLINE_FRONT)puts("ONLINE_FRONT");
        if(CCW(p1,p2,p3)==ON_SEGMENT)puts("ON_SEGMENT");
    }
    return 0;
}

Measured memory_bytes: 1224
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;
typedef long long ll;

int main(void){
    int n, k, v[55], v_sum = 0;
    cin >> n >> k;
    for (int i = 0; i < n; i++) {
        cin >> v[i];  v_sum += v[i];
    }
    
    int ans[105] = {};
    for (int i = 0; i <= n; i++) {
        for (int j = n; j >= 0; j--) {
            if (i <= j) {
                int deq = i + (n - j), sum = 0;
                vector<int> pick;
                for (int p = 0; p < i; p++) {
                    pick.push_back(v[p]);  sum += v[p];
                }
                for (int p = n - 1; p >= j; p--) {
                    pick.push_back(v[p]);  sum += v[p];
                }
                
                /*
                cout << i << " " << j << " ";
                for (int p = 0; p < pick.size(); p++) cout << pick[p] << " ";
                cout << sum << endl;*/
                
                sort(pick.begin(), pick.end());
                for (int p = deq; p <= k; p++) {
                    ans[p] = max(ans[p], sum);
                    if (p - deq < pick.size() && pick[p - deq] < 0) {
                        sum -= pick[p - deq];
                    }
                }
            }
        }
    }
    
    int la = 0;
    for (int i = 0; i <= k; i++) {
        //cout << ans[i] << endl;
        la = max(la, ans[i]);
    }
    cout << la << endl;
    
}


Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include<set>
#include<queue>
#include<bitset>
#define rep(i,j,n) for(int i=j;i<n;i++)
using namespace std;
#define int long long
struct edge{long long to,cost;};
struct st{int rate,way,num;};
typedef pair<int,int>P;
#define inf 1000000007
string alph("abcdefghijklmnopqrstuvwxyz");
signed main(){
    int n;cin>>n;
    int a[105];
    rep(i,0,n)cin>>a[i];
    sort(a,a+n);
    reverse(a,a+n);
    int al=0,b=0;
    rep(i,0,n){
        if(i%2==0)al+=a[i];
        else b+=a[i];
    }
    cout<<al-b<<endl;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize "-O3"
#pragma GCC target ("avx")
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v),greater<int>())
#define SPEED ios::sync_with_stdio(false);cin.tie(0);cout<<fixed<<setprecision(12)
signed gcd(int a, int b){return b?gcd(b,a%b):a;}
signed lcm(int a, int b){return a*b/gcd(a,b);}
//priority_queue<int, vi, greater<int> > que;//昇順

using namespace std;

const int mod=1e9+7;

signed main(){
    SPEED;
    int r,g,b;
    cin >> r >> g >> b;
    g*=10;
    if((g+b)%4==0)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 256
lst =[]
for i in range(10000):
    lst.append(int(input()))
    if lst[i] == 0:
        for v in range(len(lst)-1):
            print(f'Case {v+1}: {lst[v]}')
        break
if 0 not in lst:
    for i in range(10000):
        print(f'Case {i+1}: {lst[i]}')



Measured memory_bytes: 5924
#include <bits/stdc++.h>
using namespace std;
int main()
  {int A, B, K, c{}; cin >> A >> B >> K;
  for (int i{min(A, B)}; i > 0; --i)
    {c += !(A % i + B % i);
    if (c == K) cout << i, exit(0);}}

Measured memory_bytes: 3644
class Vector
    def initialize
        @a = []
    end

    def pushBack(x)
        @a.push(x)
#        p @a
    end

    def randomAccess(x)
        puts @a[x]
    end

    def popBack
        @a.pop
    end
end

vector = Vector.new
num = gets.to_i

num.times do
    ope, x = gets.split.map(&:to_i)
    case ope
    when 0
        vector.pushBack(x)
    when 1
        vector.randomAccess(x)
    when 2
        vector.popBack
    end
end


Measured memory_bytes: 8540
n = gets.to_i
a = gets.chomp
puts a
a = a.split(" ").map{|s| s.to_i}
for i in 1..n-1
  key = a[i]
  j = i - 1
  while j >= 0 && a[j] > key
    a[j+1] = a[j]
    j -= 1
  end
  a[j+1] = key
  for k in 0..n-1
    print(a[k])
    if k==n-1
      puts("")
    else
      print(" ")
    end
  end
end

Measured memory_bytes: 8764
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;

int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> g((size_t) n, vector<int>());
    for (int i = 0; i < m; ++i) {
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        g[a].emplace_back(b);
        g[b].emplace_back(a);
    }

    sort(g[n - 1].begin(), g[n - 1].end());
    bool pos = false;
    for (auto i : g[0]) {
        auto itr = lower_bound(g[n - 1].begin(), g[n - 1].end(), i);
        if (itr != g[n - 1].end() && *itr == i) {
            pos = true;
        }
    }

    if (pos) cout << "POSSIBLE" << endl;
    else cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 12016
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
using namespace std;

void solve() {
    string s; cin >> s;
    if(s.size() < 4) cout << "No" << endl;
    else if(s.substr(0, 4) == "YAKI") cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

    solve();
    return 0;
}
 


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

char s[100005];
int main(){

cin.tie(0);
ios::sync_with_stdio(false);

cin>>s; 

int n=strlen(s); 
for(int i=0; i<n; i++){
	if(i%2==0) cout<<s[i];
}

cout<<endl;

}



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

#define ll long long
#define pb push_back

int main() {

	int a,b,c;
	cin>>a>>b>>c;
	cout<<max(a,max(b,c))-min(a,min(b,c))<<endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <unordered_set>
#include <unordered_map>

using namespace std;

int main() {

    int n,k;
    cin>>n>>k;
    vector<int> v;
    v.resize(n,false);
    for(int i=0;i<k;i++){
        int d;
        cin>>d;
        int ai;
        for(int i=0;i<d;i++){
            cin>>ai;
            ai--;
            v[ai]=true;
        }
    }
    int cnt=0;
    for(int i=0;i<n;i++){
        if(!v[i])
            cnt++;
    }
    cout<<cnt<<endl;

    return 0;
}

Measured memory_bytes: 3624
x, n= map(int,input().split())
l=list(map(int,input().split()))

pp=x
pm=x
while (pp in l) and (pm in l):
    pp=pp+1
    pm=pm-1

if (not pp in l) and (not pm in l):
    print(min(pp, pm))
elif pp in l:
    print(pm)
else:
    print(pp)


Measured memory_bytes: 9192
import sys

N = int(input())
A = [int(input()) for i in range(N)]

for i in range(N - 1):
    if A[i + 1] - A[i] > 1:
        print('-1')
        exit()

if A[0] != 0:
    print('-1')
    exit()

A.append(0)

count = 0
for i in range(N):
    if A[i+1] - A[i] <= 0:
        count += A[i]

print(count)


Measured memory_bytes: 11052
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define int long long
#define all(a) a.begin(), a.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

int n, m;
int c[9] = {2, 5, 5, 4, 5, 6, 3, 7, 6};
bool use[10];
string dp[10010];

bool calc(string s, string t){
    if(s.size() < t.size()) return true;
    if(s.size() > t.size()) return false;
    if(s < t) return true;
    return false;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> m;
    rep(i, 0, m){
        int a;
        cin >> a;
        a--;
        use[a] = true;
    }
    dp[0] = "";
    rep(i, 0, n){
        if(i && dp[i].size() == 0) continue;
        rep(j, 0, 9){
            if(use[j]){
                string nxt = dp[i] + char('1' + j);
                if(calc(dp[i + c[j]], nxt)){
                    dp[i + c[j]] = nxt;
                }
            }
        }
    }
    string ans = dp[n];
    cout << ans << endl;
}

Measured memory_bytes: 43648
#include<stdio.h>
int main(void){
    int S,h,m,s;
    h=0;
    scanf("%d",&S);
    while(S>=3600){
        h++;
        S-=3600;
    }
    while(S>=60){
        m++;
        S-=60;
    }
    s=S;
    printf("%d:%d:%d\n",h,m,s);
    return 0;
}


Measured memory_bytes: 2100
#include<bits/stdc++.h>
// Useful constants
#define INF  (int)1e9
#define EPS   1e-9
#define MOD 1000000007ll
#define PI 3.14159
// for input-output
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
// iteration macros: have advantage of auto-casting and not recomputing arguments
#define REP(i, a, b) \
for (int i = int(a); i <= int(b); i++) // a to b, and variable i is local!
#define TRvi(c, it) \
for (vi::iterator it = (c).begin(); it != (c).end(); it++)
#define TRvii(c, it) \
for (vii::iterator it = (c).begin(); it != (c).end(); it++)
#define TRmsi(c, it) \
for (msi::iterator it = (c).begin(); it != (c).end(); it++)
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
// input macro
#define in(x,n)   for(int e=0;e<n;e++){ll y;cin>>y;x.pb(y);}
//output macro
#define print(x)    for(auto it:x) cout<<it<<' '; cout<<endl;
#define printii(x)  for(auto it:x) cout<<it.F<<' '<<it.S<<'\t';  cout<<endl;
// shortcut for data type
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define ii pair<ll,ll>
#define pll pair<ll,ll>
#define vii vector<ii>
#define vvii vector<vii>
#define viii vector<pair<ii,ll>>
#define pb push_back
#define ppb pop_back
#define eb emplace_back
#define mp make_pair
#define F first
#define S second
#define uset unordered_set
#define umap unordered_map
//--namespace
using namespace std;
//--useful function
ll gcd(ll a, ll b){ll temp;while (b > 0){temp = a%b;a = b;b = temp;} return a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
ll fpow(ll  b, ll exp, ll mod){if(exp == 0) return 1;ll t = fpow(b,exp/2,mod);if(exp&1) return t*t%mod*b%mod;return t*t%mod;}
ll divmod(ll i, ll j, ll mod){i%=mod,j%=mod;return i*fpow(j,mod-2,mod)%mod;}
// --clock funtion
clock_t time_p=clock();
void TimeTaken()
{
    time_p=clock()-time_p;
    cerr<<"Completion time : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
// --solve function
void solve() {

}
//--main function
int main(){
	int n;
	cin>>n;
	cout<<(n+n*n+n*n*n);
	return 0;

//   TimeTaken();
}


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

typedef struct
{
  string name;
  int x1, x2, y1, y2;
} Button;

int main()
{
  int n;
  while (cin >> n) {
    if (n == 0)
      break;

    int W, H;
    cin >> W >> H;

    vector<string > buf;
    map<string, vector<Button> > button;
    for (int i = 0; i < n; ++i) {
      string name;
      int b;
      cin >> name >> b;
      for (int j = 0; j < b; ++j) {
	Button tmp;
	cin >> tmp.x1 >> tmp.y1 >> tmp.x2 >> tmp.y2 >> tmp.name;
	button[name].push_back(tmp);
      }

      if (i == 0)
	buf.push_back(name);
    }

    int m, p = 0;
    cin >> m;
    while (m--) {
      string cmd;
      cin >> cmd;

      if (cmd == "click") {
	int x, y;
	cin >> x >> y;
	const vector<Button>& link = button[buf[p]];
	for (int i = 0; i < link.size(); ++i) {
	  if (link[i].x1 <= x && x <= link[i].x2 &&
	      link[i].y1 <= y && y <= link[i].y2) {
	    buf.erase(buf.begin()+p+1, buf.end());
	    buf.push_back(link[i].name);
	    ++p;
	    break;
	  }
	}
      } else if (cmd == "show") {
	cout << buf[p] << endl;
      } else if (cmd == "back") {
	if (p != 0)
	  --p;
      } else {
	if (p+1 < buf.size())
	  ++p;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 0
N = int(input())
P = list(map(int,input().split()))
sum = 0
ave = 0
ave_first = 99999
k = []
#sum は合計、aveは平均値 ave_first は絶対値の平均値との比較 
# kはもっとも近いフレーム番号のリスト
for i in range(N):
    sum += P[i]
ave = sum/N
#aveを平均値とする
for i in range(0,N-1):
    if abs(P[i]-ave)< ave_first:
            ave_first = abs(P[i]-ave)
            k.clear()
            k.append(i)
    elif abs(P[i]-ave) == ave_first:
        k.append(i)
print(min(k))

Measured memory_bytes: 3064
function Main(input){
  input = input.split("\n");
  inputStr = input[0].split(" ");
  var a = Number.parseInt(inputStr[0]);
  var b = Number.parseInt(inputStr[1]);
  
  console.log(Math.max(a*2-1,b*2-1,a+b));
  
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
import sys
import math
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def make_grid(h, w, num): return [[int(num)] * w for _ in range(h)]


def main():
    N, K = NMI()
    integars = [NLI() for _ in range(N)]

    Kr = [K]
    now_k = 0
    for i in range(32, -1, -1):
        now_bit = (K >> i) & 1
        if now_bit == 0:
            continue
        now_k += pow(2, i)
        Kr.append(now_k - 1)
    ans = 0
    for kr in Kr:
        tmp = 0
        for a, b in integars:
            if (kr | a) == kr:
                tmp += b
        ans = max(ans, tmp)
    print(ans)



if __name__ == "__main__":
    main()

Measured memory_bytes: 89540
#include<bits/stdc++.h>
using namespace std;
#define fastio ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
typedef long long ll;

int main(){
    fastio;
    int n;
    cin >> n;
    ll sum = 0;
    for(ll i = 1; i <= n; ++i){
        if(i % 3 != 0 && i % 5 != 0) sum += i;
    }
    cout << sum << "\n";
    return 0;
}


Measured memory_bytes: 3652
// By Mohit Gupta
#include <bits/stdc++.h>
using namespace std;
#define printint(v) copy(begin(v), end(v), ostream_iterator<int>(cout," "))
#define printintv(s,e) copy(s,e, ostream_iterator<int>(cout," "))
#define forstl(i,v) for(auto &i: v)
#define forn(i,e) for(int i = 0; i < e; i++)
#define forsn(i,s,e) for(int i = s; i < e; i++)
#define rforn(i,s) for(int i = s; i >= 0; i--)
#define rforsn(i,s,e) for(int i = s; i >= e; i--)
#define clz(a) __builtin_clz(a) // count leading zeroes
#define ctz(a) __builtin_ctz(a) // count trailing zeroes
#define popc(a) __builtin_popcount(a) // count set bits (for ints only diff for ll)
//https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html for other in built
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define pb push_back
#define fi first
#define se second
#define int long long
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
typedef pair<int,int> p32; 
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
typedef map<int,int> m32;
#pragma GCC optimize ("-O2")
const int LIM = 1e5+5, MOD = 998244353;
int t,n,m,k,x,y;
 
int h[LIM];
int dp[LIM];


int32_t main()
{
	IOS;
	cin>>n>>k;
	forn(i,n) cin>>h[i+1];
	memset(dp,1e9 +5,sizeof(dp));
	dp[1]=0;
	for(int i=2;i<=n;i++){
        int start=max(i-k,1LL);
        for(;start<i;start++){
            dp[i]=min(dp[i],dp[start]+abs(h[start]-h[i]));
        }
	}
	cout<<dp[n]<<ln;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)
#define OPTIMIZE_STDIO ios::sync_with_stdio(false); cin.tie(0); cout.precision(10); cout << fixed
#define endl '\n'

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

void solve(istream& cin, ostream& cout) {
  ll n, m, k;
  cin >> n >> m >> k;
  vector<ll> a(n + 1), b(m + 1);
  a[0] = 0;
  b[0] = 0;
  FOR(i, 1, n) cin >> a[i];
  FOR(i, 1, m) cin >> b[i];
  FOR(i, 1, n) a[i] += a[i - 1];
  FOR(i, 1, m) b[i] += b[i - 1];
  int best;
  RFOR(j, m, 0) {
    if (b[j] <= k) {
      best = j;
      break;
    }
  }
  int ans = 0;
  int j = best;
  FOR(i, 0, n) {
    if (a[i] > k) break;
    while (b[j] > k - a[i]) {
      j--;
    }
    ans = max(ans, i + j);
  }
  cout << ans << endl;
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
  return 0;
}
#endif


Measured memory_bytes: 6364
/*
 * atcoder/abc120/d.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(ll __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }
class DisjollSet {
public:
    DisjollSet(ll n) {
        rank.resize(n);
        parent.resize(n);
        sizes.resize(n);
        for (ll i=0; i<n; i++) rank[i] = 0, parent[i] = i, sizes[i] = 1;
    }

    bool same(ll x, ll y) {
        return root(x) == root(y);
    }

    void unite(ll x, ll y) {
        x = root(x), y = root(y);
        if (x == y) return;
        if (rank[x] < rank[y]) swap(x, y);
        else if (rank[x] == rank[y]) rank[x]++;
        parent[y] = x;
        sizes.at(x) += sizes.at(y);
    }

    long long size(ll x) {
      return sizes.at(root(x));
    }

private:
    vector<ll> rank;
    vector<ll> parent;
    vector<long long> sizes;

    ll root(ll x) {
        if (x != parent[x]) {
            parent[x] = root(parent[x]);
        }

        return parent[x];
    }
};

/*
 * 1 2
 * 3 4
 * 1 3
 * 2 3
 * 1 4
 *
 * 最後の辺から追加していって通れるようになる島の組み合わせを加算していくのはどうだろう.
 * 事前に全組み合わせを求める. 4 * 3 / 2 = 6
 * 辺なし: 6-0 = 6
 * (1 4): 6-1 = 5
 * (1 4) (2 3): 6-2 = 4
 * (1 4) (2 3) (1 3): ...
 * 毎回DFSをするならO(N) x O(M) で間に合わない.
 * 前の結果を再利用出来るならO(N)に落とせるかもしれない.
 * Disjoll setならO(N) をO(a(N))に落とせる.
 * 新しい辺(a, b)を追加するたびにunite(a, b)する.
 * aが所属する集合の要素数XについてX * (X-1) / 2が行き来できる組み合わせ
 *
 * ただし、(1 2) (3 4)のように異なる集合同士がuniteする場合はどのように集計するか.
 * 2通り行き来できるのが正しいが.
 * Disjoll setの中で要素が1より大きい集合の要素数の和. これをO(1)で求められれば.
 */

const ll MAX = 100010;
ll N, M, C;
vector<ll> res;
ll A[MAX], B[MAX];
void solve() {
  cin >> N >> M;
  C = N * (N-1) / 2;
  DisjollSet ds(N);
  res.push_back(0);
  loop(m,0,M) {
    cin >> A[m] >> B[m];A[m]--;B[m]--;
  }

  for (ll m=M-1; m>=0; m--) {
    ll a = A[m], b = B[m];
    if (ds.same(a, b)) {
      res.push_back(res[res.size()-1]);
      continue;
    }

    ll as = ds.size(a), bs = ds.size(b);
    ds.unite(a, b);
    res.push_back(res[res.size()-1] + as * bs);
  }
  reverse(res.begin(), res.end());
  loop(n,1,M+1) cout << C-res[n] << endl;
}
int main() {
  // cout.precision(15); cout << fixed;

  solve();

  return 0;
}


Measured memory_bytes: 6132
function main(input){
    args = input.split(" ");
    n = parseInt(args[0],10);
    a = parseInt(args[1],10);
    b = parseInt(args[2],10);
    c = 0;
    for (var i = 0 ; i< n +1;i++) 
    {
        var d = i % 10;
        d += (i % 100 - i % 10) /10;
        d += (i % 1000  - i % 100) / 100;
        d += (i % 10000  - i % 1000) / 1000;
        if (i == 10000) d+=1;
        
        if (d >= a && d <= b) {c+=i;}
    }
    console.log(c);


}
main(require('fs').readFileSync('/dev/stdin', {encoding:'utf8'}))


Measured memory_bytes: 21192