akhauriyash/Code-Regression huggingface dataset:
// in case of multiple test cases and N=1e5 don't intialize arrays as global except for graph vector-array
// always check whether or not you are doing mod of a negative number
// always use 1LL instead of 1
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>
 
using namespace __gnu_pbds;
using namespace std;

// using long doubles saves you from corner cases but is very time consuming
#define double      	long double
#define int         	long long
#define pb          	push_back
#define pii         	pair<int,int>
#define vi          	vector<int>
#define vii         	vector<pii>
#define mi          	map<int,int>
#define mii         	map<pii,int>
#define all(a)      	(a).begin(),(a).end()
#define sz(x)       	(int)x.size()
// just comment the line below in case of interactive problems
#define endl        	"\n"
#define repp(i,a,b) 	for(int i=a;i<b;i++)
#define rep(i,a,b) 		for(int i=a;i<=b;i++)
#define brep(i,a,b)     for(int i=a;i>=b;i--)
#define deb1(x)      	cout << #x << "=" << x << endl
#define deb2(x, y)  	cout << #x << "=" << x << "," << #y << "=" << y << endl
#define deb3(x, y, z)  	cout << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define trace(v) 		for(auto it=v.begin();it!=v.end();it++)cout<<*it<<" ";cout<<endl;
#define tracearr(a,l,r) for(int iii=l;iii<=r;iii++)cout << a[iii] << " ";cout << endl;
#define PI          	3.1415926535897932384626
#define F 				first
#define S 				second
#define clr(x,y) 		memset(x, y, sizeof(x))
#define IOS         	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);


typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
// *s.find_by_order(1) - gives the 2nd samllest element in set
// s.order_of_key(x)   - gives the number of elements in the set which are strictly smaller than x


const int N=1e5 + 5;
const int MOD=1e9 + 7;

int32_t main()
{
	IOS;
	int T=1;
	//cin >> T;
	// int numOfSetBits = __builtin_popcountll(n);
	std::cout << std::fixed << std::setprecision(12);
	while(T--)
	{
		string s;
		cin >> s;
		int n = s.size();
		if(s[n-1]=='s')
			s += "es";
		else
			s += "s";
		cout << s << endl;
	}
}

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

typedef long long ll;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define MP make_pair
#define MT make_tuple
#define F first
#define S second
#define PB push_back
#define dump(x)  cout << #x << " = " << (x) << endl;	//debug
#define SZ(x) ((ll)(x).size())
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (ll i = (a); i >= (b); i--)
#define ps(s) cout << #s << endl;
#define pv(v) cout << (v) << endl;
#define pvd(v) cout << setprecision(16) << (v) << endl;
#define ALL(a)  (a).begin(),(a).end()
#define RANGE(a, start_index, num)  (a).begin()+(start_index),(a).begin()+(num)

ll fpow(ll a, ll n) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * a;
		a = a * a;
		n >>= 1;
	}
	return res;
}

int main() {
	int n;
	cin >> n;
	vector<int> memo(100001);
	ll sum = 0;
	FOR(i, 1, n) {
		int a;
		cin >> a;
		memo[a]++;
		sum += a;
	}
	int q;
	cin >> q;
	FOR(i, 1, q) {
		int b, c;
		cin >> b >> c;
		sum += (c - b)*memo[b];
		pv(sum);
		memo[c] += memo[b];
		memo[b] = 0;
	}
	return 0;
}

Measured memory_bytes: 3784
#include<iostream>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int N,mx=0,ans = 0;
int main() {
    cin >> N;
    REP(i,N){
        int temp = N - i,x=0;
        while(temp){
            x++;
            temp /=2;
        }
        if(mx<=x){
            mx = x;
            ans = N - i;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
	int a=0, b=0,n,s,t;
	cin >> n; while (n != 0) {
		a = 0; b = 0;
		for (int i = 0; i < n; i++) {
			scanf("%d%d", &s, &t);
			if (s > t)a += s + t;
			else if (t > s)b += s + t;
			else { a += s; b += t; }
		}
		cout << a << " " << b << endl; cin >> n;
	}
	return 0;
}

Measured memory_bytes: 1244
import java.util.*;
public class Main {
	public static void main(String[] args){
		List<String> list = new ArrayList<>();
		list.add("Even");
		list.add("Odd");
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
		// スペース区切りの整数の入力
		int b = sc.nextInt();
		
		System.out.println(list.get(a*b % 2));

	}
}

Measured memory_bytes: 22612
#B Postal Code
a , b = map(int,input().split())
c = input()
d = len(c)
e = 0
for i in range(d):
    if c[i] =="-" and i != a:
        e = e + 1
if a+b+1 == d and c[a] =="-" and e == 0:
    
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
program cm
   implicit none
   integer::N,M,Q
   integer,allocatable,dimension(:)::a,b,c,d
   integer,allocatable,dimension(:)::X
   integer::i
   integer::ans=0
   read*,N,M,Q
   allocate(a(Q),b(Q),c(Q),d(Q))
   do i=1,Q
      read*,a(i),b(i),c(i),d(i)
   end do
   allocate(X(0:N))
   X(0)=1
   call DFS(1)
   print"(I0)",ans
contains
recursive subroutine DFS(K)
   integer::K
   integer::i
   if(K==N+1)then
      ans=max(ans,calc())
      return
   endif
   do i=X(K-1),M
      X(K)=i
      call DFS(K+1)
   end do
end subroutine
integer function calc()
   integer::i
   calc=0
   do i=1,Q
      if(X(B(i))-X(A(i))==c(i))calc=calc+d(i)
   end do
end function
end program cm

Measured memory_bytes: 2872
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>
using namespace std;

int main(){
    int a,b,c,d;cin>>a>>b>>c>>d;
    int x=c-a;
    int y=d-b;
    cout<<c-y<<" "<<d+x<<" "<<a-y<<" "<<b+x<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include<vector>
#include<cstdlib>
#include<stdio.h>
#include<cmath>
#include<limits>
#include<iomanip>

using namespace std;
 
template <class T> using V = vector<T>;
 
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;
}
 
const long long INF = 1LL << 60;
 
using ll = long long;
using db = long double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
using graph = V<V<int>>;
using pq = priority_queue<ll>;


 
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>=(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define pb(a) push_back(a);
  
 

ll sum(ll n) {
ll m=0;
  while(n){
    m+=n%10;
    n/=10;
  }
  return m;
}
 
 
const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void Comuse() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
 
#define comuse Comuse()
 
ll combi(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}


vll div(ll n){
  vll ret;
  for(ll i=1;i*i<=n;i++){
    if(n%i==0){
      ret.push_back(i);
      if(i*i!=n){
        ret.push_back(n/i);
      }
    }
  }
  SORT(ret);
  return (ret);
}

void Solve();

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(20)<<fixed;
  Solve();
}


/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 

void Solve(){
  st s;
    cin>>s;
  ll n=s.sz;
  vll A(0);
  ll count=1;
  FOR(i,0,n-1){
    if(s[i]!=s[i+1]){
      A.push_back(count);
      count=1;
    }

    else{
      count++;
    }
  }
  A.push_back(count);
  A.push_back(0);
  ll m=A.sz;
  ll ans=0;
  ll now=1;

  FOR(i,0,m){
    ans+=(A[i]-1)*A[i]/2;

    if(A[i]>=A[i+1]&&s[now-1]=='<'){
      ans+=A[i];
    }

    else if(A[i]<A[i+1]&&s[now-1]=='<'){
      ans+=A[i+1];
    }

    now+=A[i];
  }
  if(s[0]=='>'){
    ans+=A[0];
  }
  cout<<ans<<endl;
}
// < > > > < < > < < < < < > > > <
//0,3,2,1,0,1,2,0,1,2,3,4,5,2,1,0,1

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

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

template<class T> using v = std::vector<T>;
template<class T> using vv = v<v<T>>;

const int mod = 1000000007;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
//const int mod = 998244353;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


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

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};

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

    string n; cin >> n;
    set<int> a = {2,4,5,7,9};
    set<int> b = {0,1,6,8};
    if (a.count(n[n.size()-1] - '0')) {
        cout << "hon" << endl;
    } else if (b.count(n[n.size() - 1] - '0')) {
        cout << "pon" << endl;
    } else {
        cout << "bon" << endl;
    }

    return 0;
}


Measured memory_bytes: 3620
import java.io.*;
import java.nio.CharBuffer;
import java.util.NoSuchElementException;

public class Main {

    public static void main(String[] args) {
        SimpleScanner scanner = new SimpleScanner(System.in);
        PrintWriter writer = new PrintWriter(System.out);

        int n = scanner.nextInt();
        int k = scanner.nextInt();
        if (k == 1) {
            writer.println(1);
            writer.close();
            return;
        }
        int[] f = new int[k];
        for (int i = k - 1; i > 0; --i) {
            if (i * 2 >= k)
                f[i] = 1;
            else
                f[i] = f[i * 2] + 1;
        }
        long b = 1 << f[1];
        for (int i = k - 1; i > 0; --i) {
            f[i] = f[1] - f[i];
        }
        long a = 0;
        for (int i = 1; i <= n; ++i) {
            if (i < k) {
                a += 1 << f[i];
            } else {
                a += b;
            }
        }
        writer.println((double) a / (b * n));
        writer.close();
    }

    private static class SimpleScanner {

        private static final int BUFFER_SIZE = 10240;

        private Readable in;
        private CharBuffer buffer;
        private boolean eof;

        SimpleScanner(InputStream in) {
            this.in = new BufferedReader(new InputStreamReader(in));
            buffer = CharBuffer.allocate(BUFFER_SIZE);
            buffer.limit(0);
            eof = false;
        }


        private char read() {
            if (!buffer.hasRemaining()) {
                buffer.clear();
                int n;
                try {
                    n = in.read(buffer);
                } catch (IOException e) {
                    n = -1;
                }
                if (n <= 0) {
                    eof = true;
                    return '\0';
                }
                buffer.flip();
            }
            return buffer.get();
        }

        void checkEof() {
            if (eof)
                throw new NoSuchElementException();
        }

        char nextChar() {
            checkEof();
            char b = read();
            checkEof();
            return b;
        }

        String next() {
            char b;
            do {
                b = read();
                checkEof();
            } while (Character.isWhitespace(b));
            StringBuilder sb = new StringBuilder();
            do {
                sb.append(b);
                b = read();
            } while (!eof && !Character.isWhitespace(b));
            return sb.toString();
        }

        int nextInt() {
            return Integer.valueOf(next());
        }

        long nextLong() {
            return Long.valueOf(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}

Measured memory_bytes: 21972
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<map>
#include<cstdint>
#include<unordered_map>
#include<boost/multiprecision/cpp_int.hpp>


#define rep(i, n) for(int i = 0; i < ( int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define F first
#define S second

namespace mp = boost::multiprecision;

using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

bool dfs(vector<vector<char>>&cam, int s, int t) {
	int size = cam.size();
	int size1 = cam[s].size();
	int count = 0;
	for (int i = max(0, s - 1); 
		i< min(s + 2, size); i++) {
		if (cam[i][t] == '#') {
			count++;
		}
	}
	for (int i = max(t - 1, 0);
		i< min(t + 2,size); i++) {
		if (cam[s][i] == '#'&&i!=t) {
			count++;
		}
	}
	if (count >= 2) {
		return true;
	}
	else {
		return false;
	}
}
int main() {
	string s;
	cin >> s;
	int k;
	cin >> k;
	vector<string>str(s.size()*k);
	FOR(i,1, k+1) {
		rep(j, s.size()+1-i) {
			str.push_back(s.substr(j, i));
		}
	}
	sort(all(str));
	string tmp = "";
	
	int count = 0;

	rep(i, str.size()) {
		if (tmp < str[i]) {
			count++;
			tmp = str[i];
		}
		if (count == k) {
			break;
		}
	}
	cout << tmp << endl;
}

Measured memory_bytes: 1852
#include <iostream>
#include <vector>
#include <math.h>
#include <string>
#include <algorithm>
#include <functional>

using namespace std;

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

int main()
{
  string s;
  int pd = 0;
  cin >> s;

  if (s.length() == 1)
  {
    if (s[0] == '?')
    {
      s = "D";
    }
  }
  else
  {
    if (s[0] == '?')
    {
      if (s[1] == 'P')
      {
        s[0] = 'D';
      }
      else
      {
        s[0] = 'P';
      }
    }

    for (int i = 1; i < s.length() - 1; i++)
    {
      if (s[i] == '?')
      {
        if (s[i - 1] == 'P')
        {
          s[i] = 'D';
        }
        else if (s[i + 1] == 'D' || s[i + 1] == '?')
        {
          s[i] = 'P';
        }
        else
        {
          s[i] = 'D';
        }
      }
    }

    if (s[s.length() - 1] == '?')
    {
      s[s.length() - 1] = 'D';
    }
  }

  cout << s;

  return 0;
}

Measured memory_bytes: 3288
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_D main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX/2)
const int MGN = 10;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions

#endif 

ll f(ll x) {
    ll res = 0;
    
    for (ll i = x; i > x - ((x + 1) % 4); i--) {
        res ^= i;
    }

    return res;
}

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

    ll A, B; cin >> A >> B;

    ll ans = f(B) ^ f(A - 1);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>
#include<cstring>
#include<bitset>
#include<cassert>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,b) for (int (i)=a;(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long int;

const int inf = 1001001000;
const long long int Inf = 1001001001001001000;



void print(vector<vector<int>> a){
	for (int i = 0; i < a.size(); i++)
	{
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(vector<long long int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}

//深さ優先探索のテンプレ.デフォルトでは参照渡ししたsetに探索済みの頂点が格納される.
//graphは隣接リスト.vは探索開始地点.seenは空のセット.
void dfs(vector<vector<int>> &graph, int b, int v, map<pair<int, int>, ll> &w, vector<int> &ans){
	if ((ans[b] + w[pair<int, int>(min(v, b), max(v, b))]) % 2 == 0)
	{
		// cout << "even : " << b << " " << v << " " << w[pair<int, int>(min(v, b), max(v, b))] << endl;
		ans[v] = 0;
	}
	else
	{
		// cout << "odd : " << b << " " << v << " " << w[pair<int, int>(min(v, b), max(v, b))] << endl;
		ans[v] = 1;
	}
	for (int i = 0; i < graph[v].size(); i++)
	{
		int nxt = graph[v][i];
		if (ans[nxt] != -1) continue;
		dfs(graph, v, nxt, w, ans);
	}
}

int main(){
	int n;
	cin >> n;
	vector<vector<int>> graph(n);
	map<pair<int, int>, ll> w;
	rep(i,n-1){
		int a, b;
		ll c;
		cin >> a >> b >> c;
		a--;
		b--;
		graph[a].push_back(b);
		graph[b].push_back(a);
		w[pair<int, int>(min(a, b), max(a, b))] = c;
	}
	w[pair<int, int>(0, 0)] = 0;
	vector<int> ans(n, -1);
	ans[0] = 0;
	dfs(graph, 0, 0, w, ans);
	rep(i, n) cout << ans[i] << endl;
}

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

int main(){
    int line[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;

    cin >> k;
    cout << line[k - 1] << endl; 
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))

using P = pair<int, int>;

int n;
vs32 s[200];

int bfs(int u, vs32& color)
{
    int ret = 0;
    queue<P> q;
    q.push(P{u, 0});
    color[u] = 0;
    while (!q.empty())
    {
        int m = q.size();
        ++ret;
        rep (i, m)
        {
            P p = q.front(); q.pop();
            int u = p.first;
            int c = p.second;
            // cout << cnt++ << "u, c = " << u << ", " << c << "\n";
            // color[u] = c;
            for (auto v : s[u])
            {
                if (color[v] == -1)
                {
                    q.push(P{v, c ^ 1});
                    color[v] = c ^ 1;
                }
                else if (color[v] == c)
                {
                    ret = -1;
                    break;
                }
            }
            if (ret == -1) break;
        }
        if (ret == -1) break;
    }
    return ret;
}

int solve(int u)
{
    vs32 color(n, -1);
    int ret = bfs(u, color);
    return ret;
}

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

    cin >> n;

    rep (i, n)
    {
        string str;
        cin >> str;
        rep (j, n)
        {
            if (str[j] == '1') s[i].push_back(j);
        }
    }

    int ans = -1;
    rep (i, n)
    {
        ans = max(ans, solve(i));
    }

    cout << ans << "\n";

    return 0;
}



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

int main () {
	
	int n=0, i=0, val=0, c=0, tam=0;
	queue <int> q;

	scanf("%d", &n);

	q.push(1);
	for (i=0; i<n; i++) {
		scanf("%d", &val);

		tam = q.size();

		while (tam--) {
			int x=q.front();
			q.pop();

			q.push(x*val);
			q.push(x*(val-1));
			q.push(x*(val+1));
		}
	}

	while (!q.empty()) {
		if (q.front()%2 == 0) c++;
		q.pop();
	}

	printf("%d\n", 	c);


	return 0;
}	

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

int main() {
#define rrep(i, n) for(double i = 1; i <= (double)(n); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
  double N,K;
  cin>>N>>K;
  double a,b,c,d;
  c=0.00000000;
  rrep(i,N){
    a=i/K;
    b=1.00000000000;
    while(a<1){
      a=a*2;
      b=b/2;
      //cout<<b<<setprecision(12);
    }
    c+=b;
  }
  d=c/N;
  //cout<<(double)7/48<<setprecision(12)<<endl;
  cout << fixed << setprecision(16);
  cout<<d;
}

Measured memory_bytes: 256
r, c = map(int,input().split())
rc = []
for i in range(r):
    tmp = list(map(int,input().split()[:c]))
    tmp.append(sum(tmp))
    rc.append(tmp)

tmp = []
for i in range(c):
    sum_h = 0
    for j in range(r):
        sum_h += rc[j][i]
    tmp.append(sum_h)
tmp.append(sum(tmp))
rc.append(tmp)


for i in rc:
    print(*i)


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


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

    vector<int> L(n);
    rep(i,n) cin >> L[i];

    int count = 0;
    int sum = 0;

    while(x >= sum){
        if(count < n) {
            sum += L[count];
            count++;
        }else{
            count++;
            break;
        }
    }
    print(count);

}

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

void reverse(int* a, int* b) {
	int t;
	t = *a;
	*a = *b;
	*b = t;
}

int bubblesort(int a[], int n) {
	int v = 0;
	int j = 20000;

	while (j >= 0) {
		for (int i = n - 1; i >= 1; i--) {
			if (a[i] < a[i - 1]) {
				reverse(&a[i], &a[i - 1]);
				v++;
			}
		}
		j--;
	}

	return v;
}

int main() {
	int n;
	int a[100];
	int vv;

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

	vv = bubblesort(a, n);

	for (int i = 0; i < n; i++) {
		if (i > 0) {
			cout << " ";
		}
		cout << a[i];
	}
	cout << endl;
	cout << vv;
	cout<<endl;

	return 0;
}


Measured memory_bytes: 3148
#include<stdio.h>
#include<math.h>
int main()
{
	int a,b,i,h=1,x,sum,c=0;
	scanf("%d %d",&a,&b);
	x=b;
	while(x!=0)
	{
         x=x/10;
         c=c+1;
	}
	for(i=1;i<=c;i++)
	{
         h=h*10;
	}
	sum=a*h+b;
	int w=sqrt(sum);
    if(w*w==sum)
	{
		printf("Yes");
	}
	if(w*w!=sum)
	{
		printf("No");
	}
 return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
typedef long long ll;
string S;
int N, M;
int power[100005];
ll dp[100005][13];
ll mod = 1000000007;
int main() {
    cin >> S;
    N = S.length();
    M = 0;
    int num = 0, e = 1;
    for (int i=N-1; i>=0; i--){
        if (S[i] == '?'){
            power[M] = e;
            M++;
        }
        e = (e*10)%13;
    }
    for (int i=0; i<N; i++){
        num = (num*10)%13;
        if (S[i] != '?'){
            num = (num+S[i]-'0')%13;
        }
    }
    dp[0][num] = 1;
    for (int i=1; i<=M; i++){
        for (int j=0; j<13; j++){
            for (int k=0; k<=9; k++){
                dp[i][(j+k*power[i-1])%13] = (dp[i][(j+k*power[i-1])%13]+dp[i-1][j])%mod;
            }
        }
    }
    cout << dp[M][5] << endl;
    return 0;
}

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

#define REP(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define REPS(i, n) for (int i = (int)(1); i <= (int)(n); ++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 IREP(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define IREPS(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RVISORT(v) sort(v.begin(), v.end(), greater<int>());
#define ALL(v) v.begin(), v.end()
#define MP(n, m) make_pair(n, m);
#define COUT(d) cout<<std::setprecision(10)<<d<<endl;
#define CIN(n) getline(cin,n);

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using ll = long long;
using ul = unsigned long;

typedef long long ll;

template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }

const int mod=1e9+7;

struct mint {
  ll x;
  mint(ll x=0):x(x%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
};

mint c[4005][4005];
void init() {
  c[0][0] = 1;
  for (int i = 0; i <= 4000; i++) {
    for (int j = 0; j <= i; j++) {
      c[i+1][j] += c[i][j];
      c[i+1][j+1] += c[i][j];
    }
  }
}
mint comb(int n, int k) {
  return c[n][k];
}

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }

    return true;
}

map<ll, ll> primeFact(ll n) {
  map<ll, ll> res;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      res[i]++;
      n /= i;
    }
  }
  if (n != 1) res[n]++;
  return res;
}

void printv(VI& v){
  REP(i,v.size()) cout << v[i] << " ";
  cout << endl;
}

int vtotal(VI& v){
  int total=0;
  REP(i,v.size()) total+=v[i];
  return total;
}

int main()
{
  cin.tie( 0 );
  ios::sync_with_stdio( false );
	
  //init(); // mint初期化
  char b;
  cin>>b;
  char ans='A';
  if(b=='A')ans='T';
  if(b=='C')ans='G';
  if(b=='G')ans='C';
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 125568
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

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

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}

void solve(long long H, long long W, long long N, std::vector<long long> a)
{
    ll ans[H][W];
    ll index = 0;
    for (int i = 0; i < H; i++)
    {

        if (i % 2)
        {
            for (int j = 0; j < W; j++)
            {
                ans[i][j] = index + 1;
                a[index]--;
                if (a[index] == 0)
                {
                    index++;
                }
            }
        }
        else
        {
            for (int j = W - 1; j >= 0; j--)
            {
                ans[i][j] = index + 1;
                a[index]--;
                if (a[index] == 0)
                {
                    index++;
                }
            }
        }
    }

    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            cout << ans[i][j] << " ";
        }
        
        cout << endl;
    }
    
}

int main()
{
    long long H;
    scanf("%lld", &H);
    long long W;
    scanf("%lld", &W);
    long long N;
    scanf("%lld", &N);
    std::vector<long long> a(N);
    for (int i = 0; i < N; i++)
    {
        scanf("%lld", &a[i]);
    }
    solve(H, W, N, std::move(a));
    return 0;
}


Measured memory_bytes: 384
import itertools
import math
n = int(input())
p = tuple(map(int,input().split()))
q = tuple(map(int,input().split()))
lista = [None]*n
for i in range(n):
    lista[i] = i+1
listb =[]
for i in itertools.permutations(lista):
    listb.append(i)
pp = listb.index(p)+1
qq = listb.index(q)+1
print(abs(pp-qq))


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

int main(){
    int H, W;
    
    while(1){
        cin >> H >> W;
        if(H == 0 && W == 0) break;
        
        for(int i = 0; i < H; i++){
            for(int j = 0; j < W; j++){
                cout << "#";
            }
            cout << "\n";
        }
        cout << endl;
    }
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> X(N);
  for (int i = 0; i < N; i++) cin >> X.at(i);
  int ans = 1e9;
  for (int i = 1; i <= 100; i++) {
    int sum = 0;
    for (auto x : X) sum += (i - x) * (i - x);
    ans = min(ans, sum);
  }
  cout << ans << "\n";
}

Measured memory_bytes: 3548
class UnionFind:
    def __init__(self, n):
        self.parent = [-1] * n

    def find(self, x):
        if self.parent[x] < 0:
            return x
        else:
            self.parent[x] = self.find(self.parent[x])
            return self.parent[x]

    # xとyの属する集合の併合
    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        # sizeの大きいほうがx
        if self.parent[x] > self.parent[y]:
            x, y = y, x
        self.parent[x] += self.parent[y]
        self.parent[y] = x

    # xとyが同じ集合に属するかの判定
    def same(self, x, y):
        return self.find(x) == self.find(y)

    # xが属する集合の個数
    def size(self, x):
        return -self.parent[self.find(x)]


n, m, k = map(int, input().split())
num_friends = [0 for _ in range(n + 1)]
blocks = [[] for _ in range(n + 1)]
uf = UnionFind(n + 1)

for i in range(m):
    a, b = map(int, input().split())
    num_friends[a] += 1
    num_friends[b] += 1
    uf.unite(a, b)

for i in range(k):
    c, d = map(int, input().split())
    blocks[c].append(d)
    blocks[d].append(c)

out = ''
for i in range(1, n + 1):
    ans = uf.size(i) - num_friends[i] - 1
    for block in blocks[i]:
        if uf.same(i, block):
            ans -= 1
    out += str(ans) + ' '
print(out.strip())


Measured memory_bytes: 27924
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//(a+b-1)/b

signed main(){
	ll n; cin>>n;
	map<ll,ll> mp;
	rep(i,0,n){
		ll a; cin>>a;
		mp[a]++;
	}
	vl vec(0);
	for(auto c:mp){
		if(c.second>=2){
			rep(i,0,c.second/2){
				vec.push_back(c.first);
			}
		}
	}
	if(vec.size()<2)cout<<0<<endl;
	else{
		sort(all(vec));
		reverse(all(vec));
		cout<<vec[0]*vec[1]<<endl;
	}
	return 0;
}

Measured memory_bytes: 9744
#include <bits/stdc++.h>
#define MOD 1000000007
typedef long long int ll;
using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<double> a(n);
    for(int i=0;i<n;i++) cin >> a[i];
    double ans = 0.0;
    for(int j=0;j<n;j++){
        ans += 1/a[j];
    }
    cout << fixed;
    cout << 1/ans << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
Hs = [int(i) for i in input().split()]

ans = []
cnt = 0
for i in range(1, N):
    if Hs[i-1] >= Hs[i]:
        cnt += 1
    else:
        ans.append(cnt)
        cnt = 0
if cnt != 0:
    ans.append(cnt)
if N == 1:
    ans = [0]
print(max(ans))


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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod =(1e9)+7;
using P = pair<ll,ll>;

int main(){
    ll x;cin >>x;
    vector<ll>prime;
    ll N=1001001;
    vector<bool>isp(N,true);
    vector<ll>p;
    for (ll i =2; i < N; ++i) {
        if(isp[i]){
            p.push_back(i);
        }
        for(ll j=2*i;j<N;j+=i)isp[j]=false;
    }
    for(auto pr:p){
        if(pr >= x){
            cout <<pr<<endl;
            return 0;
        }
    }
    return 0;
}



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

inline ll int maxm (ll int a,ll int b)
{    if(a>b) return a;
     else return b;
}
inline ll int minm (ll int a,ll int b)
{    if(a>b) return b;
     else return a;
}
int main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);cout.tie(NULL);

   int n,k;cin>>n>>k;int a[n];
   for(int i=0;i<n;i++)cin>>a[i];
   vector<int> dp(n,1000000001);
   dp[0]=0;
   for(int i=1;i<=k&&i<n;i++)dp[i]=abs(a[i]-a[0]);

   for(int i=k+1;i<n;i++)
   {  for(int j=1;j<=k&&(i-j)>=0;j++)
       {dp[i]=min(dp[i-j]+abs(a[i]-a[i-j]),dp[i]);}
   }
   cout<<dp[n-1];

 }


Measured memory_bytes: 4044
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <climits>

using namespace std;

int main() {
	int n, k; cin >> n >> k;
	vector<int> h(n);
	for (auto &x : h) { cin >> x; }
	vector<int> DP(n, INT_MAX);
	DP[0] = 0;

	for (int i = 1; i < n; i++)
		for (int j = i - 1; j >= (max(0, i - k)); j--)
			DP[i] = min(DP[i], DP[j] + abs(h[i] - h[j]));

	cout << DP[n - 1] << endl;
}

Measured memory_bytes: 1024
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.stream.IntStream;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.util.OptionalInt;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyScanner in = new MyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            int N = in.nextInt();
            int M = in.nextInt();
            int X = in.nextInt();
            int Y = in.nextInt();
            int[] x = in.nextIntArray(N);
            int[] y = in.nextIntArray(M);

            int maxx = Math.max(X, IntStream.of(x).max().getAsInt());
            int maxy = Math.min(Y, IntStream.of(y).min().getAsInt());
            out.println(maxx < maxy ? "No War" : "War");
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = nextInt();
            }
            return a;
        }

    }
}



Measured memory_bytes: 28756
#include <iostream>
#include <string>
using namespace std;
int gcd(int a, int b)
{
	if (a<0){
		a=-a;
	}
	if (b<0){
		b=-b;
	}
    return b == 0 ? a : gcd(b, a % b);
}
int gcd(int a, int b,int c)
{
	int ab=gcd(a,b);
	return gcd(ab,c);
}

int main(int argc, char* argv[])
{
	int K;
	cin>>K;
	int a,b,c;
	int ans=0;
	for (a=1;a<=K;a++){
		for (b=1;b<=K;b++){
			for (c=1;c<=K;c++){
				ans+=gcd(a,b,c);
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3632
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath> // sqrt
#define _GLIBCXX_DEBUG // check []
#define DIVISOR 1000000007

using namespace std;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<int64_t, int64_t> pII;

template<typename T>
void cins(vector<T>& arr) { for(T& e: arr) cin >> e; }

#ifdef DEBUG
#define debug(fmt, ...) \
    printf("[debug: %s] " fmt, __func__, __VA_ARGS__)
#define ps(arr) \
    debug("size %ld: ", arr.size()); \
    for(auto e: arr) cout << e << " "; \
    cout << endl;
#else
#define debug(fmt, ...)
#define ps(arr)
#endif


#define _x first
#define _y second

double norm(pdd p) {
    return sqrt((p._x * p._x) + (p._y * p._y));
}

class Line {
public:
    pdd base;
    pdd unit;
    Line(pdd base, pdd other) : base(base) {
        pdd diff = make_pair(
            other._x - base._x,
            other._y - base._y
        );
        double len = norm(diff);
        unit = make_pair(
            diff._x / len,
            diff._y / len
        );
    }
};

double inner_prod(pdd p1, pdd p2) {
    return (p1._x * p2._x) + (p1._y * p2._y);
}

int main(void) {
    pdd p1, p2;
    cin >> p1._x >> p1._y;
    cin >> p2._x >> p2._y;

    Line lin(p1, p2);
    int qs;
    cin >> qs;
    for(int i = 0; i < qs; i++) {
        pdd p;
        cin >> p._x >> p._y;
        pdd inc = make_pair(
            p._x - lin.base._x,
            p._y - lin.base._y
        );
        double dist = inner_prod(inc, lin.unit);
        pdd vec = make_pair(
            lin.base._x + dist * lin.unit._x - p._x,
            lin.base._y + dist * lin.unit._y - p._y
        );
        pdd res = make_pair(
            p._x + vec._x * 2,
            p._y + vec._y * 2
        );
        printf("%.10lf %.10lf\n", res._x, res._y);
    }
    return 0;
}


Measured memory_bytes: 3216
#include<stdio.h>
#include<iostream>
#include"string"
#include"math.h"
#include <algorithm>
#include<vector>
using namespace std;
bool m;
void m_sort(int a[], int tmp[], int left, int right);
void m_sort(int a[], int tmp[], int left, int right);
void sort(int a[], int total) {
	int tmp;
	for (int i = 0; i < total; i++) {
		for (int j = i + 1; j < total; j++) {
			if (a[i] < a[j]) {
				tmp = a[i];
				a[i] = a[j];
				a[j] = tmp;
			}
		}
	}
 
}
 
void mergeSort(int a[], int tmp[], int size)
{
	m_sort(a, tmp, 0, size - 1);
}
void merge(int a[], int tmp[], int left, int mid, int right)
{
	int i, left_end, num_elements, tmp_pos;
 
	left_end = mid - 1;
	tmp_pos = left;
	num_elements = right - left + 1; // 要素 
 
	while ((left <= left_end) && (mid <= right))
	{
		if (a[left] <= a[mid])
		{
			tmp[tmp_pos] = a[left];
			tmp_pos = tmp_pos + 1;
			left = left + 1;
		}
		else
		{
			tmp[tmp_pos] = a[mid];
			tmp_pos = tmp_pos + 1;
			mid = mid + 1;
		}
	}
 
 
	while (left <= left_end)
	{
		tmp[tmp_pos] = a[left];
		left = left + 1;
		tmp_pos = tmp_pos + 1;
	}
 
	while (mid <= right)
	{
		tmp[tmp_pos] = a[mid];
		mid = mid + 1;
		tmp_pos = tmp_pos + 1;
	}
 
 
	for (i = 0; i <= num_elements; i++)
	{
		a[right] = tmp[right];
		right = right - 1;
	}
}
void m_sort(int a[], int tmp[], int left, int right)
{
	int mid;
 
	if (right > left)
	{
		mid = (right + left) / 2; 
		m_sort(a, tmp, left, mid);
		m_sort(a, tmp, mid + 1, right);
 
		merge(a, tmp, left, mid + 1, right);
	}
}


int N,ka,kc;
int ans,C[501],S[501],F[501],ti[501],blank;
int main(){
	cin>>N;
	ti[N]=0;
	for(int i=1;i<N;i++){
		cin>>C[i]>>S[i]>>F[i];
		ti[i]=0;
	}
	for(int k=1;k<N;k++){
		ti[k]=S[k]+C[k];
		for(int i=k+1;i<N;i++){
			if(ti[k]>S[i]){
				blank=S[i];
				while(blank<ti[k]){
					blank+=F[i];
				}
				ti[k]=blank;
				ti[k]+=C[i];
			}else{
				ti[k]=S[i];
				ti[k]+=C[i];
			}
		}
	}
	for(int i=1;i<=N;i++){
	cout<<ti[i]<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <cassert>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define srep(i,n,m) for(int i=n;i<m;i++)
#define elif else if
#define INF 1000000007
#define pi 3.141592653589793
using namespace std;
int sdkys(int a,int b){
    if(b==0) return a;
    return sdkys(b,a%b);
}
int sskbs(int a,int b){
    return a*b/sdkys(a,b);
}
int sosu(int a){
    if(a==2){
        return 1;
    }
    for(int i=2;i<sqrt(a)+1;i++){
        if(a%i==0){
            return 0;
        }
    }
    return 1;
}
vector<int> v;
int n,m,cnt=0,ans=0,aa[220000];
pair<int,int> pp[220000];
string s,ss[220000];
queue<int> que;
signed main(){
    cin>>n;
    rep(i,n){
        cin>>aa[i];
        cnt+=aa[i];
        cnt%=INF;
    }
    rep(i,n){
        if(cnt<aa[i]){
            cnt+=INF-aa[i];
            ans+=aa[i]*cnt;
        }else{
            cnt-=aa[i];
            ans+=aa[i]*cnt;
        }
        ans%=INF;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 12036
def four_card?(a)
  mode_value = a.max_by { |x| a.count(x) }
  a.count(mode_value) == 4
end

def full_house?(a)
  !four_card?(a) && a.uniq.size == 2
end

def straight?(a)
  a = a.uniq.sort
  return false if a.size < 5
  a.last - a.first == 4 || a[0] == 1 && a[1] == 10 && a[2] == 11 && a[3] == 12 && a[4] == 13
end

def three_card?(a)
  mode_value = a.max_by { |x| a.count(x) }
  a.count(mode_value) == 3
end

def two_pair?(a)
  !three_card?(a) && a.uniq.size == 3
end

def one_pair?(a)
  a.uniq.size == 4
end

while line = gets
  cards = line.chomp.split(',').map(&:to_i)
  if four_card?(cards)
    puts 'four card'
  elsif full_house?(cards)
    puts 'full house'
  elsif straight?(cards)
    puts 'straight'
  elsif three_card?(cards)
    puts 'three card'
  elsif two_pair?(cards)
    puts 'two pair'
  elsif one_pair?(cards)
    puts 'one pair'
  else
    puts 'null'
  end
end

Measured memory_bytes: 8644
#include <bits/stdc++.h>
#define F first
#define S second
#define T second.first
#define C second.second
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int,pair<int,int>> piii;

const int N= 1e5+5, L = 14, OO = 0x3f3f3f3f;
const ll M=10 ;
const double ESP = 1e-8;

int n, k;
piii A[N];
int dp[N][5];
int solve(int idx, int prev){
    if(idx == n)
        return 0;

    int& ret = dp[idx][prev];
    if(~ret)
        return ret;

    ret = max(ret, (prev != 1)? solve(idx+1, 1)+A[idx].F : -1);
    ret = max(ret, (prev != 2)? solve(idx+1, 2)+A[idx].T : -1);
    return ret = max(ret, (prev != 3)? solve(idx+1, 3)+A[idx].C : -1);

}

int main(){
    FIO
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    cin>>n;
    for(int i=0; i<n; i++)cin>>A[i].F>>A[i].T>>A[i].C;
    memset(dp, -1, sizeof dp);
    cout<<solve(0,4);
}


Measured memory_bytes: 11136