akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int[] selSort = new int[sc.nextInt()];
        
        for(int i = 0; i < selSort.length; i++){
            selSort[i] = sc.nextInt();
        }
        
        SelectionSort ss = new SelectionSort(selSort);
        ss.changeOfSNum();
        ss.outPutOfSNum();
        ss.outPutCount();
    }
}

class SelectionSort{
    int[] selSort;
    public SelectionSort(int[] selSort){
        this.selSort = selSort;
    }
    
    int count = 0;
    public void changeOfSNum(){
        int maxNum = 0;
        int flag = 0;
        for(int i = 0, j; i < selSort.length; i++){
            maxNum = selSort[i];
            j = i + 1;
            while(j < selSort.length){
                if(selSort[j] < selSort[i]){
                    selSort[i] = selSort[j];
                    flag = j;
                }
                j++;
            }
            if(maxNum != selSort[i]){
                selSort[flag] = maxNum;
                count++;
            }
        }
    }
    
    public void outPutOfSNum(){
        for(int i = 0; i < selSort.length; i++){
            if(i == 0){
                System.out.print(selSort[i]);
                continue;
            }
            System.out.print(" " + selSort[i]);
        }
        System.out.print("\n");
    }
    
    public void outPutCount(){
        System.out.println(count);
    }
}


Measured memory_bytes: 26412
N = int(input())
P = list(map(float,input().split()))

dp = [[0] * (N + 1) for i in range(N + 1)]
dp[0][0] = 1

for i in range(len(P)):
  for j in range(i + 2):
    if j - 1 >= 0:
      dp[i + 1][j] = dp[i][j] * (1 - P[i]) + dp[i][j - 1] * P[i]
    else:
      dp[i + 1][j] = dp[i][j] * (1 - P[i])
  
ans = 0
for i in range(N // 2 + 1, len(dp)):
  ans += dp[N][i]
  
print(ans)

Measured memory_bytes: 203756
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define bit(k) (1LL<<(k))
#define SUM(v) accumulate(all(v), 0LL)

typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
struct fast_ios{ fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; }fast_ios_;

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

#define TOSTRING(x) string(#x)
template <typename T> istream &operator>>(istream &is, vector<T> &vec) { for (T &x : vec) is >> x; return is; }
template <typename T> ostream &operator<<(ostream &os, const vector<T> &v) { os  << "["; for(auto _: v) os << _ << ", "; os << "]"; return os; };
template <typename T> ostream &operator<<(ostream &os, set<T> &st) { os << "("; for(auto _: st) { os << _ << ", "; } os << ")";return os;}
template <typename T, typename U> ostream &operator<<(ostream &os, const pair< T, U >& p){os << "{" <<p.first << ", " << p.second << "}";return os; }
template <typename T, typename U> ostream &operator<<(ostream &os, const map<T, U> &mp){ os << "["; for(auto _: mp){ os << _ << ", "; } os << "]" << endl; return os; }

#define DUMPOUT cerr
void dump_func(){ DUMPOUT << endl; }
template <class Head, class... Tail> void dump_func(Head &&head, Tail &&... tail) { DUMPOUT << head; if (sizeof...(Tail) > 0) { DUMPOUT << ", "; } dump_func(std::move(tail)...); }

#ifdef DEBUG
#define dbg(...) dump_func(__VA_ARGS__)
#define dump(...) DUMPOUT << string(#__VA_ARGS__) << ": "; dump_func(__VA_ARGS__)
#else
#define dbg(...)
#define dump(...)
#endif

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = 1000000007;
// const ll MOD = 998244353;
const long double PI = acos(-1.0);

/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/


int main() {
    int x;
    cin >> x;
    if(x)cout << 0 << endl;
    else cout << 1 << endl;
}


Measured memory_bytes: 3644
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	static final int N = 10000;

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";

		boolean[] primes = new boolean[N + 1];

		for (int i = 2; i < N / 2 + 1; i++) {
			if (!primes[i]) {
				for (int j = 2; j < N / i + 1; j++) {
					primes[i * j] = true;
				}
			}
		}

		while ((line = br.readLine()) != null && !line.isEmpty()) {
			int n = Integer.parseInt(line);
			if (n == 0) {
				break;
			}
			for (int i = n; i > 4; i--) {
				if (!primes[i] && !primes[i - 2]) {
					System.out.println(i - 2 + " " + i);
					break;
				}
			}
		}
	}
}

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


int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n , x;
    long long sum = 0 , ans = 0;
    map<long long , int> m;
    cin >> n;
    for(int i = 0 ; i < n ; i++){
        m[sum]++;
        cin >> x;
        sum += x;
        ans += m[sum];
    }

    cout << ans << endl;

    return 0;
}


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

#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

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

  long ac = 0;
  long wa = 0;
  long tle = 0;
  long re = 0;

  for (long i = 0; i < n; i++) {
    string tmp;
    cin >> tmp;
    if (tmp == "AC") {
      ac++;
    }
    if (tmp == "WA") {
      wa++;
    }
    if (tmp == "TLE") {
      tle++;
    }
    if (tmp == "RE") {
      re++;
    }
  }

  cout << "AC"
       << " x " << ac << endl;
  cout << "WA"
       << " x " << wa << endl;
  cout << "TLE"
       << " x " << tle << endl;
  cout << "RE"
       << " x " << re << endl;
}


Measured memory_bytes: 3520
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
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(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;cin>>s;
    int p=0, q=0;
    rep(i, 4){
        if(s[i]=='+') p++;
        else q++;
    }
    cout<<p-q<<endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
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; }

int n, m;
int a[310][310];
bool out[310];

int ans;

void calc(int i){
	map<int, int> cnt;
	rep(i,n){
		int id = -1;
		rep(j,m){
			if(out[a[i][j]]) continue;
			id = a[i][j];
			break;
		}
		cnt[id]++;
	}
	int maxV = 0, maxI = -1;
	for(auto p : cnt){
		if(maxV < p.second){
			maxV = p.second;
			maxI = p.first;
		}
	}
	chmin(ans, maxV);
	if(i == m) return;
	out[maxI] = true;
	calc(i+1);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> m;
    rep(i,n)rep(j,m) cin >> a[i][j];
    ans = 114514;
    calc(1);
    cout << ans << endl;
    return 0;
}

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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int MOD = 1000000007;
const long long INF = 1LL << 60;
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; }

int main() {
    int N, K; cin >> N >> K;
    vector<int> h(N);
    for (int i = 0; i < N; ++i) cin >> h[i];
    vector<ll> dp(N, INF);
    dp[0] = 0;
    for (int i = 0; i < N; ++i) {
        for (int j = 1; j <= K; ++j) {
            if (i+j < N) chmin(dp[i + j], dp[i] + abs(h[i + j] - h[i]));
        }
    }
    cout << dp[N-1] << endl;
    return 0;
}

Measured memory_bytes: 4580
#include<bits/stdc++.h>
using namespace std;
main(){
  string a,b;
  int c,d;
  int dp[2][5000],ans;
  while(cin>>a>>b){
    c=a.size(),d=b.size();
    ans=0;
    memset(dp,0,sizeof(dp));
    for(int i=1;i<=c;i++){
      for(int j=1;j<=d;j++){
	int ni=i%2,ri=1-i%2;
	//niは今のaの文字数が奇数か偶数か dpテーブルの使い回しのため
	//riはniじゃない方←前の結果のdpテーブル
	if(a[i-1]==b[j-1]){//一致したら前の状態の前の文字のdpテーブルから値を引っ張ってくる
	  dp[ni][j]=dp[ri][j-1]+1;
	}
	else dp[ni][j]=0;//違うなら打ち切る
	ans=max(ans,dp[ni][j]);
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1252
#include<iostream>
using namespace std;
int main(){
  int n,t,nc,flag=0,a,b;
  cin >> n;
  nc=n;
  t=n%10;
  while(nc!=0){
    if(nc%10!=t){
      flag=1;
      break;
    }
    nc/=10;
  }
  if(flag==1){
    a=n/100;
    b=a*100+a*10+a;
    if(b>n) t=a;
    else t=a+1;
  }
  cout << t << t << t << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define FORUL(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#define FORULE(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define FOREACH(it, X) for(__typeof((X).begin()) it = (X).begin(); it != (X).end(); it++)
#if defined(_MSC_VER) || __cplusplus > 199711L
#define AUTOVAR(newvar,v) auto newvar = (v)
#else
#define AUTOVAR(newvar,v) __typeof(newvar) r = (v)
#endif
#define PB(x) push_back(x)
#define MP(x,y) make_pair((x),(y))
#define MEMSET(m,v) memset(m,v,sizeof(m))

typedef long long				 ll;
typedef unsigned long long		ull;

#define DEBUG 1

#if DEBUG
#define DOUT cout<<"["<<__LINE__<<"]:"
#else
#define DOUT 0 && cout
#endif

using namespace std;

int X,Y;

int main(int argc, char *argv[])
{
	ios::sync_with_stdio(false);

	cin >> X >> Y;
	int ans = 0;
	if(1<=X && X<=3) {
		ans += 400000 - (X*100000);
	}
	if(1<=Y && Y<=3) {
		ans += 400000 - (Y*100000);
	}
	if(1==X && 1==Y) {
		ans += 400000;
	}

	cout << ans<<endl;

	return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#include <unistd.h>
using namespace std;
using namespace std::chrono;
using namespace __gnu_pbds;
#define ll long long int
//mp.reserve(1024);
//mp.max_load_factor(0.25);
typedef tree<int, null_type, less<int>, rb_tree_tag,
                 tree_order_statistics_node_update>
          ordered_set;
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
            x += 0x9e3779b97f4a7c15;
            x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
            x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
            return x ^ (x >> 31);
        }

        size_t operator()(uint64_t x) const {
            static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
            return splitmix64(x + FIXED_RANDOM);
        }
};

void addEdge(vector<ll> adj[], ll u, ll v)
{
   adj[u].push_back(v);
   adj[v].push_back(u);
}
vector<ll> z_function(string s) {
    ll n = s.length();
    vector<ll> z(n);
    for (ll i = 1, l = 0, r = 0; i < n; ++i) {
        if (i <= r)
            z[i] = min (r - i + 1, z[i - l]);
        while (i + z[i] < n && s[z[i]] == s[i + z[i]])
            ++z[i];
        if (i + z[i] - 1 > r)
            l = i, r = i + z[i] - 1;
    }
    return z;
}
ll mod=1e9+7;
ll power(ll x,ll y)
{
    ll res = 1; // Initialize result

    while (y > 0) {
        // If y is odd, multiply x with result
        if (y & 1)
            res = ((res%mod) * (x%mod))%mod;

        // n must be even now
        y = y >> 1; // y = y/2
        x = ((x%mod) * (x%mod))%mod; // Change x to x^2
    }
    return res;
}

int mod1(string num, int a)
{
    // Initialize result
    int res = 0;

    // One by one process all digits of 'num'
    for (int i = 0; i < num.length(); i++)
         res = (res*10 + (int)num[i] - '0') %a;

    return res;
}


int main()
{
 	ios_base::sync_with_stdio(false);
   	cin.tie(NULL);
   	cout.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output1.txt", "w", stdout);
   ll n;
   cin>>n;
   vector<ll>v,v1;
   set<ll>s;
   for(ll i=0,temp;i<n;i++){
        cin>>temp;
        v.push_back(temp);
        s.insert(temp);
   }
   v1=v;

   while(s.size()>1){
       v=v1;
        for(ll i=0;i<v.size();i++){
            if(v[i]!= *s.begin())
            v[i]=v[i]%(*s.begin());
        }
        s.clear();
        v1.clear();
        for(auto x:v)
            if(x!=0){
                s.insert(x);
                v1.push_back(x);
            }
   }
   cout<<*s.begin()<<endl;
	return 0;
}


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

long long md(pair<long long,long long> x,pair<long long,long long> y){
    return max(x.first,y.first)-min(x.first,y.first)+max(x.second,y.second)-min(x.second,y.second);
}

int main(){
    string S;
    cin >> S;
    int s=S.size(),l,r;
    for(int i=0;i<s;i++){
        if(S[i]=='A'){
            l=i;
            break;
        }
    }
    for(int i=s-1;i>0;i--){
        if(S[i]=='Z'){
            r=i;
            break;
        }
    }
    cout << r-l+1 << endl;
}

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


int main(void) {
    int N,x;
    std::vector<int> a;

    std::cin >> N;
    std::cin >> x;

    a.resize(N);
    for(int i = 0; i < N; i++) {
        std::cin >> a[i];
    }

    std::sort(a.begin(), a.end());

    int i;
    for(i = 0;i < N; i++) {
        x -= a[i];
        if(x == 0) {
            std::cout << i+1 << std::endl;
            return 0;
        }
        if(x < 0) {
            std::cout << i << std::endl;
            return 0;
        }
    }
    if(x > 0)
        i--;

    std::cout << i << std::endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int isPrimeNum( int x )
{
    int i;

    for( i = 2; i <= sqrt((double)x); i++ )
        if( x % i == 0 ) return 0;
    return 1;
}

int main(){
  int num;
  int i,j;
  int *array;
  int count = 0;

  do{
  scanf("%d",&num);
  }while(num < 1 || num > 10000);

  array = (int *)malloc(sizeof(int)*num);

  for(i = 0;i < num;i++){
    do{
    scanf("%d",&array[i]);
    }while(array[i]<2 || array[i]>100000000);
  }

  for(i = 0;i < num;i++) {
        if( isPrimeNum( array[i] ) ) {
	  count++;
        }
    }

  printf("%d\n",count);
  
  free(array);
  
  return 0;
}



Measured memory_bytes: 2068
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
using ll = long long;
using P = pair<int, int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef vector<ll> vi;
const int MOD = 1000000007;
template<class T> void print(const T& t){ cout << t << endl; }
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; }

int main(){
  ll n, i;
  cin >> n >> i;
  print(n - i + 1);
}

Measured memory_bytes: 256
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define mp make_pair
#define ALL(obj) (obj).begin(),(obj).end()
#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(i,0,n)
#define RREP(i,n) RFOR(i,0,n) 
#define SIZE(x) ((int)(x).size())
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef pair<int, int> pint;
typedef pair<lint, lint> plint;
typedef vector<lint> vec;
typedef vector<vector<lint>> matrix;
typedef priority_queue<lint> p_que;
typedef priority_queue<lint, vector<lint>, greater<lint>> p_que_rev;
const lint INF = INT_MAX;
const lint LINF = LLONG_MAX;
const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};

lint gcd(lint a, lint b) {
    lint r;
    while (b != 0) {
        r = a % b;
        a = b; 
        b = r;
    }
    return a;
}

lint lcm(lint a, lint b) {
    return (a / gcd(a, b)) * b;
}

lint power(lint x, lint n, lint mod = MOD) {
    lint ret = 1;
    while(n > 0) {
        if(n & 1){
            (ret *= x) %= mod;
        }
        (x *= x) %= mod;
        n >>= 1;
    }
    return ret;
}

vector<lint> make_power(int n, lint base){
    lint num = 1;
    vector<lint> ret;
    for (int i=0; i<=n; ++i){
        ret.push_back(num);
        num *= base;
    }
    return ret;
}

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int a, b, c, x;
    cin >> a >> b >> c >> x;
    int ans = 0;
    REP(i, a+1){
        REP(j, b+1){
            REP(k, c+1){
                if(500 * i + 100 * j + 50 * k == x){
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <string>
#include <cmath>
#include <complex>
#include <map>
using namespace std;

#define rep(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define EPS 1e-8
#define F first
#define S second

static const double PI=6*asin(0.5);
typedef pair<double,double> P;
typedef complex<double> CP;
typedef long long ll;

int a[110];

int main(){
	int n;
	while(cin>>n,n){
		rep(i,110) a[i]=0;
		rep(i,n){
			cin>>a[i];
		}
		ll res=0;
		for(int i=n;i>1;i--){
			for(int j=0;j<i-1;j++){
				if(a[j]>a[j+1]){
					int t;
					t=a[j+1];
					a[j+1]=a[j];
					a[j]=t;
					res++;
				}
			}
		}
		cout<<res<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
import math
a, b, x = map(int, input().split())
if(x < ((a*a*b)/2)):
  print(math.degrees(math.atan( a*b*b/(2 * x) )))
else:
  print(math.degrees(math.atan( 2*(a*a*b - x)/(a*a*a) )))

Measured memory_bytes: 3060
#include <stdio.h>
int main(void){
	int n,x;
	int i,j;
	int res;
	
	while(1){
		scanf(" %d %d",&n,&x);
		if(n==0 && x==0) break;
		res=0;
		for(i=1;i<=n-2;i++) for(j=i+1;j<=n-1;j++) if(n>=x-i-j && x-i-j>j) res++;
		printf("%d\n",res);
	}
	return 0;
}

Measured memory_bytes: 600
#include<cstdio>
#include<cstring>
const int N=505;
int n,m;
char s[N][N],t[N][N];
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)scanf("%s",s[i]+1),strcpy(t[i]+1,s[i]+1);
	for(int i=1;i<=n;i++)s[i][1]='#',t[i][m]='#';
	for(int i=1;i<=n;i+=2)for(int j=2;j<m;j++)s[i][j]='#';
	for(int i=2;i<=n;i+=2)for(int j=2;j<m;j++)t[i][j]='#';
	for(int i=1;i<=n;i++)puts(s[i]+1);puts("");
	for(int i=1;i<=n;i++)puts(t[i]+1);
}

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

long long M, D;

bool check(int m, int d){
	int d1 = d/10;
	int d2 = d%10;
	return d1>1 && d2>1 && m == d1 * d2;
}

int main(){
	cin >> M >> D;

	long ans = 0;
	for(int m = 1; m <= M; m++){
		for(int d = 1; d <= D; d++){
			if(check(m, d)){
				ans++;
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#pragma region _head

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<numeric>
#include<utility>

#pragma region _define

#define int LL
#define f(i,a,b) for(LL i=a;i<b;i++)
#define f_vI(v,n) f(i,0,n)cin>>v[i]
#define f_v2I(v1,v2,n) f(i,0,n)cin>>v1[i]>>v2[i]
#define f_v3I(v1,v2,v3,n) f(i,0,n)cin>>v1[i]>>v2[i]>>v3[i]
#define f_vO(v,n,option) f(i,0,n)cout<<v[i]<<option;
#define all(a) a.begin(),a.end()
#define size(s) ((int)s.size())
#define check() cout<<"! ! !"
#define endl "\n"
#define _y() cout<<"Yes"<<endl
#define _Y() cout<<"YES"<<endl
#define _n() cout<<"No"<<endl
#define _N() cout<<"NO"<<endl
#define int_INF 1<<29
#define ll_INF 1LL<<60
#define MOD 10000007

#pragma endregion

#pragma region _using

using namespace std;

using LL = long long;
using st = string;
using vi = vector<LL>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vc = vector<char>;
using vs = vector<st>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using qi = queue<int>;
using qc = queue<char>;
using qs = queue<st>;
using si = stack<LL>;
using sc = stack<char>;
using ss = stack<st>;
using pi = pair<LL, LL>;
using mll = map<LL, LL>;
using vpi = vector<pi>;

#pragma endregion

#pragma region _graph

#define node 50  //グラフの最大位数　適宜変更
//bool graph[node][node]; bool visited[node] = { false };
#define link(a,b,m) f(i,0,m){cin>>a[i]>>b[i]; a[i]--; b[i]--; graph[a[i]][b[i]]=graph[b[i]][a[i]]=true;}

#pragma endregion

//素数判定
bool is_prime(int n) {
	for (int i = 2; i*i <= n; i++) {
		if (n%i == 0) {
			return false;
		}
	}
	return true;
}

LL gcd(LL a, LL b) {
	LL r;
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}
LL lcm(LL a, LL b) {
	return (a / gcd(a, b)*b);
}

//階乗計算
LL factorial(LL n) {
	LL a = 1, ret = 1;
	while (a < n) {
		a++;
		ret *= a;
		//ret %= 1000000007;
	}
	return ret;
}

#pragma endregion

/************************************************************************/
signed main(void) {
	cin.tie(0); ios::sync_with_stdio(false);

	int n, k;
	cin >> n >> k;
	vi a(n);
	f_vI(a, n);
	double d = (double)(n - k) / (double)(k - 1);
	cout << ceil(d) + 1;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <utility>
#include <string.h>
#include <map>
#include <stack>
#include <iomanip>
#include <chrono>
#include <random>
#include <math.h>
#include <time.h>
#include <assert.h>
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define ll long long
#define pb push_back 
#define mp make_pair
#define ff first
#define ss second
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define all(x) x.begin(),x.end() 
#define PII pair <int,int>
#define N 100005
#define MOD 1000000007
#define INF 1000000000000000000
using namespace std;

int main()
{
	int a, b;
	cin >> a >> b;
	cout << max({a + a - 1, b + b - 1, a + b});
}



Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef pair<int, int> P;
const int c_INF = 111111111;
const int c_mINF = -111111111;
const int c_YET = -1;
const int c_Dx[4] = { 0,0,1,-1 };
const int c_Dy[4] = { 1,-1,0,0 };
const int c_div = 1000000007; //10^9 + 7


int main() {

	int n, m;
	scanf("%d%d", &n, &m);

	printf("%d", (n - 1) * (m - 1));









}

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

// https://atcoder.jp/contests/abc159/submissions/14840254
const long long OO = (long long) 1e18;

const int N = 200008;
int n;
long long a[N];

long long dp[N][3];
// dp[i][j] is maximum possible sum choosing (i+1-j)/2 elements from first i
// elements. This is NOT a floor! So half the dp elements will be impossible
// solely because it's impossible to choose half an element.

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

	dp[0][0] = -OO;
	dp[0][1] = 0;
	dp[0][2] = -OO;
	dp[1][0] = a[0];
	dp[1][1] = -OO;
	dp[1][2] = 0;

	for (int i = 2; i <= n; i++) {
		// note that we are computing dp[i] using a[i-1] and dp[i-1]
		for (int j = 0; j < 3; j++) {
			// take a[i-1]
			dp[i][j] = dp[i-2][j] + a[i-1];

			if (j) {
				// we have slack; don't take a[i-1]
				dp[i][j] = max(dp[i][j], dp[i-1][j-1]);
			}
		}
	}

	cout << dp[n][n % 2 == 0 ? 1 : 2];
}


Measured memory_bytes: 9844
# -*- coding: utf-8 -*-

N = int(input().strip())
T_list = [int(input().strip()) for _ in range(N)]
#-----

def gcd(a,b):
    x = max(a,b)
    y = min(a,b)

    while y != 0:
        r = x % y
        
        x = y
        y = r
    
    return x

def lcm(a, b):
    return (a * b) // gcd(a, b)


ans = T_list[0]
for i in T_list[1:]:
    ans = lcm(ans, i)

print(ans)


Measured memory_bytes: 3064
#include <stdio.h>
#include <string.h>

struct process {
	char name[11];
	int time;
	int ans;
};

struct process pro[100001], ans_pro[100001];

int main(void) {

	int n, q, i, j, co = 0, coo = 0, cot = 0, co_zero = 0, co_time = 0, co_end = 0, co_ans = 0;
	struct process k;

	scanf("%d %d", &n, &q);
	for (i = 0; i < n; i++) {
		scanf("%s %d", pro[i].name, &pro[i].time);
	}

	while (n != co_zero) {
		coo = co_zero;
		cot = 0;
		for (i = 0; i < n - coo; i++) {
			if (pro[i].time > q) {
				co_time += q;
				pro[i].time -= q;
				pro[i - cot] = pro[i];
			}
			else {
				co_time += pro[i].time;
				ans_pro[co_ans].ans = co_time;
				strcpy(ans_pro[co_ans].name, pro[i].name);
				co_ans++;
				co_zero++;
				cot++;
			}
		}
	}
	for (i = 0; i < n; i++) {
		printf("%s %d\n", ans_pro[i].name, ans_pro[i].ans);
	}
	return 0;
}



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

int main(){
  int a;
  cin >> a;
  string A;
  cin >> A;
  int count = 1;
  rep(i,a-1) if(A.at(i) != A.at(i+1)) count++;
  cout << count << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>

using namespace std;

int main() {
	int n5 = 0;
	int n7 = 0;
	for (int i = 0; i < 3; i++) {
		int input;
		cin >> input;
		if (input == 5) {
			n5++;
		} else if (input == 7) {
			n7++;
		}
	}

	if (n5 == 2 && n7 == 1) {
		cout << "YES" << endl;
	} else {
		cout << "NO" << endl;
	}
}

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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rrep(i,n) for(int i=n;i>=0;i--)
#define rrepa(i,a,n) for(int i=n;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
#define cmax(a,b) a=max(a,b)
#define cmin(a,b) a=min(a,b)
#define vc vector

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;

int main(){

    int n;
    cin>>n;
    vi p(n);
    rep(i,n)cin>>p[i];

    int ans=0;
    repa(i,1,n-1){
        if((p[i]>p[i-1] && p[i]<p[i+1]) || (p[i]<p[i-1] && p[i]>p[i+1]))ans++;
    }

    cout<<ans<<"\n";

    return 0;

}

Measured memory_bytes: 3584
from itertools import combinations

n = int(input())
balls = []
cost = n
for _ in range(n):
    x, y = map(int, input().split())
    balls.append((x, y))

for b1, b2 in combinations(balls, 2):
    p, q = b1[0] - b2[0], b1[1] - b2[1]
    if p != 0 or q != 0:
        sub = 0
        for b3, b4 in combinations(balls, 2):
            dx, dy = b3[0] - b4[0], b3[1] - b4[1]
            if dx == p and dy == q or -dx == p and -dy == q:
                sub += 1
        cost = min(cost, n - sub)

print(max(cost, 1))

Measured memory_bytes: 3064
import std;

alias sread = () => readln.chomp();
alias lread = () => readln.chomp.to!long();
alias aryread(T = long) = () => readln.split.to!(T[]);

void main()
{
    long n, m;
    scan(n, m);
    // writeln(n, m);
    auto 正解したか = new bool[](n + 1);
    auto WAの回数 = new long[](n + 1);
    foreach (_; 0 .. m)
    {
        long p;
        string s;
        scan(p, s);
        // writeln(p, s);
        if ((正解したか[p] == false) && (s == "WA"))
        {
            WAの回数[p] += 1;
        }
        else if (s == "AC")
        {
            正解したか[p] = true;

        }
    }
    // writeln(正解したか);
    // writeln(WAの回数);
    long 正解数, ペナルティ;
    foreach (i; 0 .. 正解したか.length)
    {
        正解数 += 正解したか[i];
    }
    // writeln(正解数);
    foreach (i; 0 .. WAの回数.length)
    {
        if (正解したか[i] == true)
        {
            ペナルティ += WAの回数[i];
        }
    }
    writeln(正解数, ' ', ペナルティ);
}

void scan(L...)(ref L A)
{
    auto l = readln.split;
    foreach (i, T; L)
    {
        A[i] = l[i].to!T;
    }
}


Measured memory_bytes: 5624
#include<bits/stdc++.h>
#define Tp template<typename Ty>
#define Ts template<typename Ty,typename... Ar>
#define Reg register
#define RI Reg int
#define Con const
#define CI Con int&
#define I inline
#define W while
#define N 100000
using namespace std;
int n,a[N+5],s[N+5];
class FastIO
{
	private:
		#define FS 100000
		#define tc() (A==B&&(B=(A=FI)+fread(FI,1,FS,stdin),A==B)?EOF:*A++)
		#define tn (x<<3)+(x<<1)
		#define D isdigit(c=tc())
		char c,*A,*B,FI[FS];
	public:
		I FastIO() {A=B=FI;}
		Tp I void read(Ty& x) {x=0;W(!D);W(x=tn+(c&15),D);}
		Ts I void read(Ty& x,Ar&... y) {read(x),read(y...);}
}F;
int main()
{
	RI i,t=0;for(F.read(n),i=1;i<=n;++i) F.read(a[i]),t^=a[i];if(t) return puts("No"),0;
	for(sort(a+1,a+n+1),i=1;i<=n;++i) s[i]=a[i];t=unique(s+1,s+n+1)-s-1;return puts(t<=3?"Yes":"No"),0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;

template<int64_t MOD> struct Mint {
    int64_t v;
    Mint() { v = 0; }
    Mint(int64_t x) { v = x % MOD; if(v < 0)  v += MOD; }

    Mint operator-() { return Mint{-v}; };
    Mint operator+(Mint x) { return Mint(v + x.v); };
    Mint operator-(Mint x) { return Mint(v - x.v); };
    Mint operator*(Mint x) { return Mint(v * x.v); };
    Mint operator/(Mint x) { return Mint(v * pow(x.v, MOD-2).v); };

    Mint& operator+=(Mint x) { return *this = (*this + x); };
    Mint& operator-=(Mint x) { return *this = (*this - x); };
    Mint& operator*=(Mint x) { return *this = (*this * x); };
    Mint& operator/=(Mint x) { return *this = (*this / x); };

    static Mint pow(Mint base, int64_t exp) {
        if(exp == 0)  return Mint(1);
        return pow(base*base, exp/2) * (exp&1 ? base : Mint(1));
    }

    friend ostream& operator<<(ostream& os, Mint x) { return os << x.v; }
};
using mint = Mint<1000000007>;

lint n, k;
mint memo[112345];

mint f(lint x) {
    if(x < 0 || x > k)  return 0;
    if(memo[x].v != 0)  return memo[x];

    mint res = mint::pow(mint(k/x), n);
    for(lint i=2; i*x<=k; i++) {
        res -= f(i*x);
    }
    return memo[x] = res;
}

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

    mint ans = 0;
    for(lint i=1; i<=k; i++) {
        ans += mint(i) * f(i);
    }

    cout << ans << endl;
}

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


int main(){
  int N;
  cin >> N;
  for(int ii=0; ii<=N; ii+=4){
    if((N - ii) % 7 == 0){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
use std::process;
macro_rules! get {
      ($t:ty) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.trim().parse::<$t>().unwrap()
          }
      };
      ($($t:ty),*) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              let mut iter = line.split_whitespace();
              (
                  $(iter.next().unwrap().parse::<$t>().unwrap(),)*
              )
          }
      };
      ($t:ty; $n:expr) => {
          (0..$n).map(|_|
              get!($t)
          ).collect::<Vec<_>>()
      };
      ($($t:ty),*; $n:expr) => {
          (0..$n).map(|_|
              get!($($t),*)
          ).collect::<Vec<_>>()
      };
      ($t:ty ;;) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.split_whitespace()
                  .map(|t| t.parse::<$t>().unwrap())
                  .collect::<Vec<_>>()
          }
      };
      ($t:ty ;; $n:expr) => {
          (0..$n).map(|_| get!($t ;;)).collect::<Vec<_>>()
      };
}
fn main() {
    let n = get!(i32);
    
    println!("{}", n.pow(3));
    
}


Measured memory_bytes: 4352
import sys
import copy
import  math
from _bisect import *
from collections import *
from operator import itemgetter
from math import factorial
"""
from fractions import gcd
def lcm(x, y):
    return (x * y) // gcd(x, y)
"""
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

n = ni()
li = na()
ans = [0, 0]
for j in range(2):
    tmp = j
    s = 0
    for i in range(n):
        tmp = 1 - tmp
        s += li[i]
        if tmp:
            if s <= 0:
                d = abs(s - 1)
                ans[j] += d
                s = 1
        else:
            if s >= 0:
                d = abs(s - (-1))
                ans[j] += d
                s = -1
print(min(ans))




Measured memory_bytes: 14844
# include <iostream>
# include <vector>
# include <math.h>
typedef long long ll;
using namespace std;

ll rem(ll num, ll a) {
    while (num >= a) {
        num -= a;
    }
    return num;
}

bool maxima(int index, int n, vector<int> &v) {
    int a = 0;
    int b = 2147483647;
    if (index-1 > 0) {
        a = v[index-1];
    }
    if (index+1 < n) {
        b = v[index+1];
    }
    if (a<=v[index] && v[index] > b) {
        return true;
    }
    return false;
}

int main() {
    int a;
    scanf("%d", &a);
    vector<int> v(a);
    for (int i=0; i<a; i++) {
        scanf("%d", &v[i]);
    }
    v[0]--;
    for (int i=1; i<a; i++) {
        if (v[i] >v[i-1])
            v[i]--;
        else if (v[i] < v[i-1]) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 640
# AGC031A - Colorful Subsequence
from collections import Counter


def main():
    _ = int(input())
    S = input().rstrip()
    MOD = 10 ** 9 + 7
    ans = 1
    for i in Counter(S).values():
        ans *= i + 1
        ans %= MOD
    print(ans - 1)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3444
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

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

    int h, n;
    cin >> h >> n;

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

    cout << (h > 0 ? "No" : "Yes") << "\n";
    return 0;
}

Measured memory_bytes: 888
import sys
from collections import *
import heapq
import math
import bisect
from itertools import permutations,accumulate,combinations,product
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7

n,u,v=map(int,input().split())
ab=[list(map(int,input().split())) for i in range(n-1)]

dic=defaultdict(list)
for i in range(n-1):
    a,b=ab[i]
    dic[a].append(b)
    dic[b].append(a)
# print(dic)

taka=[-1]*(n+1)
aoki=[-1]*(n+1)

d=deque([[u,0]])
if len(dic[u])==1:
    taka[u]=0
while d:
    now,cnt=d.popleft()
    flag=0
    for i in range(len(dic[now])):
        if taka[dic[now][i]]==-1:
            taka[dic[now][i]]=-2
            flag=1
            d.append([dic[now][i],cnt+1])
    if flag==0:
        taka[now]=cnt
# print(taka)

d=deque([[v,0]])
if len(dic[v])==1:
    aoki[v]=0
while d:
    now,cnt=d.popleft()
    flag=0
    for i in range(len(dic[now])):
        if aoki[dic[now][i]]==-1:
            aoki[dic[now][i]]=-2
            flag=1
            d.append([dic[now][i],cnt+1])
    if flag==0:
        aoki[now]=cnt
# print(aoki)

ans=0
for i in range(n+1):
    if taka[i]<aoki[i]:
        ans=max(ans, aoki[i]-1)
print(ans)

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

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}
template<class T> void chmax(T& a, T b){ if(a<b){a=b;} }
template<class T> void chmin(T& a, T b){ if(a>b){a=b;} }
const ll MOD = 998244353;
#define pii pair<int,int>
#define pll pair<ll,ll>


bool func(pii a, pii b){
    return a.first>b.first;
}

bool check(vector<pii> v){
    bool ok = true;
    int h = 0;
    for(pii p:v){
        int b = h+p.first;
        if(b<0){ ok = false; return false;}
        h += p.second;
    }
    return ok;
}

int main(){
    ll N; cin>>N;
    vector<pii> ls,rs;
    int x = 0;
    REP(i,N){
        string s; cin>>s;
        int h = 0;
        int b = 0;
        for(char c:s){
            if(c=='('){++h;}
            else{ --h;}
            chmin(b,h);
        }
        if(h>=0){ ls.push_back( make_pair(b,h) );}
        else{ rs.push_back( make_pair(b-h,-h) ); }
        x += h;
    }
    sort( ALL(ls), func);
    sort( ALL(rs), func);
    
    bool ok = (x==0 && check(ls) && check(rs));
    if(ok){ cout << Liny;}
    else{ cout << Linn;}
}

Measured memory_bytes: 18884
N = int(input())
A = list(map(int, input().split()))
for i in range(N):
    key = A[i]
    j = i - 1
    while A[j] > key and j >=0:
        A[j+1] = A[j]
        j -= 1
    A[j+1] = key
    print(*A)


Measured memory_bytes: 5980
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define fi first
#define se second
#define pb push_back
#define rep(i, s, n) for (int i = s; i < n; i++)
#define rrep(i, s, n) for (int i = (n)-1; i >= (s); i--)
#define all(a) a.begin(),a.end()
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
const long long MOD = 1000000007, INF = 1e17;
 
#define endl '\n'
#define IOS()ios_base::sync_with_stdio(0);cin.tie(0)

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

template<typename T>vector<T>
make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}
template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
	for(auto &e:t) fill_v(e,v);
}
//******************************************************************************
int N,par = -1,cnt = 0,sum = 0,last = -1;
vector<int>used(100010,0);
vector<pair<int,int>>ret;
void built(int i){
	if(par != -1)ret.push_back({par,i});
	rep(j,0,cnt-1){
		ret.push_back({i,i-j-1});
	}
}

signed main()
{
	//IOS();
	string s;
	cin>>s;
	N = s.size();
	rrep(i,0,N)if(s[i]=='1'){last = i;break;}

	rep(i,0,N){
		cnt++;
		if(s[i]=='1'||i>last){
			built(i);
			par = i;
			sum+=cnt;
			if(i!=N-1)used[sum]=used[N-sum]=true;
			cnt = 0;
		}
	}
	rep(i,0,N){
		//cout<<used[i+1]<<" "<<s[i]<<endl;
		if(used[i+1]!=s[i]-'0'){
			cout<<-1<<endl;
			return 0;
		}
	}
	for(auto e:ret){
		cout<<e.fi+1<<" "<<e.se+1<<endl;
	}
	
}


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

int main()
{
    int c = 0,k = 0;
    int sum = 0,money = 0;
    vector<int> summoney;

    cin >> c >> k;
    
    for (int i = 0; i < c; i++)
    {
        cin >> money;
        summoney.push_back(money);
    }

    sort(summoney.begin(),summoney.end());

    for (int j = 0; j < k; j++)
    {
        sum += summoney.at(j);
    }

    cout << sum << endl;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define rp(i,n) for(int i=0; i<n; i++)
using namespace std;
using ll=long long;
using P=pair<int,int>;
using G=vector<vector<int>>;

int main(){
    int n;
    cin >> n;
    vector<int> l(n);
    int sum=0;
    rp(i,n) {
        cin >> l.at(i);
        sum += l[i];
    }
    sort(l.begin(),l.end());
    if(sum-l[n-1]>l[n-1]) cout << "Yes" <<endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define watch(x) cout <<(#x)<<" is "<<(x)<<endl
#define debug cout <<"hi"<<endl
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
int main(){
  string s; cin >>s;
  deque<char>dq; int n=s.size();
  for(int i=0; i<n; i++) dq.push_back(s[i]);
  int q; cin >>q; bool shit=0;
  for(int i=0; i<q; i++){
    int t; cin >>t;
    if(t==1){
      if(shit) shit=0;
      else shit=1;
    }
    else{
      int f; char c; cin >>f >>c;
      if(f==1){
        if(shit) dq.push_back(c);
        else dq.push_front(c);
      }
      else{
        if(shit) dq.push_front(c);
        else dq.push_back(c);
      }
    }
  }
  if(shit) while(!dq.empty()){cout <<dq.back(); dq.pop_back();}
  else while(!dq.empty()){cout <<dq.front(); dq.pop_front();}
return 0;}

Measured memory_bytes: 896
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

#define i_cin(X) scanf("%d", &X)
#define i_cin2(X,Y) scanf("%d %d",&X,&Y)
#define i_cin3(X,Y,Z) scanf("%d %d %d",&X,&Y,&Z)
#define l_cin(X) scanf("%ld",&X)
#define l_cin2(X,Y) scanf("%ld %ld",&X,&Y)
#define s_cin(X) scanf("%s",&X)

#define  i_cout(X) printf("%d\n",X)
#define  f_cout(X) printf("%g\n",X)
#define  i_cout2(X,Y) printf("%d %d\n",X,Y)
#define  l_cout(X) printf("%ld\n",X)
#define  s_cout(X) printf("%s\n",X)
#define  ll_cout(X) printf("%lld\n",X)

typedef long long int lli;
#define rept(x, s, n) for (int x = s; x < n; x++)


int i_cins(int n, int* A);
int l_cins2(int n, long* A,long* B);
int s_dsort(const void* a, const void* b);

int main(void) {
	int   i;
	long  tmp=0;
	char  N[10];
	
	s_cin(N);
	N[strlen(N)]=0x00;

	rept(i, 0, 10) {
		if (!N[i]) break;
		tmp += (N[i] - '0');
	}

    if (atol(N)%tmp) s_cout("No");
    else s_cout("Yes");
   
	return 0;
}

//降順
int s_dsort(const void* a, const void* b) {
	return(*(int*)b - *(int*)a);
}
//
int l_cins2(int n, long* a, long* b) {
	int i;
	rept(i, 0, n) {
		l_cin2(*(a + i), *(b + i));
	}
	return 0;
}
int i_cins(int n, int* a) {
	int i;
	rept(i, 0, n) {
		i_cin(*(a + i));
	}
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ll long long
template <typename T>
bool PN(T x){ if (x <= 1) return false; if (x == 2) return true; for (int i = 2; i < sqrt(x) + 1; i++) if (x % i == 0) return false; return true;}
const ll MOD = 1e9+7;
long long Comb(int n, int i){long long ans = 1; if(i>n || i < 0) return 0; if(i == 0 || i == n) return 1; else {for(int j = 1; j <= i; ++j){ans *=(n+1-j); ans /= j; ans %= MOD;} }return ans;}
template<typename T> T gcd(T a, T b){if(b == 0) return a;else return gcd(b, a%b);}
template<typename T> T lcm(T a, T b){if(b > a) swap(a, b); T g = gcd(a, b);return a / g * b;}

void solve(){
  int x; cin >> x;
  if(x) cout << 0;
  else cout << 1;
}

int main(void){
  solve();
  return 0;
}


Measured memory_bytes: 3604
#include <iostream>
#include <stack>
#include <string>
#include <cstdlib>
using namespace std;
int main(void){
    string str;
    stack<long> st;
    
    while(cin >> str){
        if(str == "+" || str == "-" || str == "*"){
            long y = st.top();
            st.pop();
            long x = st.top();
            st.pop();
            if(str == "+")
                st.push(x + y);
            else if(str == "-")
                st.push(x - y);
            else
                st.push(x * y);
        }
        else{
            char *ends;
            st.push(strtol(str.c_str(), &ends, 0));
        }
    }
    
    cout << st.top() << endl;
    
    return 0;
}

Measured memory_bytes: 3124
#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 ALL(obj) (obj).begin(),(obj).end()
#define SCANF(i) int i;scanf("%d",&i)
typedef long long ll;
using namespace std;
using P = pair<int,int>;
const long long INF = 1LL << 60;
const int IINF=100000000;
const int MOD = (int)1e9 + 7;
//約数列挙
vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long 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.begin(), ret.end()); // 昇順に並べる
    return ret;
}
vector<int> dx={1,0,-1,0};vector<int> dy={0,-1,0,1};

signed main () {
    ll n,d;cin >> n >> d;
    ll ans =0;
    REP(i,n){
        ll x,y;cin >> x >> y;
        ll dis = x*x+y*y;
        if(sqrt(dis)<=d)ans++;
    }
    cout << ans << endl;
}//https://atcoder.jp/contests/abc174/tasks/abc174_b

Measured memory_bytes: 3688
import std.container;
import std.range;
import std.algorithm;
import std.array;
import std.string;
import std.conv;
import std.stdio;
import std.container;

void main() {
	auto s = readln.chomp;

	write(s);
	if (s[$ - 1] == 's') {
		writeln("es");
	} else {
		writeln("s");
	}
}


Measured memory_bytes: 2608
import numpy as np

size=input()
arr=np.array(input().split(" "),dtype=np.int32)

bit_array=[]
length_array=[]

for x in arr:
    bit_array.append(bin(x))
    length_array.append(len(bin(x)))

max_length=max(length_array)

fixed_bit_array=[]
for x,y in zip(bit_array,length_array):
    if y==max_length:
        fixed_bit_array.append(x[2:])
    else:
        pad=max_length-y
        x="{}{}".format("0"*pad,x[2:])
        fixed_bit_array.append(x)


result=[]
for i in range(max_length-2):
    count=0
    for x in fixed_bit_array:
        if x[i]=="1":
            count+=1
    if count%2==0:
        result.append("0")
    else:
        result.append("1")

if "1" in "".join(result):
    print("No")
else:
    print("Yes")

Measured memory_bytes: 31728