akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Deque;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Queue;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.Map.Entry;
import java.util.function.BiConsumer;

/**
 * Built using CHelper plug-in Actual solution is at the top
 */

public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Task solver = new Task();
		solver.solve(1, in, out);
		out.close();
	}

	static class Task {
		public void solve(int testNumber, InputReader in, PrintWriter out) {
			int n = in.nextInt();
			Map<Integer, Integer> map = new HashMap<Integer, Integer>();
			for (int i = 1; i <= n; i++) {
				map.put(i, in.nextInt());
			}

			List<Entry<Integer, Integer>> list_entries = new ArrayList<Entry<Integer, Integer>>(map.entrySet());

			Collections.sort(list_entries, new Comparator<Entry<Integer, Integer>>() {
				public int compare(Entry<Integer, Integer> obj1, Entry<Integer, Integer> obj2) {
					return obj1.getValue().compareTo(obj2.getValue());
				}
			});

			for (Entry<Integer, Integer> entry : list_entries) {
				System.out.print(entry.getKey() + " ");
			}

		}
	}

	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		public char nextChar() {
			return next().charAt(0);
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

	}
}


Measured memory_bytes: 55740
import sys
readline = sys.stdin.readline

N,M = map(int,readline().split())
A = sorted(list(map(int,readline().split())))

sumA = [0] + A.copy()
for i in range(1,len(sumA)):
  sumA[i] += sumA[i - 1]
  
# 左手34,33,19,14,10
# 右手34,33,19,14,10
# X以上の握手をできる組だけ採用する
# 例：50以上の握手をできるのは、
# 左手34に対しては34,33,19
# 右手33に対しては34,33,19
# この合計がM回を越えると採用できない。
# M回を下回る場合は、すべての握手の合計で最大値を更新

ok = -1
ng = 10 ** 5 * 2 + 1

import bisect
def isOk(x):
  # x以上の握手だけ採用するとき、採用できる場合に全体の合計点はいくつになるか
  cnt = 0
  for left in A:
    right = x - left
    ind = bisect.bisect_left(A, right)
    #print("N - ind",N - ind)
    cnt += N - ind
  #print("x",x,"cnt",cnt)
  if cnt > M:
    return True
  else:
    return False

while abs(ng - ok) > 1:
  #print("ng",ng,"ok",ok)
  mid = abs(ng + ok) // 2
  if isOk(mid):
    ok = mid
  else:
    ng = mid
    
#print("ok",ok)

# ok以上の握手だけ許容する場合の点数を算出
ans = 0
num = 0
#print("A",A)
#print("allA",allA)
for left in A:
  right = ok - left
  ind = bisect.bisect_left(A, right)
#  print("ok",ok,"left",left,"right",right,"ind",ind)
#  print("sumA",sumA,"ind",ind)
#  print("sumA[-1]",sumA[-1])
#  print("sumA[ind]",sumA[ind])
  ans += sumA[-1] - sumA[ind] + (N - ind) * left
  num += N - ind

if num > M:
  ans -= (num - M) * ok

print(ans)


Measured memory_bytes: 86960
#include <bits/stdc++.h>
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

i64 calc(i64 t) {
	if(t % 2) return 3 * t + 1;
	return t / 2;
}

int main() {
	i64 s; scanf("%lld", &s);
	
	int c = 1, a = s;
	std::map<i64, bool> mp; mp[s] = true;
	while(c++) {
		a = calc(a);
		
		if(mp[a]) {
			printf("%d\n", c);
			break;
		}
		mp[a] = true;
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <numeric>

using namespace std;

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

  vector<int> a(n + 1, 0);
  vector<int> w(n + 1, 0);

  for (int i = 0; i < m; ++i) {
    int idx;
    string str;
    cin >> idx >> str;
    if (str == "AC") {
      a[idx] = 1;
    }
    else {
      if (a[idx] == 0)
        ++w[idx];
    }
  }

  int suma = 0;
  int sumb = 0;
  for (int i = 1; i < n + 1; ++i) {
    if (a[i] == 0)
      continue;
    suma += a[i];
    sumb += w[i];
  }
  cout << suma << " " << sumb << endl;
}

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

int main(){
	int H, W;
	
	for(;;){
		cin >> H >> W;
		if(H == 0 && W == 0) break;
		for(int i = 0; i < H; i++){
			for(int j = 0; j < W; j++){
				if(i == 0 || i == H - 1){
					cout << "#";
				}else if(j == 0 || j == W - 1){
					cout << "#";
				}else {
					cout << '.';
				}
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
using LL = long long;
constexpr int maxn = 100000;
LL dp[maxn][2];
int main(){
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    dp[0][1] = -1e18;
    for(int i = 1, A; i <= N; i += 1){
        cin >> A;
        dp[i][0] = max(dp[i - 1][0] + A / 2, dp[i - 1][1] + (A + 1) / 2);
        if(A) dp[i][1] = max(dp[i - 1][0] + (A - 1) / 2, dp[i - 1][1] + A / 2);
        else dp[i][1] = -1e18;
    }
    cout << dp[N][0];
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define FORR(I,A,B) for(ll I = (B-1); I >= (A); --I)
const ll INF=1e18+7;
const ll MOD=1e9+7;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n,a,b;
	cin >> n >> a >> b;
	vector<ll> h(n);
	FOR(i,0,n)cin>>h[i];
	ll l = 0, r = MOD;

	while(r-l>1){
		ll mid = (l+r)/2;
		ll answ=0;



		FOR(i,0,n)if(h[i]>mid*b){
			answ += (h[i]-mid*b)/(a-b);
			if((h[i]-mid*b)%(a-b)!=0)answ++;
		}



		if(answ<=mid){
			r = mid;
		}else{
			l = mid;
		}
	}

	cout << l+1 << endl;
}

Measured memory_bytes: 1024
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int[] a = new int[n];
      for(int i = 0;i < n;i++)a[i]=sc.nextInt();
      int sum = 0;
      for(int i = 0;i < n;i++)sum+=a[i]-1;
      System.out.println(sum);
    }
}

Measured memory_bytes: 27752
/*#include <iostream>
using namespace std;
int main() {
	char X,Y;
	cin >> X;
	cin >> Y;
	if (X > Y) {
		cout << ">";
		return 0;
	}
	if (X < Y) cout << "<";
	else cout << "=";

	return 0;
}	*/
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

int main() {
	int N;
	cin >> N;
	vector<int>p;
	for (int i = 0; i < N; i++) {
		int a;
		cin >> a;
		p.push_back(a);
	}
	sort(p.begin(), p.end());
	int suma= 0;
	bool b =true;
	for (int i = N-1; i >=0; i--) {
		if (b) {
			suma += p[i];
			b = false;
		}
		else {
			suma -= p[i];
			b = true;
		}
	}

	cout << suma;

	return 0;
}

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

string str, k_list;
int k[111];

int main(){

 for (int i = 0; i < 26; i++) {
   str += (char)('a' + i);
 }
 for (int i = 0; i < 26; i++) {
   str += (char)('A' + i);
 }


 int n;
 while(cin>>n){
   if (n==0) break;

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

   cin>>k_list;
   int size = k_list.length();

   /*for (int i = 0; i < size; i++) {
     if('a' <= k_list[i] && k_list[i] <= 'z') {
       if (k_list[i] - 'a' + 26 > k[i%n])

       if ('a' <= k_list[i] - k[i%n] && k_list[i] - k[i%n] <= 'z') {
         cout<<(char)(k_list[i] - k[i%n]);
       } else {
         cout<<(char)(k_list[i] - k[i%n] - 'a' + 'Z' + 1);
       }
     } else {
       if('A' <= k_list[i] - k[i%n] && k_list[i] - k[i%n] <= 'Z') {
         cout<<(char)(k_list[i] - k[i%n]);
       } else {
         cout<<(char)(k_list[i] - k[i%n] - 'A' + 'z' + 1);
       }
     }
   }*/

   for (int i = 0; i < size; i++) {
     if('a' <= k_list[i] && k_list[i] <= 'z') {
       cout<<str[(52+k_list[i]-'a'-k[i%n])%52];
     } else {
       cout<<str[(52+k_list[i]-'A'+26-k[i%n])%52];
     }
   }
   cout<<endl;
 }



}



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

string S;
int A, B, C, D;

int main() {
    int data[10][10];

    while (true) {
        cin >> S;
        if (S == "#") { break; }
        cin >> A >> B >> C >> D;
        --A; --B; --C; --D;
        for (int j = 0; j < 10; ++j) { fill(data[j], data[j]+10, 0); }

        int h = 0;
        int w = 0;
        for (int j = 0; j < (int)S.size(); ++j) {
            if (S[j] == '/') { ++h; w = 0; }
            else if (S[j] == 'b') { data[h][w] = 1; ++w; }
            else { w += S[j] - '0'; }
        }
        ++h;

        swap(data[A][B], data[C][D]);

        for (int j = 0; j < h; ++j) {
            if (j > 0) { cout << "/"; }
            int acc = 0;
            for (int k = 0; k < w; ++k) {
                if (data[j][k] == 1) {
                    if (acc > 0) { cout << acc; }
                    acc = 0;
                    cout << "b";
                } else {
                    ++acc;
                }
            }
            if (acc > 0) { cout << acc; }
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 3156
// #define DEBUGGING
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()

template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;
using ll = int64_t;
using ull = uint64_t;
using PLL = pair<ll, ll>;

template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return max(low, min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { t = clamp(t, low, high); }

namespace init__ {

struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

}

#ifdef DEBUGGING
// #include "../debug/debug.cpp"
#include "../../debug/debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

template <typename T>
T make_v(T init) { return init; }

template <typename T, typename... Tail>
auto make_v(T init, size_t s, Tail... tail) {
#define rec make_v(init, tail...)
    return V<decltype(rec)>(s, rec);
#undef rec
}

int main() {
    ll N;
    cin >> N;
    V<PLL> students(N);
    for(ll i = 0; i < N; i++) {
        ll a;
        cin >> a;
        students[i] = PLL(a, i + 1);
    }
    sort(ALL(students));
    for(auto &&ele : students) cout << ele.second << ' '; cout << endl;
    return 0;
}


Measured memory_bytes: 2432
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
typedef long long ll;
namespace mp = boost::multiprecision;
using Mint = mp::cpp_int;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = int(a); i < int(b); i++)
#define all(v) v.begin(), v.end()
#define uni(v) v.erase(unique(all(v)), v.end())
#define sort_g(v) sort(all(v), greater<int>())
#define dump(x) cerr << #x << ' ' << '=' << ' ' << x << endl

bool is_even(string S) {
    int l = S.size() / 2;
    string sub_1 = S.substr(0, l);
    string sub_2 = S.substr(l, l);
    if(sub_1 == sub_2) return true;
    else return false;
}

int main() {
    double L;
    cin >> L;

    cout << setprecision(15) << pow(L / 3, 3) << endl;
}

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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	int n; cin>>n;
	vector<int> c(n), s(n), f(n);
	for(int i = 0; i + 1 < n; i++){
		cin>>c[i]>>s[i]>>f[i];
	}
	for(int i = 0; i + 1 < n; i++){
		int st = 0;
		for(int j = i; j + 1 < n; j++){
			st = max(s[j], ((st + f[j] - 1)/f[j])*f[j]);
			st += c[j];
		}
		cout<<st<<'\n';
	}
	cout<<0<<'\n';

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define FOR(i, a, b) for(int i = a; i < b; ++i)
#define F first
#define S second
#define OUT(x) cout << (x) << "\n"
using namespace std;
using point = pair< int,int >;
using ll = long long;

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

    int ans = 0;
    REP(i, n) {
        ans += i + 1;
    }

    OUT(ans);

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define rep2(i,j,n) for(int j=i;j<n;j++)
#define rep3(i,j,n) for(int j=i;j<=n;j++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define sp(n) cout << fixed << setprecision(n)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
using namespace std;
const ll mod=1e+9+7;
int main(void){
    ll n,k;cin>>n>>k;
    ll res=0;
    for(ll t=k;t<=n+1;t++){
        ll m=t*(t-1)/2,M=t*(n+(n-t+1))/2;
        //cout<<m<<" "<<M<<endl;
        ll buf=M-m+1;
        buf%=mod;
        res+=M-m+1;
        res%=mod;
    }
    cout<<res<<endl;
}


Measured memory_bytes: 3600
using System;
using System.Linq;

namespace ABC091_A
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = Console.ReadLine().Split().Select(int.Parse).ToArray();
            Console.WriteLine(n[0] + n[1] >= n[2] ? "Yes" : "No");
        }
    }
}


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

using namespace std;

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

using ll = long long;
using ull = unsigned 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 x; cin >> x;
  int sum = 0;
  for(int i = 1; i <= x; ++i){
    sum += i;
    if(sum >= x){
      cout << i << endl;
      return 0;
    }
  }
}


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

#define int long long
#define itn int
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
#define dump2(x, y) \
    cerr << #x << " = " << (x) << " " << #y << " = " << (y) << '\n'
#define SZ(x) ((int)(x).size())
#define bit(n) (1LL << (n))
constexpr int MOD = 1e9 + 7;

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = LLONG_MAX / 2;
using P = pair<int, int>;
using vec = vector<int>;
template <typename T>
using mat = vector<vector<T>>;

// clang-format off
template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) { return stream << p.first << "," << p.second; }
template <typename T>
void print(const vector<T> vec) { rep (i, vec.size() - 1) cout << vec[i] << ' '; cout << vec[vec.size() - 1] << '\n'; }
template <typename Arg>
void print(const Arg arg) { cout << arg << '\n'; }
template <typename Head, typename... Args>
void print(const Head head, const Args... args) { cout << head << " "; print(args...); }
template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) { rep (i, v.size()) cin >> v[i] >> w[i]; }
template <typename T>
void init(vector<T>& v) { rep (i, v.size()) cin >> v[i]; }
template <typename T>
T sum_(vector<T> vec, T init = 0) { return std::accumulate(all(vec), T(init)); }
template<typename T>
bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<typename T>
bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <typename T>
int index(const T& vec, const typename T::iterator it) { return distance(vec.begin(), it); }
template <typename T = int>
mat<T> mmat(int n, int m=0) { return mat<T>(n, vector<T>(m)); }
template <typename T = int>
vector<T> ivec(int n) { vector<T> v(n); init(v); return v; }
// clang-format on

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
// -------------------------------------------------------------------
// sort 1 2 3 4
// pqr 1 2 3 must impl >

mat<int> graph;

vec memo;

signed main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;

    graph = mmat<int>(n + 1);
    memo = vec(n + 1, -1);

    rep (i, m) {
        int a, b;
        cin >> a >> b;
        graph[a].pb(b);
        graph[b].pb(a);
    }

    pqr<pair<int, P>> q;
    q.push({0, {1, 0}});
    while (!q.empty()) {
        auto [dist, p] = q.top();
        auto [x, from] = p;
        q.pop();

        if (memo[x] >= 0) continue;

        memo[x] = from;
        repall (to, graph[x]) {
            if (memo[to] < 0) q.push({dist + 1, {to, x}});
        }
    }

    print("Yes");
    For(i, 2, n) print(memo[i]);

    return 0;
}


Measured memory_bytes: 15900
#include<cstdio>
using namespace std;

int main(){
    int n;
    int a=0,b=0;
    int at[10000]={0},bt[10000]={0};
    int j=0;
    for(;;){
        scanf("%d",&n);
        if(n==0)break;
        for(int i=0;i<n;i++){
            scanf("%d%d",&a,&b);
            if(a>b){
                at[j]+=(a+b);
            }else if(b>a){
                bt[j]+=(a+b);
            }else{
                at[j]+=a;
                bt[j]+=b;
            }
        }j++;
    }
    for(int i=0;i<j;i++){
        printf("%d %d\n",at[i],bt[i]);
    }
    return 0;
}

Measured memory_bytes: 1112
#include <stdio.h>


int x[110],y[110];
int main()
{
	int a;
	scanf("%d",&a);
	for(int i=1;i<=a;i++) scanf("%d%d",&x[i],&y[i]);
	
	for(int i=1;i<=a-2;i++)
	{
		if(x[i]==y[i]&&x[i+1]==y[i+1]&&x[i+2]==y[i+2])
		{
			printf("Yes");
			return 0;
		}
	}
	printf("No");
}

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

int gcd(int a, int b, int cnt);

int main()
{
	int a, b;

	while (cin >> a >> b, a){
		int cnt = 0;
		gcd(max(a, b), min(a, b), cnt);
	}

	return (0);
}

int gcd(int a, int b, int cnt)
{
	if (b == 0){
		cout << a << " " << cnt << endl;
	}
	else {
		return (gcd(b, a % b, cnt + 1));
	}
}

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

#define pb push_back
#define fst first
#define snd second
#define fill(a,c) memset(&a, c, sizeof(a))
#define fore(i,x,y) for(ll i=x;i<y;i++)
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

typedef long long ll;
typedef unsigned long long ull;

using namespace std;
ll mxn = 1e9+1;
ll n;
ll dp[200001];
ll arr[200001];

int main() {FIN;
  
    int k;
    cin>>n>>k;
    arr[n];
    fore(i,0,n)cin>>arr[i];
    fill(dp,mxn);
    dp[0] = 0;
    fore(i,0,n){

        fore(j,i+1,i+k+1){

            if(j<n)
                dp[j] = min(dp[j], dp[i]+abs(arr[i]-arr[j]));
        }

    }
    cout<<dp[n-1]<<"\n";
    return 0;
}




Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define REP(i,a,b) for(ll i=a;i<b;i++)
using namespace std;
typedef long long ll;
const ll INF =200005; 
//std::vector<int> adj[200005];
ll arr[200005];
vector<pair<int,int> >adj[200005];
//vector<vector<pair<int,int> > >adj[200005];
void FAST() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}

int main()
{
	

  ll d,s,t,ans;
  cin>>d>>t>>s;
   ans=t*s;
   if(ans>=d)
   	cout<<"Yes";
   else
   	cout<<"No";


	return 0;
}

Measured memory_bytes: 8304
#include<bits/stdc++.h>
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define RFOR(i,a,b) for(int i=a;i>=b;i--)
#define inf 0x3f3f3f3f
using namespace std;

const int maxn = 2e5+5;
typedef unsigned long long ULL;
typedef long long ll;

int n,m,A[maxn];
vector<int>G[maxn];

int main(){
    string str;cin>>str;
    if(str=="ABC")puts("ARC");
    else puts("ABC");
}


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

#define sync ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define endl "\n"
#define ends ' '
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define sz(x) (int)(x.size())
#define debug(x) cerr << #x << ": " << x << endl
#define debugP(p) cerr << #p << ": {" << p.first << ", " << p.second << '}' << endl
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const ll INF = 1e9, MOD = 1e6 + 7;
 
/////////////////////////////////////////////////////////////////////
 
const int N = 2e5 + 5, C = 26;

int NXT[N][C], DP[N], PAR[N];

int main() {
 
	sync;

	string s; cin >> s;
	int n = sz(s);

	for (int i = 0; i < N; i++) DP[i] = INF;
	for (int c = 0; c < C; c++) NXT[n][c] = n;
	for (int i = n - 1; i >= 0; i--) {
		for (int c = 0; c < C; c++) NXT[i][c] = NXT[i + 1][c];
		NXT[i][s[i] - 'a'] = i;
	}
	DP[n + 1] = 0;
	for (int i = n - 1; i >= 0; i--) {
		for (int c = 0; c < C; c++) if (DP[i] > DP[NXT[i][c] + 1] + 1) {
			DP[i] = DP[NXT[i][c] + 1] + 1;
			PAR[i] = c;
		}
	}
	for (int i = 0; i < n; i = NXT[i][PAR[i]] + 1) cout << (char)('a' + PAR[i]);
	cout << endl;

	return 0;
}


Measured memory_bytes: 22420
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; ++i)
typedef long long ll;
const int INF = 1 << 30;
using namespace std;

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

  int n, k; cin >> n >> k;
  vector<int> h(n);
  rep(i, n) cin >> h[i];
  sort(h.begin(), h.end());

  int ans = INF;
  rep(i, n-k+1) {
    ans = min(ans, h[i+k-1]-h[i]);
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define maxn (int)(1e5)
#define i64 long long
#define pii pair<i64,i64>
#define all(x) x.begin(),x.end()
#define LB(x,v) lower_bound(all(x), v) - x.begin()
#define fread() freopen("in.txt", "r", stdin);
using namespace std;

bool solve(string s, int n){
    if(n & 1) return false;
    string half1 = s.substr(0, n/2), half2 = s.substr(n/2);
    return half1 == half2;
}

int main() {
    /*BEFORE SUBMIT, CHECK
    sample i/o format
    statements for debugging are removed/comment out
    global values / stl containers are initialized/cleared for each test (if needed)
    all array size are sufficient
    loop variable or output value doesn't cross min/max limit of input
    // */
    // #ifndef ONLINE_JUDGE
    //     fread();
    // #endif
    
    int n,k; 
    string s;
    while(scanf("%d",&n)==1){
        getchar();
        cin>>s;
        printf("%s\n", solve(s,n) ? "Yes" : "No");     
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;

int main(){
  int N, R, I;
  cin >> N >> R;
  
  if (N<10) I = R + 100*(10-N);
  else I = R;
  
  dunk(I);
}

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

#define ll long long int
#define str string

ll MOD = 1000000007, INFL = 1ll << 60, INF = 1 << 30, mod = 1e9 + 7, Max = INF, Min = -1;
ll a = 0, b = 0, c = 0, n = 0, m = 0, sum = 0;
ll A[500000] = {}, B[500000] = {}, X[1500][13], rui[500000] = {}, dp[200000] = {};
int dy[] = { 0, 0, 1, -1 }, dx[] = { 1, -1, 0, 0 };
vector <ll> v;
str S, T;
bool check = true, check2 = false;

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

int main() {
	//Code Line
	for (int i = 1; i < 200000; i++)dp[i] = INF;
	cin >> n;
	for (int i = 0; i < n; i++)cin >> A[i];

	for (int i = 0; i < n; i++) {
		dp[i + 1] = min(dp[i + 1], dp[i] + abs(A[i] - A[i + 1]));
		dp[i + 2] = min(dp[i + 2], dp[i] + abs(A[i] - A[i + 2]));
	}
	cout << dp[n - 1] << endl;
	return 0;
}


Measured memory_bytes: 5888
#include<iostream>
using namespace std;
int A[200005];
int main(){
  int N,K;
  cin>>K>>N;
  for(int i=0; i<N; i++){
    cin>>A[i+1];
  }
  A[0]=-(K-A[N]);
  A[N+1]=K+A[1];
  int res=1000000005;
  for(int i=1; i<=N; i++){
    res=min(res,min(K-(A[i]-A[i-1]),K-(A[i+1]-A[i])));
  }
  cout<<res<<endl;
  return 0;
}


Measured memory_bytes: 1024
#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 repk(i,m,n) for(int i=m;i<n;i++)
#define IOS ios::sync_with_stdio(false);cin.tie(0);
#define F first
#define S second
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
using namespace std;
const int MOD1=1e9+7;
const int MOD2=998244353;
const ll INF=2*1e18;
const ld PI=3.14159265358979323846;
int main()
{
    IOS;
    map<ll,ll> m;
    ll x,n;
    cin>>x>>n;
    rep(i,n)
    {
        ll a;
        cin>>a;
        m[a]=1;
    }
    rep(i,100)
    {
        if(m[x-i]==0)
        {
            cout<<x-i;
            break;
        }
        if(m[x+i]==0)
        {
            cout<<x+i;
            break;
        }
    }
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main ()
{
    ll a,v,b,w,t,s1,s2;
    cin>>a>>v>>b>>w>>t;
     if(abs(a-b)<=(v-w)*t) cout<<"YES"<<endl;
     else cout<<"NO"<<endl;
}


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

#define REP(i, x) REPI(i, 0, x)
#define REPI(i, a, b) for (int i = int(a); i < int(b); ++i)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

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

  int N;
  cin >> N;

  int a;
  REP(i, N) {
    cin >> a;
    if (a % 2 == 0) {
      if (!(a % 3 == 0 || a % 5 == 0)) {
        cout << "DENIED" << endl;
        return 0;
      }
    }
  }

  cout << "APPROVED" << endl;

  return 0;
}


Measured memory_bytes: 256
using System;

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        if (n == 2 | n == 3) { Console.WriteLine(n); goto end; }
        var ret = 999999999;
        for (int i = 1; i < n/2; i++)
        {
            var w = getAns(i) + getAns(n - i);
            ret = Math.Min(ret, w);
        }
        Console.WriteLine(ret);
        end:;
    }
    public static int getAns (int aa)
    {
        var a = aa.ToString();
        var ret = 0;
        for (int i = 0; i < a.Length; i++)
            ret += int.Parse(a[i].ToString());
        return ret;
    }
}


Measured memory_bytes: 13264
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
	string a,b;
	cin>>a>>b;
	for(int i=0;i<min(a.length(),b.length());i++){
		cout<<a[i]<<b[i];
	}
	if(a.length()!=b.length())cout<<a[a.length()-1];
	cout<<endl;
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,s,n) for(int i=(int)s;i<(int)n;i++)
int main() {
  int n,m=0; cin>>n;
  int a[n],b[n]; rep(i,0,n) cin>>a[i]; rep(i,0,n) cin>>b[i];
  rep(d,0,n){
    int s=0;
    rep(i,0,d+1) s+=a[i];
    rep(i,d,n) s+=b[i];
    m=max(s,m);
  }
  cout<<m;
}

Measured memory_bytes: 3632
#include <stdio.h>

int Judge_3nobaisuu(int);

int main()
{

  int n ,i,judge;
  scanf("%d" ,&n);
  for(i=3 ; i <= n ; i++)
    {
      if(i%3==0)
	{
	  printf(" %d",i);
	  continue ;
	}
      judge = Judge_3nobaisuu(i);
      if(judge==1) printf(" %d",i);
    }
  printf("\n");
  return 0;
}

int Judge_3nobaisuu(int n)
{
  int judge=0,N;
  while( n > 0)
    {
      N = n/10;
      N=N*10;
      if((n-N)==3)
	{
	  judge=1;
	  break;
	}
      n=n/10;
    }

  return judge;


}

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

namespace v0_0005
{
    class Program
    {
        static List<int> div = new List<int>() { 2 };

        static void Main(string[] args)
        {
            string line;
            while (!string.IsNullOrEmpty(line = Console.ReadLine()))
            {
                var ab = line.Split(' ');
                var a = int.Parse(ab[0]);
                var b = int.Parse(ab[1]);
                int LCM = 1;
                int GCD = 1;

                int divVal;
                while ((divVal = GetDivisor(a, b)) != -1)
                {
                    a /= divVal;
                    b /= divVal;
                    GCD *= divVal;
                }
                LCM = GCD * a * b;

                Console.WriteLine("{0} {1}", GCD, LCM);
            }
        }

        static int GetDivisor(int a, int b)
        {
            foreach (var d in div)
            {
                if ((a % d == 0) && (b % d == 0))
                {
                    return d;
                }
            }

            for (int i = div.Min() + 1; i <= Math.Max(a, b); i++)
            {
                if ((a % i == 0) && (b % i == 0))
                {
                    if (!div.Contains(i))
                    {
                        div.Add(i);
                        div.Sort();
                    }
                    return i;
                }
            }

            return -1;
        }
    }
}

Measured memory_bytes: 9992
#include<bits/stdc++.h>
using namespace std;
using ll  = long long;
using vvl = vector<vector<ll>>;
using vl  = vector<ll>;
#define _GLIBCXX_DEBUG
#define acc_io cin.tie(0);ios::sync_with_stdio(false)
#define all(x) x.begin(),x.end()
#define rep(i,sta,end) for(ll i=sta;i<end;i++)
#define lcm(a,b) (a)/__gcd((a),(b))*(b)
#define pb push_back
const ll MOD = 1000000007;
const double PI = acos(-1);  
//name[i]   -> vl  name(i)
//name[i][j]-> vvl name(i,vl(j))
//or-> ||
//map<int,int>mp

ll n;
ll ans;
//string s;
signed main(){
	acc_io;
	ans=0;
	cin>>n;
	ll rt;
	ll a=0,b=0;
	rt=sqrt(n);
	for(int i=rt;i>0;i--){
		if(n%i==0){
			b=n/i;
			a=i;
			break;
		}
	}
//		cout<<a<<" "<<b<<endl;
	a=max(a,b);
	string s;
	s=to_string(a);
	ans=s.size();
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3764
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 400000;




int main() {

	int r;
	cin >> r;
	cout << r * r;


	system("PAUSE");

}

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

int main() {
  long long A, B;
  cin >> A >> B;

  if (A % 2 == 0) {
    switch ((B - A) % 4) {
      case 0:
        cout << B << endl;
        break;
      case 1:
        cout << 1 << endl;
        break;
      case 2:
        cout << (B ^ 1ll) << endl;
        break;
      case 3:
        cout << 0 << endl;
        break;
    }
  } else {
    switch ((B - A) % 4) {
      case 0:
        cout << A << endl;
        break;
      case 1:
        cout << (A ^ B) << endl;
        break;
      case 2:
        cout << A - 1ll << endl;
        break;
      case 3:
        cout << ((A - 1ll) ^ B) << endl;
        break;
    }
  }

  return 0;
}


Measured memory_bytes: 256
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>
#include <cmath>

auto & in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

int32_t N,K;

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	in >> N >> K;
	if (K == 1) {
		out << 0 << endl;
		return 0;
	}
	N -= K;
	out << N << endl;

	return 0;
}
#endif


Measured memory_bytes: 888
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define DUMP(v) for(auto& x : v) cerr << x << " "; cerr << endl;
using namespace std;

using ll = long long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
constexpr int INF = 1e9+5;
constexpr long long INFLL = 1LL<<60;
constexpr double eps = (1e-9);

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

  int n;
  cin >> n;

  vector<int> c(n-1), s(n-1), f(n-1);
  rep(i, n-1) cin >> c[i] >> s[i] >> f[i];

  for (int i = 0; i < n-1; i++) {
    ll ans = 0;
    for (int j = i; j < n-1; j++) {
      if (ans <= s[j]) {  // 始発が未だ
        ans = s[j] + c[j];   // 始発に乗って次へ
      } else {
        if (ans % f[j] == 0) ans += c[j];
        else ans += (f[j] - ans % f[j]) + c[j];
      }
    }

    cout << ans << endl;
  }

  cout << 0 << endl;

  return 0;
}


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

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

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

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

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

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

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

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

fn main() {
    input! {
        d:u32,
        t:u32,
        s:u32,
    }
    if d <= (t * s) {
        println!("Yes")
    } else {
        println!("No")
    }
}

Measured memory_bytes: 2128
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef vector<ll> vel;
typedef vector<str> ves;
#define REP(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define rep(i, b) REP(i, 0, b)
const ll mod = 1000000007;
const double pi = 3.14159265358979;

int main() {
    ll k, a, b;
    cin >> k >> a >> b;
    bool ans = false;
    REP(i, a, b+1) {
        if(i%k==0) {
            ans = true;
            break;
        }
    }
    if(ans) {
        cout << "OK" << endl;
    }
    else {
        cout << "NG" << endl;
    }
}

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

int main(){
  int n;cin>>n;
  vector<int> vec(n);
  for(int i=0;i<n;++i)cin>>vec[i];
  int res = 0;
  for(int i=0;i<n;++i){
    for(int j=i+1;j<n;++j){
      res += vec[i]*vec[j];
    }
  }
  cout<<res<<endl;
  return 0;
}


Measured memory_bytes: 256
N = int(input())
S = input()

ans = 0
for i in range(N):
    count = 0
    closed = []
    for j in range(i):
        if S[j] not in closed and S[j] in S[i:N]:
            count += 1
            closed.append(S[j])

    # print(i, count, S[:i], S[i:N])
    ans = max(ans, count)

print(ans)


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

using namespace std;

bool isInside(const int W, const int H, const int x, const int y, const int r);

int main()
{
	int W, H, x, y, r;
	cin >> W;
	cin >> H;
	cin >> x;
	cin >> y;
	cin >> r;

	string output = isInside(W, H, x, y, r) ? "Yes" : "No";
	cout << output << endl;

	return 0;
}

bool isInside(const int W, const int H, const int x, const int y, const int r)
{
	int top, down, left, right;
	top = y + r;
	down = y - r;
	left = x - r;
	right = x + r;

	if (H < top)
	{
		return false;
	}
	if (0 > down)
	{
		return false;
	}
	if (0 > left)
	{
		return false;
	}
	if (W < right)
	{
		return false;
	}
	return true;
}


Measured memory_bytes: 3204
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int X = scan.nextInt();
        boolean f = false;
        for(int c=1;c<=X;c++){
            if(100*c<=X&&X<=105*c){
                f = true;
                break;
            }
        }
        if(f == true){
            System.out.println("1");
        }else{
            System.out.println("0");
        }
    }
}

Measured memory_bytes: 23380
N=int(input())

XY=[list(map(int,input().split())) for i in range(N)]

XY.sort()

d={}

if N==1:
    print(1)
else:
    for i in range(N-1):
        for j in range(i+1,N):
            if str(XY[j][0]-XY[i][0])+' '+str(XY[j][1]-XY[i][1]) in d:
                d[str(XY[j][0]-XY[i][0])+' '+str(XY[j][1]-XY[i][1])]+=1
            else:
                d[str(XY[j][0]-XY[i][0])+' '+str(XY[j][1]-XY[i][1])]=1
            
    print(N-max(d.values()))


Measured memory_bytes: 3188
#include<iostream>
	#include<vector>
	#include<algorithm>
	#include<string>
	#include<cmath>
	#include<map>
	#include<cstdio>
	#include<stack>
	#include<queue>
	#include<fstream>
	#include<cstdio>
	#include<deque>
	#include<iomanip>
	#include <numeric>
	//#include<bits/stdc++.h>

	using namespace std;
	#define ok1 printf("ok1\n");
	#define ok2 printf("ok2\n");
	#define M 1000000000000000000LL
	#define rep(i,n) for(int i=0;i<n;i++)
	#define REP(i,s,n) for(int i=(s);i<(n);i++)
	#define repr(i,n) for(int i=n-1;i>=0;i--)
	#define REPR(i,s,n) for(int i=(s);i>=(n);(i)--)
	#define all(a) (a).begin(),(a).end()
	#define reall(a) (a).rbegin(),(a).rend()
	#define pb push_back
	#define pf push_front
	#define MIN(a,b) a=min((a),(b))
	#define MAX(a,b) a=max((a),(b))
	#define SIZE(v) (int)v.size()
	const double pi = acos(-1.0);

	typedef vector<int> vi;
	typedef vector<string> vs;
	typedef long long ll;
	typedef vector<ll> vll;
	typedef vector<vi> vvi;
	typedef vector<vll> vvll;
	typedef deque<ll> dll;
	typedef pair<ll, ll> P;
	const ll mod = 1e9 + 7;
	ll dx[4] = {1,0,-1,0};
	ll dy[4] = {0,1,0,-1};


	int main() {
		cin.tie(0);
		ios::sync_with_stdio(false);
		
		ll masu[105][105];
		ll n, w, h;
		ll ans = 0;
		cin >> w >> h >> n;
		rep(k,n) {
			ll x, y, a;
			cin >> x >> y >> a;
			a--;
			if (a == 0) {
				for (int i = 0; i<h; i++) {
					for (int j = 0; j<x; j++) {
						masu[i][j] = 1;
					}
				}
			}
			if (a == 1LL) {

				for (int i = 0; i<h; i++) {
					for (int j = x; j<w; j++) {
						masu[i][j] = 1;
					}
				}
			}
			if (a == 2LL) {
				for (int i = 0; i<y; i++) {
					for (int j = 0; j<w; j++) {
						masu[i][j] = 1;
					}
				}
			}
			if (a == 3LL) {
				for (int i = y; i<h; i++) {
					for (int j = 0; j<w; j++) {
						masu[i][j] = 1;
					}
				}
			}
		}
		for (int i = 0; i<h; i++) {
			for (int j = 0; j<w; j++) {
				if (masu[i][j] == 0) ans++;
			}
		}
		cout << ans << endl;
		return 0;
	}	
	

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;

main() {
    string s;
    cin >> s;

    constexpr auto M = 1000000007;
    constexpr auto K = 13L;
    int64_t base = 1;
    array<int64_t, K> dp{};
    dp[0] = 1;
    for (auto it = s.rbegin(); it != s.rend(); ++it) {
        auto c = *it;

        array<int64_t, K> next{};
        if (c != '?') {
            auto d = (base * (c - '0')) % K;
            for (auto i : irange(0L, K)) {
                next[(i + d) % K] = dp[i];
            }
        } else {
            for (auto i : irange(0L, 10L)) {
                auto d = (base * i) % K;
                for (auto j : irange(0L, K)) {
                    next[(j + d) % K] += dp[j];
                    next[(j + d) % K] %= M;
                }
            }
        }

        dp = next;
        base *= 10;
        base %= K;
    }

    cout << dp[5] << endl;
}

Measured memory_bytes: 512
import itertools
n,q = map(int, input().split())
s = input()
calc = [0]*n
prev = None
for i,c in enumerate(s):
    if prev == 'A' and c == 'C':
        calc[i] = 1
    prev = c
calc = list(itertools.accumulate(calc))
for _ in range(q):
    l,r = map(int,input().split())
    print(calc[r-1]-calc[l-1])

Measured memory_bytes: 7944
#include "bits/stdc++.h"

using namespace std;

#define int long long
#define ll long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl



signed main() {

	int N;
	cin >> N;

	int x=1, y=1;
	rep(i, N) {
		int a, b;
		cin >> a >> b;
		int k1 = (x+a-1) / a;
		int k2 = (y+b-1) / b;
		int r = max(k1, k2);
		x = a * r;
		y = b * r;
//		cerr << x << " " << y << endl;
	}
	cout << x + y << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい
// https://github.com/atcoder/live_library
// cppdbg: test.exeのterminalに標準入力を打てる

#define ALL(x) x.begin(),x.end()
#define get_tp(t,i) get<i>(t)
#define len(x) (ll)(x.size())
#define ub(a,x) (upper_bound(ALL(a),x)-a.begin())
#define lb(a,x) (lower_bound(ALL(a),x)-a.begin())
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef pair<long long,long long> pllll; //pair<ll,ll>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<ll, vector<ll>, greater<ll> > gpq; //逆順priority_queue
typedef priority_queue<ll> pq;

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const long double PI=3.1415926535897932;

int main(){
    ll N;cin>>N;
    vll A(N);
    for(ll i=0;i<N;i++)cin>>A[i];
    ll all_total=0;
    for(ll i=0;i<N;i++){
        all_total+=A[i];
        all_total%=MOD;
    }
    ll sq_total=0;
    for(ll i=0;i<N;i++){
        sq_total+=A[i]*A[i];
        sq_total%=MOD;
    }
    ll x=(all_total*all_total-sq_total)%MOD;
    if(x<0)x+=MOD;
    ll ans;
    if(x%2){
        ans=(x+MOD)/2;
    }else{
        ans=x/2;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 4848
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <vector>
#include <bitset>
#include <queue>
using namespace std;
template <typename T>
vector<T> vec1d_init(int len){
    vector<T> vec(vector<T>(len, 0));
    return vec;
}
vector<string> vec1d_init(int len){
    vector<string> vec(vector<string>(len, ""));
    return vec;
}
template <typename T>
vector<T> vec1d_sort(vector<T> vec, bool min_to_max=true){
    sort(vec.begin(), vec.end(), [min_to_max](const T a, const T b){return (min_to_max == true) ? (a < b) : (b < a);});
    return vec;
}
template <typename T>
void vec1d_show(vector<T> vec){
    for(int i = 0; i < vec.size(); i++){
        cout << vec[i] << " ";
    }
    cout << endl;
}
int main(){
    int N, K;
    cin >> N >> K;
    auto vec = vec1d_init<int>(N);
    for(int i = 0; i < N; i++){
        cin >> vec[i];
    }
    int ans = 0;
    vec = vec1d_sort<int>(vec, false);
    for(int i = 0; i < K; i++){
        ans += vec[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;

int main()
{
	int n,sum = 1;
	scanf("%d",&n);
	for (int i = 1;i <= n;i++){
		sum = sum*2;
		if (sum > n) break;
	}
	printf("%d",sum/2);
}

Measured memory_bytes: 128
#include <iostream>
#include <unordered_map>

const int MAX = 200005;
int64_t A[MAX];
int n;
int64_t k;

int main()
{
    std::ios_base::sync_with_stdio(0);
    std::cin >> n >> k;
    for (int i=1;i<=n;++i) std::cin >> A[i];
    for (int i=1;i<=n;++i) {
        A[i] = ((A[i]+A[i-1]-1)%k+k)%k;
    }
    int64_t result = 0;
    std::unordered_map<int64_t, int64_t> M;
    for (int i=n;i>=1;--i) {
        M[A[i]]++;
        if (i+k-1<=n) M[A[i+k-1]]--;
        result += M[A[i-1]];
    }
    std::cout << result << std::endl;
    return 0;
}

Measured memory_bytes: 10056
#include<stdio.h>
int main(){
  int N, M;
  int n1,n3,n5;
  int i,keta,count;
  scanf("%d", &N);
  
  keta=1;
  M=N;
  n1=9;
  n3=900;
  n5=90000;
  
  for(i=0;i<5;i++){
    M = M/10;
    if(M == 0){
      break;
    }
    keta++;
  }
  
  switch(keta){
    case 6:
      count = n1+n3+n5;
      break;
    case 5:
      count = n1+n3+N-9999;
      break;
    case 4:
      count = n1+n3;
      break;
    case 3:
      count = n1+N-99;
      break;
    case 2:
      count = n1;
      break;
    case 1:
      count = N;
      break;
  }
  printf("%d\n", count);
  return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
int a[20][20]={};
int xg,yg;
int c=0;
void tansa(int x,int y){
  // printf("point\n");
  if(x==xg&&y==yg){
    c++;
  }
  else{
    if(x!=xg){
      if(a[y][x+1]==0){
	tansa(x+1,y);
      }
    }
    if(y!=yg){
      if(a[y+1][x]==0){
	tansa(x,y+1);
      }
    }
  }
}
int main(){
  int n,i,j,x,y;
  while(1){
    for(i=0;i<20;i++){
      for(j=0;j<20;j++){
	a[i][j]=0;
      }
    }
    c=0;
    scanf("%d%d",&xg,&yg);
    if(xg==0&&yg==0)break;
    scanf("%d",&n);
    for(i=0;i<n;i++){
      scanf("%d%d",&x,&y);
      a[y][x]=1;
    }
    tansa(1,1);
    printf("%d\n",c);
  }
  return 0;
}

Measured memory_bytes: 1028
#include <iostream>
#include<set>
using namespace std;
int main()
{
    int n;
    cin >> n;
    set<int>s;
    for (int i = 0; i < n; i++)
    {
        int x;
        cin >> x;
        s.insert(x);
    }
    if (s.size()==n)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
    }
 

Measured memory_bytes: 9600