akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

// struct LazySegmentTree {
// private:
//     int n;
//     vector<ll> lazy;

// public:
//     vector<ll> node;
//     LazySegmentTree(vector<ll> v) {
//         int sz = (int)v.size();
//         n = 1; while(n < sz) n *= 2;
//         node.resize(2*n-1);
//         lazy.resize(2*n-1, 0);

//         for(int i=0; i<sz; i++) node[i+n-1] = v[i];
//         for(int i=n-2; i>=0; i--) node[i] = node[i*2+1] + node[i*2+2];
//     }
//     // k 番目のノードについて遅延評価を行う
//     void eval(int k, int l, int r) {

//     // 遅延配列が空でない場合、自ノード及び子ノードへの
//     // 値の伝播が起こる
//     if(lazy[k] != 0) {
//         node[k] += lazy[k];

//         // 最下段かどうかのチェックをしよう
//         // 子ノードは親ノードの 1/2 の範囲であるため、
//         // 伝播させるときは半分にする
//         if(r - l > 1) {
//             lazy[2*k+1] += lazy[k] / 2;
//             lazy[2*k+2] += lazy[k] / 2;
//         }

//         // 伝播が終わったので、自ノードの遅延配列を空にする
//         lazy[k] = 0;
//     }
//   }

//   void add(int a, int b, ll x, int k=0, int l=0, int r=-1) {
//     if(r < 0) r = n;

//     // k 番目のノードに対して遅延評価を行う
//     eval(k, l, r);

//     // 範囲外なら何もしない
//     if(b <= l || r <= a) return;
    
//     // 完全に被覆しているならば、遅延配列に値を入れた後に評価
//     if(a <= l && r <= b) {
//         lazy[k] += (r - l) * x;
//         eval(k, l, r);
//     }

//     // そうでないならば、子ノードの値を再帰的に計算して、
//     // 計算済みの値をもらってくる
//     else {
//         add(a, b, x, 2*k+1, l, (l+r)/2);
//         add(a, b, x, 2*k+2, (l+r)/2, r);
//         node[k] = node[2*k+1] + node[2*k+2];
//     }
// }

// ll getsum(int a, int b, int k=0, int l=0, int r=-1) {
//     if(r < 0) r = n;
//     if(b <= l || r <= a) return 0;

//     // 関数が呼び出されたら評価！
//     eval(k, l, r);
//     if(a <= l && r <= b) return node[k];
//     ll vl = getsum(a, b, 2*k+1, l, (l+r)/2);
//     ll vr = getsum(a, b, 2*k+2, (l+r)/2, r);
//     return vl + vr;
// }

// };

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

  int N, M;
  cin >> N >> M;
  vector<ll> node(N);
  for(int i = 0; i < N; i++){
    node[i] = 0LL;
  }

  int a, b;
  for(int i = 0; i < M; i++){
    cin >> a >> b;
    a--;
    b--;
    node[a]++;
    node[b]++;
  }
  bool ok = true;
  for(int i = 0; i < N; i++){
    if(node[i] % 2 == 1){
      ok = false;
      break;
    }
  }

  if(ok){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }

  return 0;
}


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

int main(){
	int n, num_cnt, res;
	cin >> n;
	vector<int> a(n);

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

	num_cnt = 1;
	res = 0;
	for(int i=0; i<n; i++){
		if(a[i] == num_cnt){
			num_cnt++;
		}else{
			res++;
		}
	}
	if(res == n){
		res = -1;
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    ll a, b, c, x, y;
    scanf("%lld%lld%lld%lld%lld", &a, &b, &c, &x, &y);
    ll bara = a * x + b * y;
    ll matome;
    if (x < y) {
        matome = min((y - x) * b + x * 2 * c, y * 2 * c);
    } else {
        matome = min((x - y) * a + y * 2 * c, x * 2 * c);
    }
    printf("%lld\n", min(bara, matome));
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String... args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		List<Integer> list = new ArrayList<>();
		for (int i = 0 ; i < n ; i++) {
			int t = sc.nextInt();
			if (!list.contains(t)) list.add(t);
		}
		System.out.println(list.size());
	}
}


Measured memory_bytes: 21844
using System;

namespace ITP_6_A{
    public class Program{
        public static void Main(string[] args){
            Console.ReadLine();
            string[] temp = Console.ReadLine().Split(' ');

            for(int i=temp.Length -1; i>=0; i--){
                Console.Write(temp[i]);
                if(i!=0){ Console.Write(" "); }
            }
            Console.WriteLine();
        }
    }
}

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

int main() {
	int N;
	int A;
	int x;
	cin >> N >> A;

	x = N / 500;
	if (N - 500 * x <= A) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

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

using namespace std;

#define int long long
#define endl '\n'
#define MOD 1000000007
#define maxn 100010

int t[5 * maxn], lazy[5 * maxn];

int doit(int a, int b) {
    return min(a, b);
}

void build(int start, int end, int index = 1) {
    if (start == end) {
        t[index] = 0;
        return;
    }

    int mid = start + end >> 1;
    build(start, mid, index << 1);
    build(mid + 1, end, index << 1 | 1);

    t[index] = doit(t[index << 1], t[index << 1 | 1]);
}

void propagate(int start, int end, int index) {
    t[index] += lazy[index];
    if (start != end) {
        lazy[index << 1] += lazy[index];
        lazy[index << 1 | 1] += lazy[index];
    }
    lazy[index] = 0;
}

int query(int start, int end, int l, int r, int index = 1) {
    if (lazy[index] != 0)
        propagate(start, end, index);
    //Invalid range
    if (r < start or l > end)
        return INT_MAX;

    //In range
    if (l <= start and end <= r) {
        return t[index];
    }

    int mid = start + end >> 1;
    return doit(query(start, mid, l, r, index << 1), query(mid + 1, end, l, r, index << 1 | 1));
}

void pUpdate(int start, int end, int point, int val, int index = 1) {
    if (start == end) {
        t[index] += val;
        return;
    }

    int mid = start + end >> 1;
    if (point <= mid)
        pUpdate(start, mid, point, val, index << 1);
    else
        pUpdate(mid + 1, end, point, val, index << 1 | 1);

    t[index] = doit(t[index << 1], t[index << 1 | 1]);
}


void rangeUpdate(int start, int end, int l, int r, int val, int index) {
    if (lazy[index])
        propagate(start, end, index);
    
    if (l > end or r < start)
        return;

    if (l <= start and end <= r) {
        lazy[index] = val;
        propagate(start, end, index);
        return;
    }

    int mid = start + end >> 1;
    rangeUpdate(start, mid, l, r, val, index << 1);
    rangeUpdate(mid + 1, end, l, r, val, index << 1 | 1);

    t[index] = doit(t[index << 1], t[index << 1 | 1]);
}

void solve() {
    int n, q;
    cin >> n >> q;

    build(0, n - 1, 1);

    for (int i = 0; i < q; i++) {
        int a;
        cin >> a;

        if (a == 0) {
            int s, t, x;
            cin >> s >> t >> x;
            rangeUpdate(0, n - 1, s, t, x, 1);
        } else {
            int s, t;
            cin >> s >> t;

            cout << query(0, n - 1, s, t, 1) << endl;
        }
    }
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
//    cin >> t;

    while (t--)
        solve();
    return 0;
}



Measured memory_bytes: 7288
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

ll v[11] = {0, 5, 10, 4, 9, 3, 8, 2, 7, 1, 6};
 
int main() {
    ll n, k;
    cin >> n >> k;

    ll ans = (n/11)*5;
    ll m = n%11;
    exrep(x, 1, 7*(m-1)) {
        if(x%7 == 0 || x%7 == 1) {
            continue;
        }
        if(x%11 == v[k]) {
            ans++;
        }
    }

    if(k == 1 || k == 3 || k == 5 || k == 7 || k == 10) {
        ans--;
    }
    
    out(ans);
    re0;
}

Measured memory_bytes: 256
#include <ctype.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void) {
  long n, a[100001], count = 0, min = 1000000001, ans = 0;

  scanf("%ld", &n);

  for (long i = 0; i < n; i++) {
    scanf("%ld", &a[i]);
    ans += abs(a[i]);
    if (a[i] < 0) count++;
    if (abs(a[i]) < min) min = abs(a[i]);
  }

  if (count % 2 == 0) {
    printf("%ld", ans);
  } else {
    printf("%ld", ans - min * 2);
  }

  return 0;
}

Measured memory_bytes: 896
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n=int(input())
    l=list(map(int,input().split()))
    l.sort()
    ans=1
    if l[0]==0:
        print(0)
    else:
        for i in l:
            ans*=i
            if ans>10**18:
                ans=-1
                break
        print(ans)
resolve()

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

//省略形
#define rep(i,n) for(auto i=0; i<n ; ++i)
#define REP(i,a,b) for(auto i=a; i<b; ++i)
#define all(v) (v).begin() , (v).end()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvc = vector<vector<char>>;
using pii = pair<int , int>;
using pll = pair<long long , long long>;

//よく使う定数
const int INF = 1e9;
const int MOD = 1e9+7;
//逆元
const int INV = 1e9+5;

//UnionFindTree
struct union_find{
  vector<int> data;
  union_find(int size) : data(size , -1) { }

  void merge(int x , int y){
    x = root(x); y = root(y);
    if(x == y) return;
    if(data[y] < data[x]) swap(x , y);
    data[x] += data[y];
    data[y] = x;
    return; 
  }

  bool same(int x , int y){
    x = root(x) , y = root(y);
    return x == y;
  }

  int root(int x){
    return data[x] < 0 ? x : (data[x] = root(data[x]));
  }

  int size(int x){
    return -data[root(x)];
  }
};

//プロトタイプ宣言
void faster(void);
template <class T>
T get_digent(T);
template <class T>
T POW(T , T);
template <class T>
T modpow(T , T , T);
bool is_palindrome(string);

//メモ
//最大公約数:__gcd　|　最小公倍数:__lcm
//回文は反転させて一致すればよい

int main(){
  faster();
  int n,m;
  cin >> n >> m;
  vi a(m);
  ll sum = 0;
  rep(i,m){
    cin >> a[i];
    sum += a[i];
  }
  if (sum > n) cout << -1;
  else cout << n - sum;
}























//同期解除
void faster(void){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}

//桁数取得
template <class T>
T get_digent(auto x){
  string s;
  s = to_string(x);
  ll digent = s.size();
  return digent;
} 

//繰り返し自乗法
template <class T>
T POW(T x, T y){
  if(y==0) return 1;
  if(y%2 == 1){
    ll temp = POW(x,y-1);
    return (temp*x);
  }
  else{
    ll temp = POW(x,y/2);
    return temp*temp;
  }
} 

//繰り返し自乗法(剰余)
template <class T>
T modpow(T x , T y , T mod){
  if(y == 0) return 1;
  if(y%2 == 1){
    ll temp = modpow(x,y-1,mod);
    return temp*x%mod;
  }
  else{
    ll temp = pow_mod(x,y/2,mod);
    return temp*temp%mod;
  }
}

bool is_palindrome(string s){
    string t(s.rbegin(),s.rend());
    return s == t;
}

Measured memory_bytes: 3656
#include <cstdio>

int binarySearch(int s[], int n, int key) {
    int left = 0;
    int right = n;
    int mid;
    while (left < right) {
        mid = (left + right) / 2;
        if (key == s[mid]) {
            return 1;
        } else {
            if (key < s[mid]) {
                right = mid;
            } else {
                left = mid + 1;
            }
        }
    }
    return 0;
}

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

    int q;
    scanf("%d", &q);
    int answer = 0;
    int key;
    for (int i = 0; i < q; i++) {
        scanf("%d", &key);
        if (binarySearch(s, n, key)) {
            answer++;
        }
    }
    
    printf("%d\n", answer);
    return 0;
}


Measured memory_bytes: 2972
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	int N; long long X;
	cin >> N >> X;
	long long bound = X * N * 2;
	vector<long long> P(N), PS(N + 1);
	for (int i = N - 1; i >= 0; --i) cin >> P[i], bound += P[i] * 5;
	for (int i = 1; i <= N; ++i) PS[i] = PS[i - 1] + P[i - 1];
	long long ans = bound;
	for (int i = 1; i < N; ++i) {
		long long cost = X * (N + i);
		for (int j = 0; i * j < N; ++j) {
			cost += (PS[min(N, i * j + i)] - PS[i * j]) * (j == 0 ? 5 : 2 * j + 3);
			if (cost > ans) cost = ans;
		}
		ans = cost;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3456
//081B
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)

using namespace std;
int main(void){
    int n;
    int cnt=0;
    bool flag = true;
    cin >> n;
    int A[n]; //配列変数
    rep(i,n) cin >> A[i];
    while(true){
        rep(i,n){
            if(A[i]%2==0){
                A[i] = A[i]/2;
            }else{
                flag= false;
                cout << cnt << endl;
                return 0;
            }
        }
        cnt+=1;
    }
    
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <set>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <bitset>
#include <stack>
#include <queue>
#include <ctype.h>

typedef long long int lli;
#define rep(i,s,N) for(int i=s;i<N;i++)
#define MOD 1000000007
#define more(a,b) (((a)>(b))?(a):(b))
#define less(a,b) (((a)<(b))?(a):(b))

using namespace std;

int main(void)
{
	string S; cin >> S;
	map<char, bool> rec;
	rep(i, 0, 26)rec['a' + i] = false;
	if (S == "zyxwvutsrqponmlkjihgfedcba")cout << -1 << endl;
	else {
		if (S.size() == 26) {
			int k = 25;
			while (S[k - 1] >= S[k])k--;
			rep(i, 0, k)rec[S[i]] = true;
			char end = S[k - 1];
			while (rec[end])end++;
			string ans = S.substr(0, k - 1) + end;
			cout << ans << endl;
		}
		else {
			rep(i, 0, S.size())rec[S[i]] = true;
			char end = 'a';
			while (rec[end])end++;
			cout << S + end << endl;
			//for (map<char, bool>::iterator it = rec.begin(); it != rec.end(); it++)
				//cout << it->first << " " << (it->second ? "ON" : "OFF") << endl;
		}

	}

	return 0;
}


Measured memory_bytes: 256
/* In the name of Allah */
#include<bits/stdc++.h>
using namespace std;

const int N = 2e3 + 5;
int n, m, q, a[N][N], dp[N][N][3];

int get(int b, int xl, int xr, int yl, int yr) {
	return dp[xr][yr][b] - dp[xl][yr][b] - dp[xr][yl][b] + dp[xl][yl][b];
}

void read_input() {
	cin >> n >> m >> q;
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= m; j++) {
			char c;
			cin >> c;
			a[i][j] = c - '0';
		}
}

void solve() {
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= m; j++) {
			dp[i][j][0] = (a[i][j] && a[i][j + 1]) + dp[i - 1][j][0] + dp[i][j - 1][0] - dp[i - 1][j - 1][0];
			dp[i][j][1] = (a[i][j] && a[i + 1][j]) + dp[i - 1][j][1] + dp[i][j - 1][1] - dp[i - 1][j - 1][1];
			dp[i][j][2] = a[i][j] + dp[i - 1][j][2] + dp[i][j - 1][2] - dp[i - 1][j - 1][2];
		}
}

void write_output() {
	while (q--) {
		int xl, xr, yl, yr;
		cin >> xl >> yl >> xr >> yr;
		cout << get(2, xl - 1, xr, yl - 1, yr) - get(1, xl - 1, xr - 1, yl - 1, yr) - get(0, xl - 1, xr, yl - 1, yr - 1) << endl;
	}
}

int main() {
	ios:: sync_with_stdio(0), cin.tie(0), cout.tie(0);
	read_input(), solve(), write_output();
	return 0;
}


Measured memory_bytes: 64640
import sys
import os
import math
import string

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: x * y / math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    a = ii()
    print(pow(a,2)*3)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3832
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast,no-stack-protector") 
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

#define int long long
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i > l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp(a, b) make_pair(a, b)
#define ret(a) {cout << a; exit(0);}

using namespace std;

mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}

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

const int N = 1e6 + 123;
int n , m , k , t;
int dp[N] , a[N] , b[N];
pii p[N];
main(){
	ios::sync_with_stdio(0); cin.tie(0);cout.tie(0);
	cin >> n >> t;
	for(int i = 1; i <= n; i++){
	     cin >> p[i].fi >> p[i].se;
	}
	sort(p + 1 , p + 1 + n);
	int ans = 0;
	for(int i = 1; i <= n; i++){
		for(int w = t - 1 ; w >= 0 ; w--){
			dp[w + p[i].fi] = max(dp[w + p[i].fi] , dp[w] + p[i].se);
			ans = max(ans , dp[w + p[i].fi]);
		}
	}
	cout << ans;
	
}


Measured memory_bytes: 2432
/*
g++ -std=c++14 -o2 -Wall template.cpp -o .\out\template.out
.\out\template.out
*/

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

int v[55];
int sv[55];

int main(){
//  freopen("./input/input.txt", "r", stdin);
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  for (int i = 0; i < n; ++i) {
    cin >> v[i];
  }
  for (int i = 0; i < n; ++i) {
    sv[i + 1] = sv[i] + v[i];
  }
  int r = min(n, k);
  int ans = 0;
  for (int a = 0; a <= r; ++a) {
    for (int b = 0; b <= r - a; ++b) {
      priority_queue<int, vector<int>, greater<int>> p;
      int temp = 0;
      for (int i = 0; i < a; ++i) p.push(v[i]);
      for (int i = 0; i < b; ++i) p.push(v[n-i-1]);
      int cnt = 0;
      while (!p.empty() && cnt < max(k - a - b, 0)) {
        int q = p.top();
        p.pop();
        if (q < 0) {
          temp -= q;
          ++cnt;
        }
      }
      temp += sv[a]+sv[n]-sv[n-b];
      ans = max(temp, ans);
    }
  }
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=2e5+7;
ll ans[maxn],d[maxn];
struct ver{
	ll l,r,c;
	bool operator<(const ver&key) const
	{
		return this->c < key.c;
	}
	ver(ll x,ll y,ll z):l(x),r(y),c(z)
	{
		
	}
};
unordered_map<ll,ll> mp;
vector<ver> v;
int main()
{
	ll n,q;scanf("%lld%lld",&n,&q);
	for(ll i=0;i<n;i++)
	{
		ll a,b,c;scanf("%lld%lld%lld",&a,&b,&c);
		v.push_back(ver(max(a-c,0ll),b-c-1,c));
	}
	sort(v.begin(),v.end());
	set<ll> s;
	for(ll i=1;i<=q;i++)
	{
		ll x;
		scanf("%lld",&x);
		mp[x]=i;s.insert(x);ans[i]=-1;
	}
	for(auto u : v)
	{
		ll l=u.l,r=u.r,c=u.c;
		while(s.size()>0)
		{
			auto it=s.lower_bound(l);
			if(it==s.end()) break;
			if((*it)>r) break;
			ans[mp[(*it)]]=c;
			s.erase((*it));
		}
	}
	for(ll i=1;i<=q;i++) cout<<ans[i]<<endl;
}

Measured memory_bytes: 26092
#include <stdio.h>
int main (void){
    int a,i,s;
    for(;;){
        scanf("%d",&s);
        if(s==0)break;
        for(i=0;i<9;i++){
            scanf("%d",&a);
            s=s-a;
        }
        printf("%d\n",s);
    }
return 0;
}

Measured memory_bytes: 600
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<climits>
using namespace std;
#define N 100
int n,minn=INT_MAX;
int a[N+5];
int PD(int mid)
{
	long long num=0;
	for(int i=1;i<=n;i++)
	{
		num+=(a[i]-mid)*(a[i]-mid);
	}
	return num;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	scanf("%d",&a[i]);
	sort(a+1,a+1+n);
	for(int i=a[1];i<=a[n];i++)
	{
		long long x=PD(i);
		if(x<minn) minn=x;
		else break;
	}
	printf("%d",minn);
 } 

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
#define INF 1e9
#define ret return

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector < pair<int, int> > vii;
typedef long double ld;
typedef tree<pair<int,int>, null_type, less<pair<int,int> >, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

int a[111111];
int dp[111111];

int main(){
	int n, k;
	cin >> n >> k;
	for(int i = 0; i < n; i++){
		cin >> a[i];
		dp[i]=INF;
	}
	dp[0]=0;
	for(int i = 1; i < n; i++){
		for(int j = k; j >= 1; j--){
			if(i>=j)dp[i]=min(dp[i],dp[i-j]+abs(a[i]-a[i-j]));
		}
	}
	cout<<dp[n-1];
	
	
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
    using namespace std;
     
    #define INF (1LL << 31 - 1)
    #define MOD int(1e9+7)
    #define repi(i,j,n) for(int i = (j); i < (n); ++i)
    #define rep(i,n) repi(i,0,n)
    #define fi first
    #define se second
     
    inline void init() {
        cin.tie(0);
        ios::sync_with_stdio(false);
    }
     
    int n, m;
    vector<int> d, t;
    map<int, int> mp;
    bool flag = true;
     
    int main() {
        cin >> n;
        d.resize(n);
        rep(i,n) {
            cin >> d[i];
            mp[d[i]]++;
        }
        cin >> m;
        t.resize(m);
        rep(i,m) {
            cin >> t[i];
            if (mp[t[i]] > 0) {
                mp[t[i]]--;
            }
            else {
                flag = false;
            }
        }
     
        if (flag) cout << "YES" << endl;
        else cout << "NO" << endl;
     
        return 0;
    }

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

int main(){
	double xa,ya,xb,yb,xc,yc,xd,yd;
	while(cin>>xa>>ya>>xb>>yb>>xc>>yc>>xd>>yd){
		if(xa<=xd&&ya<=yd&&xc<=xb&&yc<=yb)cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
	return 0;
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;

int main() {
  while(true) {
    string s;
    int m;
    cin >> s >> m;
    if(s == "-") break;
    vector<int> h(m);
    rep(i,m) {
      cin >> h[i];
    }
    string c = s;
    rep(i,m) {
      rep(j,sz(s)-h[i]) {
        c[j] = s[j+h[i]];
      }
      rep(j,h[i]) {
        c[sz(s)-h[i]+j] = s[j];
      }
      s = c;
    }
    cout << s << endl;
  }
  return 0;
}


Measured memory_bytes: 3192
#include<bits/stdc++.h>
using namespace std;
const int MAXN=101;

int n,cx,cy;
int calc(int x,int y)
{
	if(x-y<0)
	  return y-x;
	return x-y;
}

struct zb{
	int x,y;
	long long h;
	bool operator<(const zb &s)const{
		return h>s.h;
	}
}a[MAXN];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
	  scanf("%d%d%d",&a[i].x,&a[i].y,&a[i].h);
	sort(a+1,a+n+1);
	for(cx=0;cx<=100;++cx)
	    for(cy=0;cy<=100;++cy)
	    {
	    	int H=calc(cx,a[1].x)+calc(a[1].y,cy)+a[1].h;
	    	bool flag=true;
			for(int i=2;i<=n;++i)
	    	{
	    		if(a[i].h==0)
	    		{
	    			if(H-calc(a[i].x,cx)-calc(a[i].y,cy)>0)
	    			{
	    				flag=false;
	    				break;
	    			}
	    		}
	    		else
	    		{
	    			if(H-calc(a[i].x,cx)-calc(a[i].y,cy)!=a[i].h)
	    			{
	    				flag=false;
	    				break;
	    			}
	    		}
	    	}
	    	if(flag)
	    	{
	    		printf("%d %d %d",cx,cy,H);
	    		return 0;
	    	}
	    }
}

Measured memory_bytes: 256
import java.util.*;

class Main {
    static public void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        String str = sc.next();
        char[] S = new char[N];

        for (int i=0; i<N; i++) {
            S[i] = str.charAt(i);
        }

        for (int i=0; i<N; i++) {
            if (i == K-1) {
                System.out.print((char)(S[i] + 32));
            } else {
                System.out.print(S[i]);
            }
        }
    }
}


Measured memory_bytes: 21588
#include <bits/stdc++.h>
using namespace std;
long n;
string s,t="";
int main(){
  cin >> n >> s;
  if( n%2 != 0 ){
    cout << "No";
    return 0;
  }
  s = '@' + s;
  for(long i = 1; i <= n/2; i++) t += s[i];
  t += t;
  t = '@' + t;
  if( s == t ){
    cout << "Yes";
  }
  else cout << "No";
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int a = sc.nextInt();
    int b = sc.nextInt();
    if(n*a >= b){
      System.out.println(b);
    }else if(n*a < b){
      System.out.println(n*a);
    }
  }
}

Measured memory_bytes: 23380
import sys
import os

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    S = iss()
    T = iss()
    
    print('Yes' if S in T*2 else 'No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <iomanip> 

using ll = long long;
using ull = unsigned long long;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;(i) < ((int)(n));++(i))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

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

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

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline void print(T&& x){cout<<x<<endl;}// 改行付き出力
template<typename T>inline T SUM(vector<T> vec){return accumulate(all(vec),(T)0);} // vectorの中身を全部足す
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
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; }
int ctoi(char c){return c-'0';}


// TODO: write
int main() {
  int n,k;cin>>n>>k;
  vector<int> a(n);rep(i,n)cin>>a[i];
  sort(all(a));

  auto check = [&](int x) -> bool{
    int cnt = 0;
    rep(i,n)cnt += (a[i]/x) - 1 + !!(a[i]%x);
    return cnt <= k;
  };

  auto ans = [&]() -> int{
    int ok = a[n-1];
    int ng = 0;
    while(abs(ok - ng) > 1){
      int mid = (ok + ng)/2;
      if(check(mid))ok = mid;
      else ng = mid;
    }
    return ok;
  }();
  print(ans);
  return 0;
}

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

int main()
{
	int a,b,k;
	cin>>a>>b>>k;
	
	if(k*2<b-a+1){
		for(int i=0;i<k;i++) cout<<a+i<<endl;
		for(int i=k-1;i>=0;i--) cout<<b-i<<endl;
	}else
		for(int i=a;i<=b;i++) cout<<i<<endl;
	
	return 0;
}


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

 
//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;

//container util
//------------------------------------------
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
//constant
//--------------------------------------------
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
const LL INF=LONG_MAX;
const double EPS=0.00001;
const long double PI = acos(-1.0);


int main(){
    int N;cin>>N;
    vector<int>p(N);
    REP(i,N){
        cin>>p[i];p[i]--;
    }
    int res=0;
    int tmp=0;
    REP(i,N){
        if(p[i]==i){
            tmp++;
        }else{
            res+=tmp/2+tmp%2;
            tmp=0;
        }
    }
    res+=tmp/2+tmp%2;
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 640
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
using ll = long long;
using P = pair<ll,ll>;

int main(){
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
vector<ll> a(5);
rep(i,5)
cin >> a[i];
rep(i,5){
    if(a[i] == 0)
    {
        cout << i + 1 << endl;
        return 0;
    }
}
}

Measured memory_bytes: 3648
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));



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

	string S;
	cin >> S;

	int ans = 0,cnt=0;
	REP(i, S.size()) {
		if (S[i] == 'A' || S[i] == 'T' || S[i] == 'G' || S[i] == 'C')cnt++;
		else {
			ans = max(ans, cnt);
			cnt = 0;
		}
		if (i == S.size() - 1) {
			ans = max(ans, cnt);
			cnt = 0;
		}
	}


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



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

int main()
{
    string a;
    cin >> a;
    int s = 0;
    int t = 0;
    int t1 = 0;
    for (int i = 0 ; i < a.size(); i++) {
        if (a[i] == 'S') {
            s++;
        }
        else {
            if (s == t) {
                t1 += 2;
            }
            if (s > t) {
                t++;
            }
        }
    }
    cout << t1;
    return 0;
}


Measured memory_bytes: 640
import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
from collections import deque
def getN():
    return int(input())
def getList():
    return list(map(int, input().split()))
import math
import bisect
from logging import getLogger, StreamHandler, DEBUG, WARNING
logger = getLogger(__name__)
handler = StreamHandler()
handler.setLevel(DEBUG)
logger.setLevel(DEBUG)
handler.setLevel(WARNING)
logger.setLevel(WARNING)
logger.addHandler(handler)
logger.propagate = False


# class SegTree():
#     def __init__(self, n):
#         self.value = [0 for i in range(n*2)]

# MOD = 10 ** 9 + 7

# def getinvmod(n):
#     return [pow(i, MOD-2, MOD) for i in range(n+1)]

def main():
    n, m = getList()
    sushis = []
    for i in range(n):
        sushis.append(getList())

    tmp = 0
    acc = [(0, 0)]
    acc2 = [0]
    acc2idx = [0]

    for sushi in sushis:
        tmp += sushi[1]
        if tmp - sushi[0] > acc[-1][1]:
            acc.append((sushi[0], tmp - sushi[0]))
        if tmp - 2 * sushi[0] > acc2[-1]:
            acc2.append(tmp - sushi[0] * 2)
            acc2idx.append(sushi[0])

    tmp = 0
    racc = [(0, 0)]
    racc2 = [0]
    racc2idx = [0]

    for sushi in sushis[::-1]:
        tmp += sushi[1]
        dist = m - sushi[0]
        if tmp - dist > racc[-1][1]:
            racc.append((sushi[0], tmp - dist))
        if tmp - 2 * dist > racc2[-1]:
            racc2.append(tmp - 2 * dist)
            racc2idx.append(dist)


    ans = 0
    for asu in acc:
        tmp = asu[1]
        idx = bisect.bisect_left(racc2idx, m - asu[0])
        tmp += racc2[idx - 1]
        if tmp > ans:
            ans = tmp
            logger.info(asu, tmp, idx)

    for asu in racc:
        tmp = asu[1]
        idx = bisect.bisect_left(acc2idx, asu[0])
        tmp += acc2[idx - 1]
        if tmp > ans:
            ans = tmp
            logger.info(asu, tmp)

    print(ans)
    logger.info(acc, acc2)
    logger.info(racc, racc2, racc2idx)

    return
if __name__ == "__main__":
    main()

Measured memory_bytes: 84056
#include <bits/stdc++.h>
using namespace std;
#define rep(i, m, n) for (int i = m; i < n; ++i)

int N, A, B, C;
int l[8];
int ans = 1e9;

int dfs(int d, int a, int b, int c) {
  if(d == N) {
    if(a && b && c) return abs(a - A) + abs(b - B) + abs(c - C) - 30;
    else return 1e9;
  }
  int ret = min(dfs(d + 1, a, b, c), dfs(d + 1, a + l[d], b, c) + 10);
  int ret2 = min(dfs(d + 1, a, b + l[d], c) + 10, dfs(d + 1, a, b, c + l[d]) + 10);
  return min(ret, ret2);
}

int main() {
  cin >> N >> A >> B >> C;
  rep(i, 0, N) cin >> l[i];
  cout << dfs(0, 0, 0, 0) << "\n";
  return 0;
}


Measured memory_bytes: 256
import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons, std.functional;

void main() {
    auto S = readln.chomp.dup;

    bool po() {
        if (S[0] != 'A') return false;
        if (S[2..$-1].count('C') != 1) return false;
        foreach (i; 2..S.length-1) {
            if (S[i] == 'C') S[i] = 'c';
        }
        return S[1..$].toLower == S[1..$];
    }
    writeln(po() ? "AC" : "WA");
}



Measured memory_bytes: 380
#include<stdio.h>
int main(){
  int a,b,x,y,z,m;
  scanf("%d",&a);
  scanf("%d",&b);
  x = a+b;
  y = a-b;
  z = a*b;
  if(x > y) m = x;
  else m = y;
  if(z > m) m = z;
  printf("%d",m); 
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#include <unordered_map>
#define inputarr(a,n) for(ll i=0;i<n;i++) cin>>a[i];
#define prllarr(a,n) for(ll i=0;i<n;i++) cout<<a[i]<<" ";
#define pb push_back
#define ll long long
#define mod 1000000007
#define foi ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
#define in(n) scanf("%lld",&n);
#define in2(x,y) scanf("%lld %lld",&(x),&(y));
#define in3(x,y,z) scanf("%lld %lld %lld",&(x),&(y),&(z));
#define out(n) printf("%lld\n",n);
#define out2(x,y) printf("%lld %lld\n",x,y);
#define test(t)  ll t; in(t);while(t--)
#define set(arr,n,s) for(ll i=0;i<n;i++){arr[i]=s;}


/*error-----
convert every int to long long eg-1LL
create array with proper analysis of problem constrain
check mod also
*/
ll power(ll x,ll y,ll p){ll res=1;x=x%p;while(y>0){if(y&1){res=(res*x)%p;} y=y>>1;x=(x*x)%p;}return res;}
ll modInverse(ll a,ll p){return power(a,p-2,p);}//used with feemat little

ll gcd(ll x,ll y){if(x==0 || y==0){return max(y,x);}return gcd(y%x,x);}
ll gcdExtended(ll a,ll b,ll &x,ll &y){if(a==0){x=0;y=1;return b;}ll x1,y1;ll gcd = gcdExtended(b%a,a,x1,y1);x=y1-(b/a)*x1;y=x1;return gcd;}//o(log(b))

//ll ncr(ll n,ll r,ll p){if(r==0){return 1;}return ((((fact[n]* inv[r]) % p) * inv[n-r]) % p);}
ll arr[100003][3];
ll dp[100003][3];

int main()
{	
		ll n;
		in(n)
		for(ll i=0;i<n;i++)
		{
			ll a,b,c;
			in3(a,b,c)
			arr[i][0]=a;arr[i][1]=b;arr[i][2]=c;
		}
		for(ll i=1;i<=n;i++)
		{
			for(ll j=0;j<3;j++)
			{

				for(ll m=0;m<3;m++)
				{
					if(j!=m)
					{
						dp[i][j]=max(dp[i][j],arr[i-1][j]+dp[i-1][m]);
					}
				}
			}
		}
		cout<<max(max(dp[n][0],dp[n][1]),dp[n][2]);

}
	



	

Measured memory_bytes: 4992
/*
17D8101013F 森田　匡博
ID:key4 使用言語:C++
*/

#include <iostream>
#include <cmath>

int main() 
{
  int n, j, cnt, w;
  std::cin >> n;
  int A[n] = {0};
  int B[10000] = {1};
  for(int i = 0; i < n; i++) {
    std::cin >> A[i];
  }

  cnt = 0;
  for(int i = 0; i < n; i++) {
    if(A[i] == 2) {
      cnt++;
    }
    else {
      if(A[i] % 2 != 0) {
	j = 3;
	w = 0;
	while(j <= int(sqrt(A[i]))) {
	  if(A[i] % j == 0) {
	    w = 1;
	    break;
	  }
	  j += 2;
	}
	if(w == 0) {
	  cnt++;
	}
      }
    }
  }

  std::cout << cnt << "\n";

  return 0;
}



Measured memory_bytes: 3156
//コンパイラ最適化用
#pragma GCC optimize("Ofast")

//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<chrono>//実行時間計測
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm,accumulate
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//順序保持しないmap
#include<unordered_set>//順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

signed main(){
/*
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++)
    cin >> a[i];
*/
  int X;
  cin >> X;

  cout << 10 - (X / 200) << endl;

  return 0;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int len=0;
	char s[2];
	for(int i=1;i<=9;i++)
	{
		printf("? 1");
		for(int j=1;j<=i;j++)putchar('0');
		puts("");
		fflush(stdout);
		scanf("%s",s);
		if(s[0]=='N')
		{
			len=i;
			break;
		}
	}
	if(!len)
	{
		for(int i=1;i<=10;i++)
		{
			putchar('?');
			putchar(' ');
			for(int j=1;j<=i;j++)
			{
				putchar('9');
			}
			puts("");
			fflush(stdout);
			scanf("%s",s);
			if(s[0]=='Y')
			{
				putchar('!');
				putchar(' ');
				putchar('1');
				for(int j=1;j<=i-1;j++)putchar('0');
					puts("");
				fflush(stdout);
				return 0;
			}
		}
	}
	int ans[100];
	for(int i=len;i>=1;i--)
	{
		int l=0,r=9;
		while(l<r)
		{
			if(i==len&&l==0&&r==1)
			{
				break;
			}
			int mid=(l+r)>>1;
			putchar('?');
			putchar(' ');
			for(int k=len;k>i;k--)printf("%d",ans[k]);
			printf("%d" ,mid);
			for(int j=1;j<=12-(len-i);j++)putchar('9');
			puts("");
			fflush(stdout);
			scanf("%s",s);
			if(s[0]=='N')
			{
				l=mid+1;
			}
			else
			{
				r=mid;
			}
		}
		ans[i]=r;
	}

	putchar('!');
	putchar(' ');
	for(int j=len;j>=1;j--)
	{
		printf("%d",ans[j]);
	}
	puts("");
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 684
#include <bits/stdc++.h>
#define rep(n) for (int I = 0; (I) < (n); ++(I) )
#define repeat(i, n) for( int i = 0; (i) < (n); ++(i) )
#define repeat_to(i, n) for( int i = 0; (i) <= (n); ++(i) )
#define repeat_from(i, m, n) for( int i = (m); (i) < (n); ++(i) )
#define repeat_from_to(i, m, n) for( int i = (m); (i) <= (n); ++(i) )
#define repeat_from_reverse(i, m, n) for( int i = (n) - 1; (i) >= (m); --(i) )
#define dump(x) cout << " " << #x << "=" << x
#define vdump(v) for(size_t t=0; t<v.size(); ++t){cout << " " << #v << "[" << t << "]=" << v[t];} cout << endl
using namespace std;
using lint = long long;
using ld = long double;

int main(void) {
    lint a, b, x; cin >> a >> b >> x;
    lint c, d;
    
    if (a%x != 0) {
        c = (a/x)*x + x;
    }
    else {
        c = a;
    }
    
    if (b%x != 0) {
        d = (b/x)*x;
    }
    else {
        d = b;
    }
    
    if (c > d) cout << 0 << endl;
    else cout << (d-c)/x + 1 << endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
h = list(map(int, input().split()))
inf = 10**9 + 7
dp = [inf] * N
dp[0] = 0

for i in range(N-1):
    if i == N-2:
        dp[i+1] = min(dp[i+1], dp[i]+abs(h[i]-h[i+1]))
        break
    dp[i+1] = min(dp[i+1], dp[i]+abs(h[i]-h[i+1]))
    dp[i+2] = min(dp[i+2], dp[i]+abs(h[i]-h[i+2]))
print(dp[N-1])


Measured memory_bytes: 13904
n = int(input())
a = list(map(int, input().split()))

a = [0] + a + [0]

# print(a)
s = 0
for i in range(n + 1):
    s += abs(a[i] - a[i + 1])
    # print(s)
# print(s)
for i in range(1, n + 1):
    ans = s + abs(a[i - 1] - a[i + 1]) - (abs(a[i - 1] - a[i]) + abs(a[i] - a[i + 1]))
    print(ans)


Measured memory_bytes: 14048
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	private static int N = 0;
	private static int M = 0;
	private static int[][] AB;
	private static Boolean[] flagArray;
	private static int count = 0;
	private static String direction = "";

	public static void main(String[] args) {

		try (Scanner sc = new Scanner(System.in)) {
			N = Integer.parseInt(sc.next());
			M = Integer.parseInt(sc.next());
			sc.nextLine();
			// 無向なので2倍用意
			AB = new int[M * 2][2];
			// １オリジン
			flagArray = new Boolean[N + 1];
			Arrays.fill(flagArray, 1, flagArray.length, false);
			// １オリジンのため0は探索済みにしておく
			flagArray[0] = true;

			for (int i = 0; i < M * 2; i = i + 2) {
				int from = Integer.parseInt(sc.next());
				int to = Integer.parseInt(sc.next());
				//sc.nextLine();
				// 双方向分用意
				AB[i][0] = from;
				AB[i][1] = to;
				AB[i + 1][0] = to;
				AB[i + 1][1] = from;

			}
		}
		exe(1);
		System.out.println(count);
	}

	private static void exe(int now) {
		// nowは探索済み
		flagArray[now] = true;
		direction += String.valueOf(now);

		// 全て探索済みか？
		if (!Arrays.asList(flagArray).contains(false)) {
			count++;
			// Debug
			//System.out.println(direction);
			// 戻るのでnowを未探索に戻す
			flagArray[now] = false;
			direction = direction.substring(0, direction.length() - 1);
			return;
		}

		for (int i = 0; i < AB.length; i++) {
			// from値がnowでto値が探索済みでない
			if (AB[i][0] == now && !flagArray[AB[i][1]]) {
				// toへ飛ぶ
				exe(AB[i][1]);
			}
		}

		// 戻るのでnowを未探索に戻す
		flagArray[now] = false;
		direction = direction.substring(0, direction.length() - 1);
	}
}

Measured memory_bytes: 27476
n,m=map(int,input().split())
def divisor(n):
  ass=[]
  for i in range(1,int(n**0.5)+1):
    if n%i==0:
      ass.append(i)
      if i!=n//i:ass.append(n//i)
  return ass
ans=0
for i in divisor(m):
  if m//i>=n:ans=max(ans,i)
print(ans)

Measured memory_bytes: 3064
/*
        _            _                  _            _       _     _         _   _          _          _             _        
       / /\         / /\               / /\         / /\    / /\  /\ \      /\_\/\_\ _     /\ \       /\ \     _    /\ \      
      / /  \       / /  \             / /  \       / / /   / / /  \ \ \    / / / / //\_\   \ \ \     /  \ \   /\_\ /  \ \     
     / / /\ \__   / / /\ \           / / /\ \__   / /_/   / / /   /\ \_\  /\ \/ \ \/ / /   /\ \_\   / /\ \ \_/ / // /\ \_\    
    / / /\ \___\ / / /\ \ \         / / /\ \___\ / /\ \__/ / /   / /\/_/ /  \____\__/ /   / /\/_/  / / /\ \___/ // / /\/_/    
    \ \ \ \/___// / /  \ \ \        \ \ \ \/___// /\ \___\/ /   / / /   / /\/________/   / / /    / / /  \/____// / / ______  
     \ \ \     / / /___/ /\ \        \ \ \     / / /\/___/ /   / / /   / / /\/_// / /   / / /    / / /    / / // / / /\_____\ 
 _    \ \ \   / / /_____/ /\ \   _    \ \ \   / / /   / / /   / / /   / / /    / / /   / / /    / / /    / / // / /  \/____ / 
/_/\__/ / /  / /_________/\ \ \ /_/\__/ / /  / / /   / / /___/ / /__ / / /    / / /___/ / /__  / / /    / / // / /_____/ / /  
\ \/___/ /  / / /_       __\ \_\\ \/___/ /  / / /   / / //\__\/_/___\\/_/    / / //\__\/_/___\/ / /    / / // / /______\/ /   
 \_____\/   \_\___\     /____/_/ \_____\/   \/_/    \/_/ \/_________/        \/_/ \/_________/\/_/     \/_/ \/___________/    
                                                                                                                              
*/
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for(int i = 0;i < (n);++i)

#define endl '\n'
#define pb emplace_back
#define mkp make_pair
#define p_q priority_queue
#define INF 1000000000
#define PI 3.1415926
#define coutdb cout << fixed << setprecision(10)

const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};
const int dx_8[]={1,1,0,-1,-1,-1,0,1}, dy_8[]={0,-1,-1,-1,0,1,1,1};
const long long MOD = 1e9+7;

typedef long long ll;
// #define int long long

template <typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}

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

  int n,k; cin >> n >> k;
  cout << n-k+1 << endl;
  
  return 0;
}

Measured memory_bytes: 256
import numpy as np

_ = input()
L = np.array(list(map(int, input().split())))

while True:
    th, index = np.amin(L), np.argmin(L)
    L = np.mod(L, th)
    L[index] = th
    L = L[L > 0]
    if len(L) == 1:
        print(L[0])
        break

Measured memory_bytes: 23092
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace AtCoder.D
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var N = ReadLong();
            var A = ReadLongs().OrderBy(x => x).ToList();

            var max = A.Last();
            var baisuuCount = new long[max + 1];
            for (int i = 0; i < N; i++)
            {
                var baseA = A[i];

                for (int j = 1; ; j++)
                {
                    var baisuu = baseA * j;
                    if (baisuu > max)
                    {
                        break;
                    }

                    baisuuCount[baisuu]++;
                }
            }

            return A.Count(x => baisuuCount[x] == 1);
        }

        #region Console.Read

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static (long, long) Read2Longs() { var ls = ReadLongs(); return (ls[0], ls[1]); }
        public static (long, long, long) Read3Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2]); }
        public static (long, long, long, long) Read4Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3]); }
        public static (long, long, long, long, long) Read5Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3], ls[4]); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


Measured memory_bytes: 57144
#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
#define rep(i, a, n) for (int i=(a); i<(n); i++)
#define per(i, a, n) for (int i=(a); i>(n); i--)
typedef long long ll;
const int maxn = 2e5+5;
const int mod = 1e9+7;
using namespace std;
#define PI acos(-1)

void slove() {
	double a,b,h,m;
	cin >> a >> b >> h >> m;
	double deg1 = (2*PI/12*(h+m/60)), deg2 = 2*PI/60*m;
	double deg = abs(deg1-deg2);
	cout << setprecision(15) << sqrt(a*a+b*b-2*a*b*cos(deg));
}

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef DEBUG
	freopen("C:\\Users\\Fish_Brother\\Desktop\\in", "r", stdin);
	//freopen("C:\\Users\\Fish_Brother\\Desktop\\out", "w", stdout);
#endif
	cout.setf(ios::fixed);
	//int t; cin >> t; while(t--)
	slove();

	return 0;
}

Measured memory_bytes: 4268