akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

const int MAX = 2000010;
const int MOD = 1000003;

ll fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll COM (int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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

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

    COMinit();

    ll Q;
    cin >> Q;
    while (Q--) {
        ll x, d, n;
        cin >> x >> d >> n;
        ll ans;
        if (d == 0) ans = modpow(x, n);
        else {
            ll first = (MOD - 1 + x * inv[d]) % MOD;
            if (first / MOD != (first+n) / MOD) ans = 0;
            else {
                ans =  fac[first + n] * finv[first] % MOD;
                ans *= modpow(d, n);
                ans %= MOD;
            }
        }
        cout << ans << "\n";
    }
}

Measured memory_bytes: 47744
N,K = map(int,input().split())

sunuke = []
ans = 0

for i in range(N):
    sunuke.append([])

for i in range(1,K+1):
    input()
    for j in map(int,input().split()):
        sunuke[j-1].append(i)

for i in sunuke:
    if len(i) == 0:
        ans += 1

print(ans)

Measured memory_bytes: 9140
import java.io.IOException;
import java.io.InputStream;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        String s = fs.next();
        int[] arr = new int[4];
        String[] str_arr = new String[3];
        for (int i = 0; i < 4; ++i) {
            arr[i] = s.charAt(i) - 48;
        }

        for (int bit = 0; bit < (1<<3); ++bit) {
            int sum = arr[0];
            for (int i = 0; i < 3; ++i) {
                if ((bit & (1<<i)) != 0) {
                    sum += arr[i+1];
                    str_arr[i] = "+";
                } else {
                    sum -= arr[i+1];
                    str_arr[i] = "-";
                }
            }
            if (sum == 7) {
                System.out.println(arr[0] + str_arr[0] + arr[1] + str_arr[1] +
                        arr[2] + str_arr[2] + arr[3] + "=" + 7);
                System.exit(0);
            }
        }
    }
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}

    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }

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




Measured memory_bytes: 38604
#include <iostream>

int main(int argc, char const *argv[])
{
    using namespace std;

    int x, y;
    while (1)
    {
        cin >> x >> y;
        if (x != 0 || y != 0)
        {
            if (x > y)
            {
                cout << y << " " << x << endl;
            }
            else
            {
                cout << x << " " << y << endl;
            }
        }
        else if (!x && !y)
        {
            break;
        }
    }

    return 0;
}



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

int main(){

  string s;
  int len;
  cin>>len>>s;
  
  if(len%2!=0){
    cout<<"No"<<endl;
    return 0;
  }
  
  for(int i=0;i<len/2;i++){
    if(s.at(i)!=s.at(len/2+i)){
      cout<<"No"<<endl;
      return 0;
    }
  }
  
  cout<<"Yes"<<endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <fstream>

#define ll long long
#define ld long double

using namespace std;

ifstream fin("date.in");

int main() {
    string a, b;

    cin >> a >> b;

    b.pop_back();

    if (a == b)
        cout << "Yes\n";
    else
        cout << "No\n";

    return 0;
}


Measured memory_bytes: 3632
#include <cstdio>
#include <algorithm>
#include <queue>

#define Rep(i, n) for (int i = 1; i <= n; i ++)
#define Rep0(i, n) for (int i = 0; i <= n; i ++)
#define mp(a, b) make_pair(a, b)

using namespace std;

const int N = 2010;

vector<int> e[N], e0[N];
int dep[N], d[N], a[N];
bool vis[N];

void dfs(int x, int f)
{
	vis[x] = true, dep[x] = dep[f] + 1;
	if (e[x].size()) Rep0(i, e[x].size() - 1) {
		if (!vis[e[x][i]]) dfs(e[x][i], x);
		if (dep[e[x][i]] > dep[x]) e0[x].push_back(e[x][i]), d[e[x][i]] ++;
		else e0[e[x][i]].push_back(x), d[x] ++;
	}
}

int gcd(int a, int b) { return !b ? a : gcd(b, a % b);}

priority_queue< pair<int, int> > q;

int main()
{
//	freopen("mmp_.in", "r", stdin);
//	freopen("mmp_.out", "w", stdout);

	int n;
	scanf("%d", &n);
	Rep(i, n) scanf("%d", &a[i]);
	sort(a + 1, a + 1 + n);
	Rep(i, n) Rep(j, i - 1)
		if (gcd(a[i], a[j]) != 1){
			e[i].push_back(j), e[j].push_back(i);
		//	printf("%d ---> %d\n", i, j);
		}
	
	Rep(i, n) sort(e[i].begin(), e[i].end());

	Rep(i, n) if (!vis[i]) dfs(i, 0);

	Rep(i, n) if (!d[i]) q.push(mp(a[i], i));

	while(!q.empty()) {
		int x = q.top().second; q.pop();
		printf("%d ", a[x]);
		if (e0[x].size()) Rep0(i, e0[x].size() - 1) {
			d[e0[x][i]] --;
			if (!d[e0[x][i]]) q.push(mp(a[e0[x][i]], e0[x][i]));
		}
	}
	printf("\n");

	return 0;
}
/*
5
1 2 3 4 5
*/

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

namespace A___Between_Two_Integers
{
    class Program
    {
        static void Main(string[] args)
        {
            var A_B_C = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int A = A_B_C[0], B = A_B_C[1], C = A_B_C[2];

            Console.WriteLine(C >= A && C <= B ? "Yes" : "No");
        }
    }
}


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

int main() {
  int x;
  while(scanf("%d",&x)==1) {
    int a[15];
    fill(a,a+14,0);
    a[x]++;
    for(int i=0; i<4; i++) {
      scanf("%*c%d",&x);
      a[x]++;
    }
    int z=1,cnt=0;
    for(int i=1; i<14; i++) {
      if(a[i]==2) {
	if(z==1) z=2;
	else if(z==2) z=3;
	else if(z==4) z=6;
      }
      if(a[i]==3) {
	if(z==1) z=4;
	else if(z==2) z=6;
      }
      if(a[i]==4) {
	z=7;
      }
      if(a[i]==1) {
	cnt++;
      } else cnt=0;
      if(cnt==5) z=5;
    }
    if(cnt==4 && a[1]==1) z=5;

    if(z==1) cout << "null" << endl;
    if(z==2) cout << "one pair" << endl;
    if(z==3) cout << "two pair" << endl;
    if(z==4) cout << "three card" << endl;
    if(z==5) cout << "straight" << endl;
    if(z==6) cout << "full house" << endl;
    if(z==7) cout << "four card" << endl;
  }
  return 0;
}


Measured memory_bytes: 1196
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REPR(i, n) for(int i = (n); i >= 0; i--)
#define FOR(i, m, n) for(int i = (m); i < (n); i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << ": " << x << endl;

using namespace std;
typedef long long ll;

signed main() {
  ll x, s = 100, n = 0;
  cin >> x;
  while(x > s) {
    s *= 1.01;
    n++;
  }
  cout << n << endl;
  return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i < (int)(n); i++)
using ll = long long;

using namespace std;
int main() {
	ll s, allsum = 0;
	cin >> s;
	int len =ceil(log10(s+ 1LL));
	for (int bit = 0; bit < (1 << (len - 1)); bit++) {
		ll tmps = s, cut = 10;
		rep(i, len - 1) {
			if (bit & (1 << i)) {
				allsum += tmps % cut;
				tmps /= cut;
				cut = 1;
			}
			cut *= 10;
		}
		allsum += tmps;
	}
	cout << allsum << endl;
}


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

using namespace std;

const int MAX_N = 1000000;
#define IOS ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define prec std::cout << std::fixed << std::setprecision(15);
#define endl "\n"
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define rep(i, n) for (int i = 0; i < int(n); i++)
#define ssort(z) sort(z.begin(), z.end())
#define rsort(z) sort(z.rbegin(), z.rend())
#define eerase(z) z.erase(unique(z.begin(), z.end()), z.end())
#define ccnt(z, w) count(z.begin(), z.end(), w)

void printVec(std::vector<int> &vec) {
//    std::cout << "";
    for (auto it = vec.begin(); it != vec.end(); ++it) {
        std::cout << *it << " ";
    }
    cout << '\n';
}

void printVec1(std::vector<string> &vec) {
//    std::cout << "";
    for (auto it = vec.begin(); it != vec.end(); ++it) {
        std::cout << *it << " ";
    }
    cout << '\n';
}

void printVec2(std::vector<Int> &vec) {
//    std::cout << "";
    for (auto it = vec.begin(); it != vec.end(); ++it) {
        std::cout << *it << " ";
    }
    cout << '\n';
}

Int gcd(Int a, Int b) {
    return b != 0 ? gcd(b, a % b) : a;
}

Int lcm(Int a, Int b) {
    return a / gcd(a, b) * b;
    //a*bは64bit integer overflow
}

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

Int fact(int num) {
    if (num == 0)
        return 1;
    else
        return num * fact(num - 1);
}

bool ispositive(Int num,int i) {
    if (num > 0) return true;
    if (num < 0) return false;
    else if(i==0) return false;
    else return true;
}

int cnt=0;
int main() {
    IOS;
    prec;
    //std::ifstream in("01-04.txt");
    //std::cin.rdbuf(in.rdbuf());
    Int w,h,x,y;cin>>w>>h>>x>>y;
    int i=0;
    if(x*2==w&&y*2==h)i=1;
    cout<<(double)1.0*w*h/2;
    cout<<" "<<i;


    cout << endl;
    return 0;
}

/*
テレビも無ェ ラジオも無ェ
自動車もそれほど走って無ェ
ピアノも無ェ バーも無ェ
巡査 毎日ぐーるぐる
朝起ぎで 牛連れで
二時間ちょっとの散歩道
電話も無ェ 瓦斯も無ェ
バスは一日一度来る
俺らこんな村いやだ 俺らこんな村いやだ
東京へ出るだ 東京へ出だなら
銭コァ貯めで 東京でベコ(牛)飼うだ
*/


Measured memory_bytes: 256
import sys
def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
INF = 1000000000000

a = S()

if(a.istitle()):
    print('A')
else:
    print('a')

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

int main()
{
  int N, Y;
  bool flag = false;
  cin >> N >> Y;

  for (int i = N; i >= 0; i--)
  {
    for (int j = N - i; j >= 0; j--)
    {
      for (int k = N - i - j; k >= 0; k--)
      {
        if ((10000 * i) + (5000 * j) + (1000 * k) == Y && i + j + k == N)
        {
          cout << i << " " << j << " " << k << endl;
          flag = true;
          break;
        }
      }
      if (flag)
      {
        break;
      }
    }
    if (flag)
    {
      break;
    }
  }
  if (!flag)
  {
    cout << "-1 -1 -1" << endl;
  }
}


Measured memory_bytes: 3640
x1,y1,x2,y2 = map(int,input().split())

x3 = x2-(y2-y1)
y3 = y2+(x2-x1)
x4 = x1-(y2-y1)
y4 = y1+(x2-x1)
print(x3,y3,x4,y4)

Measured memory_bytes: 38384
import sys
import math
from fractions import gcd
# import queue
# from collections import Counter
# from itertools import accumulate
# from functools import reduce

def lcm(a, b):
    return a * b // gcd(a, b)

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

big_prime = 1000000007

"""
# 標準入力取得
## 文字列
 =  sys.stdin.readline().rstrip()
 =  list(sys.stdin.readline().rstrip())

## 数値
 =  int(sys.stdin.readline())
 =  map(int, sys.stdin.readline().split())
 =  list(map(int, sys.stdin.readline().split()))
 =  [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""

D, G =  map(int, sys.stdin.readline().split())
L =  [list(map(int,list(sys.stdin.readline().split()))) for i in range(D)][::-1]

ans = 10 ** 10

for bit in range(2 ** D):
    cnt = 0
    point = 0
    for i, l in enumerate(L):
        # print(bin(bit), i, bin(1 << i))
        if bit & (1 << i):
            q_num = l[0]
            bonus = l[1]
            point += q_num * (D - i) * 100 + bonus
            cnt += q_num

    if point >= G:
        ans = min(ans, cnt)
        continue

    for i, l in enumerate(L):
        if not bit & (1 << i):
            for _ in range(l[0]):
                point += (D - i) * 100
                cnt += 1
                if point >= G:
                    break
            else:
                continue
            break

    ans = min(ans, cnt)

print(ans)


Measured memory_bytes: 68204
//gauravsinghh
#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 ll long long int
#define ld long double
#define db double
#define pii pair<int,int>
#define pll pair<long long,long long>
#define sii set<int>
#define sll set<long long>
#define vii vector<int> 
#define vll vector<long long>
#define mii map<int,int>
#define mll map<long long, long long>
#define lob lower_bound
#define upb upper_bound
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define pf push_front
#define ins insert
#define mp make_pair
#define w(t) cin >> t;while(t--)
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define os cout<<" "
#define bitcount __builtin_popcount
#define gcd __gcd
#define endl "\n"
#define present(s,x) (s.find(x) != s.end()) 
#define cpresent(s,x) (find(all(s),x) != s.end()) 
#define ford(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++) 
#define fors(container, it, a, b) for(__typeof(container.begin()) it = a; it != b; it++) 
#define MOD 1000000007
#define EPSILON 1e-9
#define PI 3.14159265358979323846
#define inf 999999999999999999
#define siz 100005
#define fbo find_by_order
#define ook order_of_key
#define sz(s) (int)s.size()
#define mem(n,m) memset(n,m,sizeof(n))
#define rep(i,n) for(ll i = 0; i < n; i++)
#define ren(i,n) for(ll i = n-1; i >= 0; i--)
#define all(x) x.begin(),x.end()
#define fo(i, a, b) for(int i = a; i <= b; i++)
#define ffo(i, a, b) for(int i = a; i >= b; i--)
#define MAX 100005
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")

void io_set() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

bool comp(const pair < ll, ll >&a, const pair < ll, ll >&b){
    return ((a.ss < b.ss) || (a.ss == b.ss && a.ff < b.ff));
}

signed main(){ 
    IOS
    //io_set();
    ll n;
    cin >> n;
    ll a[n], c = 0;
    rep(i, n)   cin >> a[i];
    fo(i, 1, n-2){
        set < ll > s;
        s.ins(a[i-1]);
        s.ins(a[i+1]);
        s.ins(a[i]);
        auto it = s.begin();
        it++;
        if(*it == a[i]){
            //cout << a[i] << endl;
            c++;
        }
    }
    cout << c << endl;
    return 0;
}



Measured memory_bytes: 256
h, w = map(int, input().split())
a = [[] for _ in range(h)]

for i in range(h):
    a[i] = list(map(int, input().split()))

ans = []

for i in range(h):
    if i != h - 1:
        for j in range(w):
            if a[i][j] % 2 != 0:
                a[i + 1][j] += 1
                a[i][j] -= 1
                ans.append([i + 1, j + 1, i + 2, j + 1])
    else:
        for j in range(w - 1):
            if a[i][j] % 2 != 0:
                a[i][j + 1] += 1
                a[i][j] -= 1
                ans.append([i + 1, j + 1, i + 1, j + 2])


print(len(ans))

for y1, x1, y2, x2 in ans:
    print("%d %d %d %d" % (y1, x1, y2, x2))


Measured memory_bytes: 65500
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define itn int   
#define mod 1000000007
#define am 998244353
#define INFi 2147483647
#define INFl 9223372036854775807LL
#define fi first
#define se second
#define be begin()
#define en end()
int abs(int a,int b){ 
  int c=max(a,b)-min(a,b);
  return c;
}
int gcd(int a,int b){//最大公約数
  int c=a%b;
  while(true){
    if(c==0) break;
    a=b;
    b=c;
    c=a%b;
  }
  return b;
}
bool IsPrime(int num){
  if (num < 2) return false;
  else if (num == 2) return true;
  else if (num % 2 == 0) return false;
  double sqrtNum = sqrt(num);
  for(int i=3;i<=sqrtNum;i+=2){
    if(num%i==0){
      return false;
    }
  }
}
int lcm(int a,int b){//最小公倍数
    return (a*b)/gcd(a,b);
}	     
int d[100000];
signed main(){
// __builtin_ctz(N);      Nを２で何回割り切れるかを返す
//(n+1)*n/2;              １からNまでの総和を求める式
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c,d,e=0,f=10000000;
  cin>>a>>b;
  for(int i=0;i<b;i++){
    cin>>c>>d;
    e=max(e,c),f=min(f,d);
  }
  if(f<e) f=e-1;
  cout<<f-e+1<<"\n";}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

//Code Short
#define REP(i,n) for(int i = 0;i < n;++i)
#define PB(s) push_back(s)
#define DSORT(n) sort(n.begin(),n.end())
#define QECHO(n) cout << n
#define QECHOS(n) cout << n << " "

//Define Math
const double EPS = 1e-10;
const double PI  = acos(-1.0);

using namespace std;
typedef long long ll;
/* prototype */
int EDSum(ll);//各桁の和
vector<int> SOE(int,int);//素数 (Min,Max)
int MinCM(int,int);//最小公倍数(num1,num2)
int MaxCD(int,int);//最大公約数(num1,num2)
vector<int> igets(int);//cin * N
ll nPr(ll,ll); //(n,r)
ll nE(ll); //(n)
ll nCr(ll,ll); //(n,r)

void solve(){
  //START
  int a,b;
  cin >> a >> b;
  if(a+b==15){
    cout << "+" << endl;
  }else if(a*b==15){
    cout << "*" << endl;
  }else{
    cout << "x" << endl;
  }
}

int main(void){cin.tie(0);ios::sync_with_stdio(false);solve();}
int EDSum(ll number) {
  int ans = 0;
  while (1) {
    ans += number % 10;
    number /= 10;
    if (number == 0) break;
  }
  return ans;
}

vector < int > SOE(int min, int max) {
  if (min < 2) min = 2;
  vector < int > int_array;
  for (int i = min; i <= max; i++) int_array.push_back(i);
  vector < int > sosu;
  double stop = sqrt(max);
  while (true) {
    sosu.push_back(int_array.front());
    int_array.erase(int_array.begin());
    if (stop < (double)(sosu.back())) break;
    for (int i = 0; i < (int) int_array.size(); i++) {
      if (int_array[i] % sosu.back() == 0)
        int_array.erase(int_array.begin() + i);
    }
  }
  sosu.insert(sosu.end(), int_array.begin(), int_array.end());
  return sosu;
}

int MinCM(int a, int b) {
  int c = a * b;
  if (a < b)
    swap(a, b);
  int r = a % b;
  while (r != 0) {
    a = b;
    b = r;
    r = a % b;
  }
  return c / b;
}

int MaxCD(int a, int b) {
  if (a < b)
    swap(a, b);
  int r = a % b;
  while (r != 0) {
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}
vector < int > igets(int N) {
  vector < int > A;
  int temp;
  for (int i = 0; i < N; ++i) {
    cin >> temp;
    A.push_back(temp);
  }
  return A;
}

ll nPr(ll n, ll r) {
  ll ans = 1;
  r = n - r;
  while (n != r) {
    ans *= n;
    --n;
  }
  return ans;
}

ll nE(ll n) {
  return nPr(n, n);
}

ll nCr(ll n, ll r) {
  if (r == 0) return -1;
  else {
    if (0 != n - r && n - r < r) r = n - r;
    return nPr(n, r) / nE(r);
  }
}

Measured memory_bytes: 892
# -*- coding: utf-8 -*-
from sys import stdin

ns = lambda: stdin.readline()[:-1] # s = ns()
ni = lambda: int(stdin.readline()) # N = ni()
na = lambda: list(map(int, stdin.readline().split())) # Arr = na()

N = ni()

Words = []
w = ns()
last = w[-1]
Words.append(w)
flag = 1
for _ in range(N-1):
    w = ns()
    if w[0] != last:
        flag = 0
    if w in Words:
        flag = 0
    last = w[-1]
    Words.append(w)

if flag == 1:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3188
def is_in(p):
    return 0 <= p[0] <= W and 0 <= p[1] <= H

W, H, x, y, r = map(int, input().split())

ans = 'Yes' if is_in((x + r, y + r)) and is_in((x - r, y - r)) else 'No'

print(ans)

Measured memory_bytes: 7728
#include <stdio.h>

int main(){
   int d,c[26],s[365][26],last[26],i,j,ms,mi,t;
   long sum;

   scanf("%d",&d);
   for (i=0;i<26;i++) {
      scanf("%d",&c[i]);
      last[i]=-1;
   }
   for (j=0;j<d;j++)
      for (i=0;i<26;i++) scanf("%d",&s[j][i]);
   for (i=0;i<d;i++) {
      mi=0;
      ms=s[i][0]-c[0]*(d-last[0]);
      for (j=1;j<26;j++) {
         t=s[i][j]-c[j]*(d-last[j]);
         if (t>ms) {
            ms=t;
            mi=j;
         }
      }
      printf("%d\n",mi+1);
      last[mi]=i;
   }
   return 0;
}


Measured memory_bytes: 1772
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int n,y;
  cin>>n>>y;
  if(y/10000>n){
    cout<<"-1 -1 -1";
    return 0;
  }
  for(int i=0;i<=y/10000;i++){
    for(int j=0;j<=n-i;j++){
      int k=n-i-j;
        if(i*10000+j*5000+k*1000==y){
          cout<<i<<" "<<j<<" "<<k;
          return 0;
        }
      
    }
  }
  cout<<"-1 -1 -1";
  return 0;
}

Measured memory_bytes: 256
def calc_sum_of_candies(sum_of_children):
    sum_of_candies = 0
    for i in range(sum_of_children+1):
        sum_of_candies = sum_of_candies + i

    return sum_of_candies

if __name__=='__main__':
    sum_of_children = int(input())
    print(calc_sum_of_candies(sum_of_children))

Measured memory_bytes: 2940
#include <stdio.h>
#include <algorithm>
using namespace std;
using ll = long long;

ll lucas[87];
int main() {
	lucas[0] = 2;
	lucas[1] = 1;

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

	for (int i = 2; i <= n; i++)
		lucas[i] = lucas[i - 1] + lucas[i - 2];

	printf("%lld\n", lucas[n]);
}

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

int main() {
  string s;
  cin>>s;
  if(s=="SAT"){
    cout<<"1"<<endl;
  }
  else if(s=="MON"){
    cout<<"6"<<endl;
  }
  else if(s=="TUE"){
    cout<<"5"<<endl;
  }
  else if(s=="WED"){
    cout<<"4"<<endl;
  }
  else if(s=="THU"){
    cout<<"3"<<endl;
  }
  else if(s=="FRI"){
    cout<<"2"<<endl;
  }
  else{
    cout<<"7"<<endl;
  }
  
}


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

int main(){
  int a, b, k;
  cin >> a >> b >> k;
  int cnt=0;
  for(int i=100; cnt<k; i--){
    if(a%i==0 && b%i==0)cnt++;
    if(cnt==k)cout << i;
  }
  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;
 class Main {
    public static void main(String[] args) {

        FastReader f = new FastReader();
        int n =f.nextInt();
        int k = f.nextInt();
        int heights [] = new int[n];
        for(int i=0;i<n;i++)
            heights[i] =f.nextInt();
        System.out.println(solve(heights,n,k));



    }
    static  int solve(int[] heights,int n,int k)
    {
       int dp[] = new int[n];
       Arrays.fill(dp,Integer.MAX_VALUE);
       dp[0]=0;
       for(int i=0;i<n;i++)
       {
           for(int j=i+1;j<Math.min(i+k+1,n);j++)
           {
               dp[j] =Math.min(dp[j],dp[i]+Math.abs(heights[i]-heights[j]));
           }


       }

       return dp[n-1];

    }



    static  class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}


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

int func(int N) {
    int ans = 1;
    for (int i = 0; i < N; i++) {
        ans *= i + 1;
    }
    return ans;
}

int main() {
    int N; cin >> N;
    vector<int> P(N), Q(N);
    for (int i = 0; i < N; i++) {
        cin >> P.at(i);
    }
    for (int i = 0; i < N; i++) {
        cin >> Q.at(i);
    }
    int pcount = func(N), qcount = func(N);
    while (next_permutation(P.begin(), P.end())) {
        pcount--;
    }
    while (next_permutation(Q.begin(), Q.end())) {
        qcount--;
    }
    cout << abs(pcount - qcount) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
using namespace std;

typedef long long ll;
#define modulo 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9

int flower[101];
int N;
int ans = 0;

void input() {
	cin >> N;
	for (int i = 0; i < N; i++) cin >> flower[i];
	flower[N] = INF;
}

void solve() { // 関数を以回呼び出す＝水やり1回
	ans++;
	
	int index = 0; // flower[i]が0でない、最初のi
	while (flower[index] == 0) index++; // まだ残ってたら
	if (index != N) {
		for (; index < N && flower[index] != 0; index++) {
			flower[index]--;
		}
		solve();
	}
	else ans--; // 水やる必要がないのに関数が呼ばれてる
}

int main() {
	input();
	solve();
	cout << ans << endl;

	return 0;
}

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

int main(void){
    int N;
    cin >> N;
    map<string, int> smap;
    for(int i = 0; i < N; i++){
        string s;
        cin >> s;
        smap[s]++;
    }
	
  	int max_time = -1;
    for(auto sm : smap){
        if(max_time < sm.second) max_time = sm.second;
    }
  	for(auto sm : smap){
        if(max_time == sm.second)
          	cout << sm.first << endl;
    }
    return 0;
}

Measured memory_bytes: 25216
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll
#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, int(n) + 1)
#define rrep(i, n) RFOR(i, 0, n)
#define rrep1(i, n) RFOR(i, 1, int(n) + 1)
#define all(c) begin(c), end(c)
const int MOD = 1000000007;

template <typename T>
void __dump__(std::ostream &os, const T &first) {
    os << first;
}
template <typename First, typename... Rest>
void __dump__(std::ostream &os, const First &first, const Rest &... rest) {
    os << first << ", ";
    __dump__(os, rest...);
}
#define dump(...)                                         \
    do {                                                  \
        std::ostringstream os;                            \
        os << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; \
        __dump__(os, __VA_ARGS__);                        \
        std::cerr << os.str() << std::endl;               \
    } while (0)


int n, m;
vector<int> x, y;

int calc(vector<int> x) {
    int n = x.size();
    int S = 0;
    for (int i = 1; i < (int)x.size(); ++i) {
        int w = x[i] - x[i-1];
        int s = w * i % MOD * (n - i) % MOD;
        S += s;
    }
    return S % MOD;
}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    while(cin >> n >> m){
        x.resize(n);
        y.resize(m);
        rep(i, n) cin >> x[i];
        rep(i, m) cin >> y[i];
        sort(all(x));
        sort(all(y));
        auto sx = calc(x);
        auto sy = calc(y);
        cout << sx * sy % MOD << endl;
    }
}


Measured memory_bytes: 2672
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> // for less 
#define pb push_back
#define For(i,s,e) for (ll i=(s); i<(e); i++)
#define Debug_array(a,n) for (ll i=(0); i<(n); i++) cout<<a[i]<<" "
#define Foe(i,s,e) for (ll i=(s); i<=(e); i++)
#define Fod(i,s,e) for (ll i=(s)-1; i>=(e); i--)
#define pii pair<ll,ll>
#define fi first
#define se second
#define endl "\n"
#define mp make_pair
#define big_prime 15486277
#define bigger_prime 179424697
#define biggest_prime 32416188691
//#define random_shuffle(indices.begin(), indices.end());
//std::random_device rd;
//std::mt19937 g(rd());
//std::shuffle(v.begin(), v.end(), g);
using namespace __gnu_pbds; 
using namespace std;
template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
// template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; }
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 0
#define _CRT_SECURE_NO_WARNINGS
#endif // ifndef ONLINE_JUDGE


typedef long long ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag,tree_order_statistics_node_update> ordered_set; 

#define Mod 1000000007
#define MAX 5002

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll n;cin>>n;
	ll a[n],b[n];
	For(i,0,n){
		cin>>a[i];
		b[i]=a[i];
	}
	sort(b,b+n);
	ll maxi = b[n-1] , maxi2 = b[n-2];
	For(i,0,n){
		if(a[i]!=maxi){
			cout<<maxi<<endl;
		}else{
			cout<<maxi2<<endl;
		}
	}































	
}

Measured memory_bytes: 4864
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using ll = long long;
using p = pair<int,int>;
using Graph = vector<vector<int>>;
int main(int argc, const char * argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    string s;
    cin>>s;
    s[3]='8';
    cout<<s<<endl;

    return 0;
}

Measured memory_bytes: 3632
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] arr = sc.next().toCharArray();
		int length = arr.length;
		int[] dp = new int[2019];
		int[] next = new int[2019];
		long count = 0;
		for (int i = 0; i < length; i++) {
		    int x = arr[i] - '0';
		    for (int j = 0; j < 2019; j++) {
		        next[(j * 10 + x) % 2019] += dp[j];
		    }
		    next[x]++;
		    count += next[0];
		    int[] tmp = next;
		    next = dp;
		    dp = tmp;
		    Arrays.fill(next, 0);
		}
		System.out.println(count);
	}
}



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

using namespace std;
 
//#define int long long
using ll = long long;
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define reps(i,n) for(ll i=0;i<=n;i++)


ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
 
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

int main(){
    ios_base::sync_with_stdio(false);
    double d,t,s;
    cin >> d >> t >> s;
    if(d/s>t){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }

    return 0;
}


Measured memory_bytes: 3676
def main():
	n = int(input())
	dp = [[[0] * (n - k - j + 1) for j in range(n - k + 1)] for k in range(n + 1)]
	for thr in range(n + 1):
		for two in range(n + 1):
			for one in range(n + 1):
				su = thr + two + one
				if su > n or su == 0:
					continue
				dp[thr][two][one] += n / su
				if thr:
					dp[thr][two][one] += dp[thr - 1][two + 1][one] * thr / su
				if two:
					dp[thr][two][one] += dp[thr][two - 1][one + 1] * two / su
				if one:
					dp[thr][two][one] += dp[thr][two][one - 1] * one / su
	a = b = c = 0
	for x in map(int, input().split()):
		if x == 3:
			a += 1
		elif x == 2:
			b += 1
		elif x == 1:
			c += 1
	print(dp[a][b][c])

if __name__ == "__main__":
	main()

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

typedef long long ll;
 
int main(){
  ll MOD = 1e9 + 7;
  int n, m;
  cin >> n >> m;
  ll x=0, y=0;
  for(int i=1; i<=n; i++){
    ll tmp;
    cin >> tmp;
    x += (i-1)*tmp - (n-i)*tmp;
    x %= MOD;
  }
  for(int i=1; i<=m; i++){
    ll tmp;
    cin >> tmp;
    y += (i-1)*tmp - (m-i)*tmp;
    y %= MOD;
  }
  ll ans = x * y;
  ans %= MOD;
  cout << ans << endl;
  return 0;
  
}


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

using ll = long long int;

ll N, M;
vector<vector<int> > g;
vector<ll> dp, ans;

ll dfs1(int i, int p){
    dp[i] = 1;
    for(auto j : g[i]){
        if(j==p) continue;
        dp[i] = dp[i]*(dfs1(j,i)+1)%M;
    }
    return dp[i];
}

void dfs2(int i, int p){
    ans[i] = dp[i];
    int k = g[i].size();
    vector<ll> lv(k+1, 1), rv(k+1, 1);
    for(int j=0;j<k;j++){
        int v = g[i][j];
        lv[j+1] = dp[v]+1;
        rv[j] = dp[v]+1;
    }
    for(int j=0;j<k;j++){
        lv[j+1] *= lv[j];
        lv[j+1] %= M;
    }
    for(int j=k;j>0;j--){
        rv[j-1] *= rv[j];
        rv[j-1] %= M;
    }
    for(int j=0;j<k;j++){
        int v = g[i][j];
        if(v == p) continue;
        dp[i] = lv[j]*rv[j+1]%M;
        dp[v] *= dp[i]+1;
        dp[v] %= M;
        dfs2(v, i);
    }
}

int main(){
    cin >> N >> M;
    g.resize(N);
    dp.resize(N);
    ans.resize(N);
    for(int i=0;i<N-1;i++){
        int a, b;
        cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    dfs1(0,-1);
    dfs2(0,-1);
    for(int i=0;i<N;i++){
        cout << ans[i] << endl;
    }
    return 0;
}


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

#define ll long long
#define pb push_back
#define pr pair<ll, ll>
#define vct vector<ll>
#define vpt vector<pr>
#define st set<ll>
#define pq priority_queue<ll>
#define mat vector<vector<ll> >
#define F(i, n) for (i = 0; i < (1LL*n); i++)
#define Fr(i, n) for (i = n - 1; i >= 0; i--)

struct custom_hash
{
    static uint64_t splitmix64(uint64_t x)
    {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(uint64_t x) const
    {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
#define umap unordered_map<long long, int, custom_hash>
void prv(vct v)
{
    for (ll i = 0; i < v.size(); i++)
        cout << v[i] << " ";
    cout << "\n";
}
ll poww(ll x, ll y, ll m)
{
    ll res = 1;
    while (y)
    {
        if (y % 2 == 0)
        {
            x = (x * x) % m;
            y = y / 2;
        }
        else
        {
            res = (res * x) % m;
            y--;
        }
    }
    return res;
}
void deb(string s, ll n)
{
    cout << s << " : " << n << "\n";
}
void prn(ll n) { cout << n << "\n"; }
void prs(string n) { cout << n << "\n"; }

mat mt;
void setmtsize(ll m,ll n, ll ini=0){
    mt.resize(m,vector<ll>(n,ini));
}
void prmt(mat m){
    for(ll i=0;i<(1LL*m.size());i++)prv(m[i]);
}
vct divsors(ll n)
{
    vct ans;//ans.push_back(1);
    for(ll i=1;i<=sqrt(n);i++)
    {if(n%i==0){ans.push_back(i);if(i!=(n/i))ans.push_back(n/i);}}
    sort(ans.begin(),ans.end());
    return ans;
}
vct sieve(ll n){
    vct ans(n+1,-1);
    for(ll i=2;i<=n;i++){
        if(ans[i]==-1){
            for(ll j=i;j<=n;j+=i)if(ans[j]==-1)ans[j]=i;
        }
    }
    return ans;
}
ll n, k, m, l, r, x, y, z, ans=0;
ll t, t1, t2;
ll q;
ll i, j;
ll a, b, c;
ll mod = 1000000007;



void solve()
{
    cin>>n>>m;
    vpt v(n);
    F(i,n){
        cin>>t1>>t2;
        v[i]={t1,t2};
    }
    ll dp[n+1][m+1];
    memset(dp,0,sizeof(dp));

    for(i=1;i<=n;i++){
        pr cr=v[i-1];
        ll wt=cr.first;
        ll vl=cr.second;
        for(j=1;j<=m;j++){
            if((j-wt)<0)dp[i][j]=dp[i-1][j];
            else{
                dp[i][j]=max(dp[i-1][j],vl+dp[i-1][j-wt]);
            }
        }
    }
    prn(dp[n][m]);
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll t = 1;
    // cin >> t;
    // stress();
    while (t--)
        solve();
    return 0;
}

Measured memory_bytes: 82428
n, x=gets.split.map(&:to_i)
a=gets.split.map(&:to_i)

tot=0
n.times do |i|
  tot+=[a[i]-x, 0].max
  a[i]=x if a[i]>x
end

b=Array.new(n-1)
(n-1).times{|i| b[i]=a[i+1]+a[i]}
(n-1).times do |i|
  r=[b[i]-x, 0].max
  tot+=r
  b[i+1]-=r if i+1<n-1
end

puts tot

Measured memory_bytes: 11916
#include <stdio.h>
#include <string.h>

int main () {
    char m [3][4];

    for (int i=0; i<3; i++){
        scanf("%s", m[i]);
    }
    for (int x=0; x<3; x++){
        printf("%c", m[x][x]);

    }

    return 0;
}


Measured memory_bytes: 128
// Created by Nikolay Budin

#ifdef DEBUG
#  define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
#define ff first
#define ss second
#define szof(x) ((int)x.size())
#ifndef LOCAL
#  define cerr __get_ce
#endif

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef unsigned long long ull;
int const INF = (int)1e9 + 1e3;
ll const INFL = (ll)1e18 + 1e6;
#ifdef LOCAL
	mt19937 tw(9450189);
#else
	mt19937 tw(chrono::high_resolution_clock::now().time_since_epoch().count());
#endif
uniform_int_distribution<ll> ll_distr;
ll rnd(ll a, ll b) { return ll_distr(tw) % (b - a + 1) + a; }


void solve() {
	int n, k;
	cin >> n >> k;
	vector<int> arr;
	for (int i = 0; i < n; ++i) {
		int num;
		cin >> num;
		arr.push_back(num);
	}
	set<int> have;
	for (int i = 0; i < k; ++i) {
		have.insert(arr[i]);
	}
	// auto tmp = arr;
	// sort(tmp.begin(), tmp.begin() + k);
	// for (int num : tmp) {
	// 	cerr << num << " ";
	// }
	// cerr << endl;
	bool not_changed_found = is_sorted(arr.begin(), arr.begin() + k);
	int ans = 1;
	int from = 0;
	for (int i = 1; i < k; ++i) {
		if (arr[i] < arr[i - 1]) {
			from = i;
		}
	}
	for (int i = 1; i + k <= n; ++i) {
		bool fl = false;
		if (arr[i - 1] != *have.begin()) {
			fl = true;
		}
		have.erase(arr[i - 1]);
		have.insert(arr[i + k - 1]);
		if (arr[i + k - 1] < arr[i + k - 2]) {
			from = i + k - 1;
		}
		if (from <= i) {
			if (!not_changed_found) {
				not_changed_found = true;
				++ans;
			}
		} else if (fl || arr[i + k - 1] != *--have.end()) {
			// cerr << i << endl;
			// auto tmp = arr;
			// sort(tmp.begin() + i, tmp.begin() + i + k);
			// for (int num : tmp) {
			// 	cerr << num << " ";
			// }
			// cerr << endl;
			++ans;
		}
	}
	cout << ans << "\n";
}


int main() {
#ifdef LOCAL
	auto start_time = clock();
	cerr << setprecision(3) << fixed;
#endif
	cout << setprecision(15) << fixed;
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	int test_count = 1;
	// cin >> test_count;
	for (int test = 1; test <= test_count; ++test) {
		solve();
	}
	
#ifdef LOCAL
	auto end_time = clock();
	cerr << "Execution time: " << (end_time - start_time) * (int)1e3 / CLOCKS_PER_SEC << " ms\n";
#endif
}


Measured memory_bytes: 10484
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<string>
using namespace std;
const int NIL = -1;
const int MAXN = 1000 + 4;

struct Node
{
    int parent, left, right;
};

Node T[MAXN];
int H[MAXN], D[MAXN];

int set_Hight ( int u )
{
    int h1 = 0, h2 = 0;
    if ( T[u].left != NIL ) h1 = set_Hight ( T[u].left ) + 1;
    if ( T[u].right != NIL ) h2 = set_Hight ( T[u].right ) + 1;

    return H[u] = max ( h1, h2 );
}

int set_Brother ( int u )
{
    if ( T[u].parent == NIL ) return NIL;
    if ( T[T[u].parent].left != u && T[T[u].parent].left != NIL )
        return T[T[u].parent].left;
    if ( T[T[u].parent].right != u && T[T[u].parent].right != NIL )
        return T[T[u].parent].right;
    return NIL;
}

void set_Depth ( int u, int p )
{
    D[u] = p;
    if ( u == NIL ) return;
    if ( T[u].left != NIL ) set_Depth ( T[u].left, p + 1 );
    if ( T[u].right != NIL ) set_Depth ( T[u].right, p + 1 );
}

void print ( int u )
{
    int deg = 0;
    if ( T[u].left != NIL ) deg++;
    if ( T[u].right != NIL ) deg++;
    printf ( "node %d: ", u );
    printf ( "parent = %d, ", T[u].parent );
    printf ( "sibling = %d, ",  set_Brother(u) );
    printf ( "degree = %d, ", deg );
    printf ( "depth = %d, ", D[u] );
    printf ( "height = %d, ", H[u] );
    if ( T[u].parent == NIL ) {
        printf ( "root\n" );
    } else if ( T[u].left == NIL && T[u].right == NIL ) {
        printf ( "leaf\n" );
    } else {
        printf ( "internal node\n" );
    }

}


int main()
{

    int N, l, r, n, root = 0;
    cin>>N;
    memset ( H, 0, sizeof(H) );
    memset ( D, 0, sizeof(D) );
    for(int i = 0; i < N; i++){
        T[i].left = NIL;
        T[i].right = NIL;
        T[i].parent = NIL;
    }

    for ( int i = 0; i < N; i++ ) {
        cin>>n>>l>>r;
        T[n].left = l;
        T[n].right = r;

        if ( l != NIL ) T[l].parent = n;
        if ( r != NIL ) T[r].parent = n;
    }

    for ( int i = 0; i < N; i++ ) if ( T[i].parent == NIL )
        root = i;

    set_Depth ( root, 0 );
    set_Hight ( root );

    for ( int i = 0; i < N; i++ ) print (i);

    return 0;
}



Measured memory_bytes: 3232
S = input()
K = int(input())

N = len(S)

m= 1
for m in range(1, N):
    if S[m] != S[m-1]:break
    else: m += 1

def calc(s):
    ans = 0
    pre = s[0]
    for ss in s[1:]:
        if ss == pre:
            ans += 1
            pre = '0'
        else: pre = ss
    return ans

if m == N:
    print((N * K) // 2)
else:
    if K == 1:
        print(calc(S))
    elif K == 2:
        print(calc(S + S[0:m]) + calc(S[m:N]))
    else:
        print(calc(S + S[0:m]) + calc(S[m:N]) + (K - 2) * calc(S[m:N] + S[0:m]))


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

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

    vector<int> a(n);
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    sort(a.begin(),a.end());
    if(a[0] != (a[n-1] + 1) / 2){ cout << "Impossible" << endl; return 0; }

    int current = 0;
    for(int i=a[0]; i<=a[n-1]; i++){
        int count = 0;
        while(a[current] == i){
            count += 1;
            current += 1;
        }

        if(i == a[0]){
            if(a[n-1] % 2 == 0 && count != 1){ cout << "Impossible" << endl; return 0; }
            if(a[n-1] % 2 == 1 && count != 2){ cout << "Impossible" << endl; return 0; }
        }
        else{
            if(count < 2){ cout << "Impossible" << endl; return 0; }
        }
    }
    cout << "Possible" << endl;
    return 0;
}

Measured memory_bytes: 3544
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()
#define pb push_back

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;
}
constexpr int mod = 1e9+7;
constexpr int inf = 3e18;

int N,K;
int A[1005];
signed main(){
	cin>>N>>K;
	rep(i,N)cin>>A[i];
	sort(A,A+N);
	int ans=0;
	rep(i,K)ans+=A[i];
	cout<<ans<<endl;
}


Measured memory_bytes: 3636
import numpy as np
N = int(input())
XY = np.array([list(map(int,input().split())) for _ in [0]*N])
th = np.arctan2(XY[:,1],XY[:,0])
XY = XY[th.argsort()]
ans = 0
n = np.linalg.norm
Sxy = np.vstack((np.zeros(2),np.cumsum(XY,axis=0)))
for i in range(N):
    for j in range(i+1,i+N+1):
        r = n(Sxy[min(j,N)]-Sxy[i] + Sxy[max(0,j-N)])
        ans = max(ans,r)
print(ans)

Measured memory_bytes: 14448
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define revrep(i, s) for (int i = s-1; i > 0; i--)
#define revrrep(i, s) for (int i = s-1; i >= 0; i--)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

int main()
{
    int A, B, C, D; cin >> A >> B >> C >> D;
    if (A*B > C*D) cout << A*B << endl;
    else cout << C*D << endl;
}

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

using namespace std;

int main()
{
	int H, W;
	cin >> H >> W;

	vector<string> C(H);

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

	for (int i = 0; i < H; i++)
	{
		cout << C[i] << endl << C[i] << endl;
	}

	return 0;
}


Measured memory_bytes: 256
h500 = int(input())
h100 = int(input())
h050 = int(input())
goal = int(input())
ans = 0
i500 = 0
while i500 <= h500:
  i100 = 0
  while i100 <= h100:
    if 0 <= (goal - 500 * i500 - 100 * i100) // 50 <= h050:
      ans += 1
      #print(i500,i100,(goal-500*i500-100*i100)//50)
    i100 += 1
  i500 += 1
print(ans)

Measured memory_bytes: 3064
n, a, b = map(int, raw_input().split())
s = raw_input()

passed = 0
overseas = 0

for i, c in enumerate(s):
    if c == 'a':
        if passed < (a+b):
            passed += 1
            print 'Yes'
        else:
            print 'No'
    elif c == 'b':
        if passed < (a+b) and overseas < b:
            passed += 1
            overseas += 1
            print 'Yes'
        else:
            print 'No'
    else:
        print 'No'

Measured memory_bytes: 3076