akhauriyash/Code-Regression huggingface dataset:
function Main(input) {
  var tmp = input.trim().split(' ')
  var N = parseInt(tmp[0])
  var K = parseInt(tmp[1])

  var str = ''

  var tmp = N
  while (tmp != 0) {
    str = (tmp % K).toString() + str
    tmp = Math.floor(tmp / K)
  }

  var result = str.length

  console.log(result)
  return result
}

Main(require('fs').readFileSync('/dev/stdin', 'utf8'))

Measured memory_bytes: 7372
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  int d[n],e[n];
  for(int i=0;i<n;i++){
    cin>>d[i]>>e[i];
  }
  for(int i=0;i<n-2;i++){
    if(d[i]==e[i]&&d[i+1]==e[i+1]&&d[i+2]==e[i+2]){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;
}  

Measured memory_bytes: 3604
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val n = sc.nextInt()
    val a = Array(n) { sc.nextInt() }
    var odd = a.count { it % 2 == 1 }
    var four = a.count { it % 4 == 0 }
    println(if (odd <= four || (odd == four + 1 && odd + four == n)) "Yes" else "No")
}

fun main() {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}


Measured memory_bytes: 48068
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;

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

Measured memory_bytes: 256
#include<iostream>
using namespace std;
 
int main(){
 int medal;
 int b,r,g,c,s,t;
 while(cin>>b>>r>>g>>c>>s>>t, b||r||g||c||s||t){
  medal = 100;
  medal += ((5*b)+(3*r))*15-((5*b)+(3*r))*2;
  medal += (b+r)*15-(b+r)*3;
  medal += (g*7)+(c*2)-(g+c)*3;
  medal -= (t-(5*b)-(3*r)-b-r-g-c-s)*3;
  cout<<medal<<endl;
 }
 return 0;
}
 

Measured memory_bytes: 0
if (__name__ == '__main__'):
    n = int(input())
    dataline = input().strip().split()

    b = []
    for i in range(n-1):
        b.append(int(dataline[i]))

    a = []
    a.append(b[0])
    a.append(b[0])
    
    for i in range(1, n-1):
        a.append(b[i])
        if (b[i] < b[i-1]):
            a[i] = b[i]
            
    thesum = 0
    for i in range(n):
        thesum = thesum + a[i]


    print(thesum)


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

#ifndef M_PI
#define M_PI 3.14159265358979
#endif
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef pair<ll, ll> pll;
typedef pair<int, int> pi;
typedef long double ld;
typedef pair<long double, long double> pld;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll i, j, k, l;

    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max(a * c, max(a * d, max(b * c, b * d))) << endl;

    return 0;
}


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


int main() {
  int x, a, b;
  cin >> x >> a >> b;
  string ans = "dangerous";
  if((b - a) <= 0) ans = "delicious";
  else if((b - a) <= x) ans = "safe";
  cout << ans << endl;
  return 0;
  
}

Measured memory_bytes: 256
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

func reachable(f []int, from, to int) bool {
	n := len(f)
	dp := make([][16005]bool, n+1)
	dp[0][from+8000] = true
	for i := 0; i < n; i++ {
		for j := 0; j < 16005; j++ {
			if dp[i][j] {
				dp[i+1][j-f[i]], dp[i+1][j+f[i]] = true, true
			}
		}
	}
	return dp[n][to+8000]
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	s, x, y := next(), nextInt(), nextInt()

	ff := make([][]int, 2)
	ff[0], ff[1] = []int{0}, []int{}
	for i, t := 0, 0; i < len(s); i++ {
		if s[i] == 'T' {
			t++
			ff[t%2] = append(ff[t%2], 0)
		} else {
			ff[t%2][len(ff[t%2])-1]++
		}
	}

	if !reachable(ff[0][1:], ff[0][0], x) {
		puts("No")
		return
	}
	if !reachable(ff[1], 0, y) {
		puts("No")
		return
	}
	puts("Yes")
}


Measured memory_bytes: 84736
unittest
{
	assert( [ "100" ].parse.expand.solve == 18 );
	assert( [ "9995" ].parse.expand.solve == 35 );
	assert( [ "3141592653589793" ].parse.expand.solve == 137 );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto ns = input.front.map!( ( a ) => a.to!long - '0' ).array;
	return tuple( ns );
}

auto solve( long[] ns )
{
	auto d = false;
	auto ans = 0L;
	foreach_reverse( i, n; ns )
	{
		if( 0 < n && d )
		{
			n--;
			ans = 9 * ( ns.length.signed - i - 1 );
		}
		if( n < 9 ) d = true;
		ans += n;
	}
	return ans;
}


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

#define rep(i, n) for(int i = 0; i < n; i ++)
#define ALL(T) T.begin(), T.end()
#define mp make_pair
#define pb push_back

using namespace std;

typedef pair<int, int> pii;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;

int main(void){
    double w, l, bmi;
    for(int n; ~scanf("%d,%lf,%lf", &n, &w, &l); ) if((bmi = w / pow(l, 2.)) >= 25) cout << n << endl;

    return 0;
}

Measured memory_bytes: 1232
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
#include <iomanip>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
int main()
{
	int m1,m2,d1,d2;
	ll ans=0;
	cin>>m1>>d1;
	cin>>m2>>d2;
	if(m1!=m2)
		cout<<1<<endl;
	else
		cout<<0<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("O3")

#define fi first
#define se second
#define em emplace
#define eb emplace_back
#define mp make_pair
#define pi pair<int,int>
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define endl '\n'

#define si(v) int((v).size())
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i) 
#define rep2(i, n, m) for (ll i = n; i <= (ll)(m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (ll)(m); --i)

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

using ll = long long;
using ld = long double;
using namespace std;

constexpr ll MOD = 1000000007;

signed main()
{
  cout << fixed << setprecision(20);
  ios::sync_with_stdio(false);
  cin.tie(0);

  int n; cin >> n;
  vi a(n), b(n), c(n-1);

  rep(i, n) cin >> a[i];
  rep(i, n) cin >> b[i];
  rep(i, n-1) cin >> c[i];

  int ans = 0;
  rep(i, n-1) if (a[i+1] - a[i] == 1) ans += c[a[i]-1];
  rep(i, n) ans += b[a[i]-1];

  cout << ans << endl;

  return (0);
}


Measured memory_bytes: 3612
import java.util.*;
import java.io.*;
import java.math.*;

public class Main{
  public static OutputStream out=new BufferedOutputStream(System.out);
  static Scanner sc=new Scanner(System.in);
  static long mod=1000000007l;

  //nl-->neew line; //l-->line;  //arp-->array print;  //arpnl-->array print new line
  public static void nl(Object o) throws IOException{out.write((o+"\n").getBytes());}
  public static void l(Object o) throws IOException{out.write((o+"").getBytes());}
  public static void arp(int[] o) throws IOException{for(int i=0;i<o.length;i++) out.write((o[i]+" ").getBytes()); out.write(("\n").getBytes());}
  public static void arpnl(int[] o) throws IOException{for(int i=0;i<o.length;i++) out.write((o[i]+"\n").getBytes());}
  public static void scanl(long[] a,int n) {for(int i=0;i<n;i++) a[i]=sc.nextLong();}
  public static void scani(int[] a,int n) {for(int i=0;i<n;i++) a[i]=sc.nextInt();}
  public static void scan2D(int[][] a,int n,int m) {for(int i=0;i<n;i++) for(int j=0;j<m;j++) a[i][j]=sc.nextInt();}
  //
  static long cnt;
  static TreeSet<Integer> ans;
  static int n,m;
  static boolean[][] dp,vis;
  static HashMap<Pair,Boolean> arrl;


  public static void main(String[] args) throws IOException{
    long sttm=System.currentTimeMillis();
    long mod=1000000007l;

    int n=sc.nextInt();
    int[] a=new int[n];
    int cnt=0;
    for(int i=0;i<n;i++){
        a[i]=sc.nextInt();
        if(i%2==0){
            if(a[i]%2==1) cnt++;
        }
    }
    nl(cnt);

    out.flush();
  }
}

class Pair{
  int st,nd;
  Pair(int st,int nd){
    this.st=st;
    this.nd=nd;
  }
}


Measured memory_bytes: 38664
use std::io;
use std::str::FromStr;

fn input_char_vec() -> Vec<char> {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.trim().chars().collect()
}

fn main() {
    let s_vec = input_char_vec();
    let t_vec = input_char_vec();
    let mut count = 0;
    for i in 0..s_vec.len() {
        if s_vec[i] != t_vec[i] {
            count += 1;
        }
    }
    println!("{}", count);
}


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

using namespace std;
const int NMAX = 300000;

int v[NMAX+2];
int N, nex[NMAX+2];

int main()
{
    cin >> N;
    for( int i = 1;  i <= N;  ++i ) cin >> v[i];
    nex[N] = N + 1;
    for( int i = N - 1;  i >= 1;  --i ) {
        if( v[i + 1] )
            nex[i] = i + 1;
        else
            nex[i] = nex[i + 1];
    }
    long long ans = 0;
    for( int i = 1;  i <= N;  ++i ) {
        int ind = i, a = v[i], b = v[i];
        while( a == b && ind <= N ) {
            ind = nex[ind];
            a ^= v[ ind ];
            b += v[ ind ];
        }
        ans += 1LL * (ind - i);
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define SaveTime ios_base::sync_with_stdio(false);cin.tie(0);
#define MOD 1e9+7
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PI 4*atan(1)

using namespace std;

int main()
{
   string s; cin >> s;
   int sum = 0;
   for (int i = 0; i < s.length(); i++) {
      sum+= s[i]-'0';
   }
   if (sum % 9 == 0)
      cout << "Yes";
   else
      cout << "No";
}

Measured memory_bytes: 3728
import sys

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

def gcd(a,b):
	while True:
		a,b = b,a%b
		if b==0:
			return a

for line in sys.stdin:
	a,b = map(int, line.split())
	print("{} {}".format(gcd(a,b),lcm(a,b)))

Measured memory_bytes: 7724
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define sz(c) ((int)(c).size())

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
//const int MAX=;



int main(){
	string S;
	cin>>S;
	int l=sz(S);
	int ans=0;
	int n=0;
	rep(i,l){
		if(S[i]=='A'||S[i]=='C'||S[i]=='G'||S[i]=='T'){
			n++;
			ans=max(ans,n);
		}
		else n=0;
	}
	cout<<ans;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
#include<fstream>
#include<set>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define out(str) cout << str << endl
#define ALL(a) (a).begin(),(a).end()
#define INF (1<<29)

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

int N,K,su,B,tmp,ans,kai;

int main(){
    cin>>N>>K;
    int V[N];
    rep(i,N){
        cin>>V[i];
    }
    su=min(N,K);
    rep(A,su+1){
        rep(B,su-A+1){
            tmp=0;
            kai=max(0,K-A-B);
            vector<int> g;
            rep(i,A){
                g.push_back(V[i]);
            }
            for(int i=N-1;i>N-1-B;i--){
                g.push_back(V[i]);
            }
            sort(ALL(g));
            for(auto x : g){
                if(kai&&x<0){
                    kai--;
                    continue;
                }
                else{
                    tmp+=x;
                }
            }
            ans=max(tmp,ans);
        }
        
    }
    out(ans);

}


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

using namespace std;

//double solve(double n)

int main(void){

	double sum,table[11]={0};
	
	while(cin>>table[0]){
		sum=table[0];
		for(int i=1;i<10;i++){
			if(i%2==0){
				table[i]=table[i-1]/3;
			}
			else{
				table[i]=table[i-1]*2;	
			}			
			sum=sum+table[i];
		}
		printf("%.9f\n",sum);
		memset(table,0,sizeof(table));
	}
}

Measured memory_bytes: 1236
from math import gcd 
import sys
read=sys.stdin.buffer.readline

K=int(read())
l=[[0]*(K+1) for _ in range(K+1)]
for i in range(1,K+1):
    for j in range(i,K+1):
        x=gcd(i,j)
        l[i][j],l[j][i]=x,x

ans=0
for a in range(1,K+1):
    for b in range(1,K+1):
        x=l[a][b]
        for c in range(1,K+1):
            ans+=l[x][c]

print(ans)

Measured memory_bytes: 9456
#include <cstdio>
#include <iostream>

using namespace std;

int main(){
	int a;
	scanf("%d",&a);
	int b[a];
	int all=0;
	for(int i=0;i<a;i++){
		scanf("%d",&b[i]);
		all+=b[i];
	}
	for(int i=0;i<a;i++){
		if(all-b[i]<=b[i]){
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	long long a,b,c;
	cin>>a>>b>>c;
	if (a<0)
		a=abs(a);
	if (b>=a/c)
	{
		if ((b-a/c)%2==0)
		{
			cout<<a%c<<endl;
		}
		else
		{
			cout<<c-(a%c)<<endl;
		}
	}
	else
	{
		cout<<a-b*c<<endl;
	}
	return 0;
}


Measured memory_bytes: 3524
//
// C - 怪文書 / Dubious Document
//

#include <iostream>

using namespace std;

int main() {

    int n;
    cin >> n;

    int c1['z' + 1];
    fill(c1, c1 + 'z' + 1, 51);

    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        int c2['z' + 1] = {0};
        for (char c : s) {
            c2[c]++;
        }
        for (char c = 'a'; c <= 'z'; c++) {
            c1[c] = min(c1[c], c2[c]);
        }
    }

    for (char c = 'a'; c <= 'z'; c++) {
        for (int i = 0; i < c1[c]; i++) {
            cout << c;
        }
    }
    cout << endl;
}

Measured memory_bytes: 384
#include<stdio.h>

int main(){
	int m,f,r,sum;

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

Measured memory_bytes: 584
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pi;
typedef vector<ll> vi;
typedef vector<pi> vpi;
typedef long double ld;
const int inf = 1e9 ;
const int mod = 1e9 + 7;
const int maxn = 1e6 + 3;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define rep(i, a, b) for(int i = a; i < b; i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define lb lower_bound
#define ub upper_bound
#define fact(n) rep(i, 1, n+1)ft.pb((ft[i-1]*i)%mod);
#define mod_in(a) exp(a, mod-2)
#define ncr(n, r) ((ft[n]*mod_in((ft[r]*ft[(n)-(r)])%mod))%mod)
#define deb(x) cout << #x << " " << x << endl;
#define flash ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'




int main()
{   
    flash;
    string s;
    cin >> s;
    ll sum=0;
    ll n=s.size();
    for(ll i=0;i<n;i++){
        sum+=(ll)(s[i]-'0');
    }
    ll p=9;
    if(sum%p==0)cout<<"Yes\n";
    else cout<<"No\n";
    
}





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

con = 0

for i in range(0,len(S)):
  if S[i] == "1":
    con += 1
  else:break

if K <= con:
  print(1)
else:
  if S[0] == "1":
    S = S.replace("1","")
    print(int(S[0]))
  else:
    print(int(S[0]))

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

int asc(const void *a, const void *b) {
  long *A = (long *)a;
  long *B = (long *)b;
  if (*A > *B) return 1;
  if (*A < *B) return -1;
  return 0;
}

int main(){
	int N;
	long int M;
	long int A[100000][2];
	scanf("%d",&N);
	scanf("%ld",&M);
	int i;
	for(i=0;i<N;i++){
		scanf("%ld",&A[i][0]);
		scanf("%ld",&A[i][1]);
	}
	long int a;
	a=0;
	qsort(A,N,sizeof(A[0]),asc);
	i=0;
	while(1){
		if(A[i][1]<M){
			a=a+A[i][0]*A[i][1];
			M=M-A[i][1];
			i=i+1;
		}else{
			a=a+A[i][0]*M;
			break;
		}
	}
	printf("%ld",a);
}

Measured memory_bytes: 3324
#include<iostream>
#include<cstdio>
#include <stdio.h>
#include<algorithm>
#include<cstring>
#include <string>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<map>
#include<vector>
#include<bits/stdc++.h>
#include <set>
#define ll long long
#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
#define inf 0x3f3f3f3f
#define pi 3.1415926535898
using namespace std;

int main()
{
    int a,b,c,k;
    cin>>a>>b>>c;
    cin>>k;
    while(k&&b<=a)
    {
        b=b*2;
        k--;
    }
    while(k&&c<=b)
    {
        c=c*2;
        k--;
    }
    
    if(a<b&&b<c)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3620
n=int(input())
t,a=map(int, input().split())
h=list(map(int, input().split()))
h=[t-i*0.006 for i in h]
c=10000
ans=0
for i in range(n):
    if c>abs(a-h[i]):
        ans=i+1
        c=abs(a-h[i])
print(ans)

Measured memory_bytes: 3064
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

void readV(T...)(ref T t){auto r=readln.splitter;foreach(ref v;t){v=r.front.to!(typeof(v));r.popFront;}}
void readA(T)(size_t n,ref T[]t){t=new T[](n);auto r=readln.splitter;foreach(ref v;t){v=r.front.to!T;r.popFront;}}

void main()
{
  int n; readV(n);
  int[] a; readA(n, a);

  auto mi = a.reduce!min, ma = a.reduce!max;
  auto h = new int[](ma-mi+3);
  foreach (ai; a) h[ai-mi+1]++;

  auto r = 0;
  foreach (i; 1..ma-mi+2)
    r = max(r, h[i-1]+h[i]+h[i+1]);

  writeln(r);
}


Measured memory_bytes: 3068
#include <stdio.h>
int main(void){
	int W,H,x,y,r;
	scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
	if(x-r<0||x+r>W||y-r<0||y+r>H){
		printf("No\n");
	}
	else{
		printf("Yes\n");
	}
	return 0;
}

Measured memory_bytes: 584
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int ice[100][100];
int m,n;

int f(int i[100][100],int x,int y){
	if(x<0||m<=x||y<0||n<=y)return 0;
	if(i[y][x]==0)return 0;
	i[y][x]=0;
	int res=0;
	int xx[]={1,-1,0,0},yy[]={0,0,1,-1};
	int j;
	for(j=0;j<4;j++){
		chmax(res,f(i,x+xx[j],y+yy[j]));
	}
	i[y][x]=1;
	return res+1;
}

int main() {
	while(cin>>m>>n,m){
		int i,j;
		for(i=0;i<n;i++){
			for(j=0;j<m;j++){
				cin>>ice[i][j];
			}
		}
		int res=0;
		for(i=0;i<n;i++){
			for(j=0;j<m;j++){
				chmax(res,f(ice,j,i));
			}
		}
		cout<<res<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include"bits/stdc++.h"
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const long long inf = 1ll << 61;
const long long mod = 998244353;
int ans[505][505];
int n;
void disp() {
	cout << n << endl;
	rep(i, n) {
		rep(j, n) {
			if (j)cout << ' '; cout << ans[i][j];
		}cout << endl;
	}
}
signed main() {
	int k; cin >> k;

	if (k == 1) {
		n = 1;
		ans[0][0] = 1;
		disp(); return 0;
	}

	n = (k + 3) / 4 * 2;
	int p = n;
	if (k % 4 && k % 4 <= 2)p -= 2;
	for(int i=0;i<n;i++) {
		rep(j, n)ans[i][(j + i) % n] = j + 1 + p*(i % 2);
	}
	if (k % 4 == 3) {
		rep(i, n) {
			rep(j, n) {
				if (ans[i][j] == 2 * n)ans[i][j] = n;
			}
		}
	}
	if (k % 4 && k % 4 <= 2) {
		rep(i, n) {
			ans[i][(i + n - 2) % n] = n * 2 - 3;
			ans[i][(i + n - 1) % n] = n * 2 - 2;
		}
	}
	if (k % 4 == 1) {
		rep(i, n) {
			rep(j, n) {
				if (ans[i][j] == n * 2 - 4)ans[i][j] = n - 2;
				if (ans[i][j] == n * 2 - 2)ans[i][j] = n * 2 - 4;
			}
		}
	}
	disp();
}

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;

int main() {
    string S, T, U;
    int A, B;
    cin >> S >> T >> A >> B >> U;
    if (S == U) A--;
    if (T == U) B--;

    cout << A << " " << B << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
#include <climits>
#include <queue>
#include <iomanip>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i = 0; i < (ll)(n); ++i)
#define FOR(i, a, b) for(ll i=(a); i < (ll)(b); ++i)
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 n;
	cin >> n;
	map<int,int> a;
	REP(i,n){
		int in;
		cin >> in;
		a[in]++;
	}
	
	vector<int> four,two;
	for(auto x:a){
		if(x.second >= 2) two.push_back(x.first);
		if(x.second >= 4) four.push_back(x.first);
	}
	
	ll ans = 0;
	if((int)four.size()!=0){
		sort(four.begin(),four.end(),greater<int>());
		ans = (ll)four[0]*(ll)four[0];
	}
	
	
	if((int)two.size()>=2){
		sort(two.begin(),two.end(),greater<int>());
		chmax(ans, (ll)two[0]*(ll)two[1]);
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 8256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define MOD 1000000007
#define INF 1000000000000000000

int main(){
  string N;
  cin>>N;
  int n=N.size();
  vector<vector<int>> c(10,vector<int>(10,0));
  if(n==1){
    cout<<n<<endl;
    return 0;
  }
  for(int i=1;i<10;i++){
    for(int j=1;j<10;j++){
      int x=N.at(0)-'0';
      vector<vector<vector<int>>> dp(n,vector<vector<int>>(2,vector<int>(2,0)));
      if(x>i){
        dp.at(0).at(1).at(1)=1;
      }else if(x==i){
        dp.at(0).at(0).at(1)=1;
      }
      dp.at(0).at(1).at(0)=1;
      for(int k=1;k<n-1;k++){
        x=N.at(k)-'0';
        dp.at(k).at(0).at(1)+=dp.at(k-1).at(0).at(1);
        dp.at(k).at(1).at(0)+=dp.at(k-1).at(1).at(0);
        dp.at(k).at(1).at(1)+=10*dp.at(k-1).at(1).at(1)+dp.at(k-1).at(1).at(0);
        dp.at(k).at(1).at(1)+=x*dp.at(k-1).at(0).at(1);
      }
      if(i==j){
        x=N.at(n-1)-'0';
        c.at(i).at(j)+=dp.at(n-2).at(1).at(1);
        c.at(i).at(j)+=dp.at(n-2).at(1).at(0);
        if(j<=x){
          c.at(i).at(j)+=dp.at(n-2).at(0).at(1);
        }
      }else{
        x=N.at(n-1)-'0';
        c.at(i).at(j)+=dp.at(n-2).at(1).at(1);
        if(j<=x){
          c.at(i).at(j)+=dp.at(n-2).at(0).at(1);
          if(i==3&&j==1){
          }
        }
      }
    }
  }

  int ans=0;
  for(int i=1;i<10;i++){
    for(int j=1;j<10;j++){
      ans+=c.at(i).at(j)*c.at(j).at(i);
      //cout<<c.at(i).at(j)<<" ";
    }
    //cout<<endl;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define INF 1LL << 60;
#define LLINF 1e12
#define PI 3.14159265359
#define ALL(a) (a).begin(), (a).end()
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
int ny, nx;
typedef long long ll;
using namespace std;

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

ll lcm(ll m, ll n)
{
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n);
}

ll llpow(ll x, ll y)
{
    ll ans = 1;
    REP(i, y)
    ans *= x;
    return ans;
}

ll llmin(ll x, ll y) { return x < y ? x : y; }
ll llmax(ll x, ll y) { return x > y ? x : y; }

unsigned GetDigit(unsigned num) { return to_string(num).length(); }

template <typename Container>
bool exist_in(const Container &c, const typename Container::value_type &v)
{
    return (c.end() != std::find(c.begin(), c.end(), v));
}

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

ll nCr(int n, int r)
{
    if (n == r or n == 0)
        return 1;
    if (n < r)
        return 0;
    if (r == 1)
        return n;
    return nCr(n - 1, r - 1) + nCr(n - 1, r);
}

//std::cout << std::defaultfloat << std::setprecision(10);
////////////////////////////////////////
int main()
{
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    std::cout << std::defaultfloat << std::setprecision(10);

    double a, b, H, M; cin >> a >> b >> H >> M;
    double Mdeg = 6*M, Hdeg = 30*H + 0.5*M;
    double betdeg;

    if(Hdeg<180 and Mdeg>=Hdeg+180){
        betdeg = 360-Mdeg+Hdeg;
    }else if(Mdeg<180 and Hdeg>=Mdeg+180){
        betdeg = 360-Hdeg+Mdeg;
    }else{
        if(Mdeg>=Hdeg) betdeg = Mdeg-Hdeg;
        else betdeg = Hdeg-Mdeg;
    }

    //cout << "Mdeg= " << Mdeg << " Hdeg= " << Hdeg << endl;
    //cout <<"betdeg= " << betdeg << endl;

    cout << sqrt(a*a + b*b - 2*a*b*cos(betdeg * PI / 180)) << endl;
    
    return 0;
}


Measured memory_bytes: 4232
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from collections import deque
sys.setrecursionlimit(10**7)
MOD = 10**9+7
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(input()) #整数読み込み
def ifn(): return float(input()) #浮動小数点読み込み
def isn(): return input().split() #文字列読み込み
def imn(): return map(int, input().split()) #整数map取得
def fmn(): return map(float, input().split()) #浮動小数点map取得
def iln(): return list(map(int, input().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def fln(): return list(map(float, input().split())) # 浮動小数点リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 # 2点間の距離
def m_add(a,b): return (a+b) % MOD

N = iin()
p = fln()

dp = [[0 for _ in range(N+1)] for _ in range(N+1)]
dp[0][0] = 1

for i in range(N):
    for j in range(i+1):
        dp[i+1][j+1] += dp[i][j] * p[i]
        dp[i+1][j] += dp[i][j] * (1-p[i])
ans = 0
for i in range(N//2+1, N+1):
    ans += dp[N][i]
print(ans)

Measured memory_bytes: 276208
N,M = map(int,input().split())
lamp_list = []
for j in range(M):
  lamp_list.append([i-1 for i in map(int,input().split())])
  lamp_list[j].pop(0)
mod_list = [i for i in map(int,input().split())]

ans = 0

for i in range(2**N):
  sum_list = [0 for i in range(M)] # ランプに接続されたスイッチのon合計
  for j in range(N):
    if ((i>>j)&1):
      for k in range(M):
        if j in lamp_list[k]:
          sum_list[k] += 1
  ok = 1
  for k in range(M):
    if sum_list[k]%2 != mod_list[k]:
      ok = 0
  if ok:
    ans += 1
    
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
int main(void){
    int i,I=1000,m[I],f[I],r[I];
    for(i=0;;i++){
        scanf("%d %d %d",&m[i],&f[i],&r[i]);
        //printf("%d %d %d\n",m[i],f[i],r[i]);
        if(m[i]<0 && f[i]<0 && r[i]<0){
            break;
        }
    }
    for(i=0;;i++){
        if(m[i]<0 && f[i]<0 && r[i]<0){
            break;
        }else{
            if(m[i]<0 || f[i]<0){
                printf("F\n");
            }else{
                if(m[i]+f[i]>=80){
                    printf("A\n");
                }
            if(m[i]+f[i]>=65 && m[i]+f[i]<80){
                printf("B\n");
            }
            if(m[i]+f[i]>=50 && m[i]+f[i]<65){
                printf("C\n");
            }
            if(m[i]+f[i]>=30 && m[i]+f[i]<50 && r[i]<50){
                printf("D\n");
            }
            if(m[i]+f[i]>=30 && m[i]+f[i]<50 && r[i]>=50){
                printf("C\n");
            }   
            if(m[i]+f[i]<30){
                printf("F\n");
            }
            }   
        }
    }
    return 0;
}

Measured memory_bytes: 596
import bisect
N = int(input())
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))
ans = 0
for m in B:
    ans += bisect.bisect_left(A,m)*(N-bisect.bisect_right(C,m))

print(ans)

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

template<class T>
bool ChangeMax(T&a,const T&b){
  if(a >= b) return false;
  a = b;    return true;
}

template<class T>
bool ChangeMin(T&a,const T&b){
  if(a <= b) return false;
  a = b;    return true;  
}

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  int x; cin >> x;
  int n; cin >> n;
  bitset<101> bs;
  for(int i = 0; i < n; ++i){
    int p; cin >> p;
    bs[p] = 1;
  }
  vector<int> v(1,-1);
  for(int i = 0; i <= 101; ++i){
    if(!bs[i])v.push_back(i);
  }
  int dis = 1000;
  int arg = 0;
  for(auto e:v){
    if(ChangeMin(dis,abs(x - e))){
      arg = e;
    }
  }
  cout << arg << endl;
  return 0;
}


Measured memory_bytes: 3632
import sys
from collections import Counter


def input():
    return sys.stdin.readline().strip()


N = int(input())
A = list(map(int, input().split()))
c = Counter(A)
ans = 0
for k, v in c.items():
    if v > 1:
        ans += v * (v - 1) // 2

for a in A:
    v = c[a]
    if v > 1:
        print(ans - v * (v - 1) // 2 + (v - 1) * (v - 2) // 2)
    else:
        print(ans)


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

int main(){
    string S;
    cin >> S;
    int R = 700;
    if (S[0] == 'o') R += 100;
    if (S[1] == 'o') R += 100;
    if (S[2] == 'o') R += 100;
    cout << R << endl;
    return 0;
}


Measured memory_bytes: 256
word = list(map(int,input().split()))
#print(word) ['5', '5', '7']
a=0
b=0
for i in range(3):
    if word[i]==int(5):
        a=a+1
for i in range(3):
    if word[i]==int(7):
        b=b+1
if a==2 and b==1:
	print("YES")
else:
  	print("NO")


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

int main() {
  int n;
  cin >> n;
  vector<int> P(n), Q(n), A(n), B(n); 
  for (int i = 0; i < n; i++) cin >> P.at(i);
  for (int i = 0; i < n; i++) cin >> Q.at(i);
  for (int i = 0; i < n; i++) A.at(i) = i + 1;
  
  int count = 0, x = 0, y = 0;
  do {
    count++;
    for (int i = 0; i < n; i++) B.at(i) = A.at(i);
    if (B == P) x = count;
    if (B == Q) y = count;
  } while(next_permutation(A.begin(), A.end()));

  cout << abs(x - y) << endl;
}

Measured memory_bytes: 3632
/**
 * Created by hiramekun at 20:56 on 2020-05-17.
 */
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using P = pair<ll, ll>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = ll(n - 1); i >= 0; i--)
#define each(i, mp) for(auto& i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}

template<class T>
istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template<class T>
ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

void solve() {
    ll n, m;
    cin >> n >> m;
    vector<vector<ll>> g(n);
    rep(i, m) {
        ll a, b;
        cin >> a >> b;
        a--, b--;
        g[a].eb(b), g[b].eb(a);
    }
    vector<bool> seen(n);
    vector<ll> ans(n);
    auto rec = [&](auto &&f, vl &nxt) -> void {
        vector<ll> next;
        each(nx, nxt) {
            each(e, g[nx]) {
                if (seen[e]) continue;
                seen[e] = true;
                ans[e] = nx + 1;
                next.eb(e);
            }
        }
        if (next.empty()) return;
        f(f, next);
    };
    vl tmp = vector<ll>{0};
    rec(rec, tmp);
    cout << "Yes" << '\n';
    for (ll i = 1; i < n; ++i) {
        cout << ans[i] << '\n';
    }
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        solve();
#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 23408
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    int n,k;
    cin >> n >> k;
    VLL h(n);
    REP(i,0,n) cin >> h[i];
    sort(all(h));
    LL diff = h[k-1] - h[0];
    REP(i,1,n-k+1) diff = min(diff, h[i+k-1] - h[i]);
    cout << diff << endl;
}

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

Measured memory_bytes: 1024
use std::cmp::Ordering;
use std::io::{stdin, BufRead};
fn main() {
    let stdin = stdin();
    let stdinlock = stdin.lock();
    let mut compare: Option<Ordering> = None;
    let mut current: Option<u32> = None;
    let mut seqs = 1;
    for ak in stdinlock
        .lines()
        .skip(1)
        .next()
        .expect("second line")
        .expect("read")
        .trim()
        .split_whitespace()
        .map(|ak| ak.parse::<u32>().expect("parse error"))
    {
        if let Some(c) = current {
            match ak.cmp(&c) {
                Ordering::Equal => continue,
                current_cmp => {
                    if current_cmp != compare.unwrap_or(current_cmp) {
                        seqs += 1;
                        compare = None;
                    } else {
                        compare = Some(current_cmp);
                    }
                    current = Some(ak);
                    continue;
                }
            }
        } else {
            current = Some(ak);
            continue;
        }
    }
    println!("{}", seqs);
}


Measured memory_bytes: 2972
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, a, b = map(int, input().split())

    def cmb_mod(n, r, mod):
        x, y = 1, 1
        for i in range(r):
            x = (x * (n - i)) % mod
            y = (y * (i + 1)) % mod
        return (x * pow(y, mod - 2, mod)) % mod

    total = pow(2, n, mod) - 1
    res = total - cmb_mod(n, a, mod) - cmb_mod(n, b, mod)
    print(res % mod)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
long long n,m,mem[1001][1001];
char a[1001][1001];
long long dp(int i,int j){
    if (i==n-1 && j==m-1 && a[i][j]=='.') return 1;
    if (i==n || j==m || a[i][j]=='#') return 0;
    if(mem[i][j]!=-1) return mem[i][j];
    mem[i][j]=(dp(i+1,j)+dp(i,j+1))%1000000007;

    return mem[i][j];
}
int main(){
    cin>>n>>m;
    memset(mem,-1,sizeof mem);
    for(int i=0;i<n;i++)
        for(int j=0;j<m;j++)
            cin>>a[i][j];
    cout<<dp(0,0);
}



Measured memory_bytes: 9088
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<cstdlib>
#include<bitset>
#include<utility>
#include<sstream>
#include<iomanip>
#include<ctime>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>

using namespace std;
typedef long long ll;
#define MP make_pair

int main(void) {
    double a,b,c,d,tk,ao;
    cin>>a>>b>>c>>d;

    while(1){

        c-=b;

        if(c<=0){
            cout<<"Yes\n";
            break;
        }

        a-=d;

        if(a<=0){
            cout<<"No\n";
            break;
        }


    }
    
    return 0;
}

Measured memory_bytes: 3720
#include <iostream>
#include <string>
#include <cstdlib>
#include <sstream>
#include <algorithm>

using namespace std;
 
string its(int n){
    stringstream s;
    s << n;
     
    return s.str();
}
 
int main(){
    string str;
    int n;
     
    cin >> n;
    while(n--){
        int cnt = 0;
        cin >> str;
        int len = str.size();
         
        while(len > 1){
            cnt++;
            int MAX = 0;
            for(int i = 0 ; i < len-1; i++){
                int a = atoi(str.substr(0,i+1).c_str());
                int b = atoi(str.substr(i+1,len-1).c_str());
                MAX = max(MAX,a*b);
            }
            str = "";
            str += its(MAX);
            len = str.size();
        }
        cout << cnt << endl;
    }
    return 0;
}

Measured memory_bytes: 3164
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int str1 = sc.nextInt();
		int str2 = sc.nextInt();

		String[] yoko = new String[str2 + 2];
		for(int i=0; i<yoko.length; i++){
			System.out.print("#");
		}
		System.out.println();
		
		for(int j=0; j<str1; j++){
			System.out.print("#");
			System.out.print(sc.next());
			System.out.print("#");
			System.out.println();
		}

		for(int i=0; i<yoko.length; i++){
			System.out.print("#");
		}
	}
}

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

int main() {

  long long X;
  cin >> X;

  long long A = 0;
  long long B = 0;

  for (int i = -200; i <= 200; i++) {
    A = i;
    for (int k = 0; k < 4; k++) {
      A *= i;
    }
    for (int j = -200; j <= 200; j++) {
      B = j;
      for (int k = 0; k < 4; k++) {
        B *= j;
      }
      if (A - B == X) {
        cout << i << " " << j << endl;
        return 0;
      }
    }
  }

  return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
#include <queue>
#include <map>
#include <set>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>& p) { os << p.first << " " << p.second; return os; }
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) { for(int i = 0; i < (int) v.size(); i++) os << v[i] << (i + 1 != v.size() ? " " : ""); return os; }

void solve()
{
    int a, b; cin >> a >> b;
    for(int i = 0; i <= 1e5; i++)
    {
        if(a == (int)(i * 0.08) && b == (int)(i * 0.1))
        {
            cout << i << endl;
            return;
        }
    }
    cout << -1 << endl;
}

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
#define int long long
#define V vector
#define vel V<int>
#define rep(i,n) for(int i=0;i<n;i++)
#define mkp make_pair
#define pin pair<int,int>
pin solve(V<pin>& ab, int ex) {
	if (!ex) { return mkp(1, 0); }
	V<V<pin>> qab(2);
	for (pin x : ab) {
		qab[x.second & 1].push_back(mkp(x.first / 2, x.second / 2));
		if (x.first & 1) { qab[(x.second + 1) & 1].push_back(mkp(x.first / 2, (x.second + 1) / 2)); }
	}
	V<vel> c(2, vel(2));
	rep(i, 2) {
		for (pin x : qab[i]) {
			int qc = (2 * x.first + x.second) % 3;
			if ((qc + 1) % 2) { c[i][0] ^= 1; }
			if (qc) { c[i][1] ^= 1; }
		}
	}
	rep(i, 2) {
		if (!c[1 - i][0] && !c[1 - i][1]) {
			pin ans = solve(qab[i], ex - 1);
			ans.first *= 2; ans.second *= 2; ans.second += i;
			return ans;
		}
	}
	for (pin& v : ab) { v.first++; }
	pin ans = solve(ab, ex); ans.first--;
	return ans;
}
int readint() {
	int res = 0;
	char c = getchar();
	if ('0' <= c && c <= '9') {
		while ('0' <= c && c <= '9') {
			res = res * 10 + c - '0';
			c = getchar();
		}
	}
	else {
		c = getchar();
		while ('0' <= c && c <= '9') {
			res = res * 10 + c - '0';
			c = getchar();
		}
		res *= -1;
	}
	return res;
}
signed main() {
	long long inf = 2e17;
	int n = readint();
	V<pin> ab(n);
	rep(i, n) {
		long long a, b; a = readint(); b = readint();
		ab[i] = { a + inf,b + inf };
	}
	pin ret = solve(ab, 70);
	cout << ret.first - inf << " " << ret.second - inf << "\n";
}

Measured memory_bytes: 11632
x, y, z, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

a_plus_b = []
for i in a:
    for j in b:
        a_plus_b.append(i + j)
a_plus_b.sort(reverse=True)

a_plus_b_plus_c = []
for i in a_plus_b[:k]:
    for j in c:
        a_plus_b_plus_c.append(i + j)
a_plus_b_plus_c.sort(reverse=True)

for i in range(k):
    print(a_plus_b_plus_c[i])


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

int main() {
    double d;
    cin >> d;
    int d1 = d * 1000;
    double ans = sqrt(2) * d;
    ans = max<double>(ans, (int)(d) + 1);
    printf("%.10lf\n", ans);
    return 0;
}


Measured memory_bytes: 3200
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define deb(x) cout<<#x<<" "<<x<<endl;
#define print(arr,n) for(int i=0;i<n;++i) { cout<<arr[i]<<" "; } cout<<endl;
#define ub(x,el) upper_bound(x.begin(),x.end(),el) - x.begin()
#define lb(x,el) lower_bound(x.begin(),x.end(),el) - x.begin();
#define bs(x,el) binary_search(x.begin(),x.end(),el)
#define MOD 1000000007
#define finish return 0
using namespace std;
using namespace __gnu_pbds; 
typedef long long int ll;
typedef tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;
template<int D, typename T> struct Vec : public vector<Vec<D - 1, T>> { static_assert(D >= 1, "Vector dimension must be greater than zero!"); template<typename... Args> Vec(int n = 0, Args... args) : vector<Vec<D - 1, T>>(n, Vec<D - 1, T>(args...)) { }}; template<typename T> struct Vec<1, T> : public vector<T> { Vec(int n = 0, T val = T()) : vector<T>(n, val) { } };
inline ll mod(ll x) { return (x%MOD + MOD)%MOD; }
ll gcd(ll a, ll b, ll &x, ll &y){if(a == 0){x = 0, y = 1; return b;} ll x1, y1;  ll d = gcd(b%a, a, x1, y1); x = y1 - (b/a) * x1; y = x1; return d;}
ll power(ll x,ll y, ll p) { ll res = 1; x = x % p; while (y > 0) { if (y & 1) res = (res*x) % p; y = y>>1; x = (x*x) % p;   } return res; } 
ll power(ll x,ll y) { ll res = 1; while (y > 0) { if (y & 1) res = (res*x); y = y>>1; x = (x*x);   } return res; } 
ll mod(ll num, ll den){ return mod(mod(num) * power(den,MOD-2,MOD)); }
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	ll k;
    ll a,b;
    cin>>k>>a>>b;
    for(ll i=a;i<=b;++i)
    {
        if(i%k == 0) 
        {
            cout<<"OK"<<endl;
            finish;
        }
    }
    cout<<"NG"<<endl;
}

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

int cnt = 0;

void bubblesort(vector<int> &A){
    bool flag = true;
    while(flag){
        flag = false;
        for(int j=A.size()-1; j>0; --j){
            if(A[j] < A[j-1]){
                cnt++;
                swap(A[j], A[j-1]);
                flag =true;
            }
        }
    }
}

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

    vector<int> A(n,0);
    for(auto&& x: A){
        cin >> x;
    }
    bubblesort(A);

    for(int i=0; i<n; ++i){
        if( i!= 0)
            cout << ' ';
        cout << A[i];
    }
    cout << endl;
    cout << cnt << endl;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> L(N);
  for (int i = 0; i < N; i++) {
    cin >> L[i];
  }
  sort(L.begin(), L.end());
  int ans = 0;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < i; j++) {
      for (int k = 0; k < j; k++) {
        if (L[i] != L[j] && L[j] != L[k] && L[j] + L[k] > L[i]) {
          ans++;
        }
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3596
import std.stdio, std.conv, std.string;

void main() {
	string input = chomp(readln());
	int[4] i;
	for(int j = 0; j < 4; j++) {
		i[j] = to!int(input[j]);
	}
	int a=i[0]-48, b=i[1]-48, c=i[2]-48, d=i[3]-48;
	
	if(a+b+c+d==7) writefln("%d+%d+%d+%d=7", a, b, c, d);
	else if(a+b+c-d==7) writefln("%d+%d+%d-%d=7", a, b, c, d);
	else if(a+b-c+d==7) writefln("%d+%d-%d+%d=7", a, b, c, d);
	else if(a+b-c-d==7) writefln("%d+%d-%d-%d=7", a, b, c, d);
	else if(a-b+c+d==7) writefln("%d-%d+%d+%d=7", a, b, c, d);
	else if(a-b+c-d==7) writefln("%d-%d+%d-%d=7", a, b, c, d);
	else if(a-b-c+d==7) writefln("%d-%d-%d+%d=7", a, b, c, d);
	else if(a-b-c-d==7) writefln("%d-%d-%d-%d=7", a, b, c, d);
}


Measured memory_bytes: 256