akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define FOR(i,a,n) for(ll i=(ll)a;i<(ll)n;i++)
#define RFOR(i,a,n) for(ll i=(ll)n-1;i >= (ll)a;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,0,n)
#define ALL(v) v.begin(), v.end()
#define bra(first,second) '(' << first << ',' << second << ')'
ll MOD = 1000000007;
//ll INF = 21474836470000000;
ll INF = 100100100100100100;
long double EPS = 1e-11;
long double PI = 3.141592653589793238;
template<typename T>
void remove(std::vector<T>& vector, unsigned int index){
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<ll>>;

string S;
ll K;

ll dp[110][2][10];

int main(){
    cin >> S >> K;
    dp[0][0][0] = 1;
    rep(i,S.size()){
        ll n = S[i] - '0';
        rep(j,K+1){
            if(n != 0){
                dp[i+1][1][j+1] += 9 * dp[i][1][j] + (n-1) * dp[i][0][j];
                dp[i+1][1][j] += dp[i][1][j] + dp[i][0][j];
                dp[i+1][0][j+1] += dp[i][0][j];
            }else{
                dp[i+1][1][j+1] += 9 * dp[i][1][j];
                dp[i+1][1][j] += dp[i][1][j];
                dp[i+1][0][j] += dp[i][0][j];
            }
        }
    }
    cout << dp[S.size()][0][K] + dp[S.size()][1][K] << endl;
}


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

int main(){
    vector<vector<int>> V(3, vector<int>(3));
    for(int i = 0; i < 3; i++){
        cin >> V.at(i).at(0) >> V.at(i).at(1) >> V.at(i).at(2);
    }
    int N;
    cin >> N;
    vector<int> W(N);
    for(int i = 0; i < N; i++){
        cin >> W.at(i);
    }
    //入力終了
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 3; j++){
            for(int k = 0; k < N; k++){
                if(W.at(k) == V.at(i).at(j)){
                    V.at(i).at(j) = 500500; //制約は100未満
                }
            }
        }
    }
    //マーク付け終了
    for(int i = 0; i < 3; i++){
        if((V.at(i).at(0) == V.at(i).at(1) && V.at(i).at(1) == V.at(i).at(2) && V.at(i).at(2) == 500500) || (V.at(0).at(i) == V.at(1).at(i) && V.at(1).at(i) == V.at(2).at(i) && V.at(2).at(i) == 500500) || (V.at(0).at(0) == V.at(1).at(1) && V.at(1).at(1) == V.at(2).at(2) && V.at(2).at(2) == 500500) || (V.at(0).at(2) == V.at(1).at(1) && V.at(1).at(1) == V.at(2).at(0) && V.at(2).at(0) == 500500)){
            cout << "Yes" << endl;
            goto ABC;
        }
    }
    cout << "No" << endl;
    ABC:
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fastIO(); ios_base::sync_with_stdio(false); cin.tie(NULL);
#define fr(i,a,b) for(lli i=a;i<b;i++)
#define f0(a,b) for(lli i=a;i<b;i++)
#define fn(b,a) for(lli i=b;i>a;i--)
#define dbg(x); cout<<"\n"<<#x<<": "<<x;
#define ret return
#define pb push_back
#define pf push_front
#define mp make_pair
#define E9 1000000007
#define E5 100007
#define INF 1e18+7
#define PI 3.1415926
#define sq(a) (a)*(a)
#define fs first
#define sc second
#define el "\n"
#define all(a) a.begin(),a.end()
typedef vector<long long int> vlli;
typedef vector<vector<long long int>> vvlli;
typedef vector<int> vi;
typedef map<char,int> mci;
typedef pair<long long int,long long int> pll;
typedef long long int lli;  //  e-18 to e18
void solve(){
    lli n,m,x,sum(0),cost(INF);
    bool check(1);
    cin>>n>>m>>x;
    vector<vector<lli>> b(n,vector<lli>(m+1));
    fr(i,0,n){
        fr(j,0,m+1)
            cin>>b[i][j];
    }
    fr(i,1,(1<<n)){
        sum=0;
        vector<lli> und(m);
        fr(j,0,n){
            if(i&(1<<j)){
                sum+=b[j][0];
                fr(k,0,m) und[k]+=b[j][k+1];
            }
        }
        check=1;
        fr(j,0,m) if(und[j]<x){check=0;break;}
        if(check) cost=min(cost,sum);
    }
    cout<<(cost!=INF?cost:-1)<<el;
}
int main(){
    fastIO();
    lli t(1);
    // cin>>t;
    while(t--) solve();
    ret 0; 
}                                                             

Measured memory_bytes: 3664
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<stack>
#include<map>
#include<deque>
#include<cstdio>
#include<cstdio>
#include<time.h>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define pd(a,n) for(int i=0;i<n;i++)cout<<a[i]<<((i==n-1)?"\n":" ")
#define pdd(a,n,m)for(int i=0;i<m;i++)pd(a,m)
#define mp make_pair
#define pb push_back
#define ll __int64
#define __int64 long long
#define P pair<int,int>
#define PP pair<P,int>

int n;
string t[222222];
map<string,int>ta;

int main(){
  cin>>n;
  rep(i,n)cin>>t[i];
  rep(i,n)ta[t[i]]++;
  int ma=-1;
  rep(i,n)ma=max(ma,ta[t[i]]);
  for(map<string,int>::iterator it=ta.begin();it!=ta.end();it++){
    string key=(*it).first;
    int value=(*it).second;
    if(value==ma)cout<<key<<endl;
  }

  return 0;
}


Measured memory_bytes: 26880
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    int n,h,w; cin>>n>>h>>w;
    cout<<(n-h+1)*(n-w+1)<<endl;
}


Measured memory_bytes: 3632
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <cstring>
#include <string>
#include <map>
#include <cmath>
#include <ctime>
#include <algorithm>
#include <bitset>
#include <queue>
#include <sstream>
using namespace std;
#define mp make_pair
#define pb push_back
#define re return
#define fi first
#define se second
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef vector<string> vs;
typedef vector<vi> vvi;
int n,k;
int a[100010];
int main() {
    //freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	cin>>n>>k;
	for(int i=0;i<n;i++)cin>>a[i];
	sort(a,a+n);
	int mn=1000000000;
	for(int i=0;i<n-k+1;i++)mn=min(mn,a[i+k-1]-a[i]);
	cout<<mn<<endl;
    return 0;
}

Measured memory_bytes: 640
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
 
#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
 
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
 
    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
 
#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
 
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
 
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
 
    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };
 
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
 
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}


fn main() {
    input! {
        s: chars,
        t: chars,
    }

    let pos = check_pos(&s, &t);

    match pos {
        None => println!("UNRESTORABLE"),
        Some(p) => {
            let mut tmp = Vec::with_capacity(s.len());

        for cs in s.iter().rev() {
            tmp.push(if *cs == '?'
                        {
                            'a'
                        } else {
                            *cs
                        });
        }
        
        for (i, ct) in t.iter().rev().enumerate() {
            tmp[p+i] = *ct; 
        }

        for a in tmp.iter().rev() {
            print!("{}", a);
        }
        println!("");
        },
    }

}

fn check_pos(s: &Vec<char>, t: &Vec<char>) -> Option<usize> {
    let t_len = t.len();
    if s.len() < t.len() {
        return None;
    }
    let len = s.len() - t.len() + 1;

    

    for i in 0..len {
            let mut count = 0;
            for (ct, cs) in t.iter().rev().zip(s.iter().rev().skip(i)) {
                if *cs == '?' || *cs == *ct {
                    //println!("cs: {}, ct {}", *cs, *ct);
                    count = count + 1;
                } else {
                    break;
                }
                if count == t_len {
                    return Some(i);
                }
            }
    }

    None

}


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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<vector<int>> e(n);
    for (int i = 1; i < n; i++) {
        int a; cin >> a;
        e[--a].emplace_back(i);
    }
    vector<int> h(n, 0);
    auto f = [&](auto f, int curr) -> void {
        vector<int> v;
        for (auto &to: e[curr]) {
            f(f, to);
            v.emplace_back(h[to]+1);
        }
        sort(v.rbegin(), v.rend());
        for (int i = 0; i < v.size(); i++) {
            h[curr] = max(h[curr], v[i]+i);
        }
    };
    f(f, 0);
    cout << h[0] << "\n";
    return 0;
}

Measured memory_bytes: 14976
import java.util.Scanner;

public class Main{
 public static void main(String[] args) {
   Scanner kbd =new Scanner(System.in);
   int a=kbd.nextInt();
   int b=kbd.nextInt();
   int c=kbd.nextInt();
   int k=kbd.nextInt();
   long A=0;//合計
   int M=0;//枚数
   int K=0;//回数
   while(M<k&&K<a){
    A++;
    M++;
    K++;
   }
   K=0;//回数
   while(M<k&&K<b){
    M++;
    K++;
   }
   K=0;//回数
   while(M<k){
    A--;
    M++;
    K++;
   }
   System.out.println(A);
 }
}

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

int main() {
	int N;
	cin >> N;
	map<long long, int> Nums;
	long long sum = 0ll;
	for (int i = 0; i < N; i++) {
		long long A;
		cin >> A;
		sum += A;
		Nums[A]++;
	}
	int Q;
	cin >> Q;
	vector<long long> Ans(Q);
	for (int i = 0; i < Q; i++) {
		long long B, C;
		cin >> B >> C;
		sum += -B * Nums[B] + C * Nums[B];
		Nums[C] += Nums[B];
		Nums[B] = 0;
		Ans[i] = sum;
	}
	for (long long a : Ans) cout << a << endl;

}


Measured memory_bytes: 9704
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintStream;

class Main {

    public static void main(String[] args) throws IOException {
        doit(args, System.in, System.out);
    }

    static void doit(String[] args, InputStream in, PrintStream out)
            throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(in));
        String line = null;
        while ((line = reader.readLine()) != null) {
            if (line.isEmpty()) {
                continue;
            }
            String[] values = line.split(" ");
            int[] ps = new int[8];
            for (int i = 0; i < 8; i++) {
                ps[i] = Integer.parseInt(values[i]);
            }
            int maxCount = 0;
            int maxIndex = 0;
            for (int i = 0; i < 8; i++) {
                int count = 0;
                for (int j = 0; j < 8; j++) {
                    count += Math.min(cs[i][j], ps[j]);
                }
                if (count > maxCount) {
                    maxCount = count;
                    maxIndex = i;
                }
            }
            out.print(cs[maxIndex][0]);
            for (int i = 1; i < 8; i++) {
                out.print(" " + cs[maxIndex][i]);
            }
            out.println();
        }
    }

    private static final int[][] cs = { { 1, 2, 1, 2, 1, 4, 1, 4 },
            { 1, 2, 1, 4, 1, 4, 1, 2 }, { 1, 4, 1, 2, 1, 2, 1, 4 },
            { 1, 4, 1, 4, 1, 2, 1, 2 }, { 2, 1, 2, 1, 4, 1, 4, 1 },
            { 2, 1, 4, 1, 4, 1, 2, 1 }, { 4, 1, 2, 1, 2, 1, 4, 1 },
            { 4, 1, 4, 1, 2, 1, 2, 1 }, };
}

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

int main() {
  string s;
  cin >> s;
  int K;
  scanf("%d", &K);

  vector<string> ans;
  for (int i = 0; i < s.length(); i++) {
    for (int j = 1; j <= s.length() - i; j++) {
      if (s.substr(i, j).length() <= K) ans.push_back(s.substr(i, j));
    }
  }

  sort(ans.begin(), ans.end());
  ans.erase(unique(ans.begin(), ans.end()), ans.end());

  printf("%s", ans.at(K - 1).c_str());
  return 0;
}


Measured memory_bytes: 1660
#include<bits/stdc++.h>
#define PI 2.0*acos(0.0)
#define ll              long long int
#define gcd(a,b)        __gcd(a,b)
#define lcm(a,b)        ((a)*(b))/gcd(a,b)
#define MOD             1000000007
#define mx              123456789
using namespace std;
int main()
{
    ll a, b, c, d, e, f, n, m, i, j, k, l;
    cin>>a>>b>>c>>k;
    ll sum=min(a,k);
    if(k>0)
        k-=min(a,k);
    if(k>0)
        k-=min(b,k);
    if(k>0)
        sum-=min(c,k);
    cout<<sum<<endl;
    return 0;
}


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

#define int long long

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

    int a[200010];
    for(int i = 0;i < n;i++){
        cin >> a[i];
    }

    int cnt = 0;
    int tmp = 0;
    int ans = 0;
    int le = 0;
    for(int i = 0;i < n;i++){
        while((tmp & a[i]) != 0){
            cnt--;
            tmp ^= a[le];
            le++;
        }
        tmp ^= a[i];
        cnt++;
        ans += cnt;
    }

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

Measured memory_bytes: 1792
#include <stdio.h>
#include <utility>
#include <algorithm>
#define mod 998244353
typedef long long ll;
using namespace std;

int main(void) {
  ll i, j, k, n, sn = 1, now = 1;
  scanf("%lld", &n);
  while(sn < n) sn <<= 1;
  pair<ll, ll> p[n];
  ll seg[2 * sn], las[2 * sn], ne[n + 1], sum[n + 1];
  for(i = 1; i < sn << 1; ++i) {
    seg[i] = 0;
    if(now << 1 == i) now <<= 1;
    las[i] = sn / now * (i - now + 1);
  }
  for(i = 0; i < n; ++i) scanf("%lld%lld", &p[i].first, &p[i].second);
  sort(p, p + n);
  sum[i] = 1;
  for(i = 0; i < n; ++i) {
    pair<ll, ll> tp = make_pair(p[i].first + p[i].second, 0);
    ne[i] = lower_bound(p, p + n, tp) - p;
  }
  for(i = n - 1; i >= 0; --i) {
    ll mmax = ne[i];
    now = 1;
    while( 1 ) {
      while(!(now & 1)) now >>= 1;
      while(las[now] > ne[i]) now <<= 1;
      if(mmax < seg[now]) mmax = seg[now];
      if(las[now] == ne[i]) break;
      now++;
    }
    sum[i] = sum[mmax] + sum[i + 1];
    sum[i] %= mod;
    seg[sn + i] = mmax;
    now = (sn + i) >> 1;
    while(now) {
      seg[now] = (seg[now << 1] > seg[(now << 1) + 1] ? seg[now << 1] : seg[(now << 1) + 1]);
      now >>= 1;
    }
  }
  printf("%lld", sum[0]);
  return 0;
}

Measured memory_bytes: 14592
#include <iostream>
#include<vector>
#include<bitset>
#define rep(i,n) for(int i = 0; i < (n); i++)

using namespace std;



int main() {
    //入力部
    int n,m;
    cin>>n>>m;
    vector<bitset<10>>a(n);     //n番目のスイッチがどの電球とつながっているかを表すビット列
    rep(i,m){
        int k;
        cin>>k;
        rep(j,k){
            int s;
            cin>>s;
            s--;
            a[s] |= 1<<i;       //電球の番号のビットを立てる
        }
    }
    bitset<10>p;        //目標のビット列
    rep(i,m){
        int x; cin>>x;
        p |= x<<i;
    }
    
    //ここから全探索
    int ans =0;     //条件を満たす方法が何通りあるかの答え
    rep(i,1<<n){        //スイッチの押し方を表すビット列で全探索
        bitset<10>t;        //現在の電球の状態を示すビット列
        rep(j,n){
            if((i>>j)&1){
                t ^= a[j];      //xorをとってスイッチを押す
            }
        }
        if(t == p){
            ans++;
        }
	}

    cout<<ans<<endl;
	
    

    return 0;
}

Measured memory_bytes: 3624
while True:
    height, width = map(int, input().split())
    if height == 0 and width == 0:
        break
    
    sx,sy,ex,ey = 0, 0, width-1, height-1
    for col in range(height):
        for row in range(width):
            if col == sy or col == ey or row == sx or row == ex:
                print("#", end='')
            else:
                print(".", end='')
        print("")
    print("")


Measured memory_bytes: 7016
#include <stdio.h>
int main () {
  int h, w, i, j, x;
  char s[51][51];
  scanf ("%d%d", &h, &w);
  for (i = 0; i < h; ++i) {
    scanf ("%s", s[i]);
  }
  x = 1;
  for (i = 0; i < h && x == 1; ++i) {
    for (j = 0; j < w; ++j) {
      if (s[i][j] == '.') {
        continue;
      } else if (s[i-1][j] == '#' || s[i][j-1] == '#' || s[i][j+1] == '#' || s[\
i+1][j] == '#') {
        continue;
      } else {
        x = 0;
        break;
      }
    }
  }
  if (x == 1) {
    printf ("Yes\n");
  } else {
    printf ("No\n");
  }
  return 0;
}

Measured memory_bytes: 1664
// E - Dist Max
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;

int main(){
	int N; cin>>N;
	ll p_mn, m_mn = p_mn = 1e9 * 2;
	ll p_mx, m_mx = p_mx = -p_mn;
	while(N--){
    ll x, y; cin>>x>>y;
    ll p = x + y, m = x - y;
    p_mx = max(p_mx, p);
    p_mn = min(p_mn, p);
    m_mx = max(m_mx, m);
    m_mn = min(m_mn, m);
	}
	cout<< max(p_mx - p_mn, m_mx - m_mn) <<endl;
}


Measured memory_bytes: 3600
import math
a, b, h, m = map(int,input().split())

a_s = (30 * h) % 360 + 0.5 * m
b_s = (6*m)

s = max(a_s,b_s) - min(a_s,b_s)
ans = math.sqrt(a**2+b**2-2*a*b*math.cos(math.radians(s)))
print(ans)

Measured memory_bytes: 9448
#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 <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using ll = long long int;
using ull = long long unsigned int;
using Int = long long int;
//using Int = __int128;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:
    void solve() {
        Int S;
        cin >> S;
        Int b = 1;
        Int d = 1000000000;
        if (S % d == 0) b = 0;
        Int c = d - (S % d);
        Int a = (S + b * c) / d;

        Int men = (a * d - b * c);
        cerr << men << endl;

        cout << 0 << " " << 0 << " " << a << " " << b << " " << c << " " << d << endl;

    }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    Solve().solve();


    return 0;
}


Measured memory_bytes: 888
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // uint64_t

#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) > (b) ? (b) : (a))

int get_int(void) {
  int num;
  scanf("%d", &num);
  return num;
}

// <arr[0]> <arr[1]> .. <arr[size-1]>
int fget_array(int *arr, int size) {
    int i;
    for(i = 0; i < size; i++) {
        scanf("%d", &arr[i]);
    }
    return 0;
}

#define NUM_MAX 2000
#define LEN_MAX 1000

int asc(const void *a1, const void *a2) {
    return *(int*)a1 - *(int*)a2;
}

int main(void) {
    int num = get_int();
    static int arr[NUM_MAX];
    fget_array(arr, num);
    qsort(arr, num, sizeof(int),asc);
    // 2 edges
    static int map[LEN_MAX*2+1];
    int i, j;
    for(i = 0; i < num; i++) {
        map[arr[i]]++;
    }
    for(i = 0; i <= LEN_MAX*2; i++) {
        map[i] += map[i-1];
    }

    int ans = 0;
    for(i = 0; i < num; i++) {
        for(j = i+1; j < num; j++) {
            int len = arr[i] + arr[j];
#ifdef DEBUG
            printf("%d-%d\n", map[len-1], j+1);
#endif
            ans += map[len-1] - (j+1);
        }
    }
    printf("%d\n", ans);
    return 0;
}

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

int main(){
	int h,w; cin>>h>>w;
	h+=2; w+=2;
	vector<vector<char>> v(h,vector<char>(w));
	rep(i,h){
		rep(j,w){
			v[i][j]='#';
		}
	}
	
	for(int i=1; i<h-1; i++){
		string s; cin>>s;
		rep(j,w-2){
			v[i][j+1]=s[j];
		}
	}
	
	rep(i,h){
		rep(j,w){		
			cout<<v[i][j];
		}
		cout<<endl;
	}
}

Measured memory_bytes: 3512
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
typedef long long ll;
using namespace std;
 
 
int main(){
    ll a,b,c; cin >> a >> b >> c;
    if(c-a-b>2){
        if((c-a-b)*(c-a-b)>4*a*b) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    else cout << "No" << endl;
return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>
#include<limits>
#include<bitset>
#include<functional>
#include<type_traits>
#include<queue>
#include<stack>
#include<array>
#include<random>
#include<utility>
#include<cstdlib>
#include<ctime>

using namespace std;

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

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

long long INF = 1LL<<60;
long long dp[100010];
int h[100010];
string sd,t;
int main(){
    cin>>sd>>t;
    bool flag = false;
    int check=0;
    if(sd.length()<t.length()){
    cout<<"UNRESTORABLE"<<endl;
    return 0;
    }
    while(check<=sd.length()-t.length()){
        string partsd = sd.substr(check,t.length());
        if(partsd==t){
                replace(sd.begin(),sd.end(),'?','a');
                flag = true;
                cout<<sd<<endl;
                return 0;
        }
        check++;
    }
    int index=sd.length()-t.length();
    while(index>=0){
        string partsd = sd.substr(index,t.length());
        int i =0;
        while(partsd.at(i)==t.at(i)||partsd.at(i)=='?'){
                i++;
                if(i==t.length()){
                    sd.replace(index,t.length(),t);
                    replace(sd.begin(),sd.end(),'?','a');
                    flag = true;
                    cout<<sd<<endl;
                    return 0;
                }
        }
        index--;
    }
    if(flag==false)
    cout<<"UNRESTORABLE"<<endl;
    return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define RREP(i,a) for(int (i)=(a)-1;(i)>=0;(i)--)
#define FORR(i,a,b) for(int (i)=(a)-1;(i)>=(b);(i)--)
#define PI acos(-1.0)
#define DEBUG(C) cout<<C<<endl;
#define VI vector<int>
#define VII vector<VI>
#define VL vector<LL>
#define VLL vector<VL>
#define VD vector<double>
#define VDD vector<VD>
#define PII pair<int,int>
#define PDD pair<double,double>
#define PLL pair<LL,LL>
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort(ALL(a))
#define REVERSE(a) reverse(ALL(a))
#define MP make_pair
#define EP emplace_back
#define FORE(a,b) for(auto &&a:b)

using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
const int INF=1e9;
const int MOD=INF+7;

int main (void){
    int N,M;
    cin>>N>>M;
    int x,y;
    set<int> s;
    s.insert(1);
    map<int,int> mp;
    REP(i,N) mp[i+1]=1;
    REP(i,M){
        cin>>x>>y;
        mp[x]--; mp[y]++;
        if(s.find(x)!=s.end()){
            s.insert(y);
        }
        if(mp[x]==0){
            s.erase(x);
        }
    }
    FORE(el,s){
        if(mp[el]==0) s.erase(el);
    }
    cout<<s.size()<<endl;
}


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

#define all(x) begin(x), end(x)

using i64 = int_fast64_t;
using f64 = double;
using p64 = pair<i64, i64>;

constexpr i64 INF = INT_FAST64_MAX / 2;
constexpr f64 EPS = DBL_EPSILON;

void solve() {
    char a;
    cin >> a;
    cout << (islower(a) ? 'a' : 'A') << endl;
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}


Measured memory_bytes: 3648
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<utility>
#include<tuple>
#include<algorithm>
#include<cmath>
using namespace std;

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

int main() {
  string s;
  cin >> s;
  for(int i=0; i<4; i++){
    int count = 0;
    for(int j=0; j<4; j++){
      if(s[j] == s[i])
        count++;
    }
    if(count!=2){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
long long X, Y, Z, K, A[1009], B[1009], C[1009];
vector<long long>vec;
 
int main() {
	cin >> X >> Y >> Z >> K;
	for (int i = 0; i < X; i++) cin >> A[i]; sort(A, A + X, greater<long long>());
	for (int i = 0; i < Y; i++) cin >> B[i]; sort(B, B + Y, greater<long long>());
	for (int i = 0; i < Z; i++) cin >> C[i]; sort(C, C + Z, greater<long long>());
	
	for (int i = 0; i < X; i++) {
		for (int j = 0; j < Y; j++) {
			for (int k = 0; k < Z; k++) {
				if ((i + 1) * (j + 1) * (k + 1) <= K) vec.push_back(A[i] + B[j] + C[k]);
				else break;
			}
		}
	}
	sort(vec.begin(), vec.end(), greater<long long>());
	for (int i = 0; i < K; i++) cout << vec[i] << endl;
	return 0;
}


Measured memory_bytes: 1400
li = list(input())
count = 0



counta = 0
i = 0
while(i<len(li)-2):
  # print(i, counta, count)
  if(li[i]=='A'):
    counta += 1
    # print(i)
    if(li[i+1]=='B' and li[i+2]=='C'):
      count += counta
      li[i]='B'
      li[i+1]='C'
      li[i+2]='A'
      i = i+2
      counta -=1
    else:
      i += 1
  else:
    counta = 0
    i = i+1

print(count)




Measured memory_bytes: 4840
#include <cstdio>

int main() {
  long long N;
  scanf("%lld", &N);
  for (long long w = 1; w <= 3500; ++w) {
    for (long long h = 1; h <= 3500; ++h) {
      long long top = N * h * w;
      long long bottom = 4 * h * w - N * (w + h);
      if (bottom == 0) continue;
      long long n = top / bottom;
      if (top % bottom == 0 && 0 < n) {
        printf("%lld %lld %lld\n", h, w, n);
        return 0;
      }
    }
  }
}

Measured memory_bytes: 256
import copy
N, K  = map(int, input().split())
h = list(map(int,input().split()))
dp = [0]*N

dp[1] = abs(h[0] - h[1]) 
for i in range(2, N):
    min = float('inf')
    if i <= K:
        for j in range(0, i):
            num = dp[j] + abs(h[i]-h[j])
            if min > num:
                min = copy.deepcopy(num)
    else:
        for j in range(i-K, i):
            num = dp[j] + abs(h[i]-h[j])
            if min > num:
                min = copy.deepcopy(num)
    dp[i] = min
print(dp[N-1])


Measured memory_bytes: 65044
#include <iostream>
#include <queue>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <math.h>
#include <stdlib.h>
#include <numeric>


int main(){
	int n, m, input;
	std::cin >> n >> m;
	std::vector<std::vector<int>> vec;
	std::vector<int> p;
	for(int i = 0; i < m; i++){
		std::vector<int> tmp;
		int k;
		std::cin >> k;
		for(int j = 0; j < k; j++){
			std::cin >> input;
			tmp.push_back(input);
		}
		vec.push_back(tmp);
	}
	for(int i = 0; i < m; i++){
		std::cin >> input;
		p.push_back(input);
	}
	int count = 0;
	for(int i = 0; i < std::pow(2, n); i++){
		bool ok = true;
		for(int j = 0; j < m; j++){
			int swich = 0;
			for(int k = 0; k < vec[j].size(); k++){
				if((int)std::pow(2, vec[j][k] - 1) & i){
					swich = swich ^ 1;
				}
			}
			if(swich != p[j]){
				ok = false;
				break;
			}
		}
		if(ok){
			count++;
		}
	}
	std::cout << count << std::endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		//ARC004
		//https://arc004.contest.atcoder.jp/tasks/arc004_1
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		double ans = 0;
		int T = Integer.parseInt(sc.next());
		int X = Integer.parseInt(sc.next());
		ans = (double)T/(double)X;
		
		System.out.println(ans);
	}
	
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
//cout << fixed << setprecision(10);

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

int dp[100020];

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

  rep(i,100020) dp[i] = 0;
  dp[0] = 1;
  rep(i,100020) {
    if (dp[i] == 0) continue;
    for (int j = 100; j <= 105; ++j) {
      dp[i+j] = dp[i];
    }
  }
  cout << dp[x] << endl;
  return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
  	int a[3];
  cin>>a[0]>>a[1]>>a[2];
	sort(a,a+3);
  if(a[0]==5 and a[1]==5 and a[2]==7) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
  return 0;
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/agc041/tasks/agc041_b

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;
template <typename T>
inline bool chmax(T& a, T b);
template <typename T>
inline bool chmin(T& a, T b);
void print_ints(vector<ll> v);
template <typename T>
void drop(T a);

const ll INF = 1e18;

void solve() {
  ll N, M, V, P;
  cin >> N >> M >> V >> P;

  VL as(N);
  rep(i, N) cin >> as[i];

  sort(all(as));

  auto is_ok = [&](ll index) -> bool {
    ll a = as[index];
    ll rest = M * V;

    auto over_it = upper_bound(all(as), a + M);
    ll over_a_ct = as.end() - over_it;
    if (over_a_ct >= P) return false;

    rest -= (P - 1) * M;
    if (rest <= 0) return true;

    ll smaller_a_ct = upper_bound(all(as), a) - as.begin();
    rest -= smaller_a_ct * M;
    if (rest <= 0) return true;

    ll b_i = upper_bound(all(as), a) - as.begin();
    repf(i, b_i, N - (P - 1)) { rest -= a + M - as[i]; }

    return rest <= 0;
  };

  if (is_ok(0)) drop(N);

  ll ng = 0;
  ll ok = N - 1;

  while (ok - ng > 1) {
    ll mid = (ng + ok) / 2;
    if (is_ok(mid)) {
      ok = mid;
    } else {
      ng = mid;
    }
  }

  ll res = N - ok;
  cout << res << endl;
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

template <typename T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

void print_ints(vector<ll> v) {
  rep(i, v.size()) {
    if (i > 0) {
      cout << " ";
    }

    cout << v[i];
  }

  cout << endl;
}

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}


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

int main() {
  int64_t N, ans = 0; std::cin >> N;
  if(N%2 == 0) {
    ans += (N/=10);
    while(N >= 5) ans += (N/=5);
  }
  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
using namespace std;
const int mod = 1000000007;
#define ll long long

int main()
{
	string S; cin >> S;
	string ans = "KIHBR";
	if (S.size() < 5 || S.size() >= 10) {
		cout << "NO" << endl;
	}
	else {
		int count = 0;
		int i = 0, j = 0;
		while (i < S.size()) {
			if (S[i] == ans[j] || S[i] == 'A') {
				if (j == 0 || j == 3 || j == 4 || j == 5) {
					if (S[i] == 'A') {
						count++;
						if (count >= 2) {
							cout << "NO" << endl;
							return 0;
						}
					}
				}
				else if (j == 1 || j == 2) {
					if (S[i] == 'A') {
						cout << "NO" << endl;
						return 0;
					}
				}
			}
			else {
				cout << "NO" << endl;
				return 0;
			}
			if (S[i] == ans[j]) {
				count = 0;
				j++;
			}
			i++;
		}
		if (j < 5) {
			cout << "NO" << endl;
			return 0;
		}
		cout << "YES" << endl;
	}
}


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

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
	
		int n = sc.nextInt();
		int k = sc.nextInt();
		
		long cnt = 0;
		
		for(int i = k + 1 ; i <= n ; i++) {
			int temp1 = (Math.floorDiv(n, i)) * (i - k);
			int temp2 = n % i;
			if(temp2 >= k && k == 0) {
				cnt += temp2 - k ;
			}
			if(temp2 >= k && k != 0) {
				cnt += temp2 - k + 1;
			}
			cnt += temp1;
		}
		
		System.out.println(cnt);

	}

}


Measured memory_bytes: 23508
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    while(cin>>a>>b)
    {
        if(a==b) cout<<"Yes"<<endl;
        else if((a==4 || a==6 || a==9 || a==11) && (a==b || b==6 || b==9 || b==11))
            cout<<"Yes"<<endl;
        else if((a==1 || a==3 || a==5 || a==7 || a==8 || a==10 || a==12) && (b==1 || b==3 || b==5 || b==7 || b==8 || b==10 || b==12))
            cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
    return 0;
}


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

int main() {
    int a, b;
    cin >> a >> b;

    int ans = 0;
    int plug = 1;
    while (plug < b) {
        --plug;
        plug += a;
        ++ans;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
n = int(input())
n -= 1
ans = []
while True:
    # print(n)
    ans.append(chr(ord('a') + n % 26))
    n //= 26
    if n == 0:
        break
    else:
        n -= 1
ans = ans[::-1]
ans = ''.join(ans)
print(ans)


Measured memory_bytes: 9168
S = input()

lis = [1,0,0,0]
nlis = [1,0,0,0]

for s in S:

    if s == "?":

        nlis[0] += lis[0] * 2
        nlis[1] += lis[1] * 2
        nlis[2] += lis[2] * 2
        nlis[3] += lis[3] * 2

    if s == "A" or s == "?":

        nlis[1] += lis[0]

    if s == "B" or s == "?":

        nlis[2] += lis[1]

    if s == "C" or s == "?":

        nlis[3] += lis[2]

    lis = []
    for i in range(4):

        lis.append(nlis[i] % (10 ** 9 + 7))

print (lis[3]  % (10 ** 9 + 7))


Measured memory_bytes: 42476
N,M = map(int,input().split())
a=[]
ac_list = [0]*N
wa_list= [0]*N
count_wa = 0
for i in range(M):
    p,s=input().split()
    p = int(p) - 1
    if ac_list[p] == 0:
        if s == 'WA':
            wa_list[p] += 1
        else:
            ac_list[p] = 1
for i in range(N):
    if ac_list[i] == 1:
        count_wa += wa_list[i]

print(sum(ac_list),count_wa)

Measured memory_bytes: 4596
#include <iostream>
#include <string>

using namespace std;

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

  int rE = 0;
  for (int i = 0; i < N; i++) {
    if (S[i] == 'E') rE++;
  }

  int lW = 0;
  int ans = 1100000000;
  for (int i = 0; i < N; i++) {
    if (S[i] == 'E') rE--;
    ans = min(ans, lW + rE);
    if (S[i] == 'W') lW++;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 900
n = int(input())
primes = []
for i in range(11, 1500, 10):
    isPrime = True
    for k in range(2, 236):
        if k ** 2 > i:
            break
        elif i % k == 0:
            isPrime = False
            break
    if isPrime:
        primes.append(i)
print(" ".join(map(str, primes[:n])))


Measured memory_bytes: 2940
#include <math.h>
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;

int main()
{
double a,b,C,h,S,L;
double pi=3.14159265;
cin >> a >> b >> C;
h=sin(C*pi/180)*b;
S=h*a/2;
L=pow(a*a+b*b-cos(C*pi/180)*2*a*b,0.5)+a+b;
cout << fixed << setprecision(5) << S << endl << L << endl << h << endl;
}


Measured memory_bytes: 3540
/* Coached by rainboy */
#include <stdio.h>

int main() {
	int n, ans, h_;

	scanf("%d", &n);
	ans = 0;
	h_ = 0;
	while (n--) {
		int h;

		scanf("%d", &h);
		ans += h >= h_ ? h - h_ : 0;
		h_ = h;
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 128
import math


def print_list_split_whitespace(a):
    for x in a[:-1]:
        print(x, end=' ')
    print(a[-1])


def insertion_sort(a, n, g, cnt):
    for i in range(g, n, 1):
        v = a[i]
        j = i - g
        while j >= 0 and a[j] > v:
            a[j + g] = a[j]
            j -= g
            cnt += 1
        a[j+g] = v
    return cnt


def shell_sort(a, n):
    cnt = 0
    m = math.floor(math.log(2 * n + 1, 3))
    print(m)
    gs = [1]
    for i in range(1, m, 1):
        gs.append(gs[i - 1] * 3 + 1)
    gs.reverse()
    print_list_split_whitespace(gs)

    for i in range(m):
        cnt = insertion_sort(a, n, gs[i], cnt)
    print(cnt)


n = int(input())
a = []
for i in range(n):
    a.append(int(input()))

shell_sort(a, n)

for x in a:
    print(x)


Measured memory_bytes: 45580
from copy import *
from sys import *
import math
import queue
from collections import defaultdict,Counter,deque
from fractions import Fraction as frac

setrecursionlimit(1000000)

#s[i] is linked with t[len(s)-i-1]
def main():
	a,b,c,d = map(int,input().split())
	n = c * d // gcd(c,d)
	a-=1
	ans_b = b - (b//c + b//d - b//n)
	ans_a = a - (a//c + a//d - a//n)
	print(ans_b - ans_a)


def zip(a):
	mae = a[0]
	ziparray = [mae]
	for i in range(1,len(a)):
		if(mae != a[i]):
			ziparray.append(a[i])
			mae = a[i]
	return ziparray

def is_prime(n):
	if n < 2: return False

	for k in range(2, int(math.sqrt(n)) + 1):
		if n % k == 0:
			return False

	return True

def list_replace(n,f,t):
	return [t if i==f else i for i in n]

def base_10_to_n(X, n):
	X_dumy = X
	out = ''
	while X_dumy>0:
		out = str(X_dumy%n)+out
		X_dumy = int(X_dumy/n)
	if(out == ''): return '0'
	return out

def gcd(m,n):
	x = max(m,n)
	y = min(m,n)
	while(x%y!=0):
		z = x%y
		x = y
		y = z
	return y

class Queue():
	def __init__(self):
		self.q = deque([])
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.popleft()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class Stack():
	def __init__(self):
		self.q = []
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.pop()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class graph():
	def __init__(self):
		self.graph = defaultdict(list)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
		self.graph[t].append(f)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
		self.graph[t].remove(f)
	def linked(self,f):
		return self.graph[f]

class dgraph():
	def __init__(self):
		self.graph = defaultdict(set)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
	def linked(self,f):
		return self.graph[f]

main()

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

int main()
{
    int n, p, t, a, x;
    cin >> n >> p;

    queue<int> q[n];

    while (p--)
    {
        cin >> t;
        if (t == 0)
        {
            cin >> a >> x;
            q[a].push(x);
        }
        if (t == 1)
        {
            cin >> a;
            if (q[a].size() != 0)
                cout << q[a].front() << endl;
        }
        if (t == 2)
        {
            cin >> a;
            if (q[a].size() != 0)
                q[a].pop();
        }
    }
    return 0;
}



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

int main() {
	string str;
	cin >> str;
	str += str;

	string temp;
	cin >> temp;

	if (str.find(temp) != -1) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 3200
#include<iostream>
#include<cmath>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#define PB push_back
#define MP make_pair
#define sz(v) (in((v).size()))
#define forn(i,n) for(in i=0;i<(n);++i)
#define forv(i,v) forn(i,sz(v))
#define fors(i,s) for(auto i=(s).begin();i!=(s).end();++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
typedef long long in;
typedef vector<in> VI;
typedef vector<VI> VVI;
vector<double> x,y,r;
double sq(double a){
  return a*a;
}
double d(in u, in v){
  double s=sqrt(sq(x[u]-x[v])+sq(y[u]-y[v]));
  if(s<r[u]+r[v])
    return 0;
  return s-r[u]-r[v];
}
vector<double> mnd;
const double inf=1e18;
priority_queue<pair<double,in> > q;
VI vis;
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  double xs,ys,xt,yt;
  cin>>xs>>ys>>xt>>yt;
  in n;
  cin>>n;
  x.resize(n+2);
  y.resize(n+2);
  r.resize(n+2);
  x[0]=xs;
  y[0]=ys;
  r[0]=0;
  x[1]=xt;
  y[1]=yt;
  r[1]=0;
  forn(z,n)
    cin>>x[z+2]>>y[z+2]>>r[z+2];
  n+=2;
  mnd.resize(n,inf);
  mnd[0]=0;
  q.push(MP(-0,0));
  vis.resize(n,0);
  double u,tu,td;
  while(!q.empty()){
    tie(tu,u)=q.top();
    q.pop();
    tu=-tu;
    if(vis[u])
      continue;
    vis[u]=1;
    forn(i,n){
      td=d(u,i);
      if(tu+td<mnd[i]){
	mnd[i]=tu+td;
	q.push(MP(-(tu+td),i));
      }
    }
  }
  cout<<setprecision(15);
  cout<<mnd[1]<<endl;
  return 0;
}


Measured memory_bytes: 4468
#include<stdio.h>

    int main(){
    
            int x,y,z;
    
            for(x=1;x<=9;x++){
                    
                        for(y=1;y<=9;y++){
                                        
                            z=x*y;
                            printf("%dx%d=%d",x,y,z);
			    printf("\n");

                                        }
                 
                            }
         return 0;
                   }   

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

using namespace std;

#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)
#define sz(a) static_cast<int>((a).size())
#define pb emplace_back
#define mp make_pair
#define endl '\n'
#define f first
#define s second

#ifdef SEREZHKA
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define dbg(...)
#endif

template<typename T>
void _dbg(const char* _s, T _h) { cerr << _s << " = " << _h << "\n"; }

template<typename T, typename... Ts>
void _dbg(const char*_s, T _h, Ts... _t) {
    int _b = 0;
    
    while (((_b += *_s == '(') -= *_s == ')') != 0 || *_s != ',')
        cerr << *_s++;
    
    cerr << " = " << _h << ",";
    _dbg(_s + 1, _t...);
}

using ll = long long;

const ll INF = static_cast<ll>(1e9) + 7ll;
const ll LINF = INF * INF;
const int MAXN = static_cast<int>(2e5) + 17;

int n, k;
int a[MAXN];

bool read() {
    if (!(cin >> n >> k))
        return false;

    forn (i, n)
        cin >> a[i];

    return true;
}

void solve() {
    ll sump = 0, sum = 0, ans = -INF * INF;

    forn (i, n)
        sump += a[i] * (a[i] > 0);

    forn (i, n) {
        sum += a[i];
        sump -= a[i] * (a[i] > 0);

        if (i >= k) {
            sum -= a[i - k];
            sump += a[i - k] * (a[i - k] > 0);
        }

        if (i >= k - 1)
            ans = max(ans, max(0ll, sum) + sump);
    }

    cout << ans << endl;
}

int main() {
    cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    
#ifdef SEREZHKA
    freopen("file.in", "r", stdin);
#endif
    
    while (read())
        solve();
    
    return 0;
}



Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#define eps 1e-9
#define double long long
using namespace std;
struct point{
	double x,y;
	void read(){scanf("%lld%lld",&x,&y);}
	void write(){printf("%.9f %.9f\n",x,y);}
	point(double X=0.0,double Y=0.0):x(X),y(Y){}
	point operator +(const point a)const{return point(x+a.x,y+a.y);}
	point operator -(const point a)const{return point(x-a.x,y-a.y);}
	point operator *(double a)const{return point(x*a,y*a);}
	point operator /(double a)const{return point(x/a,y/a);} 
};
double dis(point a){return a.x*a.x+a.y*a.y;}
double dot(point a,point b){return a.x*b.x+a.y*b.y;}
double cross(point a,point b){return a.x*b.y-a.y*b.x;}
short int on_left(point o,point a,point b)//oa->ob 0:L 1:R 2:D 3:U 4:O
{
	if(cross(a-o,b-o)) return cross(a-o,b-o)<0;
	if(dot(a-o,b-o)<0) return 2;
	return 3+(dis(a-o)>=dis(b-o));
}
point p1,p2;
const char s[5][30]={"COUNTER_CLOCKWISE","CLOCKWISE","ONLINE_BACK","ONLINE_FRONT","ON_SEGMENT"};
int main()
{
	int n;
	p1.read();p2.read();
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		point p;
		p.read();
		puts(s[on_left(p1,p2,p)]);
	}
	return 0;
}



Measured memory_bytes: 3168
#include<stdio.h>
#include<stdlib.h>
#include<stdbool.h>
#include<string.h>
#include<math.h>
#include<ctype.h>

#define MOD 1e7+7
typedef long long ll;

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

ll mylcm(ll a, ll b) { return a / mygcd(a, b) * b; }

ll mymax(ll a, ll b) { return (a > b) ? a : b; }

ll mymin(ll a, ll b) { return (a < b) ? a : b; }

ll myasc(const void* a, const void* b) { return *(ll*)a - *(ll*)b; }

ll mydsc(const void* a, const void* b) { return *(ll*)b - *(ll*)a; }

bool flag;
ll n ;
char s[101];

int main() {
	scanf("%lld", &n);
	for (int i=0;i<n;i++) scanf("%c",&s[i]);
	for (int i = 0; i < n; i++) {
		if (s[i] == 'Y') {
			printf("Four");
			return 0;
		}
	}
	printf("Three");

	return 0;
}


Measured memory_bytes: 2120
#include <iostream>

using namespace std;

int main() {
    int a,b,big,small,r;

    while(1){
        cin >> a >> b;
        if(cin.eof()){
            break;
        }
        
        if(a > b){
            big = a;
            small = b;
        }
        else {
            big = b;
            small = a;
        }
        
        r = big % small;
        while(r != 0){
            big = small;
            small = r;
            r = big % small;
        }
        
    cout << small << ' ' << (a / small) * (b / small) * small << endl;
    
    }

    return 0;
}

Measured memory_bytes: 3068