akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }


int A, B, C, D, E, F;

int main() {
    while (cin >> A >> B >> C >> D >> E >> F) {
        int maxWater = 100*A, maxSugar = 0;
        double maxRatio = 0.0;
        
        for (int a = 0; a <= 30; ++a) {
            for (int b = 0; b <= 30; ++b) {
                if (a == 0 && b == 0) continue;
                
                int maxlimit1 = (a*A + b*B) * E;
                int maxlimit2 = F - 100*(a*A + b*B);
                int maxlimit = min(maxlimit1, maxlimit2);
                
                for (int c = 0; c <= 3000; ++c) {
                    int rem = maxlimit - c*C;
                    if (rem < 0) continue;
                    int q = rem / D;
                    int r = rem - q * D;
                    
                    int truesugar = maxlimit - r;
                    double ratio = (double)(truesugar) / (a*A + b*B);
                    
                    if (chmax(maxRatio, ratio)) {
                        maxWater = 100 * (a*A + b*B);
                        maxSugar = truesugar;
                    }
                }
            }
        }
        cout << maxWater+maxSugar << " " << maxSugar << endl;
        
    }
}



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

int main() {
    int N;
    int P[200000];
    cin >> N;
    for (int i = 0; i < N; i++) cin >> P[i];

    int min = 200001;
    int cnt = 0;
    for (int i = 0; i < N; i++) {
        if (P[i] < min) {
            min = P[i];
            cnt++;
        }
    }

    cout << cnt << endl;

    return 0;
}

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

public class Main implements Runnable {

	public static void main(String[] args) {

		new Thread(null, new Main(), "", 16 * 1024 * 1024).start();

	}

	@Override
	public void run() {
		exec();
	}

	private void exec() {

		FastScanner sc = new FastScanner(System.in);
		int n = sc.nextInt();
		String s = sc.next();
		StringBuilder sb = new StringBuilder();
		char pre = 0;
		char[] tmp = s.toCharArray();
		for(int i = 0 ; i < n ; i++) {
			char c = tmp[i];
			if(pre != c) {
				sb.append(c);
				pre = c;
			}
		}
		System.out.println(sb.length());

	}

}

class FastScanner {

	private final InputStream in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	public FastScanner(InputStream in) {
		this.in = in;
	}

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

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

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

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

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

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

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

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

}


Measured memory_bytes: 23764
// abc138_e
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

struct Graph {

    vector<int> depth, visited;
    vector<vector<int>> edges;
    Graph(int n): edges(n), depth(n, -1), visited(n, 0) {}

    void add_edge(int u, int v){
        edges[u].emplace_back(v);
    }

    int dfs(int v){
        if (depth[v] >= 0) return depth[v];
        if (visited[v]) return INF;

        visited[v] = 1;
        int d = 1;
        for (auto t: edges[v]) {
            d = max(d, dfs(t)+1);
        }
        return depth[v] = d;
    }
};
int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int N;
    cin >> N;
    vector<vector<int>> A;
    A.assign(N, vector<int>(N-1, 0));
    REP(i, N) REP(j, N-1){
        cin >> A[i][j];  A[i][j]--;
    }

    auto g = Graph(N*N+1);
    REP(i, N) REP(j, N-2) {
        int a = i < A[i][j] ? i*N+A[i][j] : A[i][j]*N+i;
        int b = i < A[i][j+1] ? i*N+A[i][j+1] : A[i][j+1]*N+i;
        g.add_edge(a, b);
    }

    int ans = 0;
    REP(i, N){
        int a = i < A[i][0] ? i*N+A[i][0] : A[i][0]*N+i;
        ans = max(ans, g.dfs(a));
    }

    if (ans >= INF){
        print(-1);
    } else {
        print(ans);
    }
    return 0;
}


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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
    ll n,k;cin >>n>>k;
    vector<ll>p(n);
    for (int i = 0; i < n; ++i) {
        cin >>p[i];
        p[i]++;
    }
    ll ans=0;
    vector<ll>sum(n+1,0);
    for (int i = 0; i < n; ++i) {
        sum[i+1]=sum[i]+p[i];
    }
    for (int i = 0; i < n; ++i) {
        if(i+k>n)break;
        ans=max(ans,sum[i+k]-sum[i]);
    }
    double res=ans;
    res/=2;
    printf("%.10f\n",res);
    return 0;
}


Measured memory_bytes: 6408
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#define sqr(x) (x)*(x)
using namespace std;
long long na[100005],nb[100005],add,n,i;
int main()
{
	 ios::sync_with_stdio(0);
	 cin>>n;
	 for (i=1;i<=n;i++)
	 {
	 	cin>>na[i]>>nb[i];
	 }
	 for (i=n;i;i--)
	 {
	 	na[i]+=add;
	 	if (na[i]%nb[i])
	 	{
	 		add+=nb[i]-(na[i]%nb[i]);
	 	}
	 }
	 cout<<add;
	 return 0;
}

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

int main()
{
    long long int R, C, K;
    cin >> R >> C >> K;
    vector<long long int> r(K);
    vector<long long int> c(K);
    vector<long long int> v(K);
    vector<vector<long long int>> board(R + 1, vector<long long int>(C + 1));
    vector<vector<vector<long long int>>> score(R + 1, vector<vector<long long int>>(C + 1, vector<long long int>(4)));
    long long int i, j, k, max_up, ans;
    for (i = 0; i < K; i++)
    {
        cin >> r[i] >> c[i] >> v[i];
    }
    for (i = 1; i < R + 1; i++)
    {
        for (j = 1; j < C + 1; j++)
        {
            board[i][j] = 0;
        }
    }
    for (i = 0; i < K; i++)
    {
        board[r[i]][c[i]] = v[i];
    }
    for (i = 0; i < R + 1; i++)
    {
        for (j = 0; j < C + 1; j++)
        {
            score[i][j][0] = 0;
            for (k = 1; k < 4; k++)
            {
                score[i][j][k] = -1;
            }
        }
    }
    for (i = 1; i < R + 1; i++)
    {
        for (j = 1; j < C + 1; j++)
        {
            max_up = *max_element(score[i - 1][j].begin(), score[i - 1][j].end());
            score[i][j][0] = max(score[i][j - 1][0], max_up);
            for (k = 1; k < 4; k++)
            {
                ans = -1;
                if (board[i][j] != 0)
                {
                    if (k == 1)
                    {
                        if (max_up + board[i][j] > ans)
                        {
                            ans = max_up + board[i][j];
                        }
                    }
                    if (score[i][j - 1][k - 1] != -1 && score[i][j - 1][k - 1] + board[i][j] > ans)
                    {
                        ans = score[i][j - 1][k - 1] + board[i][j];
                    }
                }
                if (score[i][j - 1][k] != -1 && score[i][j - 1][k] > ans)
                {
                    ans = score[i][j - 1][k];
                }
                score[i][j][k] = ans;
            }
        }
    }
    cout << *(max_element(score[R][C].begin(), score[R][C].end())) << endl;
    return 0;
}

Measured memory_bytes: 711860
N = int(input())
D = []
count = 0
exit = False
for i in range(N):
    D.append(input().split())

for d in D:
    if d[0] == d[1]:
        count += 1
        if count >= 3:
            print("Yes")
            exit = True
            break
    else:
        count = 0

if exit == False:
    print("No")

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

typedef long long int ll;
typedef unsigned long long int ull;

int main(){
    string s;
    cin>>s;
    deque<char>ans1,ans2;
    for(int i=0;i<s.size();i++) ans1.push_back(s[i]);
    for(int i=s.size()-1;i>=0;i--) ans2.push_back(s[i]);
    int q;
    cin>>q;
    while(q--){
        int ti;
        cin>>ti;
        if(ti==1){
            swap(ans1,ans2);
        }
        else{
            int fi;
            char c;
            cin>>fi>>c;
            if(fi==1){
                ans1.push_front(c);
                ans2.push_back(c);
            }
            else{
                ans1.push_back(c);
                ans2.push_front(c);
            }
        }
    }
    for(auto it:ans1) cout<<it;
    cout<<endl;
    return 0;
}


Measured memory_bytes: 1280
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <stack>
#include <cmath>
#include <queue>
#include <numeric>

int main()
{
	long long h, w;

	std::cin >> h >> w;

	std::vector<std::string> v(h);

	for (size_t i = 0; i < h; i++)
	{
		std::cin >> v[i];
	}

	for (size_t i = 0; i < w + 2; i++)
	{
		std::cout << "#";
	}

	std::cout << std::endl;

	for (size_t i = 0; i < h; i++)
	{
		std::cout << "#" << v[i] << "#" << std::endl;
	}



	for (size_t i = 0; i < w + 2; i++)
	{
		std::cout << "#";
	}

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


Measured memory_bytes: 256
#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>;
using vv = vector<vector<ll> >;
template <class _t> inline bool chmax (_t& a,_t b){if(a<b){a=b;return true;}return false;} template <class _t> inline bool chmin (_t& a,_t b){if(a>b){a=b;return true;}return false;}

const int INF = 2147483647;
const int max_N = 1000000000;
const long long inf = 1ll << 60;
const long long mod = 1000000007;

int dx[4] = {1,0,-1,0};
int dy[4] = {0,-1,0,1};
int main(){
    int k;cin >> k;
    int x = 7,ans=1;
    while(1){
        if(x%k==0){
            cout << ans << endl;
            return 0;
        }
        if(ans>k) break;
        x = (x*10+7)%k;
        ans++;
    }
    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 3588
#include <stdio.h>
#include <stdlib.h>
int main()
{
    int N,M,i,j,num[50]={};
    long int a[50],b[50],c,d,min[50],dis;
    scanf("%d %d",&N,&M);
    for(i=0;i<N;i++) scanf("%ld %ld",&a[i],&b[i]);
    for(i=0;i<M;i++){
        scanf("%ld %ld",&c,&d);
        for(j=0;j<N;j++){
            dis=labs(a[j]-c)+labs(b[j]-d);
            min[j]>dis?(min[j]=dis,num[j]=i):i==0?min[j]=dis:0;
        }
    }
    for(i=0;i<N;i++) printf("%d\n",num[i]+1);
    return 0;
}

Measured memory_bytes: 128
package main

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

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func readLine() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func main() {
	ins := strings.Split(readLine(), " ")

	x, _ := strconv.Atoi(ins[0])
	a, _ := strconv.Atoi(ins[1])

	if x < a {
		fmt.Println(0)
	} else {
		fmt.Println(10)
	}
}


Measured memory_bytes: 640
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int in = sc.nextInt() - sc.nextInt();
		int ans = sc.nextInt() - in;
		if(ans > 0)System.out.println(ans);
		else System.out.println(0);
	}
}

Measured memory_bytes: 21844
#include<stdio.h>
#include<iostream>
#include<algorithm> // sort(ALL())
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue> // push(), front(), pop() 先入れ先出し
#include<map> // 連想配列 map<string, int>
#include<iomanip>
#include<set>
#include<utility>
using namespace std;
#define FOR(i, a, b) for(int i=(a); i<(b);  i++)
#define REP(i, n)    for(int i=0;   i<(n);  i++)
#define REP1(i, n)   for(int i=1;   i<=(n); i++)
#define pb push_back
#define mp make_pair
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define EPS 1e-7
#define ALL(obj) (obj).begin(), (obj).end()
using ul    = unsigned long;
using ll    = long long;
using ld    = long double;
using vint  = vector<int>;
using vll   = vector<ll>;
using pint  = pair<int, int>;
using pll   = pair<ll, ll>;
using vpint = vector<pint>;
using vpll  = vector<pll>;
const int INF = (int)1e9 + 1;
const int MOD = (int)1e9 + 7;
#define INT(argu) (int)(argu+eps)



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

  int n;
  cin >> n;
  vint p(n);
  REP(i, n) scan(p[i]);

  int cnt =0;
  FOR(i, 1, n-1){
    if( (p[i-1]<p[i]&&p[i]<p[i+1]) || (p[i-1]>p[i]&&p[i]>p[i+1]) ){
      cnt++;
    }
  }


  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 256
Mod = 1000000007
H,W,K = gets.split.map(&:to_i)

ls = Array.new(W+2, 0)
ls[0] = ls[1] = 1
(0...W).each{ |i| ls[i+2] = ls[i+1] + ls[i] }
#p ls

dp = Array.new(W, 0)
dp[0] = 1

H.times {
  ndp = Array.new(W, 0)
  (0...W).each{ |i|
    s = [W-1 - (i+1), 0].max
    t = [i-1, 0].max
    #p ["", i,s,t]
    ndp[i] += dp[i] * ls[s+1] * ls[t+1]
  }
  #p ndp
  (1...W).each{ |i|
    s = [W-1 - (i+1) , 0].max
    t = [i-2, 0].max
    ndp[i-1] += dp[i] * ls[s+1] * ls[t+1]
  }
  #p ndp
  (0...W-1).each{ |i|
    s = [W-1 - (i+2) , 0].max
    t = [i-1, 0].max
    ndp[i+1] += dp[i] * ls[s+1] * ls[t+1]
  }
  #p ndp
  (0...W).each{ |i| dp[i] = ndp[i] % Mod }
}
#p dp
p dp[K-1]



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

int main() {
  int n,y;
  cin>>n>>y;
  bool ok = false;
  for (int i=0;i<=n;i++){
    for (int j=0;j+i<=n;j++){
      int k = n-i-j;
      int total = 10000*i + 5000*j + 1000*k;
      if (total == y){
        ok = true;
        cout << i <<" "<< j << " " << k << endl;
        return 0;
      }
    }
  }
  if(ok == false){
    cout << -1 <<" "<< -1 << " " << -1 << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,a,b) for (int i = (a); i < (b); i++ )
typedef pair<int,int> P;
typedef long long ll;
const int INF = 100000000;


int main (){
    int N,M;
    cin >> N;
    string S[N];
    rep(i,0,N) {
        cin >> S[i];
    }
    cin >> M;
    string T[M];
    rep(i,0,M) {
        cin >> T[i];
    }
    int ans = 0;
    int ans_tmp;
    rep(i,0,N) {
        ans_tmp = 0;
        string tmp = S[i];
        rep(j,0,N) {
            if(tmp==S[j]) {
                ans_tmp++;
            }
        }
        rep(j,0,M) {
            if(tmp==T[j]) {
                ans_tmp--;
            }
        }
        ans = max(ans,ans_tmp);

    }

    cout << ans << endl;

}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<lint, lint>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
void yes(bool expr) {
  cout << (expr ? "Yes" : "No") << "\n";
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  lint N;
  cin >> N;
  vector<lint> a(N);
  REP(i, N) cin >> a[i];
  vector<lint> idx(N);
  REP(i, N) idx[a[i]-1] = i;
  lint ans = 0;
  set<lint> st;
  REP(i, N) {
    lint tmpl = 0, tmpr = 0;
    auto itr = st.lower_bound(idx[i]);
    if(itr == st.end()) {
      tmpr = N - idx[i];
    } else {
      tmpr = *itr - idx[i];
    }
    if(itr == st.begin()) {
      tmpl = idx[i] + 1;
    } else {
      itr = prev(itr, 1);
      tmpl = idx[i] - *itr;
    }
    st.insert(idx[i]);
    ans += tmpl * tmpr * (i+1);
  }
  cout << ans << endl;
}

Measured memory_bytes: 12800
#include <stdio.h>

int main(void)
{
	int n;
	int hen[3];
	int i;
	int j;
	int max;
	int other;
	
	scanf("%d", &n);
	
	for (i = 0; i < n; i++){
		max = other = 0;
		scanf("%d %d %d", &hen[0], &hen[1], &hen[2]);
		
		for (j = 0; j < 3; j++){
			if (max <= hen[j]){
				max = hen[j];
			}
		}
		for (j = 0; j < 3; j++){
			if (hen[j] < max){
				other += hen[j] * hen[j];
			}
		}
		
		max *= max;
		if (max == other){
			printf("YES");
		}
		
		else if (max != other){
			printf("NO");
		}
		printf("\n");
	}
	
	return (0);
}

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

using namespace std;

int main(void) {
    int c[3][3];
    for(int i = 0;i < 3;i++) {
        for(int ii =0;ii < 3;ii++)
            cin >> c[i][ii];
    }
    int sum = c[0][0] + c[1][1] + c[2][2];
    for(int x = 0;x < 3;x++) {
        for(int y = 0;y < 3;y++) {
            for(int z = 0;z < 3;z++) {
                if(x != y && y != z && z != x && c[0][x] + c[1][y] + c[2][z] != sum) {
                    cout << "No" << endl;
                    return 0;
                }
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
h, w, a, b = gets.chomp.split.map(&:to_i)

1.upto(h) do |i|
    1.upto(w) do |j|
        if i <= b
            print j <= a ? 0 : 1
        else
            print j <= a ? 1 : 0
        end
    end
    print "\n"
end

Measured memory_bytes: 2812
# coding: utf-8
from math import ceil
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=False)
top = A[-1]
half = ceil(top / 2)
b = float("inf")
for i in range(N-1):
    if abs(half - b) > abs(half - A[i]):
        b = A[i]
print(top, b)

Measured memory_bytes: 14180
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>

using namespace std;

#define REP(i,e,s) for(register int i=(e); i<=(s); i++)
#define DREP(i,e,s) for(register int i=(e); i>=(s); i--)
#define ll long long
#define DE(...) fprintf(stderr,__VA_ARGS__)
#define DEBUG(a) DE("DEBUG: %d\n",a)
#define file(a) freopen(a".in","r",stdin);freopen(a".out","w",stdout)
int read() {
	int x=0,f=1,ch=getchar();
	while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

const int MAXN=100000+10;

int have[MAXN],pna[MAXN];

int main() {
	int n=read(),m=read();
	
	int ans1=0,ans2=0;

	REP(i,1,m) {
		int id=read();char op[4];
		scanf("%s",op+1);
		if(op[1]=='A') have[id]=1;
		else 
			if(!have[id]) pna[id]++;
	}	
	REP(i,1,n) if(have[i]) ans1++;
	REP(i,1,n) if(have[i]) ans2+=pna[i];
	
	printf("%d %d\n",ans1,ans2);
	return 0;
}



Measured memory_bytes: 1024
#include<stdio.h>
#include<vector>
#include<string.h>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<math.h>
int a[110];
int main(){
	int n,ans=0,k,to=0,c,p;
	scanf("%d",&n);
	for(k=1;k<=n;k++){
		scanf("%d",&a[k]);
		to+=a[k];
	}
	c=to/n;
	p=to-c*n;
	if(p>n/2) c++;
	for(k=1;k<=n;k++){
		ans+=(c-a[k])*(c-a[k]);
	}
	printf("%d",ans);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
#define sz(x) (int)(x).size()
using namespace std;
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//uniform_int_distribution<int>(1000,10000)(rng)

ll binpow(ll a, ll b)
{
    if (b == 0)
        return 1;
    ll res = binpow(a, b / 2);
    res*=res;
    if (b % 2)
        return res * a;
    return res;
}

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

string to_upper(string a)
{
    for (int i=0;i<(int)a.size();++i) if (a[i]>='a' && a[i]<='z') a[i]-='a'-'A';
    return a;
}
 
string to_lower(string a)
{
    for (int i=0;i<(int)a.size();++i) if (a[i]>='A' && a[i]<='Z') a[i]+='a'-'A';
    return a;
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n,x,t;
    cin>>n>>x>>t;
    cout<<((n+x-1)/x)*t;
    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
  int n;
  cin>>n;
  vector<int> h(n);
  map<ll,int> m;
  for(int i=0;i<n;i++)
  {
    cin>>h[i];
    m[i+1-h[i]]++;
  }
  ll ans=0;
  for(int i=0;i<n;i++)
    ans=ans+m[h[i]+i+1];
  cout<<ans<<endl;
}

Measured memory_bytes: 26572
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>

using namespace std;

#define ll long long

int main(void){
    string s, t;
    cin >> s >> t;

    int ans = 0;
    for(int i = 0;i < 3;++i){
        if(s[i] == t[i]){
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}

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

int main() {
  long h, w;
  cin >> h >> w;
  long result;
  if (h == 1 || w == 1) {
    result = 1;
  } else if (h % 2 == 0 || w % 2 == 0) {
    result = (w * h) / 2;
  } else {
    result = (w * h + 1) / 2;
  }
  cout << result << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/rope>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define long long long 
#define PI 3.141592653589793238

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
        //use cerr if u want to display at the bottom
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

typedef trie<string,null_type,trie_string_access_traits<>,pat_trie_tag,trie_prefix_search_node_update> pref_trie;
typedef tree<long int,null_type,less<long int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef cc_hash_table<long int,long int, hash<long int>, equal_to<long int>, direct_mask_range_hashing<long int>, 
hash_standard_resize_policy<hash_exponential_size_policy<>, hash_load_check_resize_trigger<true>, true>> ht;
typedef gp_hash_table<long int,long int> HashTable;

map<pair<long int,long int>,long int> s;
long int dp[3005][3005][4];
long int r,c,k;

long int solve(long int x,long int y,long int picked){

	if(x == r && y == c){
		if(s.find(make_pair(x,y)) != s.end()){
			if(picked < 3)
				return s[make_pair(x,y)];
			else
				return 0;
		}
		return 0;
	}

	if(x > r || x < 1 || y > c || y < 1)
		return -1e10;

	if(dp[x][y][picked] != -1)
		return dp[x][y][picked];

	long int ans = solve(x + 1, y, 0);

	if(picked < 3 && s.find(make_pair(x, y)) != s.end())
		ans = max(ans, s[make_pair(x,y)] + solve(x + 1, y, 0));

	ans = max(ans,solve(x, y + 1, picked));

	if(picked < 3 && s.find(make_pair(x, y)) != s.end())
		ans = max(ans, s[make_pair(x,y)] + solve(x, y + 1, picked + 1));

	return dp[x][y][picked] = ans;
}

int main(){
   IOS;
 /*    #ifndef ONLINE_JUDGE
         freopen("in.txt",  "r",  stdin);
         freopen("out.txt", "w", stdout);
     #endif */
   
   cin>>r>>c>>k;

   for(long int i = 0; i < k; i++){
   	long int a,b,c;
   	cin>>a>>b>>c;
   	s[make_pair(a,b)] += c;
   }

   for(long int i = 1; i <= r + 4; i++){
   	for(long int j = 1; j <= c + 4; j++){
   		for(long int k = 0; k < 4; k++){
   			dp[i][j][k] = -1;
   		}
   	}
   }

   cout<<solve(1,1,0);
   return 0;
}

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

int main()
{
	string s;
	getline(cin,s);
	long long sum = 0,t1 = 0,t2 = 0;
	for(int i = 0; i < s.length();){
		while(s[i] == '<'){
			t1++;
			i++;
		}
		while(s[i] == '>'){
			t2++;
			i++;
		}
		if(t1 == 0)
			sum += (t2 + 1) * t2 / 2;
		else if(t2 == 0)
			sum += (t1 + 1) * t1 / 2;
		else if(t1 >= t2)
			sum = sum + (t1 + 1) * t1 / 2 + (t2 - 1) * t2 / 2;
		else if(t1 < t2)
			sum = sum + (t1 - 1) * t1 / 2 + (t2 + 1) * t2 / 2;
		t1 = 0;
		t2 = 0;
	} 
	printf("%lld\n",sum);
	return 0;
} 

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

int main() {
    int n;
    cin >> n;
    vector<int> R(n);
    for(int i=0;i<n;i++){
        cin >> R.at(i);
    }
    int minv=R.at(0);
    int maxv=R.at(1)-R.at(0);
    for(int i=1;i<n;i++){
        maxv=max(maxv,R.at(i)-minv);
        minv=min(minv,R.at(i));
    }    
    cout << maxv << endl;
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define VI         vector<int>
#define MOD 1000000007

using ll = long long int;
using P = pair<int,int>;

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

const ll INF=(ll)1e19;
//const int INF=(1<<30);

map<int, int> mp;

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

  vector<int> a(n);
  REP(i,n){
    cin >> a[i];

    mp[i - a[i]]++;
  }


  ll ans=0;
  REP(i,n){
    ans += mp[i + a[i]];
  }

  cout << ans << endl;


}



Measured memory_bytes: 21208
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <cmath>
#include <cstring>

#define fi first
#define se second
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = 1; i < (n); ++i)
#define drep(i,n) for (int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define all(x) (x).begin(), (x).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T> >
#define PI 3.14159265358979

using namespace std;
typedef long long ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;

const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

const int mod = 1000000007;

int main() {
    double a, b, x;
    cin >> a >> b >> x;
    double tan;
    if ((a*a*b/2) < x) {
        tan = (a * a * a) / (2 * (a * a * b - x));
    }
    else {
        tan = 2 * (x / (a*b*b));
    }
    double rad = atan(tan);
    double deg = rad * (180.0 / PI);
    double ans = 90.0 - deg;
    printf("%.8f", ans);
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

# D - Moving Piece
N, K = map(int, input().split())
P = list(map(int, input().split()))
C = list(map(int, input().split()))

# 問題文とインデックスの位置を揃える
P.insert(0, 0)
C.insert(0, 0)

# マス目を周期ごとに分割する
groups = []
appeared = set()

for i in range(1, N + 1):
	if not i in appeared:
		group = []
		s = set()
		j = i

		while not j in s:
			group.append(j)
			s.add(j)
			appeared.add(j)
			j = P[j]

		groups.append(group)

MIN = -sys.maxsize
ans = MIN

# 周期ごとにハイスコアを算出
for group in groups:
	n = len(group)

	# スタート位置を1マスずつズラす
	for g in group:
		score = 0
		max_score = MIN
		scores = []
		scores.append(MIN)
		Pi = P[g]

		for j in range(n):
			score += C[Pi]
			max_score = max(max_score, score)
			scores.append(max_score)
			Pi = P[Pi]

		if K > n and score > 0:
			s = scores[K % n] + score * (K // n)
			ans = max(ans, s)

			s = max_score + score * (K // n - 1)
			ans = max(ans, s)
		elif K > n:
			ans = max(ans, max_score)
		else:
			ans = max(ans, scores[K])

print(ans)

Measured memory_bytes: 81100
import java.io.*;
import java.util.*;
 
public class Main{
	
 
	public void solve(){
		String str = next();
		boolean n = str.contains("N");
		boolean s = str.contains("S");
		boolean e = str.contains("E");
		boolean w = str.contains("W");
		if(n == s && e == w){
			out.println("Yes");
		}else{
			out.println("No");
		}
		
	}
	
	private static PrintWriter out;
	public static void main(String[] args){
		out = new PrintWriter(System.out);
		new Main().solve();
		out.flush();
	}
	
	
	
	public static int nextInt(){
		int num = 0;
		String str = next();
		boolean minus = false;
		int i = 0;
		if(str.charAt(0) == '-'){
			minus = true;
			i++;
		}
		int len = str.length();
		for(;i < len; i++){
			char c = str.charAt(i);
			if(!('0' <= c && c <= '9')) throw new RuntimeException();
			num = num * 10 + (c - '0');
		}
		return minus ? -num : num;
	}
	
	public static long nextLong(){
		long num = 0;
		String str = next();
		boolean minus = false;
		int i = 0;
		if(str.charAt(0) == '-'){
			minus = true;
			i++;
		}
		int len = str.length();
		for(;i < len; i++){
			char c = str.charAt(i);
			if(!('0' <= c && c <= '9')) throw new RuntimeException();
			num = num * 10l + (c - '0');
		}
		return minus ? -num : num;
	}
	public static String next(){
		int c;
		while(!isAlNum(c = read())){}
		StringBuilder build = new StringBuilder();
		build.append((char)c);
		while(isAlNum(c = read())){
			build.append((char)c);
		}
		return build.toString();
	}
	
	
	private static byte[] inputBuffer = new byte[1024];
	private static int bufferLength = 0;
	private static int bufferIndex = 0;
	private static int read(){
		if(bufferLength < 0) throw new RuntimeException();
		if(bufferIndex >= bufferLength){
			try{
				bufferLength = System.in.read(inputBuffer);
				bufferIndex = 0;
			}catch(IOException e){
				throw new RuntimeException(e);
			}
			if(bufferLength <= 0) return (bufferLength = -1);
		}
		return inputBuffer[bufferIndex++];
	}
	
	private static boolean isAlNum(int c){
		return '!' <= c && c <= '~';
	}
}

Measured memory_bytes: 8020
#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 1e9
const int mod = 1e9 + 7;
typedef long long ll;
using namespace std;
ll N, M, Q;
ll A, B;
ll LR[501][501];
ll ans;
string S;
ll K;
bool pairCompare(const pair<ll, ll>& firstElof, const pair<ll, ll>& secondElof)
{
	return firstElof.first > secondElof.first;
}
map<ll, vector<pair<ll,ll> > > m;
int main() {
	cin >> N >> M >> Q;
	rep(i, 0, M) {
		ll L, R;
		cin >> L >> R;
		LR[L][R]++;
	}
	rep(i, 0, N + 1) {
		rep(j, 1, N+1) {
			LR[i][j] += LR[i][j - 1];
		}
	}
	rep(i, 0, Q) {
		ll p, q;
		cin >> p >> q;
		ans = 0;
		rep(i, p, q+1) {
			ans += LR[i][q] - LR[i][p-1];
		}
		cout << ans << endl;
	}
	cin >> ans;
	return 0;
}

Measured memory_bytes: 2944
#include<iostream>
using namespace std;
int main(){
  int n;
  cin >> n;
  int i=1;
  while(++i<=n){
    int x=i;
    if(x%3==0){
      cout << " " << i;
      continue;
    }
    while(x){
      if(x%10==3){
	cout << " " << i;
	break;
      }
      x/=10;
    }
  }
  cout << endl;
  return 0;
}



Measured memory_bytes: 3092
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
 
using namespace std;
 
void addWordCount(const vector<string>& cards, map<string, int>& wordCount);
void subWordCount(const vector<string>& cards, map<string, int>& wordCount);
  
int main() {
    int numOfBlueCard = 0;
    cin >> numOfBlueCard;
    vector<string> blueCards;
    for (int i = 0; i < numOfBlueCard; ++i) {
        string blueCard;
        cin >> blueCard;
        blueCards.push_back(blueCard);
    }
 
    int numOfRedCard = 0;
    cin >> numOfRedCard;
    vector<string> redCards;
    for (int i = 0; i < numOfRedCard; ++i) {
        string redCard;
        cin >> redCard;
        redCards.push_back(redCard);
    }
    
    map<string, int> wordCount;
    addWordCount(blueCards, wordCount);
    subWordCount(redCards, wordCount);
    
    map<string, int>::iterator maxValueWord = std::max_element(wordCount.begin(), wordCount.end(),
    [](const pair<string, int>& p1, const pair<string, int>& p2) {
        return p1.second < p2.second; });
    
    int maxValue = 0;
    if (maxValueWord->second >= 0) {
        maxValue = maxValueWord->second;
    }
    cout << maxValue << endl;
}
 
void addWordCount(const vector<string>& cards, map<string, int>& wordCount) {
    for (string card : cards) {
        ++wordCount[card];
    }
}
 
void subWordCount(const vector<string>& cards, map<string, int>& wordCount) {
    for (string card : cards) {
        --wordCount[card];
    }
}


Measured memory_bytes: 3544
use proconio::input;

fn solve(n: usize, k: usize, a: Vec<Vec<i32>>) -> i32 {
    let mut v = vec![0; n];
    for w in a {
        for i in w {
            v[i as usize - 1] += 1;
        }
    }
    v.into_iter()
        .filter(|&i| i == 0)
        .count() as i32
}

fn main() {
    input! {
        n: usize,
        k: usize,
    }
    let mut a = Vec::new();
    for _ in 0..k {
        input! {
            d: usize,
            aa: [i32; d],
        }
        a.push(aa);
    }
    let r = solve(n, k, a);
    println!("{}", r);
}


Measured memory_bytes: 2260
#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() {
  ll a;
  double b;
  cin >> a >> b;
  ll ib = b*100+0.5;
  a *= ib;
  a /= 100;
  printf("%lld\n", a);
  return 0;
}

Measured memory_bytes: 3788
#include<bits/stdc++.h>
using namespace std;
int g[300][300];

int gcd(int x, int y)
{
	if(g[x][y]!=0)
		return g[x][y];

	int q, r;
	int a = x;
	int b = y;
	
	// loop till remainder is 0
	while (b > 0)
	{
		q = a / b;		// quotient 
		r = a - q * b;	// remainder

		// or we can simply use (a % b) to calculate r

		// a becomes b and b becomes r (a % b)
		a = b;
		b = r;
	}
	g[x][y] = a;
	g[y][x] = a;


	return a;

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

	int ans = 0;
	for (int i = 1; i <= n; ++i)
	{
		for(int j = 1; j <= n ;j++)
		{
			int g1 = gcd(i,j);
			for(int k = 1; k <= n ;k++)
			{
				int g2 = gcd(g1,k);
				ans += g2;
			}
		}
	}

	cout<<ans<<endl;

	
	return 0;
}



Measured memory_bytes: 3868
#include <iostream>
#include <list>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;
typedef long long lli;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<vector<lli> > mat;
typedef vector<vector<bool> > matb;
typedef vector<string> vst;
typedef pair<lli,lli> pll;
typedef pair<double,double> pdd;

set<lli> a;
lli ans = 0;
lli n,q;

int main(){
    cin >> n;
    for(lli i = 0;i < n;i++){
        lli s;
        cin >> s;
        a.insert(s);
    }
    cin >> q;
    for(lli i = 0;i < q;i++){
        lli t;
        cin >> t;
        if(a.count(t)){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3116
n,k=map(int,input().split())

F = 10000
mod = 10**9+7
fact = [1]*F
inv = [1]*F
for i in range(2,F):
    fact[i]=(fact[i-1]*i)%mod
inv[F-1]=pow(fact[F-1],mod-2,mod)
for i in range(F-2,1,-1):
    inv[i] = (inv[i+1]*(i+1))%mod

def comb(n,k):
    ans=(fact[n]*inv[n-k])%mod
    return (ans*inv[k])%mod
def H(n,k):
    return comb(n+k-1,k)

for i in range(1,k+1):
    if i<=n-k+1:
        print(comb(n-k+1,i)*H(i,k-i)%mod)
    else:
        print(0)

Measured memory_bytes: 4084
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <cassert>
using namespace std;
#define ll long long
const double EPS = 1e-10;

int main(){
  string s;
  cin>>s;
  ll a=0;
  ll b=0;
  ll asum=0;
  ll bsum=0;
  for(int i=0;i<s.size();i++){
    if(s[i]=='W') a++,b+=i;
  }
  asum=(a-1)*a/2;
  cout<<b-asum<<endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h> 
using namespace std;
const long INF=1000000000000000;
const long MOD=1000000007;

int main() {
    long N;
    cin>>N;
    vector<long> a(N);
    
    for(int i=0;i<N;i++)cin>>a.at(i);
    
    sort(a.begin(),a.end());
    cout<<a.at(a.size()-1)-a.at(0)<<endl;
}


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

int main() {
  int h, n, a, sum_a = 0;
  cin >> h >> n;
  int i;
  for (i = 0; i < n; i++) {
    cin >> a;
    sum_a += a;
  }
  cout << (h <= sum_a ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <map>
#include <queue>
#define rep(i, n) for(int i = 0; i < n; i++)
std::vector<int> hist; //[??´???] = cost
std::vector<int> field; //[??´???] = ??????
int main()
{
	int n;
	std::cin >> n;
	hist.resize(n, -1);
	rep(i, n) {
		int tmp;
		std::cin >> tmp;
		field.push_back(tmp);
	}

	std::queue<std::pair<int, int>> q;//??´???, ?????°
	q.push(std::make_pair(0, 0));
	while (1) {
		auto now = q.front(); q.pop();
		//1-6????????????????????????
		for (int i = 1; i <= 6; i++) 
		{
			//??¨?????????????????????
			auto next = now;
			next.second++;
			next.first += i;
			//??´????????????????????????????????´??????
			if (next.first >= field.size() - 1) {
				std::cout << next.second << std::endl;
				return 0;
			}
			//?¨???????????????????????????°??????????°???????
			if (hist[next.first] == -1 || hist[next.first] > next.second) {
				bool canUpdate = true;
				//??????????????¨???????§??????§????????¨???????????§?§????
				while (field[next.first]) {
					//??´??°??§????????? ????????????????§?(?????§????¨????????????????????????\?????????????????§?¨???????????????´???)
					if (hist[next.first + field[next.first]] != -1 && hist[next.first + field[next.first]] <= next.second) {
						canUpdate = false;
						break;
					}
					next.first += field[next.first];
					hist[next.first] = next.second;
				}
				//?§??????????
				hist[next.first] = next.second;
				if (canUpdate) {
					q.push(next);
				}
				if (next.first == field.size() - 1) { //??´??????
					std::cout << next.second << std::endl;
					return 0;
				}
			}
		}
	}

	return 0;
}

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

int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  vector<string> a({"SS", "WW", "SW", "WS"});
  bool yes = false;
  string res;
  for(int i=0;i<a.size();i++) {
    string ans = a[i];
    for(int i=1;i<n-1;i++) {
      if(ans[i] == 'S') {
        if(s[i] == 'o') ans += ans[i-1];
        else if(ans[i-1] == 'S') ans += 'W';
        else ans += 'S';
      }
      else {
        if(s[i] == 'x') ans += ans[i-1];
        else if(ans[i-1] == 'S') ans += 'W';
        else ans += 'S';
      }
    }
    if(ans[n-1] == 'W') {
      if(s[n-1] == 'x' && ans[n-2] != ans[0]) continue;
      else if(s[n-1] == 'o' && ans[n-2] == ans[0]) continue;
    }
    else if(ans[n-1] == 'S') {
      if(s[n-1] == 'o' && ans[n-2] != ans[0]) continue;
      else if(s[n-1] == 'x' && ans[n-2] == ans[0]) continue;
    }

    if(ans[0] == 'W') {
      if(s[0] == 'x' && ans[1] != ans[n-1]) continue;
      else if(s[0] == 'o' && ans[1] == ans[n-1]) continue;
    }
    else if(ans[0] == 'S') {
      if(s[0] == 'o' && ans[1] != ans[n-1]) continue;
      else if(s[0] == 'x' && ans[1] == ans[n-1]) continue;
    }

    yes = true;
    res = ans;
    break;
  }
  if(yes) cout << res << endl;
  else cout << -1 << endl;
}


Measured memory_bytes: 736
H = int(input())
W = int(input())
N = int(input())
count = 0
sum_a = 0
sum_b = 0

while True:
	count += 1
	sum_a += H
	if sum_a >= N:
		print(count)
		break
	sum_b += W
	if sum_b >= N:
		print(count)
		break
  
 

Measured memory_bytes: 3064
#include <stdio.h>
int main()
{
    int a[33]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    scanf("%i",&k);
    printf("%i",a[k-1]);
    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>

int main()
{

   int a;
    scanf("%d",&a);

    int k=0;
    int x=a;
   while(a>=1)
   {
       k=k+a%10;
       a=a/10;
   }

  if(x%k==0)
    printf("Yes\n");
  else
    printf("No\n");
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
    #define int ll
    #define M 1000000007
    #define hell 998244353
    #define inf 1e18
    #define pb push_back
    #define pi 3.1415926536
    #define mp make_pair
    #define ub upper_bound
    #define lb lower_bound
    #define all(a) a.begin(),a.end()
    #define ll long long
    #define vec vector <int>
    #define pii pair<int,int>
    #define endl "\n"
    #define gcd __gcd
    using namespace std;
    int power(int x, unsigned int y, unsigned int m) 
    { 
        if (y == 0) 
            return 1; 
        int p = power(x, y/2, m) % m; 
        p = (p * p) % m; 
  
        return (y%2 == 0)? p : (x * p) % m; 
    } 
    int modInverse(int a, int m) 
    {   
        return power(a, m-2, m);
    }
    int nCrModPFermat(int n, int r, int p) 
    { 
           if (r==0) 
              return 1; 
  
        int fac[n+1]; 
        fac[0] = 1; 
        for (int i=1 ; i<=n; i++) 
            fac[i] = fac[i-1]*i%p; 
  
        return (fac[n]* modInverse(fac[r], p) % p * 
            modInverse(fac[n-r], p) % p) % p; 
    } 
    signed main()
    {
        ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
        ll t=1;
        // cin >> t;
        /*SAARE INPUTS LENA*/
        /*VARIABLES KI RANGE DEKHLENA*/
        /*EXPONENT RANGE OF OUTPUT KA DHYAN RAKHNA*/
        while(t-->0)
        {
            ll n=0,W=0;
            cin>>n>>W;
            int val[n],weight[n];
            for (int i = 0; i < n; ++i)
            {
                cin>>weight[i]>>val[i];
            }
            int dp[n+1][W+1];
            for (int i = 0; i <=n; ++i)
                dp[i][0]=0;
            for (int i = 0; i <=W; ++i)
                dp[0][i]=0;
            for (int i = 1; i <=n; ++i)
            {
                for(int j=1;j<=W;j++)
                {
                    if(weight[i-1]<=j)
                    {
                        dp[i][j]=max(val[i-1]+dp[i-1][j-weight[i-1]],dp[i-1][j]);
                    }
                    else
                        dp[i][j]=dp[i-1][j];
                }
            }
            cout<<dp[n][W];
        }
        return 0;
    }

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

int main() {
  int n,k;
  cin>>n>>k;
  vector<int> h(n);
  rep(i, n) cin>>h[i];
  sort(h.begin(), h.end(), greater<int>());
  ll res=0;
  rep(i, n) {
    if (i<k) continue;
    else res+=h[i];
  }
  cout<<res<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    string t="",h="";
    t = s[0];
    t = t + s[1];
    h = h + s[2]+s[3];
    if(("01"<=t&&t<="12")&&("01"<=h&&h<="12")){
        cout << "AMBIGUOUS" << endl;
    }else if(("00"<=t&&t<="99")&&("01"<=h&&h<="12")){
        cout << "YYMM" << endl;
    }else if(("01"<=t&&t<="12")&&("00"<=h&&h<="99")){
        cout << "MMYY" << endl;
    }else{
        cout << "NA" << endl;
    }
}

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

long long N;
int tmp = 0;
void dfs(long long morty,int mask){
	if(morty>N)return ;
  	if(mask == 7)tmp++;
  	dfs(morty*10+7,mask|4);
  dfs(morty*10+5,mask|2);
  dfs(morty*10+3,mask|1);
}
void solve(long long N) {
	dfs(0,0);
  cout<<tmp;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You
// use the default template now. You can remove this line by using your custom
// template)
int main() {
  scanf("%lld", &N);
  solve(N);
  return 0;
}


Measured memory_bytes: 256