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 REP(i,n) for(int i = 0;i < (int)(n);i++)
#define RREP(i,n) for(int i = (int)n-1;i >= 0;i--)
#define FOR(i,s,n) for(int i = s;i < (int)n;i++)
#define RFOR(i,s,n) for(int i = (int)n-1;i >= s;i--)
#define ALL(a) a.begin(),a.end()
#define IN(a, x, b) (a<=x && x<b)
template<class T>inline bool CHMAX(T&a,T b){if(a<b){a = b;return true;}return false;}
template<class T>inline bool CHMIN(T&a,T b){if(a>b){a = b;return true;}return false;}
template<class T>istream&operator >>(istream&is,vector<T>&vec){for(T&x:vec)is>>x;return is;}
template<class T>inline void in(T&t){cin>>t;}
template<class T,class... Ts>inline void in(T&t,Ts&...ts){cin>>t;in(ts...);}
template<class T>inline void out(T t){cout<<t<<endl;}
template<class T,class... Ts>inline void out(T t,Ts... ts){cout<<t<<" ";out(ts...);}
template<typename T=int>vector<T>mv(size_t a){return vector<T>(a);}
template<typename T=int,typename... Ts>auto mv(size_t a,Ts... ts){return vector<decltype(mv<T>(ts...))>(a,mv<T>(ts...));}
template<typename T,typename V>typename enable_if<is_class<T>::value==0>::type fill(T&t,const V&v){t=v;}
template<typename T,typename V>typename enable_if<is_class<T>::value!=0>::type fill(T&t,const V&v){for(auto &e:t)fill(e,v);}
constexpr long long INF = 1e18;

signed main(){
	int N;
	in(N);
	map<string,int>mp;
	auto ss = mv<string>(N);
	REP(i,N){
		int t;
		in(ss[i],t);
		mp[ss[i]]=t;
	}
	string s;
	in(s);
	int ans = 0;
	int flg = 0;
	REP(i,N){
		if(flg)ans += mp[ss[i]];
		if(ss[i]==s)flg=1;
	}
	out(ans);
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.PriorityQueue;

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] str = br.readLine().split(" ");
        int n = Integer.parseInt(str[0]);
        int m = Integer.parseInt(str[1]);

        ArrayList[] nodes = new ArrayList[n];
        for (int i = 0; i < n; i++) nodes[i] = new ArrayList();

        for (int i = 0; i < m; i++) {
            str = br.readLine().split(" ");
            int a = Integer.parseInt(str[0]) - 1;
            int b = Integer.parseInt(str[1]) - 1;

            nodes[a].add(b);
            nodes[b].add(a);
        }
        PriorityQueue que = new PriorityQueue<>((int[] l, int[] r) -> (l[1] - r[1]));
        int[] vertex = new int[2];
        vertex[0] = 0;
        vertex[0] = 0;
        que.add(vertex);
        int[] dist = new int[n];
        Arrays.fill(dist, Integer.MAX_VALUE / 2);
        dist[0] = 0;

        while (!que.isEmpty()) {
            vertex = (int[]) que.poll();
            int recent = vertex[0];
            for (Object v : nodes[vertex[0]]) {
                int next = (int) v;
                if (dist[recent] < Integer.MAX_VALUE / 3 && dist[recent] + 1 < dist[next]) {
                    dist[next] = dist[recent] + 1;
                    int[] tmp = new int[2];
                    tmp[0] = next;
                    tmp[1] = dist[next];
                    que.add(tmp);
                }
            }
        }

        if (dist[n - 1] > 2) {
            System.out.println("IMPOSSIBLE");
        } else {
            System.out.println("POSSIBLE");
        }

    }

}


Measured memory_bytes: 86140
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }

typedef long long ll;

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

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

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

const double PI = acos(-1.0);

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int N;
    cin>>N;
    vector<vector<int>> F(N,vector<int>(10,0));
    vector<vector<int>> P(N,vector<int>(11,0));
    rep(i,N)rep(j,10)cin>>F[i][j];
    rep(i,N)rep(j,11)cin>>P[i][j];
    // 全探索 --- bit は {0, 1, ..., n-1} の 2^n 通りの部分集合全体を動きます。
    //bit = 店の開き方
    ll ans = -INFLL;
    for (int bit = 1; bit < (1<<10); ++bit){
        /* bit で表される集合の処理を書く */
        //ある店との競合
        ll d = 0;
        rep(i,N){
            int cnt = 0;
            //j番目のbitが立っていて、F[i][j]も立っているか
            for(int j = 0; j < 10;j++){
                if(F[i][j] == 1 && (bit>>j & 1)){
                    cnt++;
                }
            }
            d += P[i][cnt];
        }
        chmax(ans, d);
    }
    cout<<ans<<endl;
}

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

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

    int count = 0;
    for (int i = N;  i >= 1  ; --i) {
        if (std::to_string(i).size() % 2 == 1){
            count++;
        }
    }

    cout << count << endl;
    return 0;
}

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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int N,K;
int T[100];
int dp[110][3][3];

signed main(){
    cin>>N>>K;
    memset(T,-1,sizeof(T));
    rep(i,K){
        int a,b;
        cin>>a>>b;
        a--;b--;
        T[a]=b;
    }

    rep(i,3)rep(j,3){
        if(T[0]>=0&&T[0]!=i)continue;
        if(T[1]>=0&&T[1]!=j)continue;
        dp[2][i][j]=1;
    }

    for(int i=2;i<N;i++){
        rep(j,3)rep(k,3)rep(l,3){
            if(T[i]>=0&&T[i]!=l)continue;
            if(j==k&&k==l)continue;
            dp[i+1][k][l]=(dp[i+1][k][l]+dp[i][j][k])%10000;
        }
    }

    int ans=0;
    rep(i,3)rep(j,3)ans=(ans+dp[N][i][j])%10000;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1164
using System;
using System.Linq;

class TestClass {
	static void Main(string[] args) {
		int s = int.Parse(Console.ReadLine());
		int h = s / 3600;
		int m = (s % 3600) / 60;
		s = (s % 3600 ) % 60;
		Console.WriteLine(h.ToString()+":"+m.ToString()+":"+s.ToString());
	}
}


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

int getGcd(int a,int b)
{
    if(a == 0){
        return b;
    }

    getGcd(b % a,a);
}
 
int main()
{
    int n, X, gcd;
    cin >> n >> X;
    vector<int> x(n);
    for(int i = 0;i < n;i++){
        cin >> x[i];
    }

    sort(x.begin(), x.end());
    for(int i = 1;i < n;i++){
        x[i] = x[i] - x[0];
    }
    X = abs(X - x[0]);
    x[0] = 0;
    gcd = x[0];

    for(int i = 1;i < n;i++){
        gcd = getGcd(gcd,x[i]);
    }
    gcd = getGcd(gcd,X);

    cout << gcd;
    
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using vll = vector<ll>;
using vll2 = vector<vector<ll>>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr ll MOD = 1e9 + 7;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    char c;
    cin >> c;
    cout << (char)('a' + (c - 'a' + 1)) << endl;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

h, w = map(int, input().split())
if h == 1 or w == 1:
    print(1)
    sys.exit(0)

# a/bの切り上げ: (a + b - 1)//b
print(((h * w) + 2 - 1) // 2)


Measured memory_bytes: 61676
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const long long LINF=8931145141919364364,LMOD=998244353;
// const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

int main(){
    int n,k; cin>>n>>k;
    vector<long long> l,r={0};
    rep(i,n){
        int x; cin>>x;
        if(x>0) r.push_back(x);
        if(x<0) l.push_back(-x);
        if(x==0) k--;
    }
    if(k==0){
        cout<<0<<endl;
        return 0;
    }
    l.push_back(0);
    reverse(all(l));
    int ll=l.size(),rr=r.size();
    ll--;
    long long ans=LINF;
    // lからi本
    for(int i=0;i<=min(k,ll);i++){
        if(k-i<rr) ans=min({ans,2*l[i]+r[k-i],l[i]+2*r[k-i]});
    }
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;

typedef long long lli;
typedef double lld;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<double> vdl;
typedef vector<vector<lli>> mat;
typedef vector<vdl> mad;
typedef unordered_map<lli,unordered_map<lli,lli>> graph;
typedef complex<double> cmp;
typedef vector<cmp> vcl;

const lli e5 = 100009;


char s[e5];
lli n;
lli u[e5];
lli v[e5];
lli up[e5];
lli vp[e5];

void error(){
	cout << "-1" << endl;
	exit(0);
}

int main(){
	scanf("%s",s+1);
	n = strlen(s+1);
	for(lli i = 1;i < n;i++){
		u[i] = i;
		v[i] = i+1;
	}
	s[0] = '0';
	if(s[0] != s[n]) error();
	if(s[1] != '1') error();
	lli i,j;
	lli l,r;
	for(i=1,j=n-1;i<j;i++,j--){
		if(s[i] != s[j]) error();
		if(s[i] == '0'){
			v[l] = v[i];
			vp[i] = l;
			u[r] = u[j];
			up[j] = r;
		}else{
			l = i;
			r = j;
		}
	}
	if(i == j){
		if(s[i] == '0'){
			v[l] = v[i];
		}
	}
	for(lli i = 1;i < n;i++){
		if(vp[i]){
			cout << u[i] << " " << v[vp[i]] << endl;
		}else if(up[i]){
			cout << u[up[i]] << " " << v[i] << endl;
		}else{
			cout << u[i] << " " << v[i] << endl;
		}
	}


}


Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int mod = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1.0);

int flag[1000010];
int dp[1000010];

int main()
{
    int s;
    cin >> s;
    dp[1] = flag[s] = s;
    for(int i = 2; i < 1000010; i++){
        if(dp[i-1]%2) dp[i] = 3*dp[i-1] + 1;
        else dp[i] = dp[i-1] / 2;
        if(flag[dp[i]]){
            cout << i << endl;
            return 0;
        }else flag[dp[i]] = 1;
    }
}

Measured memory_bytes: 2304
N=int(input())
l=[]
for _ in range(N):
    l.append(int(input()))
L=set(l)
LL=sorted(L,reverse=True)
cnt=1
for i in range(len(LL)-1):
    if LL[i]<=LL[i+1]:
        break
    cnt+=1
print(cnt)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#ifdef DEBUG
#define FPEN freopen("in.txt", "r", stdin);
#else
#define FPEN
#endif
const int maxn = 200009;
typedef long long i64;
typedef pair<i64, i64> pi64;
typedef pair<int, int> pi;
const i64 MOD = 119 << 23 | 1;
class {
 public:
  void solve() {
    int n;
    cin >> n;
    int cur = 0;
    vector<pi> A, B;
    for (int i = 0; i < n; ++i) {
      string s;
      cin >> s;
      int a = 0, Min = 0;
      for (char c : s) {
        if (c == '(') {
          a++;
        } else {
          a--;
        }
        Min = min(Min, a);
      }
      if (a >= 0) {
        if (Min >= 0)
          cur += a;
        else
          A.emplace_back(a, Min);
      } else {
        B.emplace_back(a, Min);
      }
    }
    sort(A.begin(), A.end(), [](pi a, pi b) {
      return a.second > b.second;
    });
    for (int i = 0; i < A.size(); ++i) {
      if (A[i].second + cur >= 0) {
        cur += A[i].first;
      } else {
        cout << "No\n";
        return;
      }
    }
    sort(B.begin(), B.end(), [](pi a, pi b) {
      return a.second - a.first < b.second - b.first;
      // if (a.second == b.second) return a.first > b.first;
      // return a.second < b.second;
    });
    for (int i = 0; i < B.size(); ++i) {
      if (B[i].second + cur >= 0) {
        cur += B[i].first;
      } else {
        cout << "No\n";
        return;
      }
    }
    if (cur == 0) {
      cout << "Yes\n";
    } else {
      cout << "No\n";
    }
  }
} NSPACE;
int main() {
  FPEN;
  ios_base::sync_with_stdio(false);
  cout.tie(0);
  cin.tie(0);
  NSPACE.solve();
}

Measured memory_bytes: 7628
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <queue>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <set>
#include <map>
#include <stack>

using namespace std;

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

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

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repl(i, n) for(LL i = 0; i < (LL)(n); i++)

int main(void){
  int n;

  cin>> n;

  if (n % 10 == 0 || n % 10 == 1 || n % 10== 6 || n % 10==8) {
    cout << "pon" << endl;
  } else if (n % 10 == 3) {
    cout << "bon" << endl;
  } else {
    cout << "hon" << endl;
  }

  return 0;
}

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

typedef long long lint;
typedef pair<int, int> P;
#define REP(i, x, n) for(int i = x ; i < n ; i++)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; i--)
#define SORT(c) sort((c).begin(), (c).end())

const int IINF = 1e9 + 10;
const lint LLINF = (lint)1e18 + 10;
const lint MOD = (lint)1e9 + 7;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

int main(){
    int n;
    cin >> n;
    vector<string> v(n);
    map<string, int> mpb;
    rep(i, n){
        cin >> v[i];
        ++mpb[v[i]];
    }
    int m;
    cin >> m;
    map<string, int> mpr;
    rep(i, m){
        string s;
        cin >> s;
        ++mpr[s];
    }
    int ans = 0;
    rep(i, n){
        int tmp = mpb[v[i]] - mpr[v[i]];
        ans = max(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
nums=input().rstrip().split()
num=[]
for i in range(len(nums)):
    num.append(int(nums[i]))
main=[]
for i in range(num[0]):
    main.append(input().rstrip())
result=0
for h in range(2**num[0]):
    h_str=format(h,'0'+str(num[0])+'b')
    for w in range(2**num[1]):
        w_str=format(w,'0'+str(num[1])+'b')
        count=0
        for i in range(num[0]):
            for j in range(num[1]):
                if main[i][j]=='#' and h_str[i]!='1' and w_str[j]!='1':
                    count+=1
        if count==num[2]:
            result+=1
print(result)


Measured memory_bytes: 9224
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,A,B,C;
  int D[101];
  cin>>N;
  cin>>A>>B;
  cin>>C;
  
  for(int i=0;i<N;i++){
    cin>>D[i];
  }
  
  sort(D,D+N,greater<int>());
  
  int ans=-1;
  int sum=C;
  for(int i=0;i<N;i++){
    sum+=D[i];
    ans=max(ans,sum/(A+(i+1)*B));
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1176
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    string s; cin >> s;
    int sum = 0;
    rep(i,s.size()) {
        sum += s[i] - '0';
    }
    if (sum % 9 == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3720
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

using ll = long long;
using ull = uint64_t;
using P = pair<int, int>;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

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

struct Edge{
    int to, cap, rev;
    Edge() = default;
    Edge(int to, int cap, int rev) : to(to), cap(cap), rev(rev) {}
};

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

    int X, Y, E;
    cin >> X >> Y >> E;
    int V = X + Y + 2;
    vector<vector<Edge>> graph(X + Y + 2);
    int s = X + Y, t = s + 1;
    for(int i = 0; i < X; ++i){
        graph[s].emplace_back(i, 1, (int)graph[i].size());
        graph[i].emplace_back(s, 0, (int)graph[s].size() - 1);
    }
    for(int i = X; i < X + Y; ++i){
        graph[i].emplace_back(t, 1, (int)graph[t].size());
        graph[t].emplace_back(i, 0, (int)graph[i].size() - 1);
    }
    for(int i = 0; i < E; ++i){
        int x, y;
        cin >> x >> y;
        y += X;
        graph[x].emplace_back(y, 1, graph[y].size());
        graph[y].emplace_back(x, 0, (int)graph[x].size() - 1);
    }
    
    vector<int> depth(V), iter(V);
    auto bfs = [&](int root){
        for(int i = 0; i < V; ++i)  depth[i] = -1;
        depth[root] = 0;
        queue<int> que;
        que.emplace(root);
        while(!que.empty()){
            int from = que.front();
            que.pop();
            for(auto& e : graph[from]){
                if(e.cap > 0 && depth[e.to] == -1){
                    depth[e.to] = depth[from] + 1;
                    que.emplace(e.to);
                }
            }
        }
        return;
    };
    auto dfs = [&](auto&& self, int S, int T, int flow) -> int {
        if(S == T)  return flow;
        for(int& i = iter[S]; i < (int)graph[S].size(); ++i){
            auto& e = graph[S][i];
            if(e.cap > 0 && depth[S] < depth[e.to]){
                int f = self(self, e.to, t, min(e.cap, flow));
                if(f > 0){
                    e.cap -= f;
                    graph[e.to][e.rev].cap += f;
                    return f;
                }
            }
        }
        return 0;
    };
    auto max_flow = [&](int S, int T){
        int res = 0;
        for(;;){
            bfs(S);
            if(depth[T] < 0)    break;
            for(int i = 0; i < V; ++i)  iter[i] = 0;
            int f;
            while((f = dfs(dfs, S, T, INF)) > 0)    res += f;
        }
        return res;
    };

    cout << max_flow(s, t) << endl;
}


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

double border[7][2] =
{
    {35.50, 71.00},
    {37.50, 77.00},
    {40.00, 83.00},
    {43.00, 89.00},
    {50.00, 105.00},
    {55.00, 116.00},
    {70.00, 148.00}
};
string name[8] = {"AAA", "AA", "A", "B", "C", "D", "E", "NA"};

int main(){
    double a, b;
    int i;
    while( cin >> a >> b ){
        for(i = 0; i < 7; i++){
            if( a < border[i][0] && b < border[i][1] ){
                break;
            }
        }
        cout << name[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 1224
import sys
def input():return sys.stdin.readline()[:-1]
def N(): return int(input())
def NM():return map(int,input().split())
def L():return list(NM())
def LN(n):return [N() for i in range(n)]
def LL(n):return [L() for i in range(n)]
def Yes(x):print("Yes")if x==True else print("No")

d=N()
c=L()
s=[[0]+L() for i in range(d)]
ld=[-1]*(27)
score=0
for i in range(d):
    t=N()
    score+=s[i][t]
    ld[t]=i
    for j,k in zip(ld[1:],c):
        score-=(i-j)*k
    print(score)

Measured memory_bytes: 68616
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;
#define fi first
#define se second
set<string> c;
const ll mod=1000000007;
const ll mod2=998244353;
const ll inf=100000000000000000;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
map<char,ll> moji_s,moji_t;
map<char,bool>ok_s,ok_t;
int main(){
    string s,t;
    cin>>s>>t;
    for(char c='a';c<='z';c++){
        ok_s[c]=false;
        ok_t[c]=false;
    }
    for(int i=0;i<s.size();i++){
        ok_s[s.at(i)]=true;
        ok_t[t.at(i)]=true;
        moji_s[s.at(i)]++;
        moji_t[t.at(i)]++;
    }
    for(char c='a';c<='z';c++){
        for(char c_t='a';c_t<='z';c_t++){
            if(ok_s[c]&&ok_t[c_t]&&moji_s[c]==moji_t[c_t]){
                ok_s[c]=false;
                ok_t[c_t]=false;
            }
        }
    }
    for(char c='a';c<='z';c++){
        if(ok_s[c]||ok_t[c]){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
}


Measured memory_bytes: 776
#include<bits/stdc++.h>
#define int long long
using namespace std;
main(){
  int a,b,c;
  while(cin>>a>>b>>c,a){
    int sum=1e9,s1,s2;
    for(int i=a;i<a*100000;i+=a){
      if((i-c)%b==0){
        int x=(i-c)/b,y=i/a;
        if(i!=c+b*x||x<0||y<0)continue;
        if(sum>x+y||(sum==x+y&&y<s1)){
          sum=x+y;
          s1=y;
          s2=x;
        }
      }
    }    
    for(int i=b;i<b*100000;i+=b){
      if((i-c)%a==0){
        int x=(i-c)/a,y=i/b;
        if(i!=c+a*x||x<0||y<0)continue;
        if(sum>x+y||(sum==x+y&&x<s1)){
          sum=x+y;
          s1=x;
          s2=y;
        }
      }
    }
    for(int i=b;i<b*100000;i+=b){
      if(i>c)break;
      if((c-i)%a==0){
        int x=i/b,y=(c-i)/a;
        if(x<0||y<0)continue;
        if(sum>x+y||(sum==x+y&&x<s1)){
          sum=x+y;
          s1=y;
          s2=x;
        }
      }
    }
    cout<<s1<<' '<<s2<<endl;
  }
}

Measured memory_bytes: 3052
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in); 
		int num;
		int e_num;
		String line;
		String extra_line;
		String before_extra_line;
		 while(true) {
			 if((line = sc.next()).equals("-")) break;
			 num = sc.nextInt();
			 for(int i = 0; i < num; i ++) {
				 e_num = sc.nextInt();
				 extra_line = line.substring(0,e_num);
				 before_extra_line = line.substring(e_num, line.length());
				 line = before_extra_line + extra_line;
			 }
			 System.out.println(line);
		 }
	}
}


Measured memory_bytes: 26276
#include <bits/stdc++.h>
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
using namespace std;
using lint = long long;
using pi = pair<int, int>;
const int MAXN = 200005;
 

typedef long long ll;

int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
	ll a, b;
	cin >> a  >> b ;
	cout << a * b;
  return 0;
}

/*
         ,--"""",--.__,---[],-------._         
       ,"   __,'            \         \--""""""==;-
     ," _,-"  "/---.___     \       ___\   ,-'',"
    /,-'      / ;. ,.--'-.__\  _,-"" ,| `,'   /
   /``""""-._/,-|:\       []\,' ```-/:;-. `. /
             `  ;:::      ||       /:,;  `-.\
                =.,'__,---||-.____',.=
                =(:\_     ||__    ):)=
               ,"::::`----||::`--':::"._
             ,':::::::::::||::::::::::::'.
    .__     ;:::.-.:::::__||___:::::.-.:::\     __,
       """-;:::( O )::::>_|| _<::::( O )::::-"""
   =======;:::::`-`:::::::||':::::::`-`:::::\=======
    ,--"";:::_____________||______________::::""----.          , ,
         ; ::`._(    |    |||     |   )_,'::::\_,,,,,,,,,,____/,'_,
       ,;    :::`--._|____[]|_____|_.-'::::::::::::::::::::::::);_
      ;/ /      :::::::::,||,:::::::::::::::::::::::::::::::::::/
     /; ``''''----------/,'/,__,,,,,____:::::::::::::::::::::,"
     ;/                :);/|_;| ,--.. . ```-.:::::::::::::_,"
    /;                :::):__,'//""\\. ,--.. \:::,:::::_,"
   ;/              :::::/ . . . . . . //""\\. \::":__,"
   ;/          :::::::,' . . . . . . . . . . .:`::\
   ';      :::::::__,'. ,--.. . .,--. . . . . .:`::`
   ';   __,..--'''-. . //""\\. .//""\\ . ,--.. :`:::`
   ;    /  \\ .//""\\ . . . . . . . . . //""\\. :`::`
   ;   /       . . . . . . . . . . . . . . . . .:`::`
   ;   (          . . . . . . . . . . . . . . . ;:::`
   ,:  ;,            . . . . . . . . . . . . . ;':::`
   ,:  ;,             . . . . . . . . . . . . .;`:::
   ,:   ;,             . . . . . . . . . . . . ;`::;`
    ,:  ;             . . . . . . . . . . . . ;':::;`
     :   ;             . . . . . . . . . . . ,':::;
      :   '.          . . . . . . . .. . . .,':::;`
       :    `.       . . . . . . . . . . . ;::::;`
        '.    `-.   . . . . . . . . . . ,-'::::;
          `:_    ``--..___________..--'':::::;'`
             `._::,.:,.:,:_ctr_:,:,.::,.:_;'`
________________`"\/"\/\/'""""`\/"\/""\/"____________________________
 
*/


Measured memory_bytes: 3652
n = gets.to_i
cnt = n
n.times {
    val = gets.to_i

	if 2 == val
		next
	end
	if 0 == val%2
		cnt-=1
		next
	end
	last = Math.sqrt(val);
	3.step( last, 2 ) { |j|
		if 0 == val%j
			cnt-=1
			break
		end
	}	
}

puts( cnt )

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


typedef long long ll;
#define reg register
#define rep(i,a,b) for(int i=a,i##end=b;i<=i##end;++i)
#define drep(i,a,b) for(int i=a,i##end=b;i>=i##end;--i)


char IO;
inline ll rd(){
	ll s=0,f=0;
	while(!isdigit(IO=getchar())) if(IO=='-') f=1;
	do s=(s<<1)+(s<<3)+(IO^'0');
	while(isdigit(IO=getchar()));
	return f?-s:s;
}


const int N=2e5+10;

int n;
map<string,int>M;

int main(){
	ios::sync_with_stdio(false);
	cin>>n;
	ll ans=0;
	rep(i,1,n) {
		string x;
		cin>>x;
		sort(x.begin(),x.end());
		ans+=M[x];
		M[x]++;
	}
	cout<<ans<<endl;
}




Measured memory_bytes: 11264
import numpy as np

# 2整数の最大公約数を求める関数を定義する
def get_gcd(a, b):
    a, b = max(a, b), min(a, b)
    c = a % b
    if c == 0:
        return b
    else:
        return get_gcd(b, c)

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

# 時計の数を入力する
N = int(input())
# 時計の周回時間を入力する
arr_T = np.empty(N, dtype = int)
for i in range(N):
    arr_T[i] = int(input())
# 周回時間を降順に並べる
arr_sort_T = np.sort(arr_T)[::-1]

# 全ての周回時間の最小公倍数を求める
# 最大周回時間を取り出す
max_T = np.max(arr_T)
m = max_T
if N != 1:
    # 繰り返し
    for n in arr_sort_T[1:]:
        gcd = get_gcd(m, n)
        m = (m // gcd) * n

# 結果を出力する
print(m)

Measured memory_bytes: 12500
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pb push_back

int main(){
    int a=0,b=0,c=0;
    string s;
    cin >> s;
    for(int i=0;i<s.size();i++){
        if(s[i]=='a'){
            a++;
        }
        if(s[i]=='b'){
            b++;
        }
        if(s[i]=='c'){
            c++;
        }
    }
    if(abs(a-b)<=1&&abs(a-c)<=1&&abs(b-c)<=1){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

vector<int> digits;
void makeDigits(int dd, ll x){
  if(dd==0){
    map<int,int> m;
    ll y = x;
    while(y>0){
      m[y%10] = 1;
      y /= 10;
    }
    if(m[3]>0 && m[5]>0 && m[7]>0) digits.push_back(x);
  }else{
    makeDigits(dd-1, 10*x+3);
    makeDigits(dd-1, 10*x+5);
    makeDigits(dd-1, 10*x+7);
  }
}

int main(){

  REP(i,3,10){
    makeDigits(i, 0);
  }

  ll N;
  cin >> N;

  int ret = 0;
  rep(i,digits.size()){
    if(digits[i] <= N) ret++;
  }

  cout << ret << endl;
  
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;
    
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 
#define U_MAP unordered_map<ll,ll>
#define pq priority_queue<ll>
#define rpq priority_queue<ll,vector<ll>,greater<ll>>
#define p_b push_back
    
ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
    
//-------------------------↓↓↓↓↓↓------------------------
    
//------ 自分を天才だと信じる ------
    
int main(void){
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>a>>b;
    if(a+b==15)Cout("+");
    else if(a*b==15)Cout("*");
    else Cout("x");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    float a, b;
    float mean;
    const float KIRIAGE = 0.5;

    cin >> a >> b;
    if(a < 1 || b > 100){
        return 0;
    }
    mean = (a + b) / 2;
    if(mean - (int)mean >= KIRIAGE){
        mean = (int)(mean + 1);
    }
    else{
        mean = (int)mean;
    }

    cout << mean << endl;
}

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

int main()
{
    int n, m;
    cin >> n;
    vector<int> t(n);
    rep(i, n) cin >> t[i];
    cin >> m;
    vector<int> p(m), x(m);
    rep(i, m) cin >> p[i] >> x[i];

    int tmp=0;
    rep(i, n) tmp += t[i];

    rep(i, m)
    {
        int ans = tmp;
        ans -= t[p[i] - 1];
        ans += x[i];

        cout << ans << '\n';
    }

    return 0;
}


Measured memory_bytes: 3576
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<queue>
#include<cassert>
#include<tuple>
#include<set>
#include<map>
#include<list>
#include<bitset>

#define PB push_back
#define ALL(a)  (a).begin(),(a).end()
#define DWN(a)  (a).begin(),(a).end(), greater<int>()
#define rep(i, m) for (int i = 0; i < m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)

#define mod 1000000007

using namespace std;

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

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
const int INF = (int)1e9;

int main()
{
	int n;
	cin >> n;
	vector<int> a(n), b(n);
	rep(i, n) cin >> a[i];
	rep(i, n) cin >> b[i];

	ll bit[29];
	rep(i, 29) bit[i] = 0;
	for (int i = 29; i > 0; --i) {
		int md = 1 << i;
		rep(j, n) a[j] = a[j] % md;
		rep(j, n) b[j] = b[j] % md;
		sort(ALL(b));
		md /= 2;

		rep(j, n) {
			bit[i - 1] += lower_bound(ALL(b), 2 * md - a[j]) - lower_bound(ALL(b), md - a[j]);
			bit[i - 1] += lower_bound(ALL(b), 4 * md - a[j]) - lower_bound(ALL(b), 3 * md - a[j]);
		}
	}

	int ans = 0;
	rep(i, 29) {
		if (bit[i] % 2 == 0) continue;
		else ans += (1 << i);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) begin(x), end(x)
using namespace std;
using ll = long long;
template <typename T> using V = vector<T>;
constexpr ll Mod = 998244353;
constexpr ll mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;
const double PI = acos(-1);
template <typename T> constexpr bool chmax(T &a, const T &b) {
    if(a >= b) return false;
    a = b;
    return true;
}
template <typename T> constexpr bool chmin(T &a, const T &b) {
    if(a <= b) return false;
    a = b;
    return true;
}

/*-------------------------------------------*/

bool check(int i, int j, int d) {
    int u = __builtin_ctz(d);
    return !((u & 1 ? i : i ^ j) >> (u / 2) & 1);
}

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

    int n, d1, d2, cnt = 0;
    cin >> n >> d1 >> d2;
    rep(i, 2 * n) rep(j, 2 * n) {
        if(check(i, j, d1) && check(i, j, d2)) {
            cout << i << " " << j << "\n";
            if(++cnt >= n * n) return 0;
        }
    }

    return 0;
}

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

int main() {
  int N;
  cin>>N;
  map<int, int> m;
  vector<int> a(N);
  for(int i=0;i<N;i++) cin>>a[i];


  for(int i=0;i<N;i++){
    m[a[i]]++;
  }

  if(m.size()==N) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}


Measured memory_bytes: 10368
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
	int a,b,n;
	cin>>n>>a>>b;
	if(a*n<=b){
		cout<<a*n<<endl;
	}
	else if(a*n>=b){
		cout<<b<<endl;
	}
	
}

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

#define dump(...) cout<<"# "<<#__VA_ARGS__<<'='<<(__VA_ARGS__)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;
using pll=pair<ll,ll>;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}

template<typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	print_tuple<Cdr...>(os,t);
	os<<(sizeof...(Cdr)?",":"")<<get<sizeof...(Cdr)>(t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

int main()
{
	for(int x,y,z;cin>>x>>y>>z&&x|y|z;){
		int n=x+y+z;
		vl as(n),bs(n),cs(n);
		rep(i,n) cin>>as[i]>>bs[i]>>cs[i];

		vector<tuple<ll,ll,ll>> ts(n);
		rep(i,n) ts[i]=mt(as[i],bs[i],cs[i]);

		sort(all(ts),[](auto a,auto b){return get<0>(a)-get<1>(a)<get<0>(b)-get<1>(b);});

		vl max1(n+1);
		{
			auto get_diff=[](auto t){return get<1>(t)-get<2>(t);};
			vl csum(n+1),dsum(n+1);
			rep(i,n){
				csum[i+1]=csum[i]+get<2>(ts[i]);
				dsum[i+1]=dsum[i]+get_diff(ts[i]);
			}
			priority_queue<ll,vector<ll>,greater<ll>> pq;
			ll tmp=0;
			rep(i,y+z+1){
				max1[i]=dsum[i]-tmp;
				pq.emplace(get_diff(ts[i]));
				if(pq.size()>y){
					tmp+=pq.top();
					pq.pop();
				}
			}
			repi(i,y,y+z+1)
				max1[i]+=csum[i];
		}

		vl max2(n+1);
		{
			auto get_diff=[](auto t){return get<0>(t)-get<2>(t);};
			vl csum(n+1),dsum(n+1);
			per(i,n){
				csum[i]=csum[i+1]+get<2>(ts[i]);
				dsum[i]=dsum[i+1]+get_diff(ts[i]);
			}
			priority_queue<ll,vector<ll>,greater<ll>> pq;
			ll tmp=0;
			peri(i,y,n){
				pq.emplace(get_diff(ts[i]));
				if(pq.size()>x){
					tmp+=pq.top();
					pq.pop();
				}
				max2[i]=dsum[i]-tmp;
			}
			repi(i,y,y+z+1)
				max2[i]+=csum[i];
		}

		ll res=0;
		repi(i,y,y+z+1)
			res=max(res,max1[i]+max2[i]);
		cout<<res<<endl;
	}
}


Measured memory_bytes: 9696
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int a[]=new int [3];
		a[0]=scanner.nextInt();
		a[1]=scanner.nextInt();
		a[2]=scanner.nextInt();
		Arrays.sort(a);
		System.out.println(Integer.parseInt(String.valueOf(a[2])+String.valueOf(a[1]))+a[0]);
	}
}


Measured memory_bytes: 22996
#include <algorithm>
#include <cassert>
#include <cstring>
#include <iostream>
#include <vector>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define TRACE(x) cout << #x << " = " << x << endl
#define _ << " _ " <<

typedef long long llint;

pair<int, int> solve(int x, int K, vector<int>& parent,
                     vector<vector<int>>& E) {
  int ret = 0;
  int prev = 0;
  for (int y : E[x]) {
    auto p = solve(y, K, parent, E);
    ret += p.first;
    prev = max(prev, p.second);
  }

  if ((x == 0 || prev == K - 1) && parent[x] != 0) {
    ret++;
    prev = -1;
  }

  prev++;
  return {ret, prev};
}

int main(void) {
  ios_base::sync_with_stdio(false);
  int N, K;
  cin >> N >> K;

  vector<int> parent(N);
  REP(i, N) {
    cin >> parent[i];
    --parent[i];
  }

  if (K == 1) {
    int ret = 0;
    REP(i, N) if (parent[i] != 0) ret++;
    cout << ret << "\n";
    return 0;
  }

  vector<vector<int>> E(N);
  FOR(i, 1, N) E[parent[i]].push_back(i);

  int ret = 0;

  ret += solve(0, K, parent, E).first;

  cout << ret << "\n";
  return 0;
}


Measured memory_bytes: 13952
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef vector<vb> vvb;
typedef vector<vpii> vvpii;
const int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
const int MOD = 1000000007;
const double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
bool odd(const int &n) { return n & 1; }
bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  int n, m, t;
  cin >> n >> m >> t;
  vi cannotStudy(t + 1);
  while (n--) {
    int a;
    cin >> a;
    for (int i = a - m; i <= a + m; i++) {
      if (i < cannotStudy.size()) cannotStudy[i] = 1;
    }
  }
  int c = 0;
  loop(i, 1, cannotStudy.size()) c += !(cannotStudy[i - 1] && cannotStudy[i]);
  cout << c << endl;
}

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

int main() {
    while (true) {
        int a, b;
        cin >> a >> b;
        if (!a && !b) return 0;

        int diff = b - a;
        int x, y, z;
        z = diff / 1000;
        diff %= 1000;
        y = diff / 500;
        diff %= 500;
        x = diff / 100;
        cout << x << " " << y << " " << z << endl;
    }
}

Measured memory_bytes: 3068
#include <bits/stdc++.h>
using namespace std;
 
#define MOD 1000000007
#define INF 2000000000
#define MAX 100001
//#define int ll
#define ll long long
#define ld long double
#define vi vector<int>
#define pa pair<int, int>
 
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...)type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T& t) { cin >> t; }
template<typename First, typename...Rest>void MACRO_VAR_Scan(First& first, Rest&...rest) { cin >> first; MACRO_VAR_Scan(rest...); }
#define VEC(type, c, n) vector<type> c(n);for(auto& i:c)cin>>i;
#define MAT(type, c, m, n) vector<vector<type>> c(m, vector<type>(n));for(auto& r:c)for(auto& i:r)cin>>i;
 
#define BR cout << "\n";
#define SP cout << " ";
#define ENDL cout<<endl;
#define OUT(d) cout<<(d);
#define OUTL(d) cout<<(d)<<endl;
#define YES OUTL("YES")
#define Yes OUTL("Yes")
#define NO OUTL("NO")
#define No OUTL("No")
#define RET return 0;
 
#define REP(i, n) for(int i=0;i<(n);i++)
#define RREP(i, n) for(int i=n-1;i>=0;--i)
#define FOR(i, m, n) for(int i = m;i < n; i++)
#define RFOR(i, a, b) for(int i=(a)-1;i>=(b);--i)
#define AREP(a, n) for(auto (a):(n))
#define ALL(a) (a).begin(),(a).end()


signed main(){ INIT
    VAR(ll, q, h, s, d, n);
    
    h = min(h, q * 2);
    s = min(s, h * 2);

    ll ans = 0;
    if(d > s * 2){
        ans = n * s;
    }else{
        ans += d * (n/2) + s * (n%2);
    }
    OUTL(ans);
RET;}


Measured memory_bytes: 256
from operator import itemgetter as ig
# 定数
INF = float("inf")
MOD = int(1e9 + 7)

# エントリーポイント
def main():
    N = int(input())
    AB = (tuple(map(int, input().split())) for _ in range(N))
    ab = sorted(AB, key=ig(1))
    sum_a = 0
    for a, b in ab:
        sum_a += a
        if b < sum_a:
            print("No")
            break
    else:
        print("Yes")

main()


Measured memory_bytes: 31852
#include <bits/stdc++.h>
#define f first
#define s second
#define MOD 1000000007
#define PMOD 998244353
#define pb(x) push_back(x)
using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> plii;
typedef pair<int, pii> piii;
const int INF = 1e9+10;
const ll LINF = 1LL*INF*INF;
const int MAXN = 5e5+10;
const int MAXM = 5e3+10;

priority_queue<int> pq;
vector<vector<int> > graph;
queue<int> que;

int A[MAXN];
int v[MAXN];
char S[MAXN];

bool vis[MAXN];

int main()
{
    int n,m,k,a,b,x,y,q;
    int sum = 0;
    int cnt = 0;
    int mx = 0;
    int mn = INF;
    int cur = 0, idx = -1;
    int tc;

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin>>S;

    n = strlen(S);
    n++;

    vector<int> val;
    vector<int> valmx;

    if(S[0]=='<')val.push_back(0);
    else valmx.push_back(0);

    for(int i=0;i<n-1;i++){
        if(S[i]=='>'&&S[i+1]=='<')val.push_back(i+1);
        else if(S[i]=='<'&&S[i+1]=='>')valmx.push_back(i+1);
    }

    if(S[n-2]=='>')val.push_back(n-1);
    else valmx.push_back(n-1);

    for(int i=0;i<valmx.size();i++){
        idx = valmx[i];
        vis[idx] = true;
    }

    int L,R;

    for(int i=0;i<val.size();i++){
        idx = val[i];
        vis[idx] = true;
        L = idx-1;
        R = idx+1;
        cnt = 0;
        while(L>=0&&(!vis[L])){
            ++cnt;
            v[L] = cnt;
            L--;
        }
        cnt = 0;
        while(R<n&&(!vis[R])){
            ++cnt;
            v[R] = cnt;
            R++;
        }
    }

    for(int i=0;i<valmx.size();i++){
        idx = valmx[i];
        if(idx==0)v[idx] = v[idx+1]+1;
        else if(idx==n-1)v[idx] = v[idx-1]+1;
        else v[idx] = max(v[idx-1],v[idx+1])+1;
    }

    ll res = 0;

    for(int i=0;i<n;i++)
        res+=(ll)v[i];

    cout<<res<<"\n";

    return 0;
}


Measured memory_bytes: 5492
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() []int {
	n := readInt()
	return readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func minInt(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func minUint(a, b uint) uint {
	if a < b {
		return a
	}
	return b
}

func minInt64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func minUint64(a, b uint64) uint64 {
	if a < b {
		return a
	}
	return b
}

func maxInt(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func maxUint(a, b uint) uint {
	if a < b {
		return b
	}
	return a
}
func maxInt64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func maxUint64(a, b uint64) uint64 {
	if a < b {
		return b
	}
	return a
}

func absInt(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absInt64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int
func main() {
	defer stdout.Flush()

	w := readInt()
	a := readInt()
	b := readInt()

	ar := a + w
	br := b + w

	if a <= b && b <= ar || a <= br && br <= ar {
		println(0)
		return
	}

	println(minInt(absInt(ar-b), absInt(br-a)))

}


Measured memory_bytes: 640