akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))

using namespace std;
typedef pair<llint, llint> P;

llint n;
llint a[100005];

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	bool flag = false;
	for(int i = 1; i <= n; i++){
		cin >> a[i];
		if(a[i] == 0) flag = true;
	}
	if(flag){
		cout << 0 << endl;
		return 0;
	}
	
	llint ans = 1;
	for(int i = 1; i <= n; i++){
		if(ans <= 1000000000000000000 / a[i]) ans *= a[i];
		else{
			cout << -1 << endl;
			return 0;
		}
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 4396
x, y, a, b, c = map(int, input().split())
p = [int(i) for i in input().split(" ")]
q = [int(i) for i in input().split(" ")]
r = [int(i) for i in input().split(" ")]
p = sorted(p)
q = sorted(q)
r = sorted(r)
x_ = a-x
y_ = b-y
flag = 0
ans = sum(p[x_:]) + sum(q[y_:])
for i in range(c-1, -1, -1):
    if p[x_] > q[y_]:
        if q[y_] < r[i]:
            ans += r[i] - q[y_]
            y_ += 1
            if y_>=b:
                flag = 1
                break
        else:
            break
    else:
        if p[x_] < r[i]:
            ans += r[i] - p[x_]
            x_ += 1
            if x_>=a:
                flag = 2
                break
        else:
            break
if flag == 1:
    for j in range(i-1, -1, -1):
        if x_>=a:
            break
        if p[x_] < r[j]:
            ans += r[j] - p[x_]
            x_ += 1
        else:
            break
elif flag == 2:
    for j in range(i-1, -1, -1):
        if y_>=b:
            break
        if q[y_] < r[j]:
            ans += r[j] - q[y_]
            y_ += 1
        else:
            break
            
print(ans)


Measured memory_bytes: 23340
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<string>
#include<time.h>
#include<iomanip>
#include<list>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<bitset>
#include <queue>
#include <map>

using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldouble = long double;

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

const int MAX = 510000;
const int MOD = 1000000007;

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

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

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


int main() {
    COMinit();
    int n, m;
    cin >> n >> m;
    ull x = COM(n, 2);
    ull y = COM(m, 2);
    cout << x + y << endl;
    return 0;
}



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

int main(){
  vector<vector<int>> bi(3,vector<int>(3));
  
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
      cin >> bi[i][j];
    }
  }
  
  int N;
  cin >> N;
  
  vector<int> b(N);
  
  for(int i=0;i<N;i++){
    cin >> b[i];
  }
  
  for(int i=0;i<N;i++){
    for(int j=0;j<3;j++){
      for(int k=0;k<3;k++){
        if(bi[j][k]==b[i]){
          bi[j][k]=0;
        }
      }
    }
  }
  
  bool ans=false;
  
  for(int i=0;i<3;i++){
    if(bi[0][i]==0&&bi[1][i]==0&&bi[2][i]==0){
      ans=true;
    }
    else if(bi[i][0]==0&&bi[i][1]==0&&bi[i][2]==0){
      ans=true;
    }
  }
  
  if(bi[0][0]==0&&bi[1][1]==0&&bi[2][2]==0){
    ans=true;
  }
  
  else if(bi[2][0]==0&&bi[1][1]==0&&bi[0][2]==0){
    ans=true;
  }
  
  if(ans==true){
    cout << "Yes" << endl;
  }
  
  else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using ll = long long;
using p = pair<int,int>;
using Graph = vector<vector<int>>;
int main(int argc, const char * argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if(abs(c-a)<=d||(abs(c-b)<d&&abs(b-a)<=d))cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    return 0;
}

Measured memory_bytes: 3628
import math
import sys

def getinputdata():

    # 配列初期化
    array_result = []
    
    data = input()

    
    array_result.append(data.split(" "))

    flg = 1

    try:


        while flg:

            data = input()

            array_temp = []

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = 1

            else:

                flg = 0
    finally:


        return array_result





arr_data = getinputdata()

a = int(arr_data[0][0])
b = int(arr_data[0][1])
c = int(arr_data[0][2])

if (a==7 and b==5 and c==5) or (a==5 and b==7 and c==5) or (a==5 and b==5 and c==7):
    
    print("YES")
else:


    print("NO")



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

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

#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;

const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const double PI = 3.1415926535;
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;

ll solve(ll x, ll y){
  ll temp = e9*10;
  rep(i, 1, x){
    ll a = i*y;
    ll remain = x*y-a;
    ll b=(y/2)*(x-i);
    ll c=(y/2+y%2)*(x-i);
    ll d=(y)*((x-i)/2);
    ll e=(y)*((x-i)/2+(x-i)%2);
    ll ans = min(max({a, b, c})-min({a, b, c}),max({a, d, e})-min({a, d, e}));
    temp = min(ans, temp);
  }
  return temp;
}
int main(){
  ll h, w;
  cin >> h >> w;
  cout << min(solve(h, w),solve(w, h)) << endl;
}

Measured memory_bytes: 3592
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>


using namespace std;

int main()
{
	string s, ans;
	int n;
	//int count=0;

	cin >> s;
	n = s.size();
		
	for (int i = 0; i < n; i+=2) 
	{

		ans += s.at(i);

	}

	cout << ans << endl;


	return 0;

}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using Edge = pair<int, ll>;
using Graph = vector<vector<int>>;
using WeightedGraph = vector<vector<Edge>>;
const ll INF = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

int n, k, c;

vector<ll> count(const string& s) {
	int cur = 0, last = -c-1;
	vector<ll> res(n + 1);
	for (int i = 0; i < n; ++i) {
		if (i - last > c && s[i] == 'o') {
			++cur;
			last = i;
		}
		res[i+1] = cur;
	}
	return res;
}

int main() {
	string s;
	cin >> n >> k >> c >> s;
	string t = s;
	reverse(t.begin(), t.end());

	auto v1 = count(s);
	auto v2 = count(t);

	// iを使わない場合の最大値を合計する
	for (int i = 0; i < n; ++i) {
		if (s[i] != 'o') continue;
		if (v1[i] + v2[n-1-i] < k) {
			cout << i + 1 << endl;
		}
	}

	return 0;
}

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

class _Class
{
	void _Do()
	{
		//
		var a_ = _longArray();
		var N_ = _longArray();
		
		//
		long _l = Math.Min(a_[0]*4, a_[1]*2);
		_l = Math.Min(_l, a_[2]);

		long _2l = a_[3];

		long _リットル = N_[0];

		//
		{
			// 2l
			if (_リットル % 2 == 0)
			{
				// guusuu
				var yasui2l = Math.Min(_l*2,_2l);
				Console.WriteLine(yasui2l * _リットル /2);
			}
			else
			{
				// kisuu
				if (_2l>_l*2) {
					//
					Console.WriteLine(_リットル*_l);
				} else {
					//
					long ダブル = _リットル / 2;
					Console.WriteLine(ダブル*_2l　+　1*_l);
				}
			}
		}

	}	

	static void Main(string[] args)
	{
		new _Class()._Do();
	}


	// 1
	string[] _stringArray()
	{
		return Console.ReadLine().Split();
	}

	// 2.1 -2,147,483,648 ~ +2,147,483,647
	int[] _intArray()
	{
		var _s = Console.ReadLine().Split();

		var x = new int[_s.Length];
		for (var i = 0; i < _s.Length; i++)
			x[i] = int.Parse(_s[i]);

		return x;
	}

	// 2.2 -9,223,372,036,854,775,808 ~ +9,223,372,036,854,775,807
	long[] _longArray()
	{
		var _s = Console.ReadLine().Split();

		var x = new long[_s.Length];
		for (var i = 0; i < _s.Length; i++)
			x[i] = long.Parse(_s[i]);

		return x;
	}
}


Measured memory_bytes: 13140
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <iomanip>
#include <bitset>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>

using namespace std;

typedef pair <int, int> ii;

const int N = 22;

int n, m;
int dist[N][N];
char mat[N][N];

int xx[4] = {-1, +1, +0, +0};
int yy[4] = {+0, +0, -1, +1};

bool in(int x, int y) {
  return (x >= 0 && y >= 0 && x < n && y < m);
}

int go(int sx, int sy) {
  bool used[N][N] = {};
  int here = 0;
  queue <ii> q;
  q.push({sx, sy});
  used[sx][sy] = 1;
  dist[sx][sy] = 0;
  while (!q.empty()) {
    int x = q.front().first, y = q.front().second; q.pop();
    used[x][y] = 1;
    //cout << sx << " " << sy << " " << x << " " << y << " " << ans << endl;
    for (int i = 0; i < 4; i++) {
      int nx = x + xx[i];
      int ny = y + yy[i];
      if (in(nx, ny) && !used[nx][ny] && mat[nx][ny] != '#') {
        used[nx][ny] = 1;
        dist[nx][ny] = dist[x][y] + 1;
        q.push({nx, ny});
        here = max(here, dist[nx][ny]);
      }
    }
  }
  return here;
}

int main() {
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; i++) {
    scanf(" %s", mat[i]);
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (mat[i][j] == '#') continue;
      ans = max(ans, go(i, j));
    }
  }
  printf("%d\n", ans);
  return 0;
}


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

namespace C
{
	internal class Program
	{
		private static int n;
		private static List<int> an;
		private static LinkedList<int> b;
		private static bool insertLeft;

		public static void Main(string[] args)
		{
			n = int.Parse(Console.ReadLine());
			an = new List<int>(n);
			b = new LinkedList<int>(new List<int>(n));
			an.AddRange(Console.ReadLine().Split().Select(int.Parse).ToArray());

			insertLeft = n % 2 != 0;

			foreach (var a in an)
			{
				if (insertLeft) { b.AddFirst(a); }
				else { b.AddLast(a); }

				insertLeft = !insertLeft;
			}

			for (var i = 0; i < n - 1; i++)
			{
				Console.Write($"{b.First.Value} ");
				b.RemoveFirst();
			}

			Console.WriteLine(b.First.Value);
		}
	}
}

Measured memory_bytes: 47356
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
from collections import Counter
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())

import sys
import itertools
# import numpy as np
import time
import math
from heapq import heappop, heappush
from collections import defaultdict
from collections import Counter
from collections import deque
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())
N = int(input())
C = list(sorted(map(int, input().split()), reverse=True))

MAX = 2 * 10 ** 5 + 5
MOD = 10 ** 9 + 7

fac = [0 for i in range(MAX)]
finv = [0 for i in range(MAX)]
inv = [0 for i in range(MAX)]

def comInit(mod):
    fac[0], fac[1] = 1, 1
    finv[0], finv[1] = 1, 1
    inv[1] = 1
    for i in range(2, MAX):
        fac[i] = fac[i - 1] * i % mod
        inv[i] = mod - inv[mod % i] * (mod // i) % mod
        finv[i] = finv[i - 1] * inv[i] % mod


def com(n, r, mod):
    if n < r:
        return 0
    if n < 0 or r < 0:
        return 0
    return fac[n] * (finv[r] * finv[n - r] % mod) % mod

def p(n, r, mod):
    return fac[n] * finv[n - r] % mod
    
comInit(MOD)

ans = 0
pow_list = [1] * (N + 1)
for i in range(1, N + 1):
    pow_list[i] = (2 * pow_list[i - 1]) % MOD
base = pow_list[N]
for i, c in enumerate(C):
    now = pow_list[N - i - 1]
    tot = 0
    if i >= 1:
        tot = pow_list[i] + i * pow_list[i - 1]
    else:
        tot = pow_list[i]
    ans += (tot * now * c) % MOD
    ans %= MOD
print(ans * base % MOD)





Measured memory_bytes: 50812
#include <bits/stdc++.h>
#include <set>
#define rep(i,n) for (int i=0; i < (n); ++i)
#define all(a) a.begin(), a.end()
using ll = long long;
using namespace std;
 


int main() {
	int N;
	cin >> N;
	int answer = 0;
	for (int C = 1; C <= N; C += 2) {
		int num_of_divisors = 0;
		for (int X = 1; X <= C; ++X) {
			if (C % X == 0) {
				++num_of_divisors;
			}
		}
		if (num_of_divisors == 8) {
			++answer;
		}
	}
	cout << answer << '\n';
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>


main()
{
  int A[100],N;
  int i,k,key,j;

scanf("%d",&N);

for (k=0;k<N;k++)scanf("%d",&A[k]);

for (k=0;k<N;k++){
printf("%d",A[k]);
if(k!=N-1){printf(" ");}
}
printf("\n");

for (i=1;i<=N-1;i++){   

 
    key = A[i];
    /* insert A[i] into the sorted sequence A[0,...,j-1] */
    j = i-1;

      while(j>= 0 && A[j]>key){
        A[j+1] = A[j];
        j--;
       }
    A[j+1] = key;

for (k=0;k<N;k++){
         printf("%d",A[k]);
if(k!=N-1)printf(" ");}   

printf("\n");
  }

	  return 0;
}

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

int main(void){
    int N;
    cin >> N;
    vector <int> H(N);
    int ans = 0;
    for(int i = 0;i < N;i++){
        cin >> H[i];
        for(int j = 0;j <= i;j++){
            if(H[i] < H[j]){
                break;
            }
            if(i==j){
                ans++;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

using std::cout;
using std::cin;
using std::endl;

int main() {
	int n, x;
	int count = 0;	// x???????????°
	while (1)
	{
		cin >> n >> x;
		// ???????????¶
		if (n == 0 && x == 0) {
			break;
		}

		// ??????
		for (int i = 1; i <= n; i++)
		{
			for (int j = i+1; j <= n; j++)
			{
				for (int k = j+1; k <= n; k++)
				{
					//cout << i << "+" << j << "+" << k;
					if (i + j + k == x)
					{
						count++;
						//cout << "???";
					}
					//cout << endl;
				}
			}
		}
		cout << count << endl;
		count = 0;
	}
	return 0;
}

Measured memory_bytes: 3088
#include <bits/stdc++.h>
#define sz(a) (int)a.size()
#define all(x) (x).begin(),(x).end()
#define vi vector <int>
#define pb push_back
#define mp make_pair
#define ll long long        
#define sc scanf
#define pf printf    
#define f first
#define s second 
#define y1 DenCheini
#define y0 dadsad
#define dracarys ios_base :: sync_with_stdio(0);cin.tie(0);cout.tie(0);

using namespace std;

int n, m;
const int inf = (int)1e9;
vector<pair<int, int > > g[111];
int d[111], p[111];
set<pair<int, int> > st;
vector<pair<int, int> > edges;
int main(){//dracarys
	#ifdef LOCAL
    freopen("in.in", "r", stdin);
    freopen("out.out", "w", stdout);
    #endif
    cin >> n >> m;
    
    for(int i = 0; i < m; ++i){
    	int a, b;
    	int c;
    	cin >> a >> b >> c;
    	a--;
    	b--;
    	g[a].pb(mp(b, c));
    	g[b].pb(mp(a, c));
    	edges.pb(mp(a, b));
    }
    for(int i = 0; i < n; ++i){
    	for(int j = i + 1; j < n; ++j){
    		int s = i;
    		int b = j;
    		for(int k = 0; k < n; ++k) d[k] = inf, p[k] = -1;
    		d[s] = 0;
    		set < pair<int,int> > q;
			q.insert(make_pair(d[s], s));
			while (!q.empty()) {
				int v = q.begin()->second;
				q.erase (q.begin());
				for (int j = 0; j < g[v].size(); ++j) {
					int to = g[v][j].first,
						len = g[v][j].second;
					if (d[v] + len < d[to]) {
						q.erase (make_pair (d[to], to));
						d[to] = d[v] + len;
						p[to] = v;
						q.insert (make_pair (d[to], to));
					}
				}
			}
			if(d[b] == inf) continue;
			int u = b;
			while(u != s){
				st.insert(mp(u, p[u]));
				u = p[u];
			}

    	}
    }
    int ans = 0;
    for(int i = 0; i < edges.size(); ++i){
    	int a = edges[i].f;
    	int b = edges[i].s;
    	if(!st.count(mp(a, b))  && !st.count(mp(b, a)))ans++;
    }
    cout << ans;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    
    int a = sc.nextInt();
    int b = sc.nextInt();
    
    if((a*b)%2 == 0) {
      System.out.println("Even");
    }else {
      System.out.println("Odd");
    }      
  }
}

Measured memory_bytes: 20948
fun main(args: Array<String>) {
  val s = readLine()!!
  var i = s.length - 1
  while (i > 0) {
    if (i - 4 >= 0 && s.substring(i - 4..i) == "dream") {
      i -= 5
    } else if (i - 6 >= 0 && s.substring(i - 6..i) == "dreamer") {
      i -= 7
    } else if (i - 4 >= 0 && s.substring(i - 4..i) == "erase") {
      i -= 5
    } else if (i - 5 >= 0 && s.substring(i - 5..i) == "eraser") {
      i -= 6
    } else {
      println("NO")
      return
    }
  }
  println("YES")
}


Measured memory_bytes: 39036
use std::collections::{HashMap, HashSet};
use std::error::Error;
use std::io;
use std::iter::FromIterator;

pub fn main() {
    if let Err(e) = run() {
        panic!("Failed");
    }
}

const MOD: i64 = 1_000_000_007;

fn run() -> Result<(), Box<Error>> {
    let mut input = String::new();
    io::stdin().read_line(&mut input);
    let n: i32 = input.trim().parse().unwrap();
    input.clear();

    let mut affinities = vec![];
    for i in 0..n {
        io::stdin().read_line(&mut input);
        let affinity: Vec<i32> = input
            .trim()
            .split_whitespace()
            .map(|x| x.parse::<i32>().unwrap())
            .collect();
        affinities.push(affinity);
        input.clear();
    }
    let mut matched: i32 = (1 << n) - 1;
    let mut dp: HashMap<i32, i64> = HashMap::new();
    let result = find_match(0, &affinities, matched, &mut dp);
    println!("{}", result);
    Ok(())
}

fn find_match(
    row: usize,
    affinities: &Vec<Vec<i32>>,
    current_matched: i32,
    dp: &mut HashMap<i32, i64>,
) -> i64 {
    if row == affinities.len() {
        return 1;
    }
    if let Some(&value) = dp.get(&current_matched) {
        return value;
    }
    let mut result = 0i64;
    for i in 0..affinities[row].len() {
        if affinities[row][i] == 1 && current_matched & (1 << i) as i32 != 0 {
            result += find_match(row + 1, affinities, current_matched ^ (1 << i) as i32, dp);
            result %= MOD;
        }
    }
    dp.insert(current_matched, result);
    result
}


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

int gcd(int a,int b){
    if(a<b){
       swap(a,b);
    }
    while(b!=0){
        int q=a/b,r=a%b;
        a=b;
        b=r;
    }
    return a;
}

int tgcd(int a,int b,int c){
    int d=gcd(a,b);
    return gcd(d,c);
}

int main() {
    long long K,s=0;
    cin >> K;
    for(int i=1;i<=K;i++){
        for(int j=1;j<=K;j++){
            for(int k=1;k<=K;k++){
                s+=tgcd(i,j,k);
            }
        }
    }
    cout << s << endl;
}


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

typedef long long ll;

const long long MOD = 1000000007;
long long modpow(long long a, long long n, long long m)
{
    long long ans = 1;
    while (n)
    {
        if (n & 1)
        {
            ans = (ans * a) % m;
        }
        a = (a * a) % m;
        n >>= 1;
    }
    return ans;
}
long long combi(long long n, long long a)
{
    long long ans = 1, ans1 = 1;
    for (long long i = n - a + 1; i <= n; i++)
    {
        ans *= i % MOD;
        ans %= MOD;
    }

    for (long long i = 2; i <= a; i++)
        ans1 = (ans1 * i) % MOD;
    ans1 = modpow(ans1, MOD - 2, MOD);
    return ((ans % MOD) * ans1) % MOD;
}

void dfs(string s, char mx, ll N)
{
    if (s.length() == N)
    {
        cout << s.c_str() << endl;
    }
    else
    {
        for (char c = 'a'; c <= mx; c++)
        {
            dfs(s + c, ((c == mx) ? (char)(mx + 1) : mx), N);
        }
    }
}

int bfs(int i, int j, int h, int w, char tmp[][21])
{
    int ans[21][21] = {0};
    char c[21][21] = {0};
    queue<pair<int, int>> s;

    for (int i = 0; i<=h; i++){
        for(int j=0; j<=w; j++){
            c[i][j] = tmp[i][j];
        }
    }

        s.push(make_pair(i, j));

    while (s.size() > 0)
    {

        pair<int, int> tmp = s.front();
        s.pop();
        c[tmp.first][tmp.second] = '#';
        for (int i = -1; i <= 1; i++)
        {
            for (int j = -1; j <= 1; j++)
            {
                if (tmp.first + i < 1 || tmp.first + i > h)
                {
                    continue;
                }
                if (tmp.second + j < 1 || tmp.second + j > w)
                {
                    continue;
                }
                if (i != 0 && j != 0)
                {
                    continue;
                }
                if (i == 0 && j == 0)
                {
                    continue;
                }
                if (c[tmp.first + i][tmp.second + j] == '#')
                {
                    continue;
                }
                c[tmp.first + i][tmp.second + j] = '#';
                if (ans[tmp.first + i][tmp.second + j] == 0)
                {
                    ans[tmp.first + i][tmp.second + j] = ans[tmp.first][tmp.second] + 1;
                }
                else
                {
                    ans[tmp.first + i][tmp.second + j] = min(ans[tmp.first + i][tmp.second + j], ans[tmp.first][tmp.second] + 1);
                }
                s.push(make_pair(tmp.first + i, tmp.second + j));
            }
        }
    }

    int a = 0;

    for (int i = 1; i <= h; i++)
    {
        for (int j = 1; j <= w; j++)
        {
            a = max(a, ans[i][j]);
        }
    }

    return a;
}


int main()
{
    ll N;
    cin >> N;

    vector<ll> v;

    ll ans = 0;
    for(int i=0; i<N; i++){
        ll tmp;
        cin >> tmp;
        ans += tmp;
        if(tmp%10!=0){
            v.push_back(tmp);
        }
    }
    sort(v.begin(),v.end());

    if(ans%10){
        ;
    }
    else if(v.size() > 0){
        ans -= v.front();
    }
    else{
        ans = 0;
    }

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


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int  main()
{
	long long  ans=0;
    long long  n;
	long long a[110][15],p[110][15];
	
	while(cin>>n)
	{   long long  ma=-10000000000000;
		for(int i=1;i<=n;i++)
		for(int j=1;j<=10;j++)
		cin>>a[i][j];
		for(int i=1;i<=n;i++)
		for(int j=0;j<=10;j++)
		cin>>p[i][j]; 
	int i1,i2,i3,i4,i5,i6,i7,i8,i9,i0;
	for( i1=0;i1<2;i1++)
	for( i2=0;i2<2;i2++)
	for( i3=0;i3<2;i3++)
	for( i4=0;i4<2;i4++)
	for( i5=0;i5<2;i5++)
	for( i6=0;i6<2;i6++)
	for( i7=0;i7<2;i7++)
	for( i8=0;i8<2;i8++)
	for( i9=0;i9<2;i9++)
	for( i0=0;i0<2;i0++)
	{	
		ans=0;
		int h=i1+i2+i3+i4+i5+i6+i7+i8+i9+i0;
		if(h==0) continue;
		if(h>=1)
	{	
		for( int i=1;i<=n;i++)
		ans+=p[i][i1*a[i][1]+i2*a[i][2]+i3*a[i][3]+i4*a[i][4]+i5*a[i][5]+i6*a[i][6]+i7*a[i][7]+i8*a[i][8]+i9*a[i][9]+i0*a[i][10]];
		
		if(ans>ma) 
		ma=ans;
	}
		
	}
	cout<<ma<<endl;
	}
    
    
	
       return 0; 
	
 } 

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <math.h>
#include <algorithm>
#include <set>
#include <deque>
#include <utility>
#include <map>

#define ll long long int
#define MAX 1000000

using namespace std;

int main(void)
{
	int n;
	int x, y;

	cin >> n;

	x = n * 800;

	y = n / 15 * 200;

	cout << x - y << endl;

	return (0);
}




Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main() {
  int X,N,q,P_ANSWER,i,j,M=500,flag=0;
  cin >> X >> N;
  vector<int> P(N);
  for (i=0;i<N;i++){
    cin >> q;
    P[i]=q;
  }
 /* for (i = 0; i < N-1; i ++){
  cout << P.at(i) << " ";
}
cout << P.at(N - 1) << endl;*/

  for(j=0;j<=X;j++){
    for(i=0;i<N;i++){
      if(X-j==P[i]){
        flag=1;
        break;
      }
    }
    if(flag==0){
      P_ANSWER=X-j;
      M=j;
      break;
    }
    flag=0;
    }//減少方向にP_ANSWERを検索
  for(j=0;(j<=100-X&&j<M-1);j++){
        for(i=0;i<N;i++){
      if(X+j+1==P[i]){
        flag=1;
        break;
      }
    }
    if(flag==0){
      P_ANSWER=X+j+1;
      break;
    }
    flag=0;
    }//増加方向にP_ANSWERを検索


  cout << P_ANSWER;
}

Measured memory_bytes: 3620
line = list(map(int, list(input())))
l = len(line)-1
beki_list = [[0]*(l) for i in range(2**l)]

for i in range(2**l):
	i_2 = format(i, 'b')[::-1]
	for j in range(len(i_2)):
		beki_list[i][j] = int(i_2[j])

for i in beki_list:
	num = line[::1]
	pm_l = [num.pop(0)]
	for j in i:
		if j:
			pm_l += [num.pop(0)]
		else:
			pm_l += [-num.pop(0)]
	if (sum(pm_l) == 7):
		for n, k in enumerate(pm_l):
			if n == 0:
				print(str(k), end='')
			else:
				if k >= 0:
					print('+{}'.format(k), end='')
				else:
					print(str(k), end='')
		print('=7')
		exit()

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>
#include<string.h>
using namespace std;

int main(){
    int n;
    while(cin>>n,n){
        int t;
        vector<int>v;
        for(int i=0;i<n;i++){
            cin>>t;
            v.push_back(t);
        }
        int r=0,j=0,l=32;
        while(l>0){
            r++;
            if(r%2){
                l-=(l - 1) % 5;
            }
            else{
                l-=v[j];
                j=(j+1)%n;
            }
            if(l<0)l=0;
            cout<<l<<endl;
        }
    }
    
    
}

Measured memory_bytes: 1216
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int num = sc.nextInt();
			int b = sc.nextInt();
			int ans = num - b * 2;
			if (ans < 0) {
				System.out.println(0);
			} else {
				System.out.println(ans);
			}
		}
	}
}

Measured memory_bytes: 24532
#include<stdio.h>
int main(){
	int n, r, t;
	scanf("%d %d", &n, &r);
	t = 100 * (10 - n);
	if(n<10){
		printf("%d\n", r+t);
	}
	else{
		printf("%d\n", r);
	}
	return 0;
}


Measured memory_bytes: 3228
#include <stdio.h>
#define TURTLE 4
#define CRANE 2

int main(void){
    int i,X,Y,ans=0;
    scanf("%d %d",&X,&Y);

    for(i=0;i<=X;i++){
        if(i*TURTLE + (X-i)*CRANE == Y) ans = 1;
    }

    if(ans == 0){
        printf("No\n");
    }else{
        printf("Yes\n");
    }

    return 0;
}

Measured memory_bytes: 1660
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    s <- getLine
    let n = length s
    putStrLn $ if (kaibun s) && (kaibun (take ((n - 1) `div` 2) s)) && (kaibun (drop ((n + 3) `div` 2 - 1) s)) then "Yes" else "No"

kaibun s = s == reverse s

Measured memory_bytes: 508
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <ios>
#include <iostream>
#include <vector>

#define ll long long

using namespace std;

int A, B, C;

int main()
{
    cin >> A >> B >> C;
    cout << (A == B ? C : (A == C ? B : A)) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<bitset>
#include<vector>
#include<queue>
//#include<ext/pb_ds/priority_queue.hpp>
#include<set>
#include<map>
#include<math.h>
#include<set>
#define maxn 200005
#define lson (now<<1)
#define rson ((now<<1)|1)
//#define mid ((nl+nr)>>1)
typedef long long ll;
using namespace std;
//using namespace __gnu_pbds; 
const double eps=1e-5;
int n,k;
double a[maxn];
int check(double now)
{
	int cnt=0;
	for(int i=1;i<=n;i++)
	{
		cnt+=(int)(a[i]/now)-1;
		if(a[i]-((int)(a[i]/now)*now)>eps)
		cnt++;
	}
	return cnt<=k;
}
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
	scanf("%lf",&a[i]);
	double nl=0+eps,nr=1e9;
	while(nr-nl>eps)
	{
		double mid=((nl+nr)/2);
		if(check(mid))
			nr=mid;
		else
			nl=mid;
	}
	printf("%.0lf\n",nl+0.5);
}

Measured memory_bytes: 5316
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
// Welcome to my source code!

int main() {
    int n;
    cin >> n;
    map<int, int> mp;
    for (int i = 0, a; i < n; i++) {
        cin >> a;
        mp[a]++;
    }
    ll ans = 0;
    for (auto x : mp) {
        if (x.first != x.second) {
            if (x.first > x.second) ans += x.second;
            else ans += x.second - x.first;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4736
/*2019/10/19 */
/*template*/
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#define MOD 1000000007
#define MIN 999999999
#define MAX -999999999
typedef long long int ll;
typedef unsigned long long int ull;
void llswap(ll *x,ll *y){ll tmp;tmp=*x;*x=*y;*y=tmp;}
void swap(int *x,int *y){int tmp;tmp=*x;*x=*y;*y=tmp;}
int rmax(int x,int y){return x>y?x:y;}
int rmin(int x,int y){return x>y?y:x;}
ll llrmax(ll x,ll y){return x>y?x:y;}
ll llrmin(ll x,ll y){return x>y?y:x;}
int asc(const void *a,const void *b){if(*(int*)a < *(int*)b)return -1;else if(*(int*)a == *(int*)b)return 0;else return 1;}
int desc(const void *a,const void *b){if(*(int*)a < *(int*)b)return 1;else if(*(int*)a == *(int*)b)return 0;else return -1;}
int llasc(const void *a,const void *b){if(*(ll*)a < *(ll*)b)return -1;else if(*(ll*)a == *(ll*)b)return 0;else return 1;}
int lldesc(const void *a,const void *b){if(*(ll*)a < *(ll*)b)return 1;else if(*(ll*)a == *(ll*)b)return 0;else return -1;}
int gcd(int x,int y){if(y==0)return x;return gcd(y,x%y);}
 
//int asc_t(const void *a,const void *b){if(((pair_t*)a)->d < ((pair_t*)b)->d)return -1;else if(((pair_t*)a)->d == ((pair_t*)b)->d)return 0;else return 1;}
//int asc_t(const void *a,const void *b){if(((pair_t*)a)->d < ((pair_t*)b)->d)return 1;else if(((pair_t*)a)->d == ((pair_t*)b)->d)return 0;else return -1;}
double to_deg(double r) {return r * 180.0 / (atan(1.0) * 4.0);}

int main(){
    int n;
    char s[100000];

    scanf("%d",&n);
    scanf("%s",s);
    
    for(int i=0;s[i]!='\0';i++){
        if(s[i]+n>'Z'){
            printf("%c",s[i]+n-'Z'+'A'-1);
        }else{
            printf("%c",s[i]+n);
        }
    }
    return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>
#include<limits>
#include<iomanip>
#include<iterator>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rep(i,n) for(int i=0; i<n; i++)
#define FOR(i,a,n) for(int i=a; i<n; i++)

using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ll, char> plc;

int N;
priority_queue<int,vector<int>,greater<int> > pq;

int main()
{	
	cin >> N;
	rep(i, N) {
		int a, b;
		cin >> a >> b;
		pq.push(a + b);
	}

	while (!pq.empty()) {
		if (pq.size() <= 1) {
			cout << pq.top() << " " << 0 << endl;
			break;
		}
		int a = pq.top(); pq.pop();
		int b = pq.top(); pq.pop(); 
		if (a == b)pq.push(a + 1);
		else {
			cout << a << " " << 0 << endl;
			pq.push(b);
		}
	}
	return 0;
}

Measured memory_bytes: 3500
local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})
read.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end
string.totable = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end
string.split = function(s) local t={} for w in string.gmatch(s, "[^%s]+") do table.insert(t, w) end return (table.unpack or unpack)(t) end
local function array(dimension, default_val) assert(type(default_val) ~= 'table') local n=dimension local m={}if default_val~=nil then m[1]={__index=function()return default_val end}end for i=2,n do m[i]={__index=function(p, k)local c=setmetatable({},m[i-1])rawset(p,k,c)return c end}end return setmetatable({},m[n])end
-----------------------
local X = read.N(5)
for i=1,5 do
    if X[i] == 0 then
        print(i)
    end
end

Measured memory_bytes: 2752
//author:luckYrat(twitter:@luckYrat_)
//#include <bits/stdc++.h>

//def
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

//array
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <utility>
#include <climits>



using namespace std;

using ll = long long;
using P = pair<ll,ll>;

#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)


#define MAX 1000000000
const int mod = 1000000007;
#define EPS (1e-10)

#define pb push_back
#define fir first
#define scn second
#define ednl endl

#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")



/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
vector.unique()は隣接した同じ要素を削除するので先にソートをする

計算量は変わらないが楽できるシリーズ
C++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる

*/
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}
int main(){
  string s,t;cin>>s>>t;
  int a,b;cin>>a>>b;
  string u;cin>>u;
  if(u==s){
    cout << a-1 << " " << b << endl;
  }else{
    cout << a << " " << b-1 << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>

using namespace std;

#define BIG 1000000007

int main(){
  string s;
  cin >> s;
  long long a[13] = {};
  for(int i = 0; i < s.length(); i++){
    long long b[13] = {};
    if(i == 0){
      if(s[i] == '?'){
        for(int j = 0; j < 10; j++){
          b[j] = 1;
        }
      }
      else{
        string t = s.substr(i,1);
        int n = stoi(t);
        b[n] = 1;
      }
    }
    else{
      if(s[i] == '?'){
        for(int j = 0; j < 13; j++){
          for(int k = 0; k < 10; k++){
            b[(j*10+k)%13] += a[j];
            b[(j*10+k)%13] %= BIG;
          }
        }
      }
      else{
        string t = s.substr(i,1);
        int n = stoi(t);
        for(int j = 0; j < 13; j++){
          b[(j*10+n)%13] += a[j];
          b[(j*10+n)%13] %= BIG;
        }
      }
    }
    for(int j = 0; j < 13; j++){
      a[j] = b[j];
    }
  }
  cout << a[5] << endl;
}


Measured memory_bytes: 512
from itertools import accumulate

N = int(input())
As = [int(input()) for _ in range(N)]

Ls = [0] + list(accumulate(As, max))
Rs = list(accumulate(As[::-1], max))[::-1] + [0]

anss = [max(Ls[i], Rs[i+1]) for i in range(N)]
print('\n'.join(map(str, anss)))


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

#define INF (1LL << 31 - 1)
#define MOD int(1e9+7)
#define repi(i,j,n) for(int i = (j); i < (n); ++i)
#define rep(i,n) repi(i,0,n)
#define fi first
#define se second

inline void init() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

int n, l, r;
int imos[100002];

int main() {
    init();
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> l >> r;
        l--, r--;
        imos[l]++;
        imos[r + 1]--;
    }

    for (int i = 1; i <= 100000; ++i) imos[i] += imos[i - 1];

    int ans = 0;

    for (int i = 0; i < 100001; ++i) {
        if (imos[i]) ans++;
    }

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

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

int main() {
  // int N;
  // cin>>N;
  string S,T;
  cin>>S;
  cin>>T;

  int i = 0;
  if(S[0] == T[0]) i++;
  if(S[1] == T[1]) i++;
  if(S[2] == T[2]) i++;
  cout<<i<<endl;



  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define vll vector<ll>
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    ll n, m, a, ans = 0, t, sum = 0;
    cin >> n >> m;
    vll x;
    
    for(ll i=0; i<n; i++){
        cin >> a;
        sum += a;
        x.push_back(a);
    }
    t = (sum-1)/(4*m) + 1;

    for(auto i:x){
        if(i >= t){
            ans += 1;
        }
    }
    
    if(ans < m){
        cout << "No" << endl;
    }
    else{
        cout << "Yes" << endl;
    }
    return 0;
}

Measured memory_bytes: 3612
#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;

const int MOD = 1000000007;

int main() {
    int N;
    cin >> N;
    vector<int> odd(100001);
    vector<int> even(100001);
    for (int i = 0; i < N; i++) {
        int n;
        cin >> n;
        if (i % 2 == 0) {
            even[n]++;
        } else {
            odd[n]++;
        }
    }

    int maxEven = 0;
    int maxEvenNum = 0;
    int maxEven2 = 0;
    for (int i = 0; i < even.size(); i++) {
        if (maxEven < even[i]) {
            maxEven2 = maxEven;
            maxEvenNum = i;
            maxEven = even[i];
        } else if (maxEven2 < even[i]) {
            maxEven2 = even[i];
        }
    }


    int maxOdd = 0;
    int maxOddNum = 0;
    int maxOdd2 = 0;
    for (int i = 0; i < odd.size(); i++) {
        if (maxOdd < odd[i]) {
            maxOdd2 = maxOdd;
            maxOddNum = i;
            maxOdd = odd[i];
        } else if (maxOdd2 < odd[i]) {
            maxOdd2 = odd[i];
        }
    }

    if (maxEvenNum == maxOddNum) {
        int maxNum = maxOdd + maxEven2;
        chmax(maxNum, maxOdd2 + maxEven);
        cout << N - maxNum << endl;
    } else {
        cout << N - (maxEven + maxOdd) << endl;
    }
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main()
{
	double wt;
	
	while(cin >> wt){
		if(wt <= 48.00)         cout << "light fly\n";
		else if(wt <= 51.00)    cout << "fly\n";
		else if(wt <= 54.00)    cout << "bantam\n";
		else if(wt <= 57.00)    cout << "feather\n";
		else if(wt <= 60.00)    cout << "light\n";
		else if(wt <= 64.00)    cout << "light welter\n";
		else if(wt <= 69.00)    cout << "welter\n";
		else if(wt <= 75.00)    cout << "light middle\n";
		else if(wt <= 81.00)    cout << "middle\n";
		else if(wt <= 91.00)    cout << "light heavy\n";
		else                    cout << "heavy\n";
	}
	
	return 0;
}

Measured memory_bytes: 1192
# -*- coding: utf-8 -*-
from itertools import product
from heapq import heappop, heappush

def small_dp(N,A,B):
    *X, = filter(lambda c: int.__sub__(*c)<0, zip(A,B))
    k = len(X)
    if k == 0:
        return N
    if k == 1:
        return X[0][1]*(N//X[0][0]) + N%X[0][0]
    if k == 2:
        c = 0
        for i in range(N//X[0][0]+1):
            j = (N-i*X[0][0])//X[1][0]
            c = max(X[0][1]*i + X[1][1]*j + (N-i*X[0][0])%X[1][0], c)
        return c
    if k == 3:
        if (N//X[1][0]+1)*(N//X[0][0]+1) <= 10**6 :
            return max(X[0][1]*i + max(X[1][1]*j + X[2][1]*((N-i*X[0][0]-j*X[1][0])//X[2][0]) + ((N-i*X[0][0]-j*X[1][0])%X[2][0]) for j in range((N-i*X[0][0])//X[1][0]+1)) for i in range(N//X[0][0]+1))
        else:
            import numpy as np
            dp = np.zeros(N+1, dtype=int)
            for w in range(1,N+1):
                dp[w] = max(dp[w-X[i][0]]+X[i][1] if w>=X[i][0] else w for i in range(k))
            N = dp[-1]
            return N

def solve():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    res = small_dp(small_dp(N, A, B), B, A)

    return str(res)

if __name__ == '__main__':
    print(solve())


Measured memory_bytes: 21584
ABCK = list(map(int, input().split()))

if (ABCK[0] >= ABCK[3]):
    print(ABCK[3])
elif (ABCK[0] + ABCK[1] >= ABCK[3]):
    print(ABCK[0])
else:
    s = (ABCK[3] - ABCK[0] - ABCK[1])
    print(ABCK[0] - s)



Measured memory_bytes: 61644
#include <bits/stdc++.h>
using namespace std;
 
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define len(x) int((x).size())
#define res(x) cout << ((x) ? "YES\n" : "NO\n" )

typedef long long int integer;
typedef long double doble;

void solution() {
	int r;
	cin >> r;
	cout << r * r * 3 << endl;
}
 
int main(){
	int t = 1;
	//cin >> t;
	while(t--) solution();
	return 0;
}

Measured memory_bytes: 3604
// Problem : C - Vacation
// Contest : Educational DP Contest
// URL : https://atcoder.jp/contests/dp/tasks/dp_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cp-editor)
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define endl '\n'
#define vi vector<ll>
#define vb vector<bool>
#define mii map<ll, ll>
#define pii pair<ll, ll>
#define pb push_back
#define fi first
#define se second
#define m_p make_pair
//Proof: 
//Complexity: 
ll power(ll a, ll b){
    ll res = 1;
    while(b!=0){
        if(b&1){
            res *= a; 
        }
        a = (a * a);
        b = (b / 2);
    }
    return res;
}
int main(){
    SPEED;
    ll n;
    cin>>n;
    vi v(3);
    vector<vi> dp(n, vi(3, 0));
    cin>>v[0]>>v[1]>>v[2];
    for(ll i=0;i<3;i++){
    	dp[0][i] = v[i];
    }
    for(ll i=1;i<n;i++){
    	cin>>v[0]>>v[1]>>v[2];
    	for(ll j = 0;j<3;j++){
    		dp[i][j] += v[j] + max(dp[i-1][(j + 1)%3], dp[i - 1][(j + 2)%3]);
    	}
    }
    cout<<max(dp[n -1][0], max(dp[n - 1][1], dp[n - 1][2]));
    return 0;
}

Measured memory_bytes: 5760
str, q = input(), int(input())
for i in range(q):
    com = input().strip().split()
    if com[0] == 'print':
        print(str[int(com[1]):int(com[2])+1])
    elif com[0] == 'reverse':
        str = list(str)
        str[int(com[1]):int(com[2])+1] = str[int(com[2]):int(com[1])-len(str)-1:-1]
        str = ''.join(str)
    elif com[0] == 'replace':
        str = list(str)
        str[int(com[1]):int(com[2])+1] = com[3]
        str = ''.join(str)

Measured memory_bytes: 7708
#include <iostream>

int
main(int argc, char** argv) {
    int A, B, c;
    std::cin >> A >> B;

    c = B;
    if (A <= 5) {
        c = 0;
    } else if ((6 <= A) && (A <= 12)) {
        c = B/2;
    }

    std::printf("%d\n",c);
    return 0;
}

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

using namespace std;

void A_Hitachi_String(void) {

	string S;
	cin >> S;

	bool re = true;

	if ((int)S.size() % 2 == 1) {
		re = false;
	}
	else {

		for (int loop = 0; loop < (int)S.size(); loop += 2) {

			if (!(S[loop] == 'h' && S[loop + 1] == 'i')) {

				re = false;
				break;
			}
		}
	}

	cout << (re ? "Yes" : "No") << flush;
	return;
}

void B_Nice_Shopping(void) {

	int A, B, M;
	cin >> A >> B >> M;

	vector<int> a(A);
	int aMin = 0;
	for (int loop = 0; loop < A; loop++) {
		cin >> a[loop];
		if (aMin == 0 || a[loop] < aMin) aMin = a[loop];
	}

	vector<int> b(B); 
	int bMin = 0;
	for (int loop = 0; loop < B; loop++) {
		cin >> b[loop];
		if (bMin == 0 || b[loop] < bMin) bMin = b[loop];
	}

	int min = aMin + bMin;
	int x, y, c;
	int price = 0;
	for (int loop = 0; loop < M; loop++) {
		cin >> x >> y >> c;
		price = a[x - 1] + b[y - 1] - c;
		if (price < min) min = price;
	}

	cout << min << flush;

	return;
}

int main(void) {

	//A_Hitachi_String();
	B_Nice_Shopping();
	return 0;
}


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

int main(){
  int N,M,ans,t;
  cin>>N;
  vector<int> T(N);
  ans = 0;
  for(int i=0;i<N;i++){
    cin>>T.at(i);
    ans+=T.at(i);
  }
  cin>>M;
  vector<int> ANS(M,0);
  int ind,time;
  for(int i=0;i<M;i++){
    cin>>ind;
    cin>>time;
    ANS.at(i)=ans;
    ANS.at(i)-=T.at(ind-1);
    ANS.at(i)+=time;
  }
  for(int i=0;i<M;i++){
    cout<<ANS.at(i)<<endl;
  }
}


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

using ll = long long;
using pp = pair<ll,ll>;
const ll amari = 1e9+7;
const char BC = 'A' - 'a';
#define ben(a) a.begin(),a.end()
#define pb(a,b) a.push_back(b)
//fixed << setprecision(20)
int main(){
	string s;
	cin >> s;
	int ok = 0;
	if(s[0] == s[1] || s[1] == s[2] || s[2] == s[3])ok = 1;

	if(ok)cout << "Bad" << endl;
	else cout << "Good" << endl;
	return 0;
}

Measured memory_bytes: 256
#D
from collections import Counter
s = input()
flag = True
for i in range(len(s)-1):
    if s[i] == s[i+1]:
        print(i+1, i+2)
        flag = False
        break
    elif i <= len(s)-3 and s[i] == s[i+2]:
        print(i+1, i+3)
        flag = False
        break
if flag:
    print("-1 -1")

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

int main() {
    int n;

    cin >> n;

    int _x = 0;
    int _y = 0;
    int _t = 0;

    for(int i = 0 ; i < n ; i++){
        int t;
        int x, y;
        cin >> t >> x >> y;

        int len = abs(x - _x) + abs(y - _y);
        if(len <= (t - _t) && (len % 2 == (t - _t) % 2)){
            _x = x;
            _y = y;
            _t = t;
        }else{
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 256
// Knapsack 2

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.Arrays;

class Main {
	public static long knapsack2(long[] w, long[] p, int k, int n) {
		long[][] dp = new long[n+1][k+1];

		for(int i = 0; i <= n; i++) {
			dp[i][0] = 0;
		}

		for(int i = 0; i <= k; i++) {
			dp[0][i] = 0;
		}

		long max = 0;
		for(int i = 1; i <= n; i++) {
			for(long j = 1; j <= k; j++) {
				if(w[i-1] > j)
					dp[i][(int)j] = max(dp[i-1][(int)j], dp[i][(int)(j-1l)]);
				else
					dp[i][(int)j] = max(dp[i-1][(int)j], p[i-1]+dp[i-1][(int)(j-w[i-1])]);
				// System.out.print(dp[i][j] + " ");
				if(dp[i][(int)j] > max)
					max = dp[i][(int)j];
			}
			// System.out.println();
		}
		return max;
	}
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] s = br.readLine().split(" ");
		
		int n = Integer.parseInt(s[0]);
		int k = Integer.parseInt(s[1]);

		long[] w = new long[n];
		long[] p = new long[n];

		for(int i = 0; i < n; i++) {
			String[] s1 = br.readLine().split(" ");
			w[i] = Long.parseLong(s1[0]);
			p[i] = Long.parseLong(s1[1]);
		}

		System.out.println(knapsack2(w, p, k, n));
	}

	public static long max(long...arr) {
		long max = Long.MIN_VALUE;
		for(long i: arr) {
			if(i > max)
				max = i;
		}
		return max;
	}
}

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

#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define endl '\n'

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, int> pdi;

const ll INF = 1e18;
const int MAXN = 1e6 + 5;
const int MOD = 20200429;

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	int a, b, c;
	cin >> a >> b >> c;
	swap(a, b);
	swap(a, c);
	cout << a << ' ' << b << ' ' << c << endl;
}


Measured memory_bytes: 256