akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define REP(i, n) for(decltype(n) i = 0; i < n; i++)

#define ALL(c)   c.begin(), c.end()
#define SORT(c)  std::sort(ALL(c))
#define RSORT(c) std::sort(ALL(c), std::greater<decltype(c)::value_type>())

using namespace std;
using ll = long long;

const int MOD  = (int)1e9 + 7;
const int INF  = (int)1e9 + 1;
const ll  LINF = (ll)1e18 + 1;

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

    while(true) {
        int N;
        std::cin >> N;
        if(N == 0) break;

        vector<char> C(N);
        REP(i, N) {
            std::cin >> C[i];
        }

        vector<int> table(30);
        pair<char, int> f, s;
        REP(i, N) {
            table[C[i] - 'A']++;
            if(f.second < table[C[i] - 'A']) {
                f = make_pair(C[i], table[C[i] - 'A']);
            }
            else if(s.second < table[C[i] - 'A']) {
                s = make_pair(C[i], table[C[i] - 'A']);
            }
            if(s.second <= i - (N - f.second)) {
                std::cout << f.first << " " << i + 1 << std::endl;
                break;
            }
        }
        if(f.second == s.second) {
            std::cout << "TIE" << std::endl;
        }
    }

    return 0;
}


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

int main()
{
    string s,t,z;
    cin>>s>>t;
    int n=s.length();
    int m=t.length();
    z=t.substr(0,n);
    int x=z.compare(s);

    if(x==0 && (m-n)==1)
        cout<<"Yes";
    else
        cout<<"No";

    return 0;
}


Measured memory_bytes: 3628
#include <stdio.h>
#include <string.h>

#define N 10

char s[] = "ATCG";

int main() {
	static char cc[N + 1];
	int n, i, cnt, max;

	scanf("%s", cc);
	n = strlen(cc);
	max = cnt = 0;
	for (i = 0; i < n; i++)
		if (max < (cnt = strchr(s, cc[i]) ? cnt + 1 : 0))
			max = cnt;
	printf("%d\n", max);
	return 0;
}


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

int main(int argc, const char * argv[]) {
    uint64_t N;
    cin >> N;
    
    vector<string> Si;
    for (uint64_t i = 0; i < N; i++) {
        string tmp;
        cin >> tmp;
        sort(tmp.begin(), tmp.end());
        Si.push_back(tmp);
    }
    
    sort(Si.begin(), Si.end());

    uint64_t count = 0;
    for (uint64_t i = 0; i < N - 1; i++) {
        uint64_t match = 0;
        for (uint64_t j = i+1; j < N; j++) {
            if (Si[i] == Si[j]) {
                match++;    // matchした回数を記録。
                
                if (j == (N - 1)) {
                    i = j - 1;  // 最後の文字列まで行った場合、更新してっ次のループに入らないようにする。
                }
            }else {
                i = j-1; // 次はjを基準に文字列比較をする。次のループ開始時に+1されてしまうので、予め-1しておく。
                break;
            }
        }
        
        for (uint64_t k = 1; k <= match; k++) {
            count += k; // 総和を計算。
        }
    }
    
    cout << count << endl;
    
    return 0;
}

Measured memory_bytes: 4468
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n=nxt(),m=nxt();
    vector <pair<int,int> > v(n);
    for(int i=0;i<n;i++)
        cin>>v[i].second>>v[i].first;
    set <int> s;
    for(int i=1;i<=m;i++)
        s.insert(i);
    ll test=0;
    sort(all(v));
    for(int i=n-1;i>=0;i--)
    {
        auto it=s.lower_bound(v[i].second);
        if(it!=s.end())
        {
            test+=v[i].first;
            //cout<<v[i].first<<" "<<v[i].second<<" "<<*it<<endl;
            s.erase(it);
        }
    }
    cout<<test<<endl;

    
    
    
    return 0;   
}


 
 


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

using namespace std;

int n;
int a;
int ch[200010];

int main(void)
{
	scanf("%d", &n);
	
	for(int i = 1 ; i < n ; i++)
	{
		scanf("%d", &a);
		ch[a]++;
	}
	
	for(int i = 1 ; i <= n ; i++)
		printf("%d\n", ch[i]);
	
	return 0;
}

Measured memory_bytes: 4496
use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: u64 = itr.next().unwrap().parse().unwrap();

    // Σを別の視点で➡ある約数xにより増える総和の総和をとる
    let mut ans = 0;
    for i in 1..=n {
        let m = n / i;
        ans += (m + 1) * m / 2 * i;
    }
    println!("{}", ans);
}


Measured memory_bytes: 2168
#include <iostream>
#include <queue>
#include <map>
#include <deque>
#include <algorithm>
#include <set>
#include <string>
#include <math.h>
#include <stdio.h>
#include<iomanip>


#define ll long long
using namespace std;
//const ll MOD = (int) 10e9 + 7;

/*ll dp[100001];
vector<vector<ll>>adj;
ll dfs(ll node)
{
    if (dp[node] != -1)
        return dp[node];

    ll ans = 0;
    for (int i = 0; i < adj[node].size(); i++)
    {
        ans = max(dfs(adj[node][i]) + 1, ans);

    }
    return dp[node] = ans;
}
*/
ll factorial(ll n)
{
    if (n == 1 || n == 0)
        return 1;

    return n * factorial(n - 1);
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,m;
    cin >> n >> m;
    char chr[n][m];
    ll dp[n][m];
    for (ll i = 0; i < n; i++){
        for (ll j = 0; j < m; j++)
        {
            cin >> chr[i][j];
            dp[i][j] = 0;
        }
    }



    dp[0][0] = 1;

    for (ll i = 0; i < n; i++)
    {
        for (ll j = 0; j < m; j++)
        {
            if (chr[i][j] == '#')continue;
            if (i - 1 >= 0)
                dp[i][j] = (dp[i - 1][j] % 1000000007);
            if (j - 1 >= 0)
                dp[i][j] = ((dp[i][j - 1] % 1000000007) + dp[i][j])%1000000007;
        }
    }

    cout << dp[n - 1][m - 1]%1000000007;
    return 0;
}


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

int main()
{
    string s,t;
    cin>>s>>t;
    int p = 0;
    for (int i = 0;i < 3;i++) {
            if(s.at(i) == t.at(i)){
                p+=1;
            }else{
                p+=0;

        }
    }
    cout<<p<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)
#define all(v) (v).begin(), (v).end()
#define eb emplace_back

int main(){
    int N;
    cin >> N;
    valarray<i64> A(N), B(N);
    rep(i, N) cin >> A[i];
    rep(i, N) cin >> B[i];

    i64 can_ope = B.sum() - A.sum();
    i64 need = (B - A).apply([](i64 x){return max((x+1)/2, 0l);}).sum();

    if(can_ope >= need) cout << "Yes" << endl;
    else cout << "No" << endl; 
}


Measured memory_bytes: 512
import sys
def input():
    return sys.stdin.readline()[:-1]
inf=float("inf")
n,k=map(int,input().split())
s=input()
cnt=[]
tmp=[1,s[0]]
for i in range(1,n):
    if s[i]==tmp[1]:
        tmp[0]+=1
    else:
        cnt.append(tmp[0])
        tmp=[1,s[i]]
cnt.append(tmp[0])
# print(cnt)
ans=sum(cnt[:1+2*k])
left=0
right=0
for i in range(len(cnt)-1-2*k):
    right+=cnt[1+2*k+i]-1
# print(right)
tmp=left+ans+right
for i in range(len(cnt)-1-2*k):
    tmp1=left+ans+right
    left+=cnt[i]-1
    ans+=cnt[i+1+2*k]-cnt[i]
    right-=cnt[i+1+2*k]+1
    if tmp1<left+ans+right:
        tmp=left+ans+right
print(tmp-1)

Measured memory_bytes: 45292
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin, (x).rend()
#define endl '\n'
#define first F
#define second S
typedef long long ll;

int main(){
	int n; cin>>n;
	int dish[n];
	map<int, int> B;
	map<int, int> C;
	for(int i=0; i<n; i++){
		cin>>dish[i];
	}
	for(int i=0; i<n; i++){
		int x; cin>>x;
		B[i+1]=x;
	}
	for(int i=0; i<n-1; i++){
		int x; cin>>x;
		C[i+1]=x;
	}
	int rta=0;
	for(int i=0; i<n-1; i++){
		rta+=B[dish[i]];
		if(dish[i+1]-dish[i] == 1){
			rta+=C[dish[i]];
		}
	}
	cout<<rta+B[dish[n-1]]<<endl;
}


Measured memory_bytes: 3568
#include <iostream>
#include <cstring>
#include <map>

using namespace std;

int n;
int ans=0;
char s[100+10];
map<char,int>mp;

int main()
{
    cin>>n;
    cin>>s;
    for(int i=1;i<n;i++)
    {
        int num=0;
        for(int j=0;j<=i;j++) mp[s[j]]++;
        for(int j=i+1;j<n;j++)
        {
            if(mp[s[j]]) {
                    num++;
                    mp[s[j]]=0;
            }
        }
        ans=max(num,ans);
        mp.clear();
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {

	string s; cin >> s;
	
	bool f = true;
	for (int i = 0; i < s.size(); i++) {
		char c = s[i];
		if (i % 2 == 1 && c=='R') {
			f = false;
		}

		if (i % 2 == 0 && c == 'L') {
			f = false;
		}
		
	}

	if (f) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}


	return 0;
}

Measured memory_bytes: 256
n = int(input())
A = [0]*n
B = [0]*n

for i in range(n):
    a, b = map(int, input().split())
    A[i], B[i] = a, b

ans = 0
temp = 0
for i in reversed(range(n)):
    if (A[i]+temp)%B[i] != 0:
        j = (A[i]+temp)//B[i]
        ans += B[i]*(j+1)-(A[i]+temp)
        temp += B[i]*(j+1)-(A[i]+temp)
print(ans)


Measured memory_bytes: 46040
#include <bits/stdc++.h>
using namespace std;
 
void fail(){
    cout << "No" << endl;
    exit(0);
}
 
int main(){
    int N;
    cin >> N;
    vector<pair<int, int>> task_p, task_n;
    for(int i=0; i<N; i++){
        string S;
        cin >> S;
        int s = 0, mn = 0;
        for(char c : S){
            s += (c == '(' ? 1 : -1);
            mn = min(mn, s);
        }
        int a = -mn, b = s;
        (b >= 0 ? task_p : task_n).emplace_back(a, b);
    }
    sort(task_p.begin(), task_p.end());
    int R = 0;
    for(auto& p : task_p){
        if(R < p.first) fail();
        R += p.second;
    }
    sort(task_n.begin(), task_n.end(), [](auto a , auto b){ return a.first+a.second > b.first+b.second; });
    for(auto& p : task_n){
        if(R < p.first) fail();
        R += p.second;
    }
    if(R) fail();
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 11600
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		partC101();
	}


	public static void partC101() {
		Scanner scC = new Scanner(System.in);
		int N = scC.nextInt();
		int K = scC.nextInt();
		int[] A = new int[N];

		for(int i = 0 ; i < N ; i++) {
			A[i] = scC.nextInt();
		}

		if(K == N) {
			System.out.println(1);
		}else if(K == 2) {
			System.out.println(N - 1);
		}else if(K > (N / 2)) {
			System.out.println(2);
		}else {
			if((N-1) % (K-1) == 0){
				System.out.println((N-1) / (K-1));
			}else {
				System.out.println(((N-1) / (K-1)) + 1);
			}
		}
	}
}

Measured memory_bytes: 50496
#include <iostream>
#include <vector>
using namespace std;
void move(const vector<vector<char>> &board, vector<vector<bool>> &reached, int x, int y, int w, int h) {
    if (x < 0 || w <= x || y < 0 || h <= y) {
        return;
    } else if (board[x][y] == '#') {
        return;
    } else if (reached[x][y]) {
        return;
    }
    reached[x][y] = true;
    int dxAry[] = {0, 1, 0, -1};
    int dyAry[] = {-1, 0, 1, 0};
    for (int i = 0; i < 4; ++i) {
        move(board, reached, x + dxAry[i], y + dyAry[i], w, h);
    }
}
int main(void){
    int w, h;
    while (cin >> w >> h && w && h) {
        vector<vector<char>> board(w, vector<char>(h));
        int sx, sy;
        for (int i = 0; i < h; ++i) {
            string row;
            cin >> row;
            for (int j = 0; j < row.length(); ++j) {
                board[j][i] = row[j];
                if (row[j] == '@') {
                    sx = j;
                    sy = i;
                }
            }
        }
        vector<vector<bool>> reached(w, vector<bool>(h, false));
        move(board, reached, sx, sy, w, h);
        int count = 0;
        for (int y = 0; y < h; ++y)
            for (int x = 0; x < w; ++x)
                count += reached[x][y];
        cout << count << endl;
    }
    return 0;
}

Measured memory_bytes: 3192
import java.util.Scanner;

public class Main {
    
	public static void main(String[] args) {
	    
		Scanner src = new Scanner(System.in);
		int n = src.nextInt();
		
		for (int i = 3; i <= n; i++) {
		    
			if (i % 3 == 0 || String.valueOf(i).contains("3"))
				System.out.print(" " + i);
				
		}
		
		System.out.println();
	}
}



Measured memory_bytes: 29092
#include<bits/stdc++.h>
using namespace std;
int main(){
    std::ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n,m;
    cin>>n>>m;
    int num=1,cnt=0;
    while(num<m){
        num=num+n-1;
        cnt++;
    }
    cout<<cnt;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int h,n,sum=0;
    cin>>h>>n;
    int a[n];
    for(int i=0;i<n;i++)
        {cin>>a[i];sum+=a[i];}
    if(sum>=h)
        cout<<"Yes";
    else
    cout<<"No";

    return 0;
}


Measured memory_bytes: 640
// {{{ by unolight
#include <bits/stdc++.h>
#include <unistd.h>
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC diagnostic ignored "-Wunused-function"
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x),end(x)
#define RALL(x) rbegin(x),rend(x)
#define REP(i,n) for ( int i=0; i<int(n); i++ )
#define REP1(i,a,b) for ( int i=(a); i<=int(b); i++ )
#define MP make_pair
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef pair<int,int> PII;
typedef vector<int> VI;

namespace { namespace unolight {
// Read Input
template<class T> void _R( T &x ) { cin>>x; }
void _R( int &x ) { scanf("%d",&x); }
void _R( int64_t &x ) { scanf("%" PRId64,&x); }
void _R( double &x ) { scanf("%lf",&x); }
void _R( char &x ) { scanf(" %c",&x); }
void _R( char *x ) { scanf("%s",x); }
void R() {}
template<class T, class... U> void R( T& head, U&... tail ) { _R(head); R(tail...); }
// Write Output
template<class T> void _W( const T &x ) { cout<<x; }
void _W( const int &x ) { printf("%d",x); }
void _W( const int64_t &x ) { printf("%" PRId64,x); }
void _W( const double &x ) { printf("%.16f\n",x); }
void _W( const char &x ) { putchar(x); }
void _W( const char *x ) { printf("%s",x); }
template<class T> void _W( const vector<T> &x ) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W( const T& head, const U&... tail ) { _W(head); putchar(sizeof...(tail)?' ':'\n'); W(tail...); }

#ifdef UNOLIGHT
#include "dump.hpp"
#else
#define dump(...)
#endif

template<class T> inline bool chmax( T &a, const T &b ) { return b>a ? a=b,true : false; }
template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template<class T, class F=less<T>> void sort_uniq( vector<T> &v, F f=F() ) {
    sort(begin(v),end(v),f);
    v.resize(unique(begin(v),end(v))-begin(v));
}
// }}}


void main() {
    string s;
    int k;
    cin >> s >> k;
    string ans="";
    for ( int i=0; i<SZ(s); i+=k ) {
        ans+=s[i];
    }
    W(ans);
}

}} // {{{ main
int main() { unolight::main(); return 0; }
// }}}

Measured memory_bytes: 3632
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

const int dx[4] = {-1, 0, 0, 1};
const int dy[4] = {0, -1, 1, 0};
// Self settings
// clang-format off
#define MAX_N 10000
#define INF -1000000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
// clang-format on

int cost[] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
int N, M;
int A[9];
char ans[MAX_N];
int dp[MAX_N + 1];

void solve()
{
  fill(dp, dp + N, INF);
  dp[0] = 0;
  REP(i, N + 1)
  {
    REP(j, M)
    {
      if (i - cost[A[j]] >= 0 && dp[i - cost[A[j]]] != INF) {
        dp[i] = max(dp[i], dp[i - cost[A[j]]] + 1);
      }
    }
  }

  int i = N;
  while (i > 0) {
    int ma = 0;
    for (int j = 0; j < M; j++) {
      if (i - cost[A[j]] < 0) continue;
      if (dp[i - cost[A[j]]] == dp[i] - 1) {
        ma = max(ma, A[j]);
      }
    }
    cout << ma;
    i -= cost[ma];
  }
  cout << endl;
}

int main(void)
{
  cin >> N >> M;
  REP(i, M) { cin >> A[i]; }
  solve();
  return 0;
}


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


int main(){
  int N;

  while(std::cin >> N){
    std::vector<int> A(N);
    for(int i = 0; i < N; ++i) std::cin >> A[i];

    int64_t ans = std::accumulate(A.begin(), A.end(), 0LL);

    std::map<int, int64_t> m;
    for(int i = 0; i < N; ++i) m[A[i]] += 1;

    int Q; std::cin >> Q;

    for(int i = 0; i < Q; ++i){
      int B, C; std::cin >> B >> C;

      ans += m[B] * (C - B);

      m[C] += m[B];
      m[B] = 0;
      
      

      std::cout << ans << "\n";
    }
    
  }

  return 0;
}


Measured memory_bytes: 9524
function Main (input) {
  var t_life = parseInt(input.split(" ")[0]);
  var t_atk = parseInt(input.split(" ")[1]);
  var a_life = parseInt(input.split(" ")[2]);
  var a_atk = parseInt(input.split(" ")[3]);
  
  for (var counter = 0; a_life >= 0 && t_life >= 0; counter++) {
    if (counter % 2 === 0) {
        // 高橋君の番
        a_life = a_life - t_atk
        if (a_life <= 0) {
            console.log("Yes")
            break;
        }
    } else {
        // 青木君の番
        t_life = t_life - a_atk
        if (t_life <= 0) {
            console.log("No")
            break;
        }
    }
  }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))

void run(void){
  int n,k;
  scanf("%d%d",&n,&k);
  int *a=(int *)calloc(n,sizeof(int));
  int i;
  for(i=0;i<n;i++) scanf("%d",a+i);
  int64 sum=0;
  for(i=0;i<k;i++) sum+=a[i];
  int64 free=0;
  for(i=k;i<n;i++) free+=MAX(0,a[i]);
  int64 max=MAX(0,sum)+free;
  for(i=1;i+k-1<n;i++){
    free-=MAX(a[i+k-1],0);
    free+=MAX(a[i-1],0);
    sum-=a[i-1];
    sum+=a[i+k-1];
    max=MAX(max,MAX(sum,0)+free);
  }
  printf("%lld\n",max);
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 512
#include <stdio.h>

int main(void)
{
	int a,b,c,d,e=0,i;
	scanf("%d %d %d",&a,&b,&c);
	for(i = a; i <= b; i++){
	if(c % i == 0)e++;
	}
	printf("%d\n",e);
	return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
#define god dimasi5eks
#pragma GCC optimize("O3")
#define fi first
#define se second
#define pb push_back
#define pf push_front
#define mod 1000000007
#define dancila 3.14159265359
#define eps 1e-9

// #define fisier 1

using namespace std;

typedef long long ll;

int aib[27][500002];

string s;
int n, q;

void add(int poza, int pozb, int x)
{
    for(; pozb <= n; pozb += (pozb & (-pozb)))
        aib[poza][pozb] += x;
}
int compute(int poza, int pozb)
{
    int ans = 0;
    for(; pozb; pozb -= (pozb & (-pozb)))
        ans += aib[poza][pozb];
    return ans;
}
int main()
{

    #ifdef fisier
        ifstream f("input.in");
        ofstream g("output.out");
    #endif

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

    cin >> n;
    cin >> s;
    cin >> q;
    s = ' ' + s;
    for(int i = 1; i <= n; ++i)
        add(s[i] - 'a', i, 1);
    for(; q; --q)
    {
        int tip;
        cin >> tip;
        if(tip == 1)
        {
            int x;
            char z;
            cin >> x >> z;
            add(s[x] - 'a', x, -1);
            add(z - 'a', x, 1);
            s[x] = z;
        }
        else
        {
            int st, dr;
            cin >> st >> dr;
            int ans = 0;
            for(int i = 0; i <= 25; ++i)
            {
                int val = compute(i, dr) - compute(i, st - 1);
                ans += (val > 0);
            }
            cout << ans << '\n';
        }
    }
    return 0;
}


Measured memory_bytes: 52144
#include <bits/stdc++.h>
using namespace std;
#define maxn 302000
#define int long long
#define INF 999999999999LL
int n, m, ans = INF, A, B, x[maxn], f[maxn], sum[maxn];

int read() {
	int x = 0, k = 1;
	char c; c = getchar();
	while(c < '0' || c > '9') { if(c == '-') k = -1; c = getchar(); }
	while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return x * k;
}

struct tree {
	int mn[maxn << 2];
	void Build(int p, int l, int r) {
		mn[p] = INF; 
		if(l == r) return;
		int mid = (l + r) >> 1;
		Build(p << 1, l, mid), Build(p << 1 | 1, mid + 1, r);
	}
	
	void Update(int p, int l, int r, int x, int y) {
		if(l == r) { mn[p] = min(mn[p], y); return; }
		int mid = (l + r) >> 1;
		if(x <= mid) Update(p << 1, l, mid, x, y);
		else Update(p << 1 | 1, mid + 1, r, x, y);
		mn[p] = min(mn[p << 1], mn[p << 1 | 1]);
	}
	
	int Query(int p, int l, int r, int L, int R) {
		if(L > r || R < l) return INF;
		if(L <= l && R >= r) return mn[p]; 
		int mid = (l + r) >> 1;
		return min(Query(p << 1, l, mid, L, R), Query(p << 1 | 1, mid + 1, r, L, R));
	}
}T1, T2;

void Work(int K, int T) {
	f[1] = abs(K - x[1]); x[0] = T;
	T1.Build(1, 1, n), T2.Build(1, 1, n);
	T1.Update(1, 1, n, x[0], f[1] - x[0] - sum[1]);
	T2.Update(1, 1, n, x[0], f[1] + x[0] - sum[1]);
	for(int i = 2; i <= m; i ++) {
		f[i] = min(T1.Query(1, 1, n, 1, x[i]) + x[i], T2.Query(1, 1, n, x[i], n) - x[i]);
		f[i] += sum[i - 1];
		T1.Update(1, 1, n, x[i - 1], f[i] - x[i - 1] - sum[i]);
		T2.Update(1, 1, n, x[i - 1], f[i] + x[i - 1] - sum[i]);
	}
	for(int i = 1; i <= m; i ++) ans = min(ans, f[i] + sum[m] - sum[i]);
}

signed main() {
	n = read(), m = read(), A = read(), B = read();
	for(int i = 1; i <= m; i ++) x[i] = read();
	for(int i = 2; i <= m; i ++) sum[i] = sum[i - 1] + abs(x[i] - x[i - 1]);
	Work(A, B); Work(B, A);
	printf("%lld\n", ans);
	return 0;
}

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

int main() {
  int a,b,c,k;
  cin>>a>>b>>c>>k;
 
 
  for(int i=0; i<k; i++){
    
    if(a<b && c<=b)
      c*=2;
    else if(b<=a)
      b*=2;
    
  }
  if(a<b&&b<c)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}



Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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 = 1e10;
typedef pair<ll,ll> P;
string ans[1005];
int main(){
    int n;
    string three[3]={"aab","b.b","baa"};
    string four[4] = {"abcc","abdd","ccab","ddab"};
    string five[5] = {"..abc","..abc","aaeed","bbd.d","ccdee"};
    string seven[7] = {".aabbcc","adde...","ae.e...","bedd...","b...dde","c...e.e","c...edd"};
    cin >> n;
    if (n == 2) PRINT(-1);
    else if (n == 3 || n == 6){
        rep(i,2){
            string s = "";
            rep(j,i) s += "...";
            rep(j,3){
                ans[3*i+j] = s + three[j];
                if (i == 0 && n == 6)  ans[3*i+j] += "...";
            }
        }
        rep(i,n) PRINT(ans[i]);
    }
    else if (n == 7){
        rep(i,7){
            PRINT(seven[i]);
        }
    }
    else if (n == 11){
        rep(i,4){
            ans[i] = four[i] + ".......";
        }
        rep(i,7){
            ans[4+i] ="...." + seven[i];
        }
        rep(i,11) PRINT(ans[i]);
    }
    else{
        int k;
        rep(i,1000){
            if ((n-4*i)%5 == 0){
                k = i;
                break;
            }
        }
        string s;
        rep(i,k){
            rep(j,4){
                s = "";
                rep(c,n) s += ".";
                rep(l,4) s[4*i+l] = four[j][l];
                ans[4*i+j] = s;
            }
        }
        rep(i,(n-4*k)/5){
            rep(j,5){
                s = "";
                rep(c,n) s += ".";
                rep(l,5){
                    s[4*k+5*i+l] = five[j][l];
                }
                ans[4*k+5*i+j] = s;
            }
        }
        rep(i,n) PRINT(ans[i]);
    }
}


Measured memory_bytes: 2304
def solve():
    N = int(input())
    A = list(map(int, input().split()))
    tmp = 0
    ans = 0
    for i in range(N-1):
        if A[i] < A[i+1]:
            tmp = 0
        else:
            tmp += 1
        ans = max(ans, tmp)

    return ans

print(solve())

Measured memory_bytes: 14252
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <cstring>
#include <climits>
#include <cmath>
#include <cfloat>

#define FOR(i,b,n) for(int i=b;i<n;i++)
#define REP(i,b,n) for(i=b;i<n;i++)
#define CLR(mat) memset(mat, 0, sizeof(mat))

using namespace std;

vector<string> win;
vector<string> tic;
int n, m, winmoney[200] = {0};

int solve()
{
	int res = 0;
	
	FOR(j, 0, m)
	{
		FOR(i, 0, n)
		{
			int ct = 0;
			
			FOR(k, 0, 8)
			{
				if( win[i][k] == tic[j][k] || win[i][k] == '*' )
					ct++;
			}
			
			if( ct >= 8)
			{
				res += winmoney[i];
				break;
			}
		}
	}
	
	return res;
}

int main()
{
	while(cin >> n >> m, (n||m))
	{
		win.clear();
		tic.clear();
		string str;
		
		FOR(i, 0, n)
		{
			cin >> str;
			win.push_back(str);
			cin >> winmoney[i];
		}
		
		FOR(i, 0, m)
		{
			cin >> str;
			tic.push_back(str);
		}
		
		cout << solve() << endl;
	}
	
	return 0;
}

Measured memory_bytes: 968
#include <stdio.h>
#include <math.h>

int n=0,flag[10]={},array[10]={};
double x[10]={},y[10]={},all_len=0.0;

double distance(void);
int factorial();
void dfs(int disit);

int main(void)
{
    double average=0.0;
    scanf("%d",&n);
    for(int i=0;i<n;i++) scanf("%lf %lf",&x[i],&y[i]);
    dfs(0);
    average=all_len/(double)factorial();
    printf("%.6lf",average);
    return 0;
}

double distance(void){
    double len=0.0;
    for(int i=0;i<n-1;i++){
        len+=sqrt(pow(x[array[i]-1]-x[array[i+1]-1],2)
               +pow(y[array[i]-1]-y[array[i+1]-1],2));
    }
    return len;
}

int factorial(){
    int temp=1;
    for(int i=1;i<=n;i++) temp*=i;
    return temp;
}

void dfs(int disit){
    if(disit==n){
        all_len+=distance();
    } else {
        for(int i=1;i<=n;i++){
            if(flag[i]==0){
                flag[i]=1;
                array[disit]=i;
                dfs(disit+1);
                flag[i]=0;
            }
        }
    }
}


Measured memory_bytes: 2192
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define int long long
#define endl "\n"
#define pii pair<int,int> 
#define ff first
#define ss second
#define mii map<int,int>
#define si set<int>
#define sti stack<int>
#define qi queue<int>
#define vi vector<int>
#define pq priority_queue<int>
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int M=1e18;

int32_t main(){
	IOS;
	int n;cin>>n;
	if(n%2){cout<<0; return 0;}
	int sum=0;
	for(int i=10;i<=M;i*=5){
		sum+=((n/i));
	}
	cout<<sum<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MOD=1e9+7;
int n,dp[100005][15];
string a;
char s[100005];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>a;
	n=a.size();
	for (int i=0;i<n;++i) s[i+1]=a[i];
	dp[0][0]=1;
	for (int i=1;i<=n;++i)
	{
		if (s[i]!='?')
		{
			int tmp=s[i]-'0';
			for (int j=0;j<13;++j)
				dp[i][(j*10+tmp)%13]=(dp[i-1][j]+dp[i][(j*10+tmp)%13])%MOD;
		}
		else
		{
			for (int k=0;k<10;++k)
				for (int j=0;j<13;++j)
					dp[i][(j*10+k)%13]=(dp[i-1][j]+dp[i][(j*10+k)%13])%MOD;
		}
	}
	cout<<dp[n][5];
	return 0;
}

Measured memory_bytes: 6480
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int n, a, b;
    cin >> n >> a >> b;
    VI p(n);
    REP(i,n) p[i] = in();
    VI cnt(3);
    REP(i,n){
        if (p[i] <= a) cnt[0]++;
        else if (p[i] <= b) cnt[1]++;
        else cnt[2]++;
    }
    cout << *min_element(ALL(cnt)) << endl;

    return 0;
}


Measured memory_bytes: 256
def solve(n, m, a, b, c):
    a = sorted(a)
    x = sorted(zip(b, c), key=lambda _:-_[1])
    i = 0
    for num, v in x:
        for j in range(num):
            if a[i] < v:
                a[i] = v
                i += 1
                if i == n:
                    return sum(a)
            else:
                return sum(a)
    return sum(a)

n, m = map(int, input().split())
a = list(map(int, input().split()))
b = [0] * m
c = [0] * m
for i in range(m):
    b[i], c[i] = map(int, input().split())
print(solve(n, m, a, b, c))

Measured memory_bytes: 28024
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <list>
#include <math.h>
#include <string.h>
#include <bitset>
#include <queue>
using namespace std;

typedef pair<int, int> P;
#define INF (1LL<<60)
#define int long long
#define ll long long
#define mod 1000000007



struct matrix{
	vector<vector<int>> n;

	void init(int N){
		n.assign(N, vector<int>(N));
	}

	matrix mul(matrix b){
		int N = this->n.size();
		matrix ret;
		ret.init(N);
		for (int i = 0; i < N; i++)
			for (int j = 0; j < N; j++)
				for (int k = 0; k < N; k++)
					(ret.n[i][j] += this->n[i][k] * b.n[k][j])%=mod;

		return ret;
	}
};


signed main(){

	int N, K;
	cin >> N >> K;
	matrix a, an;
	a.init(N); an.init(N);

	for (int i = 0; i < N; i++)
		for (int j = 0; j < N; j++)
			cin >> a.n[i][j];

	for (int i = 0; i < N; i++)
		for (int j = 0; j < N; j++){
			if (i == j) an.n[i][j] = 1;
			else an.n[i][j] = 0;
		}

	while (K > 0){
		if (K % 2 == 1)
			an = an.mul(a);
		a = a.mul(a);
		K /= 2;
	}

	int ans = 0;
	for (int i = 0; i < N; i++)
		for (int j = 0; j < N; j++)
			(ans += an.n[i][j]) %= mod;

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<cmath>
using namespace std;
int N;
struct C{
	double x,y,r;
};
main()
{
	cin>>N;
	for(;N--;)
	{
		C a,b;
		cin>>a.x>>a.y>>a.r>>b.x>>b.y>>b.r;
		double d=hypot(a.x-b.x,a.y-b.y);
		cout<<(d>a.r+b.r?0:d<a.r-b.r?2:d<b.r-a.r?-2:1)<<endl;
	}
}



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

int N, M, Q;
int a[50], b[50], c[50], d[50];

int A[10];

int max = 0;

int solve() {
    int ans = 0;
    for (int i = 0; i < Q; ++i) {
        if ((A[b[i]] - A[a[i]]) == c[i]) {     
            ans += d[i];
        }
    }

    max = std::max(max, ans);
    return max;
}

int dfs(int n, int cur) {
    if (n == N) {
        return solve();
    }

    if (cur > M) { 
        return -1;
    }

    A[n] = cur;
    const int v1 = dfs(n + 1, cur);

    A[n] = 0;
    const int v2 = dfs(n, cur + 1);

    max = std::max({max, v1, v2});

    return max;
}

int main() {
    std::cin >> N >> M >> Q;
    for (int i = 0; i < Q; ++i) {
        std::cin >> a[i] >> b[i] >> c[i] >> d[i];
        --a[i];
        --b[i];
    }
    
    std::cout << dfs(0, 1) << std::endl;

    return 0;
}


Measured memory_bytes: 3508
#include<stdio.h>
#include<math.h>
int main(){
	int a,b,c,d,e,f;
	scanf("%d %d %d %d",&a,&b,&c,&d);
	e=a*b;
	f=c*d;
	if(e>=f)
		printf("%d\n",e);
	else
		printf("%d\n",f);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <numeric>
//#include<bits/stdc++.h>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;++i)
#define REP(i,s,n) for(int i=(s);i<(n);++i)
#define repr(i,n) for(int i=n-1;i>=0;--i)
#define REPR(i,s,n) for(int i=(s);i>=(n);--(i))
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll, ll> P;
const ll mod = 1e9 + 7;
ll dx[4] = { 1,0,-1,0 };
ll dy[4] = { 0,1,0,-1 };

void Yes(bool x) {
	if (x) cout << "Yes\n";
	else cout << "No\n";
}

void YES(bool x) {
	if (x) cout << "YES\n";
	else cout << "NO\n";
}

void yes(bool x) {
	if (x) cout << "yes\n";
	else cout << "no\n";
}

ll gcd(ll x, ll y)
{
	ll r;

	if (x == 0 || y == 0)  // 引数チェック
	{
		fprintf(stderr, "引数エラーです。\n");
		return 0;
	}

	// ユーグリッドの互除法
	while ((r = x % y) != 0)  // yで割り切れるまでループ
	{
		x = y;
		y = r;
	}
	return y;
}

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

	ll a, b, c, d, n, m, ans = 0, ret = M;
	string s, t;
	bool flag = false;
	cin >> s;
	n = s.size();
	vector<bool> x(n,true);
	ret = 0;
	rep(i, n) {
		if (s[i] == '1') ans++;
		else ret++;
	}
	cout << min(ans,ret)*2 << endl;
	return 0;
}


Measured memory_bytes: 512
# AtCoder
A, B, C, K = map(int, input().split())
ans = 0

if K >= A:
    ans += 1*A
    K -= A
else:
    print(K)
    exit()

if K >= 0:
    ans += K*(B*0)
    K -= B

if K >= 0:
    ans += (K*-1)
    K -= C

if 0 >= K:
    print(ans)


Measured memory_bytes: 9188
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <math.h> // sqrt
using namespace std;
typedef long long ll;

int main() {
    ll N;
    cin >> N;
    ll ans = 0;
    ll maxnum;
    for (ll i = 1; i <= N; i++) {
        maxnum = N / i;
        ans += maxnum * (maxnum + 1) * i / 2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std; 
bool is_prime(long long n){
	if(n == 1) return false; 
	if(n == 2 || n == 3) return true; 
	if(n % 6 != 1 && n % 6 != 5) return false; 
	for(long long i = 2; i * i <= n; i++){
		if(n % i == 0) return false; 
	}
	return true; 
}
long long gcd(long long a, long long b){
	return (b > 0)? gcd(b, a % b) : a ;
}
int main(){
	int N; cin >> N; 
	long long A[10010]; 
	for(int i = N; i >= 0; i--) cin >> A[i]; 
	long long G = abs(A[N]);
	for(int i = 0; i < N; i++) G = gcd(G, abs(A[i])); 
	set<long long> ans; 
	long long tmp = G; 
	for(long long i = 2; i * i <= G; i++){
		if(tmp % i == 0){
			ans.insert(i); 
			while(tmp % i == 0) tmp /= i; 
		}
	}
	if(tmp != 1) ans.insert(tmp); 
	for(long long i = 2; i <= 10000; i++){
		if(!is_prime(i)) continue; 
		if(A[0] % i != 0) continue; 
		long long C[10010] = {}; 
		for(int j = 1; j <= N; j++){
			C[j % (i-1)] += A[j]; 
		}
		bool ok = true; 
		for(int j = 0; j < i-1; j++){
			if(abs(C[j]) % i){
				ok = false; break; 
			}
		}
		if(ok) ans.insert(i); 
	}
	for(auto it = ans.begin(); it != ans.end(); it++) cout << *it << "\n"; 
}

Measured memory_bytes: 384
#include <iostream>
#include<math.h>
#include<list>
#include <algorithm>
#include<vector>
#include<math.h>
using namespace std;


int main() {
	int h, w,ret=0;
	bool flg = true;
	cin >> h>>w;
	int c[10][10], d[10][10];
	for (int i = 0; i < 10; i++) {
		for (int j = 0; j < 10; j++) {
			cin >> c[i][j];
			d[i][j] = c[i][j];
		}
	}


	while (flg) {
		flg = false;
		for (int i = 0; i < 10; i++) {
			for (int j = 0; j < 10; j++) {
				for (int k = 0; k < 10; k++) {
					if (i == j || i == k || j == k)	continue;
					if (d[i][j] > d[i][k] + d[k][j]) {
						d[i][j] = d[i][k] + d[k][j];
					}
				}
				if (c[i][j] != d[i][j]) {
					flg = true;
					c[i][j] = d[i][j];
				}
			}
		}
	}

	vector<vector<int>> a(h, vector<int>(w));
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> a[i][j];
			if (a[i][j] >= 0) {
				ret += c[a[i][j]][1];
			}
		}
	}

	cout << ret << endl;
	return 0;
}


Measured memory_bytes: 384
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define Vd vector<double>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b?gcd(b,a%b):a;} //最小公倍数

// デフォルト変数定義
int n,m,a,b,c,x,y,z;
double d,e,f;
string s,t;
//

signed main() {
  RAPID;
  IN2(a,b);
  IN2(x,y);
  OUT((a-x)*(b-y));
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	ll N, K;
	cin >> N >> K;
	ll x[N];
	for (ll i = 0; i < N; i++) {
		cin >> x[i];
	}
	ll ans = 100000000000,t;
	for (ll i = 0; i < N - K + 1; i++) {
		t=min(x[i+K-1]-x[i]+abs(x[i+K-1]), x[i+K-1]-x[i]+abs(x[i]));
		if(ans>t)ans=t;
	}
	cout << ans << endl;
}



Measured memory_bytes: 1024
#include<iostream>
#include<iomanip>

#include<vector>
#include<queue>
#include<set>
#include<map>
#include<string>

#include<algorithm>
#include<cmath>

using namespace std;
typedef long long ll;
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;}
const long long INF = 1LL << 60;
//以下変更可能領域




int main() {
    int N;
    cin >> N;
    vector<int> p(N);
    for (int i = 0; i < N; i++) cin >> p[i];
    
    int cnt = 0;

    for (int i = 1;i < N-1; i++) {
        if ((p[i-1] < p[i] && p[i] < p[i+1]) || (p[i-1] > p[i] && p[i] > p[i+1]))
        cnt++;
    }
    cout << cnt << "\n";
}


Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! parse_line {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            iter.next().unwrap().parse::<$t>().unwrap()
        }
    );

    ( $( $t:ty), +) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ( $(iter.next().unwrap().parse::<$t>().unwrap()),* )
        }
    );
}

#[allow(unused_macros)]
macro_rules! read_line {
    () => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            line.pop();
            line
        }
    )
}

#[allow(unused_macros)]
macro_rules! parse_vec {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let iter = line.split_whitespace();
            iter.map(|v| v.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    )
}

fn solve(x: u32, mut aa: Vec<u32>) -> usize {
    aa.sort();

    for (i,a) in aa.iter().enumerate() {
        if x < *a {
            return std::cmp::min(i, aa.len()-i)
        }
    }

    0
}

fn main() {
    let (_, _, x) = parse_line!(u32, u32, u32);
    let aa = parse_vec!(u32);

    println!("{}", solve(x, aa));
}

#[test]
fn solve_test() {
    assert_eq!(solve(3, vec![1,2,4]), 1);
    assert_eq!(solve(2, vec![4,5,6]), 0);
    assert_eq!(solve(5, vec![1,2,3,4,6,8,9]), 3);
}


Measured memory_bytes: 4352
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		// TODO 自動生成されたメソッド・スタブ
		BigDecimal one = new BigDecimal("1.00");
		int[] abo = {0,0,0,0};
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String tmp = null;
		int cup = 0;
		int mun = 0;
		int ter = 0;
		String[] rrr;
		int st = 0,sr = 0;
		double mon = 0;
		int syo=0,hisi=0;
		double aaaa = 1;
		
		
		while(true){
			
			try {
				tmp = br.readLine();
			} catch (IOException e) {
				// TODO 自動生成された catch ブロック
				e.printStackTrace();
			}
			
			if(tmp == null){
				break;
			}
			
			if(tmp.equals("")){
				break;
			}
			
			rrr = tmp.split(",");
			
			
			mon = Double.parseDouble(rrr[1]);
			
			aaaa = Double.parseDouble(rrr[2]);
			
			
			double oef;
			
			oef = mon/(aaaa*aaaa);
			
			if(oef >= 25.0){
				System.out.println(rrr[0]);
			}			
			
		}
	}

}

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

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if((a == b) && (b == c)){
    cout << 1 << endl;
  }else if(((a == b) && (b != c)) || ((a != b) && (b == c)) || ((a == c) && (c != b))){
  cout << 2 << endl;
  }else{
  cout << 3 << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <cmath>
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP2(i, m, n) for (int i = (m); i < (int)(n); ++i)
#define REPR(i, n) for (int i = (n)-1; i >= 0; --i)
#define REPR2(i, m, n) for (int i = (n)-1; i >= (m); --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTG(a) sort(ALL(a), greater<int>())
#define REVERSE(a) reverse(ALL(a))
#define bit_search(bit, n) REP(bit, 1<<(n))
#define bit_check(bit, i) (bit>>(i)) & 1
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define bisect_left(a, x) lower_bound(ALL(a), (x)) - a.begin()
#define bisect_right(a, x) upper_bound(ALL(a), (x)) - a.begin()
#define INPUT(a) REP(i, a.size()) cin >> a[i];
#define INPUTP(a) REP(i, a.size()) cin >> a[i].first >> a[i].second;
#define ENDL cout << endl;
using namespace std;
using ll = long long;
using ld = long double;
using PII = pair<int, int>;
using VPII = vector<PII>;
using VI = vector<int>;
using VVI = vector<VI>;
using Vll = vector<ll>;
using VVll = vector<Vll>;
using VC = vector<char>;
using VS = vector<string>;
using VB = vector<bool>;
const int INF = 1e9;
const ll MOD = 1e9 + 7;

void paint(auto &ans, auto &color, auto &now, auto &H, auto &W, auto &dir)
{
  if (now.second >= W) {now.second = W-1; now.first++; dir = 'L';}
  else if (now.second < 0) {now.second = 0; now.first++; dir = 'R';}
  ans[now.first][now.second] = color;
  if (dir == 'R') now.second++;
  else now.second--;
}

int main()
{
  int H, W, N;
  cin >> H >> W >> N;
  VI a(N);
  INPUT(a);
  VVI ans(H, VI(W));
  PII now = {0, 0};
  int color = 1;
  char dir = 'R';
  REPx(x, a)
  {
    REP(i, x) paint(ans, color, now, H, W, dir);
    color++;
  }
  REP(i, H)
  {
    REP(j, W) cout << ans[i][j] << " ";
    ENDL
  }

  return 0;
}


Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main(void){
    int N;
    int K;
    cin >> N >> K;
    int h[114514];
    int dp[114514];
    for(int i=0;i<N;i++){
        cin >> h[i];
        dp[i]=1000000000;
    }
    dp[0]=0;
    for(int i=1;i<N;i++){
        for(int j=1;j<=K;j++){
            if (i-j>=0){
                if (dp[i]>dp[i-j]+abs(h[i-j]-h[i])){
                    dp[i]=dp[i-j]+abs(h[i-j]-h[i]);
                }
            }
        }
    }
    cout << dp[N-1] << endl;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;

long long GCD(long long a, long long b) {
    if(b == 0)
        return a;
    else
        return GCD(b, a % b);
}
long long LCM(long long a, long long b) {
    long long g = GCD(a, b);
    return a / g * b;
}

int main() {
    long long n = 1000000000;
    long long N, K, S;
    cin >> N >> K >> S;
    vector<long long> A(N);
    int nokori = n;
    if(S == n) {
        nokori = 1;
    }
    rep(i, 0, N) {
        if(i < K) {
            cout << S;
        } else {
            cout << nokori;
        }
        if(i != N - 1) {
            cout << " ";
        }
    }
    cout << endl;
}


Measured memory_bytes: 2048