akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		int N = sc.nextInt();
		int A[] = new int[N];
		int max = 0;
		for(int i = 0; i < N; i++) {
			A[i] = sc.nextInt();
			if(i > 0) {
				max = Math.max(A[i] - A[i - 1], max);
			}
		}
		max = Math.max(K - A[N - 1] + A[0], max);
		System.out.println(K - max);
	}
}


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

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            string line = Console.ReadLine();
            long X = long.Parse(line);
            long takahashi = 100;
            int count = 0;
            while(takahashi < X)
            {
                takahashi = (long)(takahashi * 1.01);
                count++;
            }

            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 27516
#include<bits/stdc++.h>
#define INF 2000000000
#define MOD 1000000007
#define MOD2 100000000
#define ll long long
#define pb push_back
#define mp make_pair
#define x first
#define y second
#define all(v) v.begin(),v.end()
ll mod=MOD;
using namespace std;
long long int fast_exp(long long int base,long long int ex) {
    long long int res=1;
    while(ex>0) {
       if(ex%2==1) res=(res*base)%mod;
       base=(base*base)%mod;
       ex/=2;
    }
    return res%mod;
}
long long int gcd(long long int a, long long int b)
{
    if(b==0)return a;
     return gcd(b,a%b);
}
 ll ar[100000][3];
 ll ans[100000][3];
ll fi(ll i, ll j)
{
    if(!i)return ans[i][j]=ar[i][j];
    if(ans[i][j])return ans[i][j];
    for(int k=0;k<3;k++)
        if(k!=j)ans[i][j]=max(ans[i][j],fi(i-1,k)+ar[i][j]);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    cin>>n;

    for(int i=0;i<n;i++)
        for(int j=0;j<3;j++)
        cin>>ar[i][j];
    cout<<max(fi(n-1,0),max(fi(n-1,1),fi(n-1,2)));

    return 0;
}


Measured memory_bytes: 9600
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"

using namespace std;

const long long int MOD = 1000000007;
//const int MOD = 998244353;

long long int N, M, K, H, W, L, R;
//int N, M, K, H, W, L, R;

void Search(int n, long long int k,vector<long long int>&a,vector<long long int>&p,long long int &ans) {
	for (int i = n; i >= 0; i--) {
		if (a[i] == k) {
			ans += p[i];
			k = 0;
		}
		else if (a[i] / 2 + 1 <= k) {
			ans += p[i] / 2 + 1;
			k -= a[i] / 2 + 1;
		}
		else if (a[i] / 2 == k) {
			ans += p[i] / 2;
			k = 0;
		}
		else {
			k--;
		}
	//	cout << i << " " << ans << endl;
	}
	return;
}

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

	cin >> N >> M;
	vector<long long int>a(N + 1, 1);
	vector<long long int>p(N + 1, 1);
	for (int i = 1; i <= N; i++) {
		p[i] = p[i - 1] * 2 + 1;
		a[i] = a[i - 1] * 2 + 3;
	//	cout << i << " " << p[i] << " " << a[i] << endl;
	}
	long long int ans = 0;
	Search(N, M, a, p, ans);
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;

int main() {
  int R, G, B, N;
  cin >> R >> G >> B >> N;

  int r_max = N / R;
  int g_max = N / G;

  int ans = 0;
  for (int i = 0; i <= r_max; i++) {
    for (int j = 0; j <= g_max; j++) {
      int rest = N - i * R - j * G;
      if (rest >= 0 && rest % B == 0) {
        ans++;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3632
// Create your own template by modifying this file!
#include <string>
#include <vector>
#include <climits>
#include <cstring>
#include <map>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cassert>
#include <deque>
#include <stack>
#include <functional>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB emplace_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x;  }
void _R(int &x) { scanf("%d", &x);  }
void _R(int64_t &x) { scanf("%lld", &x);  }
void _R(double &x) { scanf("%lf", &x);  }
void _R(char &x) { scanf(" %c", &x);  }
void _R(char *x) { scanf("%s", x);  }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...);  }
template<class T> void _W(const T &x) { cout << x;  }
void _W(const int &x) { printf("%d", x);  }
void _W(const int64_t &x) { printf("%lld", x);  }
void _W(const double &x) { printf("%.16f", x);  }
void _W(const char &x) { putchar(x);  }
void _W(const char *x) { printf("%s", x);  }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' ');  }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...);  }
#ifdef DEBUG
 #define debug(...) {printf("[DEBUG] ");W(__VA_ARGS__);}
#else
 #define debug(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1<<20;
template<class T> void MIN(T& a, const T& b) { a = min(a, b); }
template<class T> void MAX(T& a, const T& b) { a = max(a, b); }

#include <atcoder/all>

using namespace atcoder;

void solve() {
    int N, M;
    R(N, M);
    scc_graph graph(N);
    while (M--) {
        int a, b;
        R(a, b);
        graph.add_edge(a, b);
    }
    auto scc = graph.scc();
    W(SZ(scc));
    for (auto &vi : scc) {
        W(SZ(vi), vi);
    }
}

int main() {
#if MULTITEST    
    CASET{
        solve();
    }
#else
    solve();
#endif
    return 0;
}


Measured memory_bytes: 40132
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a=n%10;
    if(a==2 || a==4 || a==5 || a==7 || a==9)
    {
        cout<<"hon"<<endl;
    }
    else if(a==0 || a==1 || a==6 || a==8)
    {
        cout<<"pon"<<endl;
    }
    else
    {
        cout<<"bon"<<endl;
    }
    

    return 0;
}

Measured memory_bytes: 3644
S = list(input())
N = len(S) - 1
res = 0
for bits in range(0,2**N):
    pos = [0] * N
    for i in range(N):
        if bits & (1<<i):
            pos[i] = 1
    acc = 0
    for i in range(N):
        acc += pos[i]
        if pos[i] == 1:
            pos[i] = acc
    s = list(S)
    for i in range(N):
        if pos[i] > 0:
            p = pos[i] + i
            s.insert(p, '+')

    expr = "".join(s)
    res += eval(expr)

print(res)

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  int a, b; cin >> a >> b;
  if(b < a)a--;
  cout << a << endl;
  return 0;
}


Measured memory_bytes: 256
#define	_USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cfloat>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <string>
#include <set>
#include <complex>
#include <utility>
#define  rep(i,n) for(int i=0;i<(n);i++)
#define  REP(i,n) for(int i=1;i<(n);i++)
#define  rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define  VI	vector<int>
#define	 VS vector<string>
#define  all(a) (a).begin(),(a).end()
#define  debug(x) cout<<#x<<": "<<x<<endl
using namespace std;
typedef pair<int,int> P;

const int INF=1000000;
char field[101][101];
int d[101][101];
int N,M;
int sx,sy;
int gx,gy;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

const int MAX_N=1000;

int main(){
	
	int n,w;
	
	cin>>n>>w;
	
	vector<int> c(n);
	vector<int> we(n);
	vector< vector<int> > dp(n+1,vector<int>(w+1));
	
	rep(i,n)	
		cin>>c[i]>>we[i];
	
	for(int i=n-1;i>=0;i--){
		for(int j=0;j<=w;j++){
		if(j<we[i])
			dp[i][j]=dp[i+1][j];
		else 
		dp[i][j]=max(dp[i+1][j],dp[i+1][j-we[i]]+c[i]);
		}
	}
	
	cout<<dp[0][w]<<endl;
	
	
	
	
}

Measured memory_bytes: 4968
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 3e2 + 10;

int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	string str = "aeiou";
	char c;
	cin >> c;
	if (str.find(c) != str.npos) puts("vowel");
	else puts("consonant");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
constexpr ll mod = 1e9 + 7;
#define endl '\n'
 
int main() {
  ios::sync_with_stdio(0); cin.tie(0);
 
  ll na,nb,M;
  cin >> na >> nb >> M;
  vector<ll> A(na), B(nb);
  for (auto& _a : A) cin >> _a;
  for (auto& _a : B) cin >> _a;
  vector<array<ll,3>> Q(M);
  for (auto& _a : Q) cin >> _a[0] >> _a[1] >> _a[2];
  ll ans = *min_element(A.begin(),A.end()) + *min_element(B.begin(),B.end());
  for (auto& [x,y,c] : Q) {
    --x,--y;
    ans = min(ans, A[x]+B[y]-c);
  }
  cout << ans << endl;
  
  

}


Measured memory_bytes: 7160
class SegmentTree:
    def __init__(self, n, op, e):
        self.n = 1 << (n - 1).bit_length()
        self.op = op
        self.e = e
        self.data = [e] * (2 * self.n)

    def update(self, k, v):
        k += self.n
        self.data[k] = v
        while k > 0:
            k >>= 1
            self.data[k] = self.op(self.data[2 * k], self.data[2 * k + 1])

    def query(self, left, right):
        left += self.n
        right += self.n
        l_res = self.e
        r_res = self.e
        while left < right:
            if left & 1:
                l_res = self.op(l_res, self.data[left])
                left += 1
            left >>= 1
            if right & 1:
                right -= 1
                r_res = self.op(self.data[right], r_res)
            right >>= 1
        return self.op(l_res, r_res)


MOD = 998244353
N, K, *LR = map(int, open(0).read().split())
segments = [(l, r) for l, r in zip(*[iter(LR)] * 2)]
st = SegmentTree(N + 1, lambda x, y: (x + y) % MOD, 0)
st.update(0, 1)
for i in range(1, N + 1):
    for l, r in segments:
        if i - l < 0:
            continue
        L = max(i - r, 0)
        R = i - l
        st.update(i, st.query(i, i + 1) + st.query(L, R + 1))
print(st.query(N - 1, N))

Measured memory_bytes: 75752
#include <bits/stdc++.h>
#define lli long long int
#define pb push_back
#define mod2 1000000007
#pragma GCC optimize ("-O3")
#define mod 998244353
#define MAXN 1000000000
#define v32 vector<int>
#define v64 vector<lli>
#define v1024 vector <vector <int>>
#define v4096 vector <vector <lli>>
#define vt vector
#define f(x, y, z) for (lli x = y; x < z; x++)
#define fd(x, y, z) for (lli x = y; x > z; x--)
#define lb lower_bound
#define ld long double
#define m64 map<lli,lli>
#define m32 map<int,int>
#define m64it map<lli,lli>::iterator
#define m32it map<int,int>::iterator
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ist insert
#define endl "\n"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define p_q priority_queue 
#define min_p_q priority_queue <int,vt <int>,greater <int>>
using namespace std;
using namespace __gnu_pbds; 

template <typename T> 
void DEBUG_ARR(vt<T> a,char c)
{
	f(i,0,a.size())cout<<a[i]<<c;
	cout<<"\n";
}

lli tmod(lli x,lli m=mod){return (x%m+m)%m;}//USE AT YOUR OWN RISK
lli power(lli x, lli y,lli m=mod) 
{
    lli res = 1;  
   
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x)%m; 
        y = y>>1; 
        x = (x*x)%m;  
    }
    if(res<0)
       res+=m; 
    return res; 
}

// lli fact[2000009];
// lli ncr(lli n,lli r){
//     lli ans=fact[n];
//     if(r>n)return 0;
//     ans=(ans*power(fact[n-r],mod-2))%mod;
//     ans=(ans*power(fact[r],mod-2))%mod;
//     return ans;
// }
        lli dist[2000][2000];
        // memset(dist,0,sizeof dist);
int main() 
{ 
    // fact[0]=1;
    // f(i,1,2000001)fact[i]=(i*fact[i-1])%mod;
    fastio;
    int t;
    // cin>>t;	
    t=1;
	while(t--){
        int n,x,y;
        cin>>n>>x>>y;
        x--,y--;

        f(i,0,n){
            f(j,i+1,n){
                dist[i][j]=j-i;
                if(j<=x || i>=y)continue;
                dist[i][j]=min(dist[i][j],abs(i-x)+abs(j-y)+1);
            }
        }
        lli ans[n];
        memset(ans,0,sizeof ans);
        f(i,0,n){
            f(j,i,n){
                ans[dist[i][j]]++;
            }
        }
        f(i,1,n)cout<<ans[i]<<" ";
    }   
    return 0; 	
}


Measured memory_bytes: 31104
#include<stdio.h>
#include<limits.h>
int min(int a,int b)
{
    return (a>b)?b:a;
}
int max(int a,int b)
{
    return (a>b)?a:b;
}
int main()
{
    int R[200000],n;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
        scanf("%d",&R[i]);

    int minv=R[0];
    int maxv=INT_MIN;

    for(int i=1;i<n;i++)
    {
        maxv=max(maxv,R[i]-minv);
        minv=min(R[i],minv);
    }
    printf("%d\n",maxv);
}



Measured memory_bytes: 2520
#include <bits/stdc++.h>
//#include <iostream>
#include <string>
#include <vector>
using namespace std;

int n;
int t[100010];
int x[100010];
int y[100010];

int main() {
    cin >> n;
    t[0] = x[0] = y[0] = 0;
    for (int i = 1; i <= n; i++) {
        cin >> t[i] >> x[i] >> y[i];
    }
    bool can = 1;
    int dt, dist;
    for (int i = 0; i < n; i++) {
        dt = t[i + 1] - t[i];
        dist = abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i]);
        if (dt < dist || dt % 2 != dist % 2) {
            can = 0;
            break;
        }
    }
    if (can) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
#include <cstring>
using namespace std;

using ll = long long;
using P = pair<int, int>;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

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

int c[1000005];

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

    int N;
    cin >> N;
    vector<int> A(N);
    int G = 0;
    for(int i = 0; i < N; ++i){
        cin >> A[i];
        G = gcd(G, A[i]);
    }
    if(G > 1){
        cout << "not coprime\n";
        return 0;
    }
    for(int i = 0; i < N; ++i){
        for(int j = 2; j * j <= A[i]; ++j){
            if(A[i] % j == 0){
                while(A[i] % j == 0)    A[i] /= j;
                if(c[j]){
                    cout << "setwise coprime\n";
                    return 0;
                }
                ++c[j];
            }
        }
        if(A[i] != 1){
            if(c[A[i]]){
                cout << "setwise coprime\n";
                return 0;
            }
            ++c[A[i]];
        }
    }
    cout << "pairwise coprime\n";
}

Measured memory_bytes: 7540
n, m = map(int, input().split())
d = {}
for i in range(m):
    s, c = map(int, input().split())
    if s == 1 and c == 0 and n > 1:
        print(-1)
        exit(0)
    if s in d:
        if d[s] != c:
            print(-1)
            exit(0)
    else:
        d[s] = c
ans = ''
for i in range(1, n + 1):
    if i in d:
        ans += chr(ord('0') + d[i])
    elif i == 1 and n > 1:
        ans += '1'
    else:
        ans += '0'
print(ans)


Measured memory_bytes: 3064
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.stream.Stream;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;
import java.util.HashMap;

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

    static class DBannedK {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            long a[] = new long[n];
            Stream.iterate(1, x -> x + 1)
                    .limit(n)
                    .forEach(i -> a[i - 1] = in.nextInt());

            HashMap<Long, Long> map = new HashMap<>();
            for (long x : a) {
                map.putIfAbsent(x, 0L);
                map.put(x, map.get(x) + 1);
            }

            long result = 0;
            for (Map.Entry<Long, Long> entry : map.entrySet()) {
                long b = entry.getValue();
                result += (b * (b - 1)) / 2;
            }

            for (int i = 0; i < n; i++) {
                long k = map.get(a[i]);
                long temp = (k * (k - 1)) / 2;
                result -= temp;
                long temp2 = (k - 1) * (k - 2) / 2;
                result += temp2;
                out.println(result);
                result = result - temp2 + temp;
//            map.put(k, map.get(k) + 1);
            }


        }

    }
}



Measured memory_bytes: 100428
import std.stdio,
       std.string,
       std.conv;


string selectOp(int f) {
  return (f ? "+" : "-");
}


void main() {
  string s = readln.chomp;
  int[] a;
  for (int i = 0; i < s.length; i++) {
    a ~= cast(char)s[i] - '0';
  }

  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < 2; j++) {
      for (int k = 0; k < 2; k++) {
        int e = a[0] + (i ? a[1] : -a[1])
                + (j ? a[2] : -a[2]) + (k ? a[3] : -a[3]);
        if (e == 7) {
          writeln(s[0] ~ selectOp(i) ~ s[1] ~ selectOp(j)
              ~ s[2] ~ selectOp(k) ~ s[3] ~ "=7");
          return;
        }
      }
    }
  }
}


Measured memory_bytes: 256
//????????????????????????1????????¢??????????????¨??§???0?????°????????§???????????????(1?????°????????§????????????????????§????????????
#include <iostream>
using namespace std;

int h, w;
int a[10][10000];	//a[i][j] = i(>=0)???j(>=0)????????????????????¶???

int main(){
	int i, j, k;
	
	while( cin >> h >> w ){
		if( h == 0 && w == 0 )
			break;
		for( i = 0; i < h; i++ ){
			for( j = 0; j < w; j++ ){
				cin >> a[i][j];
			}
		}
		
		int ans = 0;
		for( i = 0; i < (1 << h); i++ ){
			//?????£????????????
			for( j = 0; j < h; j++ ){
				if( (i >> j) & 1 ){
					//j??????????????£????????????
					for( k = 0; k < w; k++ )
						a[j][k] = !a[j][k];
				}
			}
			
			//??????????????§?????°????¶????
			int sumCnt = 0;
			for( j = 0; j < w; j++ ){
				//j??????????????§?????°????±???????
				int cnt = 0;
				for( k = 0; k < h; k++ ){
					cnt += a[k][j];			//?£????????????´???????????°???????????????
				}
				cnt = max(h - cnt, cnt);	//j??????????????§?????°
				sumCnt += cnt;
			}
			
			//???????????´??°
			ans = max(ans, sumCnt);
			
			//????????????
			for( j = 0; j < h; j++ ){
				if( (i >> j) & 1 ){
					//j??????????????£????????????
					for( k = 0; k < w; k++ )
						a[j][k] = !a[j][k];
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1548
#include <bits/stdc++.h>
using namespace std;
template<typename T> void rd(T &t) {
	char ch=getchar(); t=0; int f=1;
	while ('0'>ch||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do { (t*=10)+=ch-'0'; ch=getchar(); } while ('0'<=ch&&ch<='9');
	t*=f;
}
const int maxn=200010;
pair<int,int> a[maxn];
int n,ans[maxn];
int main() {
//	freopen("1.txt","r",stdin);
	rd(n);
	for (int i=1;i<=n;i++) {
		rd(a[i].first); a[i].second=i;
	}
	sort(a+1,a+(n+1));
	for (int i=1;i<=n;i++) {
		if (i<=n/2) ans[a[i].second]=a[n/2+1].first;
		else ans[a[i].second]=a[n/2].first;
	}
	for (int i=1;i<=n;i++) printf("%d\n",ans[i]);
	return 0;
}

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

using namespace std;

#define ll long long
#define pb push_back
#define mp make_pair
#define fst first
#define snd second

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

    cout << min(n % k, abs(n % k - k));

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int n,m,d;
char c[128][128];
int main(){
	int k,i,j,f,a;
	scanf("%d%d%d",&n,&m,&d);
	for(i=0;i<n;i++){
		scanf("%s",c[i]);
	}
	a=0;
	for(i=0;i<n;i++){
		for(j=0;j<=m-d;j++){
			f=1;
			for(k=0;k<d;k++){
				if(c[i][j+k]=='#'){
					f=0;
				}
			}
			if(f==1){
				a++;
			}
		}
	}
	for(i=0;i<=n-d;i++){
		for(j=0;j<m;j++){
			f=1;
			for(k=0;k<d;k++){
				if(c[i+k][j]=='#'){
					f=0;
				}
			}
			if(f==1){
				a++;
			}
		}
	}
	printf("%d\n",a);
	return 0;
}

Measured memory_bytes: 2728
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x,S) (S.count(x) != 0)
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef long long ll;
typedef long long integer;
//////////////////////////////////////////////////
int main(){
	int ans = 10000000;
	int D,G;
	SCD2(D,G);

	static int c[12] ={};
	static int p[12] ={};

	REP(i,D){
		int x,y;
		SCD2(x,y);
		p[i] = x; c[i] = y;
	}

	for (int b = 0; b < (1<<D); b++){
		int nscore = 0;
		int solved = 0;
		REP(i,D){
			if (b & (1<<i)){ 
				nscore += (100 * (i+1) * p[i] + c[i]);
				solved += p[i];
			}
		}

		int req = 0;

		for(int i = D-1; 0<=i ; i--){
			if (!(b & (1<<i))){
				
				FORq(j,0,p[i]-1){
					if (nscore >= G)  break;

					nscore += (i+1) * 100;
					solved++;

					if (nscore >= G)  break;
				}

				break;
			}else{
				continue;
			}
		}

		if (nscore >= G){
			ans = min(ans,solved);
		}



	}

	PRINTD(ans);
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;

#define int long long
#define DBG 0
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
const int north = -1;
const int west = 1;
int pow2(int a, int b) {
	if (b == 0)return 1;

	int res = pow2(a*a, b / 2);
	if (b & 1)res *= a;
	return res;
}
int gcd(int x, int y) {

	return y == 0 ? x : gcd(y, x%y);
}
signed main() {
	string s;
	while (cin >> s, s != "#") {
		vector<int>v;
		rep(i, 0, s.size()) {
			if (s[i] == 'n')v.push_back(north);
			else if (s[i] == 'w')v.push_back(west);
		}
		int bo, shi;
		bo = pow2(2, v.size() - 1);
		shi = pow2(2, v.size() - 1)*(v.back() == north ? 0 : 90);
		dump(bo);
		dump(shi);
		rep(i, 0, v.size() - 1) {
			shi += pow2(2, i)*v[i] * 90;
		}
		int g = gcd(shi, bo);
		bo /= g;
		shi /= g;
		cout << shi;
		if (bo != 1)cout << '/' << bo;
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
#define VectorType string
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define YesNo(b) b?cout << "Yes" << endl: cout << "No" << endl
#define YESNO(b) b?cout << "YES" << endl: cout << "NO" << endl
#define All(x) (x).begin(),(x).end()
#define VectorSumTotal(a) accumulate(a.begin(), a.end(), 0)
#define VectorStringTotal(a) accumulate(a.begin(), a.end(), string())
#define VectorSumMin(a) *std::min_element(a.begin(), a.end())
#define VectorSumMax(a) *std::max_element(a.begin(), a.end())
#define SortAscending(a) sort(a.begin(), a.end())
#define SortDescending(a) sort(a.begin(), a.end(), greater<>())


int main() {
    int n;
    cin >> n;
    vector<int> v(n);
    vector<int> Even((int)1e5 + 5), Odd((int)1e5 + 5);
    bool check = false;
    rep(i, n) cin >> v[i];
    int temp = v[0];
    rep(i, n) {
        if(i % 2 == 0) {
            if (temp != v[i]) check = true;
            ++Even[v[i]];
        } else {
            if (temp != v[i]) check = true;
            ++Odd[v[i]];
        }
    }
    int EvenMax = VectorSumMax(Even), OddMax = VectorSumMax(Odd);
    int ans = (n - EvenMax - OddMax);
    if (!check) ans = n / 2;
    bool Big = false;
    int evenodd;
    for (int i = 0; i < (int)1e5 + 5; ++i) {
        if (Even[i] == EvenMax && Odd[i] == OddMax && Even[i] != 0 && Odd[i] != 0) {
            Big = true;
            evenodd = i;
        }
    }
    int Eventemp = 0, Oddtemp = 0;
    if (Big) {
        for (int i = 0; i < (int)1e5 + 5; ++i) {
            if (i != evenodd) {
                Eventemp = max(Eventemp, Even[i]);
                Oddtemp = max(Oddtemp, Odd[i]);
            }
        }
        if (Eventemp == max(Eventemp, Oddtemp)) {
            ans = (n - Eventemp - OddMax);
        } else {
            ans = (n - EvenMax - Oddtemp);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(signed i=0;i<n;++i)
#define repi(n) rep(i,n)
#define repvin(n) vint a(n);r(i,n)cin>>a[i];
#define int long long
#define str string
#define vint vector<signed>
#define pint pair<signed,signed>
#define pb(a) push_back(a)
#define all(v) v.begin(),v.end()
#define yn(b) cout<<((b)?"Yes":"No")<<endl
#define YN(b) cout<<((b)?"YES":"NO")<<endl
#define call(a) for(auto t:a)cout<<t<<" ";cout<<endl
#define ENDL printf("\n");
#define debg(a) cout<<#a<<":"<<a<<endl;
#define SORT(a) sort(all(a));

signed main(){
    int n;
    cin>>n;
    double a[n];
    str s[n];
    repi(n)cin>>a[i]>>s[i];
    double res=0;
    rep(i,n){
        if(s[i]=="JPY")res+=a[i];
        else res+=a[i]*380000;
    }
    printf("%.4f",res);
  return 0;
}


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

int main() {
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<int> W(N);
  for (int i = 0; i < N; i++) cin >> W.at(i);

  int ans = 1e9;

  for (int i = 0; i < N - 1; i++) {
    int A = 0, B = 0;
    for (int j = 0; j <= i; j++) A += W.at(j);
    for (int j = i + 1; j < N; j++) B += W.at(j);
    ans = min(ans, abs(A - B));
  }

  cout << ans << "\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

main()
{
    fast;
    int n,A=0,B=0,i;
    cin>>n;
    int a[n];
    for (i=0;i<n;i++)
        cin>>a[i];
    sort(a,a+n,greater<int>());
    for (i=0;i<n;i+=2)
    {
        A+=a[i];
        if (i+1<n)
            B+=a[i+1];
    }
    cout<<A-B<<endl;
}

Measured memory_bytes: 256
from itertools import permutations

n = int(input())
xy = [list(map(int, input().split())) for _ in range(n)]

n_fact = 1
for i in range(1, n+1): n_fact *= i

sm = 0
for itr in permutations(xy):
    dist = 0
    x, y = itr[0]
    for nx, ny in itr[1: ]:
        dist += ((nx-x)**2 + (ny-y)**2) ** 0.5
        x, y = nx, ny

    sm += dist

print(sm / n_fact)

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

int main() {
  int n, a, b, c, d;

  cin >> n;

  a = n / 1000;
  b = (n - a * 1000) / 100;
  c = (n - a * 1000 - b * 100) / 10;
  d = (n - a * 1000 - b * 100 - c * 10) / 1;

  if (a == b && b == c) {
    cout << "Yes" << endl;
  } else if (b == c && c == d) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

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

using namespace std;

int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  vector<int> a(s.length());
  for(int i=0;i<s.length();i++){
    if(s[i]=='A'){
      a[i]=0;
    }
    else if(s[i]=='B'){
      a[i]=1;
    }
    else if(s[i]=='C'){
      a[i]=2;
    }
    else if(s[i]=='D'){
      a[i]=3;
    }
    else if(s[i]=='E'){
      a[i]=4;
    }
    else if(s[i]=='F'){
      a[i]=5;
    }
    else if(s[i]=='G'){
      a[i]=6;
    }
    else if(s[i]=='H'){
      a[i]=7;
    }
    else if(s[i]=='I'){
      a[i]=8;
    }
    else if(s[i]=='J'){
      a[i]=9;
    }
    else if(s[i]=='K'){
      a[i]=10;
    }
    else if(s[i]=='L'){
      a[i]=11;
    }
    else if(s[i]=='M'){
      a[i]=12;
    }
    else if(s[i]=='N'){
      a[i]=13;
    }
    else if(s[i]=='O'){
      a[i]=14;
    }
    else if(s[i]=='P'){
      a[i]=15;
    }
    else if(s[i]=='Q'){
      a[i]=16;
    }
    else if(s[i]=='R'){
      a[i]=17;
    }
    else if(s[i]=='S'){
      a[i]=18;
    }
    else if(s[i]=='T'){
      a[i]=19;
    }
    else if(s[i]=='U'){
      a[i]=20;
    }
    else if(s[i]=='V'){
      a[i]=21;
    }
    else if(s[i]=='W'){
      a[i]=22;
    }
    else if(s[i]=='X'){
      a[i]=23;
    }
    else if(s[i]=='Y'){
      a[i]=24;
    }
    else if(s[i]=='Z'){
      a[i]=25;
    }
  }
  for(int i=0;i<s.length();i++){
    a[i]=(a[i]+n)%26;
  }
  for(int i=0;i<s.length();i++){
    if(a[i]==0){
      cout << 'A';
    }
    else if(a[i]==1){
      cout << 'B';
    }
    else if(a[i]==2){
      cout << 'C';
    }
    else if(a[i]==3){
      cout << 'D';
    }
    else if(a[i]==4){
      cout << 'E';
    }
    else if(a[i]==5){
      cout << 'F';
    }
    else if(a[i]==6){
      cout << 'G';
    }
    else if(a[i]==7){
      cout << 'H';
    }
    else if(a[i]==8){
      cout << 'I';
    }
    else if(a[i]==9){
      cout << 'J';
    }
    else if(a[i]==10){
      cout << 'K';
    }
    else if(a[i]==11){
      cout << 'L';
    }
    else if(a[i]==12){
      cout << 'M';
    }
    else if(a[i]==13){
      cout << 'N';
    }
    else if(a[i]==14){
      cout << 'O';
    }
    else if(a[i]==15){
      cout << 'P';
    }
    else if(a[i]==16){
      cout << 'Q';
    }
    else if(a[i]==17){
      cout << 'R';
    }
    else if(a[i]==18){
      cout << 'S';
    }
    else if(a[i]==19){
      cout << 'T';
    }
    else if(a[i]==20){
      cout << 'U';
    }
    else if(a[i]==21){
      cout << 'V';
    }
    else if(a[i]==22){
      cout << 'W';
    }
    else if(a[i]==23){
      cout << 'X';
    }
    else if(a[i]==24){
      cout << 'Y';
    }
    else if(a[i]==25){
      cout << 'Z';
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {	
	int t=1;
//	cin >> t;
	while (t--) {
	   int n,x,time;
	   cin>>n>>x>>time;
	   
	   int a=n/x;
	   if(n%x!=0)
	    a++;
	 int ans=a*time;
	 cout<<ans<<endl;
	   
       
}
	    
	} 
	
	

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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<double> vd;
typedef vector<vd> vdd;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define debug_print(x...) cerr << "line " << __LINE__ << " : "; debug_print_in(x);

template <typename First>
void debug_print_in(First first){
  cerr << first << endl;
  return;
}

template <typename First, typename... Rest>
void debug_print_in(First first, Rest... rest){
  cerr << first << " ";
  debug_print_in(rest...);
  return;
}

void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

template <typename First>
void OUT(First first){
  cout << first << endl;
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

template<class t, class u> void chmax(t&a,u b){if(a<b)a=b;};
template<class t, class u> void chmin(t&a,u b){if(a>b)a=b;};
int popcount(int t){return __builtin_popcount(t);} //GCC
int popcount(ll t){return __builtin_popcountll(t);} //GCC

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cerr << VEC[i] << " ";
  }
  cerr << endl;
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i,MAT.size()){
    REP(j,MAT[i].size()){
      cerr << MAT[i][j] << " ";
    }
    cerr << endl;
  }
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll A, B, M;
  IN(A,B,M);
  vll a(A), b(B);
  ll a_min = INFLL, b_min = INFLL;
  REP(i,A){
    IN(a[i]);
    chmin(a_min, a[i]);
  }
  REP(i,B){
    IN(b[i]);
    chmin(b_min, b[i]);
  }
  ll ans = a_min + b_min;
  vll x(M), y(M), c(M);
  REP(i,M){
    IN(x[i], y[i], c[i]);
    x[i]--;
    y[i]--;
    chmin(ans, a[x[i]]+b[y[i]]-c[i]);
  }

  OUT(ans);

  return 0;
}

Measured memory_bytes: 4224
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true) {
			int n = sc.nextInt();
			int m = sc.nextInt();
			if(n == 0 && m == 0) break;
			int[] list1 = new int[n];
			int[] list2 = new int[m];
			for(int i = 0; i < n; i++) {
				list1[i] = sc.nextInt();
			}
			for(int i = 0; i < m; i++) {
				list2[i] = sc.nextInt();
			}
			int now = 0;
			int i = 0;
			for(i = 0; i < m; i++) {
				now += list2[i];
				if(now >= n-1) {
					break;
				}
				now += list1[now];
				if(now >= n-1) {
					break;
				}
			}
			System.out.println(i+1);
			
		}
		
		
		
		
	}
}

Measured memory_bytes: 27736
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(a) (a).begin(),(a).end()
using namespace std;
using ll = long long;
using P = tuple<ll,ll,int>;

int main(){
    int a,b; cin >> a >> b;
    cout << a * b << endl;
}

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

int main(){
    int n,k;
    int x,y;
    int sum = 0;

    cin >> n >> k >> x >> y;

    if(n <= k){
        sum = n * x;
    }
    else{
        sum = k * x + (n - k) * y;
    }

    cout << sum <<'\n';

    return 0;
}

Measured memory_bytes: 256
from collections import deque

N = int(input())

dic = {}
color = 0

for i in range(N-1):

    a,b = map(int,input().split())

    if a not in dic:
        dic[a] = []
    if b not in dic:
        dic[b] = []

    dic[a].append([b,i])
    dic[b].append([a,i])

    color = max(color,len(dic[a]),len(dic[b]))

print (color)

q = deque([[1,float("inf")]])
clis = [0] * (N-1)

while len(q) > 0:

    #print (q)
    now = q.popleft()
    np = now[0]
    ducolor = now[1]
    

    ncolor = 1
    for i in range(len(dic[np])):

        j = i
        if ncolor == ducolor:
            ncolor += 1

        nexp = dic[np][j][0]
        hen = dic[np][j][1]
        if clis[hen] == 0:
            clis[hen] = ncolor
            q.append([nexp,ncolor])
            ncolor += 1

for i in range(N-1):
    print (clis[i])


Measured memory_bytes: 98648
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;

int main(){
    long long a,b,x;
    cin>>a>>b>>x;
    if(a!=0){
        cout<<(b/x+1)-((a-1)/x+1)<<endl;
    }else{
        cout<<b/x+1<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
open System

// prelude
let readStr () = stdin.ReadLine()

let readInt () = stdin.ReadLine() |> int
let readInts () = stdin.ReadLine().Split() |> Array.map int

let pair = function
| [|a; b|] -> (a, b)
| _ -> failwith "owatta"

let triple = function
| [|a; b; c|] -> (a, b, c)
| _ -> failwith "owatta"

let inc n = n + 1
let dec n = n - 1

let inline flip f a b = f b a  

module Option =
  let getOr defaultValue = function
  | Some x -> x
  | None -> defaultValue

module Array =
  let modify (arr: _ []) i f =
    arr.[i] <- f arr.[i]

module Array2D =
  let modify (arr: _ [,]) i j f =
    arr.[i, j] <- f arr.[i, j]

// start

let rec popCnt = function | 0 -> 0 | n -> popCnt (n>>>1) + if (n&&&1) = 1 then 1 else 0

let N = readInt ()
let S = readStr ()

let charToSet c = 1<<<(int c - int 'a')

let (data, bucket, num) =
  let src = S.ToCharArray() |> Array.map charToSet
  let num =
    let rec f n = if n*n < src.Length then f (n+1) else n
    f 1
  let data = Array.create (num*num) 0
  let bucket = Array.create num 0
  for i in 0..(src.Length-1) do
    data.[i] <- src.[i]
    Array.modify bucket (i/num) ((|||) src.[i])
  data, bucket, num

let modify i c =
  data.[i] <- charToSet c
  bucket.[i/num] <-
    let rec f k = if (k/num) = (i/num) then data.[k] ||| f(k+1) else 0
    f ((i/num)*num)

let range a b =
  seq {
    let mutable x = a
    while (x%num)<>0 && x<b do
      yield data.[x]
      x<-x+1
    while b-x>=num do
      yield bucket.[x/num]
      x<-x+num
    while x<b do
      yield data.[x]
      x<-x+1
  }
  |> Seq.fold (|||) 0

type Query = Modify of int * Char | Range of int * int
let readQuery () =
  let qs = readStr().Split()
  match Array.head qs with
  | "1" -> Modify (int qs.[1], qs.[2].ToCharArray().[0])
  | "2" -> Range (int qs.[1], int qs.[2])
  | _ -> failwith "okasii"

let Q = readInt ()

let writer = new IO.StreamWriter(new IO.BufferedStream(Console.OpenStandardOutput()))
seq {
  for _ in 1..Q do
    let q = readQuery ()
    match q with
    | Modify (i, c) -> modify (i-1) c
    | Range (l, r) -> yield (range (l-1) r |> popCnt)
}
|> Seq.map (sprintf "%d")
|> Seq.iter writer.WriteLine 

writer.Dispose()

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

typedef int in;
#define int long long
int MAX=1e8;

int n,k;
int a[100005],dp[100005];

int f(int idx)
{
    if(idx==n-1)
        return 0;
    int &ret=dp[idx];
    if(ret!=-1)
        return ret;
    ret=f(idx+1)+abs(a[idx]-a[idx+1]);
    for(int i=2; i<=k; i++)
    {
        if(idx+i<n)
            ret=min(ret,f(idx+i)+abs(a[idx]-a[idx+i]));
    }
    return ret;
}

in main()
{
    int tc=1;
//    cin>>tc;
    while(tc--)
    {
        cin>>n>>k;
        for(int i=0; i<n; i++)
        {
            cin>>a[i];
        }
        memset(dp,-1,sizeof dp);
        cout<<f(0)<<endl;
    }
    return 0;
}


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

int main() {
	long long N, D, x, y, count=0;
  	cin >> N >> D;
    for (int i=0; i<N; i++){
    	cin >> x >> y;
        if (x*x+y*y <= D*D) count++;
    }
    cout << count << endl;
}

Measured memory_bytes: 3604
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
    
		// 整数の入力
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
        int x = sc.nextInt();
        int ans = 0;
      
        A : for(int ia = 0; ia <= a; ia++) {
          int sum = ia * 500;
          B : for(int ib = 0; ib <= b; ib++) {
            int sumB = sum;
            sumB += ib * 100;
            C : for(int ic = 0; ic <= c; ic++) {
              int sumC = sumB;
              sumC += ic * 50;
              if (sumC == x) {
                ans++;
                break C;
              } else if (sum > x) {
                break C;
              }
            }
          }
        }
    
		// 出力
		System.out.println(ans);
	}
}

Measured memory_bytes: 21844
*A, = map(int, open(0).read().split())
N = A[0]
visited = [0]*(N+1)

cnt = 0
a = 1
while True:
    a = A[a]
    cnt += 1
    if a == 2:
        print(cnt)
        break
    if visited[a]:
        print(-1)
        break
    visited[a] = True


Measured memory_bytes: 14196
w = int(input())
amida = list(range(1,w+1))
n = int(input())
for i in range(0,n):
  exchange = list(map(int,input().split(",")))
  amida[exchange[1]-1], amida[exchange[0]-1] = amida[exchange[0]-1], amida[exchange[1]-1]
for i in amida:
  print(i)

Measured memory_bytes: 7588
#include <stdio.h>

#define MAX 1000000


int insertionSort(int[], int, int);
int shellSort(int [], int);

int main() {
    int i;
    int array[MAX], n;

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

    shellSort(array, n);

    for (i = 0; i < n; i++) {
        printf("%d\n", array[i]);
    }
}

int shellSort(int array[], int n) {
    int i, m = 0, cnt = 0;
    int gap[MAX];

    for (i = n - 1; i > 1 ; i /= 2) {
        gap[m++] = i;
    }
    gap[m++] = 1;

    printf("%d\n", m);
    for (i = 0; i < m; i++) {
        printf("%d ", gap[i]);
    }
    printf("\n");

    for (i = 0; gap[i] > 0; i++) {
        cnt += insertionSort(array, n, gap[i]);
    }
    printf("%d\n", cnt);
    return cnt;
}

int insertionSort(int array[], int n, int gap) {
    int i, j, cnt = 0;
    int key;

    for (i = gap; i < n; i++) {
        key = array[i];
        j = i - gap;
        while (j >= 0 && key < array[j]) {
            array[j + gap] = array[j];
            j -= gap;
            cnt++;
        }
        array[j + gap] = key;
    }
    return cnt;
}




Measured memory_bytes: 5696
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int int_sort(const void * a, const void * b) {
	return strcmp((char *)a, (char *)b);
}
int int_sort2(const void * a, const void * b) {
	return strcmp((char *)b, (char *)a);
}

int main() {
	int i, n=1,max,min;
	char num[9];
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%s", &num[0]);
		qsort((void*)num, 8, 1,int_sort);
		min = atoi(num);
		qsort((void*)num, 8, 1, int_sort2);
		max = atoi(num);
		printf("%d\n", max-min);
	}
	return 0;
}

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

int partition(int A[],int n,int p,int r){
  int i, j;
  int tmp, pivot;
  pivot = A[r];
  i = p - 1;
  for(j = p;j<r;j++){
    if(A[j] < pivot){
      i++;
      tmp = A[i];A[i] = A[j];A[j] = tmp;
    }
  }
  tmp = A[i + 1];A[i + 1] = A[r];A[r] = tmp;
  return i + 1;
}

void QuickSort(int A[], int n, int p, int r){
  int q;
  if(p < r){
    q = partition(A,n,p,r);
    QuickSort(A,n,p,q-1);
    QuickSort(A,n,q+1,r);
  }
}

int main(){
  int N;cin >> N;
  int A[200000];
  for(int i = 0;i < N;++i){
    cin >> A[i];
  }
  QuickSort(A, N, 0, N-1);
  for(int i = 0;i < N-1;++i){
    if(A[i]==A[i+1]){
      cout << "NO";
      return 0;
    }
  }
  cout << "YES";
}


Measured memory_bytes: 1024
<?php

$in = trim(fgets(STDIN));

$l = 0;
$m = 0;
foreach (str_split($in, 1) as $c) {
    if (in_array($c, ['A', 'C', 'G', 'T'])) {
        $l++;
    } else {
        if ($l > $m) {
            $m = $l;
        }
        $l = 0;
    }
}
if ($l > $m) {
    $m = $l;
}
print $m;



Measured memory_bytes: 4604
#include<iostream>
#include<algorithm>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define NMAX 100000
#define INF 1e+6
#define scan(arg) cin>>arg
#define prin(arg) cout<<arg<<"\n"
#define prin2(arg1,arg2) cout<<arg1<<" "<<arg2<<"\n"
using namespace std;
typedef long long ll;
int n,a,b;
int main(){
  scan(n);scan(a);scan(b);
  int ans=0;
  rep1(i,n){
    int sum=0,j=i;
    sum+=j%10;
    while(j>=10){
      j/=10;
      sum+=j%10;
    }
    if(a<=sum&&sum<=b){
      ans+=i;
    }
  }
  prin(ans);
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(ll i=0; i<(n); ++i)
#define rep1(i,n) for(ll i=1; i<=(n); ++i)
#define repi(i,a,b) for(ll i=a; i<=(b); ++i)
#define rrep(i,n) for(ll i=(n-1); i>=0; --i)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define to_s to_string
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define print(x) cout<<(x)<<'\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
using Edge = pair<ll,ll>;
using Graph = vector<vector<Edge>>;
typedef pair<ll,ll> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
ll MOD = 1e9 + 7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}
ll devc(ll x, ll y){return 1 + (x-1)/y;}
ll modpow(ll x, ll y, ll m) {
    if (y == 0) return 1;
    ll res = modpow(x, y / 2, m);
    return res * res % m * (y & 1 ? x : 1) % m;
}
ll modinv(ll x) { return modpow(x, MOD - 2, MOD); }

ll func(ll H){
    if(H == 1) return 1;
    else return func(H/2)*2 + 1;
    throw;
}

int main(){
    ll H; cin >> H;
    print(func(H));
    
    return 0;
}

Measured memory_bytes: 256
n = int(input())

l = [0] * (n+1)

for i in range(n+1):
  if i == 0:
    l[0] = 2
  elif i == 1:
    l[1] = 1
  else:
    l[i] = l[i-2] + l[i-1]
    
print(l[n])

Measured memory_bytes: 9100