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


using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for (int i = (int)(n); i > 0; --i)
#define loop(i,x,n) for (int i = (int)(x); i < (n); ++i)
#define loops(i,x,n) for (int i = (int)(x); i <= (n); ++i)
#define loopd(i,x,n) for (int i = (int)(x); i > (n); --i)
#define loopds(i,x,n) for (int i = (int)(x); i >= (n); --i)
#define itrep(i,s) for (auto i = begin(s); i != end(s); ++i)
#define itrepd(i,s) for (auto i = --end(s); i != begin(s); --i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(whole), end(whole), ##__VA_ARGS__); }(x)
#define rall(f,x,...) [&](decltype(x)& whole) { return (f)(rbegin(whole), rend(whole), ##__VA_ARGS__); }(x)
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e17;
ll mod = static_cast<ll>(1e9 + 7);
std::ostream& endn(std::ostream& os) { return os.put(os.widen('\n')); }
template<class T> constexpr int sz(const T& a) { return (int)a.size(); }
template<class T> constexpr T pow2(const T a) { return a * a; }
template<class T, class ... Args> constexpr T mins(T& a, Args... args) { return a = min<T>({ a, args... }); }
template<class T, class... Args> constexpr T maxs(T& a, Args... args) { return a = max<T>({ a,args... }); }


int h, w;
int n;
void solve() {
    cin >> h >> w >> n;

    auto ma = max(h, w);
    cout << (n + ma - 1) / ma << endn;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    cout << flush;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <stdio.h>
using namespace std;
int main(){
    int a,b;
    char op;
    while(1){
    cin >>a>>op>>b;
    if(op=='+'){
    	cout<<a+b<<endl;
	}
	if(op=='-'){
		cout<<a-b<<endl;
	}
	if(op=='*'){
		cout<<a*b<<endl;
	}
	if(op=='/'){
		cout<<a/b<<endl;
	}
	if(op=='?'){
		break;
	}
	}
    return 0;
}


Measured memory_bytes: 3112
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
# def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n,k=LI()
  l=LI()

  l.sort()

  left=0
  right=10**9

  while right-left>1:
    middle=(left+right)//2

    cnt=0
    for x in l:
      cnt+=(x+middle-1)//middle-1

    if cnt<=k:
      right=middle
    else:
      left=middle

    # print(left,middle,right)

  return right

# main()
print(main())


Measured memory_bytes: 33316
#include<iostream>
#include<algorithm>
#include<cstdint>
#include<cstdlib>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }

uint64_t getZ() {
  uint64_t v = 0; int c;
  while((c = getchar_unlocked()) >= '0') v=v*10+c-'0';
  return v;
}

int const MAXN = 2e5;
int64_t A[MAXN];
int N;
int main() {
  N = getZ();
  int64_t vx = 0, vo = 0;
  for(int i = 0; i < N; ++i) { A[i] = getZ(); vx ^= A[i]; vo |= A[i]; }
  int64_t vc = vo - vx, vd = 0;
  for(int i = 0, j = 0; i < 60 && j < N; ++i) {
    int64_t b = (int64_t)1 << 59-i;
    if(!(b&vc)) continue;
    if(!(A[j]&b)) {
      for(int k = j+1; k < N; ++k) if(A[k]&b) {
        std::swap(A[j], A[k]); break;
      }
    }
    if(!(A[j]&b)) continue;
    for(int k = j+1; k < N; ++k) if(A[k]&b) A[k] ^= A[j];
    if(!(vd&b)) vd ^= A[j];
    ++j;
  }
  vd &= vc;
  fin(vd*2+vx);
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=int(a);i<int(b);i++)
typedef long long ll;
typedef pair<ll,ll> P;



int main(){
    ll n;cin>>n;
    ll a[100];
    rep(i,0,n)cin>>a[i];
    ll st=0;
    vector<ll> MN;
    vector<ll> MX;
    rep(i,1,n){
        if(a[i-1]<a[i]&&st==0){
            MN.push_back(i-1);
            st=1;
        }
        else if(a[i-1]>a[i]&&st==1){
            MX.push_back(i-1);
            st=0;
        }
    }
    if(a[n-2]<=a[n-1]&&st==1)MX.push_back(n-1);
    
    if(a[n-2]>=a[n-1]&&st==0)MN.push_back(n-1);
    if(MX.size()==0){
        cout<<1000<<endl;
        return 0;
    }
    ll mon=1000,kab=0;
    rep(i,0,MX.size()){
        kab=mon/a[MN[i]];
        mon=mon-kab*a[MN[i]];
        mon=mon+kab*a[MX[i]];
        kab=0;
    }
    cout<<mon<<endl;
}

    









Measured memory_bytes: 3616
/**
 * Title: D - Lamp
 * Url: https://atcoder.jp/contests/abc129/tasks/abc129_d
 */
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<numeric>
#include<functional>
#include<sstream>
#include<iomanip>

using namespace std;

const int MAX_H = 2000;
const int MAX_W = 2000;

int SCORE[MAX_H+2][MAX_W+2];
int MASU[MAX_H+2][MAX_W+2];

#define ll long long

int main() {
    int H, W; cin >> H >> W;
    for(int i=0; i<=MAX_H+1; i++) {
        for(int j=0; j<=MAX_W+1; j++) {
            MASU[i][j] = -1;
        }
    }
    for(int i=1; i<=H; i++) {
        for(int j=1; j<=W; j++) {
            char si; cin >> si;
            if(si=='#') {
                MASU[i][j] = 1;
            } else {
                MASU[i][j] = 0;
            }
        }
    }

    // O(WH)
    for(int i=1; i<=H; i++) {
        // H を固定
        int ptr = 1, c=0;
        for(int j=1; j<=W+1; j++) {
            if(MASU[i][j]==1) {
                for(int k=ptr; k<=j-1; k++) {
                    SCORE[i][k] += c;
                }
                c = 0;
                ptr = j+1;
            } else if (MASU[i][j] == -1) {
                for(int k=ptr; k<=j-1; k++) {
                    SCORE[i][k] += c;
                }
            }else {
                c++;
            }
        }
    }

    // O(WH)
    for(int i=1; i<=W; i++) {
        // H を固定
        int ptr = 1, c=0;
        for(int j=1; j<=H+1; j++) {
            if(MASU[j][i]==1) {
                for(int k=ptr; k<=j-1; k++) {
                    SCORE[k][i] += c;
                }
                ptr = j+1;
                c = 0;
            } else if (MASU[j][i] == -1) {
                for(int k=ptr; k<=j-1; k++) {
                    SCORE[k][i] += c;
                }
            }else {
                c++;
            }
        }
    }

    int ans = 0;
    for(int i=1; i<=H; i++) {
        for(int j=1; j<=W; j++) {
            ans = max(SCORE[i][j], ans);
        }
    }
    cout << ans-1 << endl;

    return 0;
}

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

using namespace std;

long long dp[105][2][105];

int main() {
	string N; cin >> N;
	int n = N.size();
	int k; cin >> k;
	dp[0][0][0] = 1;
	for (int i = 0; i < n; ++i) {
		for (int smaller = 0; smaller < 2; ++smaller) {
			for (int j = 0; j < n; ++j) {
				for (int k = 0; k <= (smaller ? 9 : N[i] - '0'); ++k) {
					dp[i + 1][smaller || k < N[i] - '0'][j + (k ? 1 : 0)] += dp[i][smaller][j];
				}
			}
		}
	}
	cout << dp[n][0][k] + dp[n][1][k] << endl;

	return 0;
}

Measured memory_bytes: 384
w, h, n = map(int,input().split())

y_min = 0
y_max = h

x_min = 0
x_max = w

for i in range(n):
  x, y, a = map(int,input().split())

  if a == 1:
    x_min = max(x_min, x)

  if a == 2:
    x_max = min(x_max, x)

  if a == 3:
    y_min = max(y_min, y)

  if a == 4:
    y_max = min(y_max, y)

white = (y_max - y_min) * (x_max - x_min)
if (y_max - y_min)>=0 and (x_max - x_min)>=0:
  print(max(white, 0))
else:
  print(0)

Measured memory_bytes: 9216
import java.io.*;
import java.util.*;
import java.math.BigInteger;
public class Main{

  public static void main(String[] args) {
    InputReader in = new InputReader(System.in);
    PrintWriter w = new PrintWriter(System.out);
    String a=in.readString(),b=in.readString();
    if (a.equals("H")){
      if (b.equals("H"))
        w.println("H");
      else
        w.println("D");
    }
    else{
      if (b.equals("H"))
        w.println("D");
      else
        w.println("H");
    }
    w.close();
    }

  static class InputReader {

    private final InputStream stream;
    private final byte[] buf = new byte[8192];
    private int curChar, snumChars;
    private SpaceCharFilter filter;

    public InputReader(InputStream stream) {
      this.stream = stream;
    }

    public int snext() {
      if (snumChars == -1)
      throw new InputMismatchException();
      if (curChar >= snumChars) {
        curChar = 0;
        try {
          snumChars = stream.read(buf);
        } catch (IOException e) {
          throw new InputMismatchException();
        }
        if (snumChars <= 0)
        return -1;
      }
      return buf[curChar++];
    }

    public int nextInt() {
      int c = snext();
      while (isSpaceChar(c)) {
        c = snext();
      }
      int sgn = 1;
      if (c == '-') {
        sgn = -1;
        c = snext();
      }
      int res = 0;
      do {
        if (c < '0' || c > '9')
        throw new InputMismatchException();
        res *= 10;
        res += c - '0';
        c = snext();
      } while (!isSpaceChar(c));
      return res * sgn;
    }

    public long nextLong() {
      int c = snext();
      while (isSpaceChar(c)) {
        c = snext();
      }
      int sgn = 1;
      if (c == '-') {
        sgn = -1;
        c = snext();
      }
      long res = 0;
      do {
        if (c < '0' || c > '9')
        throw new InputMismatchException();
        res *= 10;
        res += c - '0';
        c = snext();
      } while (!isSpaceChar(c));
      return res * sgn;
    }

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

    public String readString() {
      int c = snext();
      while (isSpaceChar(c)) {
        c = snext();
      }
      StringBuilder res = new StringBuilder();
      do {
        res.appendCodePoint(c);
        c = snext();
      } while (!isSpaceChar(c));
      return res.toString();
    }

    public String nextLine() {
      int c = snext();
      while (isSpaceChar(c))
      c = snext();
      StringBuilder res = new StringBuilder();
      do {
        res.appendCodePoint(c);
        c = snext();
      } while (!isEndOfLine(c));
      return res.toString();
    }

    public boolean isSpaceChar(int c) {
      if (filter != null)
      return filter.isSpaceChar(c);
      return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    private boolean isEndOfLine(int c) {
      return c == '\n' || c == '\r' || c == -1;
    }

    public interface SpaceCharFilter {
      public boolean isSpaceChar(int ch);
    }
  }
}


Measured memory_bytes: 20820
from collections import defaultdict
MOD = 10**9+7
n = int(input())

basis = ['A', 'C', 'G', 'T']
cands = {}
for i in basis:
    for j in basis:
        for k in basis:
            ijk = i+j+k
            if ijk in ['AGC', 'GAC', 'ACG']:
                cands[ijk] = 0
            else:
                cands[ijk] = 1
for i in range(3, n):
    cands_tmp = {ijk:0 for ijk in cands.keys()}
    for k, v in cands.items():
        for l in basis:
            k_new = k+l
            if k_new[1:] in ['AGC', 'GAC', 'ACG']:
                pass
            elif k_new[0] == 'A' and 'G' in k_new[1:3] and k_new[3] == 'C':
                pass
            else:
               cands_tmp[k_new[1:]] += v
               cands_tmp[k_new[1:]] %= MOD
    cands = cands_tmp
    
print(sum(cands.values())%MOD)

Measured memory_bytes: 3316
#include <stdio.h>

int main(void) {
    int m,f,r,m1,f1,r1;
    while(1){
        scanf("%d %d %d", &m1,&f1,&r1);
        if(m1==-1&&f1==-1&&r1==-1)
        break;
        if(m1==-1){
            m=0;
        }else{
            m = m1;
        }
        if(f1==-1){
            f=0;
        }else{
            f = f1;
        }
        if(r1==-1){
            r=0;
        }else{
            r = r1;
        }
        
        if((m+f)>=80){
            printf("A\n");
        }
        if((m+f)<80 && (m+f)>=65 && m1!=-1 && f1!=-1){
            printf("B\n");
        }
        if((m+f)<65 && (m+f)>=50 && m1!=-1 && f1!=-1){
            printf("C\n");
        }
        if((m+f)<50 && (m+f)>=30 && m1!=-1 && f1!=-1){
            if(r>=50){
                printf("C\n");
            }else{
            printf("D\n");
            }
        }
        if((m+f)<30 || m1==-1 || f1==-1){
            printf("F\n");
        }
    }
    
    return 0;
}

Measured memory_bytes: 584
#include <bits/stdc++.h>
#define cout16 cout << setprecision(16) 
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using P = std::pair<int,int>;
using vp = std::vector<P>;
using namespace std;
#define INF 1001001001
#define LL_INF 1001001001001001001
#define fi first
#define se second

int main(void) {
	int n; cin >> n;
	string s; cin >> s;
	vll a(3,0);
	rep(i,n){
		if(s[i]=='R') a[0]++;
		if(s[i]=='G') a[1]++;
		if(s[i]=='B') a[2]++;
	}
	ll ans = a[0]*a[1]*a[2];
	for(int l=1; l<n; l++){
		for(int i=0; i<n-l*2; i++){
			int j = i+l;
			int k = j+l;
			vi b(3,0);
			if(s[i]=='R') b[0]++;
			if(s[i]=='G') b[1]++;
			if(s[i]=='B') b[2]++;
			if(s[j]=='R') b[0]++;
			if(s[j]=='G') b[1]++;
			if(s[j]=='B') b[2]++;
			if(s[k]=='R') b[0]++;
			if(s[k]=='G') b[1]++;
			if(s[k]=='B') b[2]++;
			if(b[0]==1&&b[1]==1&&b[2]==1) ans--;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
# define ll int64_t
#define rep(i,n) for(ll i=0;i<n;i++)
#define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007

using namespace std;

bool compare_by_b(pair<string,ll> a,pair<string,ll> b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

bool my_compare(pair<string,ll> a,pair<string,ll> b){
    
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

int main(){
    ll a,b,c;
    cin>>a>>b>>c;
    if(c-a-b<=0) {
        cout<<"No"<<endl;
        return 0;
    }
    
    ll d=(c-a-b)*(c-a-b);
    if(4*a*b<d) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
#define mod 200003
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//(a+b-1)/b
//priority_queue<ll, vector<ll>, greater<ll>> q;
using pl = pair<ll,ll>;
using vvb=vector<vector<bool>>;
using vb= vector<bool>;
ll f(ll a,ll b,ll p){
	if(b==0) return 1;
	if(b%2==0){
		ll t=f(a,b/2,p);
		return t*t%p;
	}
	return a*(f(a,b-1,p))%p;
} 

//__builtin_popcount()
signed main(){
	ll n, m, k; cin>>n>>m>>k;
	bool ok=0;
	rep(i,0,n+1){
		rep(j,0,m+1){
			if(j*(n-i)+i*(m-j)==k)ok=1;
		}
	}
	cout<<(ok ? "Yes":"No")<<endl;


	return 0;
}

Measured memory_bytes: 3640
#include <iostream>

using namespace std;

int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    int x=0 , max=0;
    for (int i=0 ; i<n ; i++){

        if(s[i]=='I'){
            x++;
            if(x>max)
                max=x;
            }else if (s[i]=='D'){
            x--;
            }
    }
    cout << max<< endl;
    return 0;
}


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

int main(){
  int n,m;
  int *a;
  char buff[1000000];

  // data loading
  if(fgets(buff,sizeof(buff),stdin)!=NULL){
    sscanf(buff,"%d%d",&n,&m);
  }

  a = (int *)malloc(sizeof(int)*n);
  if(fgets(buff,sizeof(buff),stdin)!=NULL){
    int i;
    char *temp;
    char space[] = " ";
    temp = strtok(buff,space);
    for(i=0;i<n;i++){
      a[i] = atoi(temp);
      temp = strtok(NULL,space);
    }
  }

  // calculation
  int vote_all = 0;
  int i = 0;
  for(i=0;i<n;i++){
    vote_all += a[i];
  }
  int pop_n = 0;
  for(i=0;i<n;i++){
    if(a[i] >= vote_all / (4.0*m)){
      pop_n += 1;
    }
  }

  //print result
  if(pop_n >= m){
    printf("Yes");
    return 0;
  }else{
    printf("No");
    return 0;
  }

}


Measured memory_bytes: 128
fun main(args: Array<String>) {
    val n = readLine()?.toInt() ?: return
    val x = readLine()?.split(" ")?.map(String::toInt) ?: return

    val min = x.min() ?: return
    val max = x.max() ?: return

    val total = min.until(max + 1).map { p ->
        x.sumBy {
            Math.pow((it - p).toDouble(), 2.0).toInt()
        }
    }.min() ?: return
    println(total)
}

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

int main() {
  int n, k, q;
  cin >> n >> k >> q;
  int score[n] = {};
  int seikai;
  rep(i,q) {
    cin >> seikai;
    score[seikai-1]++;
  }
  rep(i,n) {
    if (k-q+score[i] > 0) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
  return 0;
}

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

int main()
{
    ll N, M, K;
    cin >> N >> M >> K;
    vector<ll> A(N), B(M);
    rep(i, N) cin >> A[i];
    rep(i, M) cin >> B[i];

    vector<ll> As(N + 1, 0), Bs(M + 1, 0);
    rep(i, N) As[i + 1] = As[i] + A[i];
    rep(i, M) Bs[i + 1] = Bs[i] + B[i];

    int b = M;
    int ans = 0;

    rep(a, N + 1)
    {
        if (As[a] > K)
            break;
        while (As[a] + Bs[b] > K)
        {
            b--;
        }
        ans = max(ans, a + b);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 9600
from collections import Counter
mod=998244353
n=int(input())
d=list(map(int,input().split()))
q=Counter(d)
if q[0]!=1 or d[0]!=0:
	print(0)
	exit()
ans=1
for i in range(1,max(d)+1):
    ans*=pow(q[i-1],q[i],mod)
    ans%=mod
print(ans)

Measured memory_bytes: 19936
#include<bits/stdc++.h>
#define ll long long
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define per(i,n,a) for(int i=n;i>=a;i--)
#define endl '\n'
#define mem(a,b) memset(a,b,sizeof(a))
#define IO ios::sync_with_stdio(false);cin.tie(0);
using namespace std;
const int INF=0x3f3f3f3f;
const ll inf=0x3f3f3f3f3f3f3f3f;
const int mod=1e9+7;
const int maxn=1e5+5;
int main(){
	double x;cin>>x;
	double now=100.0;
	ll cnt=0;
	while(now<x){
		now=now+floor((now)*0.01);
		cnt+=1;
	}
	cout<<cnt<<endl;
}


Measured memory_bytes: 3724
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	ll x, y, ans = 0;

	cin >> x >> y;

	if (x * y == 0) ans = x < y ? abs(x - y) : abs(x - y) + 1;
	else if (x * y < 0) ans = 1 + abs(x + y);
	else if (x <= y) ans = y - x;
	else ans = x - y + 2;

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;

public class Main {

	public static void main(String[] args) {

        try {
            BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
            String inputData = reader.readLine();
			String[] strNumber = inputData.split(" ");
			int a = Integer.parseInt(strNumber[0]);
			int b = Integer.parseInt(strNumber[1]);
			BigDecimal bdA = new BigDecimal(a);
			BigDecimal bdB = new BigDecimal(b);

			int d = a / b;
			int r = a % b;
			BigDecimal bdDivide = bdA.divide(bdB , 8 , BigDecimal.ROUND_HALF_UP).setScale(8, BigDecimal.ROUND_FLOOR);

            System.out.println(d + " " + r + " " + bdDivide.toPlainString());

        } catch (IOException e) {
            e.printStackTrace();
        }


	}

}

Measured memory_bytes: 24352
#include <cstdio>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

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

using ll = long long;

ll N;

int main()
{
  scanf( "%lld", &N );

  printf( "%lld\n", N%2?2*N:N );

  return 0;
}

Measured memory_bytes: 128
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

// 数字の和
func main() {
	sc := bufio.NewScanner(os.Stdin)
	s := ""
	for {
		sc.Scan()
		str := sc.Text()
		if str == "0" {
			break
		}
		sum := 0
		for _, v := range str {
			n, err := strconv.Atoi(string(v))
			if err != nil {
				continue
			}
			sum += n
		}
		s += fmt.Sprintf("%v\n", sum)
	}
	fmt.Print(s)
}



Measured memory_bytes: 1160
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define REP(i, n) for (int i = 0; i < (n); i++)
 
using namespace std;
 
int main() {
  long long x;
  int a, b, c;
  cin >> a >> b >> c;
  x = a * c - b;
  for (int i = 0; i < 9; i++) {
    cout << x << endl;
    x = a * x - b;
  }
  cout << x;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,ll>
const ll MOD=998244353;
const int INF=1e9;
const double PI=acos(-1);


int main() {
    ios_base::sync_with_stdio(false);

    int a,b,c;
    cin >> a >> b >> c;
    cout << min(c,b/a) << endl;
    return 0;

}


Measured memory_bytes: 3624
while True:
    [n, x] = [int(item) for item in input().split()]
    if n==0 and x==0:exit()
    returnList=[]
    cnt = 0
    for i in range(1,n+1):
        for j in range(1,i):
            k = x - i - j
            if k <j and k>0:
                returnList.append(sorted([i,j,k]))
                #print("i,j,k={},{},{}".format(i,j,k))
                #print("returnSet = {}".format(returnList))
    print(len(returnList))


Measured memory_bytes: 5728
import sys
input = sys.stdin.readline


N=int(input())

ANS=[0]*(10**5+1)

for x in range(1,10**2+1):
    for y in range(1,10**2+1):
        for z in range(1,10**2+1):
            ANS[x*x+y*y+z*z+x*y+y*z+z*x]+=1

print(*ANS[1:N+1])


Measured memory_bytes: 10012
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using P = pair<int,int>;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
const ll INF = 1LL<<60;




int main()
{
    ll A;
    double B;
    cin >> A >> B;
    ll C = B * 100 + 0.1;
    ll ans = A*C/100;
    cout << ans << endl;

    return 0;
}
//Ctrl+Shift+Bでコンパイルと実行を行ってデバッグすること

Measured memory_bytes: 3688
X,N=map(int,input().split())
A = list(map(int, input().split()))
def me(X,A,p):
    if X-p in A:
        if X+p in A:
            return me(X,A,p+1)
        else:
            print(X+p)
    else:
        print(X-p)
if X in A:
    me(X,A,1)
else:
    print(X)

Measured memory_bytes: 61932
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <string>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)


int main(){
	char st[500];
	int i = 0;
	//cout<<"hoge";
	for(int i = 0;;i++){
		scanf("%c",&st[i]);
		if(st[i] == -1){
			break;
		}
	}
	//cin >> st;
	
	rep(i,20){
		//printf("%c %d\n",st[i],st[i]);
	}
	//printf("a = %d z = %d A = %d Z = %Z\n",'a','z','A','z');
	i = 0;
	while(st[i]!=-1){
		//printf("st[%d] = %d\n",i,st[i]);
		if(st[i]<='z'&&st[i]>='a'){
			//cout<<"before "<<st[i]<<endl;
			
			st[i]+=-'a'+'A';
			//cout<<"after "<<st[i]<<endl;
		}
		i++;
	}
	//cout<< st << endl;
		printf("%s",st);
	
	 return 0;
}

Measured memory_bytes: 1136
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<set>
#include<cmath>
#include<queue>
#include<unordered_map>
#include<map>
#include<stack>
#include<bits/stdc++.h>
#include<string.h>
#include <ext/pb_ds/assoc_container.hpp>
#define FASTIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
//#define f first
//#define s second
#define respr(fir,sec) for(int i=0;i<=fir;i++){for(int j=0;j<=sec;j++){cout << res[i][j] << " ";}cout << "\n";}
#define pb push_back
//#define INF (1LL<<31)
using namespace std;
using namespace __gnu_pbds;
const int mod = 1e9+7;
const ll MAX = 1000000000000000000;
typedef pair<int,ll> pii;
typedef pair<ll,int> pi;
typedef tuple<long long,int> tp;
typedef tuple<int,int,long long> tu;
typedef multimap<pii , int> mpp;
typedef priority_queue< tp , vector<tp>, greater<tp>>  minheap;
typedef priority_queue<pii , vector<pii>> maxheap;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update>  new_data_set;
const int nax=100005;
vector<int> graph[nax];
int res[nax];
bool visited[nax];
int indegree[nax];
int ans=0;


void dfs(int s){
	
	visited[s]=true;
	for(int v: graph[s]){
		res[v] = max(res[v], res[s]+1);
		--indegree[v];
		if(indegree[v]==0)
			dfs(v);
	}
}


int main()
{
	FASTIO;
	int n,m;
	cin >> n >> m;
	int x,y;
	for(int i=0;i<m;i++)
	{
		cin >> x >> y;
		indegree[y]++;
		graph[x].push_back(y);
	}
	for(int i=1;i<=n;i++){
		if(!indegree[i] && !visited[i]){
			dfs(i);
		}
	}
	for(int i=1;i<=n;i++)
		ans = max(ans, res[i]);
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 9728
#include <iostream>
#include <algorithm>
#include <string>
#include <cstdlib>
#include <set>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <cctype>
using namespace std;
int main()
{
	int n;
	while(scanf("%d", &n) != EOF)
	{
		long long k = 1, i;
		for(i = 1; i <= n; i++)
			k = (k * i) % 1000000007;
		printf("%I64d\n", k);
	}
	return 0;
}

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

using namespace std;

const int N = 1e5+10;

int a[N];

int main(void)
{
	int n;
	cin >> n;
	for(int i = 0; i < n; ++i) cin >> a[i];
	int L = 0, R = 0, ans = 0;
	while(R < n) {
		while(R+1 < n && a[R] >= a[R+1]) {
			R++;
		}
		int len = R-L;
		ans = max(ans, len);
		L = R+1; R++;
	}
	cout << ans << endl; 
	return 0;
 } 

Measured memory_bytes: 640
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(tin())
mod=1000000007

#+++++

def conv(bb, n):
	ret = 1
	for i in range(bb-n+1, bb+1):
		ret *= i
	for i in range(1, n+1):
		ret //= i
	return ret

def main():
	#a = int(input())
	n, a, b = tin()
	#s = input()
	al = lin()
	al.sort(reverse=True)
	bb = sum(al[:a])/a
	print(bb)
	
	min_use = al[a]
	rrc = al.count(min_use)
	if al[0] == min_use:
		ret = 0
		for n in range(a, min(b, rrc)+1):
			ret += conv(rrc, n)
		print(ret)
		return 
	else:
		rr = [v for v in al if v >= min_use]
		zettai=len(rr)-rrc
		nokori = a- zettai
		n_pattern = conv(rrc, nokori)
		print(n_pattern)
		return
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 39024
import java.io.*;

class Main {
    private static int num;
    private static int[] data;

    public static void main(String[] args) {
        dataSet();

        long min = arrayMin(data);
        long max = arrayMax(data);
        long sum = arraySum(data);

        System.out.println(min + " " + max + " " + sum);
    }

    static void dataSet() {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

        try {
            String numString = reader.readLine();
            String[] dataString = reader.readLine().split(" ");

            num = Integer.parseInt(numString);

            data = new int[num];
            for (int i = 0; i < num; i++) {
                data[i] = Integer.parseInt(dataString[i]);
            }
        } catch (NumberFormatException e) {
            System.out.println(e);
        } catch (IOException e) {
            System.out.println(e);
        }
    }

    static long arrayMin(int[] data) {
        long min = Long.MAX_VALUE;
        for (int i = 0; i < data.length; i++) {
            min = Math.min(min, data[i]);
        }
        return min;
    }

    static long arrayMax(int[] data) {
        long max = Long.MIN_VALUE;
        for (int i = 0; i < data.length; i++) {
            max = Math.max(max, data[i]);
        }
        return max;
    }

    static long arraySum(int[] data) {
        long sum = 0;
        for (int i = 0; i < num; i++) {
            sum += data[i];
        }
        return sum;
    }
}

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

int main() {
	int a,b;
	while(cin>>a>>b){
	int gcd=a,lcm=b,sto;;
	while(lcm!=0)
	{
		sto=lcm;
		lcm=gcd%lcm;
		gcd=sto;
	}
	cout<<gcd<<" "<<(a/gcd)*b<<endl;}
	return 0;
}

Measured memory_bytes: 3076
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define mt make_tuple
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
#define vi vector<int>

using ll = long long;
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-8;
const ll DIV =1e9+7;
//const double PI = M_PI;
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}
inline ll lcm(ll d1, ll d2){return d1 / __gcd(d1, d2) * d2;}
inline ll inv(ll x, ll div){return pow(x, div - 2, div);}
#define chmax(a,b) a=max(a,b)
int gcj_out_cnt = 1;
#define gcj_put cout<<"Case #"<<gcj_out_cnt++<<": ";

/*Coding Space*/

int main(){
  int h,m,hh,mm,k; cin >> h >> m >> hh >> mm >> k;
  if(hh < h) hh += 24;
  cout << (-h*60-m+hh*60+mm-k) << endl;
}


Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
const int M=1e9+7;
long long s,k,x,a[2002][2002];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    for(int i=0; i<=2000; i++) a[i][0]=1;
    for(int i=1; i<=2000; i++){
        for(int j=1; j<=i; j++){
            a[i][j] = a[i-1][j]+a[i-1][j-1];
            if(a[i][j]>=M) a[i][j]-=M;
        }
    }
    cin >> s;
    for(int i=1; i<=s/3; i++){
        k = s-3*i;
        x += a[i+k-1][k];
        if(x>M) x-=M;
    }
    cout << x;
    return 0;
}

Measured memory_bytes: 26272
#include <stdio.h>

int main(void){
char op;
int a,b;
//cin >> 1 >> 2 >> 3;
while(1){
scanf("%d %c %d",&a,&op,&b);
if(op=='?')break;
if(op=='+'){
printf("%d\n",a+b);
}else if(op=='-'){
printf("%d\n",a-b);
}else if(op=='*'){
printf("%d\n",a*b);
}else{
printf("%d\n",a/b); 
}
}
}





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

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

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

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

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

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

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

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

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

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

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: usize,
        k: usize,
        v: [i64; n]
    }
    let mut ac = vec![0; n + 1];
    let mut ac2 = vec![0; n + 1];
    for i in 0..n {
        ac[i + 1] = ac[i] + v[i];
        ac2[i + 1] = ac2[i] + if v[i] > 0 {v[i]} else {0};
    }
    let mut ans = 0;
    for i in 0..n - k + 1 {
        ans = max(ans, ac2[i] + ac[i + k] - ac[i] + ac2[n] - ac2[i + k]);
        ans = max(ans, ac2[i] + ac2[n] - ac2[i + k]);
    }
    println!("{}", ans);
}


Measured memory_bytes: 6396
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String result = "No";
        int zoroCount = 0;
        for (int i = 0; i < n; i++) {
            int d1 = sc.nextInt();
            int d2 = sc.nextInt();
            if (d1 == d2) {
                zoroCount++;
            } else {
                zoroCount = 0;
            }
            if (zoroCount >= 3) {
                result = "Yes";
            }

        }
        System.out.println(result);

    }
}

Measured memory_bytes: 35988
input_list = list(map(int, input().split()))
a = input_list[0]
b = input_list[1]
taps = 0
count = 0
if b == 1:
    print(count)
else:
    taps += a
    count += 1
    while taps < b:
        taps += a-1
        count += 1
    print(count)

Measured memory_bytes: 38256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
#define ld long double
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x))//memset only use to initialize 0 or -1 no other number.
#define pii pair<int,int>
#define pll pair<ll,ll>
#define INF 1e9
#define INFL 1e18
#define mod 1000000007
//#define mod 998244353
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
using namespace __gnu_pbds; 
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> os;
typedef tree<pii,null_type,less<pii>,rb_tree_tag,tree_order_statistics_node_update> os_pair;

ll power(ll x,ll n){ll res =1;while(n>0){if(n%2==1){res=res*x;}x=x*x;n=n/2;}return res;}
ll powm(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}

//cout<< fixed << setprecision(10)


int main(){

    fast;
    int n,i,j;
    cin>>n;
    string s;
    cin>>s;
    int w[n+1]={0},r[n+1]={0};
    for(i=1;i<=n;i++)
    {
    	if(s[i-1]=='W')
    	{
    		w[i]=w[i-1]+1;
    		r[i]=r[i-1];
		}
		else
		{
			w[i]=w[i-1];
			r[i]=r[i-1]+1;
		}
	}
	if(w[n]==n||w[n]==0)
	{
		cout<<0;
		return 0;
	}
	int ans=n+1;
	int x=r[n];
	ans=min(w[x],ans);
	cout<<ans;
	
	
    

}

Measured memory_bytes: 5332
#include <cstdio>
using namespace std ;
const int MAXN = 1e5 + 10 ;
int n , a[MAXN] , cnt[MAXN] , sum[1 << 16] , f[1 << 16] , ans , t ;
int min (int a , int b) {
	return a < b ? a : b ;
}
int main () {
	scanf ("%d" , &n) ;
	for (int i = 1 ; i < n ; i++) {
		int u , v , w ;
		scanf ("%d %d %d" , &u , &v , &w) ;
		a[u] ^= w ; a[v] ^= w ;
	}
	for (int i = 0 ; i < n ; i++) cnt[a[i]]++ ;
	for (int i = 1 ; i < 16 ; i++) {
		ans += (cnt[i] >> 1) ;
		if (cnt[i] & 1) t |= (1 << (i - 1)) ;
	}
	for (int i = 1 ; i < (1 << 15) ; i++)
		f[i] = f[i >> 1] + (i & 1) ;
	for (int i = 1 ; i < (1 << 15) ; i++) f[i]-- ;
	for (int i = 1 ; i < (1 << 15) ; i++)
		for (int j = 0 ; j < 15 ; j++)
			if (i & (1 << j)) 
				sum[i] ^= (j + 1) ;
	for (int i = 1 ; i < (1 << 15) ; i++)
		if (!sum[i])
			for (int j = (i - 1) & i ; j ; j = (j - 1) & i)
				if (!sum[j])
					f[i] = min (f[i] , f[j] + f[i ^ j]) ;
	printf ("%d\n" , ans + f[t]) ;
	return 0 ;
}

Measured memory_bytes: 2392
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <cctype>
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const ll INFLL = 1001001001001001001;  // > 10^18
const int MOD = (int)1e9 + 7;
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;


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

    cout << 3*r*r << endl;

    return 0;

}




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

#define ll long long
#define ld long double
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())

const int MAX = 3 * (1e6 + 5) + 5;
const int MOD = 1000000007;

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

// テーブルを作る前処理
void COMinit()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(int n, int k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return (fac[n] * (finv[k] * finv[n - k] % MOD)) % MOD;
}

int main()
{
    int x, y;
    cin >> x >> y;

    if ((x + y) % 3 != 0)
    {
        cout << "0" << endl;
        return 0;
    }

    int k = x - (x + y) / 3;
    int l = y - (x + y) / 3;

    COMinit();
    //combination(n, r);
    //cout << f[n] << " " << f[r] << " " << f[n - r] << endl;
    cout << COM(k + l, k) << endl;
    return 0;
}

Measured memory_bytes: 70528
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**6)
INF = 10 ** 9 + 1  # sys.maxsize # float("inf")
MOD = 10 ** 9 + 7


def floor_sum_1(n, m, a, b):
    ret = 0
    if a >= m:
        ret += (n - 1) * n * (a // m) // 2
        a %= m
    if b >= m:
        ret += n * (b // m)
        b %= m
    y_max = (a * n + b) // m
    x_max = y_max * m - b
    if y_max == 0:
        return ret
    ret += (n - (x_max + a - 1) // a) * y_max
    ret += floor_sum(y_max, a, m, (a - x_max % a) % a)
    return ret


def floor_sum(n, m, a, b):
    ret = 0
    while True:
        if a >= m:
            ret += (a // m) * (n - 1) * n // 2
            a %= m
        if b >= m:
            ret += n * (b // m)
            b %= m
        if a * n + b < m:
            return ret
        y_max = (a * n + b) // m
        x_max = y_max * m - b
        ret += (n - (x_max + a - 1) // a) * y_max
        n = y_max
        m, a, b = a, m, -x_max % a


def debug(*x):
    print(*x, file=sys.stderr)


def solve(SOLVE_PARAMS):
    pass


def main():
    # parse input
    T = int(input())
    for _t in range(T):
        N, M, A, B = map(int, input().split())
        print(floor_sum(N, M, A, B))


# tests
T1 = """
5
4 10 6 3
6 5 4 3
1 1 0 0
31415 92653 58979 32384
1000000000 1000000000 999999999 999999999
"""
TEST_T1 = """
>>> as_input(T1)
>>> main()
3
13
0
314095480
499999999500000000
"""


def _test():
    import doctest
    doctest.testmod()
    g = globals()
    for k in sorted(g):
        if k.startswith("TEST_"):
            doctest.run_docstring_examples(g[k], g, name=k)


def as_input(s):
    "use in test, use given string as input file"
    import io
    f = io.StringIO(s.strip())
    g = globals()
    g["input"] = lambda: bytes(f.readline(), "ascii")
    g["read"] = lambda: bytes(f.read(), "ascii")


input = sys.stdin.buffer.readline
read = sys.stdin.buffer.read

if sys.argv[-1] == "-t":
    print("testing")
    _test()
    sys.exit()

main()


Measured memory_bytes: 70160
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, n) for (ll i = 0; i < n; i++)
#define REPR(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define FORR(i, m, n) for (ll i = m; i >= n; i--)
#define REPO(i, n) for (ll i = 1; i <= n; i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(), n.end()
#define MOD 1000000007
#define P pair<ll, ll>


int main() {
    ll a;
    cin >> a;
    cout << (a >= 30 ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#ifndef ONLINE_JUDGE
#include <custom/prettyprint.hpp>
#endif
using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef double db;
typedef string str;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef pair<db,db> pd;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<db> vd;
typedef vector<str> vs;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<pd> vpd;

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b) - 1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define rb(i,x) for (auto& i : x)
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define UNIQUE(x) (x).resize(unique(all(x)) - begin(x))
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define F first
#define S second
#define pow10(n) stoll("1"+string(n,'0'))
#define dbg(x) cout << ">>> " << #x << ": " << x << '\n'

const int MOD = 1e9+7; //998244353
const int inf = 1e9+3;
const ll INF = ll(3e18)+3;
const ld PI = acos((ld)-1);
const int dx[8] = {1,0,-1,0,1,1,-1,-1}, dy[8] = {0,1,0,-1,-1,1,1,-1};
mt19937_64 rng((uint64_t)chrono::steady_clock::now().time_since_epoch().count());
ll rnd(ll n) { return uniform_int_distribution<ll>(0, n)(rng); }
template<class T> bool ckmin(T& a, const T& b) { 
	return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) {
	return a < b ? a = b, 1 : 0; }
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
template <class T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; 

void setIO(const string& s) {
	ios_base::sync_with_stdio(false); cin.tie(nullptr);
#ifndef ONLINE_JUDGE
	freopen((s+".in").c_str(),"r",stdin);
//	freopen((s+".out").c_str(),"w",stdout);
#endif
}

int main() {
    
    setIO("input");
    int x; cin >> x;
    cout << (x >= 30 ? "Yes\n" : "No\n");
    
}

/*  ! CHECK THIS IF YOU GET IT WRONG !
	* int overflow, array bounds, NO VLAs
	* uninitialized local variables, rounding errors
	* intermediate result type, scientific
	* special cases (n = 0 or 1?)
	* reset your variables in scope
	* INF not large enough for ans, adding value to _MAX
	* using wrong variables, sorting extra 0s in global array
	* comment out input from file
	* operator precedence
*/

Measured memory_bytes: 3652
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int n,num=0,index=0;
	cin>>n;
    int kn[n];
    string s[n+1],a="A",kind[n];
    for(int i=0;i<n;i++){
      cin>>s[i];
    }
    sort(s,s+n);
    s[n]="AA";
    a=s[0];
    for(int i=0;i<=n;i++){
      if(a!=s[i]){
        a=s[i];
        kind[index]=s[i-1];
        kn[index]=num;
        num=0;
        index+=1;
      }
      num++;
    }
    int max=0;
    for(int i=0;i<index;i++){
      if(max<kn[i])max=kn[i];
    }
    for(int i=0;i<index;i++){
      if(kn[i]==max){
        cout<<kind[i]<<"\n";
      }
    }
	return 0;
}

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

int main() {
	int N, M, C;
	cin >> N >> M >> C;
	vector<int> B(M);
	for (int i = 0; i < M; i++)cin >> B[i];

	int res = 0;
	for (int i = 0; i < N; i++) {
		int sum = C;
		for (int j = 0; j < M; j++) {
			int A; cin >> A;
			sum += A * B[j];
		}
		res += sum > 0;
	}
	cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<ll,pll> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int n;

int main(){
	cin>>n;
	cout<<syosu(9)<<(double)((n+1)/2)/n<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
int main() {
	string s, t;
	cin >> s >> t;
	int S = s.size(), T = t.size();
	if (S < T) {
		cout << "UNRESTORABLE" << endl;
		return 0;
	}
	for (int i = S - T; i >= 0; i--) {
		if (s[i] == t[0]||s[i]=='?') {
			bool f = 0;
			for (int j = 0; j < T; j++) {
				if (!(s[i + j] == t[j] || s[i + j] == '?')) {
					f = 1;
					break;
				}
			}
			if (!f) {
				for (int j = i; j < i + T; j++) {
					s[j] = t[j - i];
				}
				for (int j = 0; j < S; j++)if (s[j] == '?')s[j] = 'a';
				cout << s << endl;
				return 0;
			}
		}
	}
	cout << "UNRESTORABLE" << endl;
	return 0;
}


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

#define __STDC_FORMAT_MACROS
#define p64 PRId64

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR (i, 0, n)
#define ALL(f, x, ...)                                                         \
    ([&] (decltype ((x)) ALL) {                                                \
        return (f) (begin (ALL), end (ALL), ##__VA_ARGS__);                    \
    }) (x)

using namespace std;
using ll = int64_t;

int main() {
    int N;
    cin >> N;
    cout << floor ((N + 1) / 2) / N << endl;
    return 0;
}

Measured memory_bytes: 3756
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;


int main()
{
	char a,b;
	cin>>a>>b;
	if(a>b)cout<<">"<<endl;
	else if(a<b)cout<<"<"<<endl;
	else cout<<"="<<endl;
	return 0;
}

Measured memory_bytes: 256