akhauriyash/Code-Regression huggingface dataset:
/*Whose woods these are I think I know.
His house is in the village though;
He will not see me stopping here
To watch his woods fill up with snow.

My little horse must think it queer
To stop without a farmhouse near
Between the woods and frozen lake
The darkest evening of the year.

He gives his harness bells a shake
To ask if there is some mistake.
The only other sound’s the sweep
Of easy wind and downy flake.

The woods are lovely, dark and deep,
But I have promises to keep,
And miles to go before I sleep,
And miles to go before I sleep.*/

#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define pb push_back
#define fi first
#define se second
#define MOD 1000000007
const int maxn= 100010;
int l[2020][2020];
int r[2020][2020];
int u[2020][2020];
int d[2020][2020];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int h=0,w=0,res=0;
    cin>>h>>w;
    vector<string> v(h);
    for(int i=0;i<h;++i)
        cin>>v[i];
    for(int i=0;i<h;++i)
    {
        int curr=0;
        for(int j=0;j<w;++j)
        {
            if(v[i][j]=='#')
                curr=0;
            else
                ++curr;
            l[i][j]=curr;
        }
    }
    for(int i=0;i<h;++i)
    {
        int curr=0;
        for(int j=w-1;j>=0;--j)
        {
            if(v[i][j]=='#')
                curr=0;
            else
                ++curr;
            r[i][j]=curr;
        }
    }
    for(int j=0;j<w;++j)
    {
        int curr=0;
        for(int i=0;i<h;++i)
        {
            if(v[i][j]=='#')
                curr=0;
            else
                ++curr;
            u[i][j]=curr;
        }
    }
    for(int j=0;j<w;++j)
    {
        int curr=0;
        for(int i=h-1;i>=0;--i)
        {
            if(v[i][j]=='#')
                curr=0;
            else
                ++curr;
            d[i][j]=curr;
        }
    }
    for(int i=0;i<h;++i)
        for(int j=0;j<w;++j)
        {
            if(v[i][j]=='.')
                res=max(res,l[i][j]+r[i][j]+u[i][j]+d[i][j]-3);
        }
    cout<<res<<endl;
}

Measured memory_bytes: 68096
#include <cstdio>
#include <vector>
#include <queue>
#include <algorithm>
#include <functional>
using namespace std;

int N, M;
int ai[100010];
int x, y;
vector<vector<int> > G(100010);
long long res;
int curg;
int grp[100010];
struct data{
	int val;
	int seq;
	int sz;
};
struct cmp_pq {
	bool operator() (const struct data a, const struct data b) const {
		return a.val > b.val;
	}
};
struct cmp_pq_s {
	bool operator() (const struct data a, const struct data b) const {
		return a.sz < b.sz;
		/*if(a.sz < b.sz)
			return true;
		else if(a.sz > b.sz)
			return false;
		else
			return a.val > b.val;*/
	}
};
vector<priority_queue<struct data, vector<struct data>, cmp_pq > > V(100010);
priority_queue<struct data, vector<struct data>, cmp_pq_s > pq;
int curV[100010];

void dfs(int u)
{
	int i, v;
	for(i=0; i<G[u].size(); i++){
		v = G[u][i];
		if(grp[v]==-1){
			grp[v] = curg;
			dfs(v);
		}
	}
}

bool cmp(int aa, int bb)
{
	return ai[aa] < ai[bb];
}

int solve()
{
	int i, j, k;
	for(i=0; i<N; i++){
		grp[i] = -1;
	}
	curg = 0;
	for(i=0; i<N; i++){
		if(grp[i]==-1){
			grp[i] = curg;
			dfs(i);
			curg ++;
		}
	}
	struct data d, d2, d3;
	for(i=0; i<N; i++){
		d.seq = i;
		d.val = ai[i];
		V[grp[i]].push(d);
	}
	//for(i=0; i<curg; i++){
	//	sort(V[i].begin(), V[i].end(), cmp);
	//}
	for(i=0; i<curg; i++){
		d = V[i].top();
		V[i].pop();
		d.sz = V[i].size();
		pq.push(d) ;
	}
	for(i=0; i<curg-1; i++){
		d = pq.top();
		pq.pop();
		if(pq.empty() )
			return 0;
		d2 = pq.top();
		pq.pop();
		res += d.val + d2.val ;
		if(V[grp[d.seq]].size() < V[grp[d2.seq]].size() ){
			j = grp[d.seq];
			k = grp[d2.seq];
			while(!V[j].empty() ){
				d3 = V[j].top();
				V[j].pop();
				V[k].push(d3);
				grp[d3.seq] = k;
			}
		}
		else{
			k = grp[d.seq];
			j = grp[d2.seq];
			while(!V[j].empty() ){
				d3 = V[j].top();
				V[j].pop();
				V[k].push(d3);
				grp[d3.seq] = k;
			}
		}
		if(i==curg-2)
			break;
		if(V[k].empty() )
			return 0;
		d = V[k].top();
		V[k].pop();
		d.sz = V[k].size();
		pq.push(d) ;
		/*if(curV[grp[d.seq] ] < V[grp[d.seq]].size()){
			d3.seq = V[grp[d.seq]][ curV[grp[d.seq] ] ];
			d3.val = ai[d3.seq];
			pq.push(d3) ;
		}
		if(curV[grp[d2.seq] ] < V[grp[d2.seq]].size()){
			d3.seq = V[grp[d2.seq]][ curV[grp[d2.seq] ] ];
			d3.val = ai[d3.seq];
			pq.push(d3) ;
		}*/
	}
	return 1;
}

int main()
{
	//freopen("in.txt", "r", stdin);
	int i;
	scanf("%d%d", &N, &M);
	for(i=0; i<N; i++)
		scanf("%d", &ai[i]);
	for(i=0; i<M; i++){
		scanf("%d%d", &x, &y);
		G[x].push_back(y);
		G[y].push_back(x);
	}
	if(solve() == 0)
		printf("Impossible\n");
	else
		printf("%lld\n", res);
	return 0;
}

Measured memory_bytes: 12408
#include <bits/stdc++.h>
using namespace std;
#define rep(i,e) for(int i= 0; i< (int)(e); i++)
#define reps(i,s,e) for (int i = s; i < (int)(e); i++)
#define repr(i,s,e) for(int i = s; i > (int)(e); i--)
typedef long long ll;
long bigp = 1000000007;

int main(){
    int h,w;
    cin >> h >> w;
    vector<vector<int>> v(h+1, vector<int>(w+1));
    vector<vector<int>> ans(h+1, vector<int>(w+1));
    rep(i,h){
        string s;
        cin >> s;
        rep(j,w){
            if(s[j]=='.'){
                v[i][j]=1;
            }
        }
        v[i][w]=0;
    }
    rep(j,w+1){v[h][j]=0;}

    rep(j,w){
        int start = -1;
        rep(i,h+1){
            if(v[i][j]==0){
                //ans[i][j]+=0;
                reps(k,start+1,i){
                    ans[k][j] += i-start-1;
                }
                start = i;
            }
        }
    }
    rep(i,h){
        int start = -1;
        rep(j,w+1){
            if(v[i][j]==0){
                //ans[i][j]=0;
                reps(k,start+1,j){
                    ans[i][k] += j-start-1;
                }
                start = j;
            }
        }
    }
    int ansmax = 0;
    rep(i,h){
        rep(j,w){
            if(ans[i][j] > ansmax){
                ansmax = ans[i][j];
            }
        }
    }
    cout << ansmax - 1;
}


Measured memory_bytes: 31744
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;	

int main() {
    int n; cin >> n;
    cout << (n + 1) / 2 << endl;
}


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

int main() {
  int a[5];
  while(cin >> a[0] && a[0]) {
    for(int i=1; i<5; i++) cin >> a[i];
    for(int i=0; i<5; i++) {
      int win = 0, lose = 0;
      for(int j=0; j<5; j++) {
	if(a[i]%3 == a[j]-1) win ++;
	if(a[j]%3 == a[i]-1) lose ++;
      }
      int res;
      if(win && lose == 0) res = 1;
      else if(win == 0 && lose) res = 2;
      else res = 3;
      cout << res << endl;
    }
  }
  
  return 0;
}

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

using namespace std;

int n, a[20200], b[20200];
int p[20200];

int main () {
	cin >> n;
	for (int i = 1; i <= n; i ++) {
		cin >> p[i];
		a[i] = i * 20200;
		b[i] = (n - i + 1) * 20200;
	}

	for (int i = 1, cur = 0; i <= n; i ++) {
		int j = p[i];
		a[j] += cur;
		++ cur;
	}

	for (int i = 1; i <= n; i ++)
		cout << a[i] << ' ';
	cout << '\n';
	for (int i = 1; i <= n; i ++)
		cout << b[i] << ' ';
}

Measured memory_bytes: 896
// Problem : B - An Odd Problem
// Contest : AtCoder - AIsing Programming Contest 2020
// URL : https://atcoder.jp/contests/aising2020/tasks/aising2020_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define vi vector<int>
#define vll vector<ll> 
#define all(x) (x).begin() , (x).end()
#define inf 1000000000
#define mod 1000000007

void dbg(){
	cerr << endl;
}
template<typename Head , typename... Tail>
void dbg(Head h , Tail... t){
	cerr << h << " ";
	dbg(t...);
}

#ifdef EMBI_DEBUG
#define debug(...) cerr << "(" << #__VA_ARGS__  << "): ", dbg(__VA_ARGS__)
#else 
#define debug(...)
#endif

const int max_n = 1e5 + 9;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
ll power(ll a , ll b)
{
    ll prod = 1;
    while(b)
    {
        if(b&1)
        prod = (prod*a)%mod;
        a = (a*a)%mod;
        b >>= 1;
    }
    return prod;
}
void solve(){
	int n;
	cin >> n;
	
	int a[n];
	int cnt = 0;
	for(int i = 0 ; i < n ; i++){
		cin >> a[i];
		if(a[i] % 2 == 1 && i % 2 == 0){
			cnt++;
		}
	}
	
	cout << cnt << "\n";
}
int main()
{
	speed;
	int t = 1;
	// cin >> t;
	for(int i = 1 ; i <= t ; i++){
		// cout << "Case #" << i << ": ";
		solve();
	}
    return 0;
}

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

typedef long long ll;
typedef int64_t i6;
typedef std::vector<std::vector<int64_t> > Graph;

#define rep(i, n) for (int64_t i = 0; i < n; ++i)
#define rep2(i, n) for (int64_t i = 1; i <= n; ++i)
#define repb(i, l, n) for (int64_t i = l; i < n; ++i)
#define repb2(i, l, n) for (int64_t i = l; i <= n; ++i)
#define ALL(v) (v).begin(), (v).end()
#define Sort(x) sort(ALL(x))
#define Sort_rev(x) Sort(x);reverse(ALL(x))
#define Push_back(p, a, b) (p).push_back( make_pair( (a), (b) ) )

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;  } return 0;  }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;  } return 0;  }
template<typename V,typename T> bool find_num(V v, T num) { if ( find(ALL(v), num) == v.end() ) { return false; } return true; }

int main() {
    string s;
    cin >> s;
    string t;
    cin >> t;
    std::vector<int64_t> v;
    if ( s.length() == t.length() ) {
        if ( s == t ) {
            cout << 0 << endl;
        } else {
            int64_t ans = 0;
            rep(i, s.length()) {
                if (s[i] != t[i]) ans++;
            }
            cout << ans << endl;
        }
        return 0;
    }
    rep(i, s.length()-t.length()) {
        // if ( s.at(i) == t.at(i) ) {
            int64_t num = t.length();
            rep(j, t.length()) {
                if ( s[i+j] == t[j] ) {
                    num--;
                }
            }
            v.push_back(num);
        // }
    }
    if (v.empty()) v.push_back(t.length());
    Sort(v);
    cout << *min_element(ALL(v)) << endl;
    return 0;
}


Measured memory_bytes: 3460
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll n, m;
  cin >> n >> m;
  vector<ll> a(m);
  ll sum = 0;
  REP(i, m) {
    cin >> a[i];
    sum += a[i];
  }

  if (sum > n) {
    cout << -1 << endl;
  } else {
    cout << n - sum << endl;
  }
}

Measured memory_bytes: 3648
use std::io;
use std::cmp;


fn main() {
    let (h, w) = {
        let i = read::<usize>();
        (i[0], i[1])
    };

    let mut ans = 1_000_000_000;
    for &(a, b) in [(h, w), (w, h)].iter() {
        for x in 0..b {
            let sa = a * x;
            let b1 = b - x;
            let sb1 = a * (b1 / 2);
            let sc1 = a * (b1 - b1 / 2);
            let smin1 = cmp::min(sa, cmp::min(sb1, sc1));
            let smax1 = cmp::max(sa, cmp::max(sb1, sc1));
            let sb2 = (a / 2) * b1;
            let sc2 = (a - a / 2) * b1;
            let smin2 = cmp::min(sa, cmp::min(sb2, sc2));
            let smax2 = cmp::max(sa, cmp::max(sb2, sc2));
            ans = cmp::min(ans, cmp::min(smax1 - smin1, smax2 - smin2));
        }
    }
    println!("{}", ans);
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 4352
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		String[] s = stdIn.next().split("");
		boolean flag = true;
		
		
		if(!s[0].equals("A")) {
			flag = false;
		}
		int cnt = 0;
		int tmp = 0;
		for(int i = 2; i < s.length-1; i++) {
			if(s[i].equals("C")) {
				cnt++;
				tmp = i;
			}
		}
		
		if(cnt != 1) {
			flag = false;
		}
		
		for(int i = 1; i < s.length; i++) {
			if(i == tmp) {
				continue;
			}else {
				if(!Character.isLowerCase(s[i].charAt(0))){
					flag = false;
				}
			}
			
		}
			if(flag) {
				System.out.println("AC");
			}else {
				System.out.println("WA");
			}
		
	}

}


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

using LL = long long;

int main() {
  LL N, W;
  cin >> N >> W;
  vector<LL> w(N), v(N);
  for(auto i=0; i<N; ++i) cin >> w[i] >> v[i];

  LL res = 0;
  map<LL, LL> dp;
  dp[0] = 0;
  for(auto i=0; i<N; ++i) {
    auto dup = dp;
    for(auto p: dup) {
      auto x = p.first + w[i];
      auto y = p.second + v[i];
      if(x <= W) res = max(res, dp[x] = max(dp[x], y));
    }
  }
  cout << res << endl;
}


Measured memory_bytes: 640
N = int(input())
a = list(map(int, input().split()))
colors = [False]*8
rainbow = 0
for i in range(N):
    if 1<=a[i]<=399:
        colors[0] = True
    elif 400<=a[i]<=799:
        colors[1] = True
    elif 800<=a[i]<=1199:
        colors[2] = True
    elif 1200<=a[i]<=1599:
        colors[3] = True
    elif 1600<=a[i]<=1999:
        colors[4] = True
    elif 2000<=a[i]<=2399:
        colors[5] = True
    elif 2400<=a[i]<=2799:
        colors[6] = True
    elif 2800<=a[i]<=3199:
        colors[7] = True
    else:
        rainbow += 1
if rainbow == 0:
    ans = colors.count(True)
    print(ans,ans)
else:
    tmp = colors.count(True)
    if tmp==0:# all rainbow
        min_ = 1
        max_ = rainbow
        print(min_,max_)
    else:# rainbow exist
        min_ = colors.count(True)
        max_ = colors.count(True) + rainbow
        print(min_,max_)

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;

namespace Welcome_to_AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var array = Console.ReadLine().Split().Select(_ => int.Parse(_)).ToArray();

            var num = array[0] + array[1];
            if (num % 2 == 0)
            {
                Console.WriteLine(num / 2);
            }
            else
            {
                Console.WriteLine("IMPOSSIBLE");
            }
        }
    }
}


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

int main(){
int n,a=0;cin>>n;
vector<string> g(n),g2(n);r(i,n)cin>>g[i];
r(i,n){
r(j,n)g2[(j+i)%n]=g[j];
int f=1;
r(p,n){r(q,p){if(g2[p][q]!=g2[q][p]){f=0;}}}
if(f)a+=n;
}
cout<<a<<endl;return 0;
}


Measured memory_bytes: 512
import java.util.*;
import java.lang.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
            double N = sc.nextDouble();
            double K = sc.nextDouble();
        sc.close();
        
        double tmp = 0.0;
        double ans = 0.0;

        for(int i = 1 ; i <= N ; i++){
            if(i>=K){
                tmp = N;
                ans += 1/tmp;
            }
            else{
            int p = bekijou(i,K,0);

            tmp = N*bekijou2(2,p);
            ans += 1/tmp;
            //System.out.println(bekijou2(2,p));
            //System.out.println(ans);
            }
        }
        System.out.println(ans);
    }

    static int bekijou(int a,double b,int c){
        if(a < b){
            return bekijou(a*2,b,c+1);
        }
        else{
            return c;
        }
    }

    static int bekijou2(int a,int b){
        if(b==1){
            return a;
        }
        else{
            return bekijou2(a * 2,b-1);
        }
    }
}


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

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int w = sc.nextInt();
        int h = sc.nextInt();
        int[] p = new int[w + 1];
        int[] q = new int[h + 1];
        for (int i= 0; i < w; i ++) {
            p[i] = sc.nextInt();
        }
        p[w] = Integer.MAX_VALUE;

        for (int i= 0; i < h; i ++) {
            q[i] = sc.nextInt();
        }
        q[h] = Integer.MAX_VALUE;
        System.out.println(cal(w, h, p, q));
    }

    private static long cal(final int w, final int h, final int[] p, final int[] q) {
        long mulq = w +1;
        long mulp = h+ 1;
        Arrays.sort(p);
        Arrays.sort(q);
        int pi = 0;
        int qi = 0;
        long res = 0;
        while (pi < w || qi < h) {
            if (p[pi] < q[qi]) {
                res += p[pi] * mulp;
                mulq--;
                pi++;
            } else {
                res += q[qi] * mulq;
                mulp--;
                qi++;
            }
        }
        return res;
    }
}


Measured memory_bytes: 63728
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
def main():
    x, n, *p = map(int, read().split())
    sa = 10000
    r = 10000
    for i1 in range(-101, 202):
        if i1 not in p:
            if abs(x - i1) < sa:
                sa = abs(x - i1)
                r = i1
    print(r)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9140
#include<iostream>
using namespace std;
int main()
{
	int s,t,u,a,N,cnt=0;
	int d[9]={16,2,2,56,2,2,16,2,2};
	cin>>N;
	if(N<357)
	{
		cout<<0<<endl;
		return 0;
	}
	for(int j=-1,i=357;i<=N;i+=d[++j%9])
	{
		
		a=i;
		s=0,t=0,u=0;
		while(a)
		{
			if(a%10==3)s++;
			else if(a%10==5)t++;
			else if(a%10==7)u++;
			else{s=0;break;}
			a/=10;
		}
		if(s*t*u>0)cnt++;
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<P, int> P3;
const ll MOD = ll(1e9)+7;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(1e5 + 5);
const double EPS = 1e-11;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define ALL(v) (v).begin(), (v).end()

int main() {
    int a, b, x;
    while(cin >> a >> b, a){
        x = b-a;
        cout << x%500/100 << " " << x%1000/500 << " " << x/1000 << endl;
    }
    return 0;
}



Measured memory_bytes: 3088
#include<bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
//g++ -std=c++11 

using namespace std;

#define DIV 1000000007

long long modpow(long long ori, long long po){
	long long res = 1;
	while(po > 0){
		if(po&1){
			res *= ori;
			res %= DIV;
		}
		ori *= ori;
		ori %= DIV;
		po >>= 1;
	}
	return res;
}

long long N;
map<long long, long long> memo;
map<long long, long long> A[10005];
long long A2[10005];

void prime_list(long long n, long long idx){
  map<long long, long long> ans;
  for(long long i=2;i*i<=n;++i){
    while(n%i==0){
      ++A[idx][i];
      n=n/i;
    }
  }
  if(n!=1){
    ++A[idx][n];
  }
}


int main(){
	cin >> N;
	rep(i, N) {
		cin >> A2[i];
		prime_list(A2[i], i);
	}

	rep(i, N) {
		for(auto item: A[i]) {
			memo[item.first] = max(memo[item.first], item.second);
		}
	}

	long long tmp = 1;
	for(auto item: memo) {
		 tmp *= modpow(item.first, item.second);
		 tmp %= DIV;
	}

	long long ans = 0;
	rep(i, N) {
		ans += tmp * modpow(A2[i], DIV - 2);
		ans %= DIV;
	}
	cout << ans << endl;
}


Measured memory_bytes: 7116
#include<stdio.h>
#include<math.h>
#define N 10000
main()
{
  int i,j,s,c=0,f=0,a[N];
  scanf("%d",&s);
  for(i=0;i<s;i++){
    scanf("%d",&a[i]);
  }
    for(i=0;i<s;i++){
      for(j=2;j<=sqrt(a[i]);j++){
	if(a[i]%j==0){
	  f=1;
	  break;
	}
      }
	if(f==0) c++; 
      f=0;
    }
    printf("%d\n",c);
  return 0;
}

Measured memory_bytes: 628
IDENTIFICATION  DIVISION.
        PROGRAM-ID.      christmas.
      *
        ENVIRONMENT    DIVISION.
      *
        DATA           DIVISION.
        WORKING-STORAGE SECTION.
        77  NUM         PIC 9(2).
      *
        PROCEDURE       DIVISION.
        MAIN.
        ACCEPT  NUM     FROM CONSOLE.
        IF NUM = 25 THEN
            DISPLAY "Christmas"  UPON CONSOLE
        ELSE IF NUM = 24 THEN
            DISPLAY  "Christmas Eve" UPON CONSOLE
        ELSE IF NUM = 23 THEN
            DISPLAY  "Christmas Eve Eve" UPON CONSOLE
        ELSE IF NUM = 22 THEN
            DISPLAY  "Christmas Eve Eve Eve" UPON CONSOLE  
        END-IF 
        END-IF
        END-IF.
        STOP RUN.


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


using namespace std;

int main()
{
    int a,b;

    vector<int> result;

    int temp = 0;
    while(cin >> a >> b){
        if(a == 0 && b == 0){
            break;
        }
        temp = 0;
        for (int c = 1; c <= a; ++c) {
            for (int d = c + 1; d <= a; ++d) {
                for (int e = d + 1; e <= a; ++e) {
                    if(c + d + e == b){
                        ++temp;
                    }
                }
            }
        }
        result.push_back(temp);
    }

    for(auto re : result){
        cout << re << endl;
    }

    return 0;
}

Measured memory_bytes: 3124
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;
#include<algorithm>
#include<math.h>
#include<map>
#include<queue>

int main() {
	int n, k, q;
	cin >> n >> k >>q;
	vector<int>a(n,k);
	rep(i, q) {
		int buffer;
		cin >> buffer;
		--buffer;
		a[buffer]+=1;
	}
	rep(i, n) {
		a[i] -= q;
	}
	rep(i, n) {
		if (a[i] <= 0) {
			cout << "No" << endl;
		}
		else {
			cout << "Yes" << endl;
		}
	}
	return 0;
}

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

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y
//#define CPP_STR(x) CPP_STR_I(x)
//#define CPP_STR_I(args...) #args
//#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
//using f80 = __float80;

constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
constexpr char EL[] = "\n";

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(),(x).end()
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
#define UNIQUE(x) (x).erase(unique(all(x)), (x).end());
#define REPIT(x) for(auto it=(x).begin(), end=(x).end(); it!=end; ++it)
#define perm(c) sort(all(c)); for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<typename T = i64>
T IN() { T x; cin >> x; return (x); }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
	if (comp(xmax, x)) {
		xmax = x;
		return true;
	}
	return false;
}
template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
	if (comp(x, xmin)) {
		xmin = x;
		return true;
	}
	return false;
}

void print() {
  cout << EL;
}
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  cout << head;
  if (sizeof...(tail) != 0) cout << " ";
  print(forward<Tail>(tail)...);
}
template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
	cout << a;
	if (&a != &vec.back()) cout << " ";
  }
  cout << EL;
}
template <class T>
void print(vector<vector<T>> &df) {
  for (auto& vec : df) {
	print(vec);
  }
}

struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;
#pragma endregion

signed solve()
{
	int s5 = 0, s7 = 0;
	REP(i, 3)
	{
		int a;
		cin >> a;
		if (a == 5)
			s5++;
		else if (a == 7)
			s7++;
	}
	if (s5 == 2 && s7 == 1)
		print("YES");
	else
		print("NO");
	return 0;
}

#ifndef LOCALCODE
signed main()
{
	return solve();
}
#endif


Measured memory_bytes: 256
n1,n2,n3,n4,n5,n6=map(int,input().split())
char=input()
up=n1
bottom=n6
front=n2
back=n5
left=n4
right=n3
for i in range(len(char)):
	if char[i]=="S":
		t=up
		up=back
		back=bottom
		bottom=front
		front=t
	if char[i]=="E":
		t=up
		up=left
		left=bottom
		bottom=right
		right=t
	if char[i]=="W":
		t=up
		up=right
		right=bottom
		bottom=left
		left=t
	if char[i]=="N":
		t=up
		up=front
		front=bottom
		bottom=back
		back=t
print(up)


Measured memory_bytes: 5596
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;


class Program
{
    static void Main(string[] args)
    {
        // 入力
        //var s = Console.ReadLine();
        //var n = long.Parse(Console.ReadLine());
        decimal[] nk = Console.ReadLine().Split().Select(decimal.Parse).ToArray();
        var n = nk[0];
        var k = nk[1];

        decimal ans = 0;
        if (n == 0)
        {
            ans = 0;
        }
        else if (n >= k && n % k == 0)
        {
            ans = 0;
        }
        else if (n < k && k % n == 0)
        {
            ans = n;
        }
        else
        {
            ans = Math.Min(Math.Abs((n % k)),Math.Abs((n % k) -k));
        }
        // 出力
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 11348
#include<bits/stdc++.h>
#define int long long
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define all(a) (a).begin(),(a).end()
#define X first
#define Y second
#define Max 1000
using namespace std;
const int N=3005;
double dp[N],p[N];
double ans;
void solve()
{
   int n; cin>>n;
   for(int i=0;i<n;i++)cin>>p[i];
   dp[0]=1;
   for(int i=0;i<n;i++)
   {
       for(int j=n/2;j>=0;j--)
       {
           if(j)dp[j]=dp[j-1]*(1-p[i])+dp[j]*p[i];
           else dp[j]=dp[j]*p[i];
       }
   }
   for(int i=0;i<=n/2;i++)ans+=dp[i];
   printf("%0.9f",ans);
   return;
}
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t; t=1;
    while(t--)solve();
    return 0;
}


Measured memory_bytes: 3856
#include <stdio.h>

int main()
{

 int a, b, d, r;
 double f;
 scanf("%d %d\n", &a, &b);
 d = a / b;
 r = a % b;
 f = (double)a / b;
 printf("%d %d %f\n", d, r, f);
 return 0;

}

Measured memory_bytes: 640
#include "bits/stdc++.h"

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back
#pragma GCC optimize ("-O3")

using namespace std;

// #define DEBUG_IS_VALID

#ifdef DEBUG_IS_VALID
#define DEB 1 
#else
#define DEB 0
#endif
#define DUMPOUT cout
#define dump(...) if(DEB) DUMPOUT<<"  "<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl<<"    "; if(DEB) dump_func(__VA_ARGS__)
template<typename T1,typename T2>ostream& operator << (ostream& os, pair<T1,T2> p){cout << "(" << p.first << ", " << p.second << ")"; return os;}
template<typename T>ostream& operator << (ostream& os, vector<T>& vec) { os << "{"; for (int i = 0; i<vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : ", "); os << "}"; return os; }
template<typename T>ostream& operator << (ostream& os, set<T>& st){for(auto itr = st.begin(); itr != st.end(); itr++) cout << *itr << (next(itr)!=st.end() ? ", " : ""); cout << "}"; return os;}
template<typename T1,typename T2>ostream& operator << (ostream& os, map<T1,T2> mp){cout << "{"; for(auto itr = mp.begin(); itr != mp.end(); itr++) cout << "(" << (itr->first) << ", " << (itr->second) << ")" << (next(itr)!=mp.end() ? "," : ""); cout << "}"; return os; }

void dump_func(){DUMPOUT << endl;}
template <class Head, class... Tail>void dump_func(Head&& head, Tail&&... tail){ DUMPOUT << head; if (sizeof...(Tail) == 0) { DUMPOUT << " "; } else { DUMPOUT << ", "; } dump_func(std::move(tail)...);}
template<class T> inline bool chmax(T& a,T const& b){if(a>=b) return false; a=b; return true;}
template<class T> inline bool chmin(T& a,T const& b){if(a<=b) return false; a=b; return true;}

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

const int mod=1e9+7,INF=1<<29;
const double EPS=1e-12,PI=3.1415926535897932384626;
const ll lmod = 1e9+7,LINF=1LL<<59; 

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N; cin >> N ;
  vl a(N+1);
  rep(i,N){
    cin >> a[i] ;
  }
  ll ans = 0;
  rep(i,N){
    ans += a[i]/2;
    if(a[i]%2){
      if(a[i+1]==0) continue;
      ans++;
      a[i+1]--;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define int long long
bool f;
int n, i, j;
int card[9];

bool judge (int a, int b, int c){
        if (a == b && b == c) return true;
        else if (a + 1 == b && a + 2 == c) return true;
        return false;
}
int win(){
        sort(card, card + 9);
        do{
                f = 1;
                f = judge(card[0], card[1], card[2]);
                if (f == true) f = judge(card[3], card[4], card[5]);
                if (f == true) f = judge(card[6], card[7], card[8]);
                if (f == 1) return 1;
        }while (next_permutation(card, card+9));
        return 0;
}

signed main(){
        cin >> n;
        string color;
        for (i = 0; i < n; i++){
                for (j = 0; j < 9; j++){
                        cin >> card[j];
                }
                for (j = 0; j < 9; j++){
                        cin >> color;
                        if (color == "G") card[j] += 10;
                        else if (color == "B") card[j] += 20;
                }
                int ans = win();
                cout << ans << endl;
                /*sort(card, card + 9);
                f = true;
                f = judge(card[0], card[1], card[2]);
                if (f == true) f = judge(card[3], card[4], card[5]);
                if (f == true) f = judge(card[6], card[7], card[8]);
                cout << (f ? 1 : 0) << endl;*/
        }
        return 0;
}



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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


const ll MOD = (ll)(1e9 + 7);
int nextInt() { int x; scanf("%d", &x); return x;}

const int SZ = 312345;
ll inv[SZ];
ll fact[SZ];
ll fact_inv[SZ];
ll choose(int n, int r) {
  if (n < 0 || r < 0 || n < r) return 0;
  return fact[n] * fact_inv[n-r] % MOD * fact_inv[r] % MOD;
}

int main2() {
  int N = nextInt();
  int M = nextInt();

  ll ans = 1;
  for (int d = 2; d * d <= M; d++) {
    int c = 0;
    while (M % d == 0) {
      c++;
      M /= d;
    }
    if (c > 0) {
      ans = (ans * choose(N+c-1, N-1)) % MOD;
    }
  }
  if (M > 1) {
    ans = (ans * N) % MOD;
  }
  cout << ans << endl;
  return 0;
}

int main() {

{
  inv[1] = 1;
  for (int i = 2; i < SZ; i++) inv[i] = inv[(int) (MOD % i)] * (MOD - MOD / i) % MOD;
  fact[0] = 1;
  for (int i = 1; i < SZ; i++) fact[i] = fact[i-1] * i % MOD;
  fact_inv[0] = 1;
  for (int i = 1; i < SZ; i++) fact_inv[i] = fact_inv[i-1] * inv[i] % MOD;
}

  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


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

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<vector<int>> d(n, vector<int>(2));
    for (int i = 0; i < n; i++) {
        cin >> d[i][0];
        cin >> d[i][1];
    }

    int count = 0;
    for (int i = 0; i < n; i++) {
        if (d[i][0] == d[i][1]) {
            count++;
        } else {
            count = 0;
        }
        if (count >= 3) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;

    return 0;
}

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

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define ALLTRUE(xs) all_of(ALL(xs),[](bool x){return x;})
#define AND(x,y,z) set_intersection((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define ANYTRUE(xs) any_of(ALL(xs),[](bool x){return x;})
#define CONCAT(x,y) (x).insert((x).end(),(y).begin(),(y).end())
#define DUMP(xs) for (auto x:xs) cout<<x<<' ';cout<<endl
#define FOR(i,a,b) for (int i=(int)(a);i<(int)(b);++i)
#define OR(x,y,z) set_union((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define OUT(x) cout<<x<<endl
#define REP(i,n) FOR(i,0,n)

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

struct edge { int to,cost; };

int main() {
  ll N,M;cin>>N>>M;
  // cが4つか、S1つc2つでペア一つ
  // Sで出来るだけペアを作ってからのこりのcで作る感じ

  // Sが圧倒的に多い場合
  if (N*2>=M) {
    OUT(M/2);
    return 0;
  }
  ll res = N;
  M -= 2*N;
  res += M/4;
  OUT(res);

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  int N;  cin >> N;
  vector<ll> A(N); 
  for(int i = 0; i < N; i++){ cin >> A[i]; 
                    if(A[i] > i){ cout << -1 << endl; return 0;}}
  
  for(int i = 0; i < N-1; i++){
    if( A[i+1]-A[i] >= 2){ cout << -1 << endl; return 0;}}
  
  ll cnt = 0;
  for(int i = N-2; i >= 0; i--){
    //狭義単調増加（後ろ向きに狭義単調減少）となっているかを調べる
    if( A[i+1] > A[i]){ continue;}
    else{ //この時,A[i+1]はA[i]とは別に作らなければならない
      cnt += A[i];}
  }
  cnt += A[N-1];
  cout << cnt << endl; return 0;}
    
  

Measured memory_bytes: 1792
import java.io.*;
import java.util.*;

public class Main {
	public static void main(String[] args) throws IOException{
		Scanner sc=new Scanner(System.in);
		Reader reader=new Reader();
		int t=1;//sc.nextInt();
		while(t-->0) {
			int n=reader.nextInt();
			int[] arr=reader.intArray();
			int g=arr[0];
			for(int i=0;i<n;i++) {
				g=gcd(g,arr[i]);
			}
			if(g>1) {
				System.out.println("not coprime");
				return;
			}
			HashSet<Integer> out=new HashSet<>();
			for(int i:arr) {
				HashSet<Integer> in=new HashSet<>();
				while(i%2==0) {
					i/=2;
					in.add(2);
				}
				for(int f=3;f*f<=i;f+=2) {
					while(i%f==0) {
						i/=f;
						in.add(f);
					}
				}
				if(i>1) in.add(i);
				for(int iel:in) {
					if(out.contains(iel)) {
						System.out.println("setwise coprime");
						return;
					}
				}
				out.addAll(in);
			}
			System.out.println("pairwise coprime");
		}
	}
	static int gcd(int a,int b) {
		if(a==0) return b;
		return gcd(b%a,a);
	}
}
class Reader{
	BufferedReader reader;
	Reader(){
		reader=new BufferedReader(new InputStreamReader(System.in));
	}
	int nextInt() throws IOException{
		String in=reader.readLine().trim();
		return Integer.parseInt(in);
	}
	long nextLong() throws IOException{
		String in=reader.readLine().trim();
		return Long.parseLong(in);
	}
	String next() throws IOException{
		return reader.readLine().trim();
	}
	String[] stringArray() throws IOException{
		return reader.readLine().trim().split("\\s+");
	}
	int[] intArray() throws IOException{
		String[] inp=this.stringArray();
		int[] arr=new int[inp.length];
		int i=0;
		for(String s:inp) {
			arr[i++]=Integer.parseInt(s);
		}
		return arr;
	}
}


Measured memory_bytes: 138928
#include <cstdint>
#include <iostream>
#include <vector>

using namespace std;

int main() {
  int64_t N;
  cin >> N;
  vector<int64_t> nums(N);
  cin >> nums[0];
  int64_t base = nums[0];
  for (int64_t n = 1; n < N; ++n) {
    cin >> nums[n];
    base ^= nums[n];
  }
  cout << (base ^ nums[0]);
  for (int64_t n = 1; n < N; ++n) {
    cout << " " << (base ^ nums[n]);
  }
  cout << endl;
  
  return 0;
}


Measured memory_bytes: 4812
import java.util.*;
import java.io.PrintWriter;
public class Main{
	static long ans;
	static int l;
	static int k;
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		k=sc.nextInt();
		for(int j=1; j<=10; j++){
			for(int i=1; i<=9; i++){
				l=j;
				dfs(i,i,1);
			}
		}
		System.out.println(ans);
	}
	static void dfs(long t,int last,int len){
		if(len==l){
			k--;
			if(k==0){
				ans=t;
			}
			return;
		}
		for(int i=0; i<10; i++){
			if(Math.abs(i-last)<2){
				dfs(t*10+i,i,len+1);
			}
		}
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
         
typedef long long ll;
using namespace std;
        
#define F first
#define S second
#define sqr(x) x*x
#define pb push_back
#define mp make_pair
#define sz(x) ((int) (x).size())
#define all(x) (x).begin(), (x).end()
#define allr(x) (x).rbegin(), (x).rend()
#define repit(i, n) for(auto it = n.begin(); it != n.end(); ++it)
       
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b){if(b==0)return a;else return gcd(b,a%b);}
int lcm(int a,int b){return abs(a*b)/gcd(a,b);}
          
bool comp(pair<string, int> a, pair<string, int> b){
    return a.S < b.S;
}

int main(){ios_base::sync_with_stdio(0);cin.tie(0);
    int n;
    cin >> n;
    for(int i = 1 ; ; ++i){
        if((i * i) > n){
            cout << (i - 1) * (i - 1);
            break;
        }
    }
}


Measured memory_bytes: 256
package main

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

type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func main() {
	sc := NewScanner()
	N := sc.nextInt()
	P := sc.nextIntSlice(N)
	count := 0
	for i, n := range P {
		if n != i+1 {
			count++
		}
	}
	if count <= 2 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


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


int partition(vector<int> &A, int p, int r){
    int x = A[r];
    int i = p-1; int j = p-1;
    while(j<r){
        // ポインタが加算する形で比較するときはポインタの場所で比較すべき。
        if(A[j+1]>x)++j;
        else{
            swap(A[i+1],A[j+1]);
            ++i;++j;
        }
    }
    swap(A[i+1],A[r]);
    return i+1;
}

int partition_ans(vector<int> &A, int p, int r){
    int x = A[r];
    int i = p-1; int j = p;
    while(j<r){
        // ポインタが加算する形で比較するときはポインタの場所で比較すべき。
        if(A[j]<=x){
            swap(A[i+1],A[j]);
            ++i;
        }
        ++j;
    }
    swap(A[i+1],A[r]);
    return i+1;
}



int main(){
    int n;
    cin >> n;
    vector<int>a(n);
    rep(i,n)cin>>a[i];
    int r = partition_ans(a, 0, n-1);
    rep(i,n){
        if(i)cout<<" ";
        if(i==r)cout<<"[";
        cout<<a[i];
        if(i==r)cout<<"]";
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 3136
N, K = map(int,input().split())
p = list(map(int,input().split()))

S = 0
maxsum = 0
for i in range(K):
    S += (p[i]+1)/2

for i in range(K,N):
    if(maxsum < S):
        maxsum = S
    S = S + (p[i]+1)/2 - (p[i-K]+1)/2

if(maxsum < S):
    maxsum = S

print(maxsum)



Measured memory_bytes: 25060
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>

using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;

int main() {
  int ans = 0, N;
  cin>>N;
  vector<int> h(N);
  REP(i,N) cin>>h[i];
  REP(i,N) {
    bool ok = true;
    for(int j =	i-1; j >= 0; j--) {
      if(h[j]>h[i]) {
	ok = false; break;
      } 
    }
    if(ok) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <algorithm>
#include <ctime>
#include <vector>
#include <set>
#include <queue>
using namespace std;
typedef long long ll;

#define PI 3.14159265358979323846264338327950L

int res;

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

    int N;
    cin >> N;
    vector<int> A(N);
    for(int i = 0; i < N-1; i++ )
    {
        cin >> A[i];
    }
    vector<int> boss(N, 0);
    for (int i = 0; i < N-1; i++)
    {
        boss[A[i]-1]++;
    }
    for(int i = 0; i < N; i++ )
    {
        cout << boss[i] << endl;
    }
    return 0;
}

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

int main(){
    int n;
    cin >> n;
    int subOrd[n];
    for(int i=0; i < n; i++){
        subOrd[i] = 0;
    }
    for(int k = 0; k < n-1; k++){
        int t;
        cin >> t;
        subOrd[t-1]+=1;
    }
    for(int j = 0; j < n; j++){
        cout << subOrd[j] << endl;
    }
    return 0;
}


Measured memory_bytes: 4404
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<string>
#include<algorithm>
using namespace std;

int main(){
    int abcd;
    cin >> abcd;
    int a, b, c, d;
    a = abcd / 1000;
    b = abcd % 1000 / 100;
    c = abcd % 100 / 10;
    d = abcd % 10;
    bool op1(true), op2(true), op3(true); // true = +, false = -
    bool found(false);
    vector<int> sign = {-1, +1};
    for(int i = 0; i < 2; ++i) {
        for(int j = 0; j < 2; ++j) {
            for(int k = 0; k < 2; ++k) {
                if(a + sign[i]*b + sign[j]*c + sign[k]*d == 7) {
                    found = true;
                    op1 = bool(i);
                    op2 = bool(j);
                    op3 = bool(k);
                }
            }
        }
    }
    if(found) {
        cout << to_string(a) + (op1? "+":"-") + to_string(b) + (op2? "+":"-") + to_string(c) + (op3? "+":"-") + to_string(d) + "=7" << endl;
    }
    else{
        cout << "error" << endl; // shouldn't reach here
    }
    return 0;
}

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

public class Main {

    long MOD = (long) 1e9 + 7;

    void run() {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int[] a = new int[n + 1];
        int[] exists = new int[n + 1];
        Arrays.fill(exists, -1);
        int l = -1, r = -1;

        Combination comb = new Combination(n + 10, MOD);

        for (int i = 0; i <= n; i++) {
            a[i] = sc.nextInt();
            if (exists[a[i]] >= 0) {
                l = exists[a[i]];
                r = i;
            }
            exists[a[i]] = i;
        }

        int ans = 1;
        for (int k = 1; k <= n; k++) {
            System.out.println((comb.nck(n, k) + calc(n, k, l, r, comb)) % MOD);
        }
        System.out.println(1);

    }

    long calc(int n, int k, int l, int r, Combination comb) {
        long ret = (comb.nck(n - 1, k - 1) - comb.nck(n - (r - l), k - 1) + MOD) % MOD;
        if (k - 2 >= 0) ret = (ret + comb.nck(n - 1, k - 2)) % MOD;
        return ret;
    }

    class Combination {
        int n;
        long mod;
        long[] facts;

        public Combination(int n, long mod) {
            this.n = n;
            this.mod = mod;
            facts = new long[n];
            facts[0] = 1;
            for (int i = 1; i < n; i++) {
                facts[i] = facts[i - 1] * i % mod;
            }
        }

        long modpow(long a, long b) {
            if (b == 0) return 1;
            else if (b == 1) return a;

            long x = modpow(a, b / 2);
            return b % 2 == 0 ? x * x % mod : x * (x * a % mod) % mod;
        }

        long inv(long n) {
            return modpow(n, mod - 2);
        }

        public long nck(int n, int k) {
            return n < k ? 0 : facts[n] * (inv(facts[n - k]) * inv(facts[k]) % mod) % mod;
        }
    }


    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

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

}


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

int main(){
    int n;
    cin >> n;
    vector<ll> a(n, 0);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    ll sum = 0, ans = 0, ans2 = 0;
    for(int i = 0; i < n; i++){
        sum += a[i];
        if(i%2 == 0){
            if(sum <= 0){
                ans += 1 - sum;
                sum = 1;
            }
        }
        else{
            if(sum >= 0){
                ans += 1 + sum;
                sum = -1;
            }
        }
    }
    sum = 0;
    for(int i = 0; i < n; i++){
        sum += a[i];
        if(i%2 == 0){
            if(sum >= 0){
                ans2 += 1 + sum;
                sum = -1;
            }
        }
        else{
            if(sum <= 0){
                ans2 += 1 - sum;
                sum = 1;
            }
        }
    }
    cout << min(ans, ans2) << endl;
}

Measured memory_bytes: 4044
#include <iostream>

#define N 101

using namespace std;

int main(void) {
	int i, count;
	int a, b, c;
	int penki[N];
	// get input -----------------------------
	cin >> a >> b >> c;
	// init penki ----------------------------
	for (i = 0; i < N; i++) {
		penki[i] = 0;
	}
	// buy penki -----------------------------
	penki[a]++;
	penki[b]++;
	penki[c]++;
	// count penki ---------------------------
	count = 0;
	for (i = 0; i < N; i++) {
		if (penki[i] != 0) {
			count++;
		}
	}
	// disp answer ---------------------------
	cout << count << endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i ,n) for(int i = 0 ; i < (n) ; i ++ )
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

int main() {
  int h,w,a,b;
  cin>>h>>w>>a>>b;
  cout<<(h-a)*(w-b)<<endl;
}







Measured memory_bytes: 256