akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
using namespace std;
typedef pair<int,int> ii;

struct Edge{
  int to,cap,cost,rev;
  Edge(int to=0,int cap=0,int cost=0,int rev=0):to(to),cap(cap),cost(cost),rev(rev){}
};

const int MAX_V = 1100, IINF = 1<<29;
int V;
vector<Edge> G[MAX_V];
int h[MAX_V],dist[MAX_V],prevv[MAX_V],preve[MAX_V];

inline void add_edge(int from,int to,int cap,int cost){
  G[from].push_back(Edge(to,cap,cost,G[to].size()));
  G[to].push_back(Edge(from,0,-cost,G[from].size()-1));
}

int min_cost_flow(int s,int t,int f){
  int res = 0;
  fill(h,h+V,0);
  while(f>0){
    priority_queue<ii,vector<ii>,greater<ii> > Q;
    fill(dist,dist+V,IINF);
    dist[s] = 0;
    Q.push(ii(0,s));
    while(!Q.empty()){
      ii p = Q.top(); Q.pop();
      int v = p.second;
      if( dist[v] < p.first ) continue;
      for(int i=0;i<G[v].size();i++){
        Edge &e = G[v][i];
        if( e.cap > 0 && dist[e.to] > dist[v] + e.cost + h[v] - h[e.to] ) { 
          dist[e.to] = dist[v] + e.cost + h[v] - h[e.to];
          prevv[e.to] = v;
          preve[e.to] = i;
          Q.push(ii(dist[e.to],e.to));
        }
      }
    }
    if( dist[t] == IINF ) return -1;
    rep(v,V) h[v] += dist[v];
    int d = f;
    for(int v=t;v!=s;v=prevv[v]) d = min(d,G[prevv[v]][preve[v]].cap);
    f -= d;
    res += d * h[t];
    for(int v=t;v!=s;v=prevv[v]){
      Edge &e = G[prevv[v]][preve[v]];
      e.cap -= d;
      G[v][e.rev].cap += d;
    }
  }
  return res;
}

int main() {
  int n,m,k;
  V=1003;
  cin >> n >> m >> k;
  int a[n],ans=0;
  for(int i=0; i<n; i++) {
    cin >> a[i];
    ans+=a[i];
    add_edge(1000,i,1,0);
    add_edge(i,1002,1,0);
  }
  add_edge(1002,1001,1<<29,0);
  for(int j=0; j<m; j++) {
    for(int i=0; i<n; i++) {
      int x;
      cin >> x;
      add_edge(i,j+n,1,min(0,a[i]-x));
    }
  }
  for(int i=0; i<m; i++) {
    int x;
    cin >> x;
    add_edge(i+n,1001,x,0);
  }
  cout << ans-min_cost_flow(1000,1001,n-k) << endl;
  return 0;
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long

int main() {
    fastio;
    int n, k;
    cin >> n >> k;
    int* a = new int[n];
    for (int i = 0; i < n; ++i) cin >> a[i];

    int sum = 0;
    for (int i = 0; i < n; ++i) {
        sum += min(a[i], k - a[i]);
    }
    cout << 2*sum;
    return 0;
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init));

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const int mod = 1000000007;
constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a,b;
  cin >> a>>b;
  cout << a * b << endl;
  return 0;
}

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(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 PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int d, n;

int main() {
	cin >> d >> n;
	
	int x = (n == 100 ? 101 : n);
	inc(i, d) { x *= 100; }
	
	cout << x << endl;
	
	return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    s=set()
    for i in range(1,10):
        for j in range(1,10):
            s.add(i*j)
    n=int(input())
    print("Yes" if n in s else "No")
resolve()

Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define pb push_back
const int maxn = 10000;
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;
const int mod = MOD7;

void ERROR(int num) { cout << "ERROR" << num << endl; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};


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

    int X, Y;
    cin >> X >> Y;
    int b = (Y-2*X) / 2;
    int c = (Y-2*X) % 2;
    int a = (Y-4*b) / 2;
    if(a+b!=X || a<0 || b<0 || c!=0) cout << "No" << endl;
    else cout << "Yes" << endl;
    //cout << a << " " << b << endl;
}

Measured memory_bytes: 3652
import math
s = 0
m = 10
for i in range(5):
  n = int(input())
  if n % 10 != 0:
    m = min(m, int(str(n)[-1]))
    
  s += math.ceil( n * 0.1 )
if m % 10 != 0:
  s +=  m * 0.1 - 1
print(int(s*10))


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

int main() {
	cin.tie(0)->sync_with_stdio(false);

	int n; cin >> n;
	double d; cin >> d;

	int cnt = 0;
	REP(i, n) {
		double x, y; cin >> x >> y;
		double dist = hypot(x, y);
		if (dist <= d)
			cnt++;
	}

	cout << cnt << '\n';
	return 0;
}

Measured memory_bytes: 3860
def main():
    odd_str = input()
    even_str = input()
    answer = [""] * (len(odd_str) + len(even_str))
    for i in range(len(odd_str)):
        answer[2 * i] = odd_str[i]
    for i in range(len(even_str)):
        answer[2 * i + 1] = even_str[i]
    print("".join(answer))


if __name__ == '__main__':
    main()



Measured memory_bytes: 3060
#![allow(unused_imports)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

// -----------------------------------------------
// Framework <https://github.com/vain0x/procon>
// -----------------------------------------------

//
// Macro debug!
//

#[cfg(debug_assertions)]
include!{"./procon/debug.rs"}

#[cfg(not(debug_assertions))]
macro_rules! debug {
    ($($arg:expr),*) => {};
}

//
// Macro input!
//

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

//
// IteratorExt
//

trait IteratorExt: Iterator + Sized {
    fn vec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

impl<T: Iterator> IteratorExt for T {}


//
// Main
//

fn main() {
    input! {
        r: usize,
    }

    println!("{}", 3 * r * r);
}


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

namespace ABC147B
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Cin.String();
            int ans = 0;
            for (int i = 0; i < s.Length/2; i++)
            {
                if (s[i] != s[s.Length - 1 - i])
                {
                    ans++;
                }
            }
            
            Console.WriteLine(ans);
        }
    }

    class Solver
    {
        public Solver()
        {

        }

        public IConvertible Solve()
        {
            return 0;
        }
    }

    internal static class Cin
    {
        public static string String()
        {
            return Console.ReadLine();
        }

        public static int Int()
        {
            return int.Parse(String());
        }

        public static int[] IArr()
        {
            return Split().Select(int.Parse).ToArray();
        }

        public static long Long()
        {
            return long.Parse(String());
        }

        public static long[] LArr()
        {
            return Split().Select(long.Parse).ToArray();
        }

        public static double Double()
        {
            return double.Parse(String());
        }

        public static double[] DArr()
        {
            return Split().Select(double.Parse).ToArray();
        }

        private static IEnumerable<String> Split()
        {
            return String().Split(' ');
        }
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, k;
    cin >> n >> k;

    vector<int> d(k);
    vector<vector<int>> a(k, vector<int>(n));

    for (int i =0; i < k; i++) {
        cin >> d.at(i);
        for (int j =0; j < d.at(i); j++) {
            cin >> a.at(i).at(j);
        }
    }

    int itazura = n;
    int judge = 0;

    for (int i = 1; i <= n; i++) {
        judge = 0;
        for (int x = 0; x < k; x++) {
            for (int j = 0; j < n; j++) {
                if(i == a.at(x).at(j)) {
                    itazura--;
                    judge = 1;
                    break;
                } else {
                    continue;
                }
            }
            if (judge == 1) {
                break;
            } else {
                continue;
            }
        }
    }
    cout << itazura << endl;
}

Measured memory_bytes: 3684
a,b,c=map(int,input().split())
if a==b and b==c and a%2==0:
  print(-1)
else:
  x=0
  while a%2==0 and b%2==0 and c%2==0:
    A=(b+c)/2
    B=(c+a)/2
    C=(a+b)/2
    a=A
    b=B
    c=C
    x+=1
  print(x)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<ll> VLL;
typedef vector<PLL> VP;
const static int INF = 1000000000;
const static int MOD = 1000000007;
const int dx[4]={1, 0, -1, 0};
const int dy[4]={0, 1, 0, -1};
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; }
#define rep(i,n) for (ll i=0; i<(ll)(n); i++)
#define repd(i,n) for (ll i=n-1; i>=0; i--)
#define rept(i,m,n) for(ll i=m; i<n; i++)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define PF push_front
#define PB push_back
#define SORT(V) sort((V).begin(), (V).end())
#define RVERSE(V) reverse((V).begin(), (V).end())
#define paired make_pair
#define PRINT(V) for(auto v : (V)) cout << v << " "
//charを整数に
int ctoi(char c) { if (c >= '0' && c <= '9') { return c - '0'; } return 0; }
// 累積和 for (int i = 0; i < N; ++i) s[i+1] = s[i] + a[i]; 
void cum_sum(int N,vector<double> a, vector<double> &s){ for(int i=0; i<N; i++){ s[i+1]=s[i]+a[i];}}
//ユークリッドの控除法
ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}
//最小公倍数
ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b; // Be careful not to overflow
}
//素数判定
bool is_prime(long long n) {
    if (n <= 1) return false;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p == 0) return false;
    }
    return true;
}
int getdigit(ll num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}
//空白文字も入力 getline(cin, S);
//桁数指定 setprecision

int main()
{
    ios::sync_with_stdio(0); 
    cin.tie(0); 
    cout.tie(0);
    string A;
    cin >> A;
    if(A=="A" || A=="B" || A=="C" || A=="D" || A=="E" || A=="F" || A=="G" || A=="H" || A=="I" || A=="J" || A=="K" || A=="L" || A=="M" || A=="N" || A=="O" || A=="P" || A=="Q" || A=="R" || A=="S" || A=="T" || A=="U" || A=="V" || A=="W" || A=="X" || A=="Y" || A=="Z"){
        cout << "A" << endl;
    }
    else{
        cout << "a" << endl;
    }
}

Measured memory_bytes: 3612
//https://www.youtube.com/watch?v=8LusJS5-AGo
//https://www.geeksforgeeks.org/0-1-knapsack-problem-dp-10/
#include<bits/stdc++.h>
#define int long long
#define scf(n) scanf("%lld",&n)
#define rep1(n) for(int i=1;i<=n;i++)
#define prf(n) printf("%lld",n)
#define sci(n) scanf("%lld",&n)
#define pri(n) printf("%lld",n)

#define nl printf("\n")
#define spc printf(" ")
#define file freopen("in.txt","rt",stdin)
#define pii pair<int,int>
#define piii pair<pii,int>
#define MOD 10000007
const int INF = 1e18L + 5;
using namespace std;

/*bool sortBySec(const pair<int,int> &a,const pair<int,int> &b)
{
    return (a.second < b.second);
}*/
void faster(void)
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}
/******************************************/


int32_t main()
{

  int n,m;
  sci(n);
  pri((n*(n-1))/2),nl;


    return 0;
}


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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = 1LL << 60;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
	ll a, b, c, d;

	cin >> a >> b >> c >> d;

	if (abs(a - c) <= d || (abs(a - b) <= d && abs(b - c) <= d)) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

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

int main() {
  int N;
  string S;
  cin >> N >> S;
  int count = 0;
  
  for (int i = 0; i < N-2; i++) {
    if (S.at(i) == 'A' && S.at(i+1) == 'B' && S.at(i+2) == 'C'){
      count++;
    }
  }
  cout << count << endl;
}



Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

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

    int n;
    cin >> n;
    
    int l = -1, r = n+1;
    bool even_male = true;
    for (int i = 0; ; ++i) {
        string s;
        if (i == 0) {
            cout << 0 << endl;
            fflush(stdout);
            cin >> s;
            if (s == "Vacant") return 0;
            else {
                if (s == "Female") even_male = false;
            }
        } else {
            int mid = (l + r) / 2;
            cout << mid << endl;
            fflush(stdout);
            cin >> s;
            if (s == "Vacant") return 0;
            else {
                if (s == "Male") {
                    if (even_male) {
                        if (mid % 2 == 0) {
                            l = mid;
                        } else {
                            r = mid;
                        }
                    } else {
                        if (mid % 2 == 0) {
                            r = mid;
                        } else {
                            l = mid;
                        }
                    }
                } else {
                    if (even_male) {
                        if (mid % 2 == 0) {
                            r = mid;
                        } else {
                            l = mid;
                        }
                    } else {
                        if (mid % 2 == 0) {
                            l = mid;
                        } else {
                            r = mid;
                        }
                    }
                }
            }
        }
    } 
}

Measured memory_bytes: 852
function main()
  
  num = map(x -> parse(Int,x), split(readline()))
  
  sort!(num)
  
  cnt = 0
  
  while num[1] < num[3]-1
    cnt += 1
    num[1] += 2
  end

  while num[2] < num[3]-1
    cnt += 1
    num[2] += 2
  end
  
  if num[1] == num[2] && num[1] != num[3]
    cnt += 1
  elseif num[1] != num[2]
    cnt += 2
  end

  println(cnt)
  
end

main()

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

int main(void)
{
    long long int N, D;

    cin >> N >> D;

    int ans = 0;
    for(int i = 0; i < N; ++i)
    {
        long long int x, y;

        cin >> x >> y;

        if(x*x+y*y <= D*D) ++ans;

    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 3592
from collections import deque
s = list(input())
q = int(input())
rev = 0
revcnt = 0
s_q = deque(s)
for _ in range(q):
    query = list(map(str, input().split()))
    if query[0] == "1":
        revcnt += 1
        if rev == 0:
            rev = 1
        elif rev == 1:
            rev = 0

    elif query[0] == "2":
        if rev == 0:
            if query[1] == "1":
                s_q.appendleft(query[2])
            elif query[1] == "2":
                s_q.append(query[2])
        else:
            if query[1] == "1":
                s_q.append(query[2])
            elif query[1] == "2":
                s_q.appendleft(query[2])
s = list(s_q)
if revcnt%2 == 0:
    print("".join(s))
else:
    print("".join(s[::-1]))

Measured memory_bytes: 73976
#pragma region header
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr ll inf = INT32_MAX/2;
constexpr ll INF = LLONG_MAX/2;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */

/* --------------------テンプレート------------------ */
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;
}
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ----------------------end----------------------- */
#pragma endregion
int main() {
    int n;cin >> n;
    bool ok = false;
    rep(i, n) {
        int a;cin >> a;
        if(a%2)ok = true;
    }
    if(ok)cout << "first" << endl;
    else cout << "second" << endl;
    return 0;
}

Measured memory_bytes: 3628
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = (int)(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = (int)(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define REVERSE(x) reverse((x).begin(), (x).end())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << '\n'
// #define endl '\n'

constexpr int IINF = (1 << 30) - 1;
constexpr long long LLINF = 1LL << 61;
constexpr double EPS = 1e-10;

constexpr int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
constexpr int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

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

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

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

    int n, k;
    while(cin >> n >> k){
        if((lint)(k + k + n * 2 - 1) * n * 2 > (lint)(k + n * 2 + k + n * 3 - 1) * n){
            cout << -1 << endl;
            continue;
        }

        vector<int> a(n, -1), b(n, -1), c(n);
        rep(i, n){
            c[i] = k + n * 2 + i;
        }

        int d2 = (n + 1) / 2;
        for(int i = 0 ; i < n ; i += 2){
            a[i] = k + i / 2;
            b[i] = k + n * 2 - d2 + i / 2;
        }

        for(int i = 1 ; i < n ; i += 2){
            a[i] = k + d2 + i / 2;
            b[i] = k + n + i / 2;
        }

        rep(i, n){
            cout << a[i] << ' ' << b[i] << ' ' << c[i] << endl;
        }
    }

    cout << flush;

    return 0;
}

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

int main()
{
    string s;
    cin >> s;
    for(int i = 0; i < s.size(); i++)
    {
        if(s[i]=='1')s[i]='9';
        else if(s[i]=='9')s[i]='1';
    }
    cout << s;

}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--) 
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define downque(que) priority_queue<ll> que;
#define upque(que) priority_queue<ll, vector<int>, greater<int>> que;
typedef long long ll;
typedef vector<vector<int>> Matrix;
const int MOD = 1e9 + 7;
const int MAX = 1e7;
const int INF = numeric_limits<int>::max();




int main(){
  char s[4];
  REP(i, 4)
      cin >> s[i];
      int t[4];
      REP(i, 4)
      t[i] = s[i] - '0';

 
for (int bit = 0; bit < (1 << 3); ++bit){
  char op[3];
  int sum = t[0];

  for (int i = 0; i < 3;i++){
     if(bit&(1<<i)){
       op[i] = '+';
     sum += t[i + 1];
  }else{
     op[i] = '-';
     sum -= t[i + 1];
     }
  }
     if(sum==7){
       cout << s[0] << op[0] << s[1] << op[1] << s[2] << op[2] << s[3] <<"=7"<< endl;
       break;
     }
  
}


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define ll long long 
#define rep(i,a,b) for(signed i=a;i<(b);++i)
#define erep(i,a,b) for(signed i=a;i<=(b);++i)
#define per(i,a,b) for(signed i=(a);i>(b);--i)
#define eper(i,a,b) for(signed i=(a);i>=b;--i)
#define fore(i, x, a) for(auto &&x:a) 
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define pb emplace_back
#define mp make_pair
#define ALL(x) begin(x),end(x)
#define F first
#define S second
#define debug(x)  cout << #x << ": " << (x) << '\n';
const long long INF=1001001001001001001;
const int MOD=(int)1e9 + 7;
const double EPS=1e-9;
using namespace std;
using Pii = pair<int,int>;
using vii = vector<int>;
template<class T>using  PS_queue = priority_queue<T, vector<T>, greater<T> >;
template<class T>using vv = vector<T>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill( (T*)array, (T*)(array+N), val );}
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> ostream& operator<<(ostream &os,const vector<vector<T>> &v) {
    ITR(u,begin(v),end(v))ITR(w,begin(*u),end(*u))os<<*w<<(w==end(*u)-1?"\n":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T>T gcd(T a, T b){ return b ? gcd(b, a % b) : a; }
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct edge { int from, to, cost; };
int dy[]={0, 1, -1, 0}; int dx[]={1, 0, 0, -1};
// cout << fixed;
// cout << setprecision(10) << val;

double n, k, ans;
signed main() {
 cin.tie(0);
 ios::sync_with_stdio(false);

  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    double cnt = 0, v = i+1;
    while (v < k) {
      v *= 2.0;
      cnt++;
    }
    ans += 1 / pow(2, cnt);
  }
  cout << fixed << setprecision(10) << ans / n << endl;
  return 0;
}




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

int div2(int x){
    int count=0;
    while(x % 2==0){
        count++;
        x = x / 2;
    }
    return count; 
}

int main(void) {
    int N;
    cin >> N;
    int count=0;
    for(int i=0;i<N;i++){
        int a;
        cin >> a;
        count += div2(a);
    }
    cout << count << endl;


    return 0;
}

Measured memory_bytes: 256
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/irange.hpp>
#include "bits/stdc++.h"

namespace adaptor = boost::adaptors;

int64_t n, position;
std::vector<int64_t> pre, in, post;

void rec(int64_t l, int64_t r) {
    if (l >= r) return;
    int64_t root, m;
    root = pre[position++];
    m = std::distance(in.begin(), std::find(in.begin(), in.end(), root));
    rec(l, m);
    rec(m + 1, r);
    post.push_back(root);
}

void solve() {
    std::cin >> n;
    for (int64_t i = 0; i < n; i++) {
        int64_t tmp;
        std::cin >> tmp;
        pre.push_back(tmp);
    }
    for (int64_t i = 0; i < n; i++) {
        int64_t tmp;
        std::cin >> tmp;
        in.push_back(tmp);
    }

    position = 0;
    rec(0, pre.size());
    for (int64_t i = 0; i < n; i++) {
        if (i > 0) std::cout << " ";
        std::cout << post[i];
    }
    std::cout << std::endl;

    return;
}

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



Measured memory_bytes: 3212
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

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




int main() {
    ll r;
    cin >> r;
    cout << ((r < 1200)? "ABC" : (r < 2800)? "ARC" : "AGC") << endl;
}

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

void bfs(int &h,int &w,vector<string> &s,vector<vector<int>> &distance,vector<vector<bool>> &checked,pair<int,int> &p,queue<pair<int,int>> &q,int &md){
  int i=p.first,j=p.second;
  if(i!=0&&(!checked.at(i-1).at(j))&&s.at(i-1).at(j)=='.'){
    checked.at(i-1).at(j)=true;
    q.push(pair<int,int>(i-1,j));
    distance.at(i-1).at(j)=distance.at(i).at(j)+1;
    md=max(md,distance.at(i-1).at(j));
  }
  if(i!=h-1&&(!checked.at(i+1).at(j))&&s.at(i+1).at(j)=='.'){
    checked.at(i+1).at(j)=true;
    q.push(pair<int,int>(i+1,j));
    distance.at(i+1).at(j)=distance.at(i).at(j)+1;
    md=max(md,distance.at(i+1).at(j));
  }
  if(j!=0&&(!checked.at(i).at(j-1))&&s.at(i).at(j-1)=='.'){
    checked.at(i).at(j-1)=true;
    q.push(pair<int,int>(i,j-1));
    distance.at(i).at(j-1)=distance.at(i).at(j)+1;
    md=max(md,distance.at(i).at(j-1));
  }
  if(j!=w-1&&(!checked.at(i).at(j+1))&&s.at(i).at(j+1)=='.'){
    checked.at(i).at(j+1)=true;
    q.push(pair<int,int>(i,j+1));
    distance.at(i).at(j+1)=distance.at(i).at(j)+1;
    md=max(md,distance.at(i).at(j+1));
  }
  return;
}

int maxdis(int &h,int &w,vector<string> &s,int x,int y){
  queue<pair<int,int>> q;
  vector<vector<bool>> checked(h,vector<bool>(w,false));
  vector<vector<int>> distance(h,vector<int>(w,0));
  q.push(pair<int,int>(x,y));
  checked.at(x).at(y)=true;
  int md=0;
  while(!q.empty()){
    bfs(h,w,s,distance,checked,q.front(),q,md);
    q.pop();
  }
  return md;
}

int main(){
  int h,w,i,j,M=0;
  cin >> h >> w;
  vector<string> s(h);
  for(i=0;i<h;i++){
    cin >> s.at(i);
  }
  for(i=0;i<h;i++){
    for(j=0;j<w;j++){
      if(s.at(i).at(j)=='.'){
        M=max(M,maxdis(h,w,s,i,j));
      }
    }
  }
  
  cout << M << endl;
}

Measured memory_bytes: 3584
#include <iostream>
#include <algorithm>
#include <vector>

typedef long long ll;

using namespace std;

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

    int N,T;
    cin >> N >> T;
    vector<int>t(N);

    for (int i = 0; i < N; i++) {
        cin >> t[i];
    }

    int tmp = 0;

    for (int i = 1; i < N; i++) {
        tmp += min(T,t[i]-t[i-1]);
    }
    
    tmp += T;
    
    cout << tmp << endl;

    return 0;
}

Measured memory_bytes: 1024
HK=input().split(' ')
H=int(HK[0])
K=int(HK[1])
if H==1 or K ==1:
    print(1)
else:
    if K % 2==1 and H%2==1:
        print(round(H*K/2)+1)
    else:
        print(int(H*K/2))


Measured memory_bytes: 2940
#include<cstdio>
long long gcd(long long a,long long b)
{
	if(b==0LL)
		return a;
	return gcd(b,a%b);
}
int main()
{
	long long a,b;
	while(~scanf("%lld%lld",&a,&b))
	{
		long long d=gcd(a,b);
		printf("%lld %lld\n",d,a/d*b);
	}
	return 0;
}

Measured memory_bytes: 2628
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    string s; cin>>s;
    vb flag(s.size()+1);
    vi dp(s.size()+1,0);
    rep(i,s.size()){
        if(s[i]=='B')dp[i]=1;
        else dp[i]=-1;
    }
    int ans=0;
    rep(i,s.size()-1){dp[i+1]+=dp[i];if(dp[i+1]>dp[i])flag[i+1]=true; else flag[i+1]=false;}
    rep(i,s.size()-1){
        if(i==0&&s[i]=='B')flag[i]=true;
        if(flag[i+1]!=flag[i])ans++;
    }
    cout<<ans<<endl;
   // rep(i,s.size())cout<<" "<<dp[i];
    //cout<<endl;
}

Measured memory_bytes: 896
<?php
$sc = new Scanner();
$num = $sc->nextInt();

$res = null;
if (1 <= $num && $num < 100) {
    $res = min($num, 9);
} elseif (100 <= $num && $num < 10000) {
    $res = min($num - 90, 900 + 9);
} elseif (10000 <= $num && $num <= 100000) {
    $res = min($num - 9000 - 90,  90000 + 900 + 9);
}

Out::println($res);

class Scanner {
    private $arr = [];
    private $count = 0;
    private $pointer = 0;
    public function next() {
        if ($this->pointer >= $this->count) {
            $str = trim(fgets(STDIN));
            $this->arr = explode(' ', $str);
            $this->count = count($this->arr);
            $this->pointer = 0;
        }
        $result = $this->arr[$this->pointer];
        $this->pointer++;
        return $result;
    }
    public function hasNext() {
        return $this->pointer < $this->count;
    }
    public function nextInt() {
        return (int)$this->next();
    }
    public function nextDouble() {
        return (double)$this->next();
    }
}

class Out {
    public static function println($str = "") {
        echo $str . PHP_EOL;
    }
}


Measured memory_bytes: 3700
#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 int long long
#define vec(a,n) vector<int> (a)((n))
#define Vec(a,n) vector<string> (a)((n))
#define twovec(a,n,m) vector<vector<int>> a(n,vector<int>(m,0))
#define Twovec(a,n,m) vector<vector<double>> a(n,vector<double>(m,0))
#define P pair<int,int>
#define All(a) (a).begin(),(a).end()
#define Sort(a) sort(All(a))
#define RSort(a) reverse(All(a))
#define Reverse(a) reverse(All(a))
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
#define Lower(a,t) lower_bound(All(a),t)
using namespace std;
int max_int = 1000000007;
void Debug(auto a){
    cout << "{ ";
    for(auto b: a){
        cout << b << " ";
    }
    cout << "}" << endl;
}

signed main(){
    int n,m;
    cin >> n >> m;
    vec(a,m);
    vec(b,m-1);
    REP(i,m){
        cin >> a[i];
    }
    Sort(a);
    if(n>=m){
        cout << 0 << endl;
        return 0;
    }
    REP(i,m-1){
        b[i] = a[i+1]-a[i];
    }
    Sort(b);
    RSort(b);
    int ans = 0;
    FOR(i,n-1,m-1){
        ans += b[i];
    }
    cout << ans << endl;


    
    return 0;
}



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

int main() {
	int n, k; cin >> n >> k;
	unordered_set<int> st;
	for (int i=1; i<=n; i++) {
		st.insert(i);
	};
	for (int i=0; i<k; i++) {
		int d; cin >> d;
		for (int j=0; j<d; j++) {
			int t;
			cin >> t;
			if (st.find(t) != st.end()) {
				st.erase(t);
			}
		}
	}
	cout << st.size();
}


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

int a,b,c,d,e,f;
int main()
{
	double Max=-1.0;int a1,a2;
	scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f);
	for (int i=0;i<=100;i++)
		for (int j=0;j<=100;j++)
			for (int k=0;k<=1500;k++)
			{
				int wat=i*a+j*b,sug=k*c;
				if (wat*100+sug>f) continue;
				if (wat*e<sug) continue;
				int l=min(f-wat*100-sug,wat*e-sug)/d*d;
				sug+=l;
//				cout<<wat<<' '<<sug<<endl;
				if (1.0*sug/(wat+sug)>Max)
				{
					Max=1.0*sug/(wat+sug);
					a1=wat*100+sug,a2=sug;
				}
			}
	printf("%d %d\n",a1,a2);
	return 0;
}

Measured memory_bytes: 256
//カタラン数を語らん!w

#define  _CRT_SECURE_NO_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 <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;
typedef string::const_iterator State;
#define Ma_PI 3.141592653589793
#define eps 1e-5
#define LONG_INF 2000000000000000000LL
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL
#define MOD 998244353LL
#define seg_size 262144*2
#define REP(a,b) for(long long a = 0;a < b;++a)
#define int long long
int dp[201][201][500];
int grid[201][201];
#undef int
int main() {
#define int long long
	int h, w;
	cin >> h >> w;
	int hoge = 0;
	REP(i, h) {
		REP(q, w) {
			cin >> grid[i][q];
			hoge += grid[i][q];
		}
	}
	dp[0][0][0] = grid[0][0];
	for (int i = 0; i < h + w-2; ++i) {
		for (int q = 0; q <= i; ++q) {
			for (int j = 0; j <= i; ++j) {
				int first_x = q;
				int first_y = i - q;
				int second_x = j;
				int second_y = i - j;
				REP(t, 2) {
					REP(p, 2) {
						int next_fx = first_x + t;
						int next_fy = first_y + 1 - t;
						int next_sx = second_x + p;
						int next_sy = second_y + 1 - p;
						if (next_fx >= h || next_sx >= h | next_fy >= w | next_sy >= w) {
							continue;
						}
						int winning = dp[q][j][i] + grid[next_fx][next_fy];
						if (next_fx != next_sx || next_fy != next_sy) {
							winning += grid[next_sx][next_sy];
						}
						dp[next_fx][next_sx][i+1] = max(dp[next_fx][next_sx][i+1], winning);
					}
				}
			}
		}
	}
	cout << dp[h - 1][h - 1][h + w - 2] << endl;
}

Measured memory_bytes: 158208
#include <bits/stdc++.h>
 
using namespace std;
 
#define x first
#define y second
#define mp make_pair
#define pb push_back
 
typedef long long ll;
 
const ll MOD = 1e9+7;
const ll INF = 1e9+5;
 
int a, b, c, d, e, n, m, k;
string s, t, r;
char c1, c2, c3;
 
int A[200005];
int B[200005];
int C[200005];
 
int main() {
	cin >>s;
  	if (s[2]==s[3] and s[4]==s[5]) {
      cout <<"Yes\n";
    }else {
    	cout <<"No\n";
    }
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define ALL(n) begin(n),end(n)

double Naiseki(vector<double> x,vector<double> y){
    double ip=0;
    for(int i=0; i<x.size(); i++){
        ip+=x[i]*y[i];
    }
    return ip;
}

int main(){
    vector<double> A(2),B(2);
    int q;
    cin>>A[0]>>A[1]>>B[0]>>B[1];
    cin>>q;
    vector<vector<double>> P(q,vector<double>(2));
    REP(i,q){
        cin>>P[i][0]>>P[i][1];
    }

    vector<double> AB={B[0]-A[0],B[1]-A[1]};

    REP(i,q){
        vector<double> AP={P[i][0]-A[0],P[i][1]-A[1]};
        double AB_av_2=AB[0]*AB[0]+AB[1]*AB[1];

        vector<double> AM(2);
        AM[0]=(Naiseki(AB,AP)/AB_av_2)*AB[0];
        AM[1]=(Naiseki(AB,AP)/AB_av_2)*AB[1];

        vector<double> OM={AM[0]+A[0],AM[1]+A[1]};
        cout<<fixed<<setprecision(10)<<2*OM[0]-P[i][0]<<" "<<2*OM[1]-P[i][1]<<endl;
    }
}   



Measured memory_bytes: 3332
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <algorithm> // sort
#include <map>
#include <cmath>
#include <queue>

#define DEBUG 0

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;

//最初に大きいやつを注文する必要がある
//最初の注文からT−0.5分後以降に注文することはできない

// T-1秒のときに、 i 番目を注文する
// 残りでT-1で完食するdp

//DP1[i][j] = 1～i 番目の料理で j 分以内に完食できる美味しさの合計の最大値 
//DP2[i][j] = i～N 番目の料理で j 分以内に完食できる美味しさの合計の最大値

struct Food {
  int minute;
  int taste;
};

bool cmp(const Food &a, const Food &b)
{
    if(a.minute == b.minute)
    {
        return a.taste > b.taste;
    }
    return a.minute < b.minute;
}

Food make_Food(int m, int t) {
    Food myfood = {m, t};
    return myfood;
}

int main(){
  ll N,T;
  cin >> N >> T;

  vector <Food> food(N);

  REP(i,N)
  {
    cin >> food[i].minute >> food[i].taste;
  }

  //foodを昇順に
  sort(food.begin(), food.end(), cmp);

  ll dp1[N+1][T];

  REP(i,N+1)
  {
    REP(j, T)
    {
      dp1[i][j] = 0;
    }
  }

  //DP1[i][j] = 1～i 番目の料理で j 分以内に完食できる美味しさの合計の最大値 
  for(int i = 0; i < N; ++i)
  {
    for(int j = 0; j < T; ++j)
    {
      if(food[i].minute <= j)
      {
        dp1[i+1][j] = max(dp1[i][j], dp1[i][j-food[i].minute] + food[i].taste);
      }
      else
      {
        dp1[i+1][j] = dp1[i][j];
      }
    }
  }


  ll res = 0;
  //iをT-1秒に食べたときをシミュレーション
  //昇順にソートしているので、T-1秒時点のi-1をみればよい
  for(int i = 1; i <= N; ++i)
  {
    for(int j = 0; j <= T-1; ++j)
    {    
      ll tmp = dp1[i-1][j] + food[i-1].taste;
      res = max(res, tmp);
    }
  }

#if DEBUG
  REP(j,T)
  {
    cout << dp1[N][j] << endl;
  }
#endif

  cout << res << endl;

  return 0;    
}



Measured memory_bytes: 70656
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#define my_abs(x) ((x) < 0 ? -(x) : (x))
#define mp std::make_pair
#define pb push_back
typedef long long ll; 
int arr[100005]; 
int main()
{
	// freopen("ARC099-C.in", "r", stdin); 
	int n, k, ans = 0, pos = 0; 
	scanf("%d%d", &n, &k); 
	for (int i = 0; i < n; i++)
		scanf("%d", arr + i); 
	for (int i = 0; i < n; i += k - 1)
	{
		ans++; 
		bool f = false; 
		for (int j = i; j < i + k - 1 && j < n; j++)
			f |= arr[j] == 1; 
		if (arr[i + k - 1] == 1 || f)
		{
			pos = i + k; 
			break; 
		}
	}
	while (pos < n)
	{
		ans++; 
		pos += k - 1; 
	}
	printf("%d\n", ans);
	return 0; 
}


Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    class QuestionB
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 文字列の入力
            //string s = Console.ReadLine();

            // 整数の入力
            //long n = long.Parse(Console.ReadLine());

            // 文字列配列の入力
            //string[] inputStrArray = Console.ReadLine().Split(' ');

            // 整数配列の入力
            var inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

            var A = inputLongArray[0];
            var B = inputLongArray[1];
            var C = inputLongArray[2];
            var D = inputLongArray[3];
            string result;
            result = "start";

            while (A > 0 && C > 0)
            {
                C = C - B;
                if (C > 0)
                {
                    A = A - D;
                    result = "No";
                }
                else
                {
                    result = "Yes";
                }
            }


            Console.WriteLine(result);

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 28180
//
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
//
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)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

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, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

// solution 
use std::cmp;
#[allow(unused_mut)]
#[allow(non_snake_case)]
fn main() {
    input!{
        N: usize,
        destinations: [(i64, i64, i64); N],
    }
    destinations.insert(0, (0, 0, 0));
    let mut sa = vec![(0,0,0); N];
    for ind in 0..N { 
        sa[ind] = (destinations[ind+1].0 - destinations[ind].0,
                   (destinations[ind+1].1 - destinations[ind].1).abs(),
                   (destinations[ind+1].2 - destinations[ind].2).abs());
    }

    for ind in 0..N {
        if sa[ind].0 >= sa[ind].1 + sa[ind].2 && (sa[ind].0 - sa[ind].1 - sa[ind].2)&1==0 {
            continue
        } else {
            println!("No");
            return
        }
    }
    println!("Yes");
}


Measured memory_bytes: 12540