akhauriyash/Code-Regression huggingface dataset:
import collections

factors = [[],[1]]
for i in range(2,1001):
    temp = []
    div = 2
    while div <= i and 1 < i:
        if i%div == 0:
            temp.append(div)
            i = i//div
        else:
            div += 1
    factors.append(temp)

mod = int(1e9+7)
n = int(input())
if n == 1:
    print(1)
else:
    div = []
    for i in range(2,n+1):
        for k in range(len(factors[i])):
            div.append(factors[i][k])
    s = collections.Counter(div)
    ans = 1
    for i in s:
        ans = ans*(s[i]+1)%mod
    print(ans)

Measured memory_bytes: 3444
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder.ABC113.A
{
    class Program
    {
        static void Main()
        {
            var sc = new Scanner();
            var n = sc.Nextint();
            var T = sc.Nextint();
            var A = sc.Nextint();
            var H = sc.Arrayint(n);

            var nearestTemp = double.MaxValue;
            var nearestPoint = -1;
            for (int i = 0; i < n; i++)
            {
                var temp = T - H[i] * 0.006;
                Console.Error.WriteLine(temp);
                var gap = Math.Abs(A - temp);
                if (gap < nearestTemp)
                {
                    nearestTemp = gap;
                    nearestPoint = i + 1;
                }
            }
            Console.WriteLine(nearestPoint);
        }
    }

    class Scanner
    {
        string[] s;
        long i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string Next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return Next();
            i = 0;
            return s[i++];
        }

        public int Nextint()
        {
            return int.Parse(Next());
        }
        public int[] Arrayint(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = Nextint() + add;
            }
            return Array;
        }

        public long NextLong()
        {
            return long.Parse(Next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (long i = 0; i < N; i++)
            {
                Array[i] = NextLong() + add;
            }
            return Array;
        }

        public double NextDouble()
        {
            return double.Parse(Next());
        }

        public double[] ArrayDouble(long N, double add = 0)
        {
            double[] Array = new double[N];
            for (long i = 0; i < N; i++)
            {
                Array[i] = NextDouble() + add;
            }
            return Array;
        }

        public decimal NextDecimal()
        {
            return decimal.Parse(Next());
        }

        public decimal[] ArrayDecimal(long N, decimal add = 0)
        {
            decimal[] Array = new decimal[N];
            for (long i = 0; i < N; i++)
            {
                Array[i] = NextDecimal();
            }
            return Array;
        }
    }
}


Measured memory_bytes: 13204
def function(n):
    digit=len(str(n))
    N=str(n)
    if digit<3:
        return 0
    else:
        k=int(N[0])
        m=int(N[1])
        if k<3:
            return function(10**(digit-1)-1)
        elif k==3 and m>0:
            return function(10**(digit-1)-1)+function(n%(10**(digit-1)))-function(10**(digit-2))+subfunction(5,7,n%(10**(digit-1)))
        elif k==3 and m==0:
            return function(10**(digit-1)-1)
        elif k==4:
            return function(4*(10**(digit-1))-1)
        elif k==5 and m>0:
            return function(4*(10**(digit-1))-1)+function(n%(10**(digit-1)))-function(10**(digit-2))+subfunction(3,7,n%(10**(digit-1)))
        elif k==5 and m==0:
            return function(4*(10**(digit-1))-1)
        elif k==6:
            return function(6*(10**(digit-1))-1)
        elif k==7 and m>0:
            return function(6*(10**(digit-1))-1)+function(n%(10**(digit-1)))-function(10**(digit-2))+subfunction(3,5,n%(10**(digit-1)))
        elif k==7 and m==0:
            return function(6*(10**(digit-1))-1)
        else:
            return function(8*(10**(digit-1))-1)

def subfunction(a,b,n):
    digit=len(str(n))
    N=str(n)
    k=int(N[0])
    if digit<2:
        return 0
    else:
        if k<a:
            return 0
        elif k==a:
            if n%(10**(digit-1))<b*(10**(digit-1)-1)//9:
                s=0
            else:
                s=1
            return subfunction(a,b,n%(10**(digit-1)))+s
        elif a<k<b:
            return subfunction(a,b,(a+1)*(10**(digit-1))-1)
        elif k==b:
            if n%(10**(digit-1))<a*(10**(digit-1)-1)//9:
                s=0
            else:
                s=1
            return subfunction(a,b,(a+1)*(10**(digit-1))-1)+subfunction(a,b,n%(10**(digit-1)))+s
        else:
            return subfunction(a,b,(b+1)*(10**(digit-1))-1)

N=int(input())
print(function(N))

Measured memory_bytes: 3192
#include<iostream>
#include<vector>
#include<iomanip>

int main(){
    int N, K;
    std::cin >> N >> K;
    
    std::vector< int > p(N);
    for(int i=0; i<N; i++){
        std::cin >> p[i];
    }
    
    int max = 0, tmp = 0;
    for(int i=0; i<K; i++){
        tmp += p[i];
    }
    max = tmp;
    
    for(int i=K; i<N; i++){
        tmp = tmp - p[i - K] + p[i];
        if(tmp > max){ max = tmp;}
    }
    
    double ans = (double)(max + K) / 2.0;
    std::cout << std::fixed << std::setprecision(12) << ans << std::endl;
    
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    ll stock = 0, money = 1000;
    rep(i, n) {
        // 購入
        {
            ll mv = a[i];
            bool exchange = false;
            reps(j, i + 1, n) {
                mv = min(mv, a[j]);
                if (a[j] > a[i]) {
                    exchange = true;
                    break;
                }
            }
            if ((exchange) && (mv == a[i])) {
                ll cnt = money / a[i];
                stock += cnt;
                money -= cnt * a[i];
            }
        }
        // 売却
        {
            ll mv = a[i];
            reps(j, i + 1, n) {
                mv = max(mv, a[j]);
                if (a[j] < a[i]) break;
            }
            if (mv == a[i]) {
                money += stock * a[i];
                stock = 0;
            }
        }
    }
    cout << money << endl;
    return 0;
}


Measured memory_bytes: 3660
#include <iostream>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cfloat>
#include <algorithm>
#include <numeric>
#include <vector>
#include <iterator>
#include <set>
using namespace std;

const double PI=acos(-1);

int main(){
    string s, t;
    cin >> s >> t;
    s += s;
    if(s.find(t) == std::string::npos){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <cassert>
using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> rate(n);
  for(auto& v : rate) {
    cin >> v;
  }

  int maxv = rate[1] - rate[0];
  int minv = rate[0];
  for(int i = 1; i < n; i++) {
    maxv = max(maxv, rate[i] - minv);
    minv = min(minv, rate[i]);
  }
  cout << maxv << endl;

  return 0;
}



Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
int maxx(int x, int y, int z)
{
	int p;
	if (x > y)
		p = x;
	else
		p = y;
	if (p < z)
		p = z;
	return p;
}
int main()
{
	int a, b;
	cin >> a >> b;
	int x, y, z;
	x = a + b;
	y = a - b;
	z = a * b;
	int t = maxx(x, y, z);
	cout << t << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const ll mo = 1000000007;
const ll INF = 1LL << 59; //MAX 9223372036854775807
ll ans = 0;

int main()
{
ll n;
cin >> n ;
multiset<ll> s;
ll ma=0;
rep(i, n){
  ll a;
  cin >> a;
  ma=max(ma,a);
  s.insert(a);
}
ll tar=1LL<<(64-__builtin_clzll(ma)+1);
while(tar!=1){
  auto itr=s.lower_bound(tar);
  ll siz=s.size();
  while(itr!=s.begin()){
    itr--;
    if(*itr<tar/2)break;
    auto fin=s.find(tar-*itr);
    if(fin!=s.end()&&*itr!=tar/2){
      ans++;
      s.erase(fin);
      itr=s.erase(itr);
    }
    else if(fin!=s.end()&&s.count(*itr)>1){
      ans+=s.count(*itr)/2;
      s.erase(*itr);
      break;
    }
  }
  tar/=2;
}

cout << ans << endl;
return 0;
}


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

#define CFOR(i, str) for(int i = 0; (str)[i]!='\0'; (i)++)
#define FOR(i, s, r) for(int i = (s); i < (r); i++)
#define INF 1e9
#define NINF -1e9
#define SUM(a) accumulate(a.begin(), a.end(), 0)
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v) sort(v.rbegin(), v.rend())
#define vmax(v) *max_element(v.begin(), v.end())
#define vmin(v) *min_element(v.begin(), v.end())
#define cnt(v, n) count(v.begin(), v.end(), (n))
#define vi vector<int>
#define vvi vector<vi>
#define vvvi vector<vvi>
#define vpii vector<pair<int, int>>
#define vpic vector<pair<int, char>>
#define mp make_pair

typedef long long ll;
typedef unsigned long long ulld;

using namespace std;

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


void solve(){
    int n;
    cin>>n;
    int arr[n];
    FOR(i, 0, n){
        cin>>arr[i];
    }
    int dp[n];
    dp[0] = 0;
    dp[1] = abs(arr[1] - arr[0]);
    FOR(i, 2, n){
        dp[i] = min(dp[i-1] + abs(arr[i] - arr[i - 1]), dp[i-2] + abs(arr[i] - arr[i - 2]));
    }
    // FOR(i, 0, n) cout<<dp[i]<<" ";
    cout<<dp[n-1];
}

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

    // // COMMENT BEFORE SUBMISSION /////////////////////////////////////////////////
    // clock_t start = clock();
    // //

    // int t;
    // cin>>t;

    // while(t--){
        solve();
    // }

    // //COMMENT BEFORE SUBMISSION /////////////////////////////////////////////////
    // clock_t stop = clock();
    // double elapsed = (double) (stop - start) / CLOCKS_PER_SEC;
    // cout<<setprecision(5)<<fixed;
    // cout<<"\nProcess finished in: "<<elapsed<<"s\n";
    
    return 0;

}



Measured memory_bytes: 4432
loop do
  n = gets.to_i
  break if n.zero?
  c, xs = 0, n.times.map { gets.to_i }
  n.downto 2 do |m|
    (m-1).times do |i|
      if xs[i] > xs[i+1]
        c += 1
        xs[i], xs[i+1] = xs[i+1], xs[i]
      end
    end
  end
  p c
end

Measured memory_bytes: 8744
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;

vector<long long> fact;
#define MOD 1000000007


long long mul_inv(long long a, long long b)
{
	long long b0 = b, t, q;
	long long x0 = 0, x1 = 1;
	if (b == 1) return 1;
	while (a > 1) {
		q = a / b;
		t = b, b = a % b, a = t;
		t = x0, x0 = x1 - q * x0, x1 = t;
	}
	if (x1 < 0) x1 += b0;
	return x1;
}

long long division(long long a, long long b, long long p) {		// (a / b) mod p = ((a mod p) * (b^(-1) mod p)) mod p
	long long ans, inv;
	inv = mul_inv(b, p);
	ans = ((a % p) * inv) % p;
	return ans;
}




long long calc(long long n, long long c) {
	if (c > n) return 0;
	long long a = fact[n], b = (fact[n - c] * fact[c]) % MOD;
	long long ans = division(a, b, MOD);
	return ans;
}

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

	long long n, m, i, j, k, r, b, ans, aa, bb, x, y;
	cin >> n >> k;
	fact.resize(n + 1);
	fact[0] = 1;
	for (i = 1; i <= n; i++) fact[i] = (fact[i - 1] * i) % MOD;

	//ans = 0;
	//for (i = 1; i <= m; i++) {		// # of patches of B
	//	aa = calc(b - 1, i - 1);
	//	if (i == 1) bb = r + 1;
	//	else {
	//		bb = 0;
	//		for (j = 1; j <= r; j++) {
	//			if (i == 2) x = 1;
	//			else x = calc(j, i - 1);
	//			y = (r + 1 - j);
	//			bb = (bb + x * y) % MOD;
	//		}
	//	}
	//	ans = (aa * bb) % MOD;
	//	cout << ans << "\n";
	//}

	for (i = 1; i <= k; i++) {
		aa = calc(n - k + 1, i);
		bb = calc(k - 1, i - 1);
		ans = (aa * bb) % MOD;
		cout << ans << "\n";
	}


	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 190;
const int MAXM = 18;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); } 
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
template <typename T> void write(T x) {
	if (x < 0) x = -x, putchar('-');
	if (x > 9) write(x / 10);
	putchar(x % 10 + '0');
}
template <typename T> void writeln(T x) {
	write(x);
	puts("");
}
char s[MAXN][MAXN]; int n, m;
int dp[MAXN][MAXN][MAXN][MAXM];
int main() {
	read(n), read(m);
	for (int i = 1; i <= n; i++)
		scanf("\n%s", s[i] + 1);
	for (int i = 1; i <= n; i++)
	for (int j = 1; j <= m; j++) {
		bool same = true; char col = s[i][j];
		for (int k = j; k <= m; k++) {
			if (s[i][k] != col) same = false;
			if (same) {
				if (s[i - 1][j] == s[i][j]) dp[i][j][k][0] = dp[i - 1][j][k][0];
				else dp[i][j][k][0] = i;
			} else dp[i][j][k][0] = i + 1;
		}
	}
	for (int i = 1; i <= n; i++)
	for (int len = 1; len <= m; len++) {
		for (int j = 1, k = len; k <= m; j++, k++) {
			for (int v = 1; v < MAXM; v++) {
				int tmp = dp[i][j][k][v - 1]; 
				if (tmp == 1) dp[i][j][k][v] = 1;
				else dp[i][j][k][v] = dp[tmp - 1][j][k][v - 1];
				int l = j, r = k - 1;
				while (l <= r) {
					int mid = (l + r) / 2;
					chkmin(dp[i][j][k][v], max(dp[i][j][mid][v - 1], dp[i][mid + 1][k][v - 1]));
					if (dp[i][j][mid][v - 1] > dp[i][mid + 1][k][v - 1]) r = mid - 1;
					else l = mid + 1;
				}
			}
		}
	}
	int ans = 0;
	while (dp[n][1][m][ans] != 1) ans++;
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 471424
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <vector>
#include <bitset>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <deque>
#include <string>
#include <list>
#include <iterator>
#include <algorithm>
#include <unordered_map>
#define int                long long
#define pb                 push_back
#define pi                 pair<int,int>
#define vi                 vector<int>
#define all(v)             v.begin(),v.end()
#define MOD                1000000007
#define F                  first
#define S                  second
#define FOR(i,r)           for(int i=0;i<r;i++)
#define REP(i,l,r)         for(int i=l;i<r;i++)
#define RER(i,l,r)         for(int i=l;i>=r;i--)
#define print(v)           for(auto i : v)cout << i << ' ';
#define FASTIO             ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mem(arr,k)         memset(arr,k,sizeof(arr));
#define pii                acos(-1.0)
#define PI                 3.1415926535897932385
#define Sin(a)             sin((pi*a)/180)
#define test()             int x;cin >> x;while(x--){solve();}
#define test2()            int x;cin >> x;for(int i=1;i<=x;i++){cout << "Case #" << i << " : ";solve();}
#define watch(x)           cout << (#x) << " is " << (x) << endl
using namespace std;


/* Mathematical Functions */
int power(int x,int y);
bool isPrime(int n);
int modInv(int a,int b);
int gcdExtended(int a,int b,int *x,int* y);
int mpower(int a,int b,int p);

const int inf = (int)1e17;
const int N = (int)3e5+5;

int32_t main(){

	
	FASTIO;
	int n,a,b;
	cin >> a >> b >> n;
	int r = min(b-1,n);
	cout << (a*r)/b - a*(r/b) << endl;
    return 0;

}
int modInv(int a, int m)
{
int x, y;
int g = gcdExtended(a, m, &x, &y);
int res = (x%m + m) % m;
return res;
}
 
int gcdExtended(int a, int b, int *x, int *y)
{
if (a == 0){
    *x = 0, *y = 1;
    return b;
  }
  int x1, y1;
  int gcd = gcdExtended(b%a, a, &x1, &y1);
  *x = y1 - (b/a) * x1;
  *y = x1;
  return gcd;
}
 
int mpower(int x, int y, int p)
{
int res = 1;
x = x % p;
while(y > 0){
    if(y & 1) res = (res*x) % p;
      y = y>>1;
      x = (x*x) % p;
    }
    return res;
}
int power(int x, int y)
{
int res = 1;
while (y > 0){
    if (y & 1) res = res*x;
      y = y>>1;
      x = x*x;
    }
    return res;
}
 
bool isPrime(int n)
{
if (n <= 1)  return false;
  if (n <= 3)  return true;
    if (n%2 == 0 || n%3 == 0) return false;
      int p=sqrt(n);
      for(int i=5;i<=p;i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
          return false;
      return true;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
#include<string.h>
#define ll long long 
#include<vector>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
const int mod=1e9+7;
int main(){
	IOS;
	int n,k;
	cin>>n>>k;
	vector<int> stones(n);
	for(int i=0;i<n;i++)
	cin>>stones[i];
	sort(stones.begin(), stones.end());
	bool dp[100005];
	memset(dp, false, sizeof(dp));
	dp[0]=false;
	for(int i=1;i<=k;i++){
		for(int j=0;j<n;j++){
			if(stones[j]<=i)
			{
			if(dp[i-stones[j]]==false)
			{
			dp[i]=true;
			break;
		}
			}
			else
			break;
		}
	}

if(dp[k])
cout<<"First";
else
cout<<"Second";
}

Measured memory_bytes: 3732
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();
    String[] s = new String[n];
    for (int i = 0; i < n; i++) {
      s[i] = sc.next();
    }

    int m = sc.nextInt();
    String[] t = new String[m];
    for (int i = 0; i < m; i++) {
      t[i] = sc.next();
    }

    int x = 0;
    int y = 0;

    for (int i = 0; i < n; i++) {
      x = 1;
      for (int j = i+1; j < n; j++) {
        if (s[i].equals(s[j])) x++;
      }
      for (int j = 0; j < m; j++) {
        if (s[i].equals(t[j])) x--;
      }
      y = Math.max(y, x);
    }

    System.out.println(y);
  }
}


Measured memory_bytes: 21844
a ,b = list(map(int,input().split()))

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
apri = prime_factorize(a)
bpri = prime_factorize(b)
ans_lis = []
for i in range(len(apri)):
    if bpri.count(apri[i]) > 0:
        bpri.remove(apri[i])
    ans_lis.append(apri[i])
ans_lis.extend(bpri)
ans = 1
for i in range(len(ans_lis)):
    ans = ans * ans_lis[i]
print(ans)

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
int main() {
  int N, M;
  cin >> N;
  map<string, int> countMap;
  for (int i{}; i < N; ++i) {
    string s; cin >> s;
    countMap[s] += 1;
  }
  cin >> M;
  for (int i{}; i < M; ++i) {
    string t; cin >> t;
    countMap[t] -= 1;
  }
  set<pair<string, int>, function<bool(pair<string, int>, pair<string, int>)>> countSet(countMap.begin(), countMap.end(),
      [](pair<string, int> elem1, pair<string, int> elem2) { return elem1.second > elem2.second; });
  cout << max(countSet.begin()->second, 0) << "\n";
  return 0;
}


Measured memory_bytes: 256
/* Author: Dhruv Rastogi */
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define all(sdk) sdk.begin(),sdk.end()
#define mll map<int, int>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;++i)
#define repd(i,a,b) for(int i=a;i>=b;--i)
#define mp make_pair
#define hell 1000000007
#define endl '\n'
#define vvll vector<vector<int> >
#define vll vector<int>
#define mint map<int,int> 
#define sz(x) (int)x.size()
#define sll set<int>
#define pll pair<int,int>
#define F first
#define S second
const long double PI = acos(-1.0);

const int N = 1e5+4;
vll ad[N],rem[N];
vector<pll> q[N];
int dist[N];

void solve(){  
    int n,m;
    cin>>n>>m;
    rep(i,0,m){
        int l,r,w;
        cin>>l>>r>>w;
        q[l].pb(mp(r,w));
    }
    multiset<int> active;
    rep(i,1,n+1){
        for(int j:ad[i]){
            active.insert(j);
        }
        if(i!=1 and active.empty()){
            cout<<-1<<endl;
            return;
        }
        dist[i] = (i==1?0:*active.begin());
        for(int j:rem[i]){
            active.erase(active.find(j));
        }
        for(auto j:q[i]){
            ad[i+1].pb(dist[i]+j.S);
            rem[j.F].pb(dist[i]+j.S);
        }  
    }  
    cout<<dist[n]<<endl;
}

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

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

int main() {

    int r,c,sum_r,total_sum=0;
    cin >> r >> c;
    int a[r+1][c+1];

    for (int i=0;i<=r;i++) {
        for (int j=0;j<=c;j++) {
            a[i][j]=0;
        }   
    }   

    for (int i=0;i<r;i++) {
        sum_r = 0;
        for (int j=0;j<c;j++) {
            cin >> a[i][j];
            sum_r += a[i][j];
            a[r][j] += a[i][j];
        }   
        a[i][c] = sum_r;
        total_sum += sum_r;
    }   
    a[r][c] = total_sum;
        
    for (int i=0;i<=r;i++) {
        for (int j=0;j<c;j++) {
            cout << a[i][j] << " ";
        }   
        cout << a[i][c] << endl;    
    }   
    
    return 0;
}   



Measured memory_bytes: 3024
#include <iostream>
using namespace std;
int main(){
    int h,w,n;
    cin >> h >> w >> n;
    if(h<w){
        int work = h;
        h=w;
        w=work;
    }
    int cnt=0;
    int x=0;
    while(w>0 && x<n){
        x+=h;
        cnt++;
        w--;
    }
    while(h>0 && x<n){
        x+=w;
        cnt++;
        h--;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int a,b,x;
    while(1){
        cin >> a >> b;
        if(a == 0){
            if(b == 0){
                break;
            }
            
        }
        if(a > b){
            x=a;
            a=b;
            b=x;
            
        }
    cout << a <<" "<< b <<endl;
}
return 0;
}


Measured memory_bytes: 3000
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

#define REP(i,a,b) for(int i=int(a);i<int(b);i++)

using namespace std;

typedef long long int lli;

int main () {
    int H, W;
    cin >> H >> W;
    vector<vector<char>> a(H, vector<char>(W));
    int cnt[26] = {0};
    REP (i, 0, H) REP (j, 0, W) {
        cin >> a[i][j];
        cnt[a[i][j] - 'a']++;
    }
    int d4 = 0, d2 = 0, d1 = 0;
    REP (i, 0, 26) {
        if (cnt[i] / 4) {
            d4 += cnt[i] / 4;
            cnt[i] %= 4;
        }
        if(cnt[i] / 2) {
            d2 += cnt[i] / 2;
            cnt[i] %= 2;
        }
        d1 += cnt[i];
    }

    if ((d1 <= (H % 2 && W % 2)) && (d2 <= (W % 2) * (H / 2) + (H % 2) * (W / 2)) && (((W % 2) * (H / 2) + (H % 2) * (W / 2) - d2) % 2 == 0)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define int ll
#define fr(i,a,b) for(ll i=a;i < b;i++)
#define fe(i,a,b) for(ll i=a;i <= b;i++)
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
#define pb push_back
#define fir first
#define sec second
#define tr(it,x) for(auto it = x.begin();it != x.end();it++)
#define mp make_pair
#define sz(x) (ll)x.size()
#define rep(i,n) for(ll i=0;i<n;i++)
#define double long double
#define accuracy ll precision = numeric_limits<double>::digits10
#define pll pair<ll,ll>
#define MAXN 100005
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define case(x) cout<<"Case #"<<x+1<<": "
#define endl "\n"
#define preturn(X) cout<<(X)<<endl; return 0
const int MOD = 1e9+7;
ll powmod(ll a,ll b,ll m=MOD){ll r=1;while(b>0){if(b&1)r=r*a%m;a=a*a%m;b>>=1;}return r;}
ll power(ll a,ll b){ll r=1;while(b>0){if(b&1)r=r*a;a=a*a;b>>=1;}return r;}
ll gcd(ll a,ll b){if(!b)return a;return gcd(b,a%b);}
ll inv(ll a, ll m = MOD){return powmod(a,m-2,m);}
ll lcm(ll a,ll b){return(a*b)/gcd(a,b);}

int H,W;

inline void addself(int &a, int b, int c){
    a = (c + b) % MOD;
}

int32_t main(){
    cin>>H>>W;
    vector<vector<bool>> grid(H,vector<bool> (W,false)); // if true wall is present
    rep(i,H)rep(j,W){
        char c;
        cin>>c;
        if(c == '#')grid[i][j] = true;
    }
    vector<vector<int>> dp(H,vector<int> (W,0));
    dp[0][0] = 1;
    for(int i = 1; i < W; i++){
        //compute dp[0][i]
        if(grid[0][i]){
            while(i < W){
                dp[0][i] = 0;
                i++;
            }
        }
        else{
            dp[0][i] = 1;
        }
    }
    for(int i = 1; i < H; i++){
        //compute dp[i][0]
        if(grid[i][0]){
            while(i < H){
                dp[i][0] = 0;
                i++;
            }
        }
        else{
            dp[i][0] = 1;
        }
    }
    for(int i = 1; i < H; i++){
        for(int j = 1; j < W; j++){
            if(grid[i][j])  continue;
            else{
                addself(dp[i][j] , dp[i-1][j], dp[i][j-1]);
            }
        }
    }
    cout<<dp[H-1][W-1]<<endl;
}

Measured memory_bytes: 8320
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <bitset>
#include <random>
#include <chrono>
#include <complex>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <cstring>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iomanip> 

using namespace std;

#define sqr(x) ((x)*(x))
#define mp make_pair
#define pb push_back
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define RE(i, n) FOR(i,1,n)
#define REP(i,n) FOR(i, 0, (int)(n)-1)
#define fst first
#define snd second

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
typedef tuple<int,int,int> iii;

string to_string(string s) {
    return '"' + s + '"';
}
    
string to_string(const char* s) {
    return to_string((string) s);
}
    
string to_string(bool b) {
    return (b ? "true" : "false");
}
    
template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
    
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const auto &x : v) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

void fastIO() {
    cin.sync_with_stdio(false);
    cin.tie(0);
}


int XMOV[4] = {0, 0, 1, -1};
int YMOV[4] = {1, -1, 0, 0};

//#############################
const int MAXN = 1000005;

int main() { 
    ll a, b, n;

    cin >> n >> a >> b;
    cout << (n/(a+b)) * a + min(n % (a+b), a) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int m(int, int);
int ax(int, int);

int main()
{
	int a, b, c, x, y;
	int sum = 0, max, min;

	scanf("%d %d %d %d %d", &a, &b, &c, &x, &y);

	sum = a * x + b * y;

	if (a + b > 2 * c) {
		min = m(x, y);
		sum = 2 * c * min;
		x -= min;
		y -= min;

		if (x > 0) {
			min = m(a, 2 * c);
			sum += min * x;
		}
		else {
			min = m(b, 2 * c);
			sum += min * y;
		}

	}

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

	return 0;
}

int m(int a, int b)
{
	if (a < b)
		return a;
	else
		return b;
}

int ax(int a, int b)
{
	if (a > b)
		return a;
	else
		return b;
}

Measured memory_bytes: 1720
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,x;
    string s;
    cin>>n;
    cin>>s;
    x=s.length();
    if (x<=n) cout<<s<<endl;
    else 
    {
    	for (int i=0;i<=n-1;i++)
    	  cout<<s[i];
    	cout<<"..."<<endl;
    }
	return 0;
} 

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

#define N 8
#define FREE -1
#define NOT_FREE 1

int row[N], col[N], dpos[2*N-1], dneg[2*N-1];

bool X[N][N];

void initialize() {
    for (int i = 0; i < N; i++) {
        row[i] = FREE;
        col[i] = FREE;
    }
    for (int i = 0; i < 2*N-1; i++) {
        dpos[i] = FREE;
        dneg[i] = FREE;
    }
}

void printBoard() {
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            if(X[i][j]) {
                if(row[i] != j) return;
            }
        }
    }
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            cout << ((row[i] == j) ? "Q" : ".");
        }
        cout << endl;
    }
}

void recursive(int i) {
    if( i == N ) {
        printBoard(); return;
    }

    for (int j = 0; j < N; j++) {
        if(NOT_FREE == col[j] || NOT_FREE == dpos[i + j] || NOT_FREE == dneg[i-j+N-1]) continue;
        row[i] = j; col[j] = dpos[i + j] = dneg[i-j + N - 1] = NOT_FREE;
        recursive(i + 1);
        row[i] = col[j] = dpos[i + j] = dneg[i-j + N - 1] = FREE;
    }
}

int main() {
    initialize();

    for(int i = 0; i < N; i++)
        for(int j = 0; j < N; j++) X[i][j] = false;

    int k;
    cin >> k;
    for (int i = 0; i < k; i++) {
        int r, c; cin >> r >> c;
        X[r][c] = true;
    }

    recursive(0);

    return 0;
}

Measured memory_bytes: 3100
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
	
		Scanner scan = new Scanner(System.in);

		
		String s = scan.nextLine();
		
		for(int i = 0; i < s.length(); i+=2) {
			System.out.print(s.charAt(i));
		}
		/*for(int i = 0; i <= A; i++) {
			for(int j = 0; j < A; j++) {
				System.out.print("☆");
				
			}
			System.out.println("");
		}*/
		
	}

}


Measured memory_bytes: 33540
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <vector>
#include <cmath>
#include <cctype>
#define rep(i,a,b) for(int i=(a);i<b;i++)
#define INF 1000000000
#define MAX_N 100000000
#define MAX 
using namespace std;
bool debug=false;

int main(){
  int n,a[105],cnt=0;
  cin>>n;
  rep(i,0,n)cin>>a[i];

  rep(i,0,n){
    int mini=i;
    rep(j,i,n){
      if(a[mini]>a[j])mini=j;
    }
    if(mini!=i){
      swap(a[i],a[mini]);
      cnt++;
    }
  }
  
  rep(i,0,n){
    cout<<a[i];
    if(i==n-1)cout<<endl;
    else cout<<" ";
  }
  cout<<cnt<<endl;
  return 0;
}

Measured memory_bytes: 3108
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
//#include <stdio.h>
//#include <stack>
//#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
//#include <fstream>
//#include <list>
//#include <iomanip>
#include <stdlib.h>
#include <cctype>

using namespace std;

#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define ssort(z) sort(z.begin(),z.end())
#define rsort(z) sort(z.rbegin(),z.rend())
#define eerase(z) z.erase(unique(z.begin(),z.end()),z.end())
#define ccnt(z,w) count(z.begin(),z.end(),w)


void printVec(std::vector<int> & vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec2(std::vector<Int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

Int gcd(Int a, Int b) {
	return b != 0 ? gcd(b, a % b) : a;
}
Int lcm(Int a, Int b) {
	return a / gcd(a, b) *b;
	//a*bは64bit integer overflow
}

bool comp(const string a, const string b) {
	return a.length() < b.length();
}

bool integer(double num) {
	return floor(num) == num;
}

string gen(int num) {
	string str = "";
	for (int i = 0; i < num; i++) str += ".";
	return str;
}
Int fact(int num) {
	if (num == 0) return 1;
	else return num * fact(num - 1);
}


int main() {
	int a, b; cin >> a;
	if (a>=1000)cout << "ABD";
	else cout << "ABC";

	cout << endl;
	return 0;
}

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

signed main(){

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	int n,m;
	cin>>n>>m;
	double arr[n];
	for(double& i:arr) cin>>i;
	sort(arr,arr+n);

	double val = accumulate(arr,arr+n,0.0)/(4*m);
	cout<<(arr[n-m]<val?"No":"Yes")<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <stack>
#include <math.h>

using namespace std;

typedef long long int ll;
typedef long double ld;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define vsort(a) sort(a.begin(), a.end())
#define rev(a) reverse(a.begin(), a.end())


// a,bの最小公倍数
ll LCM(ll a, ll b){ll lcm = a * b; ll r = a % b;while(r != 0){a = b; b = r; r = a % b;}return lcm /= b;}
// a,bの最大公約数
ll GCD(ll a, ll b){ll r = a % b;while(r != 0){a = b; b = r; r = a % b;}return b;}


const int MOD = 1000000007;
const int INF = INT_MAX;



int main(){



    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;

    s[k-1] = (s[k-1] - 'A') + 'a';


    cout << s << endl;


    




}





//              g++ -std=c++1z


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5+9;
int cnt[N];
inline int read() {
    int s = 1, a = 0; char ch = getchar();
    while (ch < '0' || ch > '9') {if (ch == '-') s = -1; ch = getchar();}
    while (ch >= '0' && ch <= '9') {a = a * 10 + ch - '0'; ch = getchar();}
    return s * a;
}
int main() {
    int n = read();
    for (int i = 1; i <= n; i++) {
        int ai = read();
        cnt[ ai ]++, cnt[ ai+1 ]++, cnt[ ai-1 ]++;
    }
    int res = 0;
    for (int i = 0; i <= 1e5; i++) res = max(res, cnt[i]);
    return 0 * printf("%d\n", res);
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;

struct UnionFind {
  vector<int> data;
  UnionFind(int size) : data(size, -1) { }
  bool unionSet(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool findSet(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    ll N, M; cin >> N >> M;
    UnionFind uf(N);
    for(int i = 0; i < M; i++){
        int a, b; cin >> a >> b; a--; b--;
        uf.unionSet(a, b);
    }
    ll sz = uf.size(0);
    ll rem = N-sz;
    ll ans = (sz*(sz-1))/2+(rem*(rem-1))/2-M;
    sz = uf.size(1);
    rem = N-sz;
    ans = max(ans, (sz*(sz-1))/2+(rem*(rem-1))/2-M);
    cout << ans << endl;

}

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

using namespace std;

void solve()
{
	int n;
	while(cin >> n, n)
	{
		vector<int> Vec(n);
		for(int i = 0; i < n; ++i)
		{
			cin >> Vec[i];
		}
		sort(Vec.begin(), Vec.end());
		int sum = 0;
		for(int i = 1; i < Vec.size() - 1; ++i)
		{
			sum += Vec[i];
		}
		cout << sum / (Vec.size() - 2) << endl;
	}
}

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

Measured memory_bytes: 1212
def e_get_everything(INF=float('inf')):
    # 参考: http://drken1215.hatenablog.com/entry/2019/09/29/103500
    N, M = [int(i) for i in input().split()]
    A, B, C = [], [], []
    for _ in range(M):
        a, b = [int(i) for i in input().split()]
        A.append(a)
        B.append(b)
        # 開けられる宝箱の集合Cはビット列に変換しておく
        C.append(sum(1 << (t - 1) for t in [int(i) for i in input().split()]))

    # dp[i][S]: i番目まで(i番は含まない)の鍵からいくつか選んで、
    # 開いた宝箱の集合がS(ビット列で表す)で表されるような場合にかかる費用の最小値
    dp = [[INF] * (1 << N) for _ in range(M + 1)]
    dp[0][0] = 0  # 鍵を選ばず、開ける宝箱がないとき、費用は0とする

    for i in range(M):
        for j in range(1 << N):
            # i番目の鍵を使わない場合
            dp[i + 1][j] = min(dp[i + 1][j], dp[i][j])
            # i番目の鍵を使う場合
            next_j = j | C[i]  # C[i] で指定される宝箱(のいくつか)が新たに開く
            dp[i + 1][next_j] = min(dp[i + 1][next_j], dp[i][j] + A[i])
    # M個の鍵を使ってすべての宝箱を開けるとき、費用が有限値に更新されたか？
    return dp[M][(1 << N) - 1] if dp[M][(1 << N) - 1] != INF else -1

print(e_get_everything())

Measured memory_bytes: 144472
#include <iostream>
using namespace std;
int main(int argc, char const *argv[])
{
	int W[100];
	int n;
	cin >> n;
	int S1 = 0;
	int S2 = 0;
	for (int i = 0; i < n; ++i)
	{
		cin >> W[i];
		S2 += W[i];
	}

	int ans = 1000000;

	for (int i = 0; i < n; ++i)
	{
		S1 += W[i];
		S2 -= W[i];

		if ((S2 - S1) >= 0)
		{
			ans = min(ans,S2-S1);
		}
		else
		{
			ans = min(ans,S1-S2);
		}
	}

	cout << ans << endl;
	return 0;
}

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

using namespace std;

#define ll long long
#define mp make_pair
#define f first
#define s second
#define pb push_back

int v[100100],r[100100],l[100100];
string s;
int i;

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

    cin>>s;

    int n = s.length();

    for(i=0; i<n; ++i)
    {
        if(s[i]=='R')
            r[i]=i;
        else
            r[i]=r[i-1];
    }
    for(i=n-1; i>=0; --i)
    {
        if(s[i]=='L')
            l[i]=i;
        else
            l[i]=l[i+1];
    }
    for(i=0; i<n; ++i)
    {
        if(s[i]=='R')
        {
            if((l[i]-i)%2==0)
                v[l[i]]++;
            else
                v[l[i]-1]++;
        }
        else
        {
            if((i-r[i])%2==0)
                v[r[i]]++;
            else
                v[r[i]+1]++;
        }
    }
    for(i=0; i<n; ++i)
        cout<<v[i]<<' ';
}


Measured memory_bytes: 1872
#入力:N,M(int:整数)
def input2():
	return map(int,input().split())

#入力:[n1,n2,...nk](int:整数配列)
def input_array():
	return list(map(int,input().split()))





a,b,k=input2()



if k<=a:
	a-=k
elif a+b>k:
	k-=a
	a=0
	b-=k
elif (a+b)<=k:
	a=0
	b=0

print("{} {}".format(a,b))

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

namespace ABC153
{
	class Program
	{
		static void Main(string[] args)
		{
			string[] strs = Console.ReadLine().Split(' ');
			int n = int.Parse(strs[0]);
			int k = int.Parse(strs[1]);

			strs = Console.ReadLine().Split(' ');
			List<decimal> h = new List<decimal>();
			for(int i = 0; i < n; i++)
			{
				h.Add(int.Parse(strs[i]));
			}

			decimal count = 0;

			var hd = h.OrderByDescending(v => v).ToList();
			hd.RemoveRange(0, Math.Min(k, hd.Count));

			count = hd.Sum();

			Console.WriteLine(count);
		}
	}
}

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

int main(void) {
  int N;
  cin >> N;
  for(int i = 0; i < N; i++){
   char S;
   cin >> S;
  if( S == 'Y'){
    cout << "Four" << endl;
    return 0;
  }
  }
    cout << "Three" << endl;
  return 0;
}
    





Measured memory_bytes: 256
#include<stdio.h>

void trace(int *A, int N) {
	int i;
	for (i = 0; i < N; i++) {
		if (i > 0) {
			printf(" ");
		}
		printf("%d", A[i]);
	}
	printf("\n");
}

void insertionSort(int *A, int N) {
	int i, j;
	int v;

	for (i = 0; i < N; i++) {
		v = A[i];
		j = i - 1;
		while (j >= 0 && A[j] > v) {
			A[j + 1] = A[j];
			j--;
		}
		A[j + 1] = v;
		trace(A, N);
	}
}

int main(void) {
	int N;
	int A[1000];
	int i;

	scanf("%d", &N);
	for (i = 0; i < N; i++) {
		scanf("%d", &A[i]);
	}
	insertionSort(A, N);
	
	return 0;
}


Measured memory_bytes: 1996
#include<iostream>
using namespace std;
int main()
{
    int m,n,k=1;
    cin>>m>>n;
    int a=n/1000;
    for(int x=m;x>=0;x--){
        for(int y=m-x;y>=0;y--){
            for(int z=m-x-z;z>=0;z--){
                if(x+y+z==m&&10*x+5*y+z==a){
                    cout<<x<<' '<<y<<' '<<z;
                    k=0;
                    break;
                }
            }
            if(k==0){
                break;
            }
        }
        if(k==0){
            break;
        }
    }
    if(k){
        cout<<"-1"<<' '<<"-1"<<' '<<"-1";
    }
}

Measured memory_bytes: 256
//********************************************************************//
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define RANGE(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define DFOR(i, a, b) for(int i = a; i > b; --i)
#define DEB(x) cout << #x << ": " << x << endl
#define ALL(v) v.begin(), v.end() 
#define SORT(v) sort(ALL(v))
#define DISPV(v) { for(auto x___: v) cout << x___ << " "; cout << endl; }
#define DISPM(m) { for(auto x____: m){ cout << x____.first << ": " << x____.second << endl; } };
#define DISPMV(m) { for(auto x_____: m){ cout << x_____.first << ": " ;DISPV(x_____.second);} };
using LL = long long;
using VI = vector <int>;
using VL = vector <long long>;
using VVI = vector<VI>;
using VVL = vector <VL>;
using MII = map<int, int>;
using MIVI = map<int, VI>;
using MLL = map<LL, LL>;
int READ_INT(){int temp;cin>>temp;return temp;}      // read an int
LL READ_LONG(){LL temp;cin>>temp;return temp;}      // read a long long

const int MOD = int(1e9) + 7;
const int INF = 1e9 + 5;
const double PI = acos(-1.0); //M_PI;
const double EPS = 1e-9;
//********************************************************************//

int main(){
    ios::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int h, w, m;
    cin >> h >> w >> m;
    unordered_map<int, int>row_couter, col_counter;
    set<pair<int, int>>bombs;
    int max_row_val = -1, max_col_val = -1;
    RANGE(k,m){
        int i, j;
        cin >> i >> j;
        bombs.insert({i, j});
        max_row_val = max(max_row_val, ++row_couter[i]);
        max_col_val = max(max_col_val, ++col_counter[j]);
    }
    VI rows, cols;
    for(auto p: row_couter)
        if(p.second == max_row_val)rows.push_back(p.first);
    for(auto p: col_counter)
        if(p.second == max_col_val)cols.push_back(p.first);
    // DISPV(rows);
    // DISPV(cols);
    int ans = -1;
    bool found = false;
    for(auto r: rows){
        for(auto c: cols){
            if(!bombs.count({r, c})){
                ans = row_couter[r] + col_counter[c];
                found = true;
                break;
            }
            else{
                ans = row_couter[r] + col_counter[c] - 1;
            }
        }if(found)break;
    }
    cout << ans << endl;
    return 0;
}



/* complie flags
-Wall -Wextra -pedantic -std=c++11 -O2 -Wshadow -Wformat=2 -Wfloat-equal -Wconversion -Wlogical-op -Wshift-overflow=2 -Wduplicated-cond -Wcast-qual -Wcast-align -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC -D_FORTIFY_SOURCE=2 -fsanitize=address -fsanitize=undefined -fno-sanitize-recover -fstack-protector
*/

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


int main(){
  int n,m;
  cin>>n;
  cin>>m;
  int a[n+1];
  for(int i=0;i<=n;i++)a[i]=0;
  int l,r;
  for(int i=0;i<m;i++){
    cin>>l>>r;
    a[l]++;
    a[r+1]--;
  }
  int cnt=0;
  for(int i=1;i<=n;i++){
    a[i]+=a[i-1];
    if(a[i]==m)cnt++;
  }
  cout<<cnt;
  return 0;
}


Measured memory_bytes: 640
read n
for i in 2 11 31 41 61 71 101 131 151 181 191 211 241 251 271 281 311 331 401 421 431 461 491 521 541 571 601 631 641 661 691 701 751 761 811 821 881 911 941 971 991 1021 1031 1051 1061 1091 1151 1171 1181 1201 1231 1291 1301 1321 1361; do
    n=$((n - 1))
    printf "$i "
    if (( $n == 0 )); then
        break
    fi
done
printf "\n"


Measured memory_bytes: 376
#include "bits/stdc++.h"
//#define int long long
#define range(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, a) range(i, 0, a)
#define all(a) (a).begin(),(a).end()
using namespace std;
const int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
const int MOD = 1000000007;
const long double EPS = 1e-8;
using vi = vector <int>;
using vvi = vector <vi>;

class unionFindTree {
private:
	vector <int> tree;
	vector <int> rank;

public:
	unionFindTree() {}

	unionFindTree(int sz) {
		tree = vector <int> (sz);
		rank = vector <int> (sz, 0);
		for(int i = 0; i < tree.size(); i++)
			tree[i] = i;
	}

	unionFindTree(const unionFindTree &o) {
		tree = o.tree;
		rank = o.rank;
	}

	unionFindTree &operator=(const unionFindTree &o) {
		tree = o.tree;
		rank = o.rank;
		return (*this);
	};

	int root(int x) {
		return tree[x] == x ? x : tree[x] = root(tree[x]);
	}

	bool same(int a, int b) {
		return root(a) == root(b);
	}

	void unite(int a, int b) {
		a = root(a);
		b = root(b);
		if(a == b)return;

		if(rank[a] < rank[b]) swap(a, b);

		tree[b] = a;
		rank[a] += rank[a] == rank[b];
	}

	int size() {
		return tree.size();
	}
};


class Kruskal : public unionFindTree{
	private:
		struct edge {
			int u, v, cost;
			bool operator< (const edge& e) const {
				return cost < e.cost;
			}
		};
		vector <edge> es;
		int V;

	public:
		Kruskal(int v, int e) : unionFindTree(v){
			V = v;
			es = vector <edge> (e);
		}

		void addEdge(int start, int end, int cost) {
			es.push_back({start, end, cost});
		}

		int execute() {
			sort(es.begin(), es.end());
			int res = 0;
			for(int i = 0; i < es.size(); i++) {
				edge e = es[i];
				if(!same(e.u, e.v)) {
					unite(e.u, e.v);
					res += e.cost;
				}
			}
			return res;
		}
};


signed main() {
	int n, m;
	while (cin >> n >> m, n) {
		Kruskal pear(n, m);
		rep (i, m) {
			int a, b, d;
			scanf("%d, %d, %d", &a, &b, &d);
			d -= 100;
			pear.addEdge(a, b, d);
		}
		cout << pear.execute() / 100 << endl;
	}
	return 0;
}


Measured memory_bytes: 3344
from collections import defaultdict
d = defaultdict(int)
for i in range(3):
    a,b = map(int,input().split())
    d[a] += 1
    d[b] += 1
a = sorted(d.items(),key=lambda x:x[1],reverse=True)
tc,oc = 0,0
for ai in a:
    if ai[1]==2:
        tc += 1
    elif ai[1]==1:
        oc += 1
print('YES' if tc==2 and oc==2 else 'NO')

Measured memory_bytes: 38512
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
const int maxn = 1e6+5;
const int mod = 1e9+7;
const double eps = 1e-8;
using namespace std;

void tlfclwx(){ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);}

int k[105];
int main()
{
    int n; cin >> n;
    for(int i = 1; i <= n; i++) cin >> k[i];
    for(int i = 1; i <= n; i++) {
        if(k[i]%2==0) {
            if(k[i]%3==0||k[i]%5==0) continue;
            else {
                cout << "DENIED" << endl;
                return 0;
            }
        }
    }
    cout << "APPROVED" << endl;
 }


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

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

int N;
int H[30];

int main(){
   cin>>N;
   for(int i=0;i<N;i++)cin>>H[i];
   int ans=0,s=H[0];
   for(int i=1;i<N;i++){
       s=max(s,H[i]);
       if(H[i]>=s)ans++;
   }
   cout<<ans+1<<endl;
}


Measured memory_bytes: 256