akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int count(int *a, int num, int b) {
    int count = 0;
    for (int i=0; i<num; i++) {
        if (a[i]%b != 0) count++;
    }
    if (count > 1) return 0;
    return 1;
}

int main() {
    int num = 0;
    scanf("%d\n", &num);
    int a[num];
    for (int i=0; i<num; i++) {
        scanf("%d", a+i);
    }
    int min = 0, min2 = 0;
    if (a[0] > a[1]) min = a[1], min2 = a[0];
    else min = a[0], min2 = a[1];
    for (int i=2; i<num; i++) {
        if (a[i] < min) min = a[i];
        else if (a[i] < min2) min2 = a[i];
    }
    int max = 0;
    if (num == 2) printf("%d\n", min2);
    else {
        for (int i=min; i>0; i--) {
            if (min%i == 0) {
                if (count(a, num, i)) {
                    max = i;
                    break;
                }
            }
        }
        for (int i=min2; i>0; i--) {
            if (min2%i == 0) {
                if (count(a, num, i)) {
                    if (i > max) max = i;
                    break;
                }
            }
        }
        printf("%d\n", max);
    }
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
int main() 
{ 
	SPEED
    int n;
    cin >> n;
    int arr[n];
    for (int i = 0; i < n; ++i)
    {
    	cin >> arr[i];
    }

    int brr[n] = {0};
    int larg_count = 0;
    int larg = -1;
    for (int i = 0; i < n; ++i)
    {
    	if (arr[i]>larg)
    	{
    		larg = arr[i];
    	}
    }
    for (int i = 0; i < n; ++i)
    {
    	if (arr[i]==larg)
    	{
    		brr[i] = -1;
    		larg_count++;
    	}
    }

    int larg2 = -1;
    for (int i = 0; i < n; ++i)
    {
    	if (arr[i]>larg2 && arr[i]<larg)
    	{
    		larg2 = arr[i];
    	}
    }
    if (larg2==-1)
    {
    	larg2 = larg;
    }

    
    if (larg_count>1)
    {
    	for (int i = 0; i < n; ++i)
	    {
	    	brr[i] = larg;
	    }
    }
    else
    {
    	for (int i = 0; i < n; ++i)
	    {
	    	if (brr[i]==-1)
	    	{
	    		brr[i] = larg2;
	    	}
	    	else
	    	{
	    		brr[i] = larg;
	    	}
	    }
    }


    for (int i = 0; i < n; ++i)
    {
    	cout << brr[i] << '\n';
    }
    return 0;      
} 

Measured memory_bytes: 3200
#include <iostream>
#include <cmath>
#include <stdio.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  while(n!=0){
  int s[n];
  double m=0,a=0;
  for(int i=0;i<n;i++){
    cin>>s[i];
    m+=s[i];
  }
  m/=n;
  for(int i=0;i<n;i++){
    a+=pow((m-s[i]),2);
  }
  printf("%f\n",fabs(sqrt(a/n)));
  cin>>n;
  }
      
  return 0;
}


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

using namespace std;

const int vy[] = {-1, 0, 1, 0};
const int vx[] = {0, -1, 0, 1};
const string vv = "DLUR";

const int INF = 1 << 30;

int dp1[2002][2002] = {{}}, dp2[2002][2002] = {{}};
int dp3[2001][2002] = {{}}, dp4[2001][2002] = {{}};

int main()
{
  string S;
  int K;

  cin >> S;
  cin >> K;


  string A, B;
  for(int i = 0; i < S.size(); i++) {
    if(vy[vv.find(S[i])] != 0) A += S[i];
    else B += S[i];
  }


  int latte[2002] = {}, malta[2002] = {};
  for(int i = 0; i < A.size(); i++) {
    int mv = A[i] == 'U' ? 1 : -1;
    latte[i] = mv;
  }
  for(int i = 0; i < B.size(); i++) {
    int mv = B[i] == 'L' ? 1 : -1;
    malta[i] = mv;
  }


  if(!A.empty()) {
    fill_n(*dp1, 2002 * 2002, -INF);
    fill_n(*dp2, 2002 * 2002, INF);
    dp1[0][0] = latte[0];
    dp1[0][1] = -latte[0];
    dp2[0][0] = latte[0];
    dp2[0][1] = -latte[0];
    for(int i = 1; i < A.size(); i++) {
      for(int j = 2000; j >= 0; j--) {
        dp1[i][j + 1] = max(dp1[i][j + 1], dp1[i - 1][j] + (j % 2 == 0 ? -latte[i] : latte[i]));
        dp1[i][j] = max(dp1[i][j], dp1[i - 1][j] + (j % 2 == 1 ? -latte[i] : latte[i]));
        dp2[i][j + 1] = min(dp2[i][j + 1], dp2[i - 1][j] + (j % 2 == 0 ? -latte[i] : latte[i]));
        dp2[i][j] = min(dp2[i][j], dp2[i - 1][j] + (j % 2 == 1 ? -latte[i] : latte[i]));
      }
    }

    for(int i = 1; i <= 2000; i++) {
      dp1[A.size() - 1][i] = max(dp1[A.size() - 1][i], dp1[A.size() - 1][i - 1]);
      dp2[A.size() - 1][i] = min(dp2[A.size() - 1][i], dp2[A.size() - 1][i - 1]);
    }
  }


  if(!B.empty()) {
    fill_n(*dp3, 2001 * 2002, -INF);
    fill_n(*dp4, 2001 * 2002, INF);
    dp3[0][0] = malta[0];
    dp3[0][1] = -malta[0];
    dp4[0][0] = malta[0];
    dp4[0][1] = -malta[0];
    for(int i = 1; i < B.size(); i++) {
      for(int j = 2000; j >= 0; j--) {
        dp3[i][j + 1] = max(dp3[i][j + 1], dp3[i - 1][j] + (j % 2 == 0 ? -malta[i] : malta[i]));
        dp3[i][j] = max(dp3[i][j], dp3[i - 1][j] + (j % 2 == 1 ? -malta[i] : malta[i]));
        dp4[i][j + 1] = min(dp4[i][j + 1], dp4[i - 1][j] + (j % 2 == 0 ? -malta[i] : malta[i]));
        dp4[i][j] = min(dp4[i][j], dp4[i - 1][j] + (j % 2 == 1 ? -malta[i] : malta[i]));
      }
    }
    for(int i = 1; i <= 2000; i++) {
      dp3[B.size() - 1][i] = max(dp3[B.size() - 1][i], dp3[B.size() - 1][i - 1]);
      dp4[B.size() - 1][i] = min(dp4[B.size() - 1][i], dp4[B.size() - 1][i - 1]);
    }
  }

  int ret = 0;

  for(int i = 0; i <= K; i++) {
    int aa = dp1[max(0, (int) A.size() - 1)][i];
    int bb = dp2[max(0, (int) A.size() - 1)][i];
    int cc = dp3[max(0, (int) B.size() - 1)][K - i];
    int dd = dp4[max(0, (int) B.size() - 1)][K - i];

    ret = max(ret, max(aa, -bb) + max(cc, -dd));
  }

  cout << ret << endl;
}

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

string s, t;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> s;
	t = s;
	int a = 0;
	for(size_t i=1; i<s.size(); ++i){
		if(s[i] == s[i-1]){
			++a;
			s[i] = 1-(s[i]-'0')+'0';
		}
	}
	int b = 1;
	t[0] = 1-(s[0]-'0')+'0';
	for(size_t i=1; i<t.size(); ++i){
		if(t[i] == t[i-1]){
			++b;
			t[i] = 1-(t[i]-'0')+'0';
		}
	}
	cout << min(a, b) << "\n";
}

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

int main() {
    int n;
    cin >> n;
    vector<int> a(n), b(n), c(n);
    for (auto &x: a) cin >> x;
    for (auto &x: b) cin >> x;
    for (auto &x: c) cin >> x;
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    sort(c.begin(), c.end());
    vector<long long> l(n);
    int j = 0;
    for (int i = 0; i < n; i++) {
        while (j < n && c[j] <= b[i]) j++;
        l[i] = n - j;
    }
    for (int i = n - 1; i > 0; i--) l[i-1] += l[i];
    long long ans = 0;
    j = 0;
    for (int i = 0; i < n; i++) {
        while (j < n && b[j] <= a[i]) j++;
        if (j == n) break;
        ans += l[j];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5108
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

    int count = 0;
    void solve() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        List<Integer> heights = new ArrayList<>();

        for (int i = 0; i < N; i++) {
            heights.add(sc.nextInt());
        }
        calcCount(heights);
        System.out.print(count);
    }

    void calcCount(List<Integer> heights) {
        // 脱出条件
        if (heights.size() == 0) {
            return;
        }
        if (heights.size() == 1) {
            count += heights.get(0);
            return;
        }

        int minHeight = Collections.min(heights);
        if (minHeight > 0) {
            // Integer 型のまま扱えば、もっと簡単にできるかも。
            for (int i = 0; i < heights.size(); i++) {
                int height = heights.get(i);
                heights.set(i, height - minHeight);
            }
            count += minHeight;
        }

        List<Integer> subHeights = new ArrayList<>();
        for (int i = 0; i < heights.size(); i++) {
            int height = heights.get(i);
            // 0 が来て一区切りなので、ここまでをcalcCount()にかける。
            if (height == 0) {
                if (subHeights.size() != 0) {
                    calcCount(subHeights);
                    subHeights.clear();
                }
            }
            // 部分集合の最後まで来たので、ここまでをcalcCount()にかける。
            else if (i == (heights.size() - 1)) {
                subHeights.add(height);
                calcCount(subHeights);
                subHeights.clear();
            }
            else {
                subHeights.add(height);
            }
        }
    }

    // Main
    public static void main(String[] args) {
        new Main().solve();
    }
}

Measured memory_bytes: 21716
#include <iostream>
#include <iomanip>
#include <cstring>

using namespace std;

int n;
double dp[310][310][310];

double rec(int i,int j,int k){
    if(dp[i][j][k] >= 0) return dp[i][j][k];
    if((i == 0) && (j == 0) && (k == 0)) return 0.0;
    double res = 0.0;
    if(i > 0) res += rec(i-1,j,k) * i;
    if(j > 0) res += rec(i+1,j-1,k) * j;
    if(k > 0) res += rec(i,j+1,k-1) * k;
    res += n;
    res *= 1.0/(i+j+k);

    return dp[i][j][k] = res;
    }

int main(){
    int one = 0,two = 0,three = 0;
    cin >> n;
    int a;
    for (int i = 0; i < n; i++){
        cin >> a;
        if(a == 1) one++;
        else if (a == 2) two++;
        else three++;
    }
    memset(dp,-1,sizeof(dp));
    cout << fixed << setprecision(10) << rec(one,two,three) << endl; 
    return 0;
}

Measured memory_bytes: 233088
N,M = map(int,input().split())
rule = [[] for i in range(N)]
for i in range(M):
    p = 0
    a,b = map(int,input().split())
    if len(rule[a-1]) != 0:
        for j in range(len(rule[a-1])):
            if b == rule[a-1][j]:
                p = 1
        if p == 0:
            rule[a-1].append(b)
    else:
        rule[a-1].append(b)

if N == 1:
    if len(rule[0]) == 0:
        print(0)
    elif len(rule[0]) == 1:
        print(rule[0][0])
    else:
        print(-1)


else:
    k = 0
    for i in range(N):
        if len(rule[i]) >= 2:
            k = 1
            print(-1)
            break
    if k == 0:
        if len(rule[0]) == 0:
            print(1,end='')
            for i in range(1,N):
                if len(rule[i]) == 0:
                    print(0,end='')
                else:
                    print(rule[i][0],end='')
        else:
            if rule[0][0] == 0:
                print(-1)
            else:
                print(rule[0][0],end='')
                for i in range(1, N):
                    if len(rule[i]) == 0:
                        print(0, end='')
                    else:
                        print(rule[i][0], end='')


Measured memory_bytes: 38256
#!/usr/bin/env ruby
@ans = []

def k(sum, ary)
  return 0 if ary.count.zero?

  tmp = ary.pop
  @ans << (sum + tmp + k(sum + tmp, ary.dup))
  @ans << (sum + k(sum, ary.dup))

  0
end

gets
a = gets.split.map(&:to_i)
gets
m = gets.split.map(&:to_i)

k(0, a)

@ans.uniq!.sort!

m.each do |k|
  puts (@ans.include?(k)) ? 'yes' : 'no'
end

Measured memory_bytes: 25160
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N;
  cin >> N;
  
  int sum=0;
  
  for (int i=0;i<N;i++){
    int l,r;
    cin >> l >> r;
    sum+=r-l+1;
  }
	cout << sum << endl;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define lowbit(x) ((x) & (-(x)))
using namespace std;

typedef long long ll;
const int N = 1e5 + 10, inf = (int)1e9;
int n, a[N], sum[N * 10], C[N * 10];

void add(int x) {
    for (; x <= 2 * N; x += lowbit(x)) C[x]++;
}

ll query(int x) {
    ll ret = 0;
    for (; x; x -= lowbit(x)) ret += C[x];
    return ret;
}

bool chk(int x) {
    for (int i = 1; i <= 2 * N; i++) C[i] = 0;
    for (int i = 1; i <= n; i++) sum[i] = sum[i - 1] + (a[i] >= x ? 1 : -1);
    ll tot = 0;
    for (int i = 0; i <= n; i++) {
        tot += query(sum[i] + N);
        add(sum[i] + N);
    }
    return tot >= 1ll * n * (n + 1) / 4;
}

int main() {
    scanf("%d", &n);
    int l = inf, r = -inf;
    for (int i = 1; i <= n; i++) {
        scanf("%d", &a[i]);
        l = min(l, a[i]), r = max(r, a[i]);
    }
    while (l <= r) {
        int mid = (l + r) >> 1;
        if (chk(mid)) l = mid + 1;
        else r = mid - 1;
    }
    printf("%d\n", r);
    return 0;
}


Measured memory_bytes: 7168
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

int main(){
	string S,T; cin >> S >> T;
	int N = S.size();
	int M = T.size();
	for(int i = N-M; i >= 0; i--){
		if(S[i] == T[0] || S[i] == '?'){
			bool ok = true;
			repr(j,i,i+M){
				if(S[j] != T[j-i] && S[j] != '?') ok = false;
			}
			if(ok){
				repr(j,i,i+M) S[j] = T[j-i];
				rep(j,N){
					if(S[j] == '?') S[j] = 'a';
				}
				cout << S << endl;
				return 0;
			}
		}
	}
	cout << "UNRESTORABLE" << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
const long long mod = 1e9 + 7;

int main()
{
    int n, k;
    cin >> n >> k;
    double ans = 0;
    for (int i = 1; i <= n; i++)
    {
        int count = 0;
        int x = i;
        while (true)
        {
            if (x < k)
            {
                x = x << 1;
                count++;
            }
            else
            {
                break;
            }
        }
        ans += pow(0.5, count) / n;
    }
    cout << setprecision(12) << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner io = new Scanner(System.in);
		long N = io.nextLong();
		
		long ans = Long.MAX_VALUE;
		for(long i=1;i*i<=N;i++){
			if(N%i==0){
				ans = Math.min(ans,
						Math.max(String.valueOf(i).length(),
								String.valueOf(N/i).length())
						);
			}
		}
		
		System.out.println(ans);
	}
}


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

const int MAX_N = 1e5 + 5;
int n, ans;
int Arr[MAX_N];
unordered_map <int, int> cnt[2][2], Mark;
unordered_map <int, int>::iterator it;

void calc(int x) {
	for (int i = 0; i < n; i++)
		cnt[x][i & 1][Arr[i]]++;
}

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

	calc(0);
	sort(Arr, Arr + n);
	calc(1);

	for (it = Mark.begin(); it != Mark.end(); it++)
		ans += abs(cnt[0][0][it->first] - cnt[1][0][it->first]);

	printf("%d", ans >> 1);
	return 0;
}
// 

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

int main(){
        
    int num[3];
    for(int i = 0; i < 3; i++){
        cin >> num[i];
    }
    sort(num, num + 3, greater<int>());

    int ret = (num[0] * 10 + num[1] + num[2]);
    cout << ret << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
// please, read the question correctly (do you need set or multiset)???
const int N=22; //check the limits, dummy
ll x[N], y[N], p[N];
ll n, m;
int main(){
	int t;
	scanf("%lld",&n);
	vector<pair<int, int>> v1,v2, v3, v4;
	for(int i=0; i<n; ++i){
		scanf("%lld%lld%lld",x+i, y+i, p+i);
		// x[i]=y[i]=p[i]=1;
		v1.push_back(mk(x[i], i));
		v2.push_back(mk(y[i], i));
		v3.push_back(mk(x[i], i));
		v4.push_back(mk(y[i], i));
	}
	sort(v1.begin(), v1.end());
	sort(v2.begin(), v2.end());
	sort(v3.begin(), v3.end());
	sort(v4.begin(), v4.end());
	reverse(v3.begin(), v3.end());
	reverse(v4.begin(), v4.end());
	ll ans[22];
	for(int i=0; i<=n; ++i){
		ans[i]=1e18;
	}
	ll mn[22];
	int fl[22];
	for(int i=0; i<(1<<n); ++i){
		vector<int> v;
		for(int j=0; j<n; ++j){
			if((1<<j)&i){
				v.push_back(j);
			}
		}
		int sz=v.size();
		for(int j=0; j<(1<<sz); ++j){
			for(int k=0; k<n; ++k){
				mn[k]=min(abs(x[k]), abs(y[k]));
				fl[k]=-1;
			}
			for(int k=0; k<sz; ++k){
				if((1<<k)&j){
					fl[v[k]]=0;
				}
				else{
					fl[v[k]]=1;
				}
			}
			int lst=-1e9;
			for(auto it:v1){
				if(fl[it.sc]==0){
					lst=it.fs;
				}
				mn[it.sc]=min(mn[it.sc], (ll)it.fs-lst);
			}
			lst=1e9;
			for(auto it:v3){
				if(fl[it.sc]==0){
					lst=it.fs;
				}
				mn[it.sc]=min(mn[it.sc], (ll)lst-it.fs);
			}
			lst=-1e9;
			for(auto it:v2){
				if(fl[it.sc]==1){
					lst=it.fs;
				}
				mn[it.sc]=min(mn[it.sc], (ll)it.fs-lst);
			}
			lst=1e9;
			for(auto it:v4){
				if(fl[it.sc]==1){
					lst=it.fs;
				}
				mn[it.sc]=min(mn[it.sc], (ll)lst-it.fs);
			}
			ll tmp=0;
			for(int l=0; l<n; ++l){
				tmp+=mn[l]*p[l];
			}
			ans[sz]=min(ans[sz], tmp);
		}
	}
	for(int i=0; i<=n; ++i){
		cout<<ans[i]<<endl;
	}
}

Measured memory_bytes: 3680
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

template <class T>
bool INRANGE(T x, T a, T b) { return a <= x && x <= b; }
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;
}

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(v) (v).begin(), (v).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

double fact(int n) {
    double res = 1;
    FOR(num, 1, n+1) {
        res*=num;
    }
    return res;
}

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

    int n;
    cin >> n;

    vector<pii> p;
    REP(_, n) {
        int x, y;
        cin >> x >> y;
        p.emplace_back(make_pair(x, y));
    }

    vi iv(n);
    iota(ALL(iv), 0);

    double ans = 0;
    double fc = fact(n);

    do {

        double tmp = 0;
        REP(i, n-1) {
            pii p1 = p[iv[i]];
            pii p2 = p[iv[i+1]];

            tmp += sqrt((p1.first-p2.first)*(p1.first-p2.first) + (p1.second-p2.second)*(p1.second-p2.second));
        }
        ans += tmp/fc;
    } while (std::next_permutation(ALL(iv))); 

    cout << setprecision(12) << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int gcd(int a,int b,int c)
{
	int i;
	if(a==b&&a==c)
	return a;
	else if((a==b&&a!=c)||(a==c&&a!=b)||(b==c&&a!=b))
	{
		for(i=a;i>=1;i--)
		{
			if(a%i==0&&b%i==0&&c%i==0)
			break;
		}
		return i*3;
	}
	else
	{
		for(i=a;i>=1;i--)
		{
			if(a%i==0&&b%i==0&&c%i==0)
			break;
		}
		return i*6;
	}
}
int main()
{
	int n;
	cin>>n;
	int s=0;
	int i,j,k;
	for(i=1;i<=n;i++)
		for(j=i;j<=n;j++)
			for(k=j;k<=n;k++)
			{
				s+=gcd(i,j,k);
			}
	cout<<s<<endl;
}

Measured memory_bytes: 3632
import math
 
 
a,b,h,m=map(int, input().split())
 
 
d = 30*(h+m/60)-6*m
e = 360-d
f = min(d,e)
y = math.cos(math.radians(f))
 
 
x = a**2+b**2-2*a*b*y
z = float(math.sqrt(x))
print("{0:.20f}".format(z))

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

int main() {
    int N, count = 0;
    string S;
    cin >> N >> S;
    for (int i = 0; i < S.size() - 1; i++) {
        if (S.at(i) == S.at(i + 1)) count++;
    }
    int ans = N - count;
    cout << ans << endl;
}

Measured memory_bytes: 512
#include <iostream>

using namespace std;

int main(){

int W,H;
while(1){
 cin >> H >> W;
 if((H==0)&&(W==0))break;
for(int i=0;i<H;i++){
 for(int j=0;j<W;j++){
  if((i%2)==0){ 
   if((j%2)==0){
    cout << '#';
   }else{
    cout << '.';
   }
  }else{
   if((j%2)==0){
    cout << '.';
   }else{
    cout << '#';
   }
  }
 }
 cout << "\n";
}
cout << "\n";

}

return 0;
}

Measured memory_bytes: 1124
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define MOD 998244353
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;}
const long long INF = 1LL << 60;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}
//四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

struct edge{//グラフに使うヤツ
    ll from,to,cost;
};

typedef vector<vector<edge> > G;
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}

int main(){
    ll n,k;
    cin >> n >> k;
    ll a[n];
    for (ll i=0;i<n;i++)cin >> a[i];
    sort(a,a+n);
    ll ans=0;
    for (ll i=0;i<k;i++){
        ans+=a[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <iomanip>
#include <fstream>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <algorithm>
#include <numeric>
#include <utility>
#include <random>
#include <chrono>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>

using namespace std;

using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
using PIL = pair<int, LL>;
using PLL = pair<LL, LL>;
// const int mod = 1e9 + 7;
// const int mod = 998244353;

inline void quickread() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}

inline void work() {
    int x;
    cin >> x;
    cout << 1 - x << "\n";
}

int main() {
    // freopen("input.txt", "r", stdin);
    quickread();
    work();
    return 0;
}

Measured memory_bytes: 3152
#include <stdio.h>

int main(void) {

  int h1,m1,h2,m2,k;
  scanf("%d %d %d %d %d", &h1, &m1, &h2, &m2, &k);
  int time1,time2;
  time1 = h1*60+m1;
  time2 = h2*60+m2;
  int awake = time2-time1;
  int ans = awake-k;
  printf("%d\n", ans);

  return 0;
}

Measured memory_bytes: 1736
#!/usr/bin/env python
from itertools import combinations
N, M = map(int, input().split())
K = [[int(i) for i in input().split()] for i in range(M)]
P = [int(i) for i in input().split()]

A = [0]*N
cnt = 0
a_sum = 0
for m in range(M):
    for y in K[m][1:]:
        a_sum += A[y-1]
    if a_sum % 2 != P[m]:
        break
        a_sum = 0
else:
    cnt += 1
for i in range(N):
    for x in list(combinations(range(N), i+1)):
        for e in x:
            A[e] = 1
        for m in range(M):
            a_sum = 0
            for y in K[m][1:]:
                a_sum += A[y-1]
            if a_sum % 2 != P[m]:
                break
        else:
            cnt += 1
        A = [0]*N
print(cnt)

Measured memory_bytes: 3188
#include <algorithm>

#include <bitset>

#include <tuple>

#include <cstdint>

#include <cstdio>

#include <cctype>

#include <assert.h>

#include <stdlib.h>

#include <stdio.h>

#include <cassert>

#include <cfloat>

#include <climits>

#include <cmath>

#include <complex>

#include <ctime>

#include <deque>

#include <fstream>

#include <functional>

#include <iomanip>

#include <iostream>

#include <iterator>

#include <list>

#include <limits>

#include <map>

#include <memory>

#include <queue>

#include <random>

#include <set>

#include <stack>

#include <string>

#include <unordered_map>

#include <unordered_set>

#include <utility>

#include <vector>

#include <math.h>
using namespace std;
int main() {
    string S, T;
    cin >> S >> T;
    int Tsize = T.size();
    if (T.substr(0, Tsize-1) == S) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}
  

Measured memory_bytes: 3628
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define pii pair < ll , ll >
#define F first
#define S second
#define int long long int
#define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define err(A) cout << #A << " = " << (A) << endl
using namespace std;


int32_t main(){
    ll a,b;
    cin >> a >> b;
    if (a<b){
        cout << 0;

    }
    else{
        cout << 10;
    }
    return 0;
}


Measured memory_bytes: 256
function Main(input) {
	input = input.split("\n");
	var M = input[0].split(" ").map(a => parseInt(a));
	var N = M[0];
	M = M[1];
	var L = [], R = [], D = [];
	var x = new Array(N).fill(0);
	var x2 = new Array(N);
	var ans = "Yes";
	for(var i = 0; i < N; i++){x2[i] = [];}
	for(i = 0; i < M; i++){
		L[i] = input[i+1].split(" ").map(a => parseInt(a));
		R[i] = L[i][1]-1;
		D[i] = L[i][2];
		L[i] = L[i][0]-1;
		x2[L[i]].push(R[i], D[i]);
		x2[R[i]].push(L[i], -D[i]);
	}
	
	for(i = 0; i < N; i++){
		var j = x2[i].length - 2;
		var x3 = [];
		if(j >= 0){
			set_x(i, j);
		}
		for(var k = 0; k < x3.length; k++){
			j = x2[x3[k]].length - 2;
			if(j >= 0){
				set_x(x3[k], j);
			}
		}
	}
	
	for(i = 0; i < M; i++){
		if(x[R[i]] - x[L[i]] !== D[i]){
			ans = "No";
			break;
		}
	}
	
	console.log(ans);
	
	function set_x(i, j){
		do{
			if(x2[x2[i][j]].length > 0)x3.push(x2[i][j]);
			x[x2[i][j]] = x[i] + x2[i][j+1];
			j -= 2;
		}while(j >= 0)
		x2[i] = [];
	}
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 104392
#include<cstdio>

int main(){

  int W;
  int a, b;
  int aR, bR;

  scanf("%d %d %d", &W, &a, &b);

  aR = a+W;
  bR = b+W;
  if(aR <= b) printf("%d", b - aR);
  else if(bR <= a) printf("%d", a - bR);
  else printf("0");

  return 0;

}


Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;

int main()
{
  cout << setprecision(6);
  cout << setiosflags(ios::scientific);
  cout.flags(ios::fixed);

  while(true){
    int h, w;
    cin >> h >> w;

    if(h==0&&w==0)
      break;

    for(int i=0; i<h; i++){
      for(int j=0; j<w; j++){
	if((i+j)%2==0)
	  cout << "#";
	else
	  cout << ".";
      }
      cout << endl;
    }
    cout << endl;
  }
}

Measured memory_bytes: 1156
using System.Linq;
using System.Text;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Security.Cryptography.X509Certificates;
using System.Diagnostics;
using System.Reflection.Metadata;
using System.Threading;

namespace AtCoder
{
    class Program
    {

        struct Point
        {
            public int x;
            public int y;

            public Point(int x, int y)
            {

                this.x = x;
                this.y = y;

            }

        }


        const int BiggestMod = 1000000007;

        public static void Main()
        {

            var args = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var n = args[0];
            var k = args[1];
            args = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

            for (int i = k; i < n; i++)
                Console.WriteLine((args[i] > args[i - k] ? "Yes" : "No"));

        }

    }

}

Measured memory_bytes: 46460
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n)  for (int i = 0; i < (int) (n); i++)
#define REP1(i, n) for (int i = 1; i <= (int) (n); i++)
#define all(x)     (x).begin(), (x).end()
#define SZ(x)      ((int) (x).size())
using ll = long long;

int main() {
  int a, b;
  cin >> a >> b;
  int ans = -1;
  REP(i, 100000) {
	if (2 * i / 25 == a && i / 10 == b) {
		ans = i;
		break;
	  }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds; 
#define ll          long long int
#define ull         unsigned long long int
#define pb          push_back
#define pii         pair<int,int>
#define F           first
#define S           second
#define vi          vector<int>
#define vli          vector<ll>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define M_PI        3.14159265358979323846
#define mp          make_pair
#define sz(x)       (int)x.size()
#define matrix      vector<vector<ll>>
#define forn(i,a,b)  for(int i=a;i<b;i++)
#define eps 0.0000000001
#define all(a)      (a).begin(),(a).end()
#define ordered_set     tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> 

const long long INF = (long long) 1e11+1;
const long long mod = (long long) 100000000 ;
const long long hell = (long long) 1000000007;


ll power(ll x,ll y)
{
  ll res=1;
  while(y>0){
    if(y%2) res=(x%mod*res%mod)%mod;
    x=(x%mod*x%mod)%mod;    
    y=y/2;
  }
  return res;
}

ll modinv(ll x){
  return power(x,mod-2);
}

void solve();


void fastIO() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}

ll gcd(ll a,ll b)
{
    while( b != 0)
	{
		ll  t = b;
		b= a %t;
		a = t;
	}
	return a;
}

int main(){
   fastIO();
   int test;
   //cin>>test;
   test=1;
   
   while(test--)
   solve();
}



void solve(){
    ll x;
    cin>>x;
    ll ans=0;
    ll f=x/500;
    ans+=f*1000;
    f=x%500;
    ans+=5*(f/5);
    cout<<ans;
}    


///Before submit=>
///    *check for integer overflow,array bounds
///    *check for n=1

/*
  For freq or prime factors

for(auto pri:prime){
  while(k%pri==0){
    pcnt[pri]++;
    k/=pri;
  }
}*/
// gcd of strings
/*
string getgcd(string s1,string s2){
    
    while(true){
        if(s1.length()<s2.length()){
            swap(s1,s2);
            continue;
        }
        if(s2.empty())
        return s1;
        
        if(s1.substr(0,s2.length())!=s2)
        return "";
        
        s1=s1.substr(s2.length());
    }
}
*/
/*
// for user defined DS hashmap and set
 
struct hash_pair{
      size_t operator()(const pair<int,pair<int,int>>& p) const{
          auto hash1=hash<int>()(p.F) ;
          auto hash2=hash<int>()(p.S.F) ;
          auto hash3=hash<int>()(p.S.S) ;
          return (hash1^hash2)^hash3;
      }  
};
struct pair_hash
{
	template <class T1, class T2>
	std::size_t operator () (std::pair<T1, T2> const &pair) const
	{
		std::size_t h1 = std::hash<T1>()(pair.first);
		std::size_t h2 = std::hash<T2>()(pair.second);

		return h1 ^ h2;
	}
};
*/



Measured memory_bytes: 256
import sys, threading
sys.setrecursionlimit(1 << 30)
threading.stack_size(1 << 27)


def main():
    n, *E = map(int, open(0).read().split())
    E = zip(*[iter(E)]*3)
    
    G = [[] for _ in [0]*n]
    for s, t, w in E:
        G[s].append((t, w))
        G[t].append((s, w))
    
    def dfs(v, p=-1, d=0):
        maxd = d
        maxv = v
        for u, w in G[v]:
            if u == p:
                continue
            _d, _v = dfs(u, v, d+w)
            if _d > maxd:
                maxd, maxv = _d, _v
        return maxd, maxv
    
    _, v = dfs(n//2)
    ans, _ = dfs(v)
    
    print(ans)


if __name__ == '__main__':
    threading.Thread(target=main).start()


Measured memory_bytes: 174712
#include <iostream>
#include <algorithm>
#include <vector> //動的配列
#include <string>
#include <list> //双方向リスト
#include <map> //連想配列
#include <set> //集合
#include <stack>
#include <queue>
#include <deque>
#include <cmath>
#include <bitset>


//小さい順から取り出すヒープ
//priority_queue<ll, vector<ll>, greater<ll> > pque1;

typedef long long ll;


using namespace std;

typedef pair<int, ll> P;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)



ll fast_pow(ll x,ll n,ll mod){
    if (n==0) return 1;
    ll res=fast_pow(x*x %mod,n/2,mod);
    if (n&1) res=res*x%mod;
    return res;
}

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}




int main(){
    string S,T;
    cin>>S>>T;
    int ls=S.length(),lt=T.length();
    int dp[ls+1][lt+1];
    //cout<<S[ls]<<lt;
    //直前にどこから来たかを記録する
    //０で斜め上、１で横、２で上
    int memo[ls][lt];
    //dpテーブルの初期化
    fill(dp[0],dp[ls],0);
    fill(memo[0],memo[ls],5);
    for (int i=0;i<ls;i++){
        for (int j=0;j<lt;j++){
            if (S[i]==T[j]) {
                dp[i+1][j+1]=dp[i][j]+1;
                memo[i][j]=0;
            }
            if (S[i]!=T[j]){
                dp[i+1][j+1]=max(dp[i+1][j],dp[i][j+1]);
                if (dp[i+1][j]<=dp[i][j+1]) memo[i][j]=1;
                if (dp[i][j+1]<dp[i+1][j]) memo[i][j]=2;
            }
        }
    }
    //cout<<dp[ls][lt];
    
    //答えの記録、逆になる
    vector<char> vec={};
    ls--;lt--;
    while (ls>=0 && lt>=0){
        if (memo[ls][lt]==0) {
            vec.push_back(S[ls]);
            ls--;
            lt--;
        }
        if (memo[ls][lt]==1) ls--;
        if (memo[ls][lt]==2) lt--;
    }
    reverse(begin(vec),end(vec));
    for (auto e:vec) cout<<e;
}


Measured memory_bytes: 70656
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	int n; cin >> n;
	vi a(n);
	rep(i, n) cin >> a[i];
	
	
	ll lb = 2, ub = 2;
	for(int i = n - 1; i >= 0; i--){
		ll k = a[i];
		ll x = (lb + k - 1) / k * k;
		ll y = ub / k * k;
		
		if(x > y){
			cout << -1 << endl;
			exit(0);
		}
		lb = x;
		ub = y + k - 1;
	}
	cout << lb << " " << ub << endl;
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    string s;
    cin >> s;
    int n = s.size();
    VI l,r;
    REP(i,0,n) {
        if (s[i] == 'L') l.push_back(i);
        else r.push_back(i);
    }
    VI c(n);
    REP(i,0,n) {
        int dst;
        if (s[i] == 'R') {
            dst = *lower_bound(all(l),i);
            if ((dst - i) % 2 == 0) c[dst]++;
            else c[dst-1]++;
        }
        else {
            dst = *(lower_bound(all(r),i) - 1);
            if ((i - dst) % 2 == 0) c[dst]++;
            else c[dst+1]++;
        }
    }
    REP(i,0,n) {
        if (i) cout << " ";
        cout << c[i];
    }
    cout << endl;
}

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

Measured memory_bytes: 1656
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <climits>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <complex>

using namespace std;
using pii = pair<int, int>;
using ll = long long;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	string s;
	cin >> s;
	int answer = 0;
	for (int i = 0; i <= s.length() - 3; i++) if (s.substr(i, 3) == "ABC") answer += 1;
	cout << answer;
	return 0;
}


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

char Judge(string WordT, string WordH){
	for(int i = 0; i < min(WordT.size(), WordH.size()); i++){
		if(WordT[i] > WordH[i]) return 'T';
		if(WordT[i] < WordH[i]) return 'H';
	}
	if(WordT.size() >  WordH.size()) return 'T';
	if(WordT.size() <  WordH.size()) return 'H';
	return 'D';
}

int main(){
	//???????????????????????°n????????????
	int n;
	cin >> n;
	//???????????????????????????????????????????????????????????¨????????????????????????
	int PointT = 0;
	int PointH = 0;
	for(int i = 0; i < n; i++){
		string WordT;
		string WordH;
		cin >> WordT >> WordH;
		if(Judge(WordT, WordH) == 'T') PointT += 3;
		if(Judge(WordT, WordH) == 'D') PointT++, PointH++;
		if(Judge(WordT, WordH) == 'H') PointH += 3;
	}
	//????¨????????????¨?????????
	cout << PointT << " " << PointH << endl;
	return 0;
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define RFOR(i, start, end) for (int i = start; end <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1000000007
using ll = long long;
using namespace std;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

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

    int N, M;
    cin >> N >> M;
    vector<int> a(N), b(N), c(M), d(M);
    REP(i, N) cin >> a[i] >> b[i];
    REP(i, M) cin >> c[i] >> d[i];

    vector<int> ans(N);
    REP(i, N) {
        int mindist = (int)1E9;
        int index;
        REP(j, M) {
            int now = abs(a[i] - c[j]) + abs(b[i] - d[j]);
            if (chmin(mindist, now))
                index = j;
        }
        ans[i] = index + 1;
    }

    for (auto &i : ans) {
        std::cout << i << '\n';
    }

    return 0;
}

Measured memory_bytes: 256
// ALDS1_11_A
#include <iostream>
#include <vector>
using namespace std;

int main(){
	int n, u, k;
	vector<vector<int> > A;

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

	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)
			A[i][j] = 0;

	for(int i=0;i<n;i++){
		cin>>u>>k;
		int v;
		
		for(int j=0;j<k;j++){
			cin>>v;
			A[u-1][v-1] = 1;
		}
	}

	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			if(j!=0)
				cout<<" ";
			cout<<A[i][j];
		}
		cout<<endl;
	}

	return 0;
}

Measured memory_bytes: 1244
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <deque>
#include <map>
#include <bits/stdc++.h>
#include <set>

#define ll long long
#define inf 0x3f3f3f3f
#define il inline

namespace io {

#define in(a) a = read()
#define out(a) write(a)
#define outn(a) out(a), putchar('\n')

#define I_int ll
inline I_int read() {
    I_int x = 0, f = 1;
    char c = getchar();
    while (c < '0' || c > '9') {
        if (c == '-') f = -1;
        c = getchar();
    }
    while (c >= '0' && c <= '9') {
        x = x * 10 + c - '0';
        c = getchar();
    }
    return x * f;
}
char F[200];
inline void write(I_int x) {
    if (x == 0) return (void) (putchar('0'));
    I_int tmp = x > 0 ? x : -x;
    if (x < 0) putchar('-');
    int cnt = 0;
    while (tmp > 0) {
        F[cnt++] = tmp % 10 + '0';
        tmp /= 10;
    }
    while (cnt > 0) putchar(F[--cnt]);
}
#undef I_int

}
using namespace io;

using namespace std;

#define N 100010

char s[5];
int main(){
	int n;
	long double x,sum=0;
	n = read();
	for(int i=1;i<=n;i++){
		scanf("%Lf %s",&x,s);
		if(s[0]=='J') sum+=x;
		else sum+=x*380000.0;
	}
	printf("%Lf",sum);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
  int  x,n,i,m,s=0,b=0,c,d;
  cin>>x>>n;
  int a[n];
  for(i=0;i<n;i++) cin>>a[i];
  if(n==0) cout<<x<<endl;
  else {
  sort(a,a+n);
  if(find(a,a+n,x)-a==n) cout<<x<<endl;
  else {
  for(i=1;i<x;i++)
  {
     if( (find(a,a+n,x-i)-a)== n)
     {
         s=x-i;
         break;
     }
  }
   for(i=1;i<x;i++)
     if( (find(a,a+n,x+i)-a )==n)
     {
         b=x+i;
         break;
     }

if(s==0) cout<<b<<endl;
else if(b==0) cout<<s<<endl;
else
{
    c=b-x; d=x-s;
    if(c==d) cout<<min(s,b)<<endl;
    else if(c>d) cout<<s<<endl;
    else cout<<b<<endl;
}

  }
}
}


Measured memory_bytes: 3640
#include <stdio.h>

int main(void)
{
	char str[1001], o[8];
	int q, a, b;
	scanf("%s", str);
	scanf("%d", &q);
	for (int i = 0; i < q; i++) {
		scanf("%s", o);
		scanf("%d %d", &a, &b);
		if (o[0] == 'p') {
			for (int j = a; j <= b; j++ ) {
				printf("%c", str[j]);
			}
			printf("\n");
		} else if (o[2] == 'p') {
			char p[b - a + 2];
			scanf("%s", p);
			for (int j = 0; j < b - a + 1; j++) {
				str[a + j] = p[j];
			}
		} else {
			char tmp[b - a + 1];
			for (int j = 0; j < b - a + 1; j++) {
				tmp[j] = str[b - j];
			}
			for (int j = 0; j < b - a + 1; j++) {
				str[j + a] = tmp[j];
			}
		}
	}
	return 0;
}



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

using namespace std;

#define PB push_back
#define MP make_pair
#define f first
#define s second
#define FOR(i,a,b) for (int i = a; i < b; ++i)
#define RFOR(i, b, a) for (int i = b-1; i>=a; --i)
#define FILL(a, b) memset(a, b, sizeof a)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)a.size()

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef pair<LL, LL> PLL;

const int INF = 1000 * 1000 * 1000;
const LL LINF = 1LL * INF*INF;
const int MAX = 100010;
const long double PI = acos(-1.);
const double EPS = 1e-6;
LL mod = 1000LL*1000*1000 + 7;

VI g[100*1000+7];
int u[100*1000+7];
int dfs(int v,int v2)
{
	if(v==v2)
		return 1;
	u[v] = 1;
	FOR(i,0,SZ(g[v]))
		if(!u[g[v][i]])
			return dfs(g[v][i],v2);
	return 0;
}

int main()
{
	ios_base::sync_with_stdio(0); double startClock = clock();
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
	int n;
	cin >> n;
	VI arr(n);
	FOR(i,0,n)
	{
		cin >> arr[i];
	}
	VI res;
	FOR(i,0,n)
	{
		int cnt = 0;
		int pos = -1;
		FOR(j,0,n)
		{
			if(arr[j]==-1) continue;
			cnt++;
			if(arr[j]==cnt)
				pos = j;
		}
		if(pos==-1)
		{
			cout << -1;
			return 0;
		}
		res.PB(arr[pos]);
		arr[pos] = -1;
	}
	reverse(ALL(res));
	FOR(i,0,n)
		cout << res[i] << endl;







	cerr << endl << (clock() - startClock)/CLOCKS_PER_SEC << endl;return 0;
}


Measured memory_bytes: 2560
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

fn main() {
    input!{
        n: usize,
        mut ab: [(usize, usize); n],
    }
    let mut acc = 0;
    ab.sort_by_key(|&(_, b)| b);
    for (a, b) in ab {
        if acc + a <= b {
            acc += a;
        } else {
            println!("No");
            return;
        }
    }
    println!("Yes");
}


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

  vector<int> L(n);
  for(int i=0;i<n;i++){
    cin>>L.at(i);
  }

  sort(L.begin(),L.end(),greater<int>());

  int64_t sum=0;
  for(int i=0;i<k;i++){
    sum+=L.at(i);
  }

  cout<<sum<<endl;
 

	return 0;
}

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

typedef long long ll;
typedef int64_t i6;
typedef std::vector<std::vector<int64_t> > Graph;

#define rep(i, n) for (int64_t i = 0; i < n; ++i)
#define rep2(i, n) for (int64_t i = 1; i <= n; ++i)
#define ALL(v) (v).begin(), (v).end()
#define Sort(x) sort(ALL(x))
#define Sort_rev(x) Sort(x);reverse(ALL(x))
#define Push_back(p, a, b) (p).push_back( make_pair( (a), (b) ) )

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;  } return 0;  }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;  } return 0;  }
template<typename V,typename T> bool find_num(V v, T num) { if ( find(ALL(v), num) == v.end() ) { return false; } return true; }

// π M_PI
// deg = rad*180/M_PI

int main() {
    int64_t a[2], b[2];
    rep(i, 2) {
        cin >> a[i] >> b[i];
    }
    int64_t n;
    cin >> n;
    int64_t ans = 0;
    int64_t A = a[0]*60+b[0];
    int64_t B = a[1]*60+b[1];
    ans = B-A-n;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3596
from sys import stdin


def dfs(e, ans, graph, done, N):
    if sum(done) == N:
        ans += 1
        return ans
    for s in graph[e]:
        if not done[s]:
            done[s] = True
            ans = dfs(s, ans, graph, done, N)
            done[s] = False
    return ans


def main():
    lines = stdin.readlines()
    N, M = map(int, lines[0].split())
    graph = []
    for i in range(N):
        graph.append([])
    for i in range(1, M + 1):
        a, b = map(int, lines[i].split())
        # 0-based indexing
        graph[a - 1].append(b - 1)
        graph[b - 1].append(a - 1)
    ans = 0
    done = [False] * N
    done[0] = True
    print(dfs(0, ans, graph, done, N))
    return


main()


Measured memory_bytes: 3064