akhauriyash/Code-Regression huggingface dataset:
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  set<int> s;
  REP(i,k) {
    int a;
    cin >> a;
    REP(i,a) { int x; cin >> x; s.insert(x); }
  }
  cout << n - s.size() << endl;
  return 0;
}
//templete by private_yusuke

Measured memory_bytes: 3656
#include <stdio.h>

int main(void){
	char s[2];
	int n = 0,m = 0,x = 0,a[100],i,up=0,down=0;
	scanf("%d""%d""%d",&n,&m,&x);
	for(i = 0;i<m;i++){
		scanf("%d",&a[i]);
		if(a[i]<x)
			up++;
		else
			down++;
	}
	if(up>down)
		printf("%d\n",down);
	else
		printf("%d\n",up);
		return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<cmath>
#include<complex>
#include<iomanip>

using namespace std;

#define REP(i,s,e) for(int i=int(s);i<=int(e);i++)
#define rep(i,n) for(int i=0;i<int(n);i++)
#define pi 3.14159265358979

int main(void){

	int n;
	for(;;){

	cin >> n;
	if(n==0) break;

	int c=0;
	for(int i=1;i<=n/2;i++){
		for(int j=i+1;j<n;j++){
			if((j*(j+1)/2-i*(i-1)/2)==n)
				c++;
		}
	}

    cout << c <<endl;

	}

	return 0;
}

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

#define rep(a,b) for(int a = 0;a < b;a++)
#define REP(i, x, n) for(int i = x; i < n; i++)
#define P(a) cout << a << endl
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define ssort(v) sort(v.begin(),v.end())
#define rev(v) reverse(v.begin(),v.end())
#define vP(v) for(int i = 0;i < v.size();i++){cout << v[i];if(i != v.size()-1)cout << endl;}
#define vcin(v,n) rep(i,n){int a;cin >> a;v.pb(a);}

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int dx[] = { 1, -1 , 0 , 0 };
int dy[] = { 0,  0,  1, -1 };
ll MOD = 1000000007;

void solve(){
	int a,b,c,d;
	cin >> a >> b >> c >> d;
	P(max(0,min(b,d) - max(a,c)));
}

int main() {
	solve();
	return 0;
}


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

int main(){
  long long n,i;
  cin >> n;
  vector<long long> A(n+1);
  vector<long long> B(n);
  for(i=0; i<n+1; i++) cin >> A[i];
  for(i=0; i<n; i++) cin >> B[i];
  long long num=0;	//"num" is the number of killed monsters
  for(i=0; i<n; i++){
  	if(B[i]<=A[i]){
      num = num + B[i];
  	}
  	else{
      num = num + A[i];
      if(B[i]-A[i]<A[i+1]){
        num = num + B[i] - A[i];
        A[i+1] = A[i+1] - (B[i]-A[i]);
      }
      else{
        num = num + A[i+1];
        A[i+1] = 0;
      }
    }
  }
  cout << num <<endl;
  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
const ll INF=1e18;
const int MOD=1e9+7;
const double pi=acos(-1);
int main(){
  string s;
  cin >> s;
  ll n=s.size();
  vector<int>vec;
  rep(i,n)vec.push_back(s[i]-'0');
  ll now=0;
  ll have=n;
  while(now<=have-2 && 0<=now){
    if(vec[now]!=vec[now+1]){
      vec.erase(vec.begin()+now);
      vec.erase(vec.begin()+now);
      have-=2;
      if(now!=0)now--;
    }
    else{
      now++;
    }
  }
  cout << n-have << endl;
  
}


Measured memory_bytes: 1020
#include <stdio.h>
#define N 100
#define WHITE 0
#define BLACK 1
#define GRAY 2

int n,A[N][N],d[N],f[N],color[N],t=0;

 void DFSvisit(int u){
  int v;

  color[u]=GRAY;
  t++;
  d[u] = t;

  for(v=0;v<n;v++){
    if(A[u][v]==1 && color[v]==WHITE)   DFSvisit(v);
  }
  color[u] = BLACK;
  f[u] = ++t;

  return;
}


int main(){
  int i,j,u,v,k;

 
  scanf("%d",&n);

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      A[i][j] = 0;
    }
  }

  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d",&v);
      A[u-1][v-1] = 1;
    }
  }

  for(i=0;i<n;i++){
    color[i]=WHITE;
  }

  for(i=0;i<n;i++){
    if(color[i]==WHITE)    DFSvisit(i);
  }

  for(i=0;i<n;i++){
    printf("%d %d %d\n",i+1,d[i],f[i]);
  }

  return 0;
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n); i >= 0; i--)
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using llong = long long;

const int INF = 100100100;
const int MOD = 1e9 + 7;

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

    int A, B;
    cin >> A >> B;
    int ans = A - B - B;
    if (ans < 0) {
        cout << 0 << endl;
        return 0;
    } else {
        cout << ans << endl;
        return 0;
    }
}


Measured memory_bytes: 256
from heapq import heappush, heapreplace
def main():
    x, y, z, k = map(int, input().split())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    c = list(map(int, input().split()))
    heap = []
    for i in b:
        for j in c:
            if len(heap) < k:
                heappush(heap, i+j)
            elif heap[0] < i+j:
                heapreplace(heap, i+j)
    ans = []            
    for i in heap:
        for j in a:
            if len(ans) < k:
                heappush(ans, i+j)
            elif ans[0] < i+j:
                heapreplace(ans, i+j)
    ans.sort()
    for val in reversed(ans):
        print(val)    
    return
main()

Measured memory_bytes: 3828
<?php
  list($n, $k) = explode(" ", trim(fgets(STDIN)));

  $a = array_map('intval', explode(" ", trim(fgets(STDIN))));

  sort($a);

  $R = $a[$n-1];
  $L = 0;

  while($R-$L>1){
    $ans = intdiv($R+$L, 2);
    //echo "RL:".$R." ".$L." ".$ans.PHP_EOL;
    $cut = 0;
    for ($i=0; $i<$n; $i++) {
      $cnt = intdiv($ans + $a[$i]-1, $ans)-1;
      if($cnt > 0){
        $cut += $cnt;
      }
    }
    //echo $cut.PHP_EOL;
  
    if($cut <= $k){
      $R = $ans;
    }else{
      $L = $ans;
    }
    
  }

  echo $R;


Measured memory_bytes: 38244
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
static const int MOD = 1e9+7;

ll MODP[100005];
ll PINV[100005];

ll modmat(ll a, ll b){
    ll ans = 0;
    for(ll i = 0; i < b; i++){
        ans += a;
        ans %= MOD;
    }
    return ans;
}

void calcP(ll n){
    MODP[0] = 1;
    MODP[1] = 1;
    for(int i = 1; i <= n; i++){
        //MODP[i] = modmat(MODP[i-1], i);
        MODP[i] = (MODP[i-1] * i) % MOD;
    }
}

ll calcPINV(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

ll moddiv(ll a, ll b, ll M){
    //cout <<"   " << b << "'s moddiv  :" << PINV[b] << endl;
    ll ans = (a % M) * (PINV[b] % M);
    return ans;
}

ll modCOM(ll n, ll r){
    ll ans = MODP[n];
    ll R1 = MODP[r];
    ll R2 = MODP[n-r];
    //cout << ans << " " << R1 << " " << R2 << " ";
    ans = moddiv(ans, r, MOD);
    //cout << ans << " ";
    ans = moddiv(ans, n-r, MOD);
    //cout << ans << endl;

    return ans % MOD;
}


int main(){
    int N, K; cin >> N >> K;
    calcP(N); //
    for(int i = 0; i <= N; i++)PINV[i] = calcPINV(MODP[i], MOD);
    vector<int> A(N);
    for(int i = 0; i < N; i++) cin >> A[i];
    sort(A.begin(), A.end());

    ll ans = 0;
    for(int i = 0; i < N; i++){
        if(i > K-2) {
            //ans += modmat(modCOM(i, K-1), A[i]) % MOD;
            ans += (modCOM(i, K-1) * A[i]) % MOD;
            //ans += modCOM(i, K-1) * A[i];
            //cout << "max comb : " << i << " " << K-1 << " " << (modCOM(i, K-1) * A[i]) << endl;
        }
        //ans%=MOD;
        if(i < N-K+1) {
            //ans -= modmat(modCOM(N-i-1, K-1), A[i]) % MOD;
            ans -= (modCOM(N-i-1, K-1) * A[i]) % MOD;
            //ans -= modCOM(N-i-1, K-1) * A[i];
            //cout << "min comb : " << N-i-1 << " " << K-1 << " " << modCOM(N-i-1, K-1) << endl;
        }
        if(ans < 0) ans += MOD;
        ans%=MOD;
        //cout << "ans " << ans << endl;
    }
    cout << ans << endl;

    //for(int i = 0; i <= N; i++) cout << i <<"'s MODINV " << PINV[i] << endl;
}

Measured memory_bytes: 2176
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.ABC_158
{
    class B
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);

            Method(args);

            Out.Flush();
        }

        static void Method(string[] args)
        {
            long[] nab = ReadLongs();
            long n = nab[0];
            long a = nab[1];
            long b = nab[2];

            long res = n / (a + b) * a + Min(a, n % (a + b));
            WriteLine(res);
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


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

int main() {
	int k, s, ans = 0;
	cin >> k >> s;
	for (int i = 0; i <= k; ++i) {
		for (int j = 0; j <= k && i + j <= s; ++j) {
			if (s - i - j <= k) ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(long long i=0;i<x;i++)
#define repn(i,x) for(long long i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<pair<string,P> >vec;
// vector<vector<int>> data(3, vector<int>(4));


int main(){	
	long long N;
	long long M;
	scanf("%lld",&N);
	vector<double> A(N-1+1);
	scanf("%lld",&M);
	priority_queue<double> que;
	for(int i = 0 ; i <= N-1 ; i++){
		cin >> A[i];
		que.push(A[i]);
	}
	rep(i, M) {
		double d;
		d = que.top();
		que.pop();
		que.push(d/2);
	}
	ll res = 0;
	rep(i, N) {
		res += floor(que.top());
		que.pop();
	}
	cout << res << endl;
	return 0;
}



Measured memory_bytes: 2168
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric> 
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s, t;
	cin >> s >> t;
	reverse(t.begin(), t.end());
	cout << ((s == t) ? "YES" : "NO") << endl;
	return 0;
}



Measured memory_bytes: 256
use proconio::input;
use proconio::marker::Chars;

fn main() {
    input!{
        _n: usize,
        stones: Chars, 
    }
    let mut red_count = 0;

    for s in &stones {
        if *s == 'R' {
            red_count+=1;
        }
    }

    let mut ans = 0;

    for s in &stones {
        if red_count == 0 {
            break;
        }
        if *s == 'W' {
            red_count-=1;
            ans+=1;
        } else {
            red_count-=1;
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 3020
/*   ꧁༒☬महाकाल☬༒꧂ ꧁༒ঔमहाकालঔ༒꧂
                   
                   ঔৣ۝महाकालᴳᵒᵈ۝ঔৣ            
 
 */ 
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template <typename T, typename cmp=less<T>> using oset =tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define ll long long 
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define _it iterator
#define all(_x) _x.begin(),_x.end()
#define f first
#define s second
#define pb push_back
void mahakal(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	freopen("error.txt","w",stderr);
	#endif
}
int main(){
	//mahakal(),fast;
	
	ll r ;
	cin>> r ;
	ll ans = r*r ;
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#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 ALL(x) begin(x),end(x)
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef vector<int> VI;
typedef pair<int,int> PII;

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

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    LL a=100, x;
    cin >> x;
    int t=0;
    while ( a<x ) {
        a*=1.01;
        t++;
    }
    cout << t << '\n';
    return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
#define pii pair<int, int>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const int INF = 1e8;

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

    vector<int> a(m), b(m), c(m);
    rep(i, m) {
        cin >> a[i] >> b[i] >> c[i];
        a[i]--;  b[i]--;
    }

    vector<vector<int>> dist(n, vector<int>(n, INF));
    rep(i, n) {
        rep(j, n) {
            if(i == j) {
                dist[i][j] = 0;
            }
        }
    }

    rep(i, m) {
        dist[a[i]][b[i]] = min(dist[a[i]][b[i]], c[i]);
        dist[b[i]][a[i]] = min(dist[b[i]][a[i]], c[i]);
    }

    rep(k, n) {
        rep(i, n) {
            rep(j, n) {
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }

    int ans = m;
    rep(i, m) {

        int shortest = 0;
        rep(j, n) {
            if(dist[j][a[i]] + c[i] == dist[j][b[i]]) {
                shortest = 1;
            }
        }

        if(shortest) {
            ans--;
        }
    }

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

Measured memory_bytes: 256
#pragma region RegionDefs
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include "boost/multi_array.hpp"
#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define reps(i,j,n) for(int i=(j),i##_len=(n);i<i##_len;++i)
#define repr(i,n) for(int i=(n);i>=0;--i)
#define all(x) (x).begin(),(x).end()
using namespace std;
template<class T=int> using P  = pair<T, T>;
template<class T=int> using V  = vector<T>;
template<class T=int> using PQ = priority_queue<T>;
template<class T=int> using PQG = priority_queue<T, V<T>, greater<T>>;
typedef long long ll;
const int INF = 1e9;
const ll MOD = 1000000007LL;
void in() {}
template<class Head, class... Tail>
void in(Head&& head, Tail&&... tail)
{
    cin >> head;
    in(move(tail)...);
}
#define IN(...) int __VA_ARGS__; in(__VA_ARGS__)
#define VIN(T, v, n) V<T> v(n); for(auto& _elem:v)cin>>_elem
#pragma endregion RegionDefs

void solve()
{
    IN(n, k);
    ll s = 0;
    reps(i, k+1, n+1)
    {
        s += (i-k)*(n/i) + max(0, n%i-k+1);
    }
    if (k == 0)
    {
        s -= n;
    }
    cout << s << endl;
}

int main()
{
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(numeric_limits<double>::max_digits10);

    solve();

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,n) for (int i=(n-1);i >= 0;i--)
#define all(v) v.begin(),v.end()
#define sz(v) (int)((v).size())
#define MAX(v) *max_element(all(v))
#define MIN(v) *min_element(all(v))
using namespace std; using ll = long long; using P = pair<int,int>;
using vl = vector<ll>; using vvl = vector<vl>;
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
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 = 1LL << 60;
const int dx[8] = {1,0,-1,0,1,1,-1,-1}; const int dy[8] = {0,1,0,-1,1,1,-1,-1};

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    ll n,m;
    IN(n,m);
    vl x(m);
    rep(i,m) cin >> x[i];
    sort(all(x));
    if(n >= m){
        cout << 0 << endl;
        return 0;
    }

    // 開区間の長さの情報
    vl l(m-1);
    rep(i,m-1){
        l[i] = x[i+1] - x[i];
    }
    sort(all(l),greater<ll>());
    ll ans = x[m-1] - x[0];
    rep(i,n-1){
        ans -= l[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
import Control.Monad
match a b i j = let m = length b in b == (map (take m . drop j) . take m . drop i) a
main = do
    [n, m] <- map read . words <$> getLine
    a <- replicateM n getLine
    b <- replicateM m getLine
    putStrLn (if or [match a b i j | i <- [0..n-m], j <- [0..n-m]] then "Yes" else "No")

Measured memory_bytes: 1020
using System;
using System.Linq;

public class Program
{
	public static void Main()
	{
        int[] num = Console.ReadLine().Split(' ').Select(n => int.Parse(n)).ToArray();
        Array.Sort(num);
        if(num[0] == num[1] && num[0] == 5 && num[2] == 7)Console.WriteLine("YES");
        else Console.WriteLine("NO");
	}
}

Measured memory_bytes: 11348
use std::io;

fn read_line()-> String {
    let mut s = String::new();
    let _ = io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main () {
	let a = read_line().parse::<i32>().unwrap();
	let b = read_line().parse::<i32>().unwrap();
	let h = read_line().parse::<i32>().unwrap();
	let r = ((a+b)*h)/2;
	println!("{}",r);

}


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

template <typename T>
class SegTree{
  using F = function<T(T,T)>;
  int n; T uni; F f;
  vector<T> dat;
  T query_sub(int a, int b, int k, int l, int r) {
    if(r <= a || b <= l) return uni;
    if(a <= l && r <= b) return dat[k];
    T vl = query_sub(a, b, k*2+1, l, (l+r)/2);
    T vr = query_sub(a, b, k*2+2, (l+r)/2, r);
    return f(vl,vr);
  }
public:
  SegTree(int _n, F f, T uni) : f(f), uni(uni) {
    n = 1;
    while(n < _n) n *= 2;
    dat = vector<T>(2*n-1,uni);
  }
  void update(int k, T a) {
    k += n-1;
    dat[k] = a;
    while(k > 0){
      k = (k-1)/2;
      dat[k] = f(dat[2*k+1], dat[2*k+2]);
    }
  }
  T query(int a, int b) {
    return query_sub(a, b, 0, 0, n);
  } // [a,b)
};

int main(){
  int n;
  cin >> n;
  ll a[n], b[n];
  SegTree<P> st(n,[](P a, P b){return max(a,b);},P(-1,-1));
  bool can = true;
  rep(i,n) cin >> a[i];
  rep(i,n) {
    cin >> b[i];
    if(a[i] > b[i]) can = false;
    st.update(i,P(b[i],i));
  }
  if(!can) {
    cout << -1 << endl;
    return 0;
  }
  ll d = 0;
  vector<bool> fix(n,false);
  while(true) {
    P p = st.query(0,n);
    if(p.first == -1) break;
    int l = (p.second-1+n) % n, r = (p.second+1) % n;
    ll s = b[l] + b[r];
    ll c = min(b[p.second]/s,(b[p.second]-a[p.second])/s);
    if(c == 0) {
      fix[p.second] = true; st.update(p.second,P(-1,p.second));
    } else {
      b[p.second] -= s*c;
      st.update(p.second,P(b[p.second],p.second));
      d += c;
    } 
  }
  rep(i,n) {
    if(a[i] != b[i]) can = false;
  }
  cout << (can? d : -1) << endl;
  return 0;
}

Measured memory_bytes: 11648
#include <stdio.h>
int z[9999],r[9999];
int f(int a,int b){
	printf("? %d %d\n",a,b);
	fflush(stdout);
	char c[2];
	scanf("%s",c);
	return *c=='Y';
}
int main(){
	int a,b,c=0,h;
	scanf("%d%d",&a,&b);
	if(a<=b){puts("Impossible");return 0;}
	for(int i=0;i<a+b;i++){
		if(!c||f(z[c-1],i)){
			z[c++]=i;
		}else{
			c--;
		}
	}
	h=z[c-1];
	for(int i=0;i<a+b;i++){
		r[i]=h==i||f(h,i);
	}
	printf("! ");
	for(int i=0;i<a+b;i++)printf("%d",r[i]);
	puts("");
}

Measured memory_bytes: 720
#include <bits/stdc++.h>
using namespace std;
#define _USE_MATH_DEFINES
#define ios std::ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define PI acos(-1.0) //3.14159265358
#define EPS 1e-9 //epsilon, 10^-9, checking for equality 
#define pb push_back
#define fi first
#define se second
#define sz(x) x.size()
#define rep(i,n) for(int i=0;i<n;i++)
#define isort(x) sort(x.begin(),x.end())
#define dsort(x) sort(x.rbegin(),x.rend())
const int inf=1e9+7; //10^9 +7
const int modc=998244353;
typedef long long int ll;typedef vector<int> vi;typedef vector<ll> vll;
typedef pair<int,int> ii;typedef map<int,int> mii;
inline void rvi(vi &v, int n){int temp; rep(i,n){cin>>temp;v.pb(temp);}}
inline void rvll(vll &v, int n){ll temp;rep(i,n){cin>>temp;v.pb(temp);}}
inline void prvi(vi &a){rep(i,sz(a)){cout<<a[i]<<" ";}cout<<endl;}
inline void prvll(vll &a){rep(i,sz(a)){cout<<a[i]<<" ";}cout<<endl;}
inline vll prefixsum(vi &a){vll b;b.pb(a[0]);for(int i=1;i<sz(a);i++){b.pb(a[i]+b[i-1]);}return b;}
inline vll suffixsum(vi &a){vll b(sz(a));b[sz(a)-1]=a[sz(a)-1];for(int i=sz(a)-1;i>=0;i--){b[i]=a[i]+b[i+1];}return b;}
inline vll prefixsum(vll &a){vll b;b.pb(a[0]);for(int i=1;i<sz(a);i++){b.pb(a[i]+b[i-1]);}return b;}
inline vll suffixsum(vll &a){vll b(sz(a));b[sz(a)-1]=a[sz(a)-1];for(int i=sz(a)-1;i>=0;i--){b[i]=a[i]+b[i+1];}return b;}
void solve();int main(){ios;solve();return 0;}
//--------SOLVE--------------------------------------------------------------------
void solve()
{
	int n;cin>>n;
	vi a;
	rvi(a,n);
	int dp[100005];
	dp[0]=0;
	dp[1]=abs(a[1]-a[0]);
	for(int i=2;i<n;i++)
	{
		dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
	}
	cout<<dp[n-1]<<endl;
}

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

#define rep(i,n) for (int i = 0; i < (n); ++i)

using namespace std;
typedef long long ll;
typedef pair<int, int> pint;

const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;


int main() {
    int n; cin >> n;
    string s; cin >> s;
    vector<bool> dp(n);
    rep(first, 2) rep(second, 2) {
        dp[0] = first;
        dp[1] = second;
        for (int i = 2; i < n; ++i) {
            if (s[i-1] == 'o') {
                dp[i] = !(dp[i-1]^dp[i-2]);
            } else {
                dp[i] = (dp[i-1]^dp[i-2]);
            }
        }
        if (dp[n-1] ^ (s[n-1] == 'o')) {
            if (dp[n-2] == dp[0]) continue;
        } else {
            if (dp[n-2] != dp[0]) continue;
        }

        if (dp[0] ^ (s[0] == 'o')) {
            if (dp[n-1] == dp[1]) continue;
        } else {
            if (dp[n-1] != dp[1]) continue;
        }

        string ans = "";
        rep(i, n) {
            if (dp[i]) ans += "S";
            else ans += "W";
        }
        cout << ans << endl;
        return 0;

    }

    cout << -1 << endl;


    return 0;
}


    


Measured memory_bytes: 768
#include <iostream>
#include <vector>
#include <deque>
using i64 = long long;

std::vector<int> comp, done;
std::vector<std::vector<int>> g, r, scc, vs;
std::deque<int> t;

void add_edge(const int u, const int v) {
    g[u].push_back(v);
    r[v].push_back(u);
}

void dfs(const int v, const int p = -1) {
    if (done[v]) return;
    done[v] = 1;
    for (auto to : g[v]) {
        if (v == p) continue;
        dfs(to, v);
    }
    t.push_front(v);
}

void dfs2(const int v, const int p, const int c) {
    if (comp[v] >= 0) return;
    comp[v] = c;
    for (auto to : r[v]) {
        if (v == p) continue;
        dfs2(to, v, c);
    }
}

int main() {
    int n, m;
    std::cin >> n >> m;
    g.resize(n); r.resize(n); comp.resize(n, -1); done.resize(n);
    for (int i = 0; i < m; i++) {
        int a, b;
        std::cin >> a >> b;
        add_edge(a, b);
    }

    for (int i = 0; i < n; i++) if (!done[i]) dfs(i);

    int c = 0;
    for (auto i : t) if (comp[i] < 0) dfs2(i, -1, c++);

    scc.resize(c), vs.resize(c);
    for (int i = 0; i < n; i++) {
        vs[comp[i]].push_back(i);
        for (const auto to : g[i]) {
            const int j = comp[i], k = comp[to];
            if (j != k) scc[j].push_back(k);
        }
    }

    std::cout << c << '\n';
    for (int i = 0; i < c; i++) {
        std::cout << vs[i].size();
        for (const int v : vs[i]) std::cout << ' ' << v;
        std::cout << '\n';
    }

    return 0;
}


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

ll n,a,b,ans;

int main()
{
    cin >> n >> a >> b;
    ans=n/(a+b);
    ans*=a;
    n%=(a+b);
    ans+=min(a,n);
    cout << ans << endl;
}


Measured memory_bytes: 256
let partition (a : int array) p r =
  let swap i j = let tmp = a.(i) in a.(i) <- a.(j); a.(j) <- tmp in
  let rec doit = function
    | (i, j) when j = r -> swap i r; i
    | (i, j) when a.(j) <= a.(r) -> swap i j; doit (i + 1, j + 1)
    | (i, j) -> doit (i, j + 1) in
  doit (p, p)

let () =
  let n = read_int () in
  let a = Array.init n (fun _ -> Scanf.scanf "%d " (fun i -> i)) in
  let k = partition a 0 (n - 1) in
  Array.iteri (fun i e -> Printf.printf (if i = 0 then "%d" else if i = k then " [%d]" else " %d") e) a;
  print_newline ()

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

int used[100005];

int main(){
    int n,m;
    cin>>n>>m;
    int h[n+1];
    REP(i,n){
        cin>>h[i];
    }
    vector<vector<int>> g(n+1);
    rep(i,m){
        int a,b;
        cin>>a>>b;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    int ans = 0;
    REP(i,n){
        if(used[i]==0){
            bool fl=true;
            for(auto v:g[i]){
                if(h[v]>=h[i]){
                    fl = false;
                    break;
                }else{
                    used[v]=1;
                }
            }
            if(fl) {
                ans++;

                }

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

Measured memory_bytes: 9068
/*--------------------------"SABUJ-JANA"------"JADAVPUR UNIVERSITY"--------*/
/*-------------------------------@greenindia-----------------------------------*/
//
//		  _____       _           _        _
//		 / ____|     | |         (_)      | |
//		| (___   __ _| |__  _   _ _       | | __ _ _ __   __ _
//		 \___ \ / _` | '_ \| | | | |  _   | |/ _` | '_ \ / _` |
//		 ____) | (_| | |_) | |_| | | | |__| | (_| | | | | (_| |
//		|_____/ \__,_|_.__/ \__,_| |  \____/ \__,_|_| |_|\__,_|
//		                        _/ |
//		                       |__/
/*---------------------- Magic. Do not touch.-----------------------------*/
/*------------------------------God is Great/\---------------------------------*/
#include <bits/stdc++.h>
using namespace std;
#define crap ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
//cout<<fixed<<showpoint<<setprecision(12)<<ans<<endl;
#define int long long int
#define double long double
#define PI acos(-1)
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
#define endl "\n"

void print1d(const vector<int>& vec) {for (auto val : vec) {cout << val << " ";} cout << endl;}

void print2d(const vector<vector<int>>& vec) {for (auto row : vec) {for (auto val : row) {cout << val << " ";} cout << endl;}}

vi powers;
vi primes;

void pf(int n) {

	int x = sqrt(n);
	for (int i = 2; i <= x; i++) {
		if (n % i == 0) {
			// i is a prime factor
			int cnt = 0;
			while (n % i == 0) {
				n /= i;
				cnt++;
			}

			powers.push_back(cnt);
			primes.push_back(i);
		}
	}

	if (n > 1) {
		powers.push_back(1);
		primes.push_back(n);
	}

}

void solve() {
	int n;
	cin >> n;

	pf(n);

	// print1d(primes);
	// print1d(powers);

	vi prefix(40);
	prefix[0] = 0;
	for (int i = 1; i < 40; ++i) {
		prefix[i] = prefix[i - 1] + i;
	}

	int cnt = 0;
	for (auto x : powers) {
		auto idx = upper_bound(prefix.begin(), prefix.end(), x) - prefix.begin();
		if (idx != 0) {
			idx--;
			cnt += idx;
		}
	}

	cout << cnt << endl;
}

signed main() {
	crap;

	solve();

	return 0;
}

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

class Solve {
private:
    using vi = std::vector<int>;
    using vvi = std::vector<vi>;
    using vb = std::vector<bool>;
    using vvb = std::vector<vb>;

    int D, W;
    vvi height;
    vvb visited;
    int calcMin(int t, int b, int l, int r)
    {
        int min{100};
        for (int i{t - 1}; i <= b + 1; i++)
            min = std::min({min, height[i][l - 1], height[i][r + 1]});
        for (int i{l - 1}; i <= r + 1; i++)
            min = std::min({min, height[t - 1][i], height[b + 1][i]});
        return min;
    }

    int calcCap(int t, int b, int l, int r, int h)
    {
        int ret{};
        for (int i{t}; i <= b; i++)
            for (int j{l}; j <= r; j++)
            {
                if (height[i][j] >= h) return -1;
                ret += h - height[i][j];
            }
        return ret;
    }
public:
    bool is_last_{};
    Solve()
    {
        scanf("%d%d", &D, &W);
        if (D == 0 && W == 0)
        {
            is_last_ = true;
            return;
        }
        height.resize(D + 2, vi(W + 2, -1));
        for (int i{1}; i <= D; i++)
            for (int j{1}; j <= W; j++)
                scanf("%d", &height[i][j]);
        int max{};
        for (int t{2}; t < D; t++)
            for (int b{t}; b < D; b++)
                for (int l{2}; l < W; l++)
                    for (int r{l}; r < W; r++)
                    {
                        int h{calcMin(t, b, l, r)};
                        max = std::max(max, calcCap(t, b, l, r, h));
                    }
        printf("%d\n", max);
    }
};

int main()
{
    while (!Solve().is_last_);

    return 0;
}


Measured memory_bytes: 3260
#include<stdio.h>
#include<string.h>
#include<stdlib.h>

int main(void){
  int a[26],i,j;
  char tmp,t[26]="abcdefghijklmnopqrstuvwxyz",s[100000];
  scanf("%s",s);
  for(i=0;i<26;i++){
    a[i]=1;
  }
  //for(i=0;i<26;i++) printf("%c",t[i]);
  for(i=0;i<strlen(s);i++){
    for(j=0;j<26;j++){
      if(s[i]==t[j]) a[j]=0;
    }
  }
  for(i=0;i<26;i++){
    if(a[i]==1){
      printf("%c\n",t[i]);
      return 0;
    }
  }
  printf("None\n");
  return 0;
}

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

int main(){
    int x, n;
    cin >> x >> n;
    vector<int> p(101);
    for(int i = 0; i < n; i++) cin >> p[i];
    vector<bool> backet(102, false);
    for(int i = 0; i < n; i++) backet[p[i]] = true;
    int dist = 200;
    int ans = 0;
    for(int i = 0; x-i >= 0; i++){
        if(!backet[x-i]){
            dist = i;
            ans = x-i;
            break;
        }
    }
    for(int i = 1; i+x <= 101; i++){
        if(!backet[x+i]){
            if(dist > i){
                dist = i;
                ans = x+i;
            }
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<vector>
#include<algorithm>
#define INF 1000000000
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
signed main(){
  ll n,m,p,a,b,c,next;
  ll d[3000];
  bool used[3000]={};
  vector<P> G[3000];
  cin >> n >> m >> p;
  fill(d,d+3000,0);
  used[0]=true;
  for(int i=0;i<m;i++){
    cin >> a >> b >> c;
    a--;
    b--;
    G[a].push_back(P(b,c));
  }
  for(int i=0;i<2*n;i++){
    for(int j=0;j<n;j++){
      for(int k=0;k<G[j].size();k++){
        if(!used[j]) continue;
        next = G[j][k].first;
        if(!used[next]){
          d[next] = d[j]+G[j][k].second-p;
          used[next]=true;
        }
        d[next] = max(d[next],d[j]+G[j][k].second-p);
      }
    }
  }
  for(int i=0;i<n*2;i++){
    for(int j=0;j<n;j++){
      for(int k=0;k<G[j].size();k++){
        if(!used[j]) continue;
        next = G[j][k].first;
        if(d[next]<d[j]+G[j][k].second-p){
          d[next] = INF;
        }
      }
    }
  }
  /*
  for(int i=0;i<n;i++){
    cout << d[i]<<endl;
  }
  */
  if(d[n-1]>=INF){
    cout << "-1\n";
  }else{
    cout << max(d[n-1],(ll)0)<<endl;
  }
}


Measured memory_bytes: 512
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using ll=long long;
using ld=long double;
//#define int long long
#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for (int i = 0; i < n; i++)
#define _GLIBCXX_DEBUG
#define ALL(x) (x).begin(), (x).end()
const int MOD = 1e9 + 7;
const int INF = 1e18 + 9;
constexpr long double pi = 3.141592653589793238462643383279;
int fact(int i) {
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
int gcd(int a, int b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int keta(int n) {
    if (n == 0) return 1;
    int count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
int ketasum(int n) {
    int sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
char toSmall(char c) { // 大文字を小文字へ
    return (c + 0x20);
}
char toLarge(char c) { // 小文字を大文字へ
    return (c - 0x20);
}
float myPower(int a, int n) { // aのn乗の計算
    float x = 1;
    while (n > 0) { // 全てのbitが捨てられるまで
        if (n & 1) { // 一番右のbitが１のとき
            x *= a;
        }
        a *= a;
        n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
    }
    return x;
}
bool is_prime(const unsigned n) {
    switch (n) {
    case 0: // fall-through
    case 1: return false;
    case 2: // fall-through
    case 3: return true;
    } // n > 3 が保証された

    if (n % 2 == 0 || n % 3 == 0) return false;
    // n は 2 と 3 のいずれの倍数でもないことが保証された
    // これより n は (6の倍数)-1 か (6の倍数)+1 である
    // 6の倍数前後の数を使って試し割りをする
    for (unsigned i = 5; i * i <= n; i += 6) {
        if (n % i == 0) return false; // (6の倍数)-1
        if (n % (i + 2) == 0) return false; // (6の倍数)+1
    }

    return true;
}
int main(void){
    int a, b;
    cin >> a >> b;
    int k = a + b + 1;
    string s;
    cin >> s;
    int cnt = 0;
    rep(i, k) {
        if (s[i] == '-') cnt++;
    }
    if (cnt == 1 && s[a] == '-') cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3616
#include<stdio.h>
int main(){
  long int a, b, c;
  scanf("%ld %ld", &a, &b);
  long int d = a % b;
  if(b % 2 == 1){
    if(d <= (b - 1) / 2){
      printf("%ld", d);
    }else{
      c = b - d;
      printf("%ld", c);
    }
  }
  else{
    if(d < b / 2){
      printf("%ld", d);
    }else{
      c = b - d;
      printf("%ld", c);
    }
  }
  
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;
int H, W;
int A[80][80];
int B[80][80];

bool dp1[80][80][16000];
bool dp2[80][80][16000];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    cin >> H >> W;
    for(int i = 0; i < H;i++){
        for(int j = 0; j < W; j++){
            cin >> A[i][j];
        }
    }
    for(int i = 0; i < H;i++){
        for(int j = 0; j < W; j++){
            cin >> B[i][j];
            if(A[i][j] < B[i][j]) swap(A[i][j], B[i][j]);
        }
    }
    dp1[0][0][A[0][0]-B[0][0]] = true;
    dp2[0][0][A[0][0]-B[0][0]] = true;
    for(int i = 0; i < H;i++){
        for(int j = 0; j < W; j++){
            if(i-1 >= 0){
                for(int k = 0; k < 16000; k++){
                    if(dp1[i-1][j][k]){
                        dp1[i][j][k+A[i][j]-B[i][j]] = true;
                        if(k-A[i][j]+B[i][j] >= 0) dp1[i][j][k-A[i][j]+B[i][j]]= true;
                        else dp2[i][j][-(k-A[i][j]+B[i][j])]= true;
                    }
                    if(dp2[i-1][j][k]){
                        dp2[i][j][k+A[i][j]-B[i][j]] = true;
                        if(k-A[i][j]+B[i][j] >= 0) dp2[i][j][k-A[i][j]+B[i][j]]= true;
                        else dp1[i][j][-(k-A[i][j]+B[i][j])]= true;
                    }
                }
            }
            if(j-1 >= 0){
                for(int k = 0; k < 16000; k++){
                    if(dp1[i][j-1][k]){
                        dp1[i][j][k+A[i][j]-B[i][j]] = true;
                        if(k-A[i][j]+B[i][j] >= 0) dp1[i][j][k-A[i][j]+B[i][j]]= true;
                        else dp2[i][j][-(k-A[i][j]+B[i][j])]= true;
                    }
                    if(dp2[i][j-1][k]){
                        dp2[i][j][k+A[i][j]-B[i][j]] = true;
                        if(k-A[i][j]+B[i][j] >= 0) dp2[i][j][k-A[i][j]+B[i][j]]= true;
                        else dp1[i][j][-(k-A[i][j]+B[i][j])]= true;
                    }
                }
            }
        }
    }
    int ans = 20000000;
    for(int k = 0; k < 16000; k++){
        if(dp1[H-1][W-1][k]) ans = min(ans, k);
        if(dp2[H-1][W-1][k]) ans = min(ans, k);
    }
    cout << ans << endl;
}

Measured memory_bytes: 198912
#include <cstdio>
#include <iostream>

#define REP(a, n) for (int i = (a); i < (n); i++)
#define RREP(a, n) for (int j = (a); j < (n); j++)

using namespace std;

int dp[1405][1405];
int main()
{
  int h, w, ma = 0;
  scanf("%d%d", &h, &w);
  bool oo[h + 1][w + 1];

  REP(0, h){
    RREP(0, w){
      scanf("%d", &oo[i][j]);
      if (!oo[i][j]){
        dp[i][j] = 1;
        ma = 1;
      }
    }
  }
  REP(1, h){
    RREP(1, w){
      if (!oo[i][j]){
        dp[i][j] = min(dp[i - 1][j - 1], min(dp[i - 1][j], dp[i][j - 1])) + 1;
        ma = max(ma, dp[i][j]);
      }
    }
  }
  printf("%d\n", ma * ma);
}

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

int main() {
  int a, b, c; cin >> a >> b >> c;
  if(a==5 && b==7 && c==5) cout << "YES";
  else if(a==5 && b==5 && c==7) cout << "YES";
  else if(a==7 && b==5 && c==5) cout << "YES";
  else cout << "NO";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	string s;
	getline(cin,s);
	
	transform (s.begin (), s.end (), s.begin (), ::toupper);
	
	cout << s << endl;
	
	return 0;
}

Measured memory_bytes: 3140
#include <stdio.h>
int main(void)
{
    int A,B,C;
    scanf("%d%d%d",&A,&B,&C);

    int D = A-B;
    int E = C-D;

    if(E <= 0){
        printf("%d\n", 0);
    }

    if(0 < E){
        printf("%d\n", E);
    }

    return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
int v[200005];
bool f[200005];
int main() {
    int n,x;
    scanf("%d",&n);
        int ss=0;
        memset(v, 0, sizeof(v));
        memset(f, false, sizeof(f));
        for (int i=1; i<=n; i++) {
            scanf("%d",&x);
            if(f[x-1]==true)
            {
                v[x]=v[x-1]+1;
                f[x]=true;
                ss=max(ss, v[x]);
            }
            else{
                v[x]=1;
                f[x]=true;
                ss=max(ss, v[x]);
            }
        }
    printf("%d\n",n-ss);
    return 0;
}


Measured memory_bytes: 1152
/***** author :  C0d1ngPhenomena *****/

#include <bits/stdc++.h>
#define endl "\n"
#define ll long long int
#define TestCases int T; cin>>T; while(T--)
#define rep(i,a,b) for(ll i = a; i < b; i++)
#define revrep(i,a,b) for(ll i = b-1; i >= a; i--)
#define vll vector<ll>
#define vvll vector < vll >
#define pll pair<ll, ll>
#define vpll vector <pll>
#define mp(x,y) make_pair(x,y)
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define alld(c) c.begin(),c.end(),greater<int>()
#define mem(a,val) memset(a,val,sizeof(a))
#define f first
#define s second
#define pb push_back
using namespace std;

bool sortbysec(const pair<int, int> &a, const pair<int, int> &b)
{
	return (a.second < b.second);
}





int main()
{
	std::ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	ll n, k;
	cin >> n >> k;
	vll heights(n);

	rep(i,0,n)
		cin >> heights[i];

	vll dp(n+1);
	rep(i,0,n)
	dp[i]=INT_MAX;
	dp[0] = 0;
	dp[1] = abs(heights[1] - heights[0]);

	rep(i, 2, n)
	{
		rep(j, 1, k+1)
		{
			if(j > i)
				break;

			dp[i] = min(dp[i], dp[i-j] + abs(heights[i] - heights[i-j]));
		
		}

	}

	cout << dp[n-1];





	return 0;
}







Measured memory_bytes: 4784
#include<bits/stdc++.h>
using namespace std;
using lli = long long int;
using ld = long double;
using ulli = unsigned long long int;
#define filein freopen ("in.txt", "r", stdin)
#define fileout freopen ("out.txt", "w", stdout)
#define dbg(args...) do {cerr << #args << " : "; debug(args); } while(0)
#define all(v) ((v).begin()),((v).end())
#define size(x) (int) x.size() 
#define pb emplace_back
#define mp make_pair
#define PI 3.14159265
#define mod 1000000007
void debug () {cerr << endl;}
template< class T > T gcd(T a, T b) { return (b != 0 ? gcd<T>(b, a%b) : a); }
template< class T > T lcm(T a, T b) { return (a / gcd<T>(a, b) * b); }
template < typename T, typename ... hello>void debug( T arg, const hello &... rest) {cerr << arg << ' ';debug(rest...);}
int main(){
	ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int x,n;
    cin >> x >> n;
    unordered_map<int,bool> count;
    if(n == 0){
		cout<<x;
		return 0;
	}
	for(int i = 1;i <= n; i++){
		int in;
		cin >> in;
		count[in] = true;
	}
	int min_diff = INT_MAX,ans = -1;
	for(int i = 0; i <= 101; i++){
		if(!count[i]){
			if(abs(x - i) < min_diff){
				min_diff = abs(x - i);
				ans = i;
			}
		}
	}
	cout<<ans;
}


Measured memory_bytes: 3620
#include <stdio.h>
int main(void) {
	int s[10000], t, n, q, i, num_intersection = 0;

	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d", s+i);
	}
	scanf("%d", &q);
	while (q--) {
		scanf("%d", &t);
		for (i = 0; i < n; i++) {
			if (t == s[i]) {
				s[i] = -1;
				num_intersection++;
				break;
			}
		}
	}
	printf("%d\n", num_intersection);
	return 0;
}



Measured memory_bytes: 2076
n,a,b = map(int,input().split())
'''
bbbbrrbbbbrr...
n // (a+b) : a+b個の塊がn個のなかにいくつ入っているか
n % (a+b)  : a+b個の列のうち、いくつまで入るか
'''

ans = n // (a+b) * a + min(n % (a+b), a)
print(ans)

Measured memory_bytes: 9088
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ll long long
#define si(n) scanf("%d",&n);
#define PI acos(-1.0)
#define sl(n) scanf("%lld",&n);
#define sf(n) scanf("%lf",&n);
#define ss(n) scanf("%s",n);
#define for0(i,n) for(ll i=0;i<n;i++)
#define for1(i,n) for(ll i=1;i<=n;i++)
#define forc(i,j,n) for(ll i=j;i<n;i++)
#define pb push_back
#define sor(n) sort(n.begin(),n.end())
#define sorcmp(n) sort(n.begin(),n.end(),cmp)
#define rev(n) reverse(n.begin(),n.end())
#define pi(x)  printf("%d",x);
#define pl(x)  printf("%lld",x);
#define pf(x)  printf("%.10lf",x);
#define ps(x)  printf("%s",x);
#define en() printf("\n");
#define random_shuffle(r...)random_shuffle(r,[](int _){return rand()%_;})
#define SQR(a) (a)*(a)
#define sp(x) fixed<<setprecision(x)
#define mod 1000000007
#define endl '\n'
#define pii pair<int,int>
#define pll pair<ll,ll>
#define bug cout<<"Here"<<endl
void fastio(){ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);}
template <typename T> T POW(T B,T P){ if(P==0) return 1; if(P&1) return B*POW(B,P-1);  else return SQR(POW(B,P/2));}
ll powmod(ll a, ll b){ll ans = 1;while(b){if(b&1) ans = ans*a%mod;a = a*a%mod;b >>= 1;}return ans;}

int main(){


        int a,b,h,m;
        cin>>a>>b>>h>>m;

        long double t1=0.5*(h*60+m);
        long double t2=6*m;

        long double ang=abs(t1-t2);

        ang=min(360-ang,ang);


        ang=ang* (acos(-1))/180.0;

        long double temp= a*a+b*b-2*a*b*cos(ang);
        cout<<sp(10)<<sqrtl(temp)<<endl;

return 0;
}



Measured memory_bytes: 4144
name="zabcdefghijklmnopqrstuvwxy"
def namer(number):
    if number<=26 :
        return name[number%26]
    if name[number%26]=='z':
        return namer((number//26)-1)+name[number%26]
    return namer(number//26)+name[number%26]
    
number=int(input())
print(namer(number))

Measured memory_bytes: 9172
N, Q = map(int, input().split())
S = "0" + input()
LR = []
for _ in range(Q):
    l, r = map(int, input().split())
    LR.append((l, r))

num = [0] * (N + 1)
for i in range(2, N + 1):
    if S[i - 1] == "A" and S[i] == "C":
        num[i] = num[i - 1] + 1
    else:
        num[i] = num[i - 1]

for l, r in LR:
    print(num[r] - num[l])


Measured memory_bytes: 19888
/*
https://atcoder.jp/contests/dp/tasks/dp_k
*/

#include <bits/stdc++.h>
using namespace std;
bool dp[100001];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  int n,k;
  cin >> n >> k;
  int a[100];
  for(int i=0;i<n;i++) {
    cin >> a[i];
  }
  // dp[0] = 0;
  for(int i=1;i<=k;i++) {
    for(int j=0;j<n;j++) {
      if (a[j] <= i) {
        dp[i] |= !dp[i-a[j]];
      }
    }
  }
  if (dp[k]) cout << "First\n";
  else  cout << "Second\n";
  return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
#define fr(i,n) for(ll i=0;i<n;i++)

ll gcd(ll a,ll b){
  if(a*b == 0) return a+b;
  else if (a>=b) return gcd(b,a%b);
  else return gcd(a,b%a);
}

int main(){
  ll n,k,a[100000],gd = 0;
  cin >> n >> k;
  fr(i,n) cin >> a[i];
  sort(a,a+n);
  fr(i,n) gd=gcd(gd,a[i]);
  if(a[n-1] < k) cout << "IMPOSSIBLE";
  else{
    if((a[n-1]-k)%gd == 0) cout << "POSSIBLE";
    else cout << "IMPOSSIBLE";
  }
}

Measured memory_bytes: 1024