akhauriyash/Code-Regression huggingface dataset:
n = int(input())
l = 0
r = 0
cntl = 0
cntr = 0
fl = 0
fr = 0
exl = 0
exr = 0
only_r = 0
only_l = 0
maxl = 0
maxr = 0
exlr = []
for i in range(n):
    s = input()
    templ = 0
    tempr = 0
    temp_exl = 0
    temp_exr = 0
    fl = 0
    fr = 0
    for i in s:
        if i == "(":
            tempr += 1
        elif i == ")":
            tempr -= 1
            if tempr < 0:
                tempr = 0
                templ += 1
                fl = 1
    temp_exl += templ
    if tempr > 0:
        temp_exr += tempr
        fr = 1
    if fl == 1 and fr == 0:
        only_l += temp_exl
    elif fr == 1 and fl == 0:
        only_r += temp_exr
    elif temp_exl + temp_exr > 0:
        exl += temp_exl
        exr += temp_exr
        exlr.append([temp_exl-temp_exr, temp_exl,temp_exr])
    # maxl = max(maxl,temp_exl)
    # maxr = max(maxr,temp_exr)
# print (exr,exl,only_r,only_l)
a = only_r
b = only_l
# print(exlr)
exlr.sort()
# exlr.sort(key=lambda x: x[1])

# print(exlr)
# for i in range(len(exlr)):
#     if exlr[i][1] <= a and exlr[i][0] <= 0:
#         a -= exlr[i][0]
#         exlr[i] = [0,0,0]
# print(exlr)
for i in exlr:
    a -= i[1]
    if a<0:
        print("No")
        exit()
    a += i[2]
if a-b == 0:
    print("Yes")
else:
    print("No")
# if exl+only_l == exr+only_r and exl-exr == only_r-only_l and only_l > 0 and only_r > 0:
#     print("Yes")
# elif exr+exl+only_l+only_r == 0:
#     print("Yes")
# else:
#     print("No")

    





Measured memory_bytes: 102428
#include <bits/stdc++.h>
#define rep(i,n) for (ll i=0; i<(n); i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    int x,y; cin >> x >> y;
    int xok;
    int yok;
    if (x==1 || x==3 || x==5 || x==7 || x==8 || x==10 ||x==12) xok=1;
    if (x==4 || x==6 || x==9 || x==11) xok=2;
    if (x==2) xok=3;
    
    if (y==1 || y==3 || y==5 || y==7 || y==8 || y==10 ||y==12) yok=1;
    if (y==4 || y==6 || y==9 || y==11) yok=2;
    if (y==2) yok=3;
    
    if (xok == yok) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
    
    
}

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

int main() {
	// your code goes here
	int n ;
	cin>>n ;
	int k = n%10 ;
	if(k==2 || k==4 || k==5 || k==7 || k==9  )
	cout<<"hon"<<endl ;
	else if (k==0 || k==1 || k==6 || k==8)
	cout<<"pon"<<endl ;
	else if (k==3)
	 cout<<"bon"<<endl ;
	return 0;
}


Measured memory_bytes: 3624
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main{
	public static void main(String[] args)throws Exception{
	
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line1 = br.readLine();
		String[] line2 = br.readLine().split(" ");
		StringBuilder sb = new StringBuilder();
		
		int n = Integer.parseInt(line1);
		int[] a = new int[n];
		
		int num = n;
		
		for(int i=0; i<n; i++){
			a[i] = Integer.parseInt(line2[num-1]);
			if((i == (n-1)) && (num == (n-i))){
				sb.append(a[i]+"\n");
			}	else{
				sb.append(a[i] +" ");
			}
			num--;
		}
		System.out.print(sb);
	}
}

Measured memory_bytes: 24304
#include <bits/stdc++.h>
using namespace std;
     
int main() {
  
  int N;
  cin >> N;
  
  vector<int> mons(N);
  for (int i = 0; i < N ;i++)
    cin >> mons.at(i);
  
  bool bol = true;
  while (bol){
  	sort( mons.begin() , mons.end() );
    vector<int> newMons;
    
    for ( int i = 0 ; i < mons.size() ; i++ ){
      if (i == 0){
        newMons.push_back(mons.at(i));
      }
      else if (mons.at(i) % mons.at(0) != 0){
        newMons.push_back(mons.at(i) % mons.at(0));
      }
    }
    
    mons = newMons;
    if (mons.size() == 1){
      cout << mons.at(0) << endl;
      break;
    }
  }
}

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

using namespace std;

bool StringToInt(string s, int &data)
{
	data=0;
	int sign=1;
	for(int i=0;i<s.length();i++){
		if(i==0 && s[i]=='-'){
            sign=-1;
            continue;
        }
		if('0'<=s[i] && s[i]<='9'){
			data*=10;
			data+=sign*(s[i]-'0');
		}
		else return false;
	}
	return true;
}

int main()
{
    string s;
    cin >> s;

    string y=s.substr(0,4);
    string m=s.substr(5,2);
    string d=s.substr(8,2);

    int yy;
    int mm;
    int dd;
    StringToInt(y,yy);
    StringToInt(m,mm);
    StringToInt(d,dd);

    if(yy<=2019){
        if(mm<=4){
            if(dd<=30) cout << "Heisei" << endl;
            else cout << "TBD" << endl;
        }
        else cout << "TBD" << endl;
    }
    else cout << "TBD" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,n,j) for(int i=(j);i<(n);++i)
#define ssort(n) sort((n).begin(),(n).end())
#define rsort(n) sort((n).begin(),(n).end(),greater<int>())
#define mp make_pair
using ll=long long;
using ld=long double;
typedef pair<int,int> P;
typedef pair<P,int> COST;
#define repl(i,n) for(ll i=0;i<(n);++i)
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
using Graf=vector<vector<ll>>;
#define MAX 1000000007
using ull=unsigned long long;

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

ull lcm(ull a,ull b)
{
    ull num=a/gcd(a,b);
    num*=b;
    return num;
}
int main()
{
    int n;
    cin >> n;
    vector<ull> t(n);
    rep(i,n)cin >> t[i];
    ull ans=1;
    rep(i,n){
        ans=lcm(ans,t[i]);
    }
    cout << ans << endl;
}

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

class Program {
    static int ReadInt() { return int.Parse(Console.ReadLine()); }
    static int[] ReadInts() { return Console.ReadLine().Split().Select(int.Parse).ToArray(); }
    static string[] ReadStrings() { return Console.ReadLine().Split(); }

    const int Sheep = 0;
    const int Wolf = 1;

    static bool Validate(int p, int[] xs, char reply) {
        int prev = (p - 1 + xs.Length) % xs.Length;
        int next = (p + 1) % xs.Length;

        if (xs[p] == Sheep) {
            return reply == 'o' ? xs[prev] == xs[next] : xs[prev] != xs[next];
        }
        else {
            return reply == 'o' ? xs[prev] != xs[next] : xs[prev] == xs[next];
        }
    }

    static bool Calc_1(int[] xs, string s) {

        Func<int, char, int, int> other = (animal, reply, prev) => {
            if (animal == Sheep) {
                return reply == 'o' ? prev : (prev ^ 1);
            }
            else { // Wolf
                return reply == 'o' ? (prev ^ 1) : prev;
            }
        };

        int n = s.Length;
        for (int i = 1; i < n - 1; i++) {
            int prev = xs[i - 1];
            xs[i + 1] = other(xs[i], s[i], prev);
        }

        var a = Validate(0, xs, s[0]);
        var b = Validate(n - 1, xs, s[n - 1]);
        var c = Validate(n - 2, xs, s[n - 2]);
        return a && b && c;
    }

    static void Calc(string s) {
        int n = s.Length;

        bool found = false;
        var xs = new int[n];
        for (int i = 0; i < (1 << 2); i++) {
            // (S, S), (S, W), (W, S), (W, W) の 4 パターン試す
            xs[0] = (i & 2) == 0 ? 0 : 1;
            xs[1] = i & 1;
            if (Calc_1(xs, s)) {
                Console.WriteLine(string.Join("", xs.Select(e => e == Sheep ? "S" : "W")));
                found = true;
                break;
            }
        }

        if (!found)
            Console.WriteLine(-1);
    }

    static void Main() {
        ReadInt();
        var s = Console.ReadLine();
        Calc(s);
    }
}

Measured memory_bytes: 12512
import std.algorithm;
import std.math;
import std.stdio;

struct Nums {
    int a, b, c;

    int sum() {
        return a + b + c;
    }
}

void main() {
    int k;
    Nums nums;
    with (nums) {
        readf("%d %d %d\n%d\n", &a, &b, &c, &k);
    }

    foreach (i; 0..k) {
        with (nums) {
            auto na = Nums(a * 2, b, c);
            auto nb = Nums(a, b * 2, c);
            auto nc = Nums(a, b, c * 2);
            auto m = max(na.sum, nb.sum, nc.sum);
            if (m == na.sum) {
                nums = na;
            } else if (m == nb.sum) {
                nums = nb;
            } else {
                nums = nc;
            }
        }
    }
    write(nums.sum);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	char b;
	cin>>b;
	if(b=='A')
		cout<<"T";
	if(b=='T')
		cout<<"A";
	if(b=='C')
		cout<<"G";
	if(b=='G')
		cout<<"C";
	return 0;
}

Measured memory_bytes: 256
// AOJ 1359: Wall Clocks
// 2018.1.22 bal4u@uu

#include <stdio.h>
#include <stdlib.h>

typedef struct { int f, t; } T;
T t[1001];

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

int cmp(T *a, T *b) { if (a->t-b->t) return a->t-b->t; return a->f-b->f; }

int main()
{
	int n, w, d, i, j, k, x, y, p1, p2, lim, ans;
	char f;

	n = in(), w = in(), d = in();
	lim = (w+d) << 1;
	for (i = 0; i < n; i++) {
		x = in(), y = in(), f = getchar_unlocked(), getchar_unlocked();
		if      (f == 'S') t[i].f = x-y,       t[i].t = x+y;
		else if (f == 'E') t[i].f = x+y,       t[i].t = 2*w+y-x;
		else if (f == 'N') t[i].f = 2*w+y-x,   t[i].t = lim-(x+y);
		else               t[i].f = lim-(x+y), t[i].t = lim+(x-y);
	}
	qsort(t, n, sizeof(T), cmp);

	ans = n;
	for (i = 0; i < n; i++) {
		p1 = t[i].t; if (p1 >= lim) p1 -= lim;
		p2 = -1, k = 1;
		for (j = 0; j < n; j++) if (i != j) {
			if (t[j].f <= p1 && p1 <= t[j].t) continue;
			if (t[j].f < 0) { if (lim+t[j].f <= p1) continue; }
			if (t[j].t > lim) { if (p1 <= (t[j].t-lim)) continue; }
			if (p2 < 0 || p2 < t[j].f || t[j].t < p2) p2 = t[j].t, k++;
		}
		if (k < ans) ans = k;
	}
	printf("%d\n", ans);
	return 0;
}



Measured memory_bytes: 2080
s = str(input())
tmp = [0,0]
for i in range(len(s)):
    if s[i] == 'A':
        tmp[0] = i
        break
for i in reversed(range(len(s))):
    if s[i] == 'Z':
        tmp[1] = i
        break

print(tmp[1]-tmp[0]+1)

Measured memory_bytes: 3516
#include <iostream>
#include <string>
using namespace std;
int Dice[6];

void roll(char c)
{
    int t;
    if (c == 'E')
    {
        t = Dice[2];
        Dice[2] = Dice[0];
        Dice[0] = Dice[3];
        Dice[3] = Dice[5];
        Dice[5] = t;
    }
    else if (c == 'W')
    {
        t = Dice[3];
        Dice[3] = Dice[0];
        Dice[0] = Dice[2];
        Dice[2] = Dice[5];
        Dice[5] = t;
    }
    else if (c == 'N')
    {
        t = Dice[4];
        Dice[4] = Dice[0];
        Dice[0] = Dice[1];
        Dice[1] = Dice[5];
        Dice[5] = t;
    }
    else if (c == 'S')
    {
        t = Dice[1];
        Dice[1] = Dice[0];
        Dice[0] = Dice[4];
        Dice[4] = Dice[5];
        Dice[5] = t;
    }
    else if (c == 'R')
    {
        t = Dice[2];
        Dice[2] = Dice[1];
        Dice[1] = Dice[3];
        Dice[3] = Dice[4];
        Dice[4] = t;
    }
}

int top()
{
    return Dice[0];
}

int front()
{
    return Dice[1];
}

int left()
{
    return Dice[3];
}

int right()
{
    return Dice[2];
}

int main()
{
    int n, t, f;
    for (int i = 0; i != 6; ++i)
    {
        cin >> Dice[i];
    }
    cin >> n;
    for (int i = 0; i != n; ++i)
    {
        cin >> t >> f;
        if (left() == t) roll('E');
        if (right() == t) roll('W');
        while (top() != t) roll('N');
        while (front() != f) roll('R');
        cout << right() << endl;
    }
    return 0;
}


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

int main() {
  int a,b;
  string op;
  while(true) {
      cin >> a >> op >> b;
  if(op=="+") cout << a+b << endl;
  else if (op=="-") cout << a-b << endl;
  else if (op=="*") cout << a*b << endl;
  else if (op=="/") cout << a/b << endl;
  else break;
  }
}


Measured memory_bytes: 3108
def elimrow(lst):
    lst_after = []
    gset = []
    H1 = len(lst)
    for i in range(H1):
        gset = list(set(lst[i]))
        gset.sort()
        #print(gset)
        if gset[0] != '.':
            lst_after.append(lst[i])
    return lst_after

def trans(lst):
    return list(zip(*lst))

def main():
    H,W = map(int,input().split())

    grid = [list(str(input())) for _ in range(H)]
    grid_after = []
    grid_after = elimrow(grid)
    gridT = trans(grid_after)
    grid_after2 = elimrow(gridT)
    gridT2 = trans(grid_after2)
    #print(gridT2)
    for i in gridT2:
        print(*i,sep='')

if __name__ == "__main__":
    main()

Measured memory_bytes: 9316
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    double x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    double d = sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));
    cout << fixed << setprecision(8) << d << "\n";
}

Measured memory_bytes: 3272
#include <iostream>
#include <algorithm>
#define flush fflush(stdout)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
const int mod = (int)1e9 + 7, INF = (int)1e9;
const int di[4] = { 1,0,-1,0 }, dj[4] = { 0,1,0,-1 };


int main(void) {
    int n, x, i, ans[200003] = {}, t;
    bool u[200003] = { false };

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

    if (x == 1 || x == n * 2 - 1) {
        printf("No\n");
        return 0;
    }

    printf("Yes\n");

    if (n == 2) {
        for (i = 0; i < n * 2 - 1; i++) {
            printf("%d\n", i + 1);
        }
        return 0;
    }

    ans[n] = x;
    u[x] = true;
    if (x == n * 2 - 2) {
        ans[n + 1] = n * 2 - 1;
        ans[n - 1] = 1;
        ans[n + 2] = 2;
        u[1] = u[2] = u[n * 2 - 1] = true;
    }
    else {
        ans[n + 1] = x - 1;
        ans[n - 1] = x + 1;
        ans[n + 2] = x + 2;
        u[x - 1] = u[x + 1] = u[x + 2] = true;
    }

    t = 1;
    for (i = 1; i <= n * 2 - 1; i++) {
        if (ans[i] == 0) {
            while (u[t]) {
                t++;
            }
            ans[i] = t;
            u[t] = true;
        }
    }

    for (i = 1; i <= n * 2 - 1; i++) {
        printf("%d\n", ans[i]);
    }

    return 0;
}

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

using namespace std;

#define reps(i,f,n) for(int i=f;i<int(n);i++)
#define rep(i,n) reps(i,0,n)

const int N = 1600;

int h,w;
int A[N];
int B[N];

void init(){

}

bool input(){
  cin>>h>>w;
  if(h==0)return 0;
  rep(i,h)cin>>A[i];
  rep(i,w)cin>>B[i];
  return true;
}


int solve(){
  int C[N]={0};
  int D[N]={0};
  rep(i,h){
    C[i+1] = C[i]+A[i];
  }
  rep(i,w){
    D[i+1] = D[i]+B[i];
  }

  map<int,int> sum;
  rep(i,h){
    reps(j,i,h){
      int s = C[j+1]-C[i];
      sum[s]++;
      // printf("s %d  %d\n",s,sum[s]);
    }
  }

  int ans = 0;
  rep(i,w){
    reps(j,i,w){
      int s = D[j+1]-D[i];
      ans += sum[s];
      // printf("g %d  %d\n",s,sum[s]);
    }
  }

  return ans;

}
int main(){
  while(init(),input())printf("%d\n",solve());
}

Measured memory_bytes: 19040
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int n, m, q;
vector<int> a, b, c, d;

int dfs(int num, vector<int> &res) {
  if (num == n) {
    int sum = 0;
    rep(i, q) {
      if (res[b[i]]-res[a[i]] == c[i])
        sum += d[i];
    }
    return sum;
  }
  int l;
  if (res.size())
    l = res.back();
  else
    l = 1;
  int mx = -INF;
  for (int i = l; i <= m; i++) {
    res.push_back(i);
    chmax(mx, dfs(num+1, res));
    res.pop_back();
  }
  return mx;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m >> q;
  a.resize(q);
  b.resize(q);
  c.resize(q);
  d.resize(q);
  rep(i, q) {
    cin >> a[i] >> b[i] >> c[i] >> d[i];
    --a[i], --b[i];
  }
  vector<int> res;
  int ans = dfs(0, res);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3660
#include <iostream>

using namespace std;

int main()
{
	int a[5];
	for (int i = 0; i < 5; i++)
		cin >> a[i];
	int k;
	cin >> k;

	if ((a[4] - a[0]) <= k)
		cout << "Yay!" << endl;
	else
		cout << ":(" << endl;

	return 0;
}

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

using namespace std;
const int N=20;
const int INF=1e9+7;
struct stu{
	int weight;
	int A[20];
}arr[20];
int money[N];
int n,m,x1;
//int now[N]; 
int ans=INF;
void dfs(int x,int now[],int w){
	if(x==n) { 
		bool flag=0;
		for(int i=1;i<=m;i++){
			if(now[i]<x1) flag=1; 
//			if(w==70){
//				cout<<now[i]<<endl;
//			}
		}
		if(flag) return ;
		ans=min(ans,w); 
		return ;
	}
	for(int i=1;i<=m;i++) now[i]+=arr[x].A[i];
	dfs(x+1,now,w+arr[x].weight);
	for(int i=1;i<=m;i++) now[i]-=arr[x].A[i];
	dfs(x+1,now,w);
}
int main(){ 
	cin>>n>>m>>x1;
	for(int i=0;i<n;i++){
		cin>>arr[i].weight;
		for(int j=1;j<=m;j++) cin>>arr[i].A[j];
	}
	dfs(0,money,0);
    if(ans==INF) cout<<-1<<endl;
	else cout<<ans<<endl; 
	return 0;
} 

Measured memory_bytes: 3580
A,B=map(int,input().split())
if (A/0.08)%1==0.0:
    a1=int(A/0.08)
else:
    a1=int(A/0.08)+1
if ((A+1)/0.08)%1!=0.0:
    a2=int((A+1)/0.08)
else:
    a2=int((A+1)/0.08)-1

if (B/0.1)%1==0.0:
    b1=int(B/0.1)
else:
    b1=int(B/0.08)+1
if ((B+1)/0.1)%1!=0.0:
    b2=int((B+1)/0.1)
else:
    b2=int((B+1)/0.1)-1

a=[]
b=[]
for i in range(a1,a2+1):
    s=i
    a.append(s)
for i in range(b1,b2+1):
    t=i
    b.append(t)
#print(a)
#print(b)
if max(a)<min(b):
    print(-1)
elif max(b)<min(a):
    print(-1)
elif min(a)>=min(b):
    print(min(a))
else:
    print(min(b))

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

using namespace std;

int main(){
    int n_turn;
    string a_card,b_card;
    int a_score = 0 ,b_score = 0;
    
    cin >> n_turn;
    for(int i = 0;i < n_turn;i++){
        cin >> a_card >> b_card;
        if ( a_card == b_card ) {
            a_score++;
            b_score++;
        }
        else if ( a_card < b_card ) b_score+=3;
        else if ( a_card > b_card ) a_score+=3;
    }
    
    cout << a_score << " " << b_score << "\n"; 
    return 0;
}


Measured memory_bytes: 3156
import java.util.Scanner;

class Main{
    static Scanner sc =new Scanner(System.in);
    public static void main(String args[]){
        int k=sc.nextInt();
        int ans=0;
        for(int i=1;i<=k;i++){
            for(int j=1;j<=k;j++){
                if(i%2==0&&j%2==1){
                    ans++;
                }
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 23892
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();
		String[] sArray = s.split(" ");

		int five  = 0;
		int seven = 0;

		for(int i=0; i<3; i++) {
			if(sArray[i].equals("5")) {
				five++;
			}else if(sArray[i].equals("7")){
				seven++;
			}
		}

		//結果表示
		if(five == 2 && seven == 1) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}

}


Measured memory_bytes: 20692
#include <cstdio>

using namespace std;

using int64 = long long;

class Combination {
 public:
  constexpr Combination() { Build(); }
  static constexpr int mod_ = 1000000007;
  static constexpr int n_ = 800000;
  class LookupTable {
   public:
    int64 factorial_[n_];
    int64 inverse_[n_];
    int64 finverse_[n_];
  };
  LookupTable lt{};
  // return nCk
  constexpr int64 Get(int n, int k) const noexcept {
    if (n < k || n < 0 || k < 0) return 0;
    return lt.factorial_[n] * (lt.finverse_[k] * lt.finverse_[n - k] % mod_) %
           mod_;
  }

 private:
  constexpr void Build() noexcept {
    lt.factorial_[0] = 1;
    lt.factorial_[1] = 1;
    lt.finverse_[0] = 1;
    lt.finverse_[1] = 1;
    lt.inverse_[1] = 1;
    for (int i = 2; i < n_; ++i) {
      lt.factorial_[i] = lt.factorial_[i - 1] * i % mod_;
      lt.inverse_[i] = mod_ - lt.inverse_[mod_ % i] * (mod_ / i) % mod_;
      lt.finverse_[i] = lt.finverse_[i - 1] * lt.inverse_[i] % mod_;
    }
  }
};

template<typename T> inline void fastin(T &num) {
  T c;
  num = 0;
  c = getchar_unlocked();
  for (; (c > 47 && c < 58); c = getchar_unlocked()) num = (num << 3) + (num << 1) + c - 48;
}

Combination com;

int main() {
  int x, y; fastin(x); fastin(y);

  if ((x + y) % 3 != 0) {
    printf("%d", 0);
    return 0;
  }
 
  int nn = (x + y) / 3;
  int r = x - nn;
 
  int64 ans = com.Get(nn, r);
  printf("%lld", ans);

  return 0;
}


Measured memory_bytes: 128
#include <cstdio>

int main()
{
    long N, cp[5]; // capacity
    int bn = 0; // bottle neck
    if (scanf("%ld", &N) == EOF) return -1;
    for (int i = 0; i < 5; i++) {
        if (scanf("%ld", &cp[i]) == EOF) return -1;
    }
    for (int i = 0; i < 5; i++) {
        bn = cp[bn] < cp[i] ? bn : i;
    }
    printf("%ld\n", N / cp[bn] + 5 - (N % cp[bn] == 0 ? 1 : 0));
}


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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};

int main()
{
    int x,y,ans=-1;
    cin>>x>>y;
    if(x%y!=0) ans=x;

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
 
typedef long long ll;

#define PB push_back
#define MP make_pair
#define F first
#define S second

template<typename T,typename U>
bool chmax(T& max, const U& x){
	if(max<x){
		max = x;
		return true;
	}
	return false;
}

template<typename T,typename U>
bool chmin(T& min, const U& x){
	if(min>x){
		min = x;
		return true;
	}
	return false;
}


int main(){
	 ll n,m,s=0;
  	cin >> n >> m;
  	for(ll i=0;i<m;i++){
    	ll tmp;
      	cin >> tmp;
      	s += tmp;
    }
  	if(n<s){
    	cout << -1 << endl;
    }else{
    	cout << n-s<< endl;;
    }
}

Measured memory_bytes: 3636
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <complex>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = int64_t;
using ull = uint64_t;
constexpr ll LL_MAX = numeric_limits<ll>::max();
constexpr ull ULL_MAX = numeric_limits<ull>::max();

template<typename T>
vector<T> make_vec_nd(T init, ll size) {
	return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, ll size, Args... rest) {
	auto inner = make_vec_nd(init, rest...);
	return vector<decltype(inner)>(size, inner);
}

#define rep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrep(i, a, b) for (ll i = (a)-1; i >= (b); i--)

int main() {
    string S;
    cin >> S;
    if (S == "ARC") {
        cout << "ABC" << endl;
    } else {
        cout << "ARC" << endl;
    }
}


Measured memory_bytes: 3020
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

string S;

int count (string S){
  if (S == "SSS") return 0;
  else if ((S == "RRS")||(S=="SRR"))return 2;
  else if (S =="RRR")return 3;
  else return 1;
}

int main(){
  
 cin>>S;
  int A ;
  A = count(S);
  cout <<A<<endl;
}

Measured memory_bytes: 3596
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int n = int.Parse(input[0]);
            int i = int.Parse(input[1]);

            int ans = n - i +1;

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 11092
#include<stdio.h>

int main(){
	int N;
	int ans=0;
	scanf("%d",&N);
	
	for(int i=573;i<=N;i+=20){
		int exist5=0;
		int exist7=0;
		int j=i;
		while(j>0){
			int k=j%10;
			if(k==5)exist5=1;
			else if(k==7)exist7=1;
			else if(k!=3)break;
			j/=10;
		}
		if(j>0 || exist5==0 || exist7==0)continue;
		ans++;
	}
	for(int i=375;i<=N;i+=20){
		int exist3=0;
		int exist7=0;
		int j=i;
		while(j>0){
			int k=j%10;
			if(k==3)exist3=1;
			else if(k==7)exist7=1;
			else if(k!=5)break;
			j/=10;
		}
		if(j>0 || exist3==0 || exist7==0)continue;
		ans++;
	}
	for(int i=357;i<=N;i+=20){
		int exist5=0;
		int exist3=0;
		int j=i;
		while(j>0){
			int k=j%10;
			if(k==5)exist5=1;
			else if(k==3)exist3=1;
			else if(k!=7) break;
			j/=10;
		}
		if(j>0 || exist5==0 || exist3==0)continue;
		ans++;
	}
	
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric> // accumulate(v.begin(), v.end(), 0)

using namespace std;
#define ll long long

const ll MOD = 1e+9 + 7;

struct data {
  ll prime;
  int power;
  data(ll prime, int power) : prime(prime), power(power) {}
};
vector<data> result;
void factorization(ll N) {
  if(N == 1 || N == 0) return;

  bool first = true;
  int n = N;
  while(n % 2 == 0) {
    if(first) {
      result.push_back(data(2LL, 1));
      first = false;
    } else {
      result[result.size()-1].power++;
    }
    n /= 2;
  }
  first = true;

  for(ll i=3; i<ceil(sqrt(N)); i+=2) {
    while(n % i == 0) {
      if(first) {
	result.push_back(data(i, 1));
	first = false;
      } else {
	result[result.size()-1].power++;
      }
      n /= i;
    }
    first = true;
  }

  if(n != 1) {
    result.push_back(data(n, 1));
  }

  return;
}

// int MAX_R = 100050;
// int MAX_C = 50;
// vector<vector<ll> > v(MAX_R, vector<ll>(MAX_C, 0LL));
// void prep_comb(ll mod = MOD) {
//   for(int i=0; i<MAX_C; i++) {
//     v[i][0] = 1;
//     v[i][i] = 1;
//   }
//   for(int k=1; k<v.size(); k++) {
//     for(int j=1; j<min(MAX_C, k); j++) {
//       v[k][j] = (v[k-1][j-1] + v[k-1][j]) % mod;
//     }
//   }
// }
// ll comb(int n, int r) {
//   if(2*r > n) r = n-r;
//   return v[n][r];
// }

#define N_MAX 30

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

long comb(long n, long r){
  if(2*r > n) r = n-r;
  long ans = 1;
  for(int i = 0; i < r; i++){
    ans = (ans*(n-i)%MOD)%MOD;
  }
  ans = (ans*finv[r])%MOD;
  return ans;
}

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

int main(){
  make();

  int N;
  ll M;
  cin >> N >> M;

  factorization(M);

  ll ans = 1;
  int n = N-1;
  // prep_comb();
  for(int i=0; i<result.size(); i++) {
    int m = result[i].power + n;
    ans *= comb(m, n);
    ans %= MOD;
  }

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


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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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; }

const ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n; string s;
  cin>>n>>s;
  ll ans=0;
  ll r=0,g=0,b=0;
  rep(i,n){
    if(s[i]=='R') r++;
    else if(s[i]=='G') g++;
    else b++;
  }
  ans=r*g*b;
  ll tmp=0;
  ll span=1;
  while(span<=n){
    for(ll i=0; i+2*span<n; i++){
      if(s[i]!=s[i+span] && s[i]!=s[i+2*span] && s[i+span]!=s[i+2*span]) tmp++;
      // ll span=0;
      
      
      // set<char> se;
      // se.insert(s[i]);
      // se.insert(s[i+span]);
      // se.insert(s[i+2*span]);
      // if(se.size()==3) tmp++;
      // cout<<i<<" "<<i+span<<" "<<i+span+span<<" ";
      // cout<<i+2*span<<endl;
    }
    // cout<<span<<endl;
    span++;
  }
  cout<<ans-tmp<<endl;
}

Measured memory_bytes: 3664
<?php
while (true) {
	$line = trim(fgets(STDIN));
	list($H, $W) = explode(' ', $line);
	if ($W == 0 && $H == 0) {
		break;
	}
	$room = array();
	for ($i = 0; $i < $H; $i++) {
		$room[$i] = trim(fgets(STDIN));
	}
	$visited = array();
	for ($i = 0; $i < $H; $i++) {
		for ($j = 0; $j < $W; $j++) {
			$visited[$i][$j] = false;
		}
	}
	$x = 0; $y = 0;
	$isLoop = false;
	while (true) {
		$line = $room[$y];
		$dir = $line[$x];
		if ($dir == '.') {
			break;
		}
		$visited[$y][$x] = true;
		switch ($dir) {
			case '>':
				$x++;
				break;
			case '<':
				$x--;
				break;
			case 'v':
				$y++;
				break;
			case '^':
				$y--;
				break;
		}
		if ($visited[$y][$x]) {
			$isLoop = true;
			break;
		}
	}
	if ($isLoop) {
		echo "LOOP\n";
	} else {
		echo "$x $y\n";
	}
}

Measured memory_bytes: 8288
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <string.h>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>

using namespace std;

typedef pair<long long int, long long int> P;
long long int INF = 1e18;
long long int MOD = 1000000007;

int DP[33][33][33][33];
int rem[33][33][33][33];

int h, w, s;
int u[40][40];

int S(int y, int x){
	if(y < 0 || x < 0 || y >= h || x >= w){
		return 0;
	}
	return u[y][x];
}

int main(){
	while(true){
		cin >> h >> w >> s;
		if(h == 0){
			break;
		}
		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				cin >> u[i][j];
			}
		}
		for(int i = 1; i < h; i++){
			for(int j = 0; j < w; j++){
				u[i][j] += u[i - 1][j];
			}
		}
		for(int i = 0; i < 40; i++){
			for(int j = 1; j < 40; j++){
				u[i][j] += u[i][j - 1];
			}
		}
		int th = u[h - 1][w - 1] - s;
		for(int i = 0; i < w; i++)for(int l = 0; l < h; l++)
		for(int j = 0; j < h; j++)for(int k = 0; k < w; k++){
			DP[i][j][k][l] = 0;
			rem[i][j][k][l] = 0;
			if(i <= k && j <= l){
				int hoge = S(l, k) - S(l, i - 1) - S(j - 1, k) + S(j - 1, i - 1);
				if(hoge >= th){
					DP[i][j][k][l] = 1;
					rem[i][j][k][l] = hoge - th;
				}
			}
		}
		for(int dx = 0; dx < w; dx++)for(int dy = 0; dy < h; dy++)
		for(int sx = 0; sx + dx < w; sx++)for(int sy = 0; sy + dy < h; sy++){
			int gx = sx + dx;
			int gy = sy + dy;
			for(int px = sx; px < gx; px++){
				int ret = DP[sx][sy][px][gy] + DP[px + 1][sy][gx][gy];
				int ret2 = min(rem[sx][sy][px][gy], rem[px + 1][sy][gx][gy]);
				
				if(DP[sx][sy][gx][gy] < ret){
					DP[sx][sy][gx][gy] = ret;
					rem[sx][sy][gx][gy] = ret2;
				}else if(DP[sx][sy][gx][gy] == ret){
					rem[sx][sy][gx][gy] = max(rem[sx][sy][gx][gy], ret2);
				}
			}
			for(int py = sy; py < gy; py++){
				int ret = DP[sx][sy][gx][py] + DP[sx][py + 1][gx][gy];
				int ret2 = min(rem[sx][sy][gx][py], rem[sx][py + 1][gx][gy]);
				
				if(DP[sx][sy][gx][gy] < ret){
					DP[sx][sy][gx][gy] = ret;
					rem[sx][sy][gx][gy] = ret2;
				}else if(DP[sx][sy][gx][gy] == ret){
					rem[sx][sy][gx][gy] = max(rem[sx][sy][gx][gy], ret2);
				}
			}
		}
		cout << DP[0][0][w - 1][h - 1] << " " << rem[0][0][w - 1][h - 1] << endl;
	}
	return 0;
}



Measured memory_bytes: 12044
//
//  main.cpp
//  CoderProj
//
//  Created by Minoru Hayashi on 2020/03/12.
//  Copyright © 2020 Minoru Hayashi. All rights reserved.
//
//
//
//

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

#define REP(i,n) for (int i=0; i<(n); i++)
#define REP2(i,x,n) for (int i=x; i<(n); i++)
#define ALL(n) begin(n), end(n)

using ll = long long;

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

// const ll INF = 1LL<<60;
// const int INF = 1<<29;
// const ll MOD = 1000000007;
//#define __DBG__


void solve(void){
  
  int N, A, B, ans;
  cin >> N >> A >> B;
  
  ans = min(A*N, B);
  
  cout << ans << endl;
  
  
  return;
   
}

#define TESTCASES 1

int main(int argc, const char * argv[]) {

    cin.tie(0);
    ios::sync_with_stdio(false);

    REP(i,TESTCASES){
      solve();
    }
 
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(void){
    int a,b; cin>>a>>b;
    int c=b-a;
    int t=0;
    for(int i=1;i<=c;i++){
        t=t+i;
    }
    cout<<t-b<<endl;
    
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <list>
#include <stack>

using namespace std;

/* constant */

const int INF = 1 << 30;
const int mod = 1000000007;
const double pi = 3.141592653589;

/* typedef */

typedef long long ll;

/* global variables */

/* function */

/* main */
int main() {

    // int n; cin >> n;
    int n, m; cin >> n >> m;
    
    vector< vector<int> > A(100, vector<int>(100));
    vector<int> B(100);
    vector<int> C(100);


    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> A[i][j];
        }
    }
    for (int i = 0; i < m; i++) {
        cin >> B[i];
    }

    for (int i = 0; i < n; i++) {
        int c = 0;
        for (int j = 0; j < m; j++) {
            c += A[i][j] * B[j];
        }
        C[i] = c;
    }

    for (int i = 0; i < n; i++) {
        cout << C[i] << '\n';
    }

}



Measured memory_bytes: 3208
#include <bits/stdc++.h>
#define LOOP(n) for (int _i = 0; _i < (n); _i++)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, r, n) for (int i = (r); i < (n); ++i)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;
const int INF = 2100100100;
const int MOD = 1e9 + 7;

int N, M, K, Q, W, H, R, C;
string S;

vector<bool> ud, rl;
int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);

    cin >> S;
    int x, y;
    cin >> x >> y;
    vector<int> go[2];  // 0:up,down  1:right,left

    bool flag = false;
    int ren = 0;
    int dir = 0;
    for (char c : S) {
        if (!flag) {
            if (c == 'F') {
                x--;
            } else if (c == 'T') {
                x = abs(x);
                y = abs(y);
                flag = true;
            }
        } else {
            if (c == 'F') {
                ren++;
            } else if (c == 'T') {
                if (ren != 0) {
                    go[dir].push_back(ren);
                    ren = 0;
                }
                dir++;
                dir %= 2;
            }
        }
    }
    if (ren > 0) {
        go[dir].push_back(ren);
    }

    ud.assign(9000, false);
    rl.assign(9000, false);
    ud[0] = true;
    rl[0] = true;
    int sum_ud = 0;
    int sum_rl = 0;
    for (auto d : go[0]) {
        sum_ud += d;
        RREP(i, 8000) {
            if (ud[i]) {
                if (i + d < 9000) ud[i + d] = true;
            }
        }
    }
    for (auto d : go[1]) {
        sum_rl += d;
        RREP(i, 8000) {
            if (rl[i]) {
                if (i + d < 9000) rl[i + d] = true;
            }
        }
    }

    int xd = (sum_rl - x);
    int yd = (sum_ud - y);
    if (xd % 2 == 0 && yd % 2 == 0 && xd / 2 >= 0 && rl[xd / 2] && yd / 2 >= 0 && ud[yd / 2]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


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

string shuffle(string s,int h){
    string a = s.substr(0,h);
    string b = s.substr(h,s.size()-h);
    return b+a;
}

int main(){
    string s;
    int m;
    int h;
    while(true){
        cin>>s;
        if(s[0]=='-') break;
        cin>>m;
        for(int i=0;i<m;i++){
            cin>>h;
            s = shuffle(s,h);
        }
        cout<<s<<'\n';
    }
}


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

int N;
int A[100010];
int a[100010], cnt[100010], n;

void solve()
{
	int i;
	sort(A, A+N);
	a[0] = A[0];
	cnt[0] = 1;
	n = 1;
	for(i=1; i<N; i++){
		if(A[i] == A[i-1]){
			cnt[n-1] ++;
		}
		else{
			a[n] = A[i];
			cnt[n] = 1;
			n ++;
		}
	}
	long long l1=0, l2=0;
	for(i=n-1; i>=0; i--){
		if(cnt[i] >= 2){
			l1 = a[i];
			cnt[i] -= 2;
			break;
		}
	}
	for(i=n-1; i>=0; i--){
		if(cnt[i] >= 2){
			l2 = a[i];
			break;
		}
	}
	long long res = l1 * l2;
	printf("%lld\n", res);
}

int main()
{
	int i;
	scanf("%d", &N);
	for(i=0; i<N; i++)	
		scanf("%d", &A[i]);
	solve();
	return 0;
}

Measured memory_bytes: 1280
candies = input().split()
if (int(candies[0]) + int(candies[1]) == int(candies[2])) or (int(candies[1]) + int(candies[2]) == int(candies[0])) or (int(candies[0]) + int(candies[2]) == int(candies[1])):
  print('Yes')
else:
  print('No')

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

int main(){
  bool A=true;
  int N;
  cin >> N;
  if(N==2){
    cout << 2 << endl;
  }
  else{
    for(int i=N;i<N+100;i++){
      for(int j=2;j<i;j++){
        if(i%j==0){
          break;
        }
        if(j==i-1){
          cout << i << endl;
          A=false;
          break;
        }
      }
      if(A==false){
        break;
      }
    }
  }
}


Measured memory_bytes: 3636
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define reps(i, n) for (int i = 1; i <= (n); ++i)
#define repd(i, n) for (int i = (n)-1; i >= 0; --i)
#define repds(i, n) for (int i = (n); i > 0; --i)
#define loop(i, x, n) for (int i = (x); i < (n); ++i)
#define loops(i, x, n) for (int i = (x); i <= (n); ++i)
#define loopd(i, x, n) for (int i = (x); i > (n); --i)
#define loopds(i, x, n) for (int i = (x); i >= (n); --i)
#define itrep(i, a) for (auto i = begin(a); i != end(a); ++i)
#define itrepd(i, a) for (auto i = rbegin(a); i != rend(a); ++i)
#define each(i, x) for (auto &&i : x)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(a) ((int)a.size())
#define pow2(n) (n * n)
#define int ll
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
template <class T>
using priority_queuel = priority_queue<T, vector<T>, greater<T>>;
constexpr ll inf = static_cast<ll>(1e18);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e18;
constexpr double eps = 1e-9;
ll mod = static_cast<ll>(1e9 + 7);
template <class T, class... Args>
constexpr void mins(T &a, Args... args) { a = min<T>({a, args...}); }
template <class T, class... Args>
constexpr void maxs(T &a, Args... args) { a = max<T>({a, args...}); }
template <class F>
class FixPoint : private F {
public:
    explicit constexpr FixPoint(F &&f) : F(std::forward<F>(f)) {}
    template <class... Args>
    constexpr decltype(auto) operator()(Args &&... args) const { return F::operator()(*this, std::forward<Args>(args)...); }
};
template <class F>
constexpr decltype(auto) funcs(F &&f) { return FixPoint<F>{std::forward<F>(f)}; }
template <class T>
std::vector<T> vecs(int n, T &&val) { return std::vector<T>(std::forward<int>(n), std::forward<T>(val)); }
template <class... Args>
decltype(auto) vecs(int n, Args &&... args) { return std::vector<decltype(vecs(std::forward<Args>(args)...))>(std::forward<int>(n), vecs(std::forward<Args>(args)...)); }
template <class V, class T>
void fill(V &x, const T &val) { x = val; }
template <class V, class T>
void fill(vector<V> &vec, const T &val) {
    for (auto &&v : vec)
        fill(v, val);
}

void solve() {
    string s;
    cin >> s;
    rep(i, sz(s)) if (s[i] == '?') s[i] = 'D';
    cout << s << endl;
}

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

Measured memory_bytes: 3748
import java.util.*;

class Main {
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int a, b;
	a = sc.nextInt();
	b = sc.nextInt();

	System.out.println(a/b);
	System.out.println(a%b);
	System.out.printf("%.6f\n", (double)a/b);
    }
}

Measured memory_bytes: 17328
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, A; 
  cin >> N >> A ;
  int b;
  b = N - N / 500 * 500;
  if (b <= A){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }


}


Measured memory_bytes: 3596
/// Rustで競技プログラミングの入力をスッキリ記述するマクロ
///
/// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
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)*}
    };
}

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, 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")
    };
}

fn main() {
    input!{
        x: u64,
    }

    if x == 3 || x == 5 || x == 7 {
        println!("YES");
    } else {
        println!("NO");
    }
}


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

using namespace std;
typedef long long ll;
#define Inf 1 << 20
#define MInf -(1 << 20)


#define REP(n) for(int i = 0;i < (int)(n);i++)
#define rep(i,n) for(int i = 0;i < (int)(n);i++)
#define Rep(i,n,m) for(int i = (int)(n); i < (int)(m);i++)
#define rrep(i,n) for(int i = (int)(n - 1); i > -1;i--)
#define RRep(i,n,m) for(int i = (int)(n - 1); i > (int)(m);i--)
#define trav(a, x) for(auto& a : x)

#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V))
#define REVERSE(V) reverse(ALL(V))
#define RSORT(V) SORT(V);REVERSE(V)


#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define yes(n) cout << ((n) ? "yes" : "no") << endl;




int main()
{
    int s;
    cin >> s;
    int s1 = s/100;
    int s2 = s%100;
    if (1 <= s1 && s1 <= 12) {
        if (1 <= s2 && s2 <= 12)
            cout << "AMBIGUOUS" << endl;
        else
            cout << "MMYY" << endl;
    }
    else {
        if (1 <= s2 && s2 <= 12)
            cout << "YYMM" << endl;
        else
            cout << "NA" << endl;
    }
}

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

int main(){
    
    long long int i, N;
    long long int ans = 0;
    cin >> N;
    
    for (i = 1; i <= N; i++){
        
        long long int x = N / i;
        ans += i * x * (x + 1) / 2;
    }
    
    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 3184
/* 
 * Project: AtCoder Beginners Contest 153 C - Fennec vs Monster
 * Author: toms74209200 <https://github.com/toms74209200>
 *
 * Created on 2020/07/03
 * Copyright (c) 2020 toms74209200
 * 
 * This software is released under the MIT License.
 * http://opensource.org/licenses/mit-license.php
 */
#include <stdio.h>
#include <algorithm>
#include <numeric>
using namespace std;

int n;
long h[200000];
int k;

void solve() {

    if (k >= n) {
        printf("0\n");
        return;
    }

    sort(h, h+n);
    long attack = accumulate(h, h+n-k, 0L);
    printf("%ld\n", attack);
}

int main() {

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

    solve();

}

Measured memory_bytes: 4752
#include<iostream>
#include<vector>

using namespace std;

#define rep(i, n) for (int i = 0; i < int(n); ++i)

long long dp[101][1 << 16];

bool solve() {
  int n;
  cin >> n;
  if (n == 0) return false;
  int m[n], l[n], b[n];
  rep (i, n) {
    cin >> m[i] >> l[i];
    b[i] = 0;
    rep (j, m[i]) {
      int s, e;
      cin >> s >> e;
      b[i] |= (1 << (e - 6)) - (1 << (s - 6));
    }
  }
  rep (i, 1 << 16) dp[0][i] = 0;
  rep (i, n) rep (j, 1 << 16) {
    dp[i + 1][j] = dp[i][j];
    if ((j & b[i]) == b[i]) dp[i + 1][j] = max(dp[i + 1][j], dp[i][j ^ b[i]] + l[i]);
  }
  cout << dp[n][(1 << 16) - 1] << endl;
  return true;
}

int main() {
  while (solve());
  return 0;
}

Measured memory_bytes: 52868
#include <stdlib.h>
main(){double x,q;for(;scanf("%lf",&q),q!=-1;printf("%.6lf\n",x))for(x=q/2;fabs((x*x*x)-q)>=0.00001*q;)x=x-(((x*x*x)-q)/(3*x*x));exit(0);}

Measured memory_bytes: 652
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	long long int n,c,k;cin>>n>>c>>k;
  	vector<long long int> t(n);
	for(int i=0;i<n;i++){
		cin>>t[i];	
    }
  	sort(t.begin(),t.end());
  	//必要な変数。バスの台数、客数、何時まで大丈夫？
  	int bus=1;
  	int kyaku=1;
  	int limit=t[0]+k;
  	for(int i=1;i<n;i++){
     // cout<<"bus"<<bus<<"kyaku"<<kyaku<<"LIMIT"<<limit<<endl;
      if(kyaku+1>c || t[i]>limit){
  			bus++;
        	kyaku=1;
        	limit=t[i]+k;
      }else{
      		kyaku++;
      }
    }
  cout<<bus<<endl;
}

Measured memory_bytes: 1024