akhauriyash/Code-Regression huggingface dataset:
/*レーベンシュタイン距離（diffコマンド）*/
/*
２つの文字列がどの程度異なるか示す距離。編集距離ともいう。

*/
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i < (n);++i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;

int main(){
    /*
        S = x：初期の水の体積
        ある一面から見た時の水の体積 x/a;
        MAX_S = b*a*a:水筒の体積
    */
   double a,b,x;
   cin >> a >> b >> x;
   double s = x/a;
   double rad;
   if(s >= a*b/2) {
       double h = (a*b-s) * 2 /a;
       rad = atan2(h,a);
   }else{
       double w = s*2/b;
       rad = atan2(b,w);
       
   }
   double PI = acos(-1);//PI/2
   double deg = rad/(2*PI) * 360;
    printf("%.12lf\n",deg);
}

Measured memory_bytes: 384
import java.io.*;
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

//   String nyuA=sc.nextLine();
  // String nyuB=sc.nextLine();
 
      String[] S=sc.nextLine().split("");

//int n=Integer.parseInt(nyu);

//int N=Integer.parseInt(nyuA);
//int S=Integer.parseInt(nyuB);


//long H=Long.parseLong(t[0]);
//long W=Long.parseLong(t[1]);
//long C=Long.parseLong(t[2]);

//boolean[][] data=new boolean[H][W];

for(int i=0;i<S.length;i++){
if(S[i].equals("A"))break;
S[i]="0";
}
for(int i=S.length-1;i>0;i--){
if(S[i].equals("Z"))break;
S[i]="0";
}
int count=0;
for(int i=0;i<S.length;i++){
if(S[i].equals("0")){
}else{
//System.out.print(S[i]);
count++;
}
}
System.out.println(count);
	}
}

Measured memory_bytes: 53240
s = input()

l = len(s)
f=0
for i in range(l):
    if s[i]!=s[l-i-1]:
        f=1
n = l//2
for i in range(n):
    if s[i]!=s[n-i-1]:
        f=1
m = (l+3)//2
for i in range(m,l):
    if s[i]!=s[l-i-1]:
        f=1
if f==0:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3188
#include<iostream>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<queue>
#include<set>
#include<map>
using namespace std;
using ulong = unsigned long;
using ll = long long;
const int M = 1e9 + 7;
#pragma unused(M)

int h, w, cnt;
vector<vector<char>> as;

void solve(int y, int x, int cnt){
    if(y == h && x == w){
        cout << (cnt == ::cnt ? "Possible" : "Impossible") << endl;
        exit(0);
    }
    if(y == as.size() || x == as[0].size() || as[y][x] == '.'){ return; }
    solve(y + 1, x, cnt + 1);
    solve(y, x + 1, cnt + 1);
}

int main(){
	cin >> h >> w;
    vector<vector<char>> as(h, vector<char>(w));
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin >> as[i][j];
            if(as[i][j] == '#'){
                cnt++;
            }
        }
    }
    as.swap(::as);
    h--; w--;
    solve(0, 0, 1);
    cout << "Impossible" << endl;
	return 0;
}



Measured memory_bytes: 888
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
#include <unordered_map>
#include <fstream>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef pair<int,int> pii;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {1,-1,0,0,1,-1,1,-1};
ll dx[8] = {0,0,1,-1,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T> inline void print(T &a){
    rep(i,a.size()) cout << a[i] << " ";
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
const int mod = 1e9 + 7;
//const int mod = 998244353;

ll R,C;

int query(ll yl, ll xl, ll yr, ll xr){
	if(yl != 0 && yl != R && xl != 0 && xl != C) return 0;
	if(yr != 0 && yr != R && xr != 0 && xr != C) return 0;
	return 1;
}

vector<pii> y00,yr,x00,xc;

int main(){
	ll n; cin >> R >> C >> n;
	rep(i,n){
		int a,b,c,d; cin >> a >> b >> c >> d;
		int e = query(a,b,c,d);
		if(e == 0) continue;
		if(a == 0){
			if(b == 0) x00.emplace_back(0,i);
			else if(b == C) xc.emplace_back(0,i);
			else y00.emplace_back(b,i);
		}else if(a == R){
			if(b == 0) x00.emplace_back(R,i);
			else if(b == C) xc.emplace_back(R,i);
			else yr.emplace_back(b,i);
		}else{
			if(b == 0) x00.emplace_back(a,i);
			else xc.emplace_back(a,i);
		}
		if(c == 0){
			if(d == 0) x00.emplace_back(0,i);
			else if(d == C) xc.emplace_back(0,i);
			else y00.emplace_back(d,i);
		}else if(c == R){
			if(d == 0) x00.emplace_back(R,i);
			else if(d == C) xc.emplace_back(R,i);
			else yr.emplace_back(d,i);
		}else{
			if(d == 0) x00.emplace_back(c,i);
			else xc.emplace_back(c,i);
		}
	}
	sort(all(y00)),sort(rall(yr)),sort(rall(x00)),sort(all(xc));
	vector<int> st;
	for(auto v : y00){
		if(st.empty() || st.back() != v.second) st.push_back(v.second);
		else st.pop_back();
	}
	for(auto v : xc){
		if(st.empty() || st.back() != v.second) st.push_back(v.second);
		else st.pop_back();
	}
	for(auto v : yr){
		if(st.empty() || st.back() != v.second) st.push_back(v.second);
		else st.pop_back();
	}
	for(auto v : x00){
		if(st.empty() || st.back() != v.second) st.push_back(v.second);
		else st.pop_back();
	}
	if(st.empty()) puts("YES");
	else puts("NO");
}

Measured memory_bytes: 5692
#include<iostream>
#include<vector>
#include <cassert>
#include<algorithm>
#include <tuple>
#include <utility>
#include<string>
#include <cmath>
#include <functional>
#define ll long long
using namespace std;

int main(){
    ll N;
    ll tmp;
    int keta=0;
    ll cn;
    double B;
    cin >> N; 
    tmp = N;
    // 桁の判定
    while(tmp > 0){
        keta++;
        cn = tmp;
        tmp -= pow(26,keta);
    }
    cn--;
    vector<char>v(keta);
    // cout << cn<< endl;
    for(int i=0; i<keta;i++){
        // cout << cn % 26 << endl;
        v[keta-i-1] = char('a'+ (cn % 26));
        // if(cn % 26 == 0)cn--;
        cn /= 26;
    }
    for(int i=0; i<keta;i++){
        cout << v[i];
    }
    cout << endl;
}


Measured memory_bytes: 4044
#include <algorithm>
#include <iostream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using std::cin;
using std::cerr;
using std::cout;
using std::endl;
using std::make_pair;
using std::pair;
using std::stack;
using std::string;
using std::unordered_set;
using std::vector;

int main(int argc, char* argv[]) {
  int n;
  cin >> n;
  vector<string> s(n);
  for (int i = 0; i < n; ++i) {
    cin >> s[i];
  }
  sort(s.begin(), s.end());
  int max = 1;
  int count = 1;
  string prev = "";
  for (const auto str : s) {
    if (prev != str) {
      if (max < count) {
        max = count;
      }
      count = 1;
      prev = str;
    } else {
      ++count;
    }
  }
  if (max < count) {
    max = count;
  }
  count = 1;
  prev = "";
  for (const auto str : s) {
    if (prev != str) {
      if (count == max && !prev.empty()) {
        cout << prev << endl;
      }
      count = 1;
      prev = str;
    } else {
      ++count;
    }
  }
  if (count == max) {
    cout << prev << endl;
  }

  return 0;
}


Measured memory_bytes: 14208
import Control.Applicative

type Dice    = [(Int, Int)]
type Command = Char

fromList :: [Int] -> Dice
fromList [a, b, c, d, e, f] = [(a, f), (b, e), (c, d)]
fromList _ = error "Invalid dice."

rev :: (a,a) -> (a,a)
rev (x,y) = (y,x)

roll :: Dice -> Command -> Dice
roll [a, b, c] com =
    case com of
        'N' -> [b, rev a, c]
        'E' -> [rev c, b, a]
        'S' -> [rev b, a, c]
        'W' -> [c, b, rev a]
        _   -> error "Invalid command."
roll _ _ = error "Invalid command."

spin :: Dice -> [Dice]
spin [a, b, c] = [ [a, b, c]
                 , [a, rev c, b]
                 , [a, rev b, rev c]
                 , [a, c, rev b]
                 ]
spin _ = error "Invalid dice."

dicePermutation :: Dice -> [Dice]
dicePermutation d = spin d ++ spin d' ++ concatMap (spin  . roll d) "NEWS"
  where d' = roll (roll d 'N') 'N'

equalDices :: [Dice] -> Bool
equalDices []     = True
equalDices (x:xs) = all (`notElem` dicePermutation x) xs && equalDices xs

main :: IO ()
main = do
    dices <- map (fromList . map read . words) . tail . lines <$> getContents
    putStrLn $ if equalDices dices then "Yes" else "No"

Measured memory_bytes: 4152
#include <cstdio>
#include <vector>

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

using namespace std;

int rint() {
  int n;
  scanf("%lld", &n);
  return n;
}

void wint(int n) {
  printf("%lld\n", n);
}

signed main() {
  const int p_max = static_cast<int>(1e5) - 1;
  vector<bool> f(p_max / 2 + 2, true); // true if prime
  for (int p = 3; p * p <= p_max; p += 2)
    if (f[p/2+1]) {
      int q = p + p;
      for (int c = p * p; c <= p_max; c += q)
        f[c/2+1] = false;
    }
  vector<int> pi2017(p_max / 2 + 2);
  pi2017[0] = 0;
  pi2017[1] = 0;
  pi2017[2] = 1;
  for (int p = 5; p <= p_max; p += 2) {
    int q = (p+1)/2, i = p/2+1, j = q/2+1;
    pi2017[i] = pi2017[i-1] + (f[i] && q % 2 && f[j]);
  }
  int Q = rint();
  dotimes(i, Q) {
    int l = rint();
    int r = rint();
    wint(pi2017[r/2+1] - pi2017[l/2]);
  }
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int,int> pint;
typedef pair<ll,ll> pll;

#define FI first
#define SE second
#define PB push_back
#define MP make_pair
#define ALL(s) (s).begin(),(s).end()
#define REP(i,n) for (int i = 0; i < (int)(n); ++i)
#define EACH(i,s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<<endl

template<class T1, class T2> ostream& operator<<(ostream &s, pair<T1,T2> P){return s<<'<'<<P.first<<", "<<P.second<<'>';}
template<class T> ostream& operator<<(ostream &s, vector<T> P) {s<<"{ ";for(int i=0;i<P.size();++i){if(i>0)s<<", ";s<<P[i];}return s<<" }"<<endl;}
template<class T1, class T2> ostream& operator<<(ostream &s, map<T1,T2> P) {s<<"{ ";for(__typeof__(P.begin()) it=P.begin();it!=P.end();++it){if(it!=P.begin())s<<", ";s<<'<'<<it->first<<"->"<<it->second<<'>';}return s<<" }"<<endl;}
inline long long tonum(string s) {long long v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string tostr(T x) {ostringstream sout;sout<<x;return sout.str();}



vector<string> split(const string &str, char delim) {
  vector<string> res;
  size_t current = 0, found;
  while ((found = str.find_first_of(delim, current)) != string::npos){
    res.push_back(string(str, current, found - current));
    current = found + 1;
  }
  res.push_back(string(str, current, str.size() - current));
  return res;
}


int N, T;
string str;
string ar_time, ar_st, de_time, de_st;

int wait;


vector<pair<string,int> > res;


int main() {
	res.clear();

	cin >> N >> T;
	cin >> str; cin >> str;

	for (int i = 0; i < (N-1); ++i) {
		cin >> ar_time >> ar_st >> de_time >> de_st;
		
		vector<string> sar = split(ar_time, ':');
		int ar = tonum(sar[0]) * 60 + tonum(sar[1]);

		vector<string> sde = split(de_time, ':');
		int de = tonum(sde[0]) * 60 + tonum(sde[1]);

		wait = de-ar;
		if (wait >= T) {
			res.PB(MP(ar_st, wait));
		}

	}
    cin >> str; cin >> str;

	cout << res.size() << endl;
	for (int i = 0; i < res.size(); ++i) {
		cout << res[i].FI << " " << res[i].SE << endl;
	}
    
    return 0;
}


Measured memory_bytes: 1244
#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 Reverse(a) reverse(All(a));
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
#define print(a) cout << (a) << endl
#define printD(a) cout << setprecision(15) << (a) << endl;
using namespace std;
int max_int = 1000000007;
void Debug(auto a);
int nibul(auto a,auto b);
int nibuu(auto a,auto b);
void input(vector<auto>& a,int n);

int n;

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

signed main(){
    cin >> n;
    vector<int> a;
    int tmp = n;
    if(IsPrime(n)) {print(n-1); return 0;}
    for(int i=2;i*i < tmp;i++){
        if(tmp%i==0){
            a.push_back(i);
            while(tmp%i==0) tmp /= i;
        }
    }
    if(tmp != 1) a.push_back(tmp);
    REP(i,a.size()){
        n /= a[i];
        n *= a[i]-1;
    }
    print(n);



    return 0;
}

void Debug(auto a){
    cout << "{ ";
    for(auto b: a){
        cout << b << " ";
    }
    cout << "}" << endl;
}
int nibul(auto a,auto b){
    int x = lower_bound(All(a),b) - a.begin();
    //key以上の初めてのitr
    return x;
}
int nibuu(auto a,auto b){
    int x = upper_bound(All(a),b) - a.begin();
    //key以下の最後のitr
    return x-1;
}

void input(vector<auto>& a,int n){
    REP(i,n){
        cin >> a[i];
    }
}




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

#define int long long
#define itn int
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
#define dump2(x, y) \
    cerr << #x << " = " << (x) << " " << #y << " = " << (y) << '\n'
#define SZ(x) ((int)(x).size())
#define bit(n) (1LL << (n))
constexpr int MOD = 1e9 + 7;

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = LLONG_MAX / 2;
using P = pair<int, int>;
using vec = vector<int>;
template <typename T>
using mat = vector<vector<T>>;

// clang-format off
template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) { return stream << p.first << "," << p.second; }
template <typename T>
void print(const vector<T> vec) { rep (i, vec.size() - 1) cout << vec[i] << ' '; cout << vec[vec.size() - 1] << '\n'; }
template <typename Arg>
void print(const Arg arg) { cout << arg << '\n'; }
template <typename Head, typename... Args>
void print(const Head head, const Args... args) { cout << head << " "; print(args...); }
template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) { rep (i, v.size()) cin >> v[i] >> w[i]; }
template <typename T>
void init(vector<T>& v) { rep (i, v.size()) cin >> v[i]; }
template <typename T>
T sum_(vector<T> vec, T init = 0) { return std::accumulate(all(vec), T(init)); }
template<typename T>
bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<typename T>
bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <typename T>
int index(const T& vec, const typename T::iterator it) { return distance(vec.begin(), it); }
template <typename T = int>
mat<T> mmat(int n, int m=0) { return mat<T>(n, vector<T>(m)); }
template <typename T = int>
vector<T> ivec(int n) { vector<T> v(n); init(v); return v; }
// clang-format on

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
// -------------------------------------------------------------------
// sort 1 2 3 4
// pqr 1 2 3 must impl >

signed main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    vec v(n + 1);
    rep (i, k) {
        int d;
        cin >> d;
        int a;
        rep (j, d) {
            cin >> a;
            v[a]++;
        }
    }
    int ans = 0;
    For(i, 1, n) if (v[i] == 0) ans++;
    print(ans);

    return 0;
}


Measured memory_bytes: 3644
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static int MOD = 1000000007;
	static int[] mh4 = { 0, -1, 1, 0 };
	static int[] mw4 = { -1, 0, 0, 1 };
	static int[] mh8 = { -1, -1, -1, 0, 0, 1, 1, 1 };
	static int[] mw8 = { -1, 0, 1, -1, 1, -1, 0, 1 };

	static class TaskX {

		public void solve(int testNumber, InputReader in, PrintWriter out) {

			char[] s = in.nextString().toCharArray();
			int len = s.length;

			boolean[] used = new boolean[26];
			for (int i = 0; i < len; i++) {
				used[s[i]-'a'] = true;
			}

			if (len < 26) {
				for (int i = 0; i < 26; i++) {
					if (!used[i]) {
						out.print(s);
						out.println((char)(i+'a'));
						return;
					}
				}
			} else {
				char[] t = s.clone();

				Permutation p = new Permutation();
				p.next(t);

				StringBuffer sb = new StringBuffer();
				boolean same = true;
				for (int i = 0; i < len; i++) {
					if (s[i] == t[i]) {
						sb.append(t[i]);
					} else {
						sb.append(t[i]);
						same = false;
						break;
					}
				}
				out.println(same ? -1 : sb.toString());
			}

		}

		static class Permutation {
			public boolean next(char[] a) {
				int n = a.length;

				int i = n - 1;
				while (i > 0 && a[i - 1] >= a[i])
					i--;
				if (i <= 0)
					return false;

				int j = n - 1;
				while (a[j] <= a[i - 1])
					j--;
				swap(a, i - 1, j);

				int k = n - 1;
				while (i < k)
					swap(a, i++, k--);

				return true;
			}

			private static void swap(char[] a, int i, int j) {
				char tmp = a[i];
				a[i] = a[j];
				a[j] = tmp;
			}
		}
	}


	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

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

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

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

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}
	}

}


Measured memory_bytes: 23380
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.Contracts;
using System.Linq;

namespace at_coder
{
#if TEST
    [TestClass]
#endif
    public class Test_168_a
    {

#if TEST
        public static void Test_Main()
#else
        public static void Main()
#endif
        {
            int[] hon = new int[] { 2, 4, 5, 7, 9 };

            int N = ReadInt();
            int d = N % 10;
            if (d == 3)
            {
                Write("bon");
            }
            else if (hon.Contains(d))
            {
                Write("hon");
            }
            else
            {
                Write("pon");
            }
        }


        private static void Write(string s)
        {
            Console.WriteLine(s);
        }

        private static int[] ReadIntArray()
        {
            string[] ss = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            int[] ar = new int[ss.Length];
            for (int i = 0; i < ss.Length; i++)
            {
                ar[i] = int.Parse(ss[i]);
            }
            return ar;
        }
        private static int ReadInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static void ReadInt(out int a, out int b)
        {
            var ar = ReadIntArray();
            a = ar[0];
            b = ar[1];
        }
        private static void ReadInt(out int a, out int b, out int c)
        {
            var ar = ReadIntArray();
            a = ar[0];
            b = ar[1];
            c = ar[2];
        }
        private static string ReadString()
        {
            return Console.ReadLine();
        }
        private static string[] ReadStringArray()
        {
            string[] ss = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            return ss;
        }
#if !TEST
    }
}
#endif


Measured memory_bytes: 27696
#include <stdio.h>
int Min2(int a,int b){
    return a<b?a:b;
}

int main(){
    int n,c;
    scanf("%d %d",&n,&c);
    int d[30][30];
    int cnt[3][30]={0};
    int i,j,k;
    for(i=0;i<c;i++){
        for(j=0;j<c;j++){
            scanf("%d",&d[i][j]);
        }
    }
    for(i=0;i<n;i++){
        for(j=0;j<n;j++){
            int tmp;
            scanf("%d",&tmp);
            cnt[(i+j)%3][tmp-1]++;
        }
    }
/*
    puts("");
    for(i=0;i<3;i++){
        for(j=0;j<c;j++){
            printf("%d ",cnt[i][j]);
        }
        puts("");
    }
*/
    int iwa[3][30]={0};
    for(i=0;i<3;i++){
        for(j=0;j<c;j++){
            for(k=0;k<c;k++){
                iwa[i][j]+=d[k][j]*cnt[i][k];
            }
        }
    }
/*
    puts("");
    for(i=0;i<3;i++){
        for(j=0;j<c;j++){
            printf("%d ",iwa[i][j]);
        }
        puts("");
    }
*/
    int ans=1000000000;
    for(i=0;i<c;i++){
        for(j=0;j<c;j++){
            if(i==j)continue;
            for(k=0;k<c;k++){
                if(i==k||j==k)continue;
                //printf("%d %d %d:%d %d %d %d\n",i,j,k,ans,iwa[0][i],iwa[1][j],iwa[k]);
                ans=Min2(ans,iwa[0][i]+iwa[1][j]+iwa[2][k]);
                //printf("%d %d %d:%d\n",i,j,k,ans);
            }
        }
    }
    printf("%d\n",ans);
}


Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#define INF         1e9
#define EPS         1e-9
#define REP(i,n)    for(lint i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)   for(lint i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)   for(lint i=(n)-1;i>=0;--i)
#define REPR1(i,n)  for(lint i=(n);i>0;--i)
#define REPC(i,obj) for(auto i:obj)
#define R_UP(a,b)   (((a)+(b)-1)/(b))
#define ALL(obj)    (obj).begin(),(obj).end()
#define SETP        cout << fixed << setprecision(10)
using namespace std;
using lint = long long;
template<typename T = lint>inline T in() { T x; cin >> x; return x; }

signed main() {
	string s = in<string>(), t = in<string>();
	int cnt_s[26], cnt_t[26];
	REP(i, 26) {
		cnt_s[i] = cnt_t[i] = -1;
	}
	REP(i, s.length()) {
		if (cnt_s[s[i] - 'a'] != -1 && cnt_s[s[i] - 'a'] != t[i] - 'a' || cnt_t[t[i] - 'a'] != -1 && cnt_t[t[i] - 'a'] != s[i] - 'a') {
			cout << "No" << endl;
			return 0;
		}
		cnt_s[s[i] - 'a'] = t[i] - 'a';
		cnt_t[t[i] - 'a'] = s[i] - 'a';
	}
	cout << "Yes" << endl;
	return 0;
}

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

int main()
{
  uint64_t n;
  cin >> n;
  uint64_t ans = n;

  for (uint64_t i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      uint64_t j = n / i;
      ans = min(ans, i + j - 2);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
 int main(){
   long long a,b,c;
     cin>>a>>b>>c;
   if(a>c){
   cout<<a-c<<" "<<b<<endl;
   }
   else if(a+b<c){
   cout<<0<<" "<<0<<endl;
   }
   else{
   cout<<0<<" "<<a+b-c<<endl;
   }

}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main()
{
	string num[] = { "0111111", "0000110", "1011011", "1001111",
		"1100110", "1101101", "1111101", "0100111",
		"1111111", "1101111", "1000110" };
	int n,a;
	string s,t;
	while (true){
		cin >> n;
		if (n == -1){
			break;
		}
		cin >> a;
		s = num[a];
		cout << s << endl;
		for (int i = 0; i < n - 1; i++){
			cin >> a;
			for (int i2 = 0; i2 < num[a].size(); i2++){
				if (s[i2] != num[a][i2]){
					t += '1';
				}
				else{
					t += '0';
				}
			}
			cout << t << endl;
			s = num[a];
			t.clear();
		}
	}
}

Measured memory_bytes: 1196
import sys
#import numpy as np
#import math
#from fractions import Fraction
#import itertools
#import heapq

h,w,k=map(int,input().split())
s = [list(map(int, input())) for _ in range(h)]
res=0
ans=10**9
for i in range(2**(h-1)):
    p=1
    partation=[-1]*(h-1)

    for j in range(h-1):
        if i &(1<<j):
            partation[j]=1
            p+=1
    g=[0]*p
    res=0
    l=r=0
    f=False
    while r<w:
        m=0
        for j in range(h):
            g[m]+=s[j][r]
            if g[m]>k:
                res+=1
                g=[0]*p
                if l==r:
                  f=True
                l=r
                break
            if j<h-1 and partation[j]==1:
                m+=1
        else:
            r+=1
        if f:
          break
    else:
      res+=p-1
      if res<ans:
          ans=res
print(ans)

Measured memory_bytes: 45148
#include<iostream>

using namespace std;

int mod = 1000000007;
int N;
bool isPrime(int x) {
    for(int i=2; i*i<=x; i++) if(x%i == 0) return false;
    return true;
}

int main () {
    cin >> N;
    long long int ans = 1;
    for(int i=2; i<=N; i++) {
        if( isPrime(i) ) {
            int r =  1;
            for(int x=N; x/=i; r+=x);
            ans = ans * r % mod;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

bool check(int t, string& week, string& time)
{
    static const string x[] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};

    if(week != "All" && x[t/(24*60)%7] != week)
        return false;
    if(time != "All"){
        t %= 24 * 60;
        if((time == "Day") ^ (6*60 <= t && t < 18*60))
            return false;
    }
    return true;
}

int main()
{
    for(;;){
        int s, n, cycle;
        string week, time;
        double prob;
        int m;
        cin >> s >> n >> cycle >> week >> time >> prob >> m;
        if(s == 0)
            return 0;
        prob = 1.0 - 1.0 / prob;

        double ret = 0.0;
        for(int i=0; i<60*24*7; ++i){
            double tmp = 1.0;
            for(int j=0; j<m; ++j){
                int t1 = i + j * cycle;
                int t2 = t1 + s;
                if(check(t1, week, time) && check(t2, week, time))
                    tmp *= pow(prob, n);
            }
            ret = max(ret, 1.0 - tmp);
        }

        printf("%.10f\n", ret);
    }
}

Measured memory_bytes: 1296
import sys;sys.setrecursionlimit(10**9)
class UnionFind:
  def __init__(self,n):
    self.n=[-1]*n
    self.r=[0]*n
  def find_root(self,x):
    if self.n[x]<0:
      return x
    else:
      self.n[x]=self.find_root(self.n[x])
      return self.n[x]
  def unite(self,x,y):
    x=self.find_root(x)
    y=self.find_root(y)
    if x==y:return
    elif self.r[x]>self.r[y]:
      self.n[x]+=self.n[y]
      self.n[y]=x
    else:
      self.n[y]+=self.n[x]
      self.n[x]=y
      if self.r[x]==self.r[y]:
        self.r[y]+=1
  def root_same(self,x,y):
    return self.find_root(x)==self.find_root(y)
  def count(self,x):
    return -self.n[self.find_root(x)]
n,m,k=map(int,input().split())
ab=[list(map(int,input().split()))for _ in range(m)]
cd=[list(map(int,input().split()))for _ in range(k)]
u=UnionFind(n)
for a,b in ab:u.unite(a-1,b-1)
ans=[u.count(i)-1 for i in range(n)]
for a,b in ab:
  ans[a-1]-=1
  ans[b-1]-=1
for c,d in cd:
  if u.root_same(c-1,d-1):
    ans[c-1]-=1
    ans[d-1]-=1
print(*ans)

Measured memory_bytes: 59712
#include <iostream>

using namespace std;

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

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

  cout << a[n-1];
  for(int i = n-2; i >= 0; i--){
    cout << " " << a[i];
  }
  cout << endl;

  return 0;
}



Measured memory_bytes: 3088
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);
		//入力表示

		int N = sc.nextInt();
		int K = sc.nextInt();
		int Q = sc.nextInt();
		int a[] = new int[Q];

		for (int i = 0; i < Q; i++) {
			a[i] = sc.nextInt();
		}
		int b[] = new int[N];

		Arrays.fill(b, K - Q);
		for (int i = 0; i < Q; i++) {
			b[a[i] - 1]++;
		}
		for (int i = 0; i < N; i++) {
			System.out.println(b[i] <= 0 ? "No" : "Yes");
		}
	}
}

Measured memory_bytes: 55168
#include <stdio.h>
#include <string.h>
int main(int argc, char *argv[])
{
	long long a;
	char b[11];
	scanf("%lld%s",&a,b);
	int bb=0,cc=0,i,sum=1;
	for(i=strlen(b)-1;b[i]!='.';i--){
		cc+=(b[i]-'0')*sum;
		sum*=10;
	}
	sum=1;
	for(i--;i>=0;i--){
		if(i<0)break;
		bb+=(b[i]-'0')*sum;
		sum*=10;
	}
	sum=bb*100+cc;
	printf("%lld\n",(sum*a)/100);
}

Measured memory_bytes: 1712
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
using namespace std;

#define N  100005

void solve()
{
	ll a,b;
	cin>>a>>b;
	vi x,y;
	rep(i,b*10,b*10+10){
		if((ll)floor((i*2.0)/25)==a){
			cout<<i;
			return;
		}
	}
	cout<<-1;

}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 256
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;


int main(){
    ll n;
    cin>>n;
    vector<ll> A(n);
    vector<ll> cnt(n,0);
    vector<ll> col(n,0);
    vector<vector<ll>> edge(n);
    vector<set<ll>> S(n);
    for(int i=0;i<n;i++){cin>>A[i]; A[i]--; cnt[A[i]]++; edge[i].push_back(A[i]);}
    queue<ll> Q;
    for(int i=0;i<n;i++){if(cnt[i]==0){Q.push(i);}}
    while(!Q.empty()){
        ll w=Q.front(); Q.pop();
        for(int i=0;;i++){if(S[w].count(i)==0){col[w]=i; break;}}
        for(auto &I:edge[w]){
            cnt[I]--;
            S[I].insert(col[w]);
            if(cnt[I]==0){Q.push(I);}
        }
    }
    for(int i=0;i<n;i++){
        if(cnt[i]!=0){
            pll s;
            for(int j=0;;j++){if(S[i].count(j)==0){s.F=j; break;}}
            for(int j=(int)s.F+1;;j++){if(S[i].count(j)==0){s.S=j; break;}}
            pll now=s;
            ll w=edge[i][0];
            while(w!=i){
                for(int j=0;;j++){if(S[w].count(j)==0 && j!=now.F){now.F=j; break;}}
                for(int j=0;;j++){if(S[w].count(j)==0 && j!=now.S){now.S=j; break;}}
                for(auto &I:edge[w]){w=I;}
            }
            if(now.F==s.F && now.S!=s.F){cout<<"IMPOSSIBLE"<<endl;}
            else{cout<<"POSSIBLE"<<endl;}
            return 0;
        }
    }
    assert(false);
    cout<<"POSSIBLE"<<endl;
    
    
    return 0;
}


Measured memory_bytes: 32256
// A C++ program to count number of partitions 
// of a set with n elements into k subsets 
#include<iostream> 
using namespace std; 

// Returns count of different partitions of n 
// elements in k subsets 
int countP(int n, int k) 
{ 
    // Base cases 
    if (n == 0 || k == 0 || k > n) 
        return 0; 
    if (k == 1 || k == n) 
        return 1; 

    // S(n+1, k) = k*S(n, k) + S(n, k-1) 
    return k*countP(n-1, k) + countP(n-1, k-1); 
} 

// Driver program 
int main() 
{ 
    int n;
    cin>>n;
    int res=1;
    int c=1;
    for(int i=1;i<=9;i++){
        for(int j=1;j<=9;j++){
            if(i*j==n){
                c=0;
                cout<<"Yes";
                return 0;
            }
        }
    }
    cout<<"No";
    return 0; 
} 

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include <algorithm>
#include <set>
#include<math.h>
#include<cmath>
#include<vector>
#include<map>
#include<random>
#include<sstream>
using namespace std;

int main(){
    int n; cin >> n;
    double x[n];
    string u[n];
    for(int i = 0;i < n;i++){
        cin >> x[i] >> u[i];
    }
    double total = 0;
    for(int i = 0;i < n;i++){
        if(u[i] == "JPY"){
            total += x[i];
        }else{
            total += x[i]*380000.0;
        }
    }
    cout << total << endl;

}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#include<set>

using  ll = long long;
using ull = unsigned long long;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};
constexpr ll kINF = 1152921504606846976;//2^60
constexpr double kEPS = 1e-6;

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define rep(i,n) REP(i,n)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep(i,n) RREP(i,n)
#define mp make_pair
#define fi first
#define sc second

ll N,K;
ll h[100010];
ll dp[100010];

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

int main(void) {
  cin >> N >> K;
  rep(i,N) {
    cin >> h[i];
    dp[i] = kINF;
  }
  dp[0] = 0;

  rep (i,N-1) {
    for (int j = 1; j <= K && i + j < N;j++) {
      chmin(dp[i+j],dp[i] + abs(h[i+j] - h[i]));
    }
  }
  cout << dp[N - 1] << endl;
}

Measured memory_bytes: 1792
#include<iostream>
#include <string>
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define endl "\n"
#define mp make_pair
#define sz(v) (int)(v.size())
#define len(s) (int)(s.length())
#define M 998244353
#define all(v) v.begin(),v.end()
#define fr(a,b,c) for(ll i=a;i<=b;i+=c)
#define inarr(arr,n); for(ll i=0;i<n;i++) cin >> arr[i];
#define outarr(arr,n); for(ll i=0;i<n;i++) cout<<arr[i]<<" ";
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
const ll inf = 9e18;
const ld pi = 2*acos(0.0); 
using namespace std;
ll power(ll a,ll n) 
{
    if(n==0){
        return 1;
    }
    ll p=power(a,n/2) % M;
    p = (p * p) % M;
    if (n%2==1)
    {
        p=(p*a)%M;
    }
    return p;
}
ll gcd(ll a, ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
}
const int N=1e6;
vector <ll> sieve(N,0); 
void si() 
{
    sieve[1]=1;
    for(int i=2;i<N;i++){
        if(sieve[i]==0){
            for(int j=i;j<N;j+=i){
                sieve[j]=i;
            }
        }
    }
}
int main(){
    ios;
    ll x;
    cin>>x;
    cout<<(x^1)<<endl;
    return 0;
}

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

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

  vector<int> button(N);
  vector<int> isVisited(N);
  for (int i = 0; i < N; i++) {
    cin >> button.at(i);
    isVisited.at(i) = 0; // false
  }

  int count = 1; // At least, buttons1 must be pushed once.
  int focus = 0; // button number:1~N
  while(button.at(focus) != 2) {
    if (isVisited.at(focus)) { // Avoiding infinite loop
      count = -1;
      break;
    } else {
      count++;
      isVisited.at(focus) = 1;
      focus = button.at(focus) - 1;
    }
  }

  cout << count << endl;

}


Measured memory_bytes: 1024
import heapq
X,Y,A,B,C = map(int,input().split())
p = list(map(int,input().split()))
q = list(map(int,input().split()))
r = list(map(int,input().split()))

h = []
for i in range(A):
    h.append([-p[i],0])
for i in range(B):
    h.append([-q[i],1])
for i in range(C):
    h.append([-r[i],2])
heapq.heapify(h)
x = X
y = Y
s = X+Y
ans = 0
while s>0:
    d,c = heapq.heappop(h)
    if c==0:
        if x>0:
            ans -= d
            x -= 1
            s -= 1
    elif c==1:
        if y>0:
            ans -= d
            y -= 1
            s -= 1
    else:
        ans -= d
        s -= 1
print(ans)

Measured memory_bytes: 128100
import java.io.*;
public class Main {
	
		public static void main(String[] args) throws IOException{
			
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			String str = br.readLine();
			
			double r = Double.parseDouble(str);
			
			System.out.printf("%6f %6f",r*r*Math.PI ,2*r*Math.PI );
			
			
			
		}

}

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

struct UnionFind {
    vector<int> par;
    vector<int> sz;

    UnionFind(int n=0){
        if(n>0) initialize(n);
    }

    void initialize(int n){
        par.resize(n);
        sz.resize(n);
        for(int i=0; i<n; i++){
            par[i] = i;
            sz[i] = 1;
        }
    }

    int find(int x){
        if(par[x] == x){
            return x;
        }else{
            return par[x] = find(par[x]);
        }
    }

    void unite(int x, int y){
        x = find(x);
        y = find(y);
        if(x == y) return;
        if(sz[x] < sz[y]){
            par[x] = y;
            sz[y] += sz[x];
        }else{
            par[y] = x;
            sz[x] += sz[y];
        }
    }

    bool same(int x, int y){
        return find(x) == find(y);
    }
};

int main(){
    int N, M, K, C[100000];
    cin >> N >> M >> K;

    UnionFind uf(N+K);

    int freedom = 0;
    for(int i=0; i<N; i++){
        cin >> C[i];
        if(C[i] > 0){
            C[i]--;
            uf.unite(i, N+C[i]);
        }
    }

    vector<vector<int>> edges;
    for(int i=0; i<M; i++){
        int a, b, c;
        cin >> a >> b >> c;
        edges.push_back({c, a-1, b-1});
    }
    sort(edges.begin(), edges.end());

    int64_t ans = 0;
    int k = 0;
    for(auto& e : edges){
        int c = e[0], a = e[1], b = e[2];
        if(!uf.same(a, b)){
            ans += c;
            k++;
            if(k == K-1) break;
            uf.unite(a, b);
        }
    }

    cout << (k == K-1 ? ans : -1) << endl;
    return 0;
}


Measured memory_bytes: 8244
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <cmath>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
const int inf = 1e9;
const ll linf = 1LL << 50;

int main(int argc, char const* argv[])
{
  int n;
  cin >> n;
  unordered_map<int, int> mp;
  for(int i = 0; i < n; i++){
    int x;
    cin >> x;
    mp[x]++;
  }
  ll res = 0;
  for(auto itr = mp.begin(); itr != mp.end(); ++itr){
    int num = itr->second;
    int a = itr->first;
    if(num < a)res += num;
    else res += num - a;
  }
  cout << res << endl;
	return 0;
}


Measured memory_bytes: 4260
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define mod 998244353
using namespace std;
typedef pair<llint, llint> P;
typedef pair<P, llint> E;

llint h, w;
char c[505][505];
bool red[505][505], blue[505][505];

int main(void)
{
	cin >> h >> w;
	for(int y = 1; y <= h; y++){
		for(int x = 1; x <= w; x++){
			cin >> c[x][y];
		}
	}
	for(int y = 2; y < h; y++){
		for(int x = 1; x <= w; x++){
			if(c[x][y] == '#') red[x][y] = blue[x][y] = true;
			if(x % 2) red[x][y] = true;
			else blue[x][y] = true;
		}
	}
	for(int x = 1; x <= w; x++) red[x][1] = true, blue[x][h] = true;
	
	for(int y = 1; y <= h; y++){
		for(int x = 1; x <= w; x++){
			cout << ".#"[red[x][y]];
		}
		cout << endl;
	}
	cout << endl;
	for(int y = 1; y <= h; y++){
		for(int x = 1; x <= w; x++){
				cout << ".#"[blue[x][y]];
		}
		cout << endl;
	}
	
	return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
 
int main(void) {
    int a,b,c;
    cin >> a >> b>> c;
    if(max({a,b,c})==a){
        cout << a*10+b+c << endl;
    }else if(max({a,b,c})==b){
        cout << b*10+a+c << endl;
    }else if(max({a,b,c})==c){
        cout << c*10+a+b << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,x,n) for(int i=x; i<(int)(n); i++)
#define rep_eq(i,x,n) for(int i=x; i<=(int)(n); i++)
using namespace std;

using ll=long long;

int main() {
  int L,R,d; cin >>L >>R >>d;
  int ans=0;
  rep_eq(i,L,R) {
    if (i%d==0) {
      ans++;
    }
  }
  cout <<ans <<endl;
  return 0;
}


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

namespace B_Coins_test
{
    class Program// AtCoderにて7/13 ACでした
    {
        static void Main(string[] args)
        {
            int a = Convert.ToInt32(Console.ReadLine());
            int b = Convert.ToInt32(Console.ReadLine());
            int c = Convert.ToInt32(Console.ReadLine());
            int x = Convert.ToInt32(Console.ReadLine());
            int cnt = 0;
            bool already_written = false;

            //if (x == 500 && a >= 1)
            //{
            //    Console.WriteLine(1);
            //    already_written = true;
            //    //Console.Read();
            //}
            //if(x == 100 && b >= 1)
            //{
            //    Console.WriteLine(1);
            //    already_written = true;
            //    //Console.Read();
            //}
            //if(x == 50 && c >= 1)
            //{
            //    Console.WriteLine(1);
            //    already_written = true;
            //    //Console.Read();
            //}
            for(int i = 0; i<= a; i++)
            {
                int y = x - 500 * i;
                //if (y == 0) cnt++;
                //Console.WriteLine(i);
                for (int j = 0; j <= b; j++)
                {
                    int z = y - 100 * j;
                    //if (z == 0) cnt++;
                    //Console.WriteLine(i); Console.WriteLine(j);
                    for (int k = 0; k <= c; k++)
                    {
                        int p = z - 50 * k;
                        if (p == 0) cnt++;
                        //Console.WriteLine(i); Console.WriteLine(j); Console.WriteLine(k);
                    }
                }
            }
            if(already_written == false) Console.WriteLine(cnt);
        }
    }
}


Measured memory_bytes: 13268
#define _USE_MA_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int n,m,t,p;
    cin>>n>>m>>t>>p;
    while(n){
        int a[1000][1000]={};
        int x=0,y=0,w=n,h=m;
        rep(i,m)rep(j,n)a[i][j]=1;
        while(t--){
            int d,c;
            cin>>d>>c;
            if(d==1){
                Rep(i,y,h){
                    rep(j,c){
                        a[i][x+2*c-j-1]+=a[i][x+j];
                    }
                }
                w=max(w,x+2*c);
                x+=c;
            }
            else{
                Rep(i,x,w){
                    rep(j,c){
                        a[y+2*c-j-1][i]+=a[y+j][i];
                    }
                }
                h=max(h,y+2*c);
                y+=c;
            }
        }
        while(p--){
            int r,t;
            cin>>r>>t;
            cout<<a[y+t][x+r]<<endl;
        }
        cin>>n>>m>>t>>p;
    }
}


Measured memory_bytes: 10956
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,r,s=0;
string a;
cin>>n;
cin>>a;
if(n%2==1){cout<<"No";}
else{r=n/2;
for (int i = 0; i < r; ++i)
{if(a[i]==a[i+r]){s++;}
}
if(s==r){cout<<"Yes";}
else{cout<<"No";}}



	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 8
#define nfree -1
#define free 1

int A[N][N];
int row[N],col[N],dpos[2*N-1],dneg[2*N-1];
void putQueen(int i){
  int j;
 
  if(i==N){
    print();
    return;
  }
   
  for(j=0; j<N; j++){
    if(nfree==col[j]||nfree==dpos[i+j]||nfree==dneg[i-j+N-1]) continue;
    row[i] = j;
    col[j] = dpos[i+j] = dneg[i-j+N-1] = nfree;
    putQueen(i+1);
    row[i] = col[j] = dpos[i+j] = dneg[i-j+N-1] = free;
  }
}
 
void print(){
   
  int i,j;
   
  for(i=0; i<N; i++){
    for(j=0; j<N; j++){
      if(A[i][j]){
    if(row[i]!=j) return;
      }
    }
  }
   
  for(i=0; i<N; i++){
    for(j=0; j<N; j++){
      if(row[i]==j) printf("Q");
      else printf(".");
    }
    printf("\n");
  }
}
int main(){
 
  int n;
  int i,j;
  int x,y;
   
  for(i=0; i<N; i++){
    for(j=0; j<N; j++){
      A[i][j] = 0;
    }
  }
   
  for(j=0; j<N; j++){
    row[j]=0;
    col[j]=0;
  }
  for(j=0; j<2*N-1; j++){
    dpos[j]=0;
    dneg[j]=0;
  }
   
  scanf("%d",&n);
   
  for(i=0; i<n; i++){
    scanf("%d %d",&x,&y);
    A[x][y] = 1;
  }
   
  putQueen(0);
 
  return 0;
}
 


Measured memory_bytes: 2112