akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

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

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

  long long ok = 1e18;
  long long ng = 0;

  while (ok - ng > 1) {
    long long mid = (ok + ng) / 2;
    long long x = mid;
    for (int i = 0; i < n; i++) {
      x = x / a[i] * a[i];
    }
    if (x >= 2) {
      ok = mid;
    } else {
      ng = mid;
    }
  }

  long long mn = ok;

  ok = 1e18;
  ng = 0;

  while (ok - ng > 1) {
    long long mid = (ok + ng) / 2;
    long long x = mid;
    for (int i = 0; i < n; i++) {
      x = x / a[i] * a[i];
    }
    if (x >= 3) {
      ok = mid;
    } else {
      ng = mid;
    }
  }

  long long mx = ok;

  if (mn < mx) {
    cout << mn << ' ' << mx - 1 << endl;
  } else {
    cout << -1 << endl;
  }
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incID(i, l, r) for(LL i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(LL i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(LL i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(LL i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC static_cast
#define SI(v) SC<int>(v.size())
#define SL(v) SC<LL >(v.size())
#define RF(e, v) for(auto & e: v)
#define ef else if
#define UR assert(false)

// ---- ----

int n, a, b;

int main() {
	cin >> n >> a >> b;
	
	cout << min(a * n, b) << endl;
	
	return 0;
}


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

using namespace std;

int N, M;
int A[1000];
int dp_max[2000][2000];
int dp_min[2000][2000];

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

	dp_max[0][0] = A[0];
	dp_min[0][0] = A[0];
	for(int i = 1; i < 2 * N; i++)
	{
		int w = A[i % N];
		dp_max[i][i] = w;
		dp_min[i][i] = w;
		for(int j = 0; j < i; j++)
		{
			dp_max[j][i] = std::max(dp_max[j][i - 1], w);
			dp_min[j][i] = std::min(dp_min[j][i - 1], w);
		}
	}

	long ans = 0;
	for(int i = 0; ; i += M)
	{
		if(i != 0 && i % N == 0) break;
		int j = i % N;
		ans += dp_max[j][j + M - 1] - dp_min[j][j + M - 1];
	}
	printf("%d\n", ans);

	return 0;
}

Measured memory_bytes: 30100
N= list(input())

Kisuu = ['R', 'U', 'D']
Guusu = ['L', 'U', 'D']
flag = True

for i in range(len(N)):
#     print(i, N[i])
    if (i+1) % 2 != 0:
        if N[i] not in Kisuu:
            flag = False
    elif (i+1) % 2 == 0:
#         print(Guusu)
        if N[i] not in Guusu:
            flag = False
#     print(flag)

if flag == True:
    print('Yes')    
else:
    print('No')

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

int main () {
  int N;
  cin >> N;
  
  vector<int> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  
  int ans = 0;
  for (int i = 0; i < N; i++) {
    if (i % 2 == 0) {
      ans += a[i];
    } else {
      ans -= a[i];
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3568
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define int long long
using namespace std;
signed main() {
	int n; cin >> n;
	int p = n; if (n % 2 == 0)p++;
	cout << n * (n - 1) / 2 - (n / 2) << endl;
	for (int i = 1; i <= n; i++) {
		for (int j = i + 1; j <= n; j++) {
			if (i + j != p)cout << i << ' ' << j << endl;
		}
	}
}

Measured memory_bytes: 256
class Node
  attr_reader :id
  attr_writer :parent

  def initialize(id)
    @id = id
    @parent = nil
    @children = []
  end

  def add_child(child)
    @children << child
    child.parent = self
  end

  def child_ids
    @children.map{|n| n.id }.join(', ')
  end

  def type
    return 'root' if @parent.nil?
    return 'leaf' if @children.empty?
    'internal node'
  end

  def parent_id
    return -1 if @parent.nil?
    @parent.id
  end

  def depth
    return 0 if @parent.nil?
    1 + @parent.depth
  end
end

n = gets.to_i
nodes = n.times.map{|id| Node.new(id) }

n.times do
  id, k, *child = gets.split.map(&:to_i)
  child.each do |child_id|
    nodes[id].add_child(nodes[child_id])
  end
end

nodes.each do |n|
  puts "node #{n.id}: parent = #{n.parent_id}, depth = #{n.depth}, #{n.type}, [#{n.child_ids}]"
end

Measured memory_bytes: 25448
import java.util.ArrayList;
import java.util.Scanner;
import java.util.stream.Stream;


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

        if(a >= 1000){
            ans = "ABD";
        } else {
            ans = "ABC";
        }

        System.out.println(ans);
    }
}


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

int main()
{
    string input;
    cin >> input;
    string dates[] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
    for (int i = 0; i < 7; i++)
    {
        if (dates[i] == input)
        {
            cout << 7 - i << endl;
        }
    }
}


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

 #define tr(c, i) for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define   ipr         	pair<int, int>
#define   pb            push_back
#define   ff            first
#define   ss            second
#define   fr(i, j, k)   for (int i = j; i < k; i++)
#define   rf(i, j, k)   for (int i = j; i >= k;i--)
#define   int           long long
#define   ll 			unsigned long long
#define   ld            long double
#define   all(x)        x.begin(), x.end()
#define   rall(x)       x.rbegin(),x.rend()
#define   mp            make_pair
#define   inf           INT_MAX
#define   read_file();	freopen("input.txt", "r", stdin);	freopen("output.txt", "w", stdout);
#define   IOS           std::ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
const int Maxn  =  10000;
const ld  pi   =  acos(-1);
const int mod =  1000000007;
 
 
template<class T> ostream& operator <<(ostream &out,vector<T> &A){for(auto x:A) out<<x;return out;}
template<class T> ostream& operator <<(ostream &out,set<T> &A){for(auto x:A) out<<x<<" ";return out;}
template <class T1,class T2>T1 powr(T1 a,T2 b){T1 res = 1;fr(i,1,b+1)res = res*a;return res;}
int roundUp(int numToRound, int multiple)
{
 if(multiple == 0)
 {
  return numToRound;
 }

 int roundDown = ( (int) (numToRound) / multiple) * multiple;
 int roundUp = roundDown + multiple; 
 int roundCalc = roundUp;
 return (roundCalc);
}


 

int calc(int a, int b, int c) {
	return abs(a - b) + abs(a - c) + abs(b - c);
}


//Binary exponentiation
int binpow(int a,int b) {
    int res = 1;
while (b > 0) {
        if (b & 1)res = res * a;
        a = a * a;
        b >>= 1;
}
return res;
}
// gcd
int gcd(int a, int b){
    while(b){
        a=a%b;
        swap(a,b);
    }
    return a;
}
//lcm
int lcm(int a, int b){
    return (a*b)/gcd(a,b);
}
  
 
  

int prefix[100001]; 
  
void buildPrefix(int L,int R) 
{ 
    
    vector<bool> prime(100001,true); 
   
  
    for (int p = 2; p * p <= 100001; p++) { 
  
        
        if (prime[p] == true) { 
  
           
            for (int i = p * 2; i <= 100001; i += p) 
                prime[i] = false; 
        } 
    } 
  
    
    prefix[0] = prefix[1] = 0; 
    for (int p = L; p <= L-R; p++) { 
        prefix[p] = prefix[p - 1]; 
        if (prime[p]) 
            prefix[p] += p; 
    } 
} 
  
  int hexadecimalToDecimal(vector<char> hexVal) 
{    
    int len = (hexVal.size()); 
      int base = 1; 
      
    int dec_val = 0; 
      
    
    for (int i=len-1; i>=0; i--) 
    {    if (hexVal[i]>='0' && hexVal[i]<='9') 
        { 
            dec_val += (hexVal[i] - 48)*base; 
               base = base * 16;} 
  
        
        else if (hexVal[i]>='A' && hexVal[i]<='F') 
        { 
            dec_val += (hexVal[i] - 55)*base; 
          
            
            base = base*16; 
        } 
    } 
      
    return dec_val; 
} 


  
 
int32_t main(){IOS

int n,m;
cin>>n>>m;
vector<double>k(n);
double sum=0;
fr(i,0,n){
    cin>>k[i];
    sum+=k[i];
}
double x= sum/(4.0*m);
int cnt=0;
fr(i,0,n){
if(k[i]>=x)cnt++;
}
if(cnt>=m)cout<<"Yes"<<endl;
else cout<<"No"<<endl;







 
}



Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ld;
#define vec(s) vector

#define vvec(s) vector<vector
>
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Yes(x) cout<<(x?"Yes":"No")<<endl;
#define YES(x) cout<<(x?"YES":"NO")<<endl;
#define out(s) cout<<s<<endl;
#define pb(s) push_back(s);
#define sp " " 
#define INF 10000000000
#define LINF 9000000000000000000
#define all(s) s.begin(),s.end()
void vout(vi v){
    for(lli i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    cout << std::fixed << std::setprecision(10);
    string s;
    lli n;
    cin>>n>>s;
    lli r=0, b=0;
    rep(i,n){
        (s[i]=='R'?r++:b++);
    }
    Yes(r>b);

}

Measured memory_bytes: 3508
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        // Here your code !
        Scanner sc = new Scanner(System.in);
        String[] S = new String[3];
        for(int i=0;i<3;i++){
            S[i] = sc.next();
        }
        int next = 0;
        boolean end = false;
        String winner = null;
        while(!end){
            if(S[next].equals("")){
                switch(next){
                    case 0:
                        winner = "A";
                        break;
                    case 1:
                        winner = "B";
                        break;
                    case 2:
                        winner = "C";
                        break;
                }
                end = true;
            }else{
                int x = next;
                switch(S[next].substring(0,1)){
                case "a":
                    next = 0;
                    break;
                case "b":
                    next = 1;
                    break;
                case "c":
                    next = 2;
                    break;
                }
                S[x] = S[x].substring(1,S[x].length());
                
            }
            
        }
        System.out.println(winner);
    }
}


Measured memory_bytes: 9684
using System;

class A
{
	static void Main()
	{
		var n = int.Parse(Console.ReadLine());
		var a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);

		var r = 0;
		for (int i = 0; i < n; i++)
			for (int j = i + 1; j < n; j++)
				if (a[i] > a[j]) r++;

		Array.Sort(a);
		Console.WriteLine(string.Join(" ", a));
		Console.WriteLine(r);
	}
}



Measured memory_bytes: 20020
#include <stdio.h>
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <ctime>
#include <cassert>
#include <unordered_map>
#include <fstream>
#include <random>
#include <cstring>
#include <complex>
#include <bitset>

#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()
#define pb push_back

using namespace std;

const int P = 1e9 + 7;

typedef long long ll;
typedef long double ld;
mt19937 rr(random_device{}());

const int INF = 1e9;

int main() {
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);

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

	int n;
	cin >> n;
	vector<string> s(n);
	
	for (int i = 0; i < n; ++i) 
		cin >> s[i]; 

	vector<bool> black(n, true);
	vector<bool> white(n, true);
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < n; ++j) {
			if (s[i][j] == '.')  {
				black[j] = false;
			} else {
				white[j] = false;
			}
		}
	}
	int cntB = 0;
	for (int j = 0; j < n; ++j)
		cntB += black[j];

	bool f = true;
	for (int i = 0; i < n; ++i) {
		if (!white[i])
			f = false;
	}

	if (f) {
		cout << - 1 << endl;
		return 0;
	}

	int ans = INF;
	for (int i = 0; i < n; ++i) {
		int cur = n - cntB;
		if (white[i]) {
			++cur;
		} 
		for (int j = 0; j < n; ++j) {
			if (s[i][j] == '.')
				++cur;
		}
		ans = min(ans, cur);
	}

	cout << ans << endl;

	// for (int i = 0; i < n; ++i) {
	// 	vector<string> t = s;
	// 	int l = -1;
	// 	for (int j = 0; j < n; ++j) {
	// 		if (t[j][i] == '#')
	// 			l = j;
	// 	}
	// 	if (l == -1)
	// 		continue;
	// 	int cur = 0;
	// 	for (int j = 0; j < n; ++j) {
	// 		if (t[i][j] == '#' || i == j)
	// 			continue;
	// 		string c = t[l];
	// 		for (int k = 0; k < n; ++k) {
	// 			t[k][j] = c[k];
 // 			}
 // 			++cur;
	// 	}

	// 	if (t[i][i] == '.') {
	// 		string c = t[l];
	// 		for (int k = 0; k < n; ++k) {
	// 			t[k][i] = c[k];
 // 			}
 // 			++cur;
	// 	}

	// 	for (int j = 0; j < n; ++j) {
	// 		bool f = true;
	// 		for (int k = 0; k < n; ++k) {
	// 			if (t[k][j] == '.')
	// 				f = false;
	// 		}
	// 		if (!f)
	// 			++cur;
	// 	}
	// 	cout << cur << endl;
	// 	ans = min(ans, cur);
	// }
	// cout << (ans == INF ? -1 : ans) << endl;
}

Measured memory_bytes: 512
using System;

namespace AtCoderTutorial
{
    public class AtCoder175
    {
        public static void Main(string[] args)
        {
            string str = Console.ReadLine();

            if (str == "RRR")
            {
                Console.WriteLine(3);
                return;
            }

            if (str == "SRR")
            {
                Console.WriteLine(2);
                return;
            }

            if (str == "RRS")
            {
                Console.WriteLine(2);
                return;
            }

            if (str == "RSR")
            {
                Console.WriteLine(1);
                return;
            }

            if (str == "RSS")
            {
                Console.WriteLine(1);
                return;
            }

            if (str == "SSR")
            {
                Console.WriteLine(1);
                return;
            }

            if (str == "SRS")
            {
                Console.WriteLine(1);
                return;
            }

            Console.WriteLine(0);
        }
    }
}

Measured memory_bytes: 25952
package main

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

func main() {
	fmt.Println(resolve(parseProblem(os.Stdin)))
}

func parseProblem(r io.Reader) (int, int) {
	const (
		initialBufSize = 100000
		maxBufSize     = 1000000
	)
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords) // bufio.ScanLines
	return scanInt(sc), scanInt(sc)
}

func resolve(a, b int) int {
	g := gcd(a, b)
	t := primeFactories(g)
	return len(t) + 1
}

func isPrime(n int) bool {
	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			return false
		}
	}
	return true
}

func eratosthenes(n int) []bool {
	t := make([]bool, n)
	for i := 2; i < len(t); i++ {
		t[i] = true
	}
	for i := 2; i < len(t); i++ {
		if !t[i] {
			continue
		}
		for j := 2; j*i < len(t); j++ {
			t[j*i] = false
		}
	}
	return t
}

func primes(n int) chan int {
	ch := make(chan int)
	go func() {
		t := eratosthenes(n)
		for i := 2; i < len(t); i++ {
			if !t[i] {
				continue
			}
			ch <- i
		}
		close(ch)
	}()
	return ch
}

func primeFactories(n int) (terms map[int]int) {
	terms = map[int]int{}
	num := n
	for f := 2; f*f < n; f++ {
		if num%f != 0 {
			continue
		}
		ex := 0
		for num%f == 0 {
			num /= f
			ex++
		}
		terms[f] = ex
	}
	if num > 1 {
		terms[num] = 1
	}
	return
}

func gcd(a, b int) int {
	for b > 0 {
		t := a / b
		a, b = b, a-t*b
	}
	return a
}

// snip-scan-funcs
func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}
func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 640
import java.util.Scanner;


public class Main {
    public static void main(String[] args) throws Exception {
        //スキャン
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        
        int five = H / 500 * 1000;
        int zan = H % 500;
        int litFic = zan /5 * 5;
        System.out.println(five + litFic);
    }
}

Measured memory_bytes: 23764
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)

from collections import deque


def initialize_maze(h, w):
    grid = [["."] * (w + 2) for _ in range(h + 2)]

    for row in range(h + 2):
        grid[row][0] = "#"
        grid[row][w + 1] = "#"

    for col in range(w + 2):
        grid[0][col] = "#"
        grid[h + 1][col] = "#"

    return grid


def main():
    def bfs():
        que = deque()
        que.append((1, 1, 0))

        while que:
            row, col, count = que.popleft()
            for mr, mc in ((1, 0), (0, 1), (-1, 0), (0, -1)):
                nr, nc = row + mr, col + mc
                if grid[nr][nc] == ".":
                    que.append((nr, nc, count + 1))
                    grid[nr][nc] = "!"
                elif grid[nr][nc] == "G":
                    min_count = count + 1
                    return min_count
        return - 1

    h, w = map(int, readline().split())
    grid = initialize_maze(h, w)

    black_num = 0
    for row in range(1, h + 1):
        s = input()
        for col, state in enumerate(s, 1):
            grid[row][col] = state
            if state == "#":
                black_num += 1

    grid[h][w] = "G"

    grid[1][1] = "!"
    min_count = bfs()

    if min_count == -1:
        print(-1)
    else:
        print(h * w - black_num - min_count - 1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 39920
S = input()

if 1 <= int(S[:2]) <= 12 and 1 <= int(S[2:]) <= 12:
    print('AMBIGUOUS')
elif 1 <= int(S[:2]) <= 12:
    print('MMYY')
elif 1 <= int(S[2:]) <= 12:
    print('YYMM')
else:
    print('NA')


Measured memory_bytes: 2940
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define rep2(i, l, r) for (ll i = (l); i < (r); i++)
#define ALL(x) (x).begin(), (x).end()     //昇順
#define RALL(x) (x).rbegin(), (x).rend()  // 降順
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
const long long mod = 1e9 + 7;
typedef long long ll;
typedef priority_queue<int> PQ;
typedef vector<long long> VL; // VL a(n);
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<VS> VSS;
typedef vector<VC> VCC;
typedef vector<VL> VLL; // VII a(n,VI(m)) n * m
typedef pair<ll, ll> PL;
typedef map<ll, ll> MP; // MP a;
typedef vector<pair<ll, ll>> PS; // PS a(n);

template <class T, class U>
bool chmax(T &a, U b) {
  if (a <= b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T, class U>
bool chmin(T &a, U b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
  os << "}";
  return os;
}

// g++ -std=c++11 prac.cpp
// operator << (cout,a);
// chmin(min,a)
ll sum(ll n){return n*(n+1)/2;} 

int main() {
  ll n,k,m,x=0,y=0,z=0,cnt=0,h=0,w=0,sum=0,ans=0,Max=0, Min=3e9+1;
  string s,t;
  cin >> n;
  VL a(n+2);
  a[0]=0;
  rep2(i,1,n+1) cin >> a[i];
  a[n+1]=0;
  rep(i,n+1){
    sum += abs(a[i]-a[i+1]);
  }
  for(int i=1; i<n+1; i++){
    pri(sum + abs(a[i-1]-a[i+1]) - abs(a[i-1]-a[i]) - abs(a[i]-a[i+1]));
  }
  return 0;
}

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

#define MAX 502

int h;
int w;

char room[MAX][MAX];

bool f1[MAX][MAX];
bool f2[MAX][MAX];
vector<pair<int, int> > v;
void output(){
	for (int i = 0; i < h; i++){
		for (int j = 0; j < w; j++){
			if (f1[i][j]){
				printf("#");
			}
			else{
				printf(".");
			}
		}
		puts("");
	}
	puts("");
	for (int i = 0; i < h; i++){
		for (int j = 0; j < w; j++){
			if (f2[i][j]){
				printf("#");
			}
			else{
				printf(".");
			}
		}
		puts("");
	}
}
bool ap[MAX];
int las[MAX];

int main(){
	cin >> h >> w;
	for (int i = 0; i < h; i++){
		scanf("%s", room[i]);
	}
	for (int i = 0; i < h; i++){
		for (int j = 0; j < w; j++){
			if (room[i][j] == '#'){
				v.push_back(make_pair(i, j));
				f1[i][j] = true;
				f2[i][j] = true;
				ap[i] = true;
				las[i] = j;
			}
		}
	}

	if (v.size() == 0){
		output();
		return 0;
	}
	for (int i = 0; i < h; i++){
		for (int j = 0; j < w; j++){
			f1[i][j] = true;
		}
	}
	for (int i = 0; i + 1 < h; i += 2){
		for (int j = 1; j + 1 < w; j++){
			f2[i][j] = true;
			if (room[i][j] == '.')f1[i][j] = false;
		}
		if (i + 1 < h){
			if (ap[i + 1]){

			}
			else{
				
			}
		}
	}
	for (int i = 1; i < h; i+=2){
		for (int j = 0; j+1 < w; j++){
			f1[i][j] = true;
		}
	}
	for (int i = 0; i < h; i++){
		f2[i][w - 1] = true;
		f1[i][w - 1] = false;
	}
	output();
	return 0;
}

Measured memory_bytes: 3568
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:https://atcoder.jp/contests/abc115/tasks/abc115_d>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */


template<class Type>
Type solve(Type res = Type()){
    ll N,X; cin >> N >> X;
    vector<ll> sumL(51),sumP(51);
    sumL[0] = 1;
    sumP[0] = 1;
    for(int i = 1; i <= 50; i++){
        sumL[i] = 2*sumL[i-1] + 3;
        sumP[i] = 2*sumP[i-1] + 1;
    }
    
    ll L = N;
    while(X){
        if(L == 0) { X-=1; res++; }
        else{
            if(X == 1){ // B
                X--;
            }else if(X <= sumL[L-1]+1){ // L-1 B
                X-=1;
            }else if(X == sumL[L-1]+2){ // P
                res += sumP[L-1] + 1;
                X -= sumL[L-1] + 2;
            }else if(X <= sumL[L-1]*2 + 2){ // L-1 B
                res += sumP[L-1] + 1;
                X -= sumL[L-1] + 2;
            }else if(X == sumL[L-1]*2 + 3){ // B
                res += sumP[L-1]*2 + 1;
                X -= sumL[L-1]*2 + 3;
            }
            L-=1;
        }
    }
    
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


Measured memory_bytes: 256
A,B,C,D=(int(x) for x in input().split())
t=A/D
a=C/B
if A<=D:
    t=1
elif A%D==0:
    t=t
else:
    t=t+1
if C<=B:
    a=1
elif C%B==0:
    a=a
else:
    a=a+1

if a<=t:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9192
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <sstream>
#include <algorithm>
#include <cmath>

using namespace std;

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



int main(){
  cin.tie(0); ios::sync_with_stdio(false);    // Magic for faster cin
  
  string s;
  cin>>s;
  int price = 700;

  rep(i,3){
    auto c = s[i];
    if(c=='o') price += 100;
  }
  
  cout << price << endl;
  
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        final Scanner sc = new Scanner(System.in);

        final String S = sc.next();

        final int upper = Integer.valueOf(S.substring(0, 2));
        final int lower = Integer.valueOf(S.substring(2, 4));

        if (1 <= upper && upper <= 12 && 1 <= lower && lower <= 12) {
            System.out.println("AMBIGUOUS");
        } else if (1 <= upper && upper <= 12) {
            System.out.println("MMYY");
        } else if (1 <= lower && lower <= 12) {
            System.out.println("YYMM");
        } else {
            System.out.println("NA");
        }
    }
}


Measured memory_bytes: 35476
// AOJ DPL_3_B Largest Rectangle
// 2018.5.12 bal4u
 
#include <stdio.h>
#include <stdlib.h>

#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif
 
int in()
{
    int n = 0, c = gc();
    do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
    return n;
}

typedef struct { int lp, h; } STACK;
STACK stack[1500]; int top;

int maxRectInHistogram(int n, int *h)
{
	int i, s, ans;

	h[n] = 0;
	
	ans = 0;
	stack[0].lp = -1, stack[0].h = -1, top = 0;
	for (i = 0; i <= n; i++) {
		if (h[i] == stack[top].h) continue;
		if (h[i] > stack[top].h) {
			stack[++top].lp = i, stack[top].h = h[i];
		} else {
			while (h[i] < stack[top].h) {
				s = stack[top].h*(i-stack[top].lp);
				top--;
				if (s > ans) ans = s;
			}
			stack[++top].h = h[i];
		}
	}
	return ans;
}

int h[1402][1402];
char map[1402][1402];

int main()
{
	int H, W, r, c, t, ans;

	H = in(), W = in();
	for (r = 0; r < H; r++) for (c = 0; c < W; c++) {
		map[r][c] = gc() & 1; gc();
	}
	
	for (c = 0; c < W; c++) {
		t = 0;
		for (r = 0; r < H; r++) {
			if (map[r][c]) t = 0;
			else h[r][c] = ++t;
		}
	}
	
	ans = 0;
	for (r = 0; r < H; r++) {
		t = maxRectInHistogram(W, h[r]);
		if (t > ans) ans = t;
	}
	printf("%d\n", ans);
	return 0;
}



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

#define ASC(vec) vec.begin(), vec.end()    // 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend() // 降順ソート 例：sort(DESC(vec));
#define rep(i, n) for (int i = 0; i < (n); i++)
#define Rep(i, n) for (int i = 1; i < n; i++)
#define REP(i, vec) for (auto i = vec.begin(); i != vec.end(); ++i)

const int       mod = 1000000007;
const int       inf = (1 << 21);
const long long INF = 1LL << 60;

using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vii = vector<pair<int, int>>;
using vll = vector<pair<ll, ll>>;

template<class T>
inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T>
inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T>
T GCD(T a, T b) { if (b == 0) return a; else return GCD(b, a % b); }
template<class T>
T LCM(T a, T b) { return a / GCD(a, b) * b; }

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };

// ──────────────────────────────────────────────────────────────────

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

	int a = 0;
	rep(i, c) {
		int v;
		cin >> v;
		a += v;
	}

	cout << a / (n + 1) + ((a % (n + 1) != 0) ? 1 : 0) << endl;
}


Measured memory_bytes: 3084
#include<iostream>

int main(void){
	int a,b,c;
	std::cin >> a >>  b >> c;
	if(a<1||b<1||c<1||a>500||b>500||c>1000){
		std::cout << "Input Err" << std::endl;
		return -1;
	}else if(a+b<c){
		std::cout << "No" << std::endl;
	}else{
		std::cout << "Yes" << std::endl;
	}
	return 0;
}

Measured memory_bytes: 256
import sys
import numpy as np
from collections import Counter
input = sys.stdin.buffer.readline
N = int(input())
A = np.array([0] + list(map(int, input().split())))


def f(n):
    return n * (n - 1) // 2


cumsum = A.cumsum()
ans = 0
for key, value in Counter(cumsum).items():
    ans += f(value)
print(ans)


Measured memory_bytes: 52912
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <climits>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <functional>
#include <set>
#include <numeric>
#include <stack>
#include <utility>
#include <time.h>
#include <iterator>
//#include "util.h"

using namespace std;
typedef unsigned uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vint;
typedef vector<ll> vll;

//呪文
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const pair<_KTy, _Ty>& m) { cout << "{" << m.first << ", " << m.second << "}"; return ostr; }
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const map<_KTy, _Ty>& m) { if (m.empty()) { cout << "{ }"; return ostr; } cout << "{" << *m.begin(); for (auto itr = ++m.begin(); itr != m.end(); itr++) { cout << ", " << *itr; } cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const vector<_Ty>& v) { if (v.empty()) { cout << "{ }"; return ostr; }	cout << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const set<_Ty>& s) { if (s.empty()) { cout << "{ }"; return ostr; } cout << "{" << *(s.begin()); for (auto itr = ++s.begin(); itr != s.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
#define PI 3.14159265358979323846
#define EPS 1e-8
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define all(x) (x).begin(), (x).end()
	


int main() {
	int A, B;
	cin >> A >> B;
	if (A + B >= 10) cout << "error";
	else cout << A + B;
	cout << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define ALL(vec) vec.begin(), vec.end()
#define rALL(vec) vec.rbegin(), vec.rend()
using namespace std;
using ll = long long;
// ------------------------------

int main() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) {
        cin >> A[i];
    }
    vector<ll> S(N);
    for (int i = N - 1; i >= 0; --i) {
        if (i == N - 1) S[i] = 0;
        else S[i] = (A[i + 1] + S[i + 1]) % ((int)1e9 + 7);
    }
    ll ans = 0;
    rep(i, N) {
        ans = (ans + A[i] * S[i]) % ((int)1e9 + 7);
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
  int n,m;
  cin >> n >> m;
  vector<int> h(n);
  for (int i = 0; i < n; i++)
  {
    cin >> h[i];
  }

  vector<bool> flgs(n,true);
  for (int i = 0; i < m; i++)
  {
    int a,b;
    cin >> a >> b;
    a--;
    b--;
    if(h[a]>=h[b]) flgs[b] = false;
    if(h[b]>=h[a]) flgs[a] = false;    
  }

  int ans = 0;
  for (int i = 0; i < n; i++)
  {
    if(flgs[i]){ 
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3784
#include<bits/stdc++.h>
//#include<tr1/unordered_map>
#pragma GCC optimize ("Ofast")
#define ll long long
#define pll pair<long long,long long>
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define forn(i, n) for(int i=0; i<int(n); i++)
#define Forn(i, n) for(int i=1; i<=int(n); i++)

using namespace std;

int n;
int pos[100010];
set<int> s;
ll ans;

bool valid(int x){return ((1<=x) && (x<=n));}

int main()
{
    cin.tie(0); ios_base::sync_with_stdio(false);
    cin >> n;
    Forn(i, n)
    {
        int x;
        cin >> x;
        pos[x] = i;
    }
    s.insert(-1);
    s.insert(0);
    s.insert(n+1);
    s.insert(n+2);
    s.insert(pos[n]);
    for(int i=n-1; i>=1; i--)
    {
        int newpos = pos[i];
        auto ite = s.lower_bound(newpos);
        int next1 = *ite;
        ite++;
        int next2 = *ite;
        ite--;
        ite--;
        int prev1 = *ite;
        ite--;
        int prev2 = *ite;

        ll times = 0;
        if(valid(next1)) times += (ll)(next2-next1) * (ll)(newpos-prev1);
        if(valid(prev1)) times += (ll)(next1-newpos) * (ll)(prev1-prev2);
        ans += (times * i);

        s.insert(newpos);
    }
    cout << ans << endl;
}


Measured memory_bytes: 5376
fun main(args: Array<String>) {
    val s = readString()
    val ans = StringBuilder()
    repeat(s.length) {
        ans.append("x")
    }
    println(ans)
}

// Tools
fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)

Measured memory_bytes: 33740
#include<bits/stdc++.h>
using namespace std;
#define max(a,b) (a<b?b:a)
#define abs(x) (x<0?(-x):x)
#define F(i,L,R) for (int i = L; i < R; i++)
#define FE(i,L,R) for (int i = L; i <= R; i++)
#define RF(i,L,R) for (int i = L; i > R; i--)
#define RFE(i,L,R) for (int i = L; i >= R; i--)
#define getI(a) scanf("%d", &a)
#define getII(a,b) scanf("%d%d", &a, &b)
#define getIII(a,b,c) scanf("%d%d%d", &a, &b, &c)
#define VgetI(n) int (n); scanf("%d",&(n))
#define VgetII(n,m) int (n),(m); scanf("%d %d",&(n),&(m))
#define VgetIII(n,m,k) int (n),(m),(k); scanf("%d %d %d",&(n),&(m),&(k))
#define ll long long
#define INF 1000000000000000005
#define nINF -2000000000
#define MOD 1e9+7
#define PI 3.1415926535897932384626
int main(){
	int n;
	while(~getI(n)){
		int ans=0,v[n],c[n];
		F(i,0,n) getI(v[i]);
		F(i,0,n) getI(c[i]);
		F(i,0,n) if(v[i]-c[i]>0) ans+=v[i]-c[i];
		printf("%d\n",ans);
	}
}


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

using namespace std;

int main()
{
	string s;
	int K;
	cin >> s >> K;
	for (int i = 0; i < s.length(); i++) {
		if (i == s.length() - 1) {
			s[i] = 'a' + (s[i] - 'a' + K) % 26;
		}
		else if (s[i] != 'a' && s[i] + K > 'z') {
			K -= 'z' - s[i] + 1;
			s[i] = 'a';
		}
	}
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 640
while True:
    score = 'F'
    m, f, r = map(int,input().split())
    if m == -1 and f == -1 and r == -1:
        break
    total = m + f
    
    if m == -1 or f == -1:
        print(score)
        continue
    
    if total >= 80:
        score = 'A'
    elif total >= 65:
        score = 'B'
    elif total >= 50:
        score = 'C'
    elif total >= 30:
        score = 'D'
        if r >= 50:
            score = 'C'
    
    print(score)


Measured memory_bytes: 5596
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;

namespace MyProject
{
    class Program
    {
        static void Main(string[] args)
        {
#if Local
            var sw = new Stopwatch();
            sw.Start();
            Console.SetIn(new StreamReader("input.in"));
#endif

            var solver = new Solver();
            solver.Solve();
#if Local
            Console.WriteLine($"{sw.ElapsedMilliseconds}ms");
#endif
        }
    }

    class Solver
    {
        public void Solve()
        {
            var items = Console.ReadLine().Split().Select(elem => int.Parse(elem)).ToArray();
            var N = items[0];
            var X = items[1];
            var Y = items[2];

            var dict = new Dictionary<int, int>();
            foreach (var i in Enumerable.Range(1, N - 1))
            {
                foreach (var j in Enumerable.Range(i + 1, N - i))
                {
                    var distance = Math.Min(Math.Abs(i - j), Math.Abs(X - i) + 1 + Math.Abs(Y - j));
                    if (dict.ContainsKey(distance))
                    {
                        dict[distance]++;
                    }
                    else
                    {
                        dict[distance] = 1;
                    }
                }
            }

            foreach (var k in Enumerable.Range(1, N - 1))
            {
                Console.WriteLine(dict.ContainsKey(k) ? dict[k] : 0);
            }
        }
    }
}


Measured memory_bytes: 13280
#include<stdio.h>
int main()
{
int n,sum,max;
  sum=0;
  max=0;
  scanf("%d",&n);
int a[n],i;
  for(i=0;i<n;++i)
  {
  scanf("%d",&a[i]);
  sum=sum+a[i];
  if(a[i]>max) max=a[i];
  }
if(sum > 2*max) printf("Yes");
  else printf("No");
return 0;}

Measured memory_bytes: 1724
#include <stdio.h>
#include<string.h>

int main()
{
    char s[1001];
    scanf("%s",s);
    char char_array[1001],str2[1001];
    char str[1001];
    strcpy(char_array,s);
    int t,i,a,b,k=0,l=0;
    char temp,p[1001];
    scanf("%d",&t);
    while(t--)
    {
        scanf("%s",str);
        if(strcmp(str,"replace")==0)
        {
            scanf("%d%d",&a,&b);
            scanf("%s",str2);
            for(i=a; i<=b; i++)
            {
                temp=char_array[i];
                char_array[i]=str2[k];
                str2[k]=temp;
                k++;
            }
            k=0;
        }
        else if(strcmp(str,"reverse")==0)
        {
            scanf("%d%d",&a,&b);
            while(a<b)
            {
                temp=char_array[a];
                char_array[a]=char_array[b];
                char_array[b]=temp;
                a++;
                b--;
            }
        }
        else if(strcmp(str,"print")==0)
        {
            scanf("%d%d",&a,&b);
            for(i=a; i<=b; i++)
            {
                p[l]=char_array[i];
                l++;
            }
            p[l]='\0';
            printf("%s\n",p);
            l=0;
        }
    }
}


Measured memory_bytes: 2092
#include <bits/stdc++.h>
using namespace std;
 
 
#define ll long long
#define MOD 1000000007
#define pll             pair<ll,ll>
#define pii             pair<int,int> 
#define mp(a,b)         make_pair(a,b)
#define pb 				push_back
#define vi				vector<int>
#define vl 				vector<long long>
#define vb 				vector<bool>
#define printv(v)		for(auto x : v) cout<<x<<' ';br;
#define FOR(i,a,b) 		for(ll i = a; i <= b ; i++)
#define forn(i,n) 		for(ll i = 0 ; i < n; i++)
#define br 				cout<<endl;
#define testc()			ll t;cin>>t;while(t--)
 
#define fast 			ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define INF				INT_MAX
#define INFL			LLONG_MAX
#define max1(x,y) (x)>(y)?(x):(y)
#define ss second
#define ff first
#define MAXN 100001

int main(){
    fast
    ll n,m;
    cin>>n>>m;
    char grid[n+1][m+1];
    FOR(i,1,n){
        FOR(j,1,m)
        cin>>grid[i][j];
    }
    ll ans[n+1][m+1];
    memset(ans,0,sizeof(ans));
    FOR(i,1,n){
        if(grid[i][1]=='#')
        break;
        ans[i][1]=1;
    }
    FOR(i,1,m){
        if(grid[1][i]=='#')
        break;
        ans[1][i]=1;
    }
    FOR(i,2,n){
        FOR(j,2,m){
            if(grid[i][j]=='.')
            ans[i][j]=ans[i-1][j]+ans[i][j-1];
            else
            ans[i][j]=0;
            ans[i][j]%=MOD;
        }
    }
    // FOR(i,0,n){
    //     FOR(j,0,m){
    //         cout<<grid[i][j]<<" ";
    //     }
    //     cout<<endl;
    // }
    // FOR(i,0,n){
    //     FOR(j,0,m){
    //         cout<<ans[i][j]<<" ";
    //     }
    //     cout<<endl;
    // }
    cout<<ans[n][m]<<endl;
    return 0;
}

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

using namespace std;

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

    // 文字数チェック
    if(s.length()+1!=t.length()){
        cout << "No" << endl;
        return 0;
    }
    // 文字列一致チェック
    if(s!=t.substr(0,s.length())){
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i , n) for (int i = 0; i < (int)(n); i++)
const int INF = 1<<29;
using namespace std;
using ll = long long;
ll l , a[500001];
int main(){
    int a , b , c , n , s = 0;
    cin >> a >> b >> c >> n;
    for(int i = 0; i <= a; i++){
        for(int j = 0; j <= b; j++){
            for(int k = 0; k <= c; k++){
                if(i * 500 + j * 100 + k * 50 == n){
                    s++;
                }
            }
        }
    }
    cout << s << endl;
}


Measured memory_bytes: 3552
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <cctype>    // isupper, islower, isdigit, toupper, tolower
#include <cmath>     // pow
#include <cstdint>   // int64_t, int*_t
#include <cstdio>    // printf
#include <deque>     // deque
#include <iomanip>   // setprecision
#include <iostream>  // cout, endl, cin
#include <map>       // map
#include <queue>     // queue, priority_queue
#include <set>       // set
#include <stack>     // stack
#include <string>    // string, to_string, stoi
#include <tuple>     // tuple, make_tuple
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <utility>       // pair, make_pair
#include <vector>        // vector
using namespace std;

int gcd(long long a, long long b) { return b != 0 ? gcd(b, a % b) : a; }
// cout << fixed << setprecision(10);
// vector<vector<int>> vec(H, vector<int>(W))    // int H*W
// int binary_search(int key) {
//     int ng = -1;
//     int ok = (int)a.size();
//     while(abs(ok - ng) > 1) {
//         int mid = (ok + ng) / 2;
//         if(isOK(mid, key))
//             ok = mid;
//         else
//             ng = mid;
//     }
//     return ok;
// }
int main() {
    int L, R;
    cin >> L >> R;
    int N = min(2019, R - L);
    vector<int> vec;
    for(size_t i = L; i <= L + N; i++) {
        vec.push_back(i % 2019);
    }
    int ans = 2019;
    for(size_t i = 0; i < N; i++) {
        for(size_t j = i + 1; j < N+1; j++) {
            ans = min(ans,vec[i]*vec[j]%2019);
        }
    }
    cout << ans << endl;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define int long long

signed main(){
    int r, D, x;
    cin >> r >> D >> x;
    rep(i,10){
        x = r * x - D;
        cout << x << endl;
    }
}

Measured memory_bytes: 256
#!/usr/bin/ruby
N,*A=`dd`.split.map &:to_i
h=Hash.new 0
A.each{|e|
	if e%4==0
		h[2]+=1
	elsif e%2==0
		h[1]+=1
	else
		h[0]+=1
	end
}
a=nil
if h[0]>0
	a=0
	h[0]-=1
elsif h[1]>0
	a=1
	h[1]-=1
else
	a=2
	h[2]-=1
end
while h.values.any?{|e|e>0}
	if a==0&&h[2]>0
		a=2
		h[2]-=1
	elsif a==1&&h[1]>0
		a=1
		h[1]-=1
	elsif a==1&&h[2]>0
		a=2
		h[2]-=1
	elsif a==2&&h[0]>0
		a=0
		h[0]-=1
	elsif a==2&&h[1]>0
		a=1
		h[1]-=1
	elsif a==2&&h[2]>0
		a=2
		h[2]-=1
	else
		puts :No
		exit
	end
end
puts :Yes

Measured memory_bytes: 11936
#include<stdio.h>

int main()
{
	char c;
	int n,re=0,sum=0;

	while(scanf("%c",&c) != EOF)
	{
		switch(c)
		{
		case 'I':
			n=1;break;
		case 'V':
			n=5;break;
		case 'X':
			n=10;break;
		case 'L':
			n=50;break;
		case 'C':
			n=100;break;
		case 'D':
			n=500;break;
		case 'M':
			n=1000;break;
		default:
			n=0;break;
		}
		if(!re)
		{
			re=n;
			continue;
		}
		else
		{
			if(re>=n)
			{
				sum+=re;
			}
			else
			{
				sum-=re;
			}
			if(!n)
			{
				printf("%d\n",sum);
				re=0;
				sum=0;
				continue;
			}
			re=n;
		}
	}
	
	return 0;
}

Measured memory_bytes: 536
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;


int main(){
    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    sort(a,a+3);
    int ans=0;
    ans+=a[2]-a[1];
    a[0]+=ans;
    ans+=(a[2]-a[0])/2;
    if(a[0]%2==a[2]%2) cout << ans << endl;
    else cout << ans+2 << endl;
    return 0;
}

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

int main(){
  int N;
  cin >> N;
  if (N==1){
    cout << 1 << endl;
    return 0;
  }
  int x[N], y[N], sc=N, scb=N, p=0, q=0, wh=0;
  for(int i=0; i<N; i++) cin >> x[i] >> y[i];
  for(int i=0; i<N-1; i++){
    for(int j=i+1; j<N; j++){
      p=x[j]-x[i], q=y[j]-y[i], sc=N;
      for(int k=0; k<N; k++){
        for(int l=0; l<N; l++){
          if (k==l) continue;
          if (x[k]-x[l] == p && y[k]-y[l] ==q) sc--;
        }
      }
      scb = min(sc, scb);
    }
  }
  cout << scb << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);

        while (true) {
            int H = scan.nextInt(), W = scan.nextInt();

            if (H == 0 && W == 0) {
                break;
            }

            for (int h = 0; h < H; h++) {
                //1????????¨??????????????????
                if (h % 2 == 0) {
                    for (int w = 0; w < W; w++) {
                        if (w % 2 == 0) {
                            System.out.print("#");
                        }else {
                            System.out.print(".");
                        }
                    }
                } else {
                    for (int i = 0; i < W; i++) {
                        if (i % 2 == 0) {
                            System.out.print(".");
                        } else {
                            System.out.print("#");
                        }
                    }
                }
                System.out.println();
            }
            System.out.println();
        }
    }
}

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

int main (){
	string n;cin>>n;
    for(int i=0;i<3;i++){
		if(n[i]=='1'){
			n[i]='9';
		}else{
			n[i]='1';
		}
	}
    cout<<n<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
#define fi first
#define se second
#define ll long long
int main(){
	int n, m;
	scanf("%d %d", &n, &m);
	int a[n];
	for (int i = 0; i < n; i++) scanf("%d", &a[i]);
	sort(a, a + n);
	pair<int, int> p[m];
	for (int i = 0; i < m; i++) scanf("%d %d", &p[i].se, &p[i].fi);
	sort(p, p + m);
	reverse(p, p + m);
	int pos = 0;
	bool b = false;
	for (int i = 0; i < m; i++){
		for (int j = 0; j < p[i].se; j++){
			if (p[i].fi > a[pos]){
				a[pos] = p[i].fi;
				pos++;
				if (pos == n){
					b = true;
					break;
				}
			}else{
				b = true;
				break;
			}
		}
		if (b) break;
	}
	ll sum = 0;
	for (int i = 0; i < n; i++) sum += a[i];
	printf("%lld\n", sum);
}

Measured memory_bytes: 1280
n, k = map(int, input().split())
p = list(map(int, input().split()))

for i in range(n):
    p[i] = (1+p[i])/2

s = 0
for i in range(k):
    s += p[i]

ans = s
for i in range(k, n):
    s += p[i]
    s -= p[i-k]
    ans = max(ans, s)

print(ans)


Measured memory_bytes: 25060
#include <stdio.h>

int main()
{
	int A, B;
	scanf("%d %d", &A, &B);
	if (A == B) printf("%d\n", A + B);
	else if (A > B) printf("%d\n", A * 2 - 1);
	else printf("%d\n", B * 2 - 1);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 1708