akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;

int main(){
    int n, x;
    
    while(1){
        cin >> n >> x;
        if (n==0 && x==0) break;
        int num=0, imax=min(n-2,x/3), jmax=min(n-1,x/2), kmax=min(n,x);
        for (int i=1; i<=imax; i++)
            for (int j=i+1; j<=jmax; j++)
                for (int k=j+1; k<=kmax; k++)
                    if (i+j+k==x) num++;
        cout << num << endl;
    }
    return 0;
}


Measured memory_bytes: 3076
#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars, Usize1};
use proconio::{fastout, input};
use std::cmp::{max, min};
#[fastout]
fn main() {
    input! {
        s: Chars,
    }
    let mut count_a = 0;
    let mut count_b = 0;
    let mut count_c = 0;
    for i in s.iter() {
        match i {
            'a' => count_a += 1,
            'b' => count_b += 1,
            'c' => count_c += 1,
            _ => (),
        }
    }
    if max(max(count_a, count_b), count_c) - min(min(count_a, count_b), count_c) <= 1 {
        println!("YES");
    } else {
        println!("NO");
    }
}


Measured memory_bytes: 2496
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(ll i = (ll)a;i < (ll)b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(ll i = (ll)b-1LL;i >= (ll)a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)
#define SIGN(a) (a==0?0:(a>0?1:-1))

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;
typedef long double ld;
typedef pair<ld,ld> pdd;

const ll INF=(1LL<<50);
#if __cplusplus<201700L
ll gcd(ll a, ll b) {
  if(a < b) return gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
#endif
template<class T>
bool chmax(T& a,const T& b){
  if(a<b){
    a=b;
    return true;
  }
  return false;
}
template<class T>
bool chmin(T& a,const T& b){
  if(a>b){
    a=b;
    return true;
  }
  return false;
}
template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}


void solve(long long X, long long Y, long long A, long long B, long long C, std::vector<long long> p, std::vector<long long> q, std::vector<long long> r){
  vector<pll> apple;
  sort(p.begin(),p.end(),greater<ll>());
  sort(q.begin(),q.end(),greater<ll>());
  REP(X){
    apple.push_back(pll(p[i],0));
  }
  REP(Y){
    apple.push_back(pll(q[i],1));
  }
  sort(apple.begin(),apple.end());
  sort(r.begin(),r.end());
  ll idxr=r.size()-1,idxa=0;
  while((idxr>=0&&idxa<apple.size())&&r[idxr]>apple[idxa].first){
    apple[idxa]=pll(r[idxr],2);
    --idxr;++idxa;
  }
  ll ans=0;
  dump(apple);
  for (auto &&i : apple)
  {
    ans+=i.first;
  }
  cout<<ans<<endl;
}

int main(){
  cout<<setprecision(1000);
    long long X;
    scanf("%lld",&X);
    long long Y;
    scanf("%lld",&Y);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    std::vector<long long> p(A);
    for(int i = 0 ; i < A ; i++){
        scanf("%lld",&p[i]);
    }
    std::vector<long long> q(B);
    for(int i = 0 ; i < B ; i++){
        scanf("%lld",&q[i]);
    }
    std::vector<long long> r(C);
    for(int i = 0 ; i < C ; i++){
        scanf("%lld",&r[i]);
    }
    solve(X, Y, A, B, C, std::move(p), std::move(q), std::move(r));
    return 0;
}


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

int as[200001] = {};

int main() {
	int n;
	cin>>n;
	for(int i = 0; i < n; i++) {
		cin>>as[i+1];
	}
	vector<int> ans;
	for(int i = n; i > 0; i--) {
		if(as[i]>0) {
			ans.push_back(i);
			int b = sqrt(i);
			for(int j = 1; j <= b; j++) {
				if(i%j==0) {
					int x = i/j;
					as[x] = (as[x]+1)%2;
					if(x!=j) {
						as[j] = (as[j]+1)%2;
					}
				}
			}
		}
	}
	cout << ans.size() << endl;
	if(ans.size()>0) {
		for(int i = 0; i < ans.size()-1; i++) {
			cout << ans[i] << " ";
		}
		cout << ans[ans.size()-1] << endl;
	}
	return 0;
}


Measured memory_bytes: 2424
#include<iostream>
#define ll long long int
using namespace std;
int main()
{
	ll N, K, maxSeg = 0;
	cin>>K>>N;
	ll arr[N+1];
	for(int i=0; i<N;i++)
	{
		cin>>arr[i];
	}
	arr[N] = arr[0] + K;
	for(int i=0; i<N;i++)
	{
		maxSeg = max(maxSeg,arr[i+1]-arr[i]);
	}
	cout<<K-maxSeg<<"\n";
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
using namespace std;
 
int main() {
	int a, b;
	cin >> a >> b;
 
	if (((a + b) % 2) == 0) {
		cout << ((a + b) / 2) << endl;
	}
	else {
		cout << (((a + b) / 2) + 1) << endl;
	}
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#pragma GCC optimize "03"
using namespace std;

#define int long long int
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define rep(i,a,b) for (int i = a; i < b; ++i)
#define dbg(x) { cerr<<"> "<<#x<<": "<<x<< endl; }
#define dbg2(x,y) { cerr<<"> "<<#x<<": "<<x<<" , "<<#y<<": "<<y<<endl; }
#define dbg3(x,y,z) { cerr<<"> "<<#x<<": "<<x<<" , "<<#y<<": "<<y<<" , "<<#z<<": "<<z<<endl; }
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif

const int inf = INT_MAX;
const int MOD = 1e9 + 7;
const int N = 2e5 + 5;



signed main(){
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
    #endif  
    IOS;

    int n;
    cin >> n;
    int mx = 0;
    int a[n];
    int c = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (i == 0) continue;
        if (a[i] <= a[i-1]) c++;
        else c = 0;
        mx = max(mx, c);
    }
    cout << mx << endl;


    return 0;
}

Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    int n, a, b;

    public static void main(String args[]) {
        new Main().run();
    }

    void run() {
        FastReader sc = new FastReader();
        n = sc.nextInt();
        a = sc.nextInt();
        b = sc.nextInt();
        solve();
    }

    void solve() {
        int ans = 0;
        for (int i = 1; i <= n; i++) {
            int digitSum = digitSum(i);
            if (a <= digitSum && digitSum <= b) {
                ans += i;
            }
        }
        System.out.println(ans);
    }

    int digitSum(int m) {
        int ret = 0;
        while (m > 0) {
            ret += m % 10;
            m /= 10;
        }
        return ret;
    }

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


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

int main(){

    int n,k; cin>>n>>k;

    vector<int> h(n);

    for(int i=0; i<n; i++)cin>>h[i];

    int count = 0;

    for(int i=0; i<n; i++){
        if(h[i] >= k)count++;
    }

    cout<<count<<endl;

    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<queue>
#include<stack>
using namespace std;
using ll = long long;
int main(){
    int N;
    int a[200020];
    cin >> N;
    for(int i = 1;i <= N;i++){
        cin >> a[i];
    }
    int now = 0;
    for(int i = 1;i <= N;i++){
        if(now+1 == a[i])now++;
    }
    if(now == 0)cout << -1;
    else cout << N - now;
}

Measured memory_bytes: 1024
fun main(args: Array<String>){
	val input = readLine()!!.split(" ")
		val n = input[0].toInt()
		val k = input[1].toInt()
	if(n % 2 == 0){
		if(n/2 >= k){
			println("YES")
}
else{
			println("NO")

}
}
	else{
		if((n+1)/2 >= k){
			println("YES")
}
else{
			println("NO")

}
}
		
}


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

int main() {
  int n;
  cin >> n;
  ll ans=1;
  rep(i,n) {
    ans *= (i+1);
    if(ans>=1000000007) ans %= (1000000007);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5+5;
int a[N];
int main()
{
	int n, k; scanf("%d%d", &n, &k);
	for (int i = 1; i <= n; i++) scanf("%d", a+i);
	for (int i = k+1; i <= n; i++) {
		if (a[i] > a[i-k]) puts("Yes");
		else puts("No");
	}
	return 0;
}

Measured memory_bytes: 4544
#include <bits/stdc++.h> 
 
#define INF (1<<31) - 1 //INT_MAX/2
#define MOD 1000000007
#define PI  acos(-1)
 
using ll  = long long;
using ull = unsigned long long;
 
int main(int argc, char *argv[])
{
    int s;
    std::cin >> s;

    std::vector<int> memo;
    memo.push_back(s);
    bool flag = true;
    int ans = 0;

    while(flag) {
        if (s % 2 == 0) {
            s /= 2;
        } else {
            s = 3*s + 1;
        }

        for (int i = 0; i < memo.size(); i++) {
            if (memo[i] == s) {
                flag = false;
                ans = memo.size() + 1;
                break;
            }
        }
        memo.push_back(s);
    }

    std::cout << ans << std::endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
S = [input() for i in range(N)]

S.sort()
S_dict = {}
for key in S:
    S_dict[key] = 0

for key in S:
    S_dict[key] += 1

max_value = max(S_dict.values())

ans = []
for key in S_dict:
    if S_dict[key] == max_value:
        ans.append(key)
ans.sort()

for i in ans:
    print(i)

Measured memory_bytes: 35216
//↓template↓

#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
#define rall(n) n.rbegin(),n.rend()
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double pi = acos(-1);
const ll SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
ll fac[200005], finv[200005], inv[200005];
vector<ll>dij;
struct edge { ll to, cost; };
vector<vector<edge> >G;

ll mod_pow(ll a, ll b) {
	ll res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}

	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}


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

template<typename T>
void outp(vector<T>v) {
	for (int i = 0; i < v.size(); ++i) {
		cout << v[i];
		if (i != v.size() - 1) { cout << " "; }
	}
}

//↑template↑




int main() {
	int n, k[100005];
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> k[i];
	}
	sort(k, k + n);
	cout << k[n / 2] - k[n / 2 - 1] << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define int long long
main(){
  int a[3];
  cin>>a[0]>>a[1]>>a[2];
  if(a[0]%2&&a[1]%2&&a[2]%2){
    int ans=1e15;
    cout<<min(min(a[0]*a[1],a[0]*a[2]),a[1]*a[2])<<endl;
  }
  else cout<<0<<endl;
}

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

#define INF 100100100

int N, X[110];

void Solve()
{
  int sum = INF;
  for (int p = 1; p <= 100; ++p){
    int sumP = 0;
    for (int i = 0; i < N; ++i){
      sumP += (X[i] - p) * (X[i] - p);
    }
    if (sumP < sum) sum = sumP;
  }
  cout << sum << endl;
}

void Init()
{
  cin >> N;
  for (int i = 0; i < N; ++i)
    cin >> X[i];
}

void Clean(){}

int main(){ Init(); Solve(); Clean(); return 0; }


Measured memory_bytes: 256
import java.util.Scanner

object Main extends App{

  val sc = new Scanner(System.in)

  val a1 = sc.nextInt
  val a2 = sc.nextInt
  val a3 = sc.nextInt

  val res = if(a1 + a2 + a3 >= 22) "bust" else "win"
  println(res)

}

Measured memory_bytes: 25404
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll n;cin>>n;
    ll ans=1e18;
    for(ll i=1;i*i<=n;i++)
    {
        if(n%i==0)
        {
            ans=min(ans,i+n/i-2);
        }
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
 
#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);
 
template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T,vector<T>,greater<T>>;
 
constexpr long long MOD = (long long)1e9 + 7;
constexpr long long MOD2 = 998244353;
constexpr long long HIGHINF = (long long)1e18;
constexpr long long LOWINF = (long long)1e15;
constexpr long double PI = 3.1415926535897932384626433;
 
template <class T> vector<T> multivector(size_t N,T init){return vector<T>(N,init);}
template <class... T> auto multivector(size_t N,T... t){return vector<decltype(multivector(t...))>(N,multivector(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max(a,b);}
template <class T> void chmin(T& a, const T b){a=min(a,b);}
void YN(bool flg) {cout << (flg ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << (flg ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << (flg ? "yes" : "no") << endl;}

int main() {
	int k,q; cin >> k >> q;
	vector<ll> d(k);
	for(int i = 0; i < k; ++i) cin >> d[i];
	while(q--){
		int n,x,m; cin >> n >> x >> m;
		auto e = d;
		x %= m;
		for(int i = 0; i < k; ++i) e[i] %= m;
		ll ans = n-1,sum = x;
		for(int i = 0; i < k; ++i) {
			ll cnt = (n-1)/k + (i<((n-1)%k));
			if(!e[i]) ans -= cnt;
			sum += cnt*e[i];
		}
		ans -= sum/m;
		cout << ans << endl;
	}
    return 0;
}

Measured memory_bytes: 384
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define rep(i,a,n) for(ll i =(a);i<(n);++i)
#define urep(i,a,n) for(ll i = (a);i>=(n);--i)
#define all(x) (x).begin(),(x).end()
#define INF 1e18
const int mod = 1e9 + 7;
typedef long long ll;
using namespace std;
ll dx[4] = { 1,-1,0,0 };
ll dy[4] = { 0,0,1,-1 };
ll N,M,X,Y,A,B,C,Q;
string S,T;
ll ans;
ll x[1000000];
ll y[1000000];
ll a[1000000];
ll b[1000000];
ll c[1000000];
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	else return gcd(b, a%b);
}
struct Edge{
	ll to,cost;
};
typedef vector<vector<Edge> > AdjList;
AdjList graph;
vector<ll> dist;
bool bellman_ford(ll n,ll s){
	dist=vector<ll>(n,INF);
	dist[s]=0;
	rep(i,0,n){
		rep(v,0,n){
			rep(k,0,graph[v].size()){
				Edge e =graph[v][k];
				if(dist[v]!=INF && dist[e.to]>dist[v]+e.cost){
					dist[e.to]=dist[v]+e.cost;
					if(i==n-1)return true;
				}
			}
		}
	}
	return false;
}
bool negative[1001];
int main() {
	cin>>N>>M;
	graph =AdjList(N);
	rep(i,0,M){
		ll a,b,c;
		cin>>a>>b>>c;
		a--;b--;
		graph[a].push_back((Edge{b,-1*c}));
	}
	bellman_ford(N,0);
	rep(i,0,N){
		rep(v,0,N){
			rep(k,0,graph[v].size()){
				Edge e = graph[v][k];
				if(dist[v]==INF)continue;
				if(dist[e.to] > dist[v] + e.cost){
					dist[e.to] = dist[v] + e.cost;
					negative[e.to]=true;
				}
				if(negative[v]==true){
					negative[e.to]=true;
				}
			}
		}
	}
	if(negative[N-1]){
		cout<<"inf"<<endl;
		return 0;
	}
	cout<<-1*dist[N-1]<<endl;
	return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<map>

using namespace std;

int main(){
  	map<int,int> p;
	int n,m;
  	cin>>n>>m;
  	for(int i=0;i<n;i++){
     	int k;cin>>k;
      	for(int j=0;j<k;j++){
          	int t;cin>>t;p[t]++;
        }
    }
  	m=0;
  	for(auto i:p) if(i.second==n) m++;
  	cout<<m;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main() {
  vector<long long> x(100000, 0);
  int n;
  cin >> n;
  long long ans = 0;
  for (int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    ans += a;
    --a;
    ++x.at(a);
  }

  int q;
  cin >> q;
  for (int i = 0; i < q; ++i) {
    int b, c;
    cin >> b >> c;
    ans = ans - (x.at(b-1) * b) + (x.at(b-1) * c);
    cout << ans << endl;
    x.at(c-1) += x.at(b-1);
    x.at(b-1) = 0;
  }
  return 0;
}


Measured memory_bytes: 3868
n,m = map(int,input().split())

if n%2 != 0:
  for i in range(m):
    print(1+i,n-i)
else:
  for i in range(m):
    if (n-i)-(1+i) > n/2:
      print(1+i,n-i)
    else:
      print(1+i,n-i-1)

Measured memory_bytes: 9212
from itertools import accumulate
n = int(input())
a = [0] + list(map(int, input().split())) + [0]
cost = [abs(a[i] - a[i+1]) for i in range(n+1)]
acc = [0] + list(accumulate(cost))

for i in range(1,n+1):
    print(acc[i-1] + acc[-1] - acc[i+1] + abs(a[i-1] - a[i+1]))


Measured memory_bytes: 59756
import java.util.Scanner;

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

        int[][] A = new int[3][3];
        boolean[][] B = new boolean[3][3];
        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 3; j++) {
                A[i][j] = sc.nextInt();
                B[i][j] = false;
            }
        }

        int n = sc.nextInt();
        for (int i = 0; i < n; i++) {
            int b = sc.nextInt();

            for (int j = 0; j < 3; j++) {
                for (int j2 = 0; j2 < 3; j2++) {
                    if (!B[j][j2] && A[j][j2] == b) {
                        B[j][j2] = true;
                    }
                }
            }
        }

        boolean ans = false;
        for (int i = 0; i < 3; i++) {
            if (B[i][0] && B[i][1] && B[i][2]) {
                ans = true;
                break;
            }
            if (B[0][i] && B[1][i] && B[2][i]) {
                ans = true;
                break;
            }
        }
        if (B[0][0] && B[1][1] && B[2][2]) {
            ans = true;
        }
        if (B[0][2] && B[1][1] && B[2][0]) {
            ans = true;
        }

        if (ans) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }

        sc.close();
    }
}

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

using namespace std;

int main(){
  int N;
  long long W;
  cin >> N >> W;
  
  vector<vector<long long>> v(4, vector<long long>(1, 0));
  long long w;
  long long w_in, v_in;
  cin >> w_in >> v_in;
  w = w_in;
  v[0].push_back(v_in);
  for(int i = 1; i < N; i++){
    cin >> w_in >> v_in;
    
    v[w_in - w].push_back(v_in);
  }
  
  for(int j = 0; j <= 3; j++){
    sort((v[j].begin() + 1), v[j].end(), greater<long long>());
    for(int i = 1; i < v[j].size(); i++){
      v[j][i] += v[j][i - 1];
    }
  }
  
  long long value = 0;
  for(int i = 0; i < v[0].size(); i++){
    for(int j = 0; j < v[1].size(); j++){
      for(int k = 0; k < v[2].size(); k++){
        for(int l = 0; l < v[3].size(); l++){
          if(w * i + (w + 1) * j + (w + 2) * k + (w + 3) * l <= W){
            value = max(v[0][i] + v[1][j] + v[2][k] + v[3][l], value);
          }
        }
      }
    }
  }
  
  cout << value << endl;
  
  return 0;
}

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


int main()
{
	int i = 0;
	int x;

	while(1){
		cin >> x;
		if(x==0)
			break;
		i++;
		cout <<"Case "<<i<<": "<<x<<endl;
	}


//	while(1);

	return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>

int main(){
	int a, b;
	char str2 [100];
	
	scanf ("%d %d", &a, &b);
	scanf ("%s", str2);
	
	str2[b-1] = str2[b-1] + 32;
	
	printf("%s", str2);
	
	return 0;
}

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

struct Card{
    char suit;
    int value;
};


void BubbleSort(struct Card A[], int N){
    for(int i = 0; i < N; i++){
        for(int j = N-1; j > i; j--){
            if(A[j-1].value > A[j].value){
                Card t = A[j]; A[j] = A[j-1]; A[j-1] = t;
            }
        }
    }
}

void SelectionSort(struct Card A[], int N){
    int minj;
    for(int i = 0; i < N; i++){
        minj = i;
        for(int j = i; j < N; j++){
            if(A[j].value < A[minj].value) minj = j;
        }
        Card t = A[i]; A[i] = A[minj]; A[minj] = t;
    }
}

void print(struct Card A[], int N){
    for(int i = 0; i < N; i++){
        if(i) cout << " ";
        cout << A[i].suit << A[i].value;
    }
    cout << endl;
}

bool isStable(struct Card C1[], struct Card C2[], int N){
    for(int i = 0; i < N; i++){
        if(C1[i].suit != C2[i].suit) return false;
    }
    return true;
}


int main(){
    int n;
    Card C1[100], C2[100];
    cin >> n;
    for(int i = 0; i < n; i++) cin >> C1[i].suit >> C1[i].value;
    for(int i = 0; i < n; i++) C2[i] = C1[i];

    BubbleSort(C1,n);
    print(C1,n);
    cout << "Stable" << endl;

    SelectionSort(C2,n);
    print(C2,n);
    if(isStable(C1, C2, n)){
        cout << "Stable" << endl;
    }else{
        cout << "Not stable" << endl;
    }
    return 0;
}


Measured memory_bytes: 3124
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define VIEW(x) do {cerr << #x << ": "; for(auto i : x) cerr << i << " "; cerr << endl;} while(0)

signed main() {
  int h,w; cin >> h >> w;
  vector<vector<int>> a(h, vector<int>(w));
  rep(i,h) rep(j,w) {cin >> a[i][j]; a[i][j]%=2;}

  vector<tuple<int,int,int,int>> ans;
  queue<pair<int,int>> q;
  bool c=false;
  rep(i,h) {
    for(int j=(i%2) ? 0 : w-1; (i%2) ? (j<w) : (j>=0); (i%2) ? ++j : --j) {
      if(c) q.emplace(i,j);
      if(a[i][j]) {
        if(c) {
          c=false;
          auto p=q.front(); q.pop();
          while(q.size()) {
            ans.emplace_back(p.first,p.second, q.front().first, q.front().second);
            p = q.front(); q.pop();
          }
        }
        else {
          c=true;
          q.emplace(i,j);
        }
      }
    }
  }

  printf("%d\n", (int)ans.size());
  for(auto [i,j,k,l] : ans) printf("%d %d %d %d\n", i+1,j+1,k+1,l+1);
}


Measured memory_bytes: 6328
#include<iostream>
using namespace std;
int n;
int a[6];
int b;
int main()
{
	cin>>n;
	a[1] = n/100;
	a[2]= (n-a[1]*100) /10;
	a[3] = n - a[1]*100 - a[2]*10;
    if(a[1]==a[2]&&a[2]==a[3]&&a[1]==a[3])
    {
    	cout<<a[1]<<a[2]<<a[3];
	}
    else
    {   
        b=a[1]*100+a[1]*10+a[1];
    	if(n>=b)
    	{
    		cout<<b+111; 
		}
		else
		{
			cout<<b;
		}
	}
	return 0;
	    
		
		
} 

Measured memory_bytes: 256
from collections import Counter

N = int(input())
S = [input() for _ in range(N)]
M = int(input())
T = [input() for _ in range(M)]

A = Counter(S)
B = Counter(T)

ans = 0
for k, v in A.items():
    if k in B.keys():
        v -= B[k]
    ans = max(v, ans)
print(ans)

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define ll long long
#define mp make_pair
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pii pair<ll,ll>
#define pb push_back
#define F first
#define S second
#define mi map<ll,ll>
#define mii map<pii,ll>
const ll N=(1e7+1);//mod=998244353;
ll n,m,k;//
ll a[N],dp[N];
string s;
ll l=(1e7+2);
int main(){
	int a,b,c;cin>>a>>b>>c;
	cout<<b*(c/a)<<endl;
}
/*
2
5 2
3 6 4 7 2
5 3
3 -5 6 3 10


*/


Measured memory_bytes: 256
#include <cstdio>
#include <vector>

using namespace std;

int n, t;
struct Route
{
	int cost;
	int time;
};
Route r[110];

bool compare(const Route &a, const Route &b)
{
	return a.cost < b.cost;
}

int main()
{
	scanf("%d%d", &n, &t);
	
	for (int i = 0 ; i < n ; i++)
		scanf("%d%d", &(r[i].cost), &(r[i].time));
	
	int minCost = -1;
	for (int i = 0 ; i < n ; i++)
	{
		if (r[i].time <= t)
		{
			if ((minCost == -1) || (minCost > r[i].cost))
			{
				minCost = r[i].cost;
			}
		}
	}
	
	if (minCost == -1)
		printf("TLE\n");
	else
		printf("%d\n", minCost);
	
	return 0;
}

Measured memory_bytes: 128
H,W,N=map(int,input().split())
sr,sc=map(int,input().split())
S=input()
T=input()

ld=H-sr
lu=sr-1
lr=W-sc
ll=sc-1

for i in range(N):
  x=S[i]
  y=T[i]

  if x=='U':
    lu-=1
  elif x=='D':
    ld-=1
  elif x=='L':
    ll-=1
  elif x=='R':
    lr-=1

  # print(lu,ld,ll,lr)

  if lu<0 or ld<0 or ll<0 or lr<0:
    print('NO')
    exit()

  if y=='U' and ld<H-1:
    ld+=1
  elif y=='D' and lu<H-1:
    lu+=1
  elif y=='L' and lr<W-1:
    lr+=1
  elif y=='R' and ll<W-1:
    ll+=1

  # print(lu,ld,ll,lr)

print('YES')

Measured memory_bytes: 46428
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)

using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());


int r, g, b;

int main(){
	//IO("input.txt", "output.txt");
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> r >> g >> b;
	int num = r * 100 + g * 10 + b;
	cout << ((num % 4 == 0) ? "YES\n" : "NO\n");
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast,inline,unroll-loops,fast-math")
#include <iostream>
#include <algorithm>
#include <cstdio>
#define N 100
using namespace std;

int n, m, q;
int a[N], b[N], c[N], d[N];
int v[N];

int DFS(int x, int s)
{
    int i, o;

    if(x == n + 1)
    {
        for(i = 1, o = 0; i <= q; i ++)
            if(v[b[i]] - v[a[i]] == c[i])
                o += d[i];

        return o;
    }

    for(i = s, o = 0; i <= m; i ++)
    {
        v[x] = i;
        o = max(o, DFS(x + 1, i));
    }

    return o;
}

int main(void)
{
    int i;

    cin >> n >> m >> q;
    for(i = 1; i <= q; i ++)
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    cout << DFS(1, 1) << endl;

    return 0;
}


Measured memory_bytes: 3636
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};

int main(void){
    string S;
    cin >> S;
    int L=S.size();
    if(L%2==1){
        cout << "No" << endl;
    }
    else{
        bool ans=true;
        for(int i=0;i<L;i+=2) if(S[i]!='h' || S[i+1]!='i') ans=false;
        if(ans) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}

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

ll N;
double x[8],y[8];
vector<int> v = {0,1,2,3,4,5,6,7};
double ans =0;
double fact=1;

int main(void){
    cin >> N;
    rep(i,N)cin >> x[i] >> y[i];
    
    rep(i,N)fact*=1.0*(i+1);
    
    do{
        rep(i,N-1){
            ans += sqrt( (x[v[i]] - x[v[i+1]])*(x[v[i]] - x[v[i+1]]) + (y[v[i]] - y[v[i+1]])*(y[v[i]] - y[v[i+1]]));
        }
        
    }while(next_permutation(v.begin(),v.begin()+N)); 
    ans = 1.0*ans/fact;
    cout << fixed << setprecision(8);
    cout << ans << endl;
}




Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
const int64_t INF=9999999999999999;

int main() {
 int H,W;
 vector<vector<char>>C(200,vector<char>(200));
 vector<vector<char>>K(400,vector<char>(400));
   cin>>H>>W;
   for(int i=1;i<=H;i++){
      for(int j=1;j<=W;j++){
         cin>>C[i][j];
      }
   }
   for(int i=1;i<=2*H;i++){
      for(int j=1;j<=W;j++){
         K[i][j]=C[(i+1)/2][j];
      }
   }
   for(int i=1;i<=2*H;i++){
      for(int j=1;j<=W;j++){
         cout<<K[i][j];
      }
      if(i<=2*H-1){cout<<endl;}
   }
return 0;}

Measured memory_bytes: 512
fn main() {
    let mut input = read_line_as_vector::<i32>().into_iter();
    let n = input.next().unwrap();
    let k = input.next().unwrap();
    let heights: Vec<i32> = read_line_as_vector();

    let ans = heights.iter().filter(|x| *x >= &k).count();
    println!("{}", ans);
}

fn read_line_as_vector<T: std::str::FromStr>() -> Vec<T> {
    let mut input = String::new();
    let res = std::io::stdin().read_line(&mut input);
    if let Err(error) = res {
        panic!("io error at stdin.read_line: {}", error);
    };
    match input.trim().split_whitespace().map(|x| x.parse()).collect::<Result<Vec<T>, _>>() {
        Ok(vec) => vec,
        _ => panic!("error while parsing input: {}", input)
    }
}

Measured memory_bytes: 2808
#include<stdio.h>
#include<algorithm>
using namespace std;
int main()
{
    int a[3],sum,i;
    for(i=0;i<3;i++)
        scanf("%d",&a[i]);
    sort(a,a+3);
    sum=a[1]+a[0];
    printf("%d\n",sum);
    return 0;
}


Measured memory_bytes: 128
// -*- coding:utf-8-unix -*-

use proconio::input;


// NOT WORK
// 非公式は順列で出るでなくてまともな解説くれ

fn main() {
    input! {
        s: String,
    }

    if s == "zyxwvutsrqponmlkjihgfedcba" {
        println!("-1");
        return;
    }

    let vs: Vec<char> = s.chars().collect();
    let mut vused = vec![false; 26];
    for i in 0..vs.len() {
        vused[(vs[i] as u8 - b'a') as usize] = true;
    }

    if vused.iter().all(|&a| a) {
        let mut vrevused = [false; 26];
        vrevused[(vs[vs.len() - 1] as u8 - b'a') as usize] = true;
        for i in (0..vs.len() - 1).rev() {
            if vs[i] < vs[i + 1] {
                // changed
                for j in 0..vrevused.len() {
                    if vrevused[j] && (j as u8 + b'a') > vs[i] as u8 {
                        println!("{}{}", vs[0..i].iter().collect::<String>(), (j as u8 + b'a') as char);
                        return;
                    }
                }
            }
            vrevused[(vs[i] as u8 -b'a') as usize] = true;
        }
    } else {
        for i in 0..vused.len() {
            if !vused[i] {
                println!("{}{}", s, (b'a' + i as u8) as char);
                return;
            }
        }
    }
}


Measured memory_bytes: 2164
#include <stdio.h>
#include <string.h>
#include <math.h>
 int main(void){
    
    int N,i,s=0;
   scanf("%d",&N);
    int a[N],b[N],c[N-1];
   for(i=0;i<N;i++)
     scanf("%d",&a[i]);
   for(i=0;i<N;i++)
     scanf("%d",&b[i]);
   for(i=0;i<N-1;i++)
     scanf("%d",&c[i]);
   for(i=0;i<N;i++){
     s+=b[a[i]-1];
     if(i>0){
       if(a[i]-a[i-1]==1){
         s+=c[a[i-1]-1];
       }
     }
   }
   printf("%d",s);     
}


Measured memory_bytes: 128
N=int(input())
A=[]
for i in range(N):
    A.append(int(input()))
B=sorted(A)
ans=0
tmp=B[0]
cnt=1
for i in range(1,N):
    if(tmp==B[i]):
        cnt+=1
    else:
        ans+=(cnt%2)
        cnt=1
        tmp=B[i]
ans+=cnt%2
print(ans)

Measured memory_bytes: 8276
l = int(input())


if (l<1 or l > 1000):
  quit()

length = (l/3)
l = l - length
#print ("length", length)

breadth = (l/2)
#print ("breadth", breadth)
l = l - breadth

height = l
#print("height", height)

maxVolume = length*breadth*height

result = float(l*l*l)
print (maxVolume)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  if(a <= 8 && b <= 8){
    cout<<"Yay!"<<'\n';
  }
  else{
    cout<<":("<<'\n';
  }
  return 0;
}
  


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

typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=2003;

int main(){
        
    int N,M;cin>>N>>M;
    int A[N+1][M+1],now[N+1];//now[i]はiは何番目にいるかをみてる
    bool B[M+1];//B[i]=1ならまだiは使える
    for(int i=0;i<N+1;i++){
        for(int j=0;j<M+1;j++){
            if(i&&j) cin>>A[i][j];
            else A[i][j]=-1;
            B[j]=1;
        }
        now[i]=1;
    }
    
    int ans=N;
    
    for(int j=0;j<M;j++){
        vector<int> cnt(M+1);
        for(int i=0;i<=M;i++){
            cnt[i]=0;
        }
        for(int i=1;i<=N;i++){
            while(B[A[i][now[i]]]==0){
                now[i]++;
            }
            cnt[A[i][now[i]]]++;
        }
        int Q=0,p=0;
        for(int i=1;i<=M;i++){
            if(cnt[i]>Q){
                Q=cnt[i];
                p=i;
            }
        }
        ans=min(ans,Q);
        B[p]=0;
    }
    /*for(int i=0;i<=N;i++){
        if(B[i]) cout<<i<<endl;
    }*/
    cout<<ans<<endl;
}



Measured memory_bytes: 640
#include<stdio.h>
int main()
{
int i,n,c[100],r=0;
for(i=0;i<100;i++)c[i]=0;
while(scanf("%d",&n)!=EOF)
{
	c[n-1]++;
	if(c[n-1]>c[r])r=n-1;
}
for(i=0;i<100;i++)
if(c[r]==c[i])printf("%d\n",i+1);
return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  string S;
  cin >> N >> S;
  string x;
  string y;
   
  for(int i=0;i<N/2;i++)
    x += S.at(i);

  for(int i=N/2;i<N;i++)
    y += S.at(i);
  
  if(x==y && N%2==0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

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

using namespace std;

struct DATA{
  int x;
  int y;
};

vector<int> ScanData(int);
int CalcurateSum(vector<int>);
bool Compare(const DATA&, const DATA&);

int main(){
  int i, j, n, m;
  int sum_n1, sum_n2, sum_m1, sum_m2;
  vector<int> data1, data2;
  DATA equal;
  vector<DATA> equals;

  while(1){
    cin >> n >> m;
    if(n == 0 && m == 0) break;

    data1 = ScanData(n);
    data2 = ScanData(m);
    sum_n1 = CalcurateSum(data1);
    sum_m1 = CalcurateSum(data2);

    for(i=0; i<n; ++i){
      for(j=0; j<m; ++j){
        sum_n2 = sum_n1 - data1[i] + data2[j];
        sum_m2 = sum_m1 + data1[i] - data2[j];

        if(sum_n2 == sum_m2){
          equal.x = data1[i];
          equal.y = data2[j];
          equals.push_back(equal);
        }
      }
    }

    if(equals.size() >= 2)
      sort(equals.begin(), equals.end(), Compare);

    if(equals.size() == 0)
      cout << "-1" << endl;
    else
      cout << equals[0].x << " " << equals[0].y << endl;

    data1.clear();
    data2.clear();
    equals.clear();
  }

  return 0;
}

vector<int> ScanData(int n){
  int i, s;
  vector<int> data;

  for(i=0; i<n; ++i){
    cin >> s;
    data.push_back(s);
  }
  return data;
}

int CalcurateSum(vector<int> data){
  int i, sum=0;

  for(i=0; i<data.size(); ++i)
    sum += data[i];
  return sum;
}


bool Compare(const DATA& a, const DATA& b){
  return (a.x+a.y < b.x+b.y);
}

Measured memory_bytes: 0
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <utility>
using namespace std;

#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define RFOR(i, a, b) for (int i = a; i > b; --i)
#define REP(i, n) for (int i = 0; i < n; ++i)

typedef long long ll;

const int kMaxN = 2000;
const int kMaxA = 2000;

int N;
int A[kMaxN+1];
int ans = 0;

int sum = 0;

int main() {
  cin >> N;
  REP(i, N) { cin >> A[i+1]; }

  REP(i, N) { sum += A[i+1]; }
  bitset<kMaxN*kMaxA+1> bs;
  bs[0] = true;
  REP(i, N) {
    bitset<kMaxN*kMaxA+1> bs2 = bs << A[i+1];
    bs = bs | bs2;
  }

  if (sum%2 == 0) {
    ans = sum/2;
  } else {
    ans = sum/2 + 1;
  }
  while (!bs[ans]) { ++ans; }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2176
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
	char c=getchar();bool f=0;x=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return x;
}
template<class t,class ...A> inline void read(t &x,A &...a){
	read(x);read(a...);
}
template<class t> inline void write(t x){
	if(x<0) putchar('-'),write(-x);
	else{if(x>9) write(x/10);putchar('0'+x%10);}
}

char s[1000];
int cnt;

signed main(){
	scanf("%s",s);
	for(int i=0;s[i];i++) cnt+=s[i]=='x';
	puts(cnt<=7?"YES":"NO");
}

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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        for(;;) {
            int n=sc.nextInt();
            if(n==0) {
                break;
            }
            int[] l=new int[n];
            int t=0;
            char[] c=sc.next().toCharArray();
            for(int i=0;i<100;i++) {
               if(c[i]=='S') {
                   t+=l[i%n]+1;
                   l[i%n]=0;
               }else if(c[i]=='L') {
                   l[i%n]+=t+1;
                   t=0;
               }else {
                   l[i%n]++;
               }
            } 
            Arrays.sort(l);
            for(int i=0;i<n;i++) {
                System.out.print(l[i]+(i==n-1?(" "+t+"\n"):" "));
            }
        }
    }
}


Measured memory_bytes: 29204
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n;
    cin>>n;
    cout<<(n/2)+(n%2);
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*; 
 
class Main { 
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
      	int x = sc.nextInt();
      	int t = sc.nextInt();
      	PrintWriter out = new PrintWriter(System.out);
        out.println(Math.max(x - t, 0));
      	out.flush();
    }
}

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;}
    private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
    public boolean hasNext() { skipUnprintable(); return hasNextByte();}

    public int nextInt() {
        if (!hasNext()) throw new NoSuchElementException();
        int 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();
        }
    }
}


Measured memory_bytes: 21204
#include <algorithm>
#include <iostream>
#include <cstring>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair <ll, ll> pii;

const ll MAX_N = 1e9 + 21;
string s;
int cnt[30];

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> s;
	for (int i = 0; i < 3; i++)
		cnt[s[i] - 'a']++;
	
	cout << (cnt[0] && cnt[1] && cnt[2]? "Yes": "No");
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<functional>
#include<set>


#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define LOWER(a,x) lower_bound(ALL(a), x) - a.begin() - 1;
#define COUNT(a,x)  upper_bound(ALL(a), x) - lower_bound(ALL(a), x);
#define MCOUNT(a,x,y) upper_bound(ALL(a), y) - lower_bound(ALL(a), x);
#define scan(x) scanf("%lld",&x);
#define inf 5555555555555555555
#define mod 1000000007
#define pi 3.14159265358979323846
#define pb push_back
#define F first
#define S second
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef map<ll, ll> MAP;
typedef set<ll> SET;
ll n = 0, m = 0, ans = 0, sum = 0, cnt = 0, tmp = 0, ma = 0, mi = 0;
string s;
bool flag, ok;
ll dx[4] = { 1,-1,0,0 }, dy[4] = { 0,0,1,-1 };
ll ddx[9] = { 1,-1,0,0,1,1,-1,-1,0 }, ddy[9] = { 0,0,1,-1,1,-1,1,-1,0 };
#pragma endregion
#define MAX 111111

ll a[MAX*2];
int main(void) {
  cin >> n;
  FOR(i, 1, MAX*2) {
	a[i] = a[i - 1] + i;
	if (a[i] >= n) {
	  ans = i;
	  break;
	}
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define fi first
#define se second
#define all(x) (x).begin() , (x).end()
#define rall(x) (x).rbegin() , (x).rend()
#define pb push_back
typedef long long ll;
typedef long double ld;
using namespace std;
const int N = 2e5 , inf = 1e9;
int dp[N][2];
int pred[N][2];
signed main(){
    string t;cin >> t;
    for(int i = 0 ; i < N; ++i)
        dp[i][0] = dp[i][1] = -inf;
    if(t[0] == '?')
        dp[0][0] = 0 , dp[0][1] = 0;
    else if(t[0] == 'P')
        dp[0][0] = 0;
    else
        dp[0][1] = 0;
    for(int i = 1;  i < t.size(); ++i){
        if(t[i] == '?'){
             if(dp[i-1][0] + 1 > dp[i-1][1]){
                pred[i][1] = 0;
            }else
                pred[i][1] = 1;

            if(dp[i-1][0] > dp[i-1][1])
                pred[i][0] = 0;
            else pred[i][0] = 1;

            dp[i][0] = max(dp[i-1][0] , dp[i-1][1]) + 1;
            dp[i][1] = 1 + max(dp[i-1][0] + 1 , dp[i-1][1]);
        }else if(t[i] == 'P'){
            if(dp[i-1][0] > dp[i-1][1])
                pred[i][0] = 0;
            else pred[i][0] = 1;
            dp[i][0] = max(dp[i-1][0] , dp[i-1][1]);
        }else{
            if(dp[i-1][0] + 1 > dp[i-1][1]){
                pred[i][1] = 0;
            }else
                pred[i][1] = 1;
            dp[i][1] = 1 + max(dp[i-1][0] + 1 , dp[i-1][1]);
        }
    }
    int lst;
    if(dp[t.size()-1][0] > dp[t.size()-1][1]){
        lst = 0;
    }else lst = 1;
    int ind = t.size() - 1;
    vector < int > ans;
    while(ind >= 0){
        ans.pb(lst);
        lst = pred[ind][lst];
        ind--;
    }
    reverse(all(ans));
    for(int i = 0 ; i < ans.size(); ++i)
        if(ans[i] == 0)
            cout << 'P';
        else cout << 'D';
    return 0;
}


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

#define TRACE(x) x
#define WATCH(x) TRACE(cout << #x" = " << x << endl)
#define WATCHR(a, b) TRACE(for (auto it=a; it!=b;) cout << *(it++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})

#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<string> vs;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

    int n, t;
    cin >> n >> t;
    vi p(n);
    for (int i = 0; i < n; i++){
        cin >> p[i];
    }

    ll ans = 0;
    int s = p[0];
    for (int i = 1; i < n; i++){
        if (p[i] < s + t){
            ans += p[i] - s;
        } else {
            ans += t;
        }
        s = p[i];
    }
    cout << ans + t << endl;


    return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
    public static void main(String[]args){
        Scanner in =new Scanner(System.in);
        int T=in.nextInt();
        int count=0;
        int[] arr=new int[T];
        for(int i=0;i<T;i++){
            arr[i]=in.nextInt();
        }
        for(int i=0;i<T;i++){
            if(arr[i]!=i+1)
                count++;
        }
        if(count==0 || count==2)
            System.out.println("YES");
        else
            System.out.println("NO");
    }
}

Measured memory_bytes: 27004