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

using ll = long long;

const int N = 100001;

int n, r, c[N];
vector<ll> p;
map<ll, ll> o;
map<vector<ll>, int> mp;

int main(){
    for(int i = 2; i < N; i++){
        if(c[i]) continue;
        p.push_back(ll(i));
        o[ll(i) * i] = i;
        o[i] = ll(i) * i;
        for(int j = 2 * i; j < N; j += i) c[j] = 1;
    }
    p.push_back(N);
    scanf("%d", &n);
    for(ll x; n--; ){
        scanf("%lld", &x);
        for(ll i = 2; i * i * i <= x; i++)
            while(x % (i * i * i) == 0) x /= (i * i * i);
        vector<ll> v;
        for(int i = 0; p[i] < 2500; i++){
            if(x % (p[i] * p[i]) == 0){
                x /= (p[i] * p[i]);
                v.push_back(p[i] * p[i]);
            }
            else if(x % p[i] == 0){
                x /= p[i];
                v.push_back(p[i]);
            }
        }
        if(o.find(x) != o.end()){ v.push_back(x); x = 1; }
        if(x >= N){ r++; continue; }
        mp[v]++;
    }
    for(auto &i : mp){
        vector<ll> c;
        for(ll j : i.first) c.push_back(o[j]);
        if(i.first == c){ r++; continue; }
        if(mp.find(c) != mp.end()){
            r += max(i.second, mp[c]);
            i.second = mp[c] = 0;
        }
        r += i.second;
    }
    printf("%d\n", r);
}

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

using namespace std;
using ll =long long;
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
int main()
{
	ll k , n;
	cin >> k  >> n;
	vector<ll> a(n);
	rep(i,n) cin >> a[i];
	a.push_back(k+a[0]);
//	ll sum = 0;
//	ll my_M = 0;
	ll m = 0;
	rep(i,n) {
		m = max(m,a[i+1]-a[i]);
		//ll tmp = abs(a[i+1] - a[i]);
		//chmax(my_M,tmp);
		//sum += tmp;
	}
	cout << k - m << endl;

}



Measured memory_bytes: 4864
#include <vector>
#include <iostream>
#include <valarray>
#include <string>
#include <algorithm>
#include <set>
typedef unsigned long long ull;
typedef long long ll;

#define rep(i,n) for(ull i = 0;i<(n);i++)
#define rep1(i,n) for(ull i = 1;i<=(n);i++)
#define revrep(i,n) for(ull i = (n-1);i>=0;i--)
#define all(n) (n).begin(),(n).end()
#define show(x) cout << "debug " << #x << ":" << x << endl;
#define showvec(x) cout << endl << "debug " << #x << ":" << endl; \
	for(ull __i = 0;__i < x.size();__i++){ \
		for(ull __j = 0;__j<x[0].size();__j++){ \
			cout << x[__i][__j] << " "; \
		} \
		cout << endl; \
	} \
	cout << endl;
using namespace std;

int UF_data[1011];
void UF_init(){
	rep(i,1011) UF_data[i] = i;
}
int UF_root(int a){
	if(UF_data[a] == a) return a;
	return (UF_data[a] = UF_root(UF_data[a]));
}
bool UF_is_same_set(int a, int b){
	return UF_root(a) == UF_root(b);
}
void UF_unite(int a, int b){
	UF_data[UF_root(a)] = UF_root(b);
}

int main(){
	int F[1002];
	F[0] = 1, F[1] = 2;
	for(int i = 2;i<1002;i++){
		F[i] = (F[i-1] + F[i-2]) % 1001;
	}
	int V,D;
	while(cin >> V >> D){
		UF_init();
		rep1(i,V){
			rep1(j,V){
				if(abs(F[i] - F[j]) < D){
					UF_unite(i,j);
				} 
			}
		}
		int ans = 0;
		rep1(i,V){
			if(UF_root(i) == i) ans++;
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1168
#include<stdio.h>
main(){
  int i,n,m;
  for(i=1;;i++){
    scanf("%d %d",&n,&m);
    if(n==0 && m==0)break;
    if(n>m)printf("%d %d\n",m,n);
    else printf("%d %d\n",n,m);
  }
  return 0;
}

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second

#define DUMP(x) cout<<#x<<":"<<(x)<<endl
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class T>
istream& operator>>(istream& is, vector<T>& xs){
  for(auto& x: xs)
	is >> x;
  return is;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
ostream& operator<<(ostream& os, const vector<T>& xs){
  for(unsigned int i=0;i<xs.size();++i)
	os << (i?" ":"") << xs[i];
  return os;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

int dx[] = {-1,0,1,0};
int dy[] = {0,-1,0,1};

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

  int H, W;
  cin >> H >> W;
  VS vs(H);
  cin >> vs;

  PII s, g;
  REP(y,H) REP(x,W){
	if(vs[y][x] == 'S'){
	  s = MP(y,x);
	  vs[y][x] = '.';
	}
	else if(vs[y][x] == 'G'){
	  g = MP(y,x);
	  vs[y][x] = '.';
	}
  }

  auto isin = [&](PII p){ return 0 <= p.FF && p.FF < H && 0 <= p.SS && p.SS < W; };

  map<PII,int> dist;
  using D = pair<int,PII>;
  priority_queue<D,vector<D>,greater<D>> pq;
  pq.push(MP(0,s));
  dist[s] = 0;
  while(!pq.empty()){
	auto d = pq.top();
	pq.pop();
	if(dist[d.SS] < d.FF) continue;

	REP(di,4){
	  PII np(d.SS.FF+dy[di], d.SS.SS+dx[di]);
	  if(!isin(np)) continue;
	  if(vs[np.FF][np.SS] == 'o'){
		int nd = d.FF + 1;
		if(!dist.count(np) || dist[np] > nd){
		  dist[np] = nd;
		  pq.push(MP(nd, np));
		}
	  }
	  if(vs[np.FF][np.SS] == 'x' || vs[np.FF][np.SS] == '.'){
		int nd = d.FF + 2;
		for(int tt=1;tt<=3;++tt){
		  PII nnp = MP(d.SS.FF + dy[di]*tt, d.SS.SS + dx[di]*tt);
		  if(!isin(nnp) || vs[nnp.FF][nnp.SS] == '#') break;
		  ++nd;
		  if(!dist.count(nnp) || dist[nnp] > nd){
			dist[nnp] = nd;
			pq.push(MP(nd, nnp));
		  }
		}
	  }
	  if(vs[np.FF][np.SS] == '.'){
		int nd = d.FF + 2;
		if(!dist.count(np) || dist[np] > nd){
		  dist[np] = nd;
		  pq.push(MP(nd, np));
		}
	  }
	}
  }

  cout << dist[g] << endl;

  return 0;
}



Measured memory_bytes: 3240
#include <iostream>
#include <vector>
#include <array>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <limits>

using namespace std;

typedef long long ll;

void add_mod(ll& val, ll add_val) {
	val = (val + add_val) % 100000007;
}

int main (int argc, char* argv[]) {
	string s;
	cin >> s;
	if (s == "Sunny") {
		cout << "Cloudy" << endl;
	} else if (s == "Cloudy") {
		cout << "Rainy" << endl;
	} else if (s == "Rainy") {
		cout << "Sunny" << endl;
	}
}


Measured memory_bytes: 256
def getLucas(N):
    if N == 0:
        return 2
    if N == 1:
        return 1

    l = [2, 1]

    for i in range(2, N + 1):
        l.append(l[i - 1] + l[i - 2])

    return l[N]


N = int(input())
print(getLucas(N))


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
int main(){
  int s;
  cin >> s;
  int m = 0;
  while(1){
    if (s == 1 || s == 2 || s == 4){
      cout << m + 4;
      break;
    } else {
      m++;
      if (s % 2 == 0){
        s /= 2;
      } else {
        s = s * 3 + 1;
      }
    }
  }
}

Measured memory_bytes: 256
from collections import deque
de = deque()
n,m,q = map(int,input().split())
queries = []
for _ in range(q):
    a,b,c,d = map(int,input().split())
    queries.append((a,b,c,d))
de.append([1])#bfsで作成する数列
maxscore = 0
while de:
    li = de.popleft()
    if len(li) < n:
        for i in range(li[-1],m+1):
            new_li = li + [i]
            de.append(new_li)
    else:
        score = 0
        for i in range(q):
            a,b,c,d = queries[i]
            if li[b-1] - li[a-1] == c:
                score += d
        maxscore = max(maxscore,score)
print(maxscore)

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

int main() {
  int N;
  cin >> N;
  
  bool exist=false;
  for(int i=0; i<=N/4; i++){
    for(int j=0; j<=N/7; j++){
      int x=4*i+7*j;
      if(x==N){
        exist=true;
        break;
      }
    }
    
    if(exist) break;
  }
  
  if(exist) cout << "Yes" <<endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 384
/* ITP1_6_C */
import java.io.*;
import java.util.Arrays;

class Main
{
  static final int BUILDING = 4;
  static final int FLOOR = 3;
  static final int ROOM = 10;

  public static void main(String[] args)
  {
    int[][][] count = new int[BUILDING][FLOOR][ROOM];
    // initialization
    for(int i = 0; i < BUILDING; i++){
      for(int j = 0; j < FLOOR; j++){
          Arrays.fill(count[i][j], 0);
      }
    }

    try{
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      StringBuilder sb = new StringBuilder();

      int n = Integer.parseInt(br.readLine());

      // process
      for(int i = 0; i < n; i++){
        String[] info = br.readLine().split(" ");
        int building = Integer.parseInt(info[0]) - 1;
        int floor = Integer.parseInt(info[1]) - 1;
        int room = Integer.parseInt(info[2]) - 1;
        int persons = Integer.parseInt(info[3]);

        count[building][floor][room] += persons;
        if(count[building][floor][room] < 0 || count[building][floor][room] > 9)
          return;
      }

      // output
      for(int i = 0; i < 4; i++){
        for(int j = 0; j < 3; j++){
          for(int k = 0; k < 10; k++){
            sb.append(" " + count[i][j][k]);
          }
          sb.append("\n");
        }
        if(i == 3);
        else
          sb.append("####################\n");
      }
      System.out.print(sb);


    }catch(Exception e){
      System.out.println(e);
    }
  }
}

Measured memory_bytes: 24564
fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let n: usize = read(&mut stdin_lock, &mut buf, b' ');
    let m: usize = read(&mut stdin_lock, &mut buf, b'\n');
    let mut psv = vec![(0usize, false); m];
    for i in 0..m {
        psv[i].0 = read(&mut stdin_lock, &mut buf, b' ');
        let s: String = read(&mut stdin_lock, &mut buf, b'\n');
        psv[i].1 = s == "AC";
    }

    let mut rv = vec![(0usize, false); n];
    for i in 0..psv.len() {
        let p = psv[i].0 - 1;
        let s = psv[i].1;
        if rv[p].1 {
            continue;
        } else {
            if s {
                rv[p].1 = s;
            } else {
                rv[p].0 += 1;
            }
        }
    }

    let mut wa = 0;
    let mut ac = 0;
    for i in 0..rv.len() {
        if rv[i].1 {
            wa += rv[i].0;
            ac += 1;
        }
    }
    println!("{} {}", ac, wa);
}


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

int digit(int s) {
  if(s == 0) return 1;
  int r = 0;
  while(s > 0) {
    r++;
    s /= 10;
  }
  return r;
}

int main(){
  int n, m;
  cin >> n >> m;
  int s[m], c[m];
  rep(i,m) cin >> s[i] >> c[i];
  int ans = 100000;
  for(int i = 0; i < 1000; i++) {
    if(digit(i) == n) {
      int a[n];
      int r = i;
      rep(j,n) {
        a[j] = r % 10;
        r /= 10;
      }
      bool f = true;
      rep(j,m) {
        if(c[j] != a[n-s[j]]) f = false;
      }
      if(f) ans = min(ans,i);
    }
  }
  cout << (ans == 100000? -1 : ans) << endl; 
  return 0;
}


Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

int main(){
	int che[3];
	while(cin>>che[0]>>che[1]>>che[2],che[0]||che[1]||che[2]){
		sort(che,che+3);
		int R =che[0]*che[0]+che[1]*che[1];
		int n;
		cin>>n;
		rep(i, n){
			int r;
			cin>>r;
			r =2*r*2*r;
			if(r>R){
				cout <<"OK"<<endl;
			}else{
				cout <<"NA"<<endl;
			}
		}
		

	}
	return 0;
}

Measured memory_bytes: 1172
import sys
import os
import math

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

MOD = 10 ** 9 + 7


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    l = il()
    print('YES' if l.count(5) == 2 and l.count(7) == 1 else 'NO')


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (long long i = 0; i < n; i++)
#define RREP(i, n) for (long long i = n - 1; 0 <= i; i--)
#define FOR(i, start, end) for (long long i = start; i < end; i++)
#define RFOR(i, start, end) for (long long i = start - 1; 0 <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
using ll = long long;
using namespace std;
const int INF32       = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7        = 1'000'000'007;
const int MOD9        = 1'000'000'009;
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;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}

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

    string s;
    cin >> s;
    if (s.size() == 3) {
        reverse(ALL(s));
    }
    print(s);

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	long int a,s,d,f,g,h,i,j;
	while(scanf("%ld %ld",&a,&s)!=EOF){
		g=0;
		g=a*s;
		if(a<s){
			d=a;
			a=s;
			s=d;
		}
		d=a%s;
		while(d!=0){
			a=s;
			s=d;
			d=a%s;
		}
		printf("%ld %ld\n",s,g/s);
	}
	return 0;
}

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

bool solve() {
    string S;
    cin >> S;
    for ( int i = 0; i < S.size(); i++ ) {
        if ( i % 2 == 0 && S[i] == 'L' ) return false;
        if ( i % 2 == 1 && S[i] == 'R' ) return false;
    }
    return true;
}

int main() {
    string ans = solve() ? "Yes" : "No";
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(x) (x).begin(), (x).end()
#define pb(x) push_back(x)
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
 
int main() {

    int n,y;
    cin>>n>>y;
    int ans=false;
    int a,b,c;
    rep(i,n+1) {
        rep(j,n+1-i) {
          if(10000*i+5000*j+1000*(n-i-j)==y) {
              ans=true;
              a=i;
              b=j;
              c=n-i-j;
          }  
        }
    }
    if(ans==true) {
        cout<<a<<' '<<b<<' '<<c<<' '<<endl;
    }
    else {
        cout<<-1<<' '<<-1<<' '<<-1<<endl;
    }
    
 return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
	int n, p[20], i, count = 0;

	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d", &p[i]);
	}

	for (i = 1; i < n - 1; i++) {
		if (p[i - 1] < p[i] && p[i] < p[i + 1]) {
			count++;
		}
		else if (p[i - 1] > p[i] && p[i] > p[i + 1]) {
			count++;
		}
	}

	printf("%d", count);

	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <iomanip>

using namespace std;

int main()
{
    int a, b;
    cin >> a >> b;
    if(abs(a - b) % 2 == 0)
    {
        cout << (a + b) / 2;
    }
    else
    {
        cout << "IMPOSSIBLE";
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using LL = long long int;
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define dec(i, n)  decID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define FR front()
#define BA back()
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
auto setmin   = [](auto & a, auto b) { return (b <  a ? a = b, true : false); };
auto setmax   = [](auto & a, auto b) { return (b >  a ? a = b, true : false); };
auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); };
auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); };
#define SI(v) static_cast<int>(v.size())
#define RF(e, v) for(auto & e: v)
#define until(e) while(! (e))
#define if_not(e) if(! (e))
#define ef else if
#define UR assert(false)
#define IN(T, ...) T __VA_ARGS__; IN_(__VA_ARGS__);
void IN_() { };
template<typename T, typename ... U> void IN_(T & a, U & ... b) { cin >> a; IN_(b ...); };
template<typename T> void OUT(T && a) { cout << a << endl; }
template<typename T, typename ... U> void OUT(T && a, U && ... b) { cout << a << " "; OUT(b ...); }

// ---- ----

template<typename T> istream & operator>>(istream & s, vector<T> & v) { RF(e, v) { s >> e; } return s; }
template<typename T> ostream & operator<<(ostream & s, vector<T> const & v) {
	inc(i, SI(v)) { s << (i == 0 ? "" : " ") << v[i]; }
	return s;
}
template<typename T, typename U> istream & operator>>(istream & s, pair<T, U> & p) { return (s >> p.FI >> p.SE); }
template<typename T, typename U> ostream & operator<<(ostream & s, pair<T, U> const & p) { return (s << p.FI << " " << p.SE); }

int main() {
	IN(int, n);
	vector<pair<int, int>> v(n);
	cin >> v;
	sort(ALL(v), [](auto a, auto b) { return (a.FI + a.SE < b.FI + b.SE); });
	
	const LL INF = 1e15;
	vector<LL> dp(n + 1, INF);
	dp[0] = 0;
	RF(e, v) {
		dec(i, n) {
			if(dp[i] <= e.FI) { setmin(dp[i + 1], dp[i] + e.SE); }
		}
	}
	decII(i, 0, n) {
		if(dp[i] < INF) { OUT(i); exit(0); }
	}
	UR;
}


Measured memory_bytes: 384
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_ALL_CXX17_DEPRECATION_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include <map>
#include <fstream>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <assert.h>
#include <complex>
using namespace std;
#define LONG_INF 10000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353LL
#define seg_size 65536*4
#define REP(i,n) for(long long i = 0;i < n;++i)
long long n;
string pluser(string a, string b) {
	int kuriagari = 0;
	string ans;
	for (int i = a.size() - 1; i >= 0; --i) {
		kuriagari += a[i] + b[i] - '0' - '0';
		ans.push_back(kuriagari % 2 + '0');
		kuriagari /= 2;
		kuriagari = max(kuriagari, 0);
	}
	if (kuriagari == 1) {
		ans.push_back('1');
	}
	reverse(ans.begin(), ans.end());
	return ans;
}
int main(){
#define int long long
	while (true) {
		cin >> n;
		if (n == 0) return 0;
		string base;
		cin >> base;
		base = "1" + base;
		string ans = base;
		for (int i = 0;;) {
			while (n != 0 && ans.length() == base.length()) {
				string multiply;
				multiply = base;
				for (long long q = 1;; q *= 2) {
					string now = pluser(multiply, ans);
					if (now.length() != ans.length()) {
						//繰り上がり発生
						if (q != 1) {
							//保持しない
							q /= 2;
							for (int j = multiply.size() - 1; j >= 1; --j) {
								multiply[j] = multiply[j - 1];
								multiply[j - 1] = '0';
							}
						}
						n -= q;
						ans = pluser(multiply,ans);
						break;
					}
					if (q * 2 > n) {
						n -= q;
						ans = now;
						break;
					}
					for (int j = 0; j < multiply.size() - 1; ++j) {
						multiply[j] = multiply[j + 1];
					}
					multiply[multiply.size() - 1] = '0';
				}
			}
			if (ans.length() != base.length()) {
				ans.pop_back();
				for (int q = base.length() - 1; q >= 1;--q) {
					base[q] = base[q - 1];
				}
				base[0] = '0';
				i++;
			}
			if (n == 0) {
				string s;
				int geko = i;
				for (int q = 0; q < 12; ++q) {
					s.push_back(geko % 2 + '0');
					geko /= 2;
				}
				reverse(s.begin(), s.end());
				cout << s;
				for (int j = 1; j < ans.length(); ++j) {
					cout << ans[j];
				}
				cout << endl;
				break;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 3220
program sum_of_product_of_pairs
  implicit none
  integer(8), parameter :: m = 1000000007, h = (m + 1) / 2
  integer :: n, i
  integer(8) :: a(200000) = 0, s = 0, d = 0
  read(*,*) n
  read(*,*) a(1:n)
  do i = 1, n
    s = mod(s + a(i), m)
    d = mod(d + a(i) * a(i), m)
  end do
  write(*,'(i0)') mod(modulo(s * s - d, m) * h, m)
end program sum_of_product_of_pairs

Measured memory_bytes: 4652
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <numeric>
#include <ctime>
#include <complex>
#include <bitset>
#include <random>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
#define int ll
#define double ld
#define loop(i, n) for(int i = 0; i < (int)n; ++i)
#define loop1(i, n) for(int i = 1; i <= (int)n; ++i)
#define F first
#define S second
#define pb push_back
#define pi pair <int, int>
#define all(x) begin(x), end(x)
#define ti tuple <int, int, int, int>
#define Point Vect
#define no {cout << "No\n"; return;}
 
const int N = 1e5 + 7, INF = 1e9 + 7;

vector <string> ans;
string s = "";

bool recurs(int len) {
    if (!len) {
        ans.pb(s);
        return ans.size() < N;
    }
    if (s == "")
        loop1(i, 9) {
            s.pb(i + '0');
            if (!recurs(len - 1))
                return 0;
            s.pop_back();
        }
    else
        for (int i = max(0ll, int(s.back() - '0') - 1); i <= min(9ll, int(s.back() - '0') + 1); ++i) {
            s.pb(i + '0');
            if (!recurs(len - 1))
                return 0;
            s.pop_back();
        }
    return 1;
}
 
 void solve() {
    loop1(len, 10)
        recurs(len);
    int n; cin >> n;
    cout << ans[n - 1];
 }
 
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //int t; cin >> t; loop(i, t)
    solve();
    return 0;
}

Measured memory_bytes: 7028
import sys
import heapq
import math
import fractions
import bisect
import itertools
from collections import Counter
from collections import deque
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

n,l=mp()
a=lmp()
c=True
for i in range(n-1):
    if a[i]+a[i+1]>=l:
        c=False
        ind=i
        break
if c:
    print("Impossible")
    exit()
print("Possible")
for i in range(1,ind+1):
    print(i)
for i in range(n-1,ind+1,-1):
    print(i)
print(ind+1)

Measured memory_bytes: 16076
N = int(input())
p = ''.join(input().split())
q = ''.join(input().split())
found_p = found_q = False
import itertools
for i, cand in enumerate(itertools.permutations(range(1, N+1))):
  cand = ''.join([str(_) for _ in cand])
  if cand == p:
    a = i + 1
    found_p = True
  if cand == q:
    b = i + 1
    found_q = True
  if found_p and found_q:
    break
    
print(abs(a-b))

Measured memory_bytes: 3064
//
//  main.cpp
//  Problem Code
//
//  Created by Algo张伯威 on 2020/4/24.
//  Copyright © 2020 Algo张伯威. All rights reserved.
//

#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <map>
#include <cstdlib>
#include <vector>
#include <iostream>
#include <set>
using namespace std;

char s[20], t[20];

int main() {
    int n, m, a, b, c, k;
    scanf("%d%d%d%d", &a, &b, &c, &k);
    if(k <= a) {
        printf("%d\n", k);
        return 0;
    }
    if(k <= a + b) {
        printf("%d\n", a);
        return 0;
    }
    printf("%d\n", a - (k - a - b));
    
    return 0;
}






















Measured memory_bytes: 3816
#include <algorithm>
#include <functional>
#include <iostream>
#include <queue>
#include <vector>

int main(int argc, char *argv[]) {
  int n;
  std::cin >> n;
  std::vector<int> a(n);
  for (int i = 0; i < n; ++i)
    std::cin >> a.at(i);

  std::sort(a.begin(), a.end(), std::greater<int>());

  std::queue<int> q;
  long long ans = 0;
  for (auto i : a) {
    if (q.empty()) {
      q.push(i);
      continue;
    }
    q.push(i);
    q.push(i);
    ans += q.front();
    q.pop();
  }

  std::cout << ans << std::endl;
}


Measured memory_bytes: 4476
#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;

int main() {
   char c[1001];
   int d[2][1002],i,j,k,n,m,mx;
   while(true) {
	   cin >> n; k=0; mx=0;
	   if (n==0) break;
	   memset(d,0,sizeof(d));
	   for (i=0;i<n;i++) {
		   cin >> c;
		   for (j=0;j<n;j++) {
			   if (c[j]=='.') {
				   m=min(d[k][j],d[k][j+1]);
				   m=min(m,d[1-k][j])+1;
				   d[1-k][j+1]=m;
				   mx=max(mx,m);
			   } else d[1-k][j+1]=0;
		   }
		   k=1-k;
		  }
   cout << mx << endl;
   }
   return 0;
}

Measured memory_bytes: 1172
import java.io.*
import java.util.*

val pw = PrintWriter(System.out)
fun solve(N: Int, A: IntArray) {
    val a= A.toSet()
    val M = a.max()!!
    val M2 = if (A.count{ it == M } >= 2) M else (a - M).max()!!
    repeat(N){
        when(A[it]){
            M -> M2
            else -> M
        }.let{ pw.println(it) }
    }
    pw.flush()
    return
}

fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val N = sc.next().toInt()
    val A = IntArray(N)
    for (i in 0 until N) {
        A[i] = sc.next().toInt()
    }
    solve(N, A)
}


Measured memory_bytes: 61992
function Main(input) {
  input = input.split("\n");
  var N = parseInt(input[0]);
  var s = input[1].split("");
  var r=0;
  var b=0;
  for(var i=0;i<N;i++){
    if(s[i]=="R"){
      r++;
    }
  }
  if(r>N/2){
    var ans="Yes";
  }else{
    var ans="No";
  }

  console.log('%s', ans);
  return ans;
}

function debug(n){
  var input = document.getElementById("input"+n).value;
  var ans=Main(input);
  var result="WA";
  if(ans==document.getElementById("output"+n).value.split("\n")[0]){
    result="AC";
  }
  document.getElementById("result"+n).innerHTML=result;
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
import java.util.*;

public class Main {
	private static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		int n = sc.nextInt();
		int m = sc.nextInt();
		Point[] pn = new Point[n];
		Point[] pm = new Point[m];
		for (int i = 0;i < n;i++) pn[i] = new Point(i,sc.nextInt(),sc.nextInt());
		for (int i = 0;i < m;i++) pm[i] = new Point(i,sc.nextInt(),sc.nextInt());
		int[] ret = new int[n];
		for (int i = 0;i < n;i++) {
			int d = Integer.MAX_VALUE;
			for (int j = 0;j < m;j++) {
				int tmp = Math.abs(pn[i].x-pm[j].x)+Math.abs(pn[i].y-pm[j].y);
				if (tmp<d) {
					d = Math.min(d, tmp);
					ret[i] = j+1;
				}
			}
		}
		for (int i = 0;i < n;i++) {
			System.out.println(ret[i]);
		}
	}
}

class Point {
	public int n;
	public int x;
	public int y;
	public Point(int n, int x, int y) {
		this.n = n;
		this.x = x;
		this.y = y;
	}
}

Measured memory_bytes: 21716
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
 
int n, pos;
vector<int> pre, in, post;
 
void rec(int l, int r) 
{
    if (l == r) return;
    int root = pre[pos++];
    int m = distance(in.begin(), find(in.begin(), in.end(), root));
    rec(l, m);
    rec(m + 1, r);
    post.push_back(root);
}
 
void solve()
{
    pos = 0;
    rec(0, pre.size());
    for (int i = 0; i < n; i++)
    {
        if (i) cout << " ";
        cout << post[i];
    }
    cout << endl;
}
 
int main()
{
    int key;
    cin >> n;

    for (int i = 0; i < n; i++) 
    {
        cin >> key;
        pre.push_back(key);
    }
 
    for (int i = 0; i < n; i++) 
    {
        cin >> key;
        in.push_back(key);
    }
 
    solve();
 
    return 0;
}

Measured memory_bytes: 3124
while True:
    x=list(map(int,input().split()))
    if x[0]==0 and x[1]==0:
        break
    else:
        a=''
        for i in range(x[0]):
            if i%2!=0:
                for j in range(x[1]):
                    if j%2!=0:
                        a=a+'#'
                    else:
                        a=a+'.'  
                print(a)
                a=''
            else:
                for j in range(x[1]):
                    if j%2!=0:
                        a=a+'.'
                    else:
                        a=a+'#'  
                print(a)
                a=''
        print('')



Measured memory_bytes: 5612
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,b,n) for(int i=b;i<n;i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
int n;
int main(){
	cin>>n;
	while(n--){
		ll dp[30][30]={0};
		bool mata[30][30][30][30]={false};
		int gx,gy;
		cin>>gx>>gy;
		int p;
		cin>>p;
		memset(dp,0,sizeof(dp));
		dp[0][0]=1;
		for(int i =0;i <p;i++){
			int x1,y1,x2,y2;
			cin>>x1>>y1>>x2>>y2;
			mata[x1][y1][x2][y2]=true;
			mata[x2][y2][x1][y1]=true;
		}
		for(int i =0;i <=gx;i++){
			if(i>0&&mata[i-1][0][i][0])break;
			dp[i][0]=1;
		}
		for(int i =0;i <=gy;i++){
			if(i>0&&mata[0][i-1][0][i])break;
			dp[0][i]=1;
		}
		for(int j =1;j <=gy;j++){
			for(int i =1;i <=gx;i++){
				if(!mata[i-1][j][i][j])dp[i][j]+=dp[i-1][j];
				if(!mata[i][j-1][i][j])dp[i][j]+=dp[i][j-1];
			}
		}
		if(!dp[gx][gy]){
			cout << "Miserable Hokusai!" << endl;
		}else{
			cout<<dp[gx][gy]<<endl;
		}
	}
}

Measured memory_bytes: 1956
n = int(input())
p = list(map(int, input().split()))
ans = 0
for i in range(1, n - 1):
    if((p[i-1] < p[i] and p[i] < p[i+1]) or (p[i-1] > p[i] and p[i] > p[i+1])):
        ans += 1

print(ans)

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int main() {
    int n,m,l,r;
    cin>>n>>m;
    int b=n;
    int a=1;
  	bool flag = false;
    for(int i=0;i<m;i++)
    {
        cin>>l>>r;
        if(l>a)
        {
            a=l;
        }
        if(r<b)
        {
            b=r;
        }
        if(l>b||r<a)
        {
          flag =true;
          break;
        }
    }
  	if(flag) cout<<"0"<<endl;
    else cout<<b-a+1<<endl;
}


Measured memory_bytes: 256
/*
Created by Rishu Sahu @ covid 20-20
*/
/*
*****************************************************************
*/

#include<bits/stdc++.h>
using namespace std;

#define IOS cin.sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long int
#define pai pair<int,int>
#define pal pair<ll,ll>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,a,b) for(int i=a;i<=b;i++)
#define ff first 
#define ss second
#define sz(x) (int)x.size()
#define vi vector<int>
#define vl vector<ll>
#define mpl map<ll,ll>
#define mpi map<int,int>
#define pb push_back
#define all(x) x.begin(),x.end()

const int mod = 1e9+7;
const int INF = INT_MAX;
const int mxm = 500000;
mpl mp;

ll prime[mxm];
vi vec;

void seive(){
    rep(i,mxm) prime[i]=1;
    prime[1]=prime[0]=0;
    for(int i=2;i*i<mxm;i++){
        if(prime[i]){
            for(int j=i*i;j<mxm;j+=i) 
            prime[j]=0;
        }
    }
    for(int i=2;i<mxm;i++) {
        if(prime[i])
        vec.pb(i);
    }
}

void factor(ll x){
   for(int i=0;vec[i]*vec[i]<=x;i++){
       if(x%vec[i]==0){
           mp[vec[i]]++;
           if(vec[i]*vec[i]!=x)
           mp[x/vec[i]]++;
       }
   }
   mp[x]++;
}

void solve(){
    int n;
    cin>>n;
    ll arr[n];
    rep(i,n) cin>>arr[i];
    ll ans=0,sum=arr[n-1];
    for(int i=n-2;i>=0;i--){
        ans=ans+(arr[i]*sum)%mod;
        ans=ans%mod;
        sum=(sum+arr[i])%mod;
    }
    cout<<(ans+mod)%mod<<endl;
}


int main(){
    int t=1;
    seive();
    //cin>>t;
    while(t--){
        //mp.clear();
        solve();
    }
}

Measured memory_bytes: 9188
q, h, s, d = map(int, input().split())
n = int(input())
pq = q*8
ph = h*4
ps = s*2
pd = d
if pq < ph and pq < ps and pq < pd:
    print(n*q*4)
elif ph < ps and ph < pd:
    print(n*h*2)
elif ps < pd:
    print(n*s)
elif n%2 == 0:
    print((n>>1) * d)
elif pq < ph and pq < ps:
    print((n>>1)*d + q*4)
elif ph < ps:
    print((n>>1)*d + h*2)
else:
    print((n>>1)*d + s)



Measured memory_bytes: 3316
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long w=sc.nextInt();
        long h=sc.nextInt();
        long x=sc.nextInt();
        long y=sc.nextInt();
        System.out.print(((double)(w*h)/2.0)+" ");
        System.out.println(x*2==w&&y*2==h?1:0);

    }


}

Measured memory_bytes: 21844
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

int main(){
	int n, t[100], m, p[100], x[100], c = 0, d[100];
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> t[i];
		c += t[i];
	}
	cin >> m;
	for(int i = 0; i < m; i++){
		cin >> p[i] >> x[i];
		d[i] = c - t[p[i]-1] + x[i];
	}
	for(int i = 0; i < m; i++){
		cout << d[i] << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a,b,x,y;
        double z;
        a = sc.nextInt();
        b = sc.nextInt();
        x = a / b;
        y = a % b;
        z = (double)a / b;
        System.out.println(x + " " + y + " " + String.format("%5f",z));
    }
}


Measured memory_bytes: 26468
#include <stdio.h>
#include <iostream>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <math.h>
using namespace std;
     
int main(void)
{
    int d;
    long long int n;
    cin >> d >> n;
    if(d == 0){
        if(n==100){cout << 101;}
        else{
            cout << n;
        }
    }else if(d==1){
        if(n==100){cout << 10100;}
        else{
            n = n*100;
            cout << n;
        }
    }else if(d==2){
        if(n==100){cout << 1010000;}
        else{
            n = n * 10000;
            cout << n;
        }
    }
    return 0;
 
}

Measured memory_bytes: 256
# 【考察】
# 場合分けして考える。
# ★補充の機会無く尽きるケース
#   A < B or A % B > C だと補充されることなく在庫が尽きる。
# ★補充の機会が1回はあるケース（A >= B and A % B <= C ）
#   D < B だとどこかで在庫が尽きる。
#   D == B なら、補充＆購入でプラスマイナスゼロで釣り合う状態が続くので、買い続けられる。
#   D > Bのケースが問題。
#     補充されて補充ゾーンから抜け出しても、その後に補充の機会無く在庫が尽きることが起きうる。
#    「 初期のジュースの本数が X = A + N * D 本の時、補充の機会無く在庫が尽きるような正整数 N があるか？」
#     → 尽きるのは「X % B > C」のケース。
#        大前提として、B <= C + 1 だとこうなることはあり得ないので B > C + 1 で考える。
#        N を増やしていくと、 A % B、(A + D) % B、(A + 2 * D) % B、…と「D % B」ずつ増えていく。
#        こうして C + 1 ～ B - 1 の数が作れると、将来的に在庫が尽きることになる。
#        作れる数は(A + gcd(D, B)の倍数) % Bに限られる。
#        なので、B未満の最大の「A % B + gcd(D, B)の倍数」を求めて、それが　C + 1 ～ B - 1　内にあれば在庫が尽きる。
#        そうでなければ在庫は尽きない。
import math


def solve(A, B, C, D):
    if A < B or A % B > C:
        return 'No'
    if D < B:
        return 'No'
    if D == B:
        return 'Yes'
    # A >= B and A % B <= C and D > B
    if B <= C + 1:
        return 'Yes'
    g = math.gcd(B, D)
    n = (B - 1 - (A % B)) // g
    s = A % B + n * g
    if C + 1 <= s <= B - 1:
        return 'No'
    return 'Yes'


def main():
    T = int(input())
    ans = list()
    for _ in range(T):
        A, B, C, D = map(int, input().split())
        ans.append(solve(A, B, C, D))
    for a in ans:
        print(a)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9236
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
    string s;
    cin >> s;
    int cnt = 0;
    for (int i = 1; i < s.length(); i++){
        if (s[i] == s[i-1]){
            if (s[i] == '0') s[i] = '1';
            else s[i] = '0';
            cnt++;
        }
    }
    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 512
S = input()

L = int(S[:2])
R = int(S[2:])

if 1 <= L <= 12 and 1 <= R <= 12:
    print('AMBIGUOUS')
elif 1 <= R <= 12:
    print('YYMM')
elif 1 <= L <= 12:
    print('MMYY')
else:
    print('NA')


Measured memory_bytes: 2940
# coding: utf-8
# Here your code !
n,m=[int(x) for x in input().split()]
d=[set() for x in [0]*n]
pair=[]
for i in [0]*m:
    a,b=[int(x)-1 for x in input().split()]
    d[a].add(b)
    d[b].add(a)
    pair.append((a,b))
ans=0
from collections import deque
def road(a,b):
    d[a].remove(b)
    d[b].remove(a)
    que=deque()
    que.append(a)
    aset={a}
    while que:
        t=que.popleft()
        if t==b:
            d[a].add(b)
            d[b].add(a)
            return False
        for e in d[t]:
            if e in aset:
                continue
            aset.add(e)
            que.append(e)
    d[a].add(b)
    d[b].add(a)
    return True
for a,b in pair:
    if road(a,b):
        ans+=1
print(ans)

Measured memory_bytes: 39792
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define f(i,a,b) for(i=a;i<b;i++)
#define YES cout<<"YES\n"
#define NO cout<<"NO\n"
using namespace std;

int main() {

int x;
cin>>x;

if(x>=400&&x<=599)cout<<8;

else if(x>=600&&x<=799)cout<<7;

else if(x>=800&&x<=999)cout<<6;

else if(x>=1000&&x<=1199)cout<<5;

else if(x>=1200&&x<=1399)cout<<4;
else if(x>=1400&&x<=1599)cout<<3;
else if(x>=1600&&x<=1799)cout<<2;
else cout<<1;

}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
 
using namespace std;
 
template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#endif


typedef long long ll; 
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
 
#define mp make_pair
#define pb push_back
#define all(a) a.begin(), a.end()

const int maxN = 502;

void solve() {
  ll n, k;
  cin >> n >> k;
  ll sub = n / k;
  n -= k * sub;
  cout << min(n, abs(n - k));
}
 
int main() {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    
  int t = 1;
  // cin >> t;
  while (t--) {
    solve();
  }
 
  return 0;
}

Measured memory_bytes: 256
/*
	tips:
		inline
		for(register int i = 0 ; i < n ; i ++){} ????????????????
		 
*/ 



#include<bits/stdc++.h>
// #include<string.h>
/*
	#include<iostream>
	#include<cstring>
	#include<cmath>
	#include<cstdlib>
*/ 
//#pragma comment(linker, "/STACK:1024000000,1024000000")
//	int __size__ = 256<<20;
//	char *__p__ = (char *)malloc(__size__)+__size__;
//	__asm__("movl?%0,%%esp\n"::"r"(__p__));
#define mian main
#define MAX(a,b) a>b?a:b
#define MIN(a,b) a<b?a:b
#define rep(i,n) for(int (i)=0;(i)<n;(i)++)
#define read(n) scanf("%d",&n);
#define readll(n) scanf("%lld",&n);
#define readdb(n) scanf("%lf",&n);
#define readch(n) scanf("%c",&n);
#define readstr(n) scanf("%s",n);
#define test printf("test\n");
#define pb push_back
#define in insert
#define init(n) memset(n,0,sizeof(n));

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef vector<int> VI;
typedef set<int> SI; 
typedef vector<ll> VLL;


int IT_MAX = 1 << 19;
ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;
//bool operator < (const p1 & a,const p1 & b)
//{
//	    if(a.x == b.x){
//			return a.y<b.y;
//		}else{
//			return a.x<b.x;
//		}
//}
void lcs(){
	/*
		for(int i = 0 ; i < n ; i ++){
			for(int j = i ; j < n ; j ++){
				if(c[i] == b[j]){
					dp[i+1][j+1] = dp[i][j] + 1;
				}else{
					dp[i+1][j+1] = max(dp[i+1][j],dp[i][j+1]);
				}
			}
		}
	*/
}


//inline ll read()
//{
//    ll x=0,f=1;char ch=getchar();
//    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
//    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
//    return x*f;
//}
ll gcd(ll m, ll n)
{
    while(m>0)
    {
        ll c = n % m;
        n = m;
        m = c;
    }
    return n;
} 
//   ll gcd(ll a , ll b){
//    return b?gcd(b,a%b):a;  
//}
double qpow(double a, ll b) {
      double res = 1;
      while(b) {
          if (b & 1) res = res * a;
          a = a * a;
         b >>= 1;
     }
     return res;
}
ll C(ll n,ll x){
	ll ans = 1;
	for(ll i = n , j = 1 ; i >= n-x+1 ; i -- , j ++){
		ans *= i ;
		ans /= j ;
	}
	return ans;
}		

//#define LOCAL_DEFINE
//-O2??? 
//#pragma GCC optimize(2)

//bool cmp(int a,int b){
//    return a > b;
//}
int main(){
	ios::sync_with_stdio(false);
  	cin.tie(0);
  	cout.precision(10);
	
	int n;
	cin >> n;
	VI c(n);
	int z=0,f=0;
	ll sum = 0;
	ll mmin = LL_INF; 
	for(int i = 0 ; i< n ; i ++){
		cin >> c[i];
		if(c[i] < 0){
			f ++;
			c[i] = -c[i];
		}
		sum += c[i];
	}
	sort(c.begin(),c.end());
	if(f%2 == 1){
		sum -= 2*c[0];
	}
	cout << sum;
	
	 
	
	
	
	
	
	
	
	
	
	




	 
#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	
	
	








	return 0; 
} 

Measured memory_bytes: 640
N, A, B=map(int,input().split(' '))
sum=0
ans=0
for i in range(1, N+1):
    s=list(str(i))
    for j in range(len(s)):
        sum =int(sum)+int(s[j])
    if A<=int(sum)<=B:
        ans = int(ans)+i
    sum=0
    s=0

print(ans)


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

int main() {
  int a,b,t1,t2;
  cin >> a >> b;
  for(int i = 1; i <= 1250; i++){
    t1 = i * 0.08;
    t2 = i * 0.1;
    if(t1 == a && t2 == b){
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
}


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

signed main(){
    ios::sync_with_stdio(0);cin.tie(0);
    
    int n;
    cin>>n;

    int ans=0;
    if(!(n&1) and n>=10){
        int x=10;
        while(n/x>0){
            ans+=n/x;
            x*=5;
        }
    }
    cout<<ans;

    return 0;
}

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

vector<int> d[10];

struct mode{
	int n;
	bool has[10];
};

mode dfs[100000];

int main()
{
	int n,m,i,j,a,b,top,tmp,count,ans;
	bool hast[10];
	cin>>n>>m;
	for(i=0;i<m;i++) 
	{
		cin>>a>>b;
		if(b!=1) d[a].push_back(b);
		if(a!=1) d[b].push_back(a);
	}
	top=0,dfs[0].n=1,dfs[0].has[1]=1,ans=0;
	while(top>=0)
	{
		tmp = dfs[top].n,count=0;
		for(i=1;i<=n;i++) hast[i]=dfs[top].has[i],count+=hast[i];
		top--;
		if(count==n)
		{
			ans++;
			continue;
		}
		for(i=0;i<d[tmp].size();i++)
		{
			if(!(hast[d[tmp][i]]))
			{
				dfs[++top].n=d[tmp][i];
				for(j=1;j<=n;j++) dfs[top].has[j]=hast[j];
				dfs[top].has[d[tmp][i]] = 1;
			}
		}
	}
	cout<<ans;
}

Measured memory_bytes: 256