akhauriyash/Code-Regression huggingface dataset:
//Author: master19
#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 ff first 
#define ss second 
#define pb push_back
#define endl "\n"
#define PI acos(-1.0)
#define mod 1000000007LL // fixed...
#define modd 1000000007LL // Can be changed for global use
#define yes cout << "YES\n"
#define no cout << "NO\n"
#define Yes cout << "Yes\n"
#define No cout << "No\n"
#define all(arr) arr.begin(),arr.end()
#define x(arr) arr.begin(),arr.end()
#define ulli unsigned long long int
#define assign(x,val) memset(x,val,sizeof(x))
#define prec(val, dig) fixed << setprecision(dig) << val
#define Sort(arr) sort(arr.begin(), arr.end())
#define lower(str) transform(str.begin(), str.end(), str.begin(), ::tolower);
#define upper(str) transform(str.begin(), str.end(), str.begin(), ::toupper);
#define crap ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define get(arr, num) vector < ll > arr(num); for(int i=0; i<num; i++)cin >> arr[i];
#define get_set(arr, num, st, type) set < type > st; for(int i=0; i<num; i++) st.insert(arr[i]);
#define put(arr, num) for(int i=0; i<num; i++)cout << arr[i] << " "; cout << endl;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update > new_ds; 
ll lets_do_it();
pair < ll, ll > xy[] = {{-1, 0}, {1, 0} , {0, -1}, {0, 1}};
pair < ll, ll > dig[] = {{-1, -1}, {-1, 1}, {1, 1}, {1, -1}};
bool isValid(ll x, ll y, ll row, ll col){
    return ((x>=0) && (y >=0)  && (x < row) && (y < col));
}
int main(int argc, const char** argv) {
    crap;
    ll test = 1;
    // cin >> test;
    for(int loop=0; loop<test; loop++){
        // cout << "Case #" << (loop+1) << ": "; 
        lets_do_it();
    }
    return 0;
}
ll lets_do_it(){
    // Your code goes by here !!
    string str;
    cin >> str;
    ll count = 0;
    ll maxi = 0;
    for(int i=0; i<str.length(); i++){
        if(str[i] == 'R')
            count++;
        else{
            maxi = max(maxi, count);
            count = 0;
        }
    }
    maxi = max(maxi, count);
    cout << maxi << endl;




    return 0;
}


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

int main(){
  int n;
  cin>>n;
  int w[n];
  for(int i=0;i<n;i++){
    cin>>w[i];
  }
  
  int sum=0;
  for(int i=0;i<n;i++){
    sum+=w[i];
  }
  
  int sumsub=0;
  int mi=sum;
  for(int i=0;i<n-1;i++){
    sumsub+=w[i];
    mi=min(mi,abs(sum-2*sumsub));
  }
  cout<<mi<<endl;
}


Measured memory_bytes: 256
import numpy as np

N = int(input())

a_inputs = input().split()

a = np.zeros(N)
for i in range(N):
  a[i] = int(a_inputs[i])
  
a = np.sort(a)[::-1]

alice = a[0::2].sum()
bob   = a[1::2].sum()

print(int(alice - bob))

Measured memory_bytes: 18732
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <utility>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

//const long double PIL = 3.141592653589793238462643383279502884L;
//const double PI = 3.14159265358979323846;

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vii;
#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()

const int N = 601;
double dp[N];
vi adj[N];

int main() {
	//~ ios::sync_with_stdio(0);
	//~ cin.tie(0);
	int n, m;
	scanf("%d%d", &n, &m);
	for (int i = 0; i < m; i++) {
		int a, b;
		scanf("%d%d", &a, &b);
		adj[a].push_back(b);
	}

	double best = n;
	for (int i = n-1; i > 0; i--) {
		if (adj[i].size() == 1)
			dp[i] = 1 + dp[adj[i][0]];
		else {
			int remove = 0;
			for (int j = 1; j < adj[i].size(); j++)
				if (dp[adj[i][j]] > dp[adj[i][remove]]) remove = j;
			dp[i] = 0;
			for (int j = 0; j < adj[i].size(); j++)
				if (j != remove) dp[i] += (1 + dp[adj[i][j]]) / (adj[i].size() - 1);
			for (int j = i - 1; j > 0; j--) {
				dp[j] = 0;
				for (int k = 0; k < adj[j].size(); k++)
					dp[j] += (1 + dp[adj[j][k]]) / adj[j].size();
			}
			best = min(best, dp[1]);

			dp[i] = 0;
			for (int j = 0; j < adj[i].size(); j++)
				dp[i] += (1 + dp[adj[i][j]]) / adj[i].size();
		}
	}
	best = min(best, dp[1]);
	printf("%.10f\n", best);
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define FOR(i,s,e) for(int i=(s);i<(e);i++)
#define REP(i,n) FOR(i,0,n)
#define all(v) (v).begin(),(v).end()
#define pb(a) push_back(a)
using namespace std;
typedef long long LL;
typedef pair<int, int> P;

struct UnionFind
{
    vector< int > data;
    UnionFind(int sz){
        data.assign(sz, -1);
    }
    bool unite(int x, int y){
        x = root(x), y = root(y);
        if(x == y) return false;
        if(data[x] > data[y]) swap(x, y);
        data[x] += data[y];
        data[y] = x;
        return true;
    }
    int root(int k){
        if(data[k] < 0) return(k);
        return (data[k] = root(data[k]));
    }
    int size(int k){
        return -data[root(k)];
    }
};

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

    int n, m;
    cin >> n >> m;
    vector<vector<int> > l(n);
    vector<bool> spoken(m, false);
    REP(i, n){
        int k;
        cin >> k;
        REP(j, k){
            int x;
            cin >> x;
            l[i].pb(--x);
            spoken[x] = true;
        }
    }

    UnionFind UF(m);
    REP(i, n){
        REP(j, l[i].size()) UF.unite(l[i][0], l[i][j]);
    }

    bool ans = true;
    REP(i, m){
        if(spoken[i] && UF.root(i) != UF.root(l[0][0])) ans = false;
    }
    cout << (ans? "YES" : "NO" ) << endl;

}


Measured memory_bytes: 6144
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskD {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int[] a = in.nextIntArray(n);

            int[] last = new int[20];
            Arrays.fill(last, -1);

            long ans = 0;
            int start = 0;
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < 20; j++) {
                    if ((a[i] >> j & 1) == 1) {
                        start = Math.max(start, last[j] + 1);
                        last[j] = i;
                    }
                }
                ans += i - start + 1;
            }

            out.println(ans);
        }

    }

    static class InputReader {
        BufferedReader in;
        StringTokenizer tok;

        public String nextString() {
            while (!tok.hasMoreTokens()) {
                try {
                    tok = new StringTokenizer(in.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return tok.nextToken();
        }

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

        public int[] nextIntArray(int n) {
            int[] res = new int[n];
            for (int i = 0; i < n; i++) {
                res[i] = nextInt();
            }
            return res;
        }

        public InputReader(InputStream inputStream) {
            in = new BufferedReader(new InputStreamReader(inputStream));
            tok = new StringTokenizer("");
        }

    }
}



Measured memory_bytes: 42436
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner scanner = new Scanner(System.in);
        int N=scanner.nextInt();
        final int MAX=55555;
        boolean[] isPrime =new boolean[MAX];
        for(int i=0;i<MAX;i++){
            isPrime[i]=true;
        }
        for(int i=2;i<240;i++){
            if(isPrime[i-1]==false) continue;
            for(int j=0;j<MAX/i;j++){
                if(j>0){
                    isPrime[i*(j+1)-1]=false;
                }
            }
        }
        int[] results=new int[N];
        int index=0;
        for(int i=1;i<MAX;i++){
            if((i+1)%5==1){
                if(isPrime[i]){
                    results[index]=i+1;
                    index++;
            if(index==N){
                break;
            }
                }
                
            
            }
        }
        for(int i=0;i<N-1;i++){
            System.out.print(results[i]+" ");
        }
        System.out.println(results[N-1]);
        
    }
}


Measured memory_bytes: 19284
#include<cstdio> 
using namespace std;
int f[1000005];
int main(){
	int k;
	scanf("%d",&k);
	int s=0,now=7%k;
	while (1){
		s++;
		if (f[now]){
			break;
		}
		f[now]=1;
		if (!now){
			printf("%d\n",s);
			return 0;
		}
		now=(now*10+7)%k;
	}
	printf("-1\n");
	return 0;
}

Measured memory_bytes: 7092
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<cmath>
#include<iomanip>
#include<set>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;

int main() {
    ll a, b, c; cin >> a >> b >> c;
    if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0) {cout << 0 << endl; return 0;}
    cout << min(min(b * c, a * b), a * c) << endl;
}



Measured memory_bytes: 256
import sys

input = sys.stdin.readline
s = input()
k = int(input())
if len(s) == 1:
    print(s)
elif k == 1:
    print(s[0])
else:
    ans = '1'
    for i in range(min(len(s), k)):
        if s[i] != '1':
            ans = s[i]
            break
    print(ans)


Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int H,W;
    cin >> H >> W;
    char a[H][W];
    int i,j,k,l,m,line;
    l=0,m=0,line=-1;
    for(i=0;i<H;i++){
        for(j=0;j<W;j++){
            cin >> a[i][j];
        }
    }
    for(i=0;i<H;i++){
        for(j=0;j<W;j++){
            for(k=0;k<W;k++){
                if(a[i][k]=='#'){
                    l=1;
                }
            }
            for(k=0;k<H;k++){
                if(a[k][j]=='#'){
                    m=1;
                }
            }
            if(l==1&&m==1){
                if(i!=line&&line!=-1){
                    cout << endl;
                }
                cout << a[i][j];
                line=i;
            }
            l=0;
            m=0;
        }
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;
 
template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)
 
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;
  

int main() {
    string S;
    cin >> S;
    
    int res = 0;
    int N = S.size();
    rep(i, (N + 1) / 2) {
        if (S[i] != S[N-1-i]) res++;
    }

    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<climits>
#include<map>
#include<string>
#include<functional>
#include<iomanip>
#include<deque>
#include<random>
#include<set>

using namespace std;
typedef long long ll;
typedef double lldo;
#define mp make_pair
#define pub push_back
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
ll gcd(ll a, ll b) { if (a % b == 0) { return b; } else  return gcd(b, a % b); }
ll lcm(ll a, ll b) { if (a == 0) { return b; }return a / gcd(a, b) * b; }
template<class T>ll LBI(vector<T>& ar, T in) { return lower_bound(ar.begin(), ar.end(), in) - ar.begin(); }
template<class T>ll UBI(vector<T>& ar, T in) { return upper_bound(ar.begin(), ar.end(), in) - ar.begin(); }

ll n, q, com, s, t, x, i;

const int sqrtN = 512;
struct SqrtDecomposition {
	int N, K;
	vector<int> data;
	vector<int> bucketAdd;
	SqrtDecomposition(int n) : N(n) {
		K = (N + sqrtN - 1) / sqrtN;
		data.assign(K * sqrtN, 0);
		bucketAdd.assign(K, 0);
	}
	// [s, t)
	void add(int s, int t, int x) {
		for (int k = 0; k < K; ++k) {
			int l = k * sqrtN, r = (k + 1) * sqrtN;
			if (r <= s || t <= l)
				continue;
			if (s <= l && r <= t) {
				bucketAdd[k] += x;
			}
			else {
				for (int i = max(s, l); i < min(t, r); ++i) {
					data[i] += x;
				}
			}
		}
	}
	int get(int i) {
		int k = i / sqrtN;
		return data[i] + bucketAdd[k];
	}
};

int main() {
	cin >> n >> q;
	SqrtDecomposition raq(n);
	rep(j, q) {
		cin >> com;
		if (com == 0) {
			cin >> s >> t >> x;
			raq.add(s - 1, t, x);
		}
		else {
			cin >> i;
			cout << raq.get(i - 1) << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3128
#include <iostream>
#include <vector>
#include <utility>
#include <string>
#include <map>
#include <algorithm>
#include <stdio.h>
#include <set>
#include <cmath>
#include <functional>

typedef long long ll;
using namespace std;


int main(){
    int k;
    cin >> k;
    ll ch = 10000000;
    ll a = 0;
    ll b = 7;
    ll ans = -1;
    for(ll i = 0; i < ch; i++){
        ll new_a = (a + b) % k;
        if(new_a == 0){
            ans = i + 1;
            break;
        } else {
            a = new_a;
            b = (b % k) * 10;
        }
        
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

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

const ll inf = 1e15;
const ll mod = 1e9+7;

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

int main() {
    ll N;
    cin >> N;
    
    vector<ll> a(N);
    rep(i, N) cin >> a[i];
    
    sort(a.begin(), a.end());
    cout << a[N-1] - a[0] << endl;
    
    return 0;
}

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

namespace Miscelleneous {
   class Program {
      public static int cin() { 
      string s = Console.ReadLine();
      if (string.IsNullOrEmpty(s)) return -1;
      return int.Parse(s); 
      }
      public static int[] cins() {
         string s = Console.ReadLine();
         if (string.IsNullOrEmpty(s)) return new int[]{ };
         string[] ss = s.Split(',');
         int[] Res = new int[ss.Length];
         for (int i = 0; i<ss.Length; i++) Res[i]=int.Parse(ss[i]);
         return Res;
      }
      public static void print(object s) { Console.WriteLine(s.ToString()); }
      public static void Main(string[] args) {
         const int N = 50000;
         bool[] Tape=new bool[N];
         Tape[0]=true;

         for (int j = 2; j*j<=N; j++) {
            if (Tape[j-1]) continue;
            for (int i = 2; i*j<=N; i++) {
               Tape[i*j-1]=true;
            }
         }
         IEnumerable<int> G = Tape.Select((i,j) => new { K = j,V = i })
            .Where(i=>!i.V).Select(i=>i.K+1);

         int n,resi,ress;

         while (true) {
            n=cin();
            if (n==-1) break;
            resi=G.Last(i => i<n);
            ress=G.Last()<=n ? 50021 : G.First(i => i>n);
            print(resi+" "+ress);
         }
      }
   }
}

Measured memory_bytes: 9720
import java.util.*;

public class Main {
	public static void main(String[] args) {
		ArrayList<Integer> caca = new ArrayList<Integer>();
		Scanner scn = new Scanner(System.in);
		String din = scn.next();
		int din2 = Integer.parseInt(din);
		for(int i = scn.nextInt();i>0;i--) {
			caca.add(scn.nextInt());
		}for(int i = din.length()-1;i>=0;i--) {
			if(caca.contains((int)(din2/(1*(Math.pow(10,din.length()-i-1))))%10)) {
				din2+=(Math.pow(10,din.length()-i-1));
				din = Integer.toString(din2);
				String f = "";
				for(int i2 = i+1;i2<din.length();i2++) {
					f+="0";
				}
				din = din.substring(0,i+1)+f;
				din2 = Integer.parseInt(din);
				i++;
			}
		}din = Integer.toString(din2);
		for(int i = din.length()-1;i>=0;i--) {
			if(caca.contains((int)(din2/(1*(Math.pow(10,din.length()-i-1))))%10)) {
				din2+=(Math.pow(10,din.length()-i-1));
				i++;
			}
		}
		System.out.println(din2);
		scn.close();
	}
}

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

int n, k;
int ans = 1e8;

void dfs(int i, int last) {
  if (i == n) {
    ans = min(ans, last);
  }
  else {
    dfs(i + 1, last * 2);
    dfs(i + 1, last + k);
  }
  return;
}

int main(void){
    // Here your code !
    scanf("%d", &n);
    scanf("%d", &k);
    dfs(0, 1);
    printf("%d\n", ans);
    return 0;
}


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

int main(){
	int N, i, x = 0, max = 0;
	char *S;

	scanf("%d\n", &N); N++;
	S = (char *)malloc(sizeof(char)*N);
	if(S == NULL) return 1;
	fgets(S, N, stdin);

	for(i = 0; i < N; i++){
		x += (S[i] == 'I') ? +1 : -1 ;
		if(max < x) max = x;
	}

	printf("%d\n", max);

	free(S);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cmath>
#include <string>
#include <typeinfo>
#include <climits>
#include <algorithm>
#include <cctype>
#include <stdio.h>
#include <cstdlib>
using namespace std;

int main(){
    char a[3][4];
    for(int i=0;i<3;i++){
        cin >> a[i];
    }
    cout << a[0][0] << a[1][1] << a[2][2]; 
}

Measured memory_bytes: 256
//💭💡🎈fold
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define frd(x) freopen("x","r",stdin)
#define fwt(x) freopen("x","w",stdout)
#define fo(i,a) for(int i=1;i<=(a.n);i++)
#define fup(i,x,y) for(int i=(x);i<=(y);i++)
#define fdn(i,x,y) for(int i=(x);i>=(y);i--)
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

const int __=100005;
int a[__],b[__];

int main()
{
    int n;ll h;
    scanf("%d%lld",&n,&h);
    int maxx=0;
    fup(i,1,n)
    {
        scanf("%d%d",&a[i],&b[i]);
        if(a[i]>maxx)maxx=a[i];
    }
    sort(b+1,b+n+1,greater<int>());
    ll sum=0,ans=0;
    fup(i,1,n)
        if(b[i]>maxx)
        {
            h-=b[i],ans++;
            if(h<=0)return !printf("%lld\n",ans);
        }
        else break;
    ans+=(h+maxx-1)/maxx;
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>

using namespace std;
typedef long long ll;

int gcd(int x, int y) {
  if (x < y) swap(x, y);
  while (y > 0) {
    int r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//for(int i = ; i < ; i++){}

int main(){
    int n;
    int k;
    cin>>n>>k;
    int a[n];
    for(int i = 0; i<n; i++){
        cin>>a[i];
    }
    int sum = 0;
    int i = 0;
    while(sum<n){
        if(i == 0){
            sum+=k;
        } 
        else{
            sum+=k-1;
        }
        i++;
    }
    cout<<i<<endl;
    return 0;
}


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

int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  
  bool stop = false;
  while(a > 0 || c > 0){
    c -= b;
    if(c <= 0){
      cout << "Yes" << endl;
      break;
    }
    a -= d;
    if(a <= 0){
      cout << "No" << endl;
      break;
    }
  }
    
}


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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int N;
class Point{
public:
	double x,y;
	Point()=default;
	Point(double u,double v):x(u),y(v){}
};

using PIter = list<Point>::iterator;

void Koch(list<Point>& P,PIter start,PIter end,int depth){
	if(depth==N) return;
	Point s,t,u;
	double dx = end->x-start->x;
	double dy = end->y-start->y;
	s.x = start->x+dx/3.0, s.y = start->y+dy/3.0;
	t.x = start->x+2.0*dx/3.0, t.y = start->y+2.0*dy/3.0;

	double nx = -dy, ny = dx;
	double norm = hypot(dx,dy);
	nx /= norm;
	ny /= norm;

	double l = norm*sin(4.0*atan(1.0)/3.0)/3.0;
	u.x = start->x+dx/2.0+nx*l, u.y = start->y+dy/2.0+ny*l;

	PIter si = P.insert(end,s);
	PIter ui = P.insert(end,u);
	PIter ti = P.insert(end,t);

	Koch(P,start,si,depth+1);
	Koch(P,si,ui,depth+1);
	Koch(P,ui,ti,depth+1);
	Koch(P,ti,end,depth+1);
}

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

	N=in();
	list<Point> P;
	P.push_back(Point(0,0));
	P.push_back(Point(100,0));
	PIter start = P.begin();
	PIter end = P.begin();
	advance(end,1);
	Koch(P,start,end,0);

	for(auto& x:P){
		printf("%.10lf %.10lf\n",x.x,x.y);
	}
	
	return 0;
}



Measured memory_bytes: 3284
# coding: utf-8
import math
N = int(input())
AC = 0
WA = 0
TLE = 0
RE = 0
for i in range(N):
    s = input()
    if s == 'AC':
        AC += 1
    elif s == "WA":
        WA += 1
    elif s == "TLE":
        TLE += 1
    else:
        RE += 1

print("AC x " + str(AC))
print("WA x " + str(WA))
print("TLE x " + str(TLE))
print("RE x " + str(RE))

Measured memory_bytes: 9156
#include<iostream>
using namespace std;
#include<map>
#include<unordered_map>
#include<vector>
#include<cmath>
#include<set>
#include<algorithm>
#define int long long int
#define mod 1000000007
int function2(int initial,int final,int memo[],int arr[])
{
	if(initial>final)
	   return 0;
	if(initial==final)
	   return 1;
	if(memo[initial]!=-1)
	    return memo[initial];
	if(arr[initial]==-1)
	   return 0;
	else
	{
		int answer=function2(initial+1,final,memo,arr);
		answer+=function2(initial+2,final,memo,arr);
		memo[initial]=answer%mod;
		return memo[initial];
	}
}
int32_t main()
{
	int n;
	cin>>n;
	int memo[n+1];
	int j;
	for(j=0;j<=n;j++)
	{
		memo[j]=-1;
	}
	int arr[n+1]={0};
	int m;
	cin>>m;
	for(j=0;j<m;j++)
	{
		int x;
		cin>>x;
		arr[x]=-1;
	}
	int answer=function2(0,n,memo,arr);
	cout<<answer<<endl;
}


Measured memory_bytes: 11332
#!/usr/bin/python3
# -*- coding: utf-8 -*-

N, M = map(int, input().split())
L = [0] * M
R = [0] * M
for i in range(M):
    L[i], R[i] = map(int, input().split())
L_min = L[0]
R_max = R[0]
for i in range(1, M):
    if L_min < L[i]:
        L_min = L[i]
    if R[i] < R_max:
        R_max = R[i]
result = R_max-L_min+1
if result <= 0:
    print(0)
else:
    print(R_max-L_min+1)

Measured memory_bytes: 10868
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;


int main()
{
   
    ll i,j,n,p,m=1000000007,flag=0,temp=0;
   cin>>n;
   ll arr[n];

   for(i=0;i<n;i++)cin>>arr[i];

    sort(arr,arr+n);

  if(arr[n/2-1]!=arr[n/2])
  {
    temp=arr[n/2]-arr[n/2-1];
   
  }

  cout<<temp<<endl;
  
 return 0;
  }

Measured memory_bytes: 1024
#include <algorithm>
#include <iostream>
#include <climits>
#include <cstring>
#include <string>
#include <vector>
#include <cmath>
#include <map>

using namespace std;

#define ll long long
#define mod 1000000007
#define vi vector<int>
#define vll vector<ll>
#define pb(x) push_back(x)

ll power(int x, unsigned int y){
    ll res = 1;
    while(y > 0){
        if(y & 1) res = res * x;
        y >>= 1;
        x *= x;
    }
    return res;
}

void solve(){
    int n, m, x;
    cin >> n >> m >> x;

    vector<vi> arr(n, vi(m));
    vi c(n);
    for(int i = 0; i < n; i++){
        cin >> c[i];
        for(int j = 0; j < m; j++) 
            cin >> arr[i][j];
    }

    ll end = (1 << n);
    ll ans = 1e8;
    for(int t = 0; t < end; t++){

        vi check(m);

        ll currCost = 0;

        for(int i = 0; i < n; i++){
            if((t>>i) & 1){
                currCost += c[i];
                for(int j = 0; j < m; j++)
                    check[j] +=  arr[i][j];
            }
        }

        bool checkIfValid = true;

        for(int i = 0; i < m; i++){
            if(check[i] < x) checkIfValid = false;
        }

        if(checkIfValid) ans = min(ans, currCost);
    }

    if(ans == 1e8) cout << "-1\n";
    else cout << ans;
}

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

Measured memory_bytes: 3680
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <utility>
#include <cstdint>

using namespace std;

int main() {
	int64_t n;
	cin >> n;
	int64_t a = 1;

	for (int64_t i = 1; i <= n; i++) {
		a *= i;
		a %= 1000000007;
	}

	cout << a << endl;

	return 0;
}

Measured memory_bytes: 3636
import math
 
date0=input().rstrip().split(" ")
A=int(date0[0])
B=int(date0[1])
H=int(date0[2])
M=int(date0[3])
P=(H+(M/60))*30
Q=M*6
if P>Q:
    R=P-Q
else:
    R=Q-P
if R>=180:
    R=360-R
print(math.sqrt(A**2+B**2-2*A*B*math.cos(math.radians(R))))

Measured memory_bytes: 9524
def LI():
    return list(map(int, input().split()))


N = int(input())
H = LI()
ans = 0
count = 0
for i in range(1, N):
    if H[i-1] >= H[i]:
        count += 1
    else:
        ans = max(ans, count)
        count = 0
print(max(ans, count))


Measured memory_bytes: 20500
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
const ll MOD = 1e9+7;

int main(){
  int n;
  cin >> n;
  int p;
  int ch = 0, ans = 0;
  rep(i, n){
    cin >> p;
    if(ch==1) ch=0;
    else if(p==i+1) {ans++; ch=1;}
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define maxn 100100
int n,k,a[maxn];
int main()
{
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;++i) scanf("%d",&a[i]);
    int ans=1e9;
    for(int i=1;i+k-1<=n;++i)
    {
        //[i,i+k-1]
        int ret;
        if(a[i]>=0) ret=a[i+k-1];
        else if(a[i+k-1]<=0) ret=-a[i];
        else ret=min(a[i+k-1]-a[i]*2,a[i+k-1]*2-a[i]);
        ans=min(ans,ret);
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pl;
typedef vector<ll> vl;
const int MN = 100012;
const ll MOD = 1e9+7;

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

vector<ll> mt[MN];
ll dp[MN];

int main (void) {
  ios::sync_with_stdio(false);cin.tie(0);
  ll n,k; cin >> n >> k;
  for (ll i = 1; i <= k; i++) {
    for (ll j = i+i; j <= k; j += i)
      mt[i].push_back(j);
  }
  ll ans = 0;
  for (; k > 0; k--) {
    dp[k] = modpow(mt[k].size()+1, n);
    for (ll x : mt[k]) dp[k] = (dp[k]+MOD-dp[x])%MOD;
    ans += k*dp[k]%MOD;
    ans %= MOD;
  }
  cout << ans << '\n';
  return 0;
}



Measured memory_bytes: 17376
def main():
    n = int(input())
    a = [int(x) for x in input().split()]
    inf = -10**16
    if n%2:
        dp0 = [0]*n
        dp1 = [0]*n
        sumk = a[0]
        dp0[1] = inf
        dp1[1] = max([a[0], a[1]])
        if n > 2:
            dp0[2] = 0
            dp1[2] = max([a[2], dp1[1]])
            sumk += a[2]
        if n > 3:
            dp0[3] = max([dp1[2], a[3]])
            dp1[3] = max([a[0]+a[2], a[0]+a[3], a[1]+a[3]])
        for i in range(4, n):
            if i%2 == 0:
                dp0[i] = max([dp0[i-1], dp0[i-2]+a[i]])
                dp1[i] = max([dp1[i-1], dp1[i-2]+a[i]])
                sumk += a[i]
            else:
                dp0[i] = max([dp1[i-1], dp0[i-2]+a[i]])
                dp1[i] = max([dp1[i-2]+a[i], sumk])
        ans = dp1[n-1]
    else:
        key = sum(a[::2])
        ans = key
        for i in range(n-1, 0, -2):
            key += a[i]
            key -= a[i-1]
            if ans < key:
                ans = key
    print(ans)
            
    
    

if __name__ == "__main__":
    main()

Measured memory_bytes: 105416
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 998244353;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;

#define all(a) (a).begin(), (a).end()

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

ll modpow(ll a, ll b){
    if(b == 0) return 1;
    else if(b % 2 == 0){
        ll d = modpow(a, b / 2) % MOD;
        return (d * d) % MOD;
    }
    else{
        return (a * modpow(a, b - 1)) % MOD;
    }
}

const int MAX_N = 200010;
ll fact[MAX_N], finv[MAX_N];
ll comb(int n, int r){
    if(n < r || r < 0) return 0;
    return fact[n] * finv[n-r] % MOD * finv[r] % MOD;
}

void comb_init(int n){
    fact[0] = finv[0] = 1;
    for(int i=1; i<=n; i++){
        fact[i] = (fact[i-1] * i) % MOD;
        finv[i] = modpow(fact[i], MOD - 2);
    }
}

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

    ll n, m, k; cin>>n>>m>>k;

    comb_init(200005);

    ll ans = 0;
    for(int i=0; i<=k; i++){
        ll cur = m * modpow(m - 1, n - i - 1);
        cur %= MOD;
        cur *= comb(n - 1, i);
        cur %= MOD;
        ans += cur;
        ans %= MOD;
    }

    cout << ans << endl;

    return 0;
}

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

int to_int(char s) {
    return s - '0';
}

int main() {
    string S;  cin >> S;
    int N = S.size();
    int K;  cin >> K;

    vector<vector<vector<long long>>> dp(N + 1, vector<vector<long long>>(K + 1, vector<long long>(2)));
    dp[0][K][1] = 1;
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j <= K; ++j) {
            for (int f = 0; f < 2; ++f) {
                for (int nd = 0; nd < 10; ++nd) {
                    int nj = j, nf = f;
                    if (nd != 0) --nj;
                    if (nj < 0) continue;
                    if (f) {
                        if (nd > to_int(S[i])) continue;
                        if (nd < to_int(S[i])) nf = 0;
                    }
                    dp[i + 1][nj][nf] += dp[i][j][f];
                }
            }
        }
    }

    cout << dp[N][0][0] + dp[N][0][1] << endl;
}


Measured memory_bytes: 256
program sequence_sum
  implicit none
  integer(8) :: n, m, num, a(0:100000) = 0
  integer :: x, b(0:100000) = 0, period, offset, rem, i
  read(*,*) n, x, m
  if (n == 1) then
    write(*,'(i0)') x
    stop
  end if
  a(1) = x
  b(x) = 1
  do i = 2, int(m) + 1
    x = int(mod(int(x, 8) * x, m))
    a(i) = a(i - 1) + x
    if (i == n) then
      write(*,'(i0)') a(i)
      stop
    end if
    if (b(x) > 0) then
      offset = b(x) - 1
      period = i - offset - 1
      exit
    end if
    b(x) = i
  end do
  num = (n - offset) / period
  rem = int(n - offset - num * period)
  write(*,'(i0)') (a(offset + period) - a(offset)) * num + a(offset + rem)
end program sequence_sum

Measured memory_bytes: 3644
#include<iostream>
#include<cstring>
using namespace std;
int main(){

    long long int n,ans=0,i,j,k;
    cin>>n;
    long long int a[n+1][n+1];
    bool p[n+1][n+1];
    memset(p,0,sizeof(p));
    for(i=1;i<=n;i++)
        for(j=1;j<=n;j++)
            cin>>a[i][j];
    //读入数据以及初始化操作

    for(k=1;k<=n;k++)      
        for(i=1;i<=n;i++)
            for(j=1;j<=n;j++){
                if(k!=j&&k!=i&&i!=j){
                    if(a[i][j]==a[i][k]+a[k][j])
                        p[i][j]=1;  //标记
                    if(a[i][j]>a[i][k]+a[k][j]){
                        cout<<"-1"<<endl;  //不是最短路，无解
                        return 0;
                    }
                }
            }
    //核心操作语句

    for(i=1;i<=n;i++)
        for(j=1;j<=n;j++)
            if(p[i][j]==0)
                ans+=a[i][j]; //统计长度总和
    cout<<ans/2<<endl;
    //统计总和及输出

    return 0;
}

Measured memory_bytes: 1024
is_zero = False
while not is_zero:
    list = input().split(' ')
    x = int(list[0])
    y = int(list[1])
    if x == 0 and y == 0:
        is_zero = True
    else:
        if x < y:
            print(f'{x} {y}')
        else:
            print(f'{y} {x}')



Measured memory_bytes: 5624
use std::io;

fn main() {
    let mut input = String::new();
    io::stdin().read_line(&mut input).ok();

    let mut iter = input.split_whitespace().map(|w| w.parse::<i32>().unwrap());
    let w = iter.next().unwrap();
    let h = iter.next().unwrap();
    let x = iter.next().unwrap();
    let y = iter.next().unwrap();
    let r = iter.next().unwrap();

    match 0 <= x - r && x + r <= w && 0 <= y - r && y + r <= h {
        true => println!("Yes"),
        false => println!("No"),
    }
}



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

int main() {
	string n;
	cin>>n;
	int sum=0;
	
	for(auto i:n){
		
		sum+=i-'0';
		
	}
	if(sum%9==0){
		cout<<"Yes";
	}
	else{
		cout<<"No";
	}
	return 0;
}

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

int main() {
    double a, b, h, m;
    cin >> a >> b >> h >> m;
    
    double hk, mk, k, c, pi;
    pi = 3.1415926536;
    hk = pi / 6 * h + pi / 360 * m;
    mk = pi / 30 * m;
    k = hk - mk;
    if(k < 0)
        k *= -1;
    
    c = sqrt(pow(a,2) + pow(b,2) - 2*a*b*cos(k));
    
    cout << fixed << setprecision(10) << c << endl;
    
    return 0;
}


Measured memory_bytes: 4216
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define pb push_back
#define mp make_pair
#define ff first
#define pi pair<ll,ll>
#define ss second
#define ll long long
#define MAXN 100005
using namespace std;
using namespace __gnu_pbds;  

ll k;
deque<ll> q;

void solve()
{
	cin>>k;
	if(k<=9)
	{
		cout<<k<<endl;return;
	}
	for(ll i=1;i<=9;i++) q.pb(i);
	ll i=9;
	while(1)
	{
		ll p=q.front();
		q.pop_front();
		if(p%10>0)
		{
			q.pb(p*10+p%10-1);
			i++;
		}
		if(i==k) break;
		q.pb(p*10+p%10);
		i++;
		if(i==k) break;
		if(p%10<9)
		{
			q.pb(p*10+p%10+1);
			i++;
		}
		if(i==k) break;
	}
	cout<<q.back()<<endl;
}

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


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

#define REP(i, a, b) for (int i = (a); i < (b); i++)
#define REPR(i, a, b) for (int i = (a); i >= (b); i--)
#define ALL(container) (container).begin(), (container).end()

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;

const int INF = 1e9;
const int MAX_LEN = 2000;

int H, W;
vector<string> S(MAX_LEN);
int L[MAX_LEN][MAX_LEN], R[MAX_LEN][MAX_LEN], U[MAX_LEN][MAX_LEN], D[MAX_LEN][MAX_LEN];

void countLUBlock(int i, int j) {
  if (S[i][j] == '#') {
    L[i][j] = 0;
    U[i][j] = 0;
  } else {
    L[i][j] = j == 0 ? 1 : L[i][j-1] + 1;
    U[i][j] = i == 0 ? 1 : U[i-1][j] + 1;
  }
}

void countRDBlock(int i, int j) {
  if (S[i][j] == '#') {
    R[i][j] = 0;
    D[i][j] = 0;
  } else {
    R[i][j] = j == W-1 ? 1 : R[i][j+1] + 1;
    D[i][j] = i == H-1 ? 1 : D[i+1][j] + 1;
  }
}

int main() {
  cin >> H >> W;
  REP(i, 0, H) {
    cin >> S[i];
  }

  int maxBlockCount = 0;
  int oppH, oppW;
  REP(i, 0, H) {
    REP(j, 0, W) {
      countLUBlock(i, j);
      oppH = H-i-1;
      oppW = W-j-1;
      countRDBlock(oppH, oppW);
    }
  }

  int blockCount;
  REP(i, 0, H) {
    REP(j, 0, W) {
      if (S[i][j] == '#') {
        blockCount = 0;
      } else {
        blockCount = L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3;
      }
      if (maxBlockCount < blockCount) {
        maxBlockCount = blockCount;
      }
    }
  }

  cout << maxBlockCount << endl;

  return 0;
}


Measured memory_bytes: 66816
#include <iostream>
using namespace std;
     
int main() {
    
	int count[4][3][10];
	
	for(int i = 0; i < 4; i++){
		for(int j = 0; j < 3; j++){
		    for(int k = 0; k < 10; k++){
    			count[i][j][k]=0;
		    }
		}
	}
	
	int n;
	cin >> n ;
	int b, f, v, r;
	
	for(int h = 0; h < n; h++){
		cin >> b >> f >> r >> v;
		count[b-1][f-1][r-1] += v;
	}
		
	for(int i = 0; i < 4; i++){
		for(int j = 0; j < 3; j++){
		    for(int k = 0; k < 10; k++){
    			cout << " " << count[i][j][k];
		    }
		    cout << endl;
		}
		if(i!=3)
		    cout << "####################" << endl;
		
	}
}


Measured memory_bytes: 3100
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int a,b,area,length;
        a=sc.nextInt();
        b=sc.nextInt();
        area=a*b;
        length=2*a+2*b;
        System.out.println(area+" "+length);
    }
}


Measured memory_bytes: 26036
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = input()
ans = 0
for j in range(k):
    pre = 'no'
    for i in range(n - 1 - j, -1, -k):
        score = 0
        if t[i] == 'r' and pre != 'p':
            score = p
            pre = 'p'
        if t[i] == 's' and pre != 'r':
            score = r
            pre = 'r'
        if t[i] == 'p' and pre != 's':
            score = s
            pre = 's'
        if score == 0:
            pre = 'no'
        ans += score
print(ans)

Measured memory_bytes: 3316
/* _________________________________________________________________________________________________
  |                                                                                                 |
  |                             Author      : Aditya Ahuja                                          |
  |                             Date        : Thu, 20th Jun 2019                                    |
  |_________________________________________________________________________________________________|
*/
 
#include<bits/stdc++.h>
using namespace std;

// #define int long long

#define pb          push_back
#define F           first
#define S           second
#define rep(i,a,b)  for(int i=a; i<b; i++)
#define all(a)      (a).begin(),(a).end()
#define ret(x)      {cout << (x) << endl; return;}
#define sz(x)       (int)x.size()
#define type(x)     typeid(x).name()

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<vector<int>> vii;

#define wa(x)       cout << (#x) << " -------- " << (x) << endl
#define pvi(v)      {for(auto it:v) cout << it << " "; cout << endl;}
#define line1	    printf("---------------------------\n")

// #define wa //
// #define line1 //
// #define pvi //
// #define printf //

void solve();
signed main() {
	//ios_base::sync_with_stdio(false); cin.tie(NULL);
	////cout << fixed << setprecision(10);

	int t=1; 
	//cin>>t;
	while(t--) solve();
	return 0;
}

//___________________________________________________________________________________________________

const int nax = 3005;
ll dp[nax][nax];

void solve() {

	int n;
	cin >> n;

	vi a(n);
	rep(i,0,n) cin >> a[i];

	for(int l=n-1; l>=0; --l){
		for(int r=l; r<n; ++r){
			if(l==r) dp[l][r] = a[l];
			else dp[l][r] = max(a[l] - dp[l+1][r], a[r] - dp[l][r-1]);
		}
	}

	ret(dp[0][n-1]);
}


Measured memory_bytes: 70016
// 2020-09-19 13:35:56
// clang-format off
#include <bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
using P = pair<int, int>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }
// #include <atcoder/convolution>
// #include <atcoder/dsu>
// #include <atcoder/fenwicktree>
// #include <atcoder/lazysegtree>
#include <atcoder/math>
// #include <atcoder/maxflow>
// #include <atcoder/mincostflow>
// #include <atcoder/modint>
// #include <atcoder/scc>
// #include <atcoder/segtree>
// #include <atcoder/string>
// #include <atcoder/twosat>
// #include <atcoder/all>
using namespace atcoder;

// clang-format on
void answer() {
  ll n, m, a, b;
  cin >> n >> m >> a >> b;
  cout << floor_sum(n, m, a, b) << '\n';
}

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  int t;
  cin >> t;
  rep(_, t) answer();
  return 0;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
#define For(i,a,b) for(i=a;i<b;i++)
#define rep(i,N) For(i,0,N)
int main(){
  long i,st=0,N,ansp=0,ansm=0;
  cin>>N;
  string ss;
  cin>>ss;
  rep(i,N){
    if(ss[i]==')'){
      if(st==0){
        ansp++;
      }else{
        st--;
      }
    }else{
      st++;
    }
  }
  while(ansp--)cout<<"(";
  cout<<ss;
  while(st--)cout<<")";
  return 0;
}

Measured memory_bytes: 256
class UnionFind:
    def __init__(self, N):
        """
        N:要素数
        root:各要素の親要素の番号を格納するリスト.
             ただし, root[x] < 0 ならその頂点が根で-root[x]が木の要素数.
        rank:ランク
        """
        self.N = N
        self.root = [-1] * N
        self.rank = [0] * N

    def __repr__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

    def find(self, x):
        """頂点xの根を見つける"""
        if self.root[x] < 0:
            return x
        else:
            while self.root[x] >= 0:
                x = self.root[x]
            return x

    def union(self, x, y):
        """x,yが属する木をunion"""
        # 根を比較する
        # すでに同じ木に属していた場合は何もしない.
        # 違う木に属していた場合はrankを見てくっつける方を決める.
        # rankが同じ時はrankを1増やす
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        elif self.rank[x] > self.rank[y]:
            self.root[x] += self.root[y]
            self.root[y] = x
        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            if self.rank[x] == self.rank[y]:
                self.rank[y] += 1

    def same(self, x, y):
        """xとyが同じグループに属するかどうか"""
        return self.find(x) == self.find(y)

    def count(self, x):
        """頂点xが属する木のサイズを返す"""
        return - self.root[self.find(x)]

    def members(self, x):
        """xが属する木の要素を列挙"""
        _root = self.find(x)
        return [i for i in range(self.N) if self.find == _root]

    def roots(self):
        """森の根を列挙"""
        return [i for i, x in enumerate(self.root) if x < 0]

    def group_count(self):
        """連結成分の数"""
        return len(self.roots())

    def all_group_members(self):
        """{ルート要素: [そのグループに含まれる要素のリスト], ...}の辞書を返す"""
        return {r: self.members(r) for r in self.roots()}




import sys
input = sys.stdin.readline
n, q = map(int, input().split())
uf = UnionFind(n)
for i in range(q):
    t, u, v = map(int, input().split())
    if t:
        print(int(uf.same(u, v)))
    else:
        uf.union(u, v)


Measured memory_bytes: 74880
#include <iostream>

using namespace std;

int main(void) {
	int a, b, c, d;
  	cin >> a >> b >> c >> d;
  
  	int turn = 1;
	while(true){
      	if (turn) {
          	c-=b;
          	turn = 0;
          	if (c <= 0) {
              	cout << "Yes" << endl;
              	return 0;
            }
        } else {
          	a-=d;
          	turn = 1;
          	if (a <= 0) {
              	cout << "No" << endl;
              	return 0;
            }
        }
    }
  
	return 0;
}


Measured memory_bytes: 3636
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

LL N, total;
std::vector<LL>A;

int main()
{
	in >> N;
	A.resize(N + 2);
	rep(i, N) in >> A[i + 1];
	rep(i, N + 1) total += abs(A[i + 1] - A[i]);
	rep(i, N)
	{
		LL minus = abs(A[i + 1] - A[i]) + abs(A[i + 1] - A[i + 2]);
		LL plus = abs(A[i + 2] - A[i]);
		out << total - minus + plus << std::endl;
	}
	return 0;
}


Measured memory_bytes: 2048
// includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
#include<bitset>
#include<cstdlib>
// #include<deque>
// #include<multiset>
// #include<cstring>
// #include<bits/stdc++.h>
// }}}
using namespace std;
using ll = long long;

ll ans[2002];
int main() {
  std::ios::sync_with_stdio(false), std::cin.tie(0);
  int n, x, y;
  cin >> n;
  cin >> x >> y;
  assert(x + 1 < y);

  int k = x + n - y + 1;
  int l = n - k + 2;
  int Y = n - y + 1;

  for(int i = 1; i <= l / 2; i++) {
    if(i == l/2 && l%2 == 0) break;
    ans[Y-1+i] += 1;
    ans[i] -= 1;
    ans[x-1+i] += 1;
    ans[i] -= 1;
    if(i == l/2) break;
    ans[Y+i] += 1;
    ans[1+i] -= 1;
    ans[x+i] += 1;
    ans[1+i] -= 1;
  }

  for(int i = n-2; i >=0; i--) ans[i] += ans[i+1];

  for(int i = 0; i < k; i++) ans[k-1-i] += i + 1;
  for(int i = 1; i < l/2; i++) ans[i] += l;
  if(l % 2 == 0) {
    ans[l/2] += l / 2;
  } else {
    ans[l/2] += l;
  }
  ans[1]--;

  for(int i = 1; i <= n-1; i++) {
    cout << ans[i] << "\n";
  }
  return 0;
}

Measured memory_bytes: 256
import math
def souhei(n):
	for w in range(n):
		a=list(map(int,input().split()))
		return(a)
n=int(input())
A=souhei(n)
B=souhei(n)
P=[]
for mm in range(1,5):
	del P[:]
	P=[]
	if mm==4:
		for m in range(n):
			P.append(abs(A[m]-B[m]))
			p=max(P)
	else:
		for m in range(n):
			o=(abs(A[m]-B[m]))**mm
			P.append(o)
		p=sum(P)
		p=(p**(1/mm))
	print('{:.5f}'.format(p))


Measured memory_bytes: 5700
#include <iostream>
#include <vector>
//#include <string>
//#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 100100
//#define NIL -1

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

    LL ans_t=t[0];
    LL ans_a=a[0];
    LL tmp_t;
    LL tmp_a;
    for(LL i=1; i<n; i++){
        if(ans_t%t[i]==0){
            tmp_t=ans_t/t[i];
        }else{
            tmp_t=ans_t/t[i]+1;
        }
        if(ans_a%a[i]==0){
            tmp_a=ans_a/a[i];
        }else{
            tmp_a=ans_a/a[i]+1;
        }
        ans_t=max(tmp_t,tmp_a)*t[i];
        ans_a=max(tmp_t,tmp_a)*a[i];
    }

    cout << ans_t+ans_a << endl;

    return 0;
}


Measured memory_bytes: 3600
#include <stdio.h>
#include <string.h>
int main(){
  int a, b;

  scanf("%d%d", &a, &b);

  if(a % 3 == 0){
    printf("Possible");
  }else if(b % 3 == 0){
    printf("Possible");
  }else if((a + b) % 3 == 0){
    printf("Possible");
  }else{
    printf("Impossible");
  }
  printf("\n");
  
}


Measured memory_bytes: 128