akhauriyash/Code-Regression huggingface dataset:
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define forever while (true)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
template<typename A> using V = std::vector<A>;
template<typename A> using F = std::function<A>;
template<typename A, typename B> using P = std::pair<A, B>;
using pii = P<int, int>;
using vi = V<int>;
using vd = V<double>;
using vs = V<std::string>;
using vpii = V<pii>;
using vvi = V<vi>;
using vvpii = V<vpii>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr 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; }
template<typename T> std::istream &operator>>(std::istream &is, std::vector<T> &v) { for (T &x : v) is >> x; return is; }
using namespace std;
// clang-format on

using Weight = int;
struct Edge {
  int src, dst;
  Weight weight;
  Edge(const int &s = 0, const int &d = 0, const Weight &w = 0) : src(s), dst(d), weight(w) {}
};

using Edges = std::vector<Edge>;
using Array = std::vector<Weight>;
using Matrix = std::vector<Array>;

class Graph {
  std::vector<Edges> g;

public:
  Graph(const int &size = 0) : g(size) {}

  void addArc(const int &src, const int &dst, const Weight &w = 1) { g[src].emplace_back(src, dst, w); }

  void addEdge(const int &node1, const int &node2, const Weight &w = 1) {
    addArc(node1, node2, w);
    addArc(node2, node1, w);
  }

  const Edges &operator[](const int &i) const { return g[i]; }

  Graph toRootedTree(int r);
  std::pair<std::vector<Weight>, std::vector<int>> dijkstra(const int &src, const int &inf);
  Matrix warshallFloyd(const int &inf);
  std::pair<Weight, Edges> prim(const int &r);
  template<typename UnionFind> std::pair<Weight, Edges> kruskal();
  Weight solveTSP(const int &inf);
};

Matrix Graph::warshallFloyd(const int &inf = std::numeric_limits<Weight>::max() / 8) {
  int n = g.size();
  Matrix d(n, Array(n, inf));
  rep(i, n) d[i][i] = 0;
  for (auto &adj : g) {
    for (auto &e : adj) cmin(d[e.src][e.dst], e.weight);
  }
  rep(k, n) rep(i, n) rep(j, n) {
    if (d[i][k] != inf && d[k][j] != inf) cmin(d[i][j], d[i][k] + d[k][j]);
  }
  return d;
}

main {
  ios::sync_with_stdio(false);
  int n, t;
  cin >> n >> t;
  Graph g(n);
  while (t--) {
    int s, t, d;
    cin >> s >> t >> d;
    g.addArc(s, t, d);
  }
  Matrix d = g.warshallFloyd(INF);
  rep(i, n) if (d[i][i] < 0) {
    cout << "NEGATIVE CYCLE" << endl;
    return 0;
  }
  rep(i, n) {
    rep(j, n) {
      if (j) cout << ' ';
      cout << (d[i][j] == INF ? "INF" : to_string(d[i][j]));
    }
    cout << endl;
  }
}

Measured memory_bytes: 3456
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	string s;
	cin >> n >> s;
	set<int> R, G, B;
	rep(i,n){
		if(s[i] == 'R') R.insert(i);
		if(s[i] == 'G') G.insert(i);
		if(s[i] == 'B') B.insert(i);
	}
	ll ans = 0;
	for(int r : R){
		for(int g : G){
			int i = min(r, g) - abs(r - g);
			int j = (r + g) / 2;
			if((r + g)%2 != 0) j = -1;
			int k = max(r, g) + abs(r - g);
			ans += B.size();
			if(0 <= i && s[i] == 'B') --ans;
			if(0 <= j && j < n && s[j] == 'B') --ans;
			if(k < n && s[k] == 'B') --ans;
		}
	}
	cout << ans << endl;
	return 0;
}


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

int main(int argc, char const *argv[]) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    bool win;
    while (true) {
        c -= b;
        if (c <= 0) {
            win = true;
            break;
        }
        a -= d;
        if (a <= 0) {
            win = false;
            break;
        }
    }

    if (win) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3616
INF = 10 ** 20
V, E = map(int, input().split())
graph = [[INF] * V for _ in range(V)]
for i in range(V):
  graph[i][i] = 0
for _ in range(E):
  s, t, d = map(int, input().split())
  graph[s][t] = d

for k in range(V):
  for i in range(V):
    if graph[i][k] == INF:
      continue
    for j in range(V):
      if graph[k][j] == INF:
        continue
      graph[i][j] = min(graph[i][j], graph[i][k] + graph[k][j])

negative = 0
for i in range(V):
    if graph[i][i] < 0:
      negative = 1
      break

if negative == 1:
  print("NEGATIVE CYCLE")
else:
  for i in range(V):
    for j in range(V):
      if graph[i][j] == INF:
        print("INF", end = "")
      else:
        print("{}".format(graph[i][j]), end = "")
      if j != V-1:
        print(" ", end = "")
    print()


Measured memory_bytes: 6788
// at_abc148d.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
using namespace std;
int main()
{
    int n;cin >> n;
    int cur = 1;
    for (int i = 0;i < n;i++) {
        int temp;cin >> temp;
        if (temp == cur) {
            cur++;
        }
    }
    if (cur == 1) {
        cout << "-1\n"; return 0;
    }
    cout << n - cur + 1<<"\n";
}

// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started: 
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <sstream>
#include <set>
#include <tuple>
#include <algorithm>
#include <memory>
#include <numeric>
#include <queue>
#include <functional>
#include <cmath>
#include <cstring>
#include <map>
#include <unordered_map>
#include <sstream>
#include <iomanip>

using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

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

const ll INF = 1LL << 60;
const ll MOD = 1000000007;

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

	ll N;
	cin >> N;

	vector<ll> P(N);
	for (ll i = 0; i < N; ++i) cin >> P[i];

	ll m = numeric_limits<ll>::max();
	ll ans = 0;

	for (ll i = 0; i < N; ++i)
	{
		if (m < P[i])
		{
			continue;
		}
		else
		{
			m = P[i];
			ans++;
		}
	}

	cout << ans << endl;

	//system("pause");
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define int long long int
#define MP make_pair
#define PB push_back
#define F first
#define S second
using namespace std;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef vector<PII> VP;

int n, m, a[110], b[110][110];
int score[110];

signed main()
{
  cin >> n >> m;
  for(int i = 1; i <= m; i++){
    cin >> a[i];
  }
  for(int i = 1; i <= m; i++){
    for(int j = 1; j <= n; j++){
      cin >> b[i][j];
    }
  }

  for(int i = 1; i <= m; i++){
    for(int j = 1; j <= n; j++){
      if(a[i] == b[i][j]){
	score[j]++;
      }
      else{
	score[a[i]]++;
      }
    }
  }

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

Measured memory_bytes: 3164
def solve(string):
    n, *a = map(int, string.split())
    a = ["{:060b}".format(_a) for _a in a]
    m = 10**9 + 7
    ans = 0
    for d in zip(*a):
        ans <<= 1
        s = "".join(d).count("1")
        ans += s * (n - s)
        ans %= m
    return str(ans)


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))


Measured memory_bytes: 72924
#include <bits/stdc++.h>
#define prt_cs                  printf("Case %lld: ",cs)
#define sqr(x)                  (x)*(x)
#define ms(a,b)                 memset(a, b, sizeof(a))
#define db                      double
#define ll                      long long int
#define MOD                     100000007
#define PI                      2*acos(0.0)
#define pii                     pair< int, int >
#define READ                    freopen("in.txt","r",stdin)
#define WRITE                   freopen("out.txt","w",stdout)
#define gcd(a, b)               __gcd(a, b)
#define lcm(a, b)               (((a)*(b))/gcd(a,b))
#define MAX                     1005

using namespace std;

char s[3*MAX],t[3*MAX];
int dp[3*MAX][3*MAX];
string str;

int LCS(int i,int j)
{
    if(s[i]=='\0' || t[j]=='\0')
        return 0;
    if(dp[i][j]!=-1)return dp[i][j];
    int ans=0;
    if(s[i]==t[j])
    {
        ans=1+LCS(i+1,j+1);
    }
    else
    {
        int r1,r2;
        r1=LCS(i+1,j);
        r2=LCS(i,j+1);
        ans=max(r1,r2);
    }
    return dp[i][j]=ans;
}

void printLCS(int i,int j)
{
    if(s[i]=='\0' || t[j]=='\0')
    {
        return;
    }
    if(s[i]==t[j])
    {
        str+=s[i];
        printLCS(i+1,j+1);
    }
    else if(dp[i+1][j]>dp[i][j+1])
        printLCS(i+1,j);
    else
        printLCS(i,j+1);
}

int main()
{
//    READ;
//    WRITE;
    scanf("%s %s",&s,&t);
    ms(dp,-1);
    int ans=LCS(0,0);
//    printf("%d\n",ans);
    printLCS(0,0);
    cout<<str<<endl;
    return 0;
}


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

int calcPath(int x, int y) {
  string p1, p2, p3, p4;
  for (int i=0; i<y; i++) {
    p1 += "U";
  }
  for (int i=0; i<x; i++) {
    p1 += "R";
  }

  for (int i=0; i<y; i++) {
    p2 += "D";
  }
  for (int i=0; i<x; i++) {
    p2 += "L";
  }  

  p3 += "L";
  for (int i=0; i<y+1; i++) {
    p3 += "U";
  }
  for (int i=0; i<x+1; i++) {
    p3 += "R";
  }
  p3 += "D";  

  p4 += "R";
  for (int i=0; i<y+1; i++) {
    p4 += "D";
  }
  for (int i=0; i<x+1; i++) {
    p4 += "L";
  }
  p4 += "U";
  
  cout << p1+p2+p3+p4 << endl;
}

int main() {
  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;
  calcPath(tx-sx, ty-sy);


  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
int main()
{
    int a, b;
    cin >> a >> b;
    int ans = max({a+b, a-b, a*b});
    cout << ans << endl;
    return 0;
}

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

int main(){
    int N;
    cin >> N;
    vector<int> D(N);
    for(int i = 0; i < N; i++){
        cin >> D.at(i);
    }

    sort(D.begin(), D.end());

    int count = 0;

    for(int i = 0; i < N; i++){
        if(i == N-1){
            break;
        }
        else if(D.at(i) == D.at(i+1)){
            count++;
        }
    }

    cout << N - count << endl;

}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;

int main(void) {

	int n, m;

	cin >> n >> m;

	vector<string> a(n), b(m);

	bool itti = true, go = false;

	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}

	for (int i = 0; i < m; i++)
	{
		cin >> b[i];
	}

	for (int ay = 0; ay < n; ay++)
	{
		for (int ax = 0; ax < n; ax++)
		{
			//cout << "\n///////////////////////////////\n\nnext";
			//printf("(%d ,%d)\n", ay, ax);

			itti = true;

			for (int by = 0; by < m; by++)
			{
				for (int bx = 0; bx < m; bx++)
				{
					//printf("ay%dax%dby%dbx%d\n", ay, ax, by, bx);
					//if (by + ay <= n && bx + ax <= n) {
						/*if (a[by + ay].at(bx + ax) == b[by].at(bx)) {
							
							cout << a[by + ay].at(bx + ax) << b[by].at(bx);
							cout << "w\n";
						}*/
					//}
					if (ay + m <= n && ax + m <= n) {
						if (a[by + ay].at(bx + ax) != b[by].at(bx)) {
							itti = false;
							//cout << "*  ";
							//printf("ay=%d,ax=%d,by=%d,bx=%d\n", ay, ax, by, bx);
							//cout << a[ay + by].at(ax + bx);
							//cout << b[by].at(bx) << "\n\n";
						}
						else {
							//cout << "o  ";
							//printf("ay=%d,ax=%d,by=%d,bx=%d\n", ay, ax, by, bx);
							//cout << a[ay + by].at(ax + bx);
							//cout << b[by].at(bx) << "\n\n";
						}
					}
					else {
						itti = false;
					}
				}
			}

			if (itti == true) {
				go = true;
				//cout << "\ntrue\n";
			}
		}
	}

	if (go == true)cout << "Yes\n";
	else cout << "No\n";

	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
ll N;
vector<ll> divvec;


int main() {
    cin >> N;
    --N;
    vector<ll> divnum;
    divvec.push_back(0);
    divnum.push_back(1);
    while(divvec.back()<N){
        divnum.push_back(divnum.back()*26);
        divvec.push_back(divvec.back()+ divnum.back());
    }
    int t = divvec.size()-1;
    while(divvec[t]>N){
            --t;
    }
    N -= divvec[t];
    string ans ="";
    // cerr<<"N=" << N << endl;
    for(int i=t;i>=0;--i){
        int s = N/divnum[i];
        // cerr <<"s=" <<s <<endl;
        ans += char('a' +s);
        N -= s* divnum[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3628
import java.util.Scanner;
import java.util.Collections;
import java.util.List;
import java.util.ArrayList;

public class Main {
  public static void main(String[] args) {
    Scanner s = new Scanner(System.in);
    Long n = s.nextLong();
    List<Long> a = new ArrayList<Long>();
    for (int i = 0; i < n; i++) {
      a.add(s.nextLong());
    }
    Long min = Collections.min(a);
    Long max = Collections.max(a);
    Long sum = 0L;
    for (Long elem : a) {
      sum += elem;
    }
    System.out.println(min + " " + max + " " + sum);
    s.close();
  }
}



Measured memory_bytes: 43712
/*-- ILSH  --*/
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;
#define pb push_back 
#define pop pop_back
#define mp make_pair
#define vii vector < int >
#define vll vector < ll > 
#define dt cout<<"HERE\n";
#define pii pair < int , int >
#define pll pair < ll , ll >
#define vpi vector < pll >
#define vpl vector < pll >
#define fi first
#define se second 
#define sz size 
#define len length 

const ll inf=1e18+1e17;
const ll mod =1e9+7;
//const ll mod = 998244353;

ll modInverse(ll a,ll m){ll m0=m;ll y=0,x=1;if(m == 1)return 0;while(a> 1){ll q=a/m;ll t=m;m=a%m,a=t;t=y;y=x-q*y;x=t;}if(x<0)x+=m0;return x;}  
ll powm(ll a,ll b){a=a%mod;ll res=1;while(b){if(b&1)res=(res*a)%mod;a=(a*a)%mod;b>>=1;}return (res%mod);}


const ll N =1e3+6;

bool check (string s){
	ll a=s.len();
	for ( int i=0;i<a;i++)
		if ( s[i]!=s[a-i-1])
			return false;
	return true;
}

void solve(){
	string s;
	cin>>s;
	ll n=s.len();
	if ( check ( s.substr(0,( n-1/2)))&&check(s.substr( (n+3)/2-1,n-(n+3)/2+1))&&check(s))
		cout<<"Yes\n";
	else
		cout<<"No\n";

}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie( NULL);
	// #ifndef ONLINE_JUDGE
	// 	cin.tie(NULL);
	// 	freopen ("INPUT.txt" , "r" , stdin);
	// 	freopen ("OUTPUT.txt", "w" , stdout);
	// #endif	
    ll t=1;
   // cin>>t;
    for (ll i=1;i<=t;i++){
    //	cout<<"Case #"<<i<<": ";
    	solve();
 	}
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
const ll INF = 1LL<<61;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
  if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
  }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる




int main() {
  ll n,m;
  cin>>n>>m;

  vector<vector<ll>> p(n);
  map<ll,string> q;
  vector<ll> r(m);
  rep(i,m){
    ll a,b;
    cin>>a>>b;
    p[a-1].pb(b);
    r[i]=b;
    string s = to_string(a);
    int z=s.size();
    string t="";
    rep(j,6-z){
      t+="0";
    }
    t+=s;
    q[b]=t;
  }

  rep(i,n){
    sort(all(p[i]));
    rep(j,p[i].size()){
      string s = to_string(j+1);
      int z=s.size();
      string t="";
      rep(j,6-z){
        t+="0";
      }
      t+=s;      
      q.at(p[i][j])+=t;
    }
  }

  rep(i,m){
    cout << q.at(r[i]) << endl;
  }

}


Measured memory_bytes: 20352
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define ll int64_t
using namespace std;

bool compare_by_b(pair<string,int> a,pair<string,int> b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

bool my_compare(pair<string,int> a,pair<string,int> b){
    
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

int main(){
    int n;
    cin>>n;
    vector<pair<string,int>> v(n),b(n);
    rep(i,n){
        cin>>v[i].first>>v[i].second;
        b[i].first=v[i].first;
        b[i].second=v[i].second;
    }
    sort(ALL(v),my_compare);
    rep(i,n) rep(j,n){
        if(v[i]==b[j]) cout<<j+1<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
n=int(input())
m=[0]+list(map(int,input().split()))+[0]
ans=0
l1=[]
l2=[]
for i in range(n+1):
  ans+=abs(m[i+1]-m[i])
for i in range(1,n+1):
  l1.append(abs(m[i]-m[i-1])+abs(m[i]-m[i+1]))
  l2.append(abs(m[i+1]-m[i-1]))
for i in range(n):
  print(ans-l1[i]+l2[i])

Measured memory_bytes: 16708
#include <stdio.h>

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }

template <typename T, typename V>
void __print(const pair<T, V> &x) {
    cerr << '{';
    __print(x.first);
    cerr << ',';
    __print(x.second);
    cerr << '}';
}
template <typename T>
void __print(const T &x) {
    int f = 0;
    cerr << '{';
    for (auto &i : x) cerr << (f++ ? "," : ""), __print(i);
    cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
    __print(t);
    if (sizeof...(v)) cerr << ", ";
    _print(v...);
}
#ifdef LOCAL
#define debug(x...)               \
    cerr << "[" << #x << "] = ["; \
    _print(x)
#else
#define debug(x...)
#endif

#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)

typedef long long ll;

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

    ll N;
    cin >> N;
    vector<tuple<string, ll, ll>> SP(N);
    REP(i, N) {
        string S;
        ll P;
        cin >> S >> P;
        SP[i] = make_tuple(S, -P, i+1);
    }
    sort(SP.begin(), SP.end());

    REP(i, N) { cout << get<2>(SP[i]) << endl; }

    return 0;
}


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

int main(){
	int n;
    cin >> n;
    int ans=0;
    if(n % 2 == 0){
    ans += n/2;
    cout << ans << endl;
    }
    else{
    ans += n/2;
    ans ++;
    cout <<ans <<endl;
    }

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
struct UnionFind
{
    vector<int> data;

    UnionFind(int sz)
    {
        data.assign(sz, -1);
    }

    bool unite(int x, int y)
    {
        x = find(x), y = find(y);
        if (x == y)
            return (false);
        if (data[x] > data[y])
            swap(x, y);
        data[x] += data[y];
        data[y] = x;
        return (true);
    }

    int find(int k)
    {
        if (data[k] < 0)
            return (k);
        return (data[k] = find(data[k]));
    }

    int size(int k)
    {
        return (-data[find(k)]);
    }
    bool same(int x, int y)
    {
        return find(x) == find(y);
    }
};

int main()
{
    int N, M, K;
    cin >> N >> M >> K;
    UnionFind Friend(N), Block(N);
    //    vvint block = vvint(N), fr = vvint(N);
    vector<set<int>> block(N), fr(N);
    vint deg(N);
    rep(i, M)
    {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        Friend.unite(a, b);
        fr[a].insert(b);
        fr[b].insert(a);
        deg[a]++;
        deg[b]++;
    }
    rep(i, K)
    {
        int c, d;
        cin >> c >> d;
        c--;
        d--;
        //        Block.unite(c, d);
        block[c].insert(d);
        block[d].insert(c);
    }
    rep(i, N)
    {
        int num = Friend.size(i) - 1 - deg[i];
        for (int u : block[i])
        {
            if (Friend.same(u, i))
                num--;
        }
        cout << num << " ";
    }
    return 0;
}

Measured memory_bytes: 30208
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
#define PI 3.141592653589793
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}
int gcd(int a, int b){//ユークリッドの互除法
  if (a < b) gcd(b,a); //aの方がbよりでかいのが前提
  if (b == 0) return a; //aをbで割り切れたらreturn
  else gcd(b, a % b);
}
const int INF = 1<<30;
const int MOD = 1000000007;
int dx[4] = {0,0,-1,1};
int dy[4] = {-1,1,0,0};

int main(){
  int k,x; cin >> k >> x;
  int ans = k * 500;
  if(ans >= x) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define fi first
#define se second
#define fastio ios_base::sync_with_stdio(false); cin.tie(0)
#define loop(i, a, b) for(lli i=a; i<b; i++)
#define loopb(i, a, b) for(lli i=a; i>=b; i--)
#define pb push_back
#define umap unordered_map
typedef long long int lli;
typedef pair<lli, lli> pii;
typedef vector<lli> vll;
typedef pair<lli, pii> ppi;
typedef tree<lli, null_type, less<lli>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// use to avoid collision
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
// for pair in unordered_map
struct hash_pair {
    static uint64_t splitmix64(uint64_t x) {
    // http://xorshift.di.unimi.it/splitmix64.c
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
    }
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const{
        auto hash1 = hash<T1>{}(p.first);
        auto hash2 = hash<T2>{}(p.second);
        uint64_t x = hash1 ^ hash2;
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
lli M = 1e9 + 7;
lli power(lli x, lli y){
    lli res = 1;
    x = x%M ;
    while (y > 0) {
        if (y & 1)
            res = (res*x)%M ;
        y = y>>1;
        x = (x*x)%M;
    }
    return res%M;
}
lli solve(){
    lli n;
    cin>>n;
    string s, t;
    cin>>s>>t;
    string ans = s + t;
    loop(i, 0, n){
        cout<<ans[i]<<ans[i+n];
    }
    return 0;
}
int main(){
    fastio;
    lli t;
    // cin>>t;
    t = 1;
    while(t>0){
        t--;
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader; 
import java.io.*;
import java.io.InputStreamReader; 
import java.util.Scanner; 
import java.util.StringTokenizer; 
import java.util.*;
import java.math.*;
public class Main 
{ 
    static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader()
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next()
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine();
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
   public static void main(String args[])
    {
        Scanner sc=new Scanner(System.in);
        PrintWriter pw=new PrintWriter(System.out);
        int t = 1;//sc.nextInt();
        while(t-- > 0)
        {
            int l = sc.nextInt(),r=sc.nextInt(),d=sc.nextInt();
            int l1=(l-1)/d,l2=r/d;
            pw.println(l2-l1);
        }
        pw.close();
    }
}

Measured memory_bytes: 35748
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;

public class Main {
	private static int n;
	private static HashMap<Integer, List<Integer>> graph;
	private static Stack<Integer> stack;
	private static int time;
	private static int[][] timeRecorder;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		graph = new HashMap<>();

		for (int i = 0; i < n; i++) {
			int u = sc.nextInt();
			int k = sc.nextInt();
			List<Integer> vs = new ArrayList<>();
			for (int j = 0; j < k; j++) {
				int v = sc.nextInt();
				if (v != 0) {
					vs.add(v);
				}
			}
			graph.put(u, vs);
		}
		sc.close();

		stack = new Stack<>();
		time = 0;

		timeRecorder = new int[n][2];

		while (getStart() != null) {
			int start = getStart();
			stack.push(start);
			time++;
			timeRecorder[start - 1][0] = time;
			for (int key : graph.keySet()) {
				graph.get(key).removeIf(item -> item == start);
			}
			dfs(start);
		}

		for (int i = 0; i < n; i++) {
			System.out.print(i + 1);
			System.out.print(" ");
			System.out.print(timeRecorder[i][0]);
			System.out.print(" ");
			System.out.print(timeRecorder[i][1]);
			System.out.print("\n");
		}
	}

	private static Integer getStart() {
		for (int i = 1; i <= n; i++) {
			if (graph.get(i).size() != 0) {
				return i;
			}
		}
		return null;
	}

	private static Integer getNext(int now) {
		int checkLength = graph.get(now).size();
		if (checkLength != 0) {
			return graph.get(now).get(0);
		} else {
			return null;
		}
	}

	private static void dfs(int now) {
		while(!stack.isEmpty()) {
			Integer next = getNext(now);
			if (next == null) {
				int finished = stack.pop();
				time++;
				timeRecorder[finished - 1][1] = time;
				return;
			} else {
				stack.push(next);
				time++;
				timeRecorder[next - 1][0] = time;
				for (int key : graph.keySet()) {
					graph.get(key).removeIf(item -> item == next);
				}
				dfs(next);
			}
		}
	}
}

class Stack<T> {
	private LinkedList<T> stack;
	public Stack() {
		stack = new LinkedList<>();
	}
	public void push(T item) {
		stack.addLast(item);
	}
	public T pop() {
		T ret = stack.getLast();
		stack.removeLast();
		return ret;
	}
	public T top() {
		return stack.getLast();
	}
	public boolean isEmpty() {
		return stack.size() == 0;
	}
}

Measured memory_bytes: 33864
program bbb
implicit none

integer :: s, i, j

read*, s
i=s/100
j=s-i*100

if(i==0.and.j==0) then
write(*,'(a2)') 'NA'
return
end if

if(i==0) then
 if(j>12) 	write(*,'(a2)') 'NA'
 if(j<=12)  write(*,'(a4)') 'YYMM'
else if(j==0) then
 if(i>12)   write(*,'(a2)') 'NA'
 if(i<=12)  write(*,'(a4)') 'MMYY'
else
 if(i<=12.and.j<=12) write(*,'(a9)') 'AMBIGUOUS'
 if(i<=12.and.j>12) 	write(*,'(a4)') 'MMYY' 
 if(i>12.and.j<=12) 	write(*,'(a4)') 'YYMM'
 if(i>12.and.j>12) 	write(*,'(a2)') 'NA'
end if

end program

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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for (int i = a; i < b; i++)
#define N 100005
#define MOD 1000000007

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    int n;
    cin>>n;
    int a[n];
    REP(i,0,n)
        cin>>a[i];
    sort(a,a+n);
    ll sum=0;
    REP(i,1,n)
    {
        sum+=(a[n-1-(i/2)]);
    }
    cout<<sum;
}

Measured memory_bytes: 4444
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<iomanip>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

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

int main(){
  // 入力
  ll D; cin >> D;
  ll N = 26;
  vector<ll> c(N); rep(i,N) cin >> c[i];

  vector<vector<ll> > s(D , vector<ll>(N));
  vector<vector<ll> > ns(D , vector<ll>(N));
  rep(i,D) rep(j,N) cin >> s[i][j];
  rep(i,D) rep(j,N) ns[i][j] = s[i][j];

  rep(i,D){
    rep(j,N){
      ns[i][j] += (i + 1) * c[j];
    }
  }

  vector<ll> t(D);

  rep(i,D){
    ll choice = 0;
    ll tmp = -INF;
    rep(j,N){
      if(tmp < ns[i][j]){
        choice = j;
        tmp = ns[i][j];
      }
    }
    t[i] = choice;
    cout << choice + 1 << endl;
  }

  // score計算
  ll score = 0;
  vector<set<ll> > set(N);
  rep(i,N) set[i].insert(0);

  rep(i,D){
    score += s[i][t[i]];
    set[t[i]].insert(i + 1);

    rep(j,N){
      score -= (i - (*rbegin(set[j])) + 1) * c[j];
    }
  }
  // cout << score << endl;
}


Measured memory_bytes: 3824
#include <iostream>
#include <stack>

int main(void) {
    u_int in;
    std::stack<u_int> st;

    while (std::cin >> in) {
        if (in > 0) {
            st.push(in);
        } else {
            std::cout << st.top() << std::endl;
            st.pop();
        }
    }

    return 0;
}

Measured memory_bytes: 1192
#![allow(dead_code)]
use crate::scanner::Scanner;
use maplit::hashset;
fn main() {
    let mut scan = Scanner::new();
    let n = scan.read::<usize>();
    let s = scan.chars();
    let mut r = vec![0; n + 1];
    let mut g = vec![0; n + 1];
    let mut b = vec![0; n + 1];
    for i in 0..n {
        r[i + 1] = r[i] + (s[i] == 'R') as i64;
        g[i + 1] = g[i] + (s[i] == 'G') as i64;
        b[i + 1] = b[i] + (s[i] == 'B') as i64;
    }
    let mut cnt = 0;
    for i in 2..n {
        for j in 1..i {
            match (s[i], s[j]) {
                ('R', 'G') => cnt += b[j],
                ('R', 'B') => cnt += g[j],
                ('G', 'R') => cnt += b[j],
                ('G', 'B') => cnt += r[j],
                ('B', 'R') => cnt += g[j],
                ('B', 'G') => cnt += r[j],
                _ => (),
            };
            if s[i] != s[j]
                && j >= (i - j)
                && hashset!(s[i], s[j], s[j - (i - j)]) == hashset!('R', 'G', 'B')
            {
                cnt -= 1;
            }
        }
    }
    println!("{}", cnt);
}
mod scanner {
    use std::io::{stdin, BufReader, Bytes, Read, Stdin};
    use std::str::FromStr;
    pub struct Scanner {
        buf: Bytes<BufReader<Stdin>>,
    }
    impl Scanner {
        pub fn new() -> Scanner {
            Scanner {
                buf: BufReader::new(stdin()).bytes(),
            }
        }
        pub fn read_next<T: FromStr>(&mut self) -> Option<T> {
            let token = self
                .buf
                .by_ref()
                .map(|c| c.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect::<String>();
            token.parse::<T>().ok()
        }
        pub fn read<T: FromStr>(&mut self) -> T {
            self.read_next().unwrap()
        }
        pub fn readn<T: FromStr>(&mut self, n: usize) -> Vec<T> {
            (0..n).map(|_| self.read::<T>()).collect()
        }
        pub fn chars(&mut self) -> Vec<char> {
            self.read::<String>().chars().collect()
        }
        pub fn char(&mut self) -> char {
            self.read::<String>().chars().next().unwrap()
        }
    }
}



Measured memory_bytes: 2240
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace abc087a
{
    class Program
    {
        static void Main(string[] args) {
            var X = int.Parse(Console.ReadLine());
            var A = int.Parse(Console.ReadLine());
            var B = int.Parse(Console.ReadLine());
            Console.WriteLine((X-A)%B);
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
int main(){
 int N, K;
  long long count;
  count = 0;
  cin >> N >> K;
  if(N <= K)
    cout << 0 << endl;
  else
  {
    vector<int> H(N);
    for(int i=0;i<N;i++)
    {
      cin >> H.at(i);
    }
    sort(H.begin(),H.end());
    for(int i=0;i<N-K;i++)
      count += H.at(i);
    cout << count << endl;
  }
  
}

Measured memory_bytes: 1024
s = input()
c = 0

for i in range(len(s)):
    if i % 2 == 0:
        if s[i] != "R" and s[i] != "U" and s[i] != "D":
            c += 1
    else:
        if s[i] != "L" and s[i] != "U" and s[i] != "D":
            c += 1

if c == 0:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3060
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

class Main {

	public static void main(String[] args) {

		FastScanner sc = new FastScanner();
		int a=sc.nextInt();
		int b=sc.nextInt();
		int c=sc.nextInt();
		int ans=0;
		if(c>a-b)
		ans=c-(a-b);

		System.out.println(ans);

	}

	static class FastScanner {
		private final InputStream in = System.in;
		private final byte[] buffer = new byte[1024];
		private int ptr = 0;
		private int buflen = 0;

		private boolean hasNextByte() {
			if (ptr < buflen) {
				return true;
			} else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) {
					return false;
				}
			}
			return true;
		}

		private int readByte() {
			if (hasNextByte())
				return buffer[ptr++];
			else
				return -1;
		}

		private static boolean isPrintableChar(int c) {
			return 33 <= c && c <= 126;
		}

		public boolean hasNext() {
			while (hasNextByte() && !isPrintableChar(buffer[ptr]))
				ptr++;
			return hasNextByte();
		}

		public String next() {
			if (!hasNext())
				throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (isPrintableChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		public long nextLong() {
			if (!hasNext())
				throw new NoSuchElementException();
			long n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while (true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if (b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}

		public int nextInt() {
			long nl = nextLong();
			if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
				throw new NumberFormatException();
			return (int) nl;
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}
	}

}

Measured memory_bytes: 22612
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a, b, c, ans;
    cin >> a >> b >> c;
    
    ans = c - ( a - b);
    if(ans >0)
    {
        cout << ans << endl;
    }
    else
    {
        cout << "0" << endl;
    }
    
}


Measured memory_bytes: 3624
n=int(input())
sosu=[2,3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997]
a=[0]*len(sosu)
for i in range(2,n+1):
	for j in range(len(sosu)):
		while i%sosu[j]==0:
			i//=sosu[j]
			a[j]+=1
ans=1
for i in range(len(sosu)):
	ans*=(a[i]+1)
	ans%=(10**9+7)
print(ans)


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

void printArray(vector<int> A)
{
    for(int i = 0; i < A.size(); i++)
    {
        cout<<A[i]<<" ";
    }
    cout<<endl;
}

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

    vector<int> ht(n);
    vector<int> dp(n);

    for(int i = 0; i < n; i++)
    {
        int tmp;
        cin>>tmp;
        ht[i] = tmp;
    }

    //printArray(ht);

    dp[0] = 0;
    dp[1] = abs( ht[1] - ht[0] );

    for(int i = 2;  i < n; i++)
    {
        dp[i] = min( dp[i-1] + abs( ht[i-1] - ht[i] ), dp[i-2] + abs( ht[i-2] - ht[i]) );
    }

    cout<<dp[n-1]<<endl;

    // main();
    
    return 0;
}


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

int main(){
    int n;
    cin >> n;
    int count = 0;
    for(int i=1;i<n;i++){
        int l = n-i;
        for(int j = 1;j*j<=l;j++){
            if(l%j==0){
                if(j==(l/j)) count++;
                else count += 2;
            }
        }
    }
    cout << count ;
    return 0;
}

Measured memory_bytes: 3600
#!/usr/bin/env python3
import sys
import numpy as np

def solve(N: int, A: "List[int]"):
    maxA = 0
    maxInd = 0
    for i in range(N):
        if A[i] > maxA:
            maxA = A[i]
            maxInd = i
    A[maxInd] = 0
    subMaxA = max(A)
    for i in range(N):
        if i == maxInd:
            A[i] = subMaxA
        else:
            A[i] = maxA
    print('\n'.join(map(str, A)))
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 27888
#include <bits/stdc++.h>
#define rep(i, n) for(ll i=0; i<(n); ++i)
#define rep1(i,n) for(ll i=1; i<=(n); ++i)
#define repi(i,a,b) for(ll i=a; i<=(b); ++i)
#define rrep(i,n) for(ll i=(n-1); i>=0; --i)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define to_s to_string
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define print(x) cout<<(x)<<'\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
using Edge = pair<ll,ll>;
using Graph = vector<vector<Edge>>;
typedef pair<ll,ll> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
ll MOD = 1e9 + 7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}
ll devc(ll x, ll y){return 1 + (x-1)/y;}
ll modpow(ll x, ll y, ll m) {
    if (y == 0) return 1;
    ll res = modpow(x, y / 2, m);
    return res * res % m * (y & 1 ? x : 1) % m;
}
ll modinv(ll x) { return modpow(x, MOD - 2, MOD); }

int main(){
    ll N; cin >> N;
    map<ll,ll> mp; 
    rep(i,N){
        ll a; cin >> a;
        mp[a]++;
    }
    
    if(sz(mp) == N) print("YES");
    else print("NO");
    
    return 0;
}

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

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

    int rCount = 0, gCount = 0, bCount = 0;
    vector<int> rCountVec(n, 0), gCountVec(n, 0), bCountVec(n, 0);

    for (int i = n - 1; i >= 0; --i)
    {
        if (s.at(i) == 'R')
        {
            ++rCount;
        }
        else if (s.at(i) == 'G')
        {
            ++gCount;
        }
        else
        {
            ++bCount;
        }

        rCountVec.at(i) = rCount;
        gCountVec.at(i) = gCount;
        bCountVec.at(i) = bCount;
    }

    long long combiCount = 0;

    for (int first = 0; first <= n - 3; ++first)
    {
        char firstColor = s.at(first);
        for (int middle = first + 1; middle <= n - 2; ++middle)
        {
            char middleColor = s.at(middle);

            char remainColor = 'R' + 'G' + 'B' - firstColor - middleColor;

            int diff1 = middle - first;
            int ngIndex = middle + diff1;

            if (firstColor != middleColor)
            {
                if (remainColor == 'R')
                {
                    if (ngIndex < n && s.at(ngIndex) == 'R')
                    {
                        combiCount += max(rCountVec.at(middle) - 1, 0);
                    }
                    else
                    {
                        combiCount += rCountVec.at(middle);
                    }
                }
                else if (remainColor == 'G')
                {
                    if (ngIndex < n && s.at(ngIndex) == 'G')
                    {
                        combiCount += max(gCountVec.at(middle) - 1, 0);
                    }
                    else
                    {
                        combiCount += gCountVec.at(middle);
                    }
                }
                else if (remainColor == 'B')
                {
                    if (ngIndex < n && s.at(ngIndex) == 'B')
                    {
                        combiCount += max(bCountVec.at(middle) - 1, 0);
                    }
                    else
                    {
                        combiCount += bCountVec.at(middle);
                    }
                }
            }
        }
    }

    cout << combiCount << endl;
}

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

template <typename Container>
vector<int> zfunc(const Container& s) {
    int n = s.size();
    vector<int> z(n, 0);
    z[0] = n;
    for (int i = 1, l = 0, r = 0; i < n; ++i) {
        if (i <= r)
            z[i] = min(r - i + 1, z[i - l]);
        else
            z[i] = 0;
        while (i + z[i] < n && s[z[i]] == s[i + z[i]])
            ++z[i];
        if (i + z[i] - 1 > r)
            l = i, r = i + z[i] - 1;
    }
    return z;
}

int main() {
    int n;
    string s;
    cin >> n >> s;
    int ans = 0;
    for (int l = 0; l < n; ++l) {
        // up to l
        string t = s.substr(l);
        t += '$';
        t += s;

        vector<int> z = zfunc(t);
        for (int i = l + 1; i < n; ++i) {
            int j = n - l + 1 + i;
            int got = min(i - l, z[j]);
            ans = max(ans, got);
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define ll long long  
#define pb push_back
#define mk make_pair
#define mod 998244353
#define lb lower_bound
#define ub upper_bound
#define endl "\n"
#define all(x) x.begin(),x.end()
int main()
{
    ios::sync_with_stdio(0) ;
    cin.tie(0); 
    int n,k;
    cin>>k>>n;
    int arr[n];
    for(int i=0;i<n;i++)
    cin>>arr[i];
    int dif[n]={0};int mx=0;
    for(int i=1;i<n;i++)
    {
        dif[i]=arr[i]-arr[i-1];
        mx=max(mx,dif[i]);
    }
    int ans=arr[n-1]-arr[0];
    int ans1=k-mx;
    ans=min(ans,ans1);
    cout<<ans;
    return 0;
}
//make all values ll



Measured memory_bytes: 1792