akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
  #define endl "\n"
  #define ll long long int
  #define vi vector<int>
  #define vll vector<ll>
  #define vvi vector < vi >
  #define pii pair<int,int>
  #define pll pair<long long, long long>
  #define mod 1000000007
  #define inf 1000000000000000001;
  #define all(c) c.begin(),c.end()
  #define mp(x,y) make_pair(x,y)
  #define mem(a,val) memset(a,val,sizeof(a))
  #define pb push_back
  #define f first
  #define se second
  
  using namespace std;
  int main()
  {
    std::ios::sync_with_stdio(false);
    ll n=0,m=0,k=0,x=0,t1=0,t2=0,t3=0,f=0,sum=0,count=0;

    cin>>n;
    ll arr[n+1],dp[n+1];
    arr[0]=inf; dp[0]=0;

    for (ll i = 1; i <= n; ++i){
      cin>>arr[i];
    }
    dp[1]=0;

    for (ll i = 2; i <= n; ++i)
    {
      dp[i]=min(abs(arr[i]-arr[i-1])+dp[i-1],abs(arr[i]-arr[i-2])+dp[i-2]);
    }

    cout<<dp[n]<<endl;

    return 0;
  }

Measured memory_bytes: 5008
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <utility>
#include <map>
#include <climits>
#include <vector>
#include <set>
#include <string>
#include <numeric>

#define FAST_IO ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
//#define int long long
using namespace std;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<pair<int, int>> vii;
const int N = 2 * (1e5 + 1);
const int INF = 1e9 + 5;
const long long MOD = 1e9 + 7;

int32_t main() {
    FAST_IO;
    string s;
    cin >> s;
    int n = s.length();
    int l, r;
    for (l = 0; l < n; l++) if (s[l] == 'A') break;
    for (r = n - 1; r >= 0; r--) if (s[r] == 'Z') break;
    cout << r - l + 1;
    return 0;
}


Measured memory_bytes: 720
import collections


N = int(input())
S = [input() for _ in range(N)]
c = collections.Counter(S)
values, counts = zip(*c.most_common())
ans = []
if len(values) == 1:
    ans.append(values[0])
else:
    for i in range(N):
        if counts[i] == counts[0]:
            ans.append(values[i])
        else:
            break
ans.sort()
for i in range(len(ans)):
    print(ans[i])

Measured memory_bytes: 59504
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
double dist(double x, double y){
  return sqrt(x * x + y * y);
}

int main(){
  int N;
  int CASE = 1;
  while(cin>>N && N){
    printf("Case %d: ", CASE++);
    double x[14][2], y[14][2];
    double d[14];
    REP(i, N){
      REP(j, 2) cin>>x[i][j]>>y[i][j];
      d[i] = dist(x[i][0] - x[i][1] , y[i][0] - y[i][1]);
    }
    double dp[1<<14][14][2];
    REP(i, 1<<N)REP(j, N)REP(k, 2) dp[i][j][k] = INF;
    REP(i, N)REP(k, 2) dp[1<<i][i][k] = d[i];
    REP(S, 1<<N){
      REP(from, 2 * N){
        int f_i = from / 2;
        int f_j = from % 2;
        if(!(S & 1 << f_i)){
          from++;
          continue;
        }
        REP(to, 2 * N){
          int t_i = to / 2;
          int t_j = to % 2;
          if(S & 1<<t_i){
            to++;
            continue;
          }
          dp[S | (1<<t_i)][t_i][t_j] = min(dp[S | (1<<t_i)][t_i][t_j],
              dp[S][f_i][f_j] + dist(x[f_i][f_j] - x[t_i][(t_j + 1) % 2], y[f_i][f_j] - y[t_i][(t_j + 1) % 2]) + d[t_i]);
        }
      }
    }
    double ans = 1e16;
    REP(i, N)REP(j, 2) ans = min(ans, dp[(1<<N) - 1][i][j]);
    
    printf("%.5f\n", ans);
  }
  return 0;
}

Measured memory_bytes: 4832
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=n-1;i>=(0);i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define eall(v) unique(all(v), v.end())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;

int main() {
	string s; cin >> s;
	rep(i, 2)rep(j, 2)rep(k, 2) {
		int sum = s[0] - '0';
		if(i == 0) sum += s[1] - '0';
		else sum -= s[1] - '0';
		if(j == 0) sum += s[2] - '0';
		else sum -= s[2] - '0';
		if(k == 0) sum += s[3] - '0';
		else sum -= s[3] - '0';
		if(sum == 7) {
			// printf("%d %d %d\n", i, j, k);
			string ans{s[0]};
			// cout << ans << endl;

			if(i == 0) ans += "+";
			else ans += "-";
			ans += s[1];

			if(j == 0) ans += "+";
			else ans += "-";
			ans += s[2];

			if(k == 0) ans += "+";
			else ans += "-";
			ans += s[3];

			cout << ans + "=7" << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>

using Bool = bool;
using Int = long long int;
template <class T>
using Vector = std::vector<T>;
template <class T>
using Stack = std::stack<T>;

Bool solve() {
    Vector<Vector<Int>> graph;
    Vector<Int> deg, dist;

    Stack<Int> stk;
    while (true) {
        Int a;
        std::cin >> a;

        if (a == 0) break;
        if (a > 0) {
            Int v = graph.size();
            graph.push_back(Vector<Int>());
            deg.push_back(a);

            if (stk.empty()) {
                dist.push_back(0);
            } else {
                Int u = stk.top();
                dist.push_back(dist[u] + 1);
                graph[u].push_back(v);
                graph[v].push_back(u);
                --deg[u], --deg[v];
            }
            stk.push(v);
        } else {
            Int v = stk.top();
            Int u;
            for (u = 0; u < v; ++u) {
                if (deg[u] > 0 && dist[u] - dist[v] == a) break;
            }
            graph[u].push_back(v);
            graph[v].push_back(u);
            --deg[u], --deg[v];
        }

        while (!stk.empty() && deg[stk.top()] == 0) stk.pop();
    }

    for (Int v = 0; v < graph.size(); ++v) {
        std::cout << v + 1;
        std::sort(graph[v].begin(), graph[v].end());
        for (auto u : graph[v]) {
            std::cout << ' ' << u + 1;
        }
        std::cout << std::endl;
    }
    return true;
}

int main() {
    Int n;
    std::cin >> n;
    for (Int i = 0; i < n; ++i) solve();
    return 0;
}



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

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

  set<int> s;

  for(int i = 0; i < N; i++){
    int x; cin >> x;

    if(s.count(x)) s.erase(x); // xと同じ要素の数を数えて、あればsetから消す
    else s.insert(x); // sに新しくxを挿入
  }
  cout << s.size() << endl; // sの要素数を出力

}


Measured memory_bytes: 8252
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long INF = 1000000000000;
    int n, W;
    cin>>n>>W;
    long long weights[n];
    int values[n];
    int sum = 10;
    for(int i=0;i<n;i++){
        cin>>weights[i]>>values[i];
        sum += values[i];
    }
    long long dp[n+1][sum];
    for(int i=0;i<=n;i++){
        dp[i][0] = 0;
    }
    for(int i=1;i<sum;i++){
        dp[0][i] = INF;
    }
    for(int i=1;i<=n;i++){
        for(int v=1;v<sum;v++){
            if((v < values[i-1]) || (dp[i-1][v-values[i-1]] + weights[i-1] > W)){
                dp[i][v] = dp[i-1][v];
            }else{
                long long include = dp[i-1][v-values[i-1]];
                long long exclude = dp[i-1][v];
                dp[i][v] = min(include + weights[i-1], exclude);
            }
        }
    }
    int ans = 0;
    for(int i=0;i<sum;i++){
        if(dp[n][i] < INF){
            ans = i;
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 79104
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Scanner;
import java.util.Set;


public class Main {


    static void solve() {
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        int c = scan.nextInt();
        int k = scan.nextInt();

        int i = 0;
        int cnt = 0;
        long sum = 0;
        while(i<a && cnt < k ) {
            sum++;
            i++;
            cnt++;
        }
        i=0;
        while(i<b && cnt < k) {
            i++;
            cnt++;
        }

        i=0;
        while(i<c && cnt < k) {
            sum--;
            i++;
            cnt++;
        }
        System.out.println(sum);

//        for (int i = 0; i < t; i++) {
//            int n = scan.nextInt();
//            int k = scan.nextInt();
//            scase(n,k);
////            System.out.println(res);
////            solveCase(i, x,y,s);
//        }
    }



//    static class Pair {
//        int a;
//        int b;
//    }




//    static void solveCase(int t, int x, String s) {
//
//    }



    static void scase(int n, int k) {

    }



    public static void main(String[] args) {

        solve();

        //        Main m = new Main();
        //        Scanner scan = new Scanner(System.in);

        //        long n = scan.nextLong();
        //        long r = scan.nextLong();
        //        List<Long> list = new ArrayList<>();
        ////        int[] arr = new int[n];
        //        for (long i=0;i<n;i++){
        //            list.add(scan.nextLong());
        //        }
//            System.out.println(ch);
        //        solve(n, arr);
        //        scan.close();
    }


//
//    class Counter extends HashMap<Integer, Integer> {
//        public int get(int k) {
//            return containsKey(k) ? super.get(k) : 0;
//        }
//
//        public void add(int k, int v) {
//            put(k, get(k) + v);
//        }
//    }


//    static class Node {
//        int val;
//        Node next;
//        Node random;
//
//        public Node(int val) {
//            this.val = val;
//            this.next = null;
//            this.random = null;
//        }
//    }

//    static class Node {
//        int key;
//        int data;
//        Node next;
//        Node prev;
//
//        Node(int key, int data) {
//            this.key = key;
//            this.data = data;
//        }
//    }

    static class TreeNode {
        int val;
        TreeNode left;
        TreeNode right;

        TreeNode(int x) {
            val = x;
        }
    }
}


Measured memory_bytes: 27132
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ll N, A, B;
  cin >> N >> A >> B;
  if(A == 0) {
    cout << 0 << endl;
  }
  else{
    ll s = 0, t = 0;
    t = N / (A + B); //t = 1
    if((N - (t * (A + B))) >= A) {
      s = (t * A) + A;
    }
    
    else {
      s = (t * A) + (N - (t * (A + B)));
    }
    cout << s << endl;
  }
}

Measured memory_bytes: 256
///int ->(-2147483648<->2147483647)
///unsigned int(0<->4294967295)
///long long int (-9,223,372,036,854,775,808 to 9,223,372,036,854,775,807)
///unsigned long long int (0 to 18,446,744,073,709,551,615)
//#include<bits/stdc++.h>
#include<iostream>
#include<vector>
#include<queue>
#include<stdio.h>
#include<map>
#include<math.h>
#include<algorithm>
#include<string>
#include<utility>
#include<stack>
#include<cstring>
#include<iterator>
#include<unordered_map>
#include<unordered_set>
#include<set>
#include<iomanip> ///setprecision
#include<cmath>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

#define FIO ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define OPEN freopen("in.txt","r",stdin)
#define OUT freopen("out.txt","r",stdin)
#define INF 1000000000
#define ll long long
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pcc pair<char,char>
#define pdd pair<double,double>
#define vi vector<int>
#define vll vector<long long>
#define vc vector<char>
#define vd vector<double>
#define sci(value) scanf("%d%*c",&value)
#define scl(value) scanf("%lld%*c",&value)
#define pi  (2*acos(0))
#define pb push_back
#define valid(value123,value234,limitrow,limitcol) value123>=0&&value123<limitrow&&value234>=0&&value234<limitcol
//int fx[]= {0,0,1,-1,-1,1,-1,1};//kings move
//int fy[]= {1,-1,0,0,-1,1,1,-1};//kings move
//int fx[]={-2,-2,-1,-1, 1,1, 2,2};  // Knights Move
//int fy[]={-1, 1,-2, 2,-2,2,-1,1}; // Knights Move
//ll powFunction(ll a,ll b){if(b==0)return 1;ll re=powFunction(a,b/2);re=(re*re);if(b&1)re=(re*a);return re;}
///ll digitSum(ll a){ll ans=0;while(a){ans+=(a%10);a/=10;}return ans;}

#define MX 1005
#define mod 1000000007
ll path[MX][MX];
string str[MX];
ll h,w;
bool vis[MX][MX];
ll findpath(int i,int j)
{
    //printf("%d %d\n",i,j);
    if(i == h-1 && j == w-1)
        return 1;
    if(vis[i][j])
        return path[i][j];
    vis[i][j]=1;

    ll x1=0,x2=0;
    if(i+1<h && str[i+1][j]=='.')
    {
        x1 = findpath(i+1,j);
    }
    if(j+1< w && str[i][j+1] == '.')
    {
        x2 = findpath(i,j+1);
    }
    return path[i][j]=(x1+x2)%mod;
}
int main()
{
    scl(h),scl(w);
    for(int i=0;i<h;i++)
    {
        cin>>str[i];
    }

    cout<<findpath(0,0)<<endl;
    /*
    for(int i=0;i<h;i++)
    {
        for(int j=0;j<w;j++)
        {
            printf("%lld ",path[i][j]);
        }
        printf("\n");
    }
    */
}



Measured memory_bytes: 10240
import math
def lazy_update(s, e, value):
    a = [(1, l+s, l+e, 1)]
    ap = a.append
    while a:
        k, s, e, depth = a.pop()
        l_end, r_end = k << (rank-depth), (k+1) << (rank-depth)
        mid = (l_end + r_end) // 2

        if s == l_end and e == r_end:
            lazy[k] = value
        else:
            child = k<<1
            if lazy[k] is not None:
                lazy[child] = lazy[k]
                lazy[child+1] = lazy[k]
                lazy[k] = None
            if s < mid:
                ap((child, s, (mid, e)[e<mid], depth+1))
            if e > mid:
                ap((child+1, (mid, s)[s>mid], e, depth+1))

def get_value(i):
    i += l
    for j in range(rank, -1, -1):
        n = lazy[i>>j]
        if n is not None:
            return n
    return tree[i]

n, q = map(int,input().split())
l = 1 << math.ceil(math.log2(n))
tree = [2**31-1]*(2*l)
lazy = [None]*(2*l)
rank = int(math.log2(len(tree)))
ans = []
ap = ans.append

for _ in [None]*q:
    query = list(map(int, input().split()))
    if query[0] == 0:
        lazy_update(query[1], query[2]+1, query[3])
    else:
        ap(get_value(query[1]))

print("\n".join((str(n) for n in ans)))

Measured memory_bytes: 19800
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define mp make_pair
#define fi first
#define sc second
ll n,q,s,t,a[200020],b[200020];
int main(){
    scanf("%lld%lld%lld%lld",&n,&q,&s,&t);

    REP(i,n + 1)
        scanf("%lld",a + i);

    ll tj = 0;
    REP(i,n){
        b[i] = a[i + 1] - a[i];
        tj -= (b[i] > 0) ? s * b[i] : t * b[i];
    }

    REP(i,q){
        ll l,r,x;
        scanf("%lld%lld%lld",&l,&r,&x);
        tj += (b[l - 1] > 0) ? s * b[l - 1] : t * b[l - 1];
        if(r < n)
            tj += (b[r] > 0) ? s * b[r] : t * b[r];
        b[l - 1] += x;
        b[r] -= x;
        tj -= (b[l - 1] > 0) ? s * b[l - 1] : t * b[l - 1];
        if(r < n)
            tj -= (b[r] > 0) ? s * b[r] : t * b[r];
        //REP(i,n)
            //printf("%lld ",b[i]);
        //printf("\n");
        printf("%lld\n",tj);
    }
    return 0;
}

Measured memory_bytes: 6332
#include <bits/stdc++.h>
#define endl '\n'
#define int long long
#define lint long long
#define pii pair<int, int>
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define FORR(i, a, b) for(int i = (a); i > (b); --i)
#define REP(i, n) FOR(i, 0, n)
#define SZ(v) ((int)v.size())
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define FINF(a) memset(a, 0x3f, sizeof(a))
#define POW(n) (1LL << (n))
#define POPCNT(n) (__builtin_popcount(n))
#define IN(i, a, b) ((a) <= (i) && (i) <= (b))
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a > b) { a = b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a < b) { a = b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(begin(a), end(a)); }
template <typename T> inline void REV(T& a) { reverse(begin(a), end(a)); }
template <typename T> inline void UNI(T& a) { sort(a.begin(), a.end()); a.erase(unique(a.begin(), a.end()), a.end()); }
template <typename S, typename T> inline T LB(S& v, T a) { return *lower_bound(begin(v), end(v), a); }
template <typename S, typename T> inline int LBP(S& v, T a) { return lower_bound(begin(v), end(v), a) - begin(v); }
template <typename S, typename T> inline T UB(S& v, T a) { return *upper_bound(begin(v), end(v), a); }
template <typename S, typename T> inline int UBP(S& v, T a) { return upper_bound(begin(v), end(v), a) - begin(v); }
template <typename S, typename T> ostream& operator << (ostream& os, const pair<S, T>& p) { os << p.first << " " << p.second; return os; }
template <typename S, typename T> istream& operator >> (istream& is, pair<S, T>& p) { is >> p.first >> p.second; return is; }
template <typename T> ostream& operator << (ostream& os, const vector<T>& v) { for (int i = 0; i < v.size(); ++i) { if (i) os << " "; os << v[i]; } return os; }
template <typename T> istream& operator >> (istream& is, vector<T>& v) { for(T& in : v) is >> in; return is; }
template <typename T = int> vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }
template <typename T, typename V> typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) { t = v; }
template <typename T, typename V> typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) { for(auto &e : t) fill_v(e, v); }
const lint MOD = 1000000007;
const lint INF = 0x3f3f3f3f3f3f3f3f;
const double PI = 3.14159265358979323846;
const double EPS = 1e-10;

int N;
int a[200010];

void _main() {
    cin >> N;
    REP (i, N) cin >> a[i];
    int x = 1;
    REP (i, N) {
        if (a[i] == x) {
            x++;
        }
    }
    if (x == 1) cout << -1 << endl;
    else cout << N - (x - 1) << endl;
}

signed main(signed argc, char **argv) {
    if (argc > 1) {
        if (strchr(argv[1], 'i')) freopen("input.txt", "r", stdin);
        if (strchr(argv[1], 'o')) freopen("output.txt", "w", stdout);
    }
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}

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

int main(){
    int MOD = 1000000007;
    int H,W,K,i,j,k,ans;
    cin >> H >> W >> K;
    long long int A[H+1][W];
    int p[7]={1,2,3,5,8,13,21};
    int a[max(1,W-1)];//iとi+1を結ぶ線を経路とするときのその段の他の線の引き方
    int b[W];//i番目の線を直下するときのその段の線の引き方

    if(W==1){
        a[0] = 1;
        b[0] = 1;
    }else if(W==2){
        a[0] = 1;
        b[0] = 1; b[1] = 1;
    }else{
        a[0]=p[W-3];
        a[W-2] = p[W-3];
        for(j=1;j<W-2;j++) a[j]=p[W-j-3]*p[j-1];
        b[0]=p[W-2];
        b[W-1]=p[W-2];
        for(j=1;j<W-1;j++) b[j]=p[W-j-2]*p[j-1];
    }

    for(j=0;j<W;j++) A[H][j]=0;
    A[H][K-1]=1;
    for(i=H-1;i>=0;i--){
        for(j=0;j<W;j++){
            A[i][j]=0;
            if(j>=1){
                A[i][j] += (A[i+1][j-1]*a[j-1])%MOD;
                A[i][j] %= MOD;
            }
            A[i][j] += (A[i+1][j] * b[j])%MOD;
            A[i][j] %= MOD;
            if(j<W-1) A[i][j] += (A[i+1][j+1] * a[j])%MOD;
            A[i][j]%=MOD;
        }
    }
    cout << A[0][0] << endl;
    return 0;
}

Measured memory_bytes: 256
S = input()
c = 0
for i in range(len(S)-1,-1,-1):
    S = S[0:i]
    if len(S) % 2 == 0:
        m = int(len(S)/2)
        if S[0:m] == S[m:len(S)]:
            print(len(S))
            break
    c+=1


Measured memory_bytes: 2940
#include <iostream>
#include <stdio.h>
#include <string.h>
#define MAX_N 300005
#define MOD 998244353
#define int long long

using namespace std;

int n,a,b,K,ans=0;
int f[MAX_N];
int inf[MAX_N];

void exgcd(int a,int b,int &x,int &y)
{
	if(b==0)
	{
		x=1,y=0;
		return;
	}
	exgcd(b,a%b,y,x);
	y-=(a/b)*x;
}

int inv(int a)
{
	int x,y;
	exgcd(a,MOD,x,y);
	return (x%MOD+MOD)%MOD;
}

int c(int n,int m)
{
	return f[n]*inf[m]%MOD*inf[n-m]%MOD;
}

signed main()
{
	scanf("%lld%lld%lld%lld",&n,&a,&b,&K);
	f[0]=1;
	for(int i=1;i<=n;i++) f[i]=f[i-1]*i%MOD;
	inf[n]=inv(f[n]),inf[0]=1;
	for(int i=n-1;i>=1;i--) inf[i]=inf[i+1]*(i+1)%MOD;
	for(int i=0;i<=n;i++)
	{
		if(!((K-a*i)%b))
		{
			int j=(K-a*i)/b;
			if(0<=j && j<=n) ans=(ans+c(n,i)*c(n,j)%MOD)%MOD;
		}
	}
	printf("%lld\n",ans);
}


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

int main(){
  int n,cnt=0,i; cin >>n;
  for(i=1;i<=n;i++){
    cnt+=i;
    if(cnt>=n) break;
  }
  for(int j=1;j<=n;j++){
    if(j==cnt-n) continue;
    cout << j << endl;
    if(i==j) break;
  }
  return 0;
}

Measured memory_bytes: 3644
import sys

n, q = map(int, input().split())

queue = list(map(lambda x: {"name": x[0], "time": int(x[1])}, [x.split() for x in sys.stdin]))
elapsed = 0
i = 0

while len(queue) > 0:
    #p = queue[0]
    p = queue[i]
    t = min(q, p["time"])
    p["time"] -= t
    elapsed += t

    #queue = queue[1:]
    if p["time"] > 0:
        #queue.append(p)
        i = (i + 1) % len(queue)
    else:
        print(p["name"], elapsed)
        del queue[i]
        i = i if len(queue) > i else 0



Measured memory_bytes: 28912
#include <iostream>
#include <cmath>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <list>
#include <cctype>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)

int main(){
    int n,x,now=0,ans=1;
    cin >> n >> x;
    int l[n];
    rep(i,n){
        cin >> l[i];
        now += l[i];
        if(now <= x) ans++;
        else break;
    }
    cout << ans << endl;
}

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

int main() {
	ios_base::sync_with_stdio(false);
	int n, ac = 0, wa = 0, tle = 0, re = 0;
	cin>>n;
	while(n--){
		string s;
		cin>>s;
		if(!s.compare("AC")) ac++;
		else if(!s.compare("WA")) wa++;
		else if(!s.compare("TLE")) tle++;
		else re++;
	}
	cout<<"AC x "<<ac<<'\n';
	cout<<"WA x "<<wa<<'\n';
	cout<<"TLE x "<<tle<<'\n';
	cout<<"RE x "<<re<<'\n';
	return 0;
}
//ios_base::sync_with_stdio(false);


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

int main() {
  char c;
  cin >> c;
 
  if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o')
    cout << "vowel" << endl;
  else
    cout << "consonant" << endl;
}


Measured memory_bytes: 256
#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
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair <ld, ld> pld;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;
typedef vector <ld> vld;
typedef vector <ll> vll;
typedef vector <pll> vpll;
typedef set <ld> sld;
typedef set <ll> sll;
typedef set <pll> spll;
typedef char ch;
typedef string str;
typedef tree <int,
            null_type,
            less<int>,
            rb_tree_tag,
            tree_order_statistics_node_update> super_set;
const ll DIM = 1e3+7;
const ll MODULO = 1e9+7;
const ld INF = 1e9;
const ld eps = 1e-9;
const ld pi = acos(-1.0);
const ld e = pow(1.0 + 1.0/INF, INF);
const ld gr = (1.0+sqrt(5.0))/2.0;
const ld alpha0 = 2*cos(pi/8)/(1+cos(pi/8));
const ld beta0 = 2*sin(pi/8)/(1+cos(pi/8));
ll n,m,a[DIM][DIM],F[DIM][DIM];
ch x;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //freopen("paintbarn.in", "r", stdin);
    //freopen("paintbarn.out", "w", stdout);

    cin >> n >> m;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            cin >> x;
            if (x == '#')
                a[i][j] = 1;
        }
    }
    F[1][1] = 1;
    for (int i = 2; i <= n; i++) {
        F[1][i] += F[1][i-1];
        if (a[1][i] == 1)
            F[1][i] = 0;
    }
    for (int i = 2; i <= m; i++) {
        F[i][1] += F[i-1][1];
        if (a[i][1] == 1)
            F[i][1] = 0;
    }
    for (int i = 2; i <= n; i++) {
        for (int j = 2; j <= m; j++) {
            F[i][j] += (F[i][j-1] + F[i-1][j])%MODULO;
            if (a[i][j] == 1)
                F[i][j] = 0;
        }
    }
    cout << F[n][m] << endl;
    return 0;
}


Measured memory_bytes: 16000
#include <stdio.h>
#include <math.h>
int main(){
    long long int a,b,k;
    scanf("%lld %lld",&a,&b);
    k=(a+b)/2;
    if ((abs(a-k))==(abs(b-k))) {
        printf("%lld\n",k);
    }
    else
        printf("IMPOSSIBLE\n");
    
return 0;

}


Measured memory_bytes: 1712
#include <iostream>
using namespace std;
int n;
int a;
string s;
int main(void){
    cin>>n>>s;
    for(int i=0;i<s.size();i++){
        a=s[i]+n;
        if(a>90)a-=26;
        cout<<char(a);
    }
    cout<<endl;
}


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

using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define rep3(i, n) for (int i = 1; i < (int)(n+1); i++)
#define rep4(i, s, n) for (int i = (s); i < (int)(n+1); i++)
#define repr(i,n) for (int i = (n-1); i>=0;i--)
#define repr3(i,n) for(int i = (n);i>0;i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
const ll INF = 1001001000100010;
const ld PI = 3.14159265358979323846;


int main() {
int N;
int check_num[30004];
string S;
cin>>N>>S;
string key="";
bool check[11][11][11];
rep(i,11){
    rep(j,11){
        rep(k,11){
            check[i][j][k]=false;
        }
    }
}
rep(i,N){
    rep(j,10){
        rep(k,10){
            if(check[j][k][10]==true){
                check[j][k][S[i]-'0']=true;

            }
            
        }
    }
    rep(j,10){
        if(check[j][10][10]==true){
            check[j][S[i]-'0'][10]=true;
        }
    }
    check[S[i]-'0'][10][10]=true;
}
int count=0;
rep(i,10){
    rep(j,10){
        rep(k,10){
            if(check[i][j][k]==true){
                count++;
            }
        }
    }
}
cout<<count<<endl;
return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue> 
using namespace std;
#define INF 0x3f3f3f3f
char a[15],b[15],c[15];
int n,m,k;
int main()
{
	while(~scanf("%d%d%d",&n,&m,&k))
	{
		int d=__gcd(n,m);
		
		if(k%d==0) cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#sになるのがちょうどk個
n,k,s=map(int,input().split())
ans=[0]*n
if s==10**9:
    ans = [s]*k +[10**9-1]*(n-k)
else:
    ans = [s]*k + [10**9]*(n-k)
print(*ans, sep=' ')

Measured memory_bytes: 6764
<?php
fscanf(STDIN, "%d %d", $n, $k);
$array = array();
$array = explode(' ', trim(fgets(STDIN)));  # explodeで行全部を配列に取り込む。

$narray = array();
$len = strlen($n);   # Nの桁数を数える。
for($i = 0; $i < $len; $i++){
    $narray[$i] = substr($n, $i, 1);
}
$j = 0;
while($j < $k){
    if(in_array($array[$j], $narray)){  # 嫌いな数字がNにあるかを調べる。
        $n++;
        $narray = array();
        $len = strlen($n);
        for($i = 0; $i < $len; $i++){
            $narray[$i] = substr($n, $i, 1);
        }
        $j = 0;
    }else{
        $j++;
    }
}
print $n;

Measured memory_bytes: 4984
fn solve() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let n: usize = sc.read();
    let m: usize = sc.read();
    let mut xs: Vec<i32> = sc.vec(m);
    xs.sort();
    if n == 1 {
        let mut sum: u64 = 0;
        for i in 0..m - 1 {
            let tmp = xs[i + 1] - xs[i];
            sum += tmp as u64;
        }
        println!("{}", sum);
        return ;
    }
    let n = n - 2;
    let mut ys: Vec<u64> = Vec::new();
    for i in 0..m - 1 {
        let tmp = xs[i + 1] - xs[i];
        ys.push(tmp as u64);
    }
    ys.sort_by(|x, y| y.cmp(x));

    let mut result = 0;
    for i in n+1..ys.len() {
        result += ys[i];
    }
    println!("{}", result);
}

fn main() {
    std::thread::Builder::new()
        .stack_size(64 * 1024 * 1024) // 64MB
        .spawn(|| solve())
        .unwrap()
        .join()
        .unwrap();
}

//snippet from kenkoooo
pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self.stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_line(&mut self) -> String {
        use std::io::Read;
        let buf = self.stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b'\n' || b == b'\r')
            .take_while(|&b| b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 10620
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  

#pragma warning(disable:4996)  
#pragma comment(linker, "/STACK:336777216")  
using namespace std;

#define mp make_pair  
#define Fi first  
#define Se second  
#define pb(x) push_back(x)  
#define szz(x) ((int)(x).size())  
#define rep(i, n) for(int i=0;i<n;i++)  
#define all(x) (x).begin(), (x).end()  
#define ldb ldouble  

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 15;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;

char in1[100050];
char in2[100050];
int sum1[100050];
int sum2[100050];
int main() {
	scanf("%s %s", in1 + 1, in2 + 1);
	int N = strlen(in1 + 1), M = strlen(in2 + 1), i;
	for (i = 1; i <= N; i++) sum1[i] = sum1[i - 1] + (in1[i] == 'A' ? 1 : -1);
	for (i = 1; i <= M; i++) sum2[i] = sum2[i - 1] + (in2[i] == 'A' ? 1 : -1);

	int Q, t1, t2, t3, t4;
	scanf("%d", &Q);
	while (Q--) {
		scanf("%d %d %d %d", &t1, &t2, &t3, &t4);
		int v1 = sum1[t2] - sum1[t1 - 1];
		int v2 = sum2[t4] - sum2[t3 - 1];
		if ((v1 - v2) % 3) printf("NO\n");
		else printf("YES\n");
	}
	return 0;
}

Measured memory_bytes: 1536
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner stdIn = new Scanner(System.in);
		String S = stdIn.nextLine();
		String T = stdIn.nextLine();
		
		char[] s = S.toCharArray();
		char[] t = T.toCharArray();
		
		int minCount = 1000;
		
		for(int i = 0; i <= s.length - t.length; i ++) {
			int counter = 0;
			for(int j = 0; j < t.length; j ++) {
				if(s[i + j] != t[j]) {
					counter ++;
				}
				if(minCount <= counter) {
					break;
				}
			}
			minCount = Math.min(minCount, counter);
		}
		
		System.out.println(minCount);
	}
}

Measured memory_bytes: 35948
#include<bits/stdc++.h>
#include<math.h>
#define ll long long int
#define ve vector<int>
#define vl vector<long long int>
#define all(a) a.begin(),a.end()
using namespace std;

int main(){
  ll n,x;
  cin>>n>>x;
  vl a(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  sort(all(a));
  ll use=0,A=0;
  for(int i=0;i<n-1;i++){
    if(x>=a[i]){
      A++;
      x-=a[i];
    }
  }
  if(a[n-1]==x) A++;
  cout<<A<<endl;
}

Measured memory_bytes: 256
S = input()

if S == '0000':
    print('NA')
else:
    if '01' <= S[0:2] <= '12' and (S[2:4] >= '13' or S[2:4] == '00'):
        print('MMYY')
    elif '01' <= S[2:4] <= '12' and S[0:2] >= '13' or S[0:2] == '00':
        print('YYMM')
    elif '01' <= S[0:2] <= '12' and '01' <= S[2:4] <= '12':
        print('AMBIGUOUS')
    else:
        print('NA')


Measured memory_bytes: 38384
//kunal_goyal
#include<bits/stdc++.h>
//#include"debug.h"

using namespace std;
#define int1(a) scanf("%d",&a)
#define int2(a,b) scanf("%d %d",&a,&b)
#define int3(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define int4(a,b,c,d) scanf("%d %d %d %d",&a,&b,&c,&d)
#define lint1(a) scanf("%lld",&a)
#define lint2(a,b) scanf("%lld %lld",&a,&b)
#define lint3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define lint4(a,b,c,d) scanf("%lld %lld %lld %lld",&a,&b,&c,&d)
#define lli long long int
#define pint(x) printf("%d",x)
#define all(x) x.begin(),x.end()
#define ps printf(" "); 
#define plint(x) printf("%lld",x)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define bg begin()
#define ed end()
#define Set(a, s) memset(a, s, sizeof (a))
#define mod 1000000007
#define tmod(k) if ((k) >= mod) k %= mod;
#define endl '\n'
#define nl printf("\n");
#define fore(i,n) for(int i=n; i>=0; i--)
#define fors(i,a,n) for(int i=a; i<n; i++)
#define fora(i,ele) for(auto i: ele)
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
typedef string st;
typedef vector<int> vi;
typedef vector<st> vs;
typedef pair<int,int> pii;
typedef vector<lli> vli;
template< class T > T gcd(T a, T b) { return (b != 0 ? gcd<T>(b, a%b) : a); }
template< class T > T lcm(T a, T b) { return (a / gcd<T>(a, b) * b); }
double tick(){static clock_t oldt,newt=clock();double diff=1.0*(newt-oldt)/CLOCKS_PER_SEC;oldt=newt;return diff;}
float roundoff(float val, float p){ return floor(val*pow(10.0,p)+0.5)/pow(10.0,p);}
const int INF = 0x3f3f3f3f;
#define pi 3.14159265

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

int main(void) {
    ios_base::sync_with_stdio(true);
    cin.tie(NULL);
    cout.tie(NULL);
	/*
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
	*/
    // cout<<"Execution time : "<<tick()<<"\n";
	int x,y;
	int2(x,y);
	if(x%y==0){
		cout<<-1;
	}
	else{
		cout<<x;
	}
    return 0;
}





Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k;
    scanf("%d%d",&n,&k);
    vector< int > v(n);
    for(int i=0;i<n;++i){
        scanf("%d",&v[i]);
    }
    sort(v.begin(),v.end(),greater< int >());
    int sum=0;
    for(int i=0;i<k;++i){
        sum+=v[i];
    }
    printf("%d\n",sum);
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
using namespace std;
int main() {
    long long int n, q, a, b, c;
    cin >> n >> q;
    vector<priority_queue<long long int>> v(n);
    for (int i = 0; i < q; i++) {
        cin >> a;
        if (a == 0) {
            cin >> b >> c;
            v[b].push(c);
        }
        else if (a == 1) {
            cin >> b;
            if (!v[b].empty())   cout << v[b].top() << endl;
        }
        else if (a == 2) {
            cin >> b;
            if (!v[b].empty())   v[b].pop();
        }
    }
}


Measured memory_bytes: 5056
n=int(input())
a=[int(x) for x in input().split()]
b=[int(x) for x in input().split()]
c=[int(x) for x in input().split()]
ans=b[a[0]-1]
for i in range(1,n):
    #print("ans: ", ans)
    #print("a[i]: ",a[i])
    ans+=b[a[i]-1]
    if a[i-1]+1 == a[i]:
        #print("a[i]: ",a[i])
        ans+=c[a[i]-2]
        #print("c: ",c[i-1])
print(ans)

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

const int MOD = 1000000007;
const int INF = 1e9;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n, i##_len=(n); i>=0; i--)
#define FOR(i,a,b) for(int i=(a), i##_len=(b); i<i##_len; ++i)

//最大公約数 
 ll gcd(ll a,ll b){
 if(b == 0) return a;
 return gcd(b,a%b);
 }

//最小公倍数
 ll lcm(ll a,ll b){
 ll g = gcd(a,b);
 return a / g * b; // Be careful not to overflow  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
} 




int main(){
string S, T;
cin >> S >> T;
int cnt = 0;
for(int i = 0; i < 3; i++) {
    if(S.at(i) == T.at(i)) cnt++;
}
print(cnt);

}


Measured memory_bytes: 256
#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 ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n,m;
  string s;
  cin >> n >> m >> s;
  string d = "";
  REP(i,m) d += "1";
  if(s.find(d)!=string::npos){
    cout << -1 << '\n';
    return 0;
  }
  reverse(ALL(s));
  int pos = 0;
  vector<int> path;
  while(true){
    for(int i=m; i>0; i--){
      if(pos+i>=n+1) continue;
      if(s[pos+i]=='1') continue;
      pos += i;
      path.emplace_back(i);
      //cout << i << " " << pos << '\n';
      break;
    }
    if(pos==n) break;
  }
  REPR(i,(int)path.size()-1) cout << path[i] << " ";
  
  return 0;
}



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

int main() {
		int N, K;
		cin >> N >> K;

		int result = 1;

		for(int i=0; i<N; i++) {
			if ((result * 2) < (result + K)) {
					result *= 2;
			} else {
					result += K;
			}
		}

		cout << result << endl;
		return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T> ostream& operator<<(ostream &os, vector<T> V) { os << "[ "; for(auto v : V) os << v << " "; return os << "]"; }
template<class T> ostream& operator<<(ostream &os, set<T> S){ os << "{ "; for(auto s:S) os<<s<<" ";return os<<"}"; }
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) { return os << "(" << P.first << "," << P.second << ")";}
template<class L, class R> ostream& operator<<(ostream &os, map<L,R> M) { os << "{ "; for(auto m:M) os<<"("<<m.first<<":"<<m.second<<") "; return os<<"}"; }
#ifdef LMAO
    #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){cerr << name << " : " << arg1 << endl;}
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){ const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | "; __f(comma+1, args...); }
#else
    #define trace(...) 42
#endif
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define endl "\n"
#define tcase int tt; cin>>tt; while(tt--)
#define tcase2 int tt; cin>>tt; for(int qq=1;qq<=tt;qq++)
#define all(x) x.begin(), x.end()
typedef long long int ll;
typedef  unsigned long long int ull;
typedef long double ld;
const int MAX = 1000010;
const int MOD2 = 998244353;
const int MOD = 1000000007; 
const int INF = 1e8;    
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
const ld EPS = 1e-7;
#define forn(i, n) for(int i = 0; i < (int)n; i++)
#define forne(i, a, b) for(int i = a; i <= b; i++)   
/*****************start************/
void solve()
{
    int l,r,d;
    cin>>l>>r>>d;
    cout<<(r/d)-((l-1)/d)<<endl;
}
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);cout<<fixed<<setprecision(25);cerr<<fixed<<setprecision(10);
    auto start = std::chrono::high_resolution_clock::now();
    // tcase{
        solve();
    // }
    auto stop = std::chrono::high_resolution_clock::now(); 
    auto duration = std::chrono::duration_cast<std::chrono::nanoseconds>(stop - start); 
    // cerr << "Time taken : " << ((long double)duration.count())/((long double) 1e9) <<"s "<< endl;     
    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};
// int d[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  int n,k;
  cin >> n >> k;
  vector<ll>p(n);
  rep(i,n)cin>>p[i];
  sort(p.begin(),p.end());
  if(p[n-1]<=0 && k&1){
    ll ans = 1;
    rep(i,k){
      ans*=p[n-1-i];
      ans%=MOD;
    }
    while(ans<0)ans+=MOD;
    cout << ans << endl;
    return 0;
  }
  ll ans = 1;
  ll nowp=n-1,nowm=0;
  ll cnt = 0;
  while(cnt<k){
    if(nowp>=1 && nowm<=n-2 && nowp-nowm>=1 && cnt+2<=k){
      ll resp=p[nowp]*p[nowp-1];
      ll resm=p[nowm]*p[nowm+1];
      if(resp>resm){
        cnt+=2;
        nowp-=2;
        resp%=MOD;
        ans*=resp;
        ans%=MOD;
      }
      else{
        cnt+=2;
        nowm+=2;
        resm%=MOD;
        ans*=resm;
        ans%=MOD;
      }
    }
    else{
      cnt++;
      p[nowp]%=MOD;
      ans*=p[nowp];
      ans%=MOD;
      nowp--;
    }
  }
  while(ans<0)ans+=MOD;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define pii pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
#define sz(x) ((ll)(x).size())
#define pb push_back
#define mp make_pair
#define bit(n) (1LL<<(n))
#define F first
#define S second
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll INF = 1LL<<60;
const ll mod = (int)1e9 + 7;

int main() {
    int h,w,k;
    cin >> h >> w >> k;
    char s[h][w];
    int ln[h]={};
    rep(i,h){
        rep(j,w){
            cin >> s[i][j];
            if(s[i][j]=='#')ln[i]++;
        }
    }
    int cnt[h]={};
    bool aa=false;
    int usnum=1;
    int ans[h][w];
    rep(i,h){
        if(ln[i]){
            rep(j,w){
                if(s[i][j]=='.')ans[i][j]=usnum;
                else{
                    cnt[i]++;
                    if(cnt[i]>1)usnum++;
                    ans[i][j]=usnum;
                }
                if(i!=0 && !aa){
                    int ii=i;
                    while(ii>=0){
                        ans[ii][j]=usnum;
                        ii--;
                    }
                }
            }
            usnum++;
            aa=true;
        }
        else{
            if(aa){
                rep(j,w)ans[i][j]=ans[i-1][j];
            }
        }
    }
    rep(i,h){
        rep(j,w){
            cout << ans[i][j] << ' ';
        }
        cout << endl;
    }
    


}

/*



 */



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

int main()
{
	int a[4];
	for (int i = 0; i < 3; ++i) {
		cin >> a[i];
	}
	a[3] = a[0];
	int ret = 0;
	int temp = 0;
	for (int i = 1; i < 4; ++i) {
		ret += abs(a[i] - a[i-1]);
		temp = max(temp, abs(a[i] - a[i - 1]));
	}

	cout << ret - temp << endl;

	return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	//fmt.Println("Hello World")

	var n int
	fmt.Scanf("%d", &n)

	ac,wa,tle,re := 0,0,0,0
	for i := 0; i < n; i++ {
		var tmp string
		fmt.Scanf("%s", &tmp)

		switch tmp{
		case "AC": ac++
		case "WA": wa++
		case "TLE": tle++
		case "RE": re++
		}
	}
	fmt.Println("AC x ",ac)
	fmt.Println("WA x ",wa)
	fmt.Println("TLE x ",tle)
	fmt.Println("RE x ",re)

}


Measured memory_bytes: 6336
#include <bits/stdc++.h>
#define pb push_back
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ggdem=b;i<ggdem;++i)
#define SZ(x) ((int)x.size())
#define ALL(x) x.begin(),x.end()
#define mset(a,v) memset((a),(v),sizeof(a))
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long ll;

const ll MOD=1000000007;

char t[1010][1010];
ll h,w; 
ll dp[1010][1010];

ll f(ll x,ll y){
	ll &r=dp[x][y];
	if(r>=0)return r;
	if(x>=h||y>=w){
		r=0; return r;
	}
	if(t[x][y]=='#'){
		r=0; return r;
	}
	if(x==h-1&&y==w-1){
		r=1; return r;
	}
	r=(f(x+1,y)+f(x,y+1))%MOD;
	return r;
}

int main(){FIN;
	cin>>h>>w;
	fore(i,0,h){
		fore(j,0,w){
			cin>>t[i][j];
		}
	}
	mset(dp,-1);
	cout<<f(0,0);
	return 0;
}

Measured memory_bytes: 9344