akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{

    class Program
    {
        static void Main()
        {
            Solve();

            Console.ReadKey();
        }

        static void Solve()
        {
            var N = GetInt();
            var A = GetIntArray();

            var left = -A.Max();
            var right = A.Max();
            while (right - left != 1)
            {
                var mid = (left + right) / 2;
                long sad = 0;
                for(int i = 0; i < N; i++)
                {
                    sad += Math.Abs(A[i] - (i + 1) - mid);
                }
                long nextsad = 0;
                for(int i = 0; i < N ; i++)
                {
                    nextsad += Math.Abs(A[i] - (i + 1) - mid - 1);
                }

                if (sad < nextsad)
                {
                    right = mid;
                }
                else
                {
                    left = mid;
                }

            }

            long leftans = 0;
            for (int i = 0; i < N; i++)
            {
                leftans += Math.Abs(A[i] - (i + 1) - left);
            }
            long rightans = 0;
            for (int i = 0; i < N; i++)
            {
                rightans += Math.Abs(A[i] - (i + 1) - right);
            }

            var ans = Math.Min(leftans, rightans);

            Console.Write(ans);
        }



        static public string GetStr() { return Console.ReadLine(); }
        static public int GetInt() { return int.Parse(Console.ReadLine()); }
        static public long GetLong() { return long.Parse(Console.ReadLine()); }
        static public string[] GetStrArray() { return Console.ReadLine().Split(' '); }
        static public int[] GetIntArray() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
        static public long[] GetLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
        static public List<double> GetDoubleList() { return Console.ReadLine().Split(' ').Select(double.Parse).ToList(); }
        static public void WriteObjects<T>(IEnumerable<T> values) { foreach (var o in values) { Console.Write(o + " "); } }

        static bool eq<T, U>() => typeof(T).Equals(typeof(U));
        static T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
        static T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s))
                           : eq<T, long>() ? ct<T, long>(long.Parse(s))
                           : eq<T, double>() ? ct<T, double>(double.Parse(s))
                           : eq<T, char>() ? ct<T, char>(s[0])
                                             : ct<T, string>(s);
        static void Multi<T>(out T a) => a = cv<T>(GetStr());
        static void Multi<T, U>(out T a, out U b)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]);
        }
        static void Multi<T, U, V>(out T a, out U b, out V c)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]);
        }
    }
}

Measured memory_bytes: 30940
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val s = sc.next()
  val k = sc.nextLong()

  val len = s.length

  var now = s.first()
  var count = 1L
  var ans = 0L
  var flag = true
  var topCount = 1L
  var bottomCount = 1L
  for (i in 1 until len) {
    if (s[i] != now) {
      flag = false
      ans += count / 2
      count = 1L
      now = s[i]
    } else {
      count++
      if (flag) topCount++
    }
  }
  if (count > 1L) ans += count / 2
  now = s.last()
  for (i in len-2 downTo 0) {
    if (now != s[i]) break
    bottomCount++
  }

  if (topCount == len.toLong()) println(len * k / 2)
  else if (s.first() == s.last()) println(ans * k - (topCount / 2 + bottomCount / 2 - (topCount + bottomCount)/2) * (k-1))
  else println(ans * k)

}


Measured memory_bytes: 37612
// Author: Shusuke Ueda
// AtCoder Beginner Contest 136 - Problem D

#include <iostream>
#include <vector>

int main() {
    std::string s;
    std::cin >> s;
    int n = s.length();

    std::vector<int> ans(n);
    int r = 0;
    for (int i = 0; i < n; i++) {
        if (s[i] == 'R') {
            r++;
        } else {
            ans[i] += r / 2;
            ans[i - 1] += (r + 1) / 2;
            r = 0;
        }
    }
    int l = 0;
    for (int i = n - 1; i >= 0; i--) {
        if (s[i] == 'L') {
            l++;
        } else {
            ans[i] += l / 2;
            ans[i + 1] += (l + 1) / 2;
            l = 0;
        }
    }

    for (int i = 0; i < n; i++) {
        if (i > 0) {
            std::cout << ' ';
        }
        std::cout << ans[i];
    }
    std::cout << std::endl;

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int popcount(int n) {
    int r = 0;
    while (n > 0) {
        r += n&1;
        n >>= 1;
    }
    return r;
}
int popcount(string n) {
    int r = 0;
    for (auto c: n) {
        r += c == '1';
    }
    return r;
}
int f(int n) {
    int k = 0;
    while (n != 0) {
        n %= popcount(n);
        k++;
    }
    return k;
}
int pow_mod(int a, int b, int mod) {
    if (b == 0) return 1 % mod;
    ll k = pow_mod(a, b/2, mod);
    k *= k;
    k %= mod;
    if (b % 2 == 0) return k;
    return (k*a) % mod;
}
int main() {
    int N;
    string X;
    cin >> N >> X;
    reverse(X.begin(), X.end());
    int s = popcount(X);
    int A = 0, B = 0;
    for (int i = 0; i < N; i++) {
        if (X[i] == '1') {
            A += pow_mod(2, i, s+1);
            A %= s+1;
            if (s-1 > 0) {
                B += pow_mod(2, i, s-1);
                B %= s-1;
            }
        }
    }
    for (int i = N-1; i >= 0; i--) {
        if (X[i] == '1') {
            if (s-1 == 0) {
                cout << 0 << endl;
                continue;
            }
            int b = B;
            b -= pow_mod(2, i, s-1);
            b += s-1;
            b %= s-1;
            cout << 1+f(b) << endl;
        }
        else {
            int a = A;
            a += pow_mod(2, i, s+1);
            a %= s+1;
            cout << 1+f(a) << endl;
        }
    }
}

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

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

	int N;
	scanf("%d", &N);

	int x, y, h;
	vector<int> x_zero, y_zero;
	vector<int> x_pos, y_pos, h_pos;
	for (int i = 0; i < N; i++) {
		scanf("%d %d %d", &x, &y, &h);
		if (h == 0) {
			x_zero.insert(x_zero.end(), x);
			y_zero.insert(y_zero.end(), y);
		} else {
			x_pos.insert(x_pos.end(), x);
			y_pos.insert(y_pos.end(), y);
			h_pos.insert(h_pos.end(), h);
		}
	}

	for (int Cx = 0; Cx <= 100; Cx++) {
		for (int Cy = 0; Cy <= 100; Cy++) {
			int h_est = abs(x_pos[0] - Cx) + abs(y_pos[0] - Cy) + h_pos[0];
			for (int i = 1; i < x_pos.size(); i++) {
				if (h_est !=
				    abs(x_pos[i] - Cx) + abs(y_pos[i] - Cy) + h_pos[i]) {
					goto next_loop;
				}
			}
			for (int i = 0; i < x_zero.size(); i++) {
				if (h_est > abs(x_zero[i] - Cx) + abs(y_zero[i] - Cy)) {
					goto next_loop;
				}
			}

			cout << Cx << " " << Cy << " " << h_est;
			return 0;
		next_loop:
			continue;
		}
	}
	cout << "Notfound";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define SORTR(x) sort(ALLR(x))
#define SORT(x) sort(ALL(x))
#define SUM(x) accumulate(ALL(A), 0)
#define EACH(i,x) for(typeof((x).begin()) i=(x).begin(); i!=(x).end(); ++i)
using VI=vector<ll>;
using VD=vector<ld>;
using VVI=vector<VI>;
using VC=vector<char>;
using VVC=vector<VC>;
using VS=vector<string>;
using PLL =pair<ll,ll>;
using PLD=pair<ld,ld>;
using VPLL=vector<PLL>;
const int INF  = 1<<30;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template <class BidirectionalIterator>
bool next_partial_permutation(BidirectionalIterator first, BidirectionalIterator middle,BidirectionalIterator last){reverse(middle, last); return next_permutation(first , last);}
#define COUT(x) cout<<x<<"\n";

void Main()
{
	ll N,D;
	ll result=0;
	string S;
	cin>>D>>N;

	if(D==0) result=N;
	if(D!=0) result=pow(100,D)*N;
	if(N==100) result+=pow(100,D);
	cout << result << "\n";
	return;
}

int main()
{
	std::cin.tie(0);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}


Measured memory_bytes: 256
#include <sys/time.h>

#include <iostream>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <utility>
#include <cctype>


#include <boost/multiprecision/cpp_int.hpp>

using namespace std;

using ll = unsigned long long;
using P = pair<double, double>;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mkp(a, b) make_pair(a, b)
ll mod = 1000000007LL;

namespace mp = boost::multiprecision;
using BigInt = mp::cpp_int;


int main() {
	string s;
	cin >> s;
	int max_r = 0;
	int cur = 0;
	for(char c : s) {
		if (c == 'R') {
			cur++;
			max_r = max(cur, max_r);
		} else {
			cur = 0;
		}
	}

	cout << max_r << endl;



	return 0;
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define chmax(x,y) x = max(x,y)


ll dp[3005][3005][4];
int A[3005][3005];

int main() {
  int R,C,K;
  cin >> R >> C >> K;

  rep(i,K) {
    int r,c,v;
    cin >> r >> c >> v;
    r--;
    c--;
    A[r][c]= v;
  }

  rep(i,R) rep(j,C) {
    if(i > 0) {
      rep(k,4){
        chmax(dp[i][j][0], dp[i-1][j][k]);
      }
    }
    if(j > 0){
      rep(k,4){
        chmax(dp[i][j][k], dp[i][j-1][k]);
      }
    }
    int v = A[i][j];
    if (v > 0) {
      for(int k=3; k>0; k--){
        chmax(dp[i][j][k], dp[i][j][k-1] + v);
      }
    }
  }
  
  ll ans = 0;
  rep(k,4){
    chmax(ans, dp[R-1][C-1][k]);
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
  int L, H, K;
  cin >> L >> H >> K;
  if (H - L < K * 2) {
    for (int i = L; i <= H; i++) {
      cout << i << endl;
    }
    return 0;
  }
  for (int i = 0; i < K; i++) {
    cout << L+i << endl;
  }
  for (int i = K; i > 0; i--) {
    cout << H+1-i << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(ll i = 0; i < n; i++)
const ll INF = 1LL << 60;

int main(){
    int H, W; cin >> H >> W;
    vector<vector<ll>> dp(10, vector<ll>(10, INF));
    rep(i, 10){
        rep(j, 10){
            cin >> dp[i][j];
        }
    }
    for(int k = 0; k < 10; k++){
        for(int i = 0; i < 10; i++){
            for(int j = 0; j < 10; j++) dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
        }
    }

    ll ans = 0;
    rep(i, H){
        rep(j, W){
            int c; cin >> c;
            if(c != -1 && c != 1){
                ans += dp[c][1];
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3632
#include<stdio.h>
#include<math.h>

int main(void){
	
	int i,j,k;
	int N;
	scanf("%d" ,&N);
	int W[2][N];
	int re[N]; 
	int max;
	
	
	for(i = 0; i<N; i++){
		scanf("%d" ,&W[0][i]);
	}
	for(j = 0; j<N; j++){
		scanf("%d" ,&W[1][j]);
	}
	
/*	for(i = 0; i<2; i++){
		for(j = 0; j<N; j++){
			printf("%d " ,W[i][j]);
		}
		printf("\n");
	}
*/	
	for(i = 0; i<N; i++) re[i] = 0;
	
	for(i = 0; i < N; i++){
		for(j = 0; j<2; j++){
			for(k = 0; k<N; k++){
				
				if(i ==k){
					re[i] += (W[0][k] + W[1][k]);
					j++;
					//printf("a");
				}else{
					re[i] += W[j][k];
				}
				//printf("%d ",re[i]);
			}
			//printf("\n");
		}
		
	}
	
	max = re[0];
	for(i = 1; i<N; i++){
		if(re[i] > max) max = re[i];
	}
	
	printf("%d\n" ,max);
	
}
	



Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
const long double PI = acos(-1);
typedef long long ll;
typedef pair<int64_t,int64_t> pll;
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};
#define INF (2147483647)
#define mod (1000000007)
#define limit (7368791)
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define ALL(a) begin(a),end(a)
#define sz(s) (s).size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second


void solve()
{
    int n;cin>>n;
    string s;cin>>s;
    auto res=unique(ALL(s));
    s.erase(res,s.end());
    cout<<s.size()<<endl;
}

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

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

using namespace std;

int main(){

    string str = "";
    cin >> str;
    int len = str.length();
    for(int i=0; i<len; i++){
        str[i] = (str[i] - 'A' +23) % 26 + 'A';
    }
    cout << str << endl;
    return 0;
}

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

namespace AtCoder2 {
	class Program {
		static void Main(string[] args) {

	
				var inputArray = retreiveStringArray();
			var inputCount = 2;

			// 不正な入力は処理しない
			if (inputArray.Length != inputCount) {
				Console.WriteLine("invalid input");
				return;
			}
			var decimalArray = inputArray.Select(x => decimal.Parse(x)).ToArray();

			//答えの出力
			var mul = decimalArray[0]* decimalArray[1];
			var ans = Math.Floor(mul);
			Console.WriteLine(ans);
		}

		/// <summary>
		/// スペースで区切られた文字列配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static string[] retreiveStringArray() {
			var inputArray = Console.ReadLine().Split(' ');
			return inputArray;
		}

		/// <summary>
		/// スペースで区切られた整数配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static long[] retreiveLongArray() {
			var inputArray = Console.ReadLine().Split(' ');
			var longArray = inputArray.Select(s => long.Parse(s));
			return longArray.ToArray();
		}
	}
}


Measured memory_bytes: 28208
#include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define repb(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define int long long
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int c,r,ans;
int d[10][10000],f[10];

void dfs(int now){
	if(now==c){
		int sum=0;
		rep(i,0,r){
			int tmp=0;
			rep(j,0,c){
				if((d[j][i] && f[j])||(d[j][i]==0 && f[j]==0)) tmp++;
			}
			tmp=max(tmp,c-tmp);
			sum+=tmp;
		}
		ans=max(ans,sum);
		return;
	}
	rep(i,0,2){
		f[now]=i;
		dfs(now+1);
	}
}

signed main(){
	while(1){
		cin>>c>>r;
		if(c+r==0) break;
		rep(i,0,c) rep(j,0,r) scanf("%d",&d[i][j]);
		ans=0;
		dfs(0);
		o(ans);
	}
}

Measured memory_bytes: 2020
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<utility>
#include<numeric>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<functional>
#include<iterator>
#include<cmath>
#include<cctype>
#include<cassert>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = INF+7;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define rep(i,n) FOR(i,0,n)

struct edge{int to,cost;};

void dump(int *b,int n){
	for(int i=0;i<n;i++){
		cout << b[i] << " ";
	}
	cout << "\n";
}

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

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	
	int n,m;
	scanf("%d %d",&n,&m);
	
	vector<P> py[n];
	int p,y;
	rep(i,m){
		scanf("%d %d",&p,&y);
		py[p-1].push_back(P(y,i));
	}
	rep(i,n) sort(py[i].begin(),py[i].end()); //py[県].(年,ind)
	
	int mae[m],usiro[m];
	int ind;

	rep(i,n){
		for(int j=0;j<py[i].size();j++){
			ind = py[i][j].second;
			mae[ind]=i+1,usiro[ind]=j+1;
		}
	}
	rep(i,m){
		printf("%06d%06d\n",mae[i],usiro[i]);
	}	

	return 0;
}

Measured memory_bytes: 7808
#include<bits/stdc++.h>
#define llong __int128
#define mkpr make_pair
#define x first
#define y second
#define iter iterator
#define riter reversed_iterator
#define y1 Lorem_ipsum_
#define tm dolor_sit_amet_
using namespace std;

inline int read()
{
	int x = 0,f = 1; char ch = getchar();
	for(;!isdigit(ch);ch=getchar()) {if(ch=='-') f = -1;}
	for(; isdigit(ch);ch=getchar()) {x = x*10+ch-48;}
	return x*f;
}

map<llong,llong> mp;
llong n,A,B,C,D;

void read128(__int128 &x) {long long y; scanf("%lld",&y); x = y;}

llong absl(llong x) {return x<0?-x:x;}

void updmin(llong &x,llong y) {x = min(x,y);}

void dfs(llong x)
{
	if(mp.count(x)) {return;}
	llong ret = x*D,t;
	t = x/2ll; dfs(t); updmin(ret,mp[t]+min((x-t)*D,A+(x%2ll)*D));
	t = (x+1)/2ll; dfs(t); updmin(ret,mp[t]+min((x-t)*D,A+(2ll-x%2ll)%2ll*D));
	t = x/3ll; dfs(t); updmin(ret,mp[t]+min((x-t)*D,B+(x%3ll)*D));
	t = (x+2)/3ll; dfs(t); updmin(ret,mp[t]+min((x-t)*D,B+(3ll-x%3ll)%3ll*D));
	t = x/5ll; dfs(t); updmin(ret,mp[t]+min((x-t)*D,C+(x%5ll)*D));
	t = (x+4)/5ll; dfs(t); updmin(ret,mp[t]+min((x-t)*D,C+(5ll-x%5ll)%5ll*D));
	mp[x] = ret;
	return;
}

int main()
{
	int T = read(); while(T--)
	{
		read128(n),read128(A),read128(B),read128(C),read128(D);
		mp.clear(); mp[0] = 0ll; mp[1] = D;
		dfs(n);
		printf("%lld\n",(long long)mp[n]);
	}
	return 0;
}

Measured memory_bytes: 4872
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    int arr[5];
    cin >> a >> b;
    arr[0]= a+b;
    arr[1]= a-b;
    arr[2]= a*b;
    sort(arr,arr+3);
    cout << arr[2] << endl;
    
}

Measured memory_bytes: 256
n = int(input())
A = list(map(int,input().split()))
count = [0]*(10**5 +1)
for a in A:
    count[a] += 1
    
ans = 0
for i in range(10**5 +1):
    if count[i]==0:
        continue
    else:
        ans += i*count[i]

q = int(input())
bc = [list(map(int,input().split())) for _ in range(q)]
for i in range(q):
    b,c = bc[i]
    ans += (c-b)*count[b]
    count[c] += count[b]
    count[b] = 0
    print(ans)

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

using namespace std;

#define mp make_pair
#define F first
#define S second
#define pb push_back
#define fo(i, n) for(int i = 1; i <= n; ++i)

typedef long long ll;
typedef pair<int, int> pii;

const int N = 200200;
const int mod = 1e9 + 7;

inline bool ask(string cur)
{
	cout << "? ";
	cout << cur << endl;
	string s;
	cin >> s;
	return s == "Y";
}

inline void print(string s)
{
	cout << "! " << s << endl;
	exit(0);
}

inline void solve_step()
{
	string res = "";
	for(int i = 1; i <= 11; ++i)
	{
		string cur = res;
		if(i == 1) cur += '2';
		else cur += '1';
		if(ask(cur))
			print(res + (i == 1 ? "1" : "0"));
		res += (i == 1 ? "1" : "0");
	}
}

int n;
int main()
{
	string check = "";
	int len = -1;
	for(int i = 1; i <= 11; ++i)
	{
		string res = check;
		if(i == 1) res += '1';
		else res += '0';
		if(!ask(res+ ""))
		{
			len = i - 1;
			break;
		}
		check += (i == 1 ? "1" : "0");
	}	
	if(len == -1)                     
		solve_step();
	else
	{
		string ans = "";
		for(int p = 1; p <= len; ++p)
		{
			int l = -1, r = 9;
			if(p == 1) l++;
			while(l + 1 < r)
			{
				int m = l + r >> 1;
				string check = ans;
				check += char(m + '0');
				for(int j = p + 1; j <= len + 1; ++j)
					check += '9';
				if(!ask(check))
					l = m;
				else
					r = m;
			}	
			ans += char(r + '0');
		}
		print(ans);
	}
	return 0;
}

Measured memory_bytes: 596
#include<iostream>
#include<algorithm>
using namespace std;
#define mod 1000000007
typedef long long ll;

using namespace std;
#define N 4010
class CS{
  public:
  ll cs[N];
  void init(ll a[]){
    cs[0]=0;
    for(int i=0;i<N-1;i++){
      cs[i+1]=cs[i]+a[i];
    }
  }
  ll qry(ll l,ll r){
    if(l<0)l=0;
    return (cs[r+1]-cs[l])%mod;
  }
};CS cs;

ll f[N][N],n,m,k;
int main(){
    cin>>n>>m>>k;
    for(int i=0;i<N;i++)f[0][i]=0; f[0][0]=1;
    for(int i=1;i<N;i++){
      cs.init(f[i-1]);
      for(int j=0;j<N;j++){
	f[i][j]=cs.qry(j-k+1,j);
      }
    }
    ll ans=0;
    for(;n>0;n-=(k-1)){
      ll s=(n+m-1)/(k-1);
      ans=(ans+f[s][n])%mod;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 125952
/*
 *	Argorithms and Data Structures
 *	Lectuire 2
 *	Bubble Sort
 */

#include <stdio.h>

#define MAX_N 100

int main(void){
	int A[MAX_N], N;
	int i, j, count = 0, hoge;

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


	for( i=0; i<N-1; i++){
		for( j=N-1; j>i; j--){
			 if( A[j] < A[j-1]){
				 hoge = A[j];
				 A[j] = A[j-1];
				 A[j-1] = hoge;
				 count++;
			 }
		}
	}

	for( i=0; i<N-1; i++)
		printf("%d ", A[i]);
	printf("%d\n", A[i]);
	printf("%d\n", count);

	return 0;
}

Measured memory_bytes: 600
import math
import sys

def getinputdata():

    # 配列初期化
    array_result = []
    
    data = input()

    
    array_result.append(data.split(" "))

    flg = 1

    try:


        while flg:

            data = input()

            array_temp = []

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = 1

            else:

                flg = 0
    finally:


        return array_result





arr_data = getinputdata()

s = arr_data[0][0]

print(s.replace("2017","2018"))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
#define MOD 1000000007
using ll = long long;
using namespace std;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int r;
cin>>r;
if(r<1200){
    cout<<"ABC"<<endl;
}
else if(r<2800){
    cout<<"ARC"<<endl;
}
else{
    cout<<"AGC"<<endl;
}
//system("pause");
return 0;
}

Measured memory_bytes: 256
use io::*;

fn main() {
    let con = read_string();
    let mut sc = Scanner::new(&con);
    let r: i32 = sc.next();

    let ans = if r < 1200 {
        "ABC"
    } else if r < 2800 {
        "ARC"
    } else {
        "AGC"
    };
    println!("{}", ans);
}

pub mod io {
    use std;
    use std::str::FromStr;

    pub struct Scanner<'a> {
        iter: std::str::SplitWhitespace<'a>,
    }

    impl<'a> Scanner<'a> {
        pub fn new(s: &'a str) -> Scanner<'a> {
            Scanner {
                iter: s.split_whitespace(),
            }
        }

        pub fn next<T: FromStr>(&mut self) -> T {
            let s = self.iter.next().unwrap();
            if let Ok(v) = s.parse::<T>() {
                v
            } else {
                panic!("Parse error")
            }
        }

        pub fn next_vec_len<T: FromStr>(&mut self) -> Vec<T> {
            let n: usize = self.next();
            self.next_vec(n)
        }

        pub fn next_vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
            (0..n).map(|_| self.next()).collect()
        }
    }

    pub fn read_string() -> String {
        use std::io::Read;

        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }

    pub fn read_line() -> String {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().to_owned()
    }
}


Measured memory_bytes: 4476
#include<stdio.h>

int main(void)
{
	int b1, b2, b3;
	
	scanf( "%d %d %d", &b1, &b2, &b3 );
	
	if ( b1 & b2 | b3 ) printf( "Open\n" );
	else printf( "Close\n" );
	
	return 0;
}

Measured memory_bytes: 584
#!/usr/bin/env python
# -*- coding: utf-8 -*-
 
def pow(a, b):
    if b == 1:return a
    if b%2 == 0: return pow(a*a, int(b/2))
    return a*pow(a*a, int(b/2))
 
def binaryOne(n, multi):
    l, r = 0, n
    mid = (l + r)/2    
    while r - l > 1:
        if pow(mid, multi) >= n:
            r = mid
        else:
            l = mid
        mid = (r + l)/2
    return r;
 
 
def binaryTwo(n, maxi, multi):
    l, r = 0, multi
    mid = (l + r)/2
    while r - l > 1:
        if pow(maxi, (multi - mid))*pow(maxi - 1, mid) >= n:
            l = mid
        else:
            r = mid
        mid = (r + l)/2;
    return l
 
n, a = map(int,raw_input().split(" "))
ans = 1e18
for i in xrange(0, 40):
    maxi = binaryOne(n, i + 1);
    subt = binaryTwo(n, maxi, i + 1)
    ans = min(ans, a*i + maxi*(i + 1) - subt)
    
print ans

Measured memory_bytes: 2696
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	N := nextInt()
	T := nextInt()
	tList := nextInts(N)

	// pp.Println(N, T, tList)

	result := 0
	currentTime := 0

	for _, t := range tList[1:] {
		// fmt.Println(t)
		if t-currentTime < T {
			result += t - currentTime
		} else {
			result += T
		}
		currentTime += t - currentTime
	}
	result += T
	fmt.Println(result)
}

// 引数処理
func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}

func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}

func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}


Measured memory_bytes: 5120
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#define ll long long
using namespace std;
struct Point
{
	ll x,y;
	Point(ll xx=0,ll yy=0){x=xx,y=yy;}
	Point operator+(Point p){return Point(x+p.x,y+p.y);}
	Point operator-(Point p){return Point(x-p.x,y-p.y);}
	Point operator*(int d){return Point(x*d,y*d);}
	Point operator/(int d){return Point(x/d,y/d);}
	ll dot(Point p){return x*p.x+y*p.y;}
	ll det(Point p){return x*p.y-y*p.x;}
}a[1005],b[105],tmp[1005];
int n,num,st[1006],top;
bool cmp(Point a,Point b)
{
	return a.x<b.x||(a.x==b.x&&a.y<b.y);
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%lld%lld",&b[i].x,&b[i].y);
	num=1;
	a[1]=Point(0ll,0ll);
	for(int xx=1;xx<=n;xx++)
	{
		for(int j=1;j<=num;j++)
			a[j+num]=a[j]+b[xx];
		num*=2;
		sort(a+1,a+num+1,cmp);
		top=0;
		for(int i=1;i<=num;i++)
		{
			while(top>=2&&(a[i]-a[st[top]]).det(a[st[top]]-a[st[top-1]])<=0)top--;
			st[++top]=i;
		}
		for(int i=1;i<=top;i++)tmp[i]=a[st[i]];
		int now=top;
		top=0;
		for(int i=1;i<=num;i++)
		{
			while(top>=2&&(a[i]-a[st[top]]).det(a[st[top]]-a[st[top-1]])>=0)top--;
			st[++top]=i;
		}
		for(int i=2;i<top;i++)tmp[++now]=a[st[i]];
		for(int i=1;i<=now;i++)a[i]=tmp[i];
		num=now;
	}
	ll ans=0;
	for(int i=1;i<=num;i++)
	  ans=max(ans,a[i].x*a[i].x+a[i].y*a[i].y);
	printf("%.100lf\n",sqrt(ans));
	return 0;
}

Measured memory_bytes: 384
N = int(input())
T,A=map(int,input().split())
h_list =list(map(int,input().split()))
dif_list = [abs(A-(T-x*0.006)) for x in h_list]
mn =min(dif_list)
for i in range(N):
	if mn == dif_list[i]:
		break
print(i+1)

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


int main() {

	int H, W;
	char A[200][200];
	scanf("%d%d", &H, &W);

	for (int i = 0; i < H; i++) {
		scanf("%s", A[i]);
	}

	for (int i = 0; i < W+2; i++) {
		printf("#");
	}
	printf("\n");

	for (int i = 0; i < H; i++) {
		printf("#%s#\n", A[i]);
	}


	for (int i = 0; i < W + 2; i++) {
		printf("#");
	}


}


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

#define int long long

using namespace std;

#define REP(i, n)   for(int i = 0; i < (n); i++)
#define REPS(i, n)  for(int i = 1; i <= (n); i++)
#define RREP(i, n)  for(int i = (n)-1; i >= 0; i--)
#define RREPS(i, n) for(int i = (n); i > 0; i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define mt make_tuple
#define pb push_back

using ll  = long long;
using pi  = pair<int, int>;
using pl  = pair<ll, ll>;
using vi  = vector<int>;
using vl  = vector<ll>;
using vs  = vector<string>;
using vb  = vector<bool>;
using vvi = vector<vi>;
using vvl = vector<vl>;

const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const ll  INFL = 1e18;
const double PI = 3.141592653589793;
const double EPS = 1e-9;

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

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int a, b, h; cin >> a >> b >> h;
    cout << (a+b) * h / 2 << endl;
}

Measured memory_bytes: 3644
#include <iostream>
using namespace std;
#define D 600

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

  int d;
  while(cin >> d) {
    int s = 0;
    for(int n=d;n<D;n+=d) {
      s += n*n * d;
    }
    cout << s << endl;
  }
}

Measured memory_bytes: 1192
#!/usr/bin/env ruby

n = gets.to_i
cards = gets.split.map{|n| n.to_i }.sort.reverse

sum1 = 0
sum2 = 0

cards.each_slice(2) do |a, b|
  sum1 += a.to_i
  sum2 += b.to_i
end

puts sum1 - sum2


Measured memory_bytes: 1788
#define _USE_MATH_DEFINES

#include <iostream>
#include <math.h> 
#include <vector>
#include <algorithm>
#include <iomanip>      // std::setprecision
#include <map>
#include <unordered_map>
#include <string>
#include <set>
#include <unordered_set>

using namespace std;

int main()
{
	int a;
	std::set<int> nums;
	int num_matches = 0;
	int num_unmatches = 0;
	for (int i = 0; i < 3; i++)
	{
		std::cin >> a;
		if (!nums.count(a))
		{
			num_unmatches++;
			nums.insert(a);
		}
		else
		{
			num_matches++;
		}
	}
	if (num_matches == 1 && num_unmatches == 2)
		std::cout << "Yes\n";
	else
		std::cout << "No\n";
	
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <unordered_map>
#include <climits>
#include <cmath>
#include <cstdint>


using namespace std;

template<class T>
T read()
{
    T value;
    std::cin >> value;
    return value;
}

template<class F>
void times_do(size_t n, F func)
{
    for(size_t i = 0; i < n; ++i) func();
}

template<class T>
vector<T> reads(size_t n)
{
    vector<T> a;
    a.reserve(n);
    times_do(n, [&](){
        a.push_back(read<T>());
    });
    return a;
}

uint64_t strange_fact(int n){
    if(n == 0) return 1;
    uint64_t f = n;
    while(n > 1)
    {
        f *= --n;
        f %= 1'000'000'007;
    }
    return f;
}

uint64_t strange_perm(int n, int m){
    if(n == 0) return 1;
    uint64_t f = n;
    while(n > 1 && --m > 0)
    {
        f *= --n;
        f %= 1'000'000'007;
    }
    return f;
}

int main()
{
    const int N = read<int>();
    const int M = read<int>();
    
    if(abs(N-M) > 1)
    {
        cout << 0 << endl;
        return 0;
    }
    cout << (N == M ? 2 : 1) * strange_fact(M) % 1'000'000'007 * strange_fact(N) % 1'000'000'007 << endl;
    return 0;
}


Measured memory_bytes: 1016
n, m = map(int, input().split())
a = [list(input()) for _ in range(n)]
b = [list(input()) for _ in range(m)]

def check():
    for i in range(n):
            for j in range(n):
                if i + m <= n and j + m <= n:
                    aa = []
                    for k in range(m):
                        aa.append(a[i + k][j : j+m])
                    if aa == b:
                        return 'Yes'
    return 'No'

print(check())

Measured memory_bytes: 3064
fun main(arr: Array<String>) {
    val (w,h,n) = readLine()!!.split(" ").map { it.toInt() }
    val map = (1..h).map { (1..w).map { 0 }.toMutableList() }.toMutableList()
    for(i in (1..n)) {
        val (x,y,a) = readLine()!!.split(" ").map { it.toInt() }
        when (a) {
            1 -> {
                (0 until h).forEach { yidx-> (0 until w).filter { it < x }.forEach { xidx -> map[yidx][xidx] = 1 } }
            }
            2 -> {
                (0 until h).forEach { yidx-> (0 until w).filter { it >= x }.forEach { xidx -> map[yidx][xidx] = 1 } }
            }
            3 -> {
                (0 until h).filter { it < y }.forEach { yidx -> map[yidx] = (0 until w).map { 1 }.toMutableList() }
            }
            else -> {
                (0 until h).filter { it >= y }.forEach { yidx -> map[yidx] = (0 until w).map { 1 }.toMutableList() }
            }
        }
    }
    val ans = map.map { it.count { it==0 } }.sum()
    println(ans)
}

Measured memory_bytes: 56552
#include <bits/stdc++.h>
using namespace std;
#define F(i, s, t) for (int i = (s), _ = (t); i <= _; i ++)
const int N = 200005;
int n, a[N], b[N];
int ans, s[2][N], t[2][N];
namespace Input {
	const int S = 10000000;
	char s[S], *h = s+S, *t = h;
	char nchar() {
		if (h == t) fread(s, 1, S, stdin), h = s;
		return *h ++;
	}
	int rd() {
		int x = 0; char c;
		do { c = nchar(); } while (! isdigit(c));
		do { x = x*10+c-'0', c = nchar(); } while (isdigit(c));
		return x;
	}
}
using Input::rd;
void Get(int s[2][N], int a[N], int x) {
	s[0][0] = s[1][0] = 0;
	F(i, 1, n) {
		int ty = a[i] >> x & 1;
		s[ty][++ s[ty][0]] = a[i] & ((1 << x+1) - 1);
	}
	sort(s[0] + 1, s[0] + s[0][0] + 1);
	sort(s[1] + 1, s[1] + s[1][0] + 1);
}
int main() {
	n = rd();
	F(i, 1, n) a[i] = rd();
	F(i, 1, n) b[i] = rd();
	for (int x = 0; x <= 28; x ++) {
		Get(s, a, x);
		Get(t, b, x);
		int cur = 0;
		for (int i = 1, j = t[0][0] + 1, LI = 1 << x; i <= s[0][0]; i ++) {
			while (j > 1 && s[0][i] + t[0][j-1] >= LI)
				j --;
			cur ^= (t[0][0] - j + 1 & 1);
		}
		for (int i = s[1][0], j = 0, LI = 1 << x+1; i; i --) {
			while (j < t[0][0] && s[1][i] + t[0][j+1] < LI)
				j ++;
			cur ^= (j & 1);
		}
		for (int i = s[0][0], j = 0, LI = 1 << x+1; i; i --) {
			while (j < t[1][0] && s[0][i] + t[1][j+1] < LI)
				j ++;
			cur ^= (j & 1);
		}
		for (int i = 1, j = t[1][0] + 1, LI = (1 << x) + (1 << x+1); i <= s[1][0]; i ++) {
			while (j > 1 && s[1][i] + t[1][j-1] >= LI)
				j --;
			cur ^= (t[1][0] - j + 1 & 1);
		}
		if (cur) ans += 1 << x;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 10624
from fractions import gcd

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

nums = b - a + 1
c_count = b // c - a // c + 1 if a % c == 0 else b // c - a // c
d_count = b // d - a // d + 1 if a % d == 0 else b // d - a // d
lcm = c * d // gcd(c, d)
lcm_count = b // lcm - a // lcm + 1 if a % lcm == 0 else b // lcm - a // lcm
print(nums - c_count - d_count + lcm_count)


Measured memory_bytes: 5048
n=int(input())
#print(ord('a'),ord('z'))

c=1
while 1:
    if n-26**c<=0:
        break
    else:
        n=n-26**c
        c+=1
#print(c,n)

d=[]
n-=1
for i in range(c-1):
#    print(n//(26**(c-1-i)))
    d.append(n//(26**(c-1-i)))
    n=n-(26**(c-1-i))*(n//(26**(c-1-i)))
d.append(n)
#print(d)

s=[]
for j in range(c):
    s.append(chr(ord('a')+d[j]))
print(''.join(s))

Measured memory_bytes: 9112
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,q;
  cin >> n >> q;
  string s;
  cin >> s;
  vector<int> l(q),r(q),a(n);
  for(int i=0;i<q;i++){
    cin >> l[i] >> r[i];
  }
  for(int i=1;i<n;i++){
    if(s[i-1]=='A'&&s[i]=='C'){
      a[i]=a[i-1]+1;
    }
    else{
      a[i]=a[i-1];
    }
  }
  for(int i=0;i<q;i++){
    cout << a[r[i]-1]-a[l[i]-1] << endl;
  }
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
int main(){
  int c;
  cin>>c;
  if(0<c/100&&c/100<=12){
    if(0<c%100&&c%100<=12){
      cout<<"AMBIGUOUS"<<endl;
    }
    else cout<<"MMYY"<<endl;
  }
  else{
    if(0<c%100&&c%100<=12){
      cout<<"YYMM"<<endl;
    }
    else cout<<"NA"<<endl;
  }
}

Measured memory_bytes: 256
#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 MOD = 1e9 + 7, INF = 1e9;
using vi = vector <int>;
using vvi = vector <vi>;
//g++ -std==c++14

signed main(){
	int n, m;
	cin >> n >> m;

	vi v(n), w(n);
	rep(i, n)cin >> v[i] >> w[i];

	vi dp(n * 100 + 1, 1e18);
	dp[0] = 0;

	rep(i, n){
		for(int j = n * 100; j >= 0; j--){
			if(dp[j] != 1e19 && dp[j] + w[i] <= m)
				dp[j + v[i]] = min(dp[j + v[i]], dp[j] + w[i]);
			}
	}

	int ans;
	rep(i, dp.size())
		if(dp[i] != 1e18)ans = i;
	cout << ans << endl;
}

Measured memory_bytes: 3200
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef vector< long long > vll;
typedef pair< int,int > ii;
typedef long long ll;
#define sz(a) int((a).size())
#define pb push_back
#define mp  make_pair
#define mod 1000000007
#define mod2 998244353
#define all(c) c.begin(),c.end()
#define tr(c,i) for(typeof(c).begin() i = c.begin(); i != c.end(); i++)
#define present(c,x) (c.find(x) != c.end())
#define cpresent(c,x) (find(all(c),x) != c.end())
#define rep(i, a, b) for (int i = (a); i <= int(b); i++)
#define fo(i,n) for(ll i=0;i<n;i++)
#define YES cout<<"YES\n"
#define NO cout<<"NO\n"
#define Yes cout<<"Yes\n"
#define No cout<<"No\n"
#define nl "\n"
ll gcd (ll a, ll b) {
    if (b == 0)
        return a;
    else
        return gcd (b, a % b);
}

unsigned long long factorial[1000004]; 
    /*factorial[0] = 1; 
    for (int i = 1; i <= n; i++) {
        factorial[i] = (factorial[i - 1] * i) % mod3; 
    }*/




unsigned long long power(unsigned long long x, 
                         int y, int p) 
{ 
    unsigned long long res = 1; // Initialize result 
  
    x = x % p; // Update x if it is more than or 
    // equal to p 
  
    while (y > 0) { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res * x) % p; 
  
        // y must be even now 
        y = y >> 1; // y = y/2 
        x = (x * x) % p; 
    } 
    return res; 
} 



  
// Returns n^(-1) mod p 
unsigned long long modInverse(unsigned long long n, int p) 
{ 
    return power(n, p - 2, p); 
} 
unsigned long long nc(unsigned long long n, 
                                 int r, int p) 
{ 
    // Base case 
    if (r == 0) 
        return 1; 
  
    // Fill factorial array so that we 
    // can find all factorial of r, n 
    // and n-r 
 
  
    return (factorial[n]* modInverse(factorial[r], p) % p * modInverse(factorial[n - r], p) % p) % p; 
} 



int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

   string s,t;
   cin>>s;
   cin>>t;
   int n=s.length();
   int m = t.length();
   int ma = 10000;
   
   for(int i=0;i<=n-m;i++){
       int c=0;
        for(int j=0;j<m;j++){
            if(s[i+j]!=t[j]){
                c++;
            }
        }
        ma = min(c,ma);
   }
   cout<<ma<<nl;
    

    


	return 0;
}


Measured memory_bytes: 3656
#include<vector>
#include<iostream>
#include<algorithm>
#include <stdint.h>
#include <math.h>

using namespace std;
const int INF = (1<<31) - 1;
class segment_tree {
private:
	int n;
	vector<int> node;
public:
	//元配列をセグメント木で表現する
	segment_tree(vector<int>v) {
		
		int sz = v.size();
		//最下段のノード数は元配列のサイズ以上になる最小の2冪->これをnとおく
		n = 1;
		while (n < sz) {
			n *= 2;
		}
		node.resize(2 * n - 1, INF);
		//最下段を初期化
		for (int i = 0; i < sz; i++) {
			node[i + n - 1] = v[i];
		}
		//親の値を決めていく
		for (int i = n - 2; i >= 0; i--) {
			node[i] = min(node[2 * i + 1], node[2 * i + 2]);
		}
	}

	void update(int x, int val) {
		x += (n - 1);
		node[x] = val;
		while (x > 0) {
			x = (x - 1) / 2;
			node[x] = min(node[2 * x + 1], node[2 * x + 2]);
		}
	}
	//[a,b)の最小値を求める
	//k番目のノード　範囲は[l,r)
	int query(int a, int b, int k=0, int l=0, int r=-1) {
		if (r < 0) {
			r = n;
		}
		if (r <= a || b <= l)
		{
			return INF;
		}
		if (a <= l && r <= b)
		{
			return node[k];
		}
		else
		{
			int vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
			int vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
			return min(vl, vr);
		}
	}

};

int main() {
	int N;
	int Q;
	cin >> N >> Q;
	segment_tree seg(vector<int>(N, INF));
	for (int i = 0; i < Q; i++) {
		int c, x, y;
		cin >> c >> x >> y;
		if (c == 0) {
			seg.update(x, y);
		}
		else {
			cout << seg.query(x, y + 1) << endl;
		}
	}
}








Measured memory_bytes: 4160
program speedrun
    use iso_fortran_env
implicit none
integer::N
character(10**5)::S
integer::ans=1
integer::i
read*,N
read*,S
do i=2,N
    if(S(i:i)/=S(i-1:i-1))ans=ans+1
end do
print"(i0)",ans
end program speedrun

Measured memory_bytes: 1084
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;
constexpr ll INF = (1LL << 55);

int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  vector<set<int>> st(26);
  for (int i = 0; i < n; i++) {
    st[(int)s[i] - 'a'].insert(i);
  }
  int q;
  cin >> q;
  while (q--) {
    int f;
    cin >> f;
    f--;
    if (!f) {
      int i;
      char c;
      cin >> i >> c;
      i--;
      st[s[i] - 'a'].erase(i);
      s[i] = c;
      st[s[i] - 'a'].insert(i);
    } else {
      int l, r, res = 0;
      cin >> l >> r;
      l--; r--;
      for (int i = 0; i < 26; i++) {
        auto itr1 = st[i].lower_bound(l);
        if (itr1 == st[i].end()) continue;
        if (*itr1 > r) continue;
        res++;
      }
      cout << res << endl;
    } 
  }
  return 0;
} 

Measured memory_bytes: 24196
#include<bits/stdc++.h>
#define N 3
using namespace std;
char s[N];
int main()
{
	scanf("%s", s);
	if(s[2])
		for(int i = 2; i >= 0; -- i)
			putchar(s[i]);
	else
		printf("%s", s);
	return 0;
}

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

typedef long long ll;
typedef pair<int,int> P;
ll const mod = 1e9+7;

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

int main() {
    int n,k;
    cin >> n >> k;
    vector<int> a(n);
    vector<vector<int>> dp(n+1,vector<int>(k+1,0));
    for (int i = 0;i < n;++i) cin >> a[i];
    dp[0][0] = 1;
    for (int i = 0;i < n;++i) {
        vector<int> sums(k+2,0);
        for (int j = 0;j < k+1;++j) sums[j+1] = (sums[j]+dp[i][j])%mod;
        for (int j = 0;j < k+1;++j) dp[i+1][j] = (sums[j+1]-sums[max(0,j-a[i])])%mod;
    }
    cout << (dp[n][k]+mod)%mod << endl;
    return 0;
}

Measured memory_bytes: 40192
#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define inf (int)1e18+7
const int nmax = (int) 1e6 + 10;



int h[nmax];
int cost[nmax];

int absub(int a, int b) {
    return abs(a - b);
}

signed main() {
    ios_base :: sync_with_stdio(false);
    cin.tie(0);
    
    //cost[n] = min((cost[n - 1] + abs(h[n] - h[n - 1])), cost[n - 2] + abs(h[n] - h[n - 2]))
    
    int n, k;
    cin >> n >> k;
    for (int i = 1; i <= n; i ++) {
        cin >> h[i];
    }
    cost[1] = 0;
    cost[2] = absub(h[2], h[1]);

    for (int i = 3; i <= n ; i++) {
        cost[i] = inf;
        for (int j = i - 1; j >= i - k; j --) {
            if ( j == 0) break;
            int dif = absub(h[i], h[j]);
            cost[i] = min(cost[i], cost[j] + dif);    
        }
    }
    

    
    cout << cost[n] << endl;




    return 0;
}

Measured memory_bytes: 5120
#include<iostream>
#include<vector>
#include<cmath>
#include<cstdio>
using namespace std;

int main(void){
	double t,d;
	cin>>t>>d;
	double ta,tb;
	cin>>ta>>tb;
	double da,db;
	cin>>da>>db;
	double min = 100000;
	
	for(int i = 0 ; i <= d ; i += da){
		for(int j = 0 ; j + i <= d ; j += db){
			if(min>abs(t-(ta*i+tb*j)/(i+j)))
				min=abs(t-(ta*i+tb*j)/(i+j));
		}
	}

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

Measured memory_bytes: 1240
// -*- mode:c++; coding:utf-8; indent-tabs-mode:nil; -*-
// ALDS1_2-C

#include <cstring>
#include <algorithm>
#include <iostream>

struct card {
  char mark;
  unsigned int number;

  bool operator<(const card& rhs) { return number < rhs.number; }
};

std::ostream& operator<<(std::ostream& os, const card& card)
{
  return os << card.mark << card.number;
}

std::istream& operator>>(std::istream& is, card& card)
{
  return is >> card.mark >> card.number;
}

static void print_cards(const card cards[], const unsigned int n) {
  const char* sep = "";
  for (unsigned int i = 0; i < n; ++i) {
    std::cout << sep << cards[i];
    sep = " ";
  }
  std::cout << std::endl;
}

void bubble_sort(card cards[], const unsigned int n) {
  for (unsigned int j = 0; j < n-1; ++j) {
    for (unsigned int i = n-1; i > j; --i) {
      if (cards[i] < cards[i-1]) {
        std::swap(cards[i], cards[i-1]);
      }
    }
  }
}

void selection_sort(card cards[], const unsigned int n) {
  for (unsigned int i = 0; i < n-1; ++i) {
    unsigned int min_j = i;
    for (unsigned int j = i+1; j < n; ++j) {
      if (cards[j] < cards[min_j]) {
        min_j = j;
      }
    }
    if (i != min_j) {
      std::swap(cards[i], cards[min_j]);
    }
  }
}

int main(void) {
  unsigned int n;
  std::cin >> n;
  card cards1[n], cards2[n];
  for (unsigned int i = 0; i < n; ++i) {
    std::cin >> cards1[i];
  }
  std::memcpy(cards2, cards1, sizeof(cards1));

  bubble_sort(cards1, n);
  print_cards(cards1, n);
  std::cout << "Stable" << std::endl; // bubble sort is stable

  selection_sort(cards2, n);
  print_cards(cards2, n);
  if (std::memcmp(cards1, cards2, sizeof(cards1)) == 0) {
    std::cout << "Stable" << std::endl;
  } else {
    std::cout << "Not stable" << std::endl;
  }

  return 0;
}
// end

Measured memory_bytes: 1160
n = int(input())
data = list(map(int, input().split()))

count = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        for k in range(j+1, n):
            i_ = data[i]
            j_ = data[j]
            k_ = data[k]
            # 全て異なる値
            if i_ != j_ and i_ != k_ and j_ != k_:
                # 三角形が作成可能
                if sum([i_, j_, k_]) - max(i_, j_, k_) > max(i_, j_, k_):
                    # print("作れる　:", i_, j_, k_)
                    count += 1
                # else:
                #     print("作れない:", i_, j_, k_)                

print(count)


Measured memory_bytes: 9136
#include<iostream>
using namespace std;
int main(){
  long long x;
  cin >> x;

  if(x % 11 == 0) cout << (x / 11)*2 << endl;
  else if(x % 11 > 6) cout << (x / 11)*2 + 2 << endl;
  else cout << (x / 11) *2 + 1 << endl;
  return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
#define ALL(a)  (a).begin(),(a).end()
 
const ll mod = 1000000007;
const ll LINF = 1e13;
const ll LLINF = 1e18;
const ll ALPHABET = 26;
 
template <class T>
void Swap(T& r, T& l) {
  T tmp = r;
  r = l;
  l = tmp;
}
 
template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
  for (T& x : vec) is >> x; //for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいい
  return is;
}


int main(){
    // ll N,S,K;
    ll n,k;
    cin >> n >>k;
    vector<ll> h(n);
    cin >> h;

    ll ans = 0;
    for (ll i = 0; i < n; i++)
    {
        if (h[i] >= k)ans++;
    }
    

    cout << ans;
}


Measured memory_bytes: 1024