akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace C
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var n = int.Parse(Console.ReadLine());
            var max = 0;
            var second = 0;
            var ai = new int[n];
            for (var i = 0; i < n; i++)
            {
                var a = int.Parse(Console.ReadLine());
                ai[i] = a;
                if (max <= a)
                {
                    second = max;
                    max = a;
                }
                else if (second <= a)
                {
                    second = a;
                }
            }
            for (var i = 0; i < ai.Length; i++)
            {
                if (ai[i] == max) Console.WriteLine(second);
                else Console.WriteLine(max);
            }
        }
    }
}


Measured memory_bytes: 17108
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5+5;
ll a[N], b[N], suma[N], sumb[N];
int main()
{
	int n,m,k;cin>>n>>m>>k;
	for (int i = 1; i <= n; i++) {
		scanf("%lld", a+i);
		suma[i] = suma[i-1] + a[i];
	}
	for (int i = 1; i <= m; i++) {
		scanf("%lld", b+i);
		sumb[i] = sumb[i-1] + b[i];
	}
	int ans = 0;
	ll sum = 0;
	for (int i = 0; i <= n; i++) {
		if (k < suma[i]) break;
		auto it = upper_bound(sumb+1, sumb+1+m, k-suma[i]);
		it--; int t = it-sumb;
		if (it != sumb+1+m) ans = max(ans, i+t);
		else break;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 9900
#include <cmath>
#include <iostream>
#include <limits>

auto get_digit_num(uint64_t num) -> int
{
    int result = 0;
    while(true)
    {
        uint64_t tmp = num / 10;
        if(tmp == 0 && num % 10 == 0)
        {
            /* std::cout << num << " " << result << std::endl; */
            return result;
        }
        else
        {
            result++;
            num = tmp;
        }
    }
}

int main(int argc, char const* argv[])
{
    uint64_t n;
    std::cin >> n;

    auto result = std::numeric_limits<uint64_t>::max();
    for (uint64_t i = 1; i <= std::sqrt(n); ++i) {
        if((n % i) != 0)
        {
            continue;
        }
        uint64_t a = i;
        uint64_t b = n / a;

        uint64_t dig_a = get_digit_num(a);
        uint64_t dig_b = get_digit_num(b);

        uint64_t tmp = std::max(dig_a, dig_b);
        result = std::min(tmp, result);
    }
    std::cout << result << std::endl;
}

Measured memory_bytes: 256
#include<stdio.h>
main(){
  int a,b,c,N,i;
  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%d %d %d",&a,&b,&c);
    if(c>=a &&c>=b){
    if(c*c==a*a+b*b){
      printf("YES\n");
    }
    else{
      printf("NO\n");
    }
    }
    else if(b>=a && b>=c){
      if(b*b==a*a+c*c){
	printf("YES\n");
      }
      else{
	printf("NO\n");
      }
    }
    else if(a>=b && a>=c){
      if(a*a==b*b+c*c){
	printf("YES\n");
      }
      else{
	printf("NO\n");
      }
    }
  }
  return 0;
}

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

using Int = long long;

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

int main() {

	Int N, W;
	std::cin >> N >> W;

	std::vector<Int> weight(2 * N);
	std::vector<Int> value(2 * N);
	for (Int i = 0; i < N; i++)std::cin >> weight[i] >> value[i];

	std::vector<std::vector<Int>> dp(2*N,std::vector<Int>(W+1));

	for (Int i = 0; i < N; i++) {
		for (Int sum_w = 0; sum_w <= W; sum_w++) {


			if (sum_w - weight[i] >= 0) {
				chmax(dp[i + 1][sum_w], dp[i][sum_w - weight[i]] + value[i]);

			}
			chmax(dp[i + 1][sum_w], dp[i][sum_w]);

		}

	}

	std::cout << dp[N][W] << std::endl;
}

Measured memory_bytes: 157824
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(int i=(n);i<(m);i++)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) for(int i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<ll,ll>;
using PP=pair<ll,P>;
using vp=vector<P>;
using vpp=vector<PP>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
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;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
ll gcd(ll a,ll b){
    return b==0?a:gcd(b,a%b);
}
ll lcm(ll a,ll b){
    return a/gcd(a,b)*b;
}
int main(){
    int n;
    cin>>n;
    cout<<lcm(n,2)<<endl;
    return 0;
}


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

using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr ll mod = static_cast<ll>(1e9 + 7);
template<long long Mod = mod>
constexpr long long MOD(long long in) {
    return in % Mod;
}
template<class T>
constexpr T UP(T left, T div) {
    return (left + div - 1) / div;
}

constexpr int size = 'z' - 'a' + 1;
std::string a;
int strs[size];
int main()
{
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);

    std::cin >> a;

    int n = (int)a.size();
    for (int i = 0; i < n; ++i)
        ++strs[a[i] - 'a'];

    ll ans = ((ll)n) * (n - 1) / 2 + 1;
    for (int i = 0; i < size; ++i)
        ans -= ((ll)strs[i]) * (strs[i] - 1) / 2;

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


Measured memory_bytes: 720
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define inf 10e17
#define rep(i,n) for(long long i=0; i<n; i++)
#define repr(i,n,m) for(long long i=m; i<n; i++)
#define mod 1000000007
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto&& itr : x) { cerr << (itr) << " "; }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

int main() {
  string s,t;
  cin >> s >> t;
  int a,b;
  cin >> a >> b;
  string u;
  cin >> u;

  if (u == s) {
    cout << a-1 << " " << b << endl;
  } else {
    cout << a << " " << b-1 << endl;
  };
}

Measured memory_bytes: 256
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*
cout<<fixed<<setprecision(20);
cin.tie(0);
ios::sync_with_stdio(false);
*/
const llint mod=1000000007;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	int n;cin>>n;
	set<string>s;
	while(n--){
		string qu,st;cin>>qu>>st;
		if(qu=="insert"){s.ins(st);}
		else{
			if(s.count(st)){cout<<"yes"<<endl;}
			else{cout<<"no"<<endl;}
		}
	}
	return 0;
}



Measured memory_bytes: 32144
// #pragma comment(linker, "/stack:200000000")
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")

#include <bits/stdc++.h>  
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define pl pair<ll,ll>
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define vl vector<ll>
#define N 100005
#define mod 1000000007


int main()
{   
    ll n;cin>>n;
    vector<ll>v;
    for(ll i=1;i<=sqrt(n);i++)
    {
        if(n%i==0)
        {
            if(i!=n/i)
            {
                v.pb(i);
                v.pb(n/i);
            }
            else
            v.pb(i);
        }
    }
    ll ans=0;
    for(ll i=0;i<v.size();i++)
    {
        if(v[i]!=1 && (n/v[i])==n/(v[i]-1))
        {
            ans+=v[i]-1;
        }
    }
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 3704
h, w = map(int, input().split())
A = [list(input()) for i in range(h)]
A1 = [a for a in A if "#" in a]
A2 = [a for a in zip(*A1) if "#" in a]
A3 = [a for a in zip(*A2)]
for a in A3:
  print("".join(a))

Measured memory_bytes: 3316
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;n>i;++i)
using namespace std;
using ll=int64_t;
using vi=vector<int>;
using VI=vector<ll>;
using vis=vector<string>;
using vvi=vector<vi>;
int gcd(int a,int b){
    if(a%b==0)
    return b;
    return gcd(b,a%b);
}
int main(){
    int n,c;
    cin>>n;
    set<int> a;
    rep(i,n){
        cin>>c;
        a.insert(c);
    }
    cout<<a.size()<<endl;
}


Measured memory_bytes: 3612
#include "bits/stdc++.h"
using namespace std;

#define ll long long int
#define str string
#define ALL(a)  (a).begin(),(a).end()
#define P pair<ll,ll>

using Graph = vector<vector<int>>;

const int dy[] = { 0, 0, 1, -1 }, dx[] = { 1, -1, 0, 0 };
ll INFL = 1ll << 60, INF = 1 << 30, mod = 1e9 + 7, Min = INFL, Max = -1;
ll a, b, c, n, sum, A[500010], B[500000], rui[500000], dp[5000];
str S; bool check = true;	vector<ll> v;



int main() {
	//Code Line
cin >> n;
for(int i = 0;i < n;i++){
cin >> A[i];

if(A[i]%2 == 0){

if(A[i] % 3 == 0 || A[i] % 5 == 0);
else  check = false;

}

}

if(check)cout << "APPROVED" << endl;
else cout << "DENIED" << endl;

	return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define mod 1000000007LL
#define IN freopen("C.in","r",stdin)
#define OUT freopen("output.txt","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG pf("Hi\n")
#define INF 1000000000
#define i64 long long int
#define eps (1e-8)
#define xx first
#define yy second
#define ln 17
#define off 8002

using namespace __gnu_pbds;
using namespace std ;

typedef tree< i64, null_type, less<i64>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef pair<i64, i64> pii;

#define maxn 8005
const int N = 16005 ;

bitset<N> dp ;

bool f( vector <int> moves , int x )
{
  //  printf("--- %d\n",x) ;
    for(int i=0 ; i<N ; i++) dp[i] = 0 ;
    dp[0+off] = 1 ;

    for(int i=0 ; i<moves.size() ; i++)
    {
        dp = (dp<<moves[i])|(dp>>moves[i]) ;
    }
  /*  for(int i=0 ; i<N ; i++)
    {
        if( dp[i] ) printf("%d ",i-off) ;
    }
    printf("\n") ; */
    if( off+x < 0 ||  x+off >= N ) return false ;
    return dp[off+x] ;
}

int main()
{
    char s[maxn] ;
    int n , x , y ;

    scanf("%s %d %d",s,&x,&y) ;

    vector <int> v[2] ;

    n = strlen(s) ;

    int i = 0 ;
    while( i<n && s[i]=='F' ) i++ ;

    x -= i ;

    for( int fl =1 ; i<n  ; i++ , fl^=1)
    {
        int l = i , r = i ;
        while( r+1 < n && s[r+1]=='F' ) r++ ;
        i = r ;
        v[fl].pb( r-l ) ;
    }


    if( f(v[0],x) && f(v[1],y) ) printf("Yes\n") ;
    else printf("No\n") ;

    return 0 ;
}


Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <array>
#include <tuple>
#include <string>
#include <algorithm>
#include <functional> // greater など
#include <cmath>      // abs など
#include <numeric>    // accumulate, gcd など
#include <cassert>    // assert
#include <stdexcept>
#include <bitset>
using namespace std;

// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
// typedef int128_t ll;
// typedef cpp_int ll;

// GCC, 配列のアクセスなど
#define _GLIBCXX_DEBUG
// Clang, 配列のアクセスなど
#define _LIBCPP_DEBUG 0

//////////////// //////////////// //////////////// //////////////// ////////////////
//////////////// //////////////// //////////////// //////////////// ////////////////

// constexpr inline ll mod = 1'000'000'007;
// constexpr int max_n = 200'000 + 5;

int main()
{
    // 高速な入出力
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << setprecision(15); // 浮動小数の表示の精度

    string s;
    cin >> s;
    int n = s.size();
    bool all = true;
    for (int i = 0; i < n; i++) {
        all &= (s[i] == s[n - 1 - i]);
    }
    for (int i = 0; i < (n - 1) / 2; i++) {
        all &= (s[i] == s[(n-1)/2 - 1 - i]);
    }
    for (int i = 0; i < (n - 1) / 2; i++) {
        all &= (s[i + (n + 1) / 2] == s[n - 1 - i]);
    }
    cout << (all ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 3600
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
/*answer*/
    int a, b, i;

    for(i = 0;i < 7;i++){
      a = sc.nextInt(); b = sc.nextInt();
      out.println(a - b);
    }

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
}

Measured memory_bytes: 17364
import java.util.Collections;
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		TreeMap<Integer, Integer> map = new TreeMap<Integer, Integer>(Collections.reverseOrder());
		for(int i = 0; i < N; i++) {
			int a = sc.nextInt();
			if(map.containsKey(a)) {
				map.put(a, map.get(a) + 1);
			}else {
				map.put(a, 1);
			}
		}
		long first = -1, second = -1;
		for(Map.Entry<Integer, Integer> elem : map.entrySet()) {
			if(elem.getValue() >= 4) {
				if(first == -1) {
					first = elem.getKey(); second = elem.getKey();
					break;
				}else if(second == -1){
					second = elem.getKey();
					break;
				}
			}else if(elem.getValue() >= 2) {
				if(first == -1) {
					first = elem.getKey();
				}else if(second == -1) {
					second = elem.getKey();
					break;
				}
			}
		}
		if(second == -1) System.out.println("0");
		else System.out.println(first * second);
	}
}

Measured memory_bytes: 60732
#include <bits/stdc++.h>
#define LLI long long int
#define FOR(v, a, b) for(LLI v = (a); v < (b); ++v)
#define FORE(v, a, b) for(LLI v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(LLI v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define popcount __builtin_popcount
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(...) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

struct Init{
  Init(){
    cin.tie(0);
    ios::sync_with_stdio(false);
  }
}init;

template <typename T, typename Container=vector<T>> vector<pair<T,int64_t>> run_length_encode(const Container &v){
  vector<pair<T,int64_t>> ret;

  for(auto &x : v){
    if(ret.empty()) ret.push_back({x,1});
    else if(ret.back().fst == x) ++ret.back().snd;
    else ret.push_back({x,1});
  }

  return ret;
}



int main(){
  int N;
  while(cin >> N){
    vector<LLI> A(N); cin >> A;
    REP(i,N) A[i] -= 1;

    sort(ALL(A));
    
    vector<int> count(N);

    REP(i,N){
      count[A[i]] += 1;
    }

    sort(RALL(count));
    while(count.back() == 0){
      count.pop_back();
    }

    dump(count);

    auto count2 = run_length_encode<int>(count);

    dump(count2);

    FORE(k,1,N){

      auto check =
        [&](int x){
          LLI s = 0;

          for(auto &p : count2){
            s += min(x, p.fst) * p.snd;
          }


          return s >= (LLI)x * k;
        };

      int lb = -1, ub = N/k+1;
      while(abs(lb-ub) > 1){
        int mid = (lb+ub) / 2;

        if(check(mid)){
          lb = mid;
        }else{
          ub = mid;
        }
      }

      
      cout << lb << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 4352
x=int(input())
if x>=400 and x<=599:
  print(8)
if x>=600 and x<=799:
  print(7)
if x>=800 and x<=999:
  print(6)
if x>=1000 and x<=1199:
  print(5)
if x>=1200 and x<=1399:
  print(4)
if x>=1400 and x<=1599:
  print(3)
if x>=1600 and x<=1799:
  print(2)
if x>=1800 and x<=1999:
  print(1)

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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 1e6 + 5;

int n;
int x,y,t;

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

  cin>>n;
  

  for (int i=0; i<n; i++) {
    int x0,y0,t0; cin>>t0>>x0>>y0;
    int dist = abs(x0-x)+abs(y0-y);
    if (dist > t0-t) {
      out("No");
    }
    if (dist == t0-t) continue;
    int dt = t0-t;
    if (dist%2 != dt%2) {
      out("No");
    }
    x=x0; y=y0; t=t0;
  }
  out("Yes");  

  return 0;
}


Measured memory_bytes: 256
N = long(raw_input())
A = map(int, raw_input().split())
A = [0] + A + [0]
#print str(A)

maxCost = 0

# Total
for x in range(1, len(A), 1):
    maxCost += abs(A[x -1] - A[x])

#print "maxCost : " + str(maxCost)

# remove each point
for x in range(1, len(A) - 1, 1):
    # unnecessary move
    umove1 = abs(A[x - 1] - A[x])
    umove2 = abs(A[x] - A[x + 1])
    # additional move
    amove = abs(A[x - 1] - A[x + 1])
    print maxCost - umove1 -umove2 + amove


Measured memory_bytes: 11600
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

using Graph = vector<vector<P>>;
vector<int> ans;

void dfs(const Graph &G, int v, int p, int d){
    if(d % 2 == 0)ans[v] = 0;
    else ans[v] = 1;
    for(auto nv : G[v]){
        if(nv.first != p)dfs(G, nv.first, v, d+nv.second);
    }
}

int main() {
    int n;
    cin >> n;
    ans.resize(n);
    Graph G(n);
    rep(i, n-1){
        int u, v, w;
        cin >> u >> v >> w;
        u--; v--;
        G[u].push_back(make_pair(v, w));
        G[v].push_back(make_pair(u, w));
    }
    dfs(G, 0, -1, 0);
    rep(i, n){
        cout << ans[i] << endl;
    }
}


Measured memory_bytes: 8960
#include<cstdio>
#include<cstring>

int main(){

  char s[201], t[101], p[101];

  scanf("%s %s", s, p);
  strcpy(t, s);
  strcat(s, t);

  if( strstr(s, p) == NULL ) printf("No\n");
  else printf("Yes\n");
  
  return 0;
}

Measured memory_bytes: 972
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;


int main() {
    int N,K,R,S,P;
    cin >> N >> K;
    cin >> R >> S >> P;
    string T;
    cin >> T;
    int dp[N][3]{};
    int p[N];
    int gcp[N];
    for(int i = 0; i < N; i++) {
        if(T[i] == 'r') { p[i] = P; gcp[i] = 2; }
        if(T[i] == 's') { p[i] = R; gcp[i] = 0; } 
        if(T[i] == 'p') { p[i] = S; gcp[i] = 1; } 
    }
    for(int i = 0; i < K; i++) {
        dp[i][gcp[i]] = p[i];
        for(int j = i + K; j < N; j += K) {
            for(int k = 0; k < 3; k++) {
                if(gcp[j] == k) dp[j][k] = max(dp[j - K][(k + 1) % 3], dp[j - K][(k + 2) % 3]) + p[j];
                else dp[j][k] = max(dp[j - K][(k + 1) % 3], dp[j - K][(k + 2) % 3]);
            }
        }
    }
    int ans = 0;
   for(int i = 1; i <= K; i++) {
       ans += max(max(dp[N - i][0], dp[N - i][1]), dp[N - i][2]);
   }

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

Measured memory_bytes: 2432
#include<stdio.h>

int main()
{
	int total_sec, hh, mm, ss;

    scanf("%d", &total_sec);

	
	ss = total_sec % 60;
	hh = total_sec / 3600;
	mm = (total_sec % 3600) / 60; 

    printf("%d:%d:%d\n", hh, mm, ss);
	return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,k,q,j,m,i;
    cin>>n>>k>>q;
    ll a[n];
    ll b[n]={0};
    std::fill_n(a, n, k);
    for( i=0;i<q;i++){
        cin>>j;
        k--;
        b[j-1]++;
        
        
        
        
    }
    std::fill_n(a, n, k);
    for(i=0;i<n;i++){
        a[i]=a[i]+b[i];
        if(a[i]<=0){
            cout<<"No\n";
        }
        else
        cout<<"Yes\n";
    }
    
 
  return 0;
    
}

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

int main(void){
    string s;
    cin >> s;
    int ans = 0;
    for(int i=0; i<s.length(); i++){
        if(s[i] == '1'){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
	int n, p;
	cin >> n;
	vector<pair<pair<string, int>, int>> sp(n);
	for (int i = 0; i < n; ++i) {
		cin >> sp[i].first.first >> p;
		sp[i].first.second = -p;
		sp[i].second = i + 1;
	}
	sort(sp.begin(), sp.end());
	for (int i = 0; i < n; ++i) cout << sp[i].second << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int N,r=0,b=0;
  char s[108]={'\0'};
  scanf("%d",&N);
  scanf("%s",s);
  for(int i=0;i<N;i++){
    if(s[i]=='R'){
      r++;
    }else{
      b++;
    }
  }
  if(r>b){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
  return 0;
}

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

struct Info {
  int M, D, t, e, p;  
};

signed main() {
  int n;
  while ( cin >> n, n ) {
    vector<int> sum(1000, 0);
    int cnt = 0;
    vector<Info> dat;    
    while ( n-- ) {      
      int M, D, h, m, p;
      char e;
      scanf("%d/%d %d:%d %c %d", &M, &D, &h, &m, &e, &p);
      if ( e == 'I' ) {
	dat.emplace_back(Info{M, D, h*60+m, 0, p});
	cnt++;
      } else {
	dat.emplace_back(Info{M, D, h*60+m, 1, p});
	cnt--;
      }

      if ( cnt ) continue;
      vector<int> zero(1500, 0);
      vector<int> I(1000, 0);      
      for ( Info i : dat ) {
	if ( i.p != 0 ) continue;
	if ( i.e == 0 ) {
	  I[i.p] = i.t;	  
	} else {
	  for ( int j = I[i.p]; j < i.t; j++ ) {
	    zero[j]++;	    
	  }
	}
      }

      for ( Info i : dat ) {
	if ( i.p == 0 ) continue;
	if ( i.e == 0 ) {
	  I[i.p] = i.t;	  
	} else {
	  for ( int j = I[i.p]; j < i.t; j++ ) {
	    if ( zero[j] ) sum[i.p]++;	    
	  }
	}
      }

      dat.clear();      
    }

    int ma = 0;
    for ( int i = 0; i < 1000; i++ ) {
      ma = max(ma, sum[i]);
    }

    cout << ma << endl;
  }
  return 0;
}



Measured memory_bytes: 3156
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define ep emplace_back
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){
	if(y<h && y>=0 && x<w && x>=0) return true;
	return false;
}





int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	string s;cin >> s;
	rep(i,2){
		rep(j,2){
			vector<int> a(n + 2);
			a[1] = i;
			a[2] = j;
			for(int k = 2; k < n; k++){
				if(a[k]){
					if(s[k - 1] == 'o'){
						a[k + 1] = a[k- 1];
					}
					else{
						a[k + 1] = a[k- 1] ^ 1;
					}
				}
				else{
					if(s[k - 1] == 'o'){
						a[k + 1] = a[k- 1] ^ 1;
					}
					else{
						a[k + 1] = a[k- 1];
					}
				}
			}
			bool ok = true;
			if(a[1]){
				if(s[0] == 'o'){
					if(a[n] != a[2]) ok = false;
				}
				else{
					if(a[n] == a[2]) ok = false;
				}
			}
			else{
				if(s[0] == 'o'){
					if(a[n] == a[2]) ok = false;
				}
				else{
					if(a[n] != a[2]) ok = false;
				}
			}
			if(a[n]){
				if(s[n - 1] == 'o'){
					if(a[1] != a[n - 1]) ok = false;
				}
				else{
					if(a[1] == a[n - 1]) ok = false;
				}
			}
			else{
				if(s[n - 1] == 'o'){
					if(a[1] == a[n - 1]) ok = false;
				}
				else{
					if(a[1] != a[n - 1]) ok = false;
				}
			}
			if(ok){
				for(int k = 1; k <= n; k++){
					if(a[k]) cout << "S";
					else cout << "W";
				}
				cout << endl;
				return 0;
			}
		}
	}
	cout << -1 << endl;
}


Measured memory_bytes: 976
import java.util.*; 

class Main{
public static void main(String[] args){
	Scanner sc=new Scanner(System.in);
        int h=sc.nextInt();
        int w=sc.nextInt();
		int k=sc.nextInt();
		int ans=0;

  		String[][] a=new String[h][w];
		for(int c=0;c<h;c++){
          String s=sc.next();
		a[c]=s.split("");
    		
    	}
    
 	for(int f=0;f<(1<<h);f++){
    	for(int g=0;g<(1<<w);g++){
        	int count=0;
          	for(int d=0;d<h;d++){
            if((1&f>>d)==1){
              for(int e=0;e<w;e++){
              if((1&g>>e)==1&&a[d][e].equals("#")){
              count++;
              }
              }
     }
            }
          if(count==k){
          ans++;
          }
        }
    }

    	System.out.println(ans);
    }
}


Measured memory_bytes: 35496
# -*- coding: utf-8 -*-

from collections import Counter 

cnt = int(input())
input_list = [int(i) for i in input().split()]

# 各数値ごとに数を集計(Counterオブジェクトで集計処理を簡略化)
num_dict = Counter(input_list)

ans = 0
# 数値(key)と個数(value)の大小によって処理を分ける
for key, value in num_dict.items():
    # valueのが大きければkeyとvalueを揃える
    if key < value:
        ans += value - key
    # 元々揃っていれば何もしない
    elif key == value:
        continue
    # keyのが大きければその値を取り除く
    elif key > value:
        ans += value
print(ans)

Measured memory_bytes: 18672
#include <iostream>
#include <string>
using namespace std;
int main(void){
    string a,b,c;
    int m,h;
    while(true){
        cin >> a;
        if(a == "-"){
            break;
        } else {
            cin >> m;
            for(int i = 1; i <= m; i++){
                cin >> h;
                b = "";
                c = "";
                for(int j = 0; j < h; j++){
                    b += a[j];
                }
                for(int j = h; j < a.length(); j++){
                    c += a[j];
                }
                a = c + b;
            }
            cout << a << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 3196
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

    ll n;
    cin >> n;
    string s;
    cin >> s;

    ll b = 0, w = 0;
    REP(i, n){
        if(s[i] == '#') b++;
        else w++;
    }

    ll res = min(b, w), tmp, leftb = 0, rightw = w;
    REP(i, n){
        if(s[i] == '.'){
            rightw--;
        }
        else{
            leftb++;
        }
        tmp = rightw + leftb;
        res = min(res, tmp);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 720
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int A, B, C, X, Y;
	cin >> A >> B >> C >> X >> Y;
	if (A + B < C * 2) {
		cout << A*X + B*Y << endl;
	}
	else {
		if (A > C * 2) {
			A = C * 2;
		}
		if (B > C * 2) {
			B = C * 2;
		}
		if (X < Y) {
			cout << C * 2 * X + (Y - X)*B << endl;
		}
		else {
			cout << C * 2 * Y + (X - Y)*A << endl;
		}
	}

	
}

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

using namespace std;

const int N = 2e5 + 100;

int a[N], cnt[N], tmp[N];
int n, m, ans;

void remove(int x) {
    if (x - cnt[x] < 0) {
	cnt[x]--;
	return;
    }
    tmp[x - cnt[x]]--;
    ans += !tmp[x - cnt[x]];
    cnt[x]--;
}

void add(int x) {
    cnt[x]++;
    if (x - cnt[x] >= 0) {
	ans -= !tmp[x - cnt[x]];
	tmp[x - cnt[x]]++;
    }
}

int main() {
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cin >> n >> m;
    ans = n;
    for (int i = 0; i < n; i++) {
	cin >> a[i];
	add(a[i]);
    }
    while (m--) {
	int x, y;
	cin >> x >> y;
	x--;
	remove(a[x]);
	add(y);
	a[x] = y;
	cout << ans << '\n';
    }
}

Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef map<int, int> mi;
typedef set<int> si;
#define VV(T) vector<vector< T > >
#define dump(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl

#define rep(i, n) REP(i, 0, n)                              // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++)             // x, x + 1, ..., n-1
#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(v) (v).begin() , (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

#define pb push_back
#define pu push
#define mp make_pair
#define fi first
#define sc second

#define COUT(x) cout << (x) << endl
#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECCOUT(x) for(auto&youso_: (x) )cout<<youso_<<" ";cout<<endl

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; cin >> n;
    vi v(21);
    vi c(21);
    rep(i, n) cin >> v[i];
    rep(i, n) cin >> c[i];

    int ans = 0;
    for(int bit = 0; bit < (1<<n); bit++) {
        int cost = 0;
        int value = 0;
        rep(i, n) {
            if(bit & (1<<i)) {
                value += v[i];
                cost += c[i];
            }
        }
        ans = max(ans, value - cost);
    }
    COUT(ans);
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<bitset>

using namespace std;
typedef long long ll;
#define i_7 1000000007
#define i_5 1000000005

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
ll inf=1000000000000;/*10^12*/
#define rep(i,l,r) for(ll i=l;i<=r;i++)
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}


//////////////////////////////////////

int main(){
    int n;cin>>n;
    int a[3*n];rep(i,0,3*n-1)cin>>a[i];
    priority_queue<ll,vector<ll>,greater<ll>>q;
    ll dp[2][3*n];memset(dp,0,sizeof(dp));
    ll sum=0;
    rep(i,0,n-1){
        sum+=a[i];
        q.push(a[i]);
    }
    dp[0][n-1]=sum;
    rep(i,n,2*n-1){
        sum+=a[i];
        q.push(a[i]);
        ll t=q.top();q.pop();
        sum-=t;
        dp[0][i]=sum;
    }
    sum=0;
    priority_queue<ll>p;
    for(int i=3*n-1;i>=2*n;i--){
        sum+=a[i];
        p.push(a[i]);
    }
    dp[1][2*n]=sum;
    for(int i=2*n-1;i>=n;i--){
        sum+=a[i];
        p.push(a[i]);
        ll t=p.top();p.pop();
        sum-=t;
        dp[1][i]=sum;
    }
    ll ans=dp[0][n-1]-dp[1][n];
    rep(i,n,2*n-1){
        ans=max(ans,dp[0][i]-dp[1][i+1]);
    }
    
 /*   rep(i,0,1){
        rep(j,0,3*n-1){
            cout<<dp[i][j]<<" ";
        }cout<<endl;
    }*/
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 8436
#include <iostream>
#include <vector>
#include <cassert>
#include <map>

using namespace std;

struct SegmentTree {
  SegmentTree(int n) : n_(n) {
    int twos = 1;
    while (twos < n) twos <<= 1;
    v_.resize(twos * 2 - 1);
  }
  int parent(int node) {
    assert(node > 0);
    return (node - 1) / 2;
  }
  int left(int node) {
    return node * 2 + 1;
  }
  int right(int node) {
    return node * 2 + 2;
  }
  void Increment(int pos, int val) {
    int index = v_.size() / 2 + pos;
    while (true) {
      v_[index][val]++;
      if (index == 0) {
        break;
      }
      index = (index - 1) / 2;
    }
  }
  int Count(int begin, int end, int x) {
    return doCount(begin, end, x, 0, 0, n_);
  }
  int doCount(int begin, int end, int x, int node, int node_begin, int node_end) {
    if (node_begin <= begin && end <= node_end) {
      return v_[node][x];
    }
    if (end <= node_begin || node_end <= begin) {
      return 0;
    }
    int mid = (node_begin + node_end) / 2;
    return doCount(begin, end, x, left(node), node_begin, mid) +
        doCount(begin, end, x, right(node), mid, node_end);
  }
  int n_;
  vector<map<int, int>> v_;
};

int A[2 * 100000];

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

  SegmentTree tree(N);

  for (int i = 0; i < N; ++i) {
    cin >> A[i];
    tree.Increment(i, A[i] - i);
  }

  long long count = 0;
  for (int i = 0; i < N; ++i) {
    count += tree.Count(i + 1, N, -A[i] - i);
  }
  cout << count << endl;
}

Measured memory_bytes: 212888
#include <iostream>
#include <algorithm>

using namespace std;

typedef long long int ll;

ll vsum[100010];
//ll xsum[100010];

ll cal[100010];
ll calmax[2][100010];
ll x[100010];
//ll v[100010];

int main(void) {
	int N;
	ll C;
	cin >> N >> C;
	for (int i = 1; i <= N; i++) {
		ll v;
		cin >> x[i] >> v;
		vsum[i] = vsum[i - 1] + v;
	}
	for (int i = 1; i <= N; i++) {
		calmax[0][i] = max(calmax[0][i - 1], vsum[i] - x[i]);
		calmax[1][i] = max(calmax[1][i - 1], vsum[i] - x[i] * 2);
	}
	ll ma = 0;
	for (int i = N; i > 0; i--) {
		ma = max(max(ma, vsum[N] - vsum[i - 1] - (C - x[i])), max(calmax[0][i - 1] + vsum[N] - vsum[i - 1] - (C - x[i]) * 2, calmax[1][i - 1] + vsum[N] - vsum[i - 1] - (C - x[i])));
	}
	ma = max(ma, calmax[0][N]);
	cout << ma << endl;
	//system("pause");
}

Measured memory_bytes: 3328
import java.util.*;

class Main {
    static long MOD=1000000007;
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        long n=scan.nextLong();
        int B=62;
        long[][]dp=new long[3][B];
        dp[0][B-1]=1;
        for(int i=B-2;i>=0;--i){
            for(int a=0;a<=2;++a){
                if(n>>>i<a)continue;
                long m=n>>>i;
                int b=(int)(m/2-(m-a)/2);
                int c=(int)((m-a)%2);
                if(c!=0)
                    dp[a][i]=dp[b][i+1]%MOD;
                else
                    dp[a][i]=(dp[b][i+1]+dp[b+1][i+1])%MOD;
            }
        }
        long[] r=new long[B],s=new long[B];
        r[0]=1;s[0]=0;
        for(int i=1;i<B;++i)r[i]=(3*r[i-1]+MOD-1)%MOD;
        for(int i=1;i<B;++i)s[i]=(3*s[i-1]+1)%MOD;
        long t=0;
        for(int i=B-2;i>=0;--i){
            if((n&1L<<i)!=0){
                t+=dp[1][i]*r[i]%MOD;
                t+=dp[2][i]*s[i]%MOD;
                t%=MOD;
            }
        }
        t=(t+dp[0][0])%MOD;
        System.out.println(t);
    }
}


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

int main(){
  int x,n;
  cin >>x >>n;
  vector<int> p(n);
  int num[105] = {0};
  rep(i,n) {
    cin >>p[i];
    num[p[i]]++;
  }
  for(int i = 0;; i++){
    int curans = x-i;
    if(num[curans]==0){
      cout << curans << endl;
      return 0;
    }
    curans = x+i;
    if(num[curans]==0){
      cout << curans << endl;
      return 0;
    }
  }
  return 0;
}

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

bool chmin(long long &a, long long b){
  if(a > b){
    a = b;
    return 1;
  }
  return 0;
}

int main() {
  int N;
  cin >> N;
  vector<int> h(N);
  for(int i = 0; i < N; i++) cin >> h.at(i);
  vector<long long> cost(N, 1000000000000000000);
  cost.at(0) = 0;
  
  for(int i = 1; i < N; i++){
    chmin(cost.at(i), cost.at(i-1) + abs(h.at(i) - h.at(i - 1)));
    if(i > 1) chmin(cost.at(i), cost.at(i-2) + abs(h.at(i) - h.at(i - 2)));
  }
  
  cout << cost.at(N - 1) << endl;
}

Measured memory_bytes: 1408
#include <iostream>

using namespace std;

int main() {
  
  int K,S;
  cin >> K >> S;
  int ans=0;
  for (int x = 0; x <= K; x++) {
    for (int y = 0; y <= K; y++) {
      int z = S - x - y;
      if (0 <= z and z <= K) ans++;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int a[100];
  int datanum,i,temp,j,datachange=0;
  scanf("%d",&datanum);
  for(i=0;i<datanum;i++){
    scanf("%d",&a[i]);
  }
  
  for(i=0;i<datanum;i++)
    for(j=0;j<datanum-1;j++){
      if(a[j] > a[j+1]){
	datachange++;
	temp = a[j];
	a[j] = a[j+1];
	a[j+1] = temp;
      }
    }
  for(i=0;i<datanum;i++){
    if(i == datanum-1){
      printf("%d\n",a[i]);
      break;
    }
    printf("%d ",a[i]);
  }
  printf("%d\n",datachange);
  return 0;

}



Measured memory_bytes: 2108
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Map = map<string,ll>;



int main(){
	ll A;
	cin >> A;
	ll B;
	cin >> B;

    ll ans=A+B;
    ans=max(ans,A-B);
	ans=max(ans,A*B);
	cout<<ans<<endl;
return 0;
}  



Measured memory_bytes: 256
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define reps(i,a,b) for(int i=a;i<b;++i)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

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

    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    rrep(i, n) cout << a[i] << (i == 0 ? '\n' : ' '); 
}



Measured memory_bytes: 3172
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vl;
typedef vector<int> vi;
#define pb push_back
#define en "\n"
#define forn(i,e) for(ll i=0; i<e; i++)
#define forsn(i,s,e) for(ll i=s; i<e; i++)
#define rforn(i,e) for(ll i=e; i>=0; i--)
#define rforsn(i,s,e) for(ll i=e; i>=s; i--)
#define asort(arr,n) sort(arr,arr+n)
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v) sort(v.begin(), v.end(),greater<int>())
#define ff first
#define ss second
#define aout(a) for (auto u:a) {cout<<u<<" ";}cout<<en;

 
#define out(x1) cout << x1 << en
#define out2(x1,x2) cout << x1 << " " << x2 << en
#define out3(x1,x2,x3) cout << x1 << " " << x2 << " " << x3 << en

 
#define in(x1) cin >> x1
#define in2(x1,x2) cin >> x1 >> x2
#define in3(x1,x2,x3) cin >> x1 >> x2 >> x3
 
#define arrin(a,n) forn(i,n) cin >> a[i];
#define arrout(a,n) forn(i,n) {cout << a[i] << " ";} cout << en;
 

int main(){
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("oput.txt", "w", stdout);
#endif

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


ll n,m;
in2(n,m);
ll w[n+1];
ll v[n+1];
// ll c[n];
multiset<pair<ll,ll>>s;
for (ll i = 0; i < n; i++)
{ll x,y;
	in2(x,y);
s.insert({x,y});
}
ll i=1;
for (auto u:s)
{
w[i]=u.first;
v[i]=u.second;
i++;
//cout<<u<<" ";
	
}

ll dp[n+1][m+1];
for (ll i = 0; i <= n; i++)
{dp[i][0]=0;}

for (ll i = 0; i <= m; i++)
{dp[0][i]=0;
	
}
for (ll i = 1; i <= n; i++)
{
for (ll j = 1; j <= m; j++)
{
if (j>=w[i]){
	dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i]]+v[i]);
}
else{dp[i][j]=dp[i-1][j];}

	
}

	
}
out(dp[n][m]);

// for (ll i = 0; i <= n; i++)
// {for (ll j = 0; j <=m; j++)
// {cout<<dp[i][j]<<" ";
	
// }cout<<en;
	
// }


















    return 0;
}


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

int main(){
  int n,a;
  bool win = false;
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> a;
    if((a&1) == 1){
       win = true;
       break;
    }
  }
  if(win == true){
    cout << "first" << endl;
  } else {
    cout << "second" << endl;
  }
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define timer_start()                            \
    chrono::system_clock::time_point start, end; \
    start = chrono::system_clock::now();
#define timer_wrap()                                                       \
    end = chrono::system_clock::now();                                     \
    double time = static_cast<double>(                                     \
        chrono::duration_cast<chrono::microseconds>(end - start).count() / \
        1000.0);                                                           \
    printf("%lf[ms]\n", time);                                             \
    start = end;
#define optimize_cin() \
    cin.tie(0);        \
    ios::sync_with_stdio(false)
using namespace std;
using ll = long long;
#define INF 1000000000    // 10^9
#define INFINF LLONG_MAX  // 2^63-1
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 end ##########

#ifdef DEBUG_ON
void test_all();
#endif

int N;
vector<int> L;

int binarySearchMax(int ok, int ng, int c) {
    if (L.at(ok + 1) > c) {
        return -1;
    }
    while (abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;
        if (L.at(mid) <= c) {
            ok = mid;
        } else {
            ng = mid;
        }
    }
    if (L.at(ok) <= c) {
        return ok;
    } else {
        return -1;
    }
}
int binarySearchMin(int ok, int ng, int c) {
    if (L.at(ok - 1) < c) {
        return -1;
    }
    while (abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;
        if (L.at(mid) >= c) {
            ok = mid;
        } else {
            ng = mid;
        }
    }
    if (L.at(ok) >= c) {
        return ok;
    } else {
        return -1;
    }
}
void resolve() {
    cin >> N;
    L = vector<int>(N + 1);
    for (int i = 0; i < N; i++) {
        cin >> L.at(i);
    }
    L.at(N) = pow(10, 9);
    sort(L.begin(), L.end());
    ll result = 0;
    for (int i = 0; i < N - 2; i++) {
        int a = L.at(i);
        for (int j = i + 1; j < N - 1; j++) {
            int b = L.at(j);
            int minC = b - a + 1;
            int maxC = a + b - 1;
            if (minC <= maxC) {
                int minI = binarySearchMin(N, j, minC);
                int maxI = binarySearchMax(j, N, maxC);
                if (minI >= 0 && maxI >= 0) {
                    result += maxI - minI + 1;
                }
            }
        }
    }
    cout << result << endl;
}

int main() {
#ifdef DEBUG_ON
    test_all();
#else
    resolve();
#endif
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <string>
#include <numeric>
#include <stack>
#include <cstdlib>

using namespace std;

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

#define rep(i, a, N) for(int i = a; i < N; i++)
#define rrep(i, a, N) for(int i = a; i >= N; i--)

const int inf = 1000000000;

int main() {
    int n;
    cin >> n;
    vector<int> x(n);
    int xmax = 0;
    int xmin = inf;
    rep(i, 0, n) {
        cin >> x[i];
        xmax = max(xmax, x[i]);
        xmin = min(xmin, x[i]);
    }

    int ans = inf;
    rep(i, xmin, xmax + 1) {
        int total = 0;
        rep(j, 0, n) {
            total += pow((x[j] - i), 2);
        }
        ans = min(ans, total);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
//D
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807

int N;
int A[100000] = {};
int nex = 0;
vector<int> S[1000];

int solve(int size, int now){
    for(int i=0; i<now; i++){
        S[now].push_back(S[i][now-1]);
        A[S[i][now-1]]++;
    }
    size -= now;
    while(size > 0){
        if(A[nex] != 0){
            nex++;
            continue;
        }
        S[now].push_back(nex);
        A[nex]++;
        nex++;
        size--;
    }
}

int main(){
    
    cin >> N;//max99681
    int tmp = 0;
    int i;
    for(i=1; i<1000; i++){//Max448
        tmp += i;
        if(tmp > N){
            cout << "No" << endl;
            return 0;
        }
        if(tmp == N) break;
    }
    cout << "Yes" << endl;
    cout << i+1 << endl;
    for(int j=0; j<i+1; j++){
        cout << i;
        solve(i, j);
        for(int k=0; k<i; k++){
            cout << " " << S[j][k]+1;
        }
        cout << endl;
    }
    
    return 0;
}

Measured memory_bytes: 2688