akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(long long int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

int main(){

    long long int n,w;
    cin>>n>>w;
    struct Nimotsu{
        long long int weight;
        long long int value;
    };
    vector<Nimotsu> v(n);
    REP(i,n){
        cin >> v[i].weight >> v[i].value;
    }
    vector<long long int> dp(111111,inf);
    dp[0] = 0;
    REP(i,n){
        DEFOR(j,dp.size(),0){
            if(j-v[i].value>=0){
                dp[j] = min(dp[j],dp[j - v[i].value] + v[i].weight);
            }
        }
    }
    DEFOR(i,dp.size(),0){
        if(dp[i]<=w){
            cout<<i<<endl;
          //  DEB(dp[i]);
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  if(N%2==0){
    cout << 0.5 << endl;
  }else{
    cout << ((double)(N-1)/2.0 + 1.0)/(double)N << endl;
  }
  return 0;
}

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

using ll = long long;

int main()
{
  int K, A, B;
  cin >> K;
  cin >> A >> B;
  int as = (A-1) / K;
  int bs = B /K;
  // cout << bs << " " << as;
  if (bs-as >0){
    cout <<"OK" << endl;
  }else{
    cout << "NG" << endl;
  }
  

}

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

int main() {
	string s;
	int k;
	cin >> s >> k;
	int n = s.size();
	for (int i = 0; i < n&&k>0; i++) {
		if (s[i] != 'a' && (s[i] - 'a') + k >= 26) {
			k -= 26 - (s[i] - 'a');
			s[i] = 'a';
		}
	}
	s[n - 1] = (s[n - 1] - 'a' + k) % 26 + 'a';
	cout << s << endl;
}

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

int main(){
  long long int n; cin>>n;
  long long int a[5];
  long long int tmp=1e+16;
  for(int i=0;i<5;i++){
    cin>>a[i];
    tmp=min(tmp,a[i]);
  }
  cout<<(n%tmp==0 ? ((n/tmp)+4):((n/tmp)+5));
}


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

#define int long long

#define PB push_back
#define PPB pop_back
#define MK make_pair
#define ALL(V) V.begin(), V.end()
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<string, int> psi;
typedef pair<int, pii> pipii;

static const int INF = 1LL << 61;
//static const int MOD = 1000000007;
//static const int MAX_N = 100005;



signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    string s, t;
    cin >> n >> s >> t;
    for (int i = 0; i < n; ++i) {
        string temp = t.substr(0, n - i);
        if (s.find(temp, i) == string::npos) continue;

        cout << n * 2 - (n - i) << endl;
        return 0;
    }
    cout << n * 2 << endl;
}


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

int main(){
	while(1){
		unsigned int a, b;
		cin >> a >> b;
		if(a == 0 && b == 0) break;
		if(a < b){
			int temp = a;
			a = b;
			b = temp;
		}
		int ans = 0;
		while(b != 0){
			int temp = a;
			a = b;
			b = temp % b;
			ans++;
		}
		cout << a << ' ' << ans << endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
n = int(input())
lst = list(map(int,input().split()))
for j in range(101):
    if (j == 0):
        ans = 0
        for i in range(n):
            ans = ans + lst[i]**2
    else:
        x = 0
        for i in range(n):
            x = x + (lst[i] - j)**2
        if (x < ans):
            ans = x

print(ans)


Measured memory_bytes: 9124
#include <bits/stdc++.h>
using namespace std;
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define pb push_back
#define mp make_pair
#define INF9 1000000000 //10^9
#define MOD 1000000007 //10^9+7
#define fi first
#define sc second
using ll=long long;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
using vstr=vector<string>;

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout<<fixed<<setprecision(20);

    int a,b,c,x,y; cin >> a >> b >> c >> x >> y;
    int p = min(a+b,2*c);
    int ans = 0;
    while(x>=1&&y>=1){
        x--;y--;
        ans += p;
    } 
    ans += x*min(a,2*c);
    ans += y*min(b,2*c);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
fun main(args:Array<String>?): Unit {
    var single = false
    val double = BooleanArray(26){false}
    var last = 'a'
    val out = "!OUT"
    repeat(50){
        println("?${last + it.toString().map{c -> 'a' + (c - '0')}.joinToString("") + 'a'}")
        val result = readLine()!!.trim()
        if (result.first() != 'a'){
            println(out)
            return
        }else if (result.length == 2 && double[result[1] - 'a']){
            println(out)
            return
        }else if (result.length == 1 && single) {
            println(out)
            return
        }
        if (result.length == 2) double[result[1] - 'a'] = true
        else single = true
        last = result.last()
    }
}


Measured memory_bytes: 30848
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10, mod = 998244353;
int f[N][3][3][2];

int add(int x, int y) {
  return (x += y) > mod ? x - mod : x;
}

void Add(int &x, int y) {
  x = add(x, y);
}

char lx[N];
int main() {
  scanf("%s", lx + 1);
  int n = strlen(lx + 1);
  int tot = 0, flg = 1, F = 1;
  for(int i = 1; i <= n; ++i) {
    int pos = lx[i] - 'a';
    tot = (tot + pos) % 3;
    if(i > 1 && lx[i] != lx[i - 1]) F = 0;
    if(i > 1 && lx[i] == lx[i - 1]) flg = 0;
  }
  if(F) {
    puts("1");
    exit(0);
  } else if(n == 2) {
    puts("2");
    exit(0);
  } else if(n == 3) {
    if(lx[1] == lx[2]) {
      puts("6");
    } else {
      if(lx[2] == lx[3]) {
        puts("6");  
      } else if(lx[3] == lx[1]) {
        puts("7");
      } else {
        puts("3");
      }
    }
    exit(0);
  }
  for(int i = 0; i < 3; ++i) f[1][i][i][0] = 1;
  for(int i = 1; i < n; ++i)
    for(int j = 0; j < 3; ++j) 
      for(int k = 0; k < 3; ++k)
        for(int t = 0; t < 2; ++t) {
          //f[i][j][k][t];
          for(int w = 0; w < 3; ++w) {
            Add(f[i + 1][(j + w) % 3][w][t | (w == k)], f[i][j][k][t]);
          }
        }
  int ans = flg;
  for(int j = 0; j < 3; ++j) 
    Add(ans, f[n][tot][j][1]);
  printf("%d\n", ans);
  return 0;
}

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

int main(void){

  int N;
  cin >> N;
  int i;
  vector<double> v(N);
  for(i = 0;i<N;i++){
      cin >> v[i];
  }
  
  sort(v.begin(),v.end());
  
  for(i = 0;i < N-1 ;i++){
      v[i + 1] = (v[i] + v[i+1])/2;
  }
  cout  << v[N-1] << endl;
  
  return 0;

}


Measured memory_bytes: 256
n,l = map(int,input().split())

ringo = []
for i in range(l,l+n):
    ringo.append(i)
ringo.sort(key=int)
if 0 in ringo:
    print(sum(ringo))
else:
    if ringo[0] > 0:
        ringo.pop(0)
    else:
        ringo.pop(-1)
    print(sum(ringo))

Measured memory_bytes: 9136
import java.util.*;
public class Main 
{
	public static void main(String[] args) 
	{
		Scanner stdIn = new Scanner(System.in);
		int dx[] = {1, 0, -1, 0, 1, 1, -1, -1, 2, 0, -2, 0};
		int dy[] = {0, -1, 0, 1, 1, -1, 1, -1, 0, -2, 0, 2};
		int field[][] = new int[10][10];
		while(stdIn.hasNext())
		{
			String[] s = stdIn.next().split(",");
			int x = Integer.valueOf(s[0]);
			int y = Integer.valueOf(s[1]);
			int size = Integer.valueOf(s[2]);
			++field[x][y];
			int n = 4 * size;
			for(int i = 0; i < n; ++i)
			{
				if((0 <= x + dx[i] && x + dx[i] < 10) && (0 <= y + dy[i] && y + dy[i] < 10))
				{
					++field[x + dx[i]][y + dy[i]];
				}
			}
		}
		int count = 0;
		int max = 0;
		for(int i = 0; i < 10; ++i)
		{
			for(int j = 0; j < 10; ++j)
			{
				if(field[i][j] >= 1)
				{
					++count;
				}
				if(field[i][j] > max)
				{
					max = field[i][j];
				}
			}
		}
		System.out.println(100 - count);
		System.out.println(max);
	}
}

Measured memory_bytes: 12000
# include <bits/stdc++.h>
# define INF 1e9
using namespace std;

int main(){

  string S;
  cin >> S;
  int n = S.size();
  int ans = INF;
  for(int i=0; i<(n-2); i++){
    int v = stoi(S.substr(i, 3));
      ans = min(ans, abs(753-v));
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  long N,M;
  cin>>N>>M;
  vector<vector<long>> a(N,vector<long>(2));
  for(int i = 0;i<N;i++){
    cin>>a[i][0]>>a[i][1];
  }
  sort(a.begin(),a.end());
  long ans = 0;
  long num = 0;
  int t = 0;
  while(1){
    if((num+a[t][1])<M){
      ans+=a[t][0]*a[t][1];
      num+=a[t][1];
      t++;
    }
    else{
      break;
    }
  }
  ans+=a[t][0]*(M-num);
  cout << ans << endl;
  return 0;
  /*for(int i = 0;i<N;i++){
    cout << a[i][0] << " " << a[i][1] << endl;
  }
  */
}

Measured memory_bytes: 5760
import java.util.Scanner;

class Main{
	public static void main(String[]$){

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		double s = 0;
		for(int i = 1; i <= n; i++){

			int c = 0;
			if(i<k)
				for(int t = i; t < k; t *= 2)
					c++;

			s += (1.0000000000/n) * Math.pow(0.5000000000, c);
		}

		System.out.println(s);
	}
}


Measured memory_bytes: 21844
N = int(input())
A = list(map(int, input().split()))
b4 = b2 = 0
for x in A:
    if x % 4 == 0:
        b4 += 1
    elif x % 2 == 0:
        b2 += 1
print('Yes' if b4 + b2 // 2 >= N // 2 else 'No')

Measured memory_bytes: 15020
#![allow(unused_mut, non_snake_case,unused_imports)]
use std::iter;
use std::cmp::{max, min, Ordering};
use std::mem::{swap};
use std::collections::{HashMap,BTreeMap,HashSet,BTreeSet,BinaryHeap,VecDeque};
use std::iter::FromIterator;

//　高速 EOF要
//macro_rules! input {(source = $s:expr, $($r:tt)*) => {let mut iter = $s.split_whitespace();input_inner!{iter, $($r)*}};($($r:tt)*) => {let mut s = {use std::io::Read;let mut s = String::new();std::io::stdin().read_to_string(&mut s).unwrap();s};let mut iter = s.split_whitespace();input_inner!{iter, $($r)*}};}
//macro_rules! input_inner {($iter:expr) => {};($iter:expr, ) => {};($iter:expr, $var:ident : $t:tt $($r:tt)*) => {let $var = read_value!($iter, $t);input_inner!{$iter $($r)*}};}
//macro_rules! read_value {($iter:expr, ( $($t:tt),* )) => {( $(read_value!($iter, $t)),* )};($iter:expr, [ $t:tt ; $len:expr ]) => {(0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()};($iter:expr, chars) => {read_value!($iter, String).chars().collect::<Vec<char>>()};($iter:expr, usize1) => {read_value!($iter, usize) - 1};($iter:expr, $t:ty) => {$iter.next().unwrap().parse::<$t>().expect("Parse error")};}
// 低速 EOF不要
macro_rules! input {(source = $s:expr, $($r:tt)*) => {let mut iter = $s.split_whitespace();let mut next = || { iter.next().unwrap() };input_inner!{next, $($r)*}};($($r:tt)*) => {let stdin = std::io::stdin();let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));let mut next = move || -> String{bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect()};input_inner!{next, $($r)*}};}
macro_rules! input_inner {($next:expr) => {};($next:expr, ) => {};($next:expr, $var:ident : $t:tt $($r:tt)*) => {let $var = read_value!($next, $t);input_inner!{$next $($r)*}};}
macro_rules! read_value {($next:expr, ( $($t:tt),* )) => {( $(read_value!($next, $t)),* )};($next:expr, [ $t:tt ; $len:expr ]) => {(0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()};($next:expr, chars) => {read_value!($next, String).chars().collect::<Vec<char>>()};($next:expr, usize1) => {read_value!($next, usize) - 1};($next:expr, $t:ty) => {$next().parse::<$t>().expect("Parse error")};}

/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */
fn main(){
    input!(a:i64,n:i64,m:i64);
    let mut ans = 0;
    for y  in 1..100{
        let mut x = 1;
        for _ in 0..n{
            x *= (y+a);
            if x > m{
                break;
            }
        }
        if x > m{
            continue;
        }
        let mut t = 0;
        while x != 0{
            t += x%10;
            x/=10;
        }
        if t == y{
            ans+=1;
        }
    }
    println!("{}",ans);
}


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

int main(){
    int n;
    cin>>n;
    vector<string> a;
    a.push_back("1");
    a.push_back("2");
    a.push_back("3");
    a.push_back("4");
    a.push_back("5");
    a.push_back("6");
    a.push_back("7");
    a.push_back("8");
    a.push_back("9");
    if(n<=9){
        cout<<a[n-1];
        return 0;
    }
    int i = 0;

    while(a.size()<n){
        string b = a[i];
        if(b[b.size()-1] == '0'){
            a.push_back(b+'0');
            a.push_back(b+'1');
        }
        else if(b[b.size()-1] == '9'){
            a.push_back(b+'8');
            a.push_back(b+'9');
        }
        else{
            int x = b[b.size()-1] - '0';
            // cout<<x<<endl;
            a.push_back(b + (char)(-1+x + '0'));
            a.push_back(b+(char)(x + '0'));
            a.push_back(b+(char)(1+x + '0'));
        }
        i++;
    }
    // for(int i=0;i<a.size();i++)
    //  cout<<a[i]<<" ";
    cout<<a[n-1];
}

Measured memory_bytes: 6900
package main

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

var sc = bufio.NewScanner(os.Stdin)

func newInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func main() {

	var n, m, k, ans int
	sc.Split(bufio.ScanWords)
	n = newInt()
	m = newInt()
	k = newInt()
	a := make([]int, n+1)
	b := make([]int, m+1)

	for i := 0; i < n; i++ {
		a[i+1] = a[i] + newInt()
	}

	for i := 0; i < m; i++ {
		b[i+1] = b[i] + newInt()
	}

	j := m
	for i := 0; i <= n; i++ {
		if a[i] > k {
			break
		}
		for a[i]+b[j] > k {
			j--
		}
		if i+j > ans {
			ans = i + j
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 8280
#include <stdio.h>
#include <stdlib.h>
#define N 100


int main()
{
  int top=0;
  char S[N];
  int S1[N];
  
  while(1)
    {
      top++;
      if((scanf("%s",S))==EOF) break;
   
      if(S[0]=='+')
	{
	  S1[top-2]=S1[top-2]+S1[top-1];
	  top=top-2;		    
	}
      else if(S[0]=='-')
	{
	  S1[top-2]=S1[top-2]-S1[top-1];
	  top=top-2;
	}
      else if(S[0]=='*')
	{
	  S1[top-2]=S1[top-2]*S1[top-1];
	  top=top-2;
	}
	 
      else
	{
	  S1[top]=atoi(S);
	}
           
    }

   printf("%d\n",S1[top - 1]);



  return 0;
}



Measured memory_bytes: 2100
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 1000000007;
constexpr int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;



signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int K;
	cin >> K;
	int ans = 0;
	rep(i,K){
		rep(j,K){
			rep(k,K){
				ans += gcd(gcd(i+1,j+1),k+1);
			}
		}
	}
	cout << ans << endl;
}

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

int main(void) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
  
    int N;
    cin >> N;
    vector<long long> A(N);
    bool zero_flag = false;
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
        if (!A[i]) zero_flag = true;
    }
    if (zero_flag) {
        cout << 0 << "\n";
        return 0;
    }
    double log_sum = 0;
    for (int i = 0; i < N; ++i) log_sum += log10(A[i]);
    if (log_sum > 18.5) {
        cout << -1 << "\n";
        return 0;
    }
    long long ans = 1;
    for (int i = 0; i < N; ++i) ans *= A[i];
    if (ans > 1000000000000000000) cout << -1 << "\n";
    else cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3980
#include <bits/stdc++.h>
using namespace std;
const int INF = 1001001001;

int main(){
  int a, b, m; int mina=INF, minb=INF;
  cin >> a >> b >> m;
  vector<int> ai(a);
  vector<int> bi(b);
  for(int i=0; i<a; ++i){
    cin >> ai.at(i);
    mina= min(mina, ai.at(i));
  }
  for(int i=0; i<b; ++i){
    cin >> bi.at(i);
    minb= min(minb, bi.at(i));
  }
  
  int ans= mina + minb;
  for(int i=0; i<m; ++i){
    int x, y, c;
    cin >> x >> y >> c;
    ans= min(ans, ai.at(x-1)+ bi.at(y-1) -c);
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
import java.io.*;
import java.util.*;

public class Main {
    private void solve() {
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }

        int m = n % 2 == 0 ? 2 : 3;
        long[][] dp = new long[n][m];
        for (int i = 0; i < n; i++) {
            Arrays.fill(dp[i], Long.MIN_VALUE);
        }
        dp[0][0] = a[0];
        dp[1][1] = a[1];

        if (n > 2) {
            dp[2][0] = a[0] + a[2];
            if (m == 3) {
                dp[2][2] = a[2];
            }
        }

        for (int i = 3; i < n; i++) {
            for (int j = 0; j < m; j++) {
                for (int k = 0; k < m; k++) {
                    int pi = i - 2 - k;
                    int pj = j - k;
                    if (pi >= 0 && pj >= 0) {
                        dp[i][j] = Math.max(dp[pi][pj], dp[i][j]);
                    }
                }
                if (dp[i][j] != Long.MIN_VALUE) {
                    dp[i][j] += a[i];
                }
            }
        }

        long ans = Long.MIN_VALUE;
        for (int j = 0; j < m; j++) {
            int li = n - 1 - j;
            int lj = m - 1 - j;
            if (li >= 0) {
                ans = Math.max(ans, dp[li][lj]);
            }
        }

        out.println(ans);
    }

    private static PrintWriter out;
    private static MyScanner sc;

    private static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        private MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }
    }

    public static void main(String[] args) {
        out = new PrintWriter(new BufferedOutputStream(System.out));
        sc = new MyScanner();
        new Main().solve();
        out.close();
    }
}


Measured memory_bytes: 56024
/**
DufauX-XuafuD
**/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define reset(x) memset(x,-1,sizeof(x))
#define CheckBit(a,b) (a&(1ll<<b))
#define SetBit(a,b) a=(a|(1ll<<b))
#define UnSetBit(a,b) a=(a&(~(1ll<<b)))
#define maxx 10000006
#define PI 2*acos(0.0)
const long long INF = 2000000000000000000LL;	// 2e18
const int inf = 0x3f3f3f3f;	// 1061109567
const long double EPS = 1e-9;
//bitset<maxx/2>vis;
//bitset<maxx>pr;
//int mobi[maxx+10];
//vector<ll>prime;
//void sieve(){
//    ll x=maxx/2, y=sqrt(maxx)/2;
//    for(ll i=1;i<=y;i++){
//        if(vis[i]==0){
//            for(ll j=(i*(i+1)*2);j<x;j+=(2*i)+1)
//                vis[j]=1;
//        }
//    }
//    prime.push_back(2);
//    for(ll i=3;i<maxx;i+=2)
//        if(vis[i/2]==0)
//        prime.push_back(i);
//}
//void generate_mobius()
//{
//    for(int i=0;i<maxx;i++)mobi[i]=1;
//    for(int i=2;i<maxx;i++){
//        if(!pr[i]){
//            mobi[i]*=-1;
//            for(int j=i+i;j<maxx;j+=i){
//                pr[j]=1;
//                mobi[j]*=(j%(i*i)?-1:0);
//            }
//        }
//    }
//}
//bool isprime(ll a)
//{
//    if(a==1)return false;
//    if(a==2)return true;
//    if(a%2==0)return false;
//    for(ll i=0;i<prime.size() && prime[i]*prime[i]<=a;i++)
//        if(a%prime[i]==0)return false;
//    return true;
//}
/* Calculate ( a*b ) %c */
inline ll mulmod(ll a, ll b, ll c) {
    ll ret = 0 , cur = a % c ;
    while(b) { if(b%2) ret=(ret+cur)%c; cur=(cur<<1)%c; b=b>>1; }
    return ret%c;
}
//Calculate (b^p)%m || modular inverse: b^-1 = bigmod(b, m-2, m)
inline ll bigmod(ll b, ll p, ll m){
    ll ret = 1, cur = b % m;
    while(p) { if(p&1) ret=(ret*cur)%m; cur=(cur*cur)%m; p=p>>1; }
    return ret;
}
inline ll modulo(ll a,ll b,ll c) { //Same as big mod, use for numbers over 1e10
    ll ret = 1 , cur = a%c ;
    while(b) { if(b%2) ret=mulmod(ret,cur,c); cur=mulmod(cur,cur,c); b=b>>1; }
    return ret%c ;
}
inline ll power(ll b, ll p){
    ll ret = 1, cur = b;
    while(p) { if(p&1) ret=(ret*cur); cur=(cur*cur); p=p>>1; }
    return ret;
}
ll lcm(ll a,ll b)
{
    return (a/__gcd(a,b))*b;
}
ll gcd(ll a,ll b)
{
    return __gcd(a,b);
}
ll mod=1000000007;
void Dufaux()
{
    ll n,ans=1;
    cin>>n;
    for(int i=1;i<=n;i++){
        ans*=i;
        ans%=mod;
    }
    cout<<ans<<endl;
}
int main()
{
    FastIO;
	///sieve();
	///generate_mobius();
	int test=1;
	while(test--){
        Dufaux();
	}
	return 0;
}





Measured memory_bytes: 3608
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase

/*
cout<<fixed<<setprecision(20);
cin.tie(0);
ios::sync_with_stdio(false);
*/
const llint mod=1000000007;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
//WATLEPIYO

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(20);
	int i,j,n;cin>>n;
	vector<double>dp(1);dp[0]=1;
	for(i=0;i<n;i++){
		vector<double>ep(i+2);
		double p;cin>>p;
		ep[0]=dp[0]*(1-p);
		for(j=1;j<=i;j++){ep[j]=dp[j-1]*p+dp[j]*(1-p);}
		ep[i+1]=dp[i]*p;
		swap(dp,ep);
	}
	double ans=0;
	for(j=n/2+1;j<=n;j++){ans+=dp[j];}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
#define maxn 200100
#define ll long long
int m,n,k;
ll pre[maxn];
int a[maxn];
ll ans;
void solve(int l,int r)
{
    if(l==r)
    {
        ans+=(a[l]>=0);
        return;
    }
    int mid=(l+r)>>1;
    solve(l,mid);
    solve(mid+1,r);
    //printf("l=%d,r=%d,ans=%I64d\n",l,r,ans);
    int cnt=0;
    pre[cnt]=0;
    for(int i=mid+1;i<=r;++i)
    {
        cnt++;
        pre[cnt]=pre[cnt-1]+a[i];
    }
    sort(pre+1,pre+cnt+1);
    ll sum=0;
    for(int i=mid;i>=l;--i)
    {
        sum+=a[i];
        int lx=lower_bound(pre+1,pre+cnt+1,-sum)-pre;
        //printf("l=%d,r=%d,lx=%d,cnt=%d\n",l,r,lx,cnt);
        ans+=max(0,cnt-lx+1);
    }
}
int main()
{
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;++i)
    {
        scanf("%d",&a[i]);
        a[i]-=k;
    }
    solve(1,n);
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define bs ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long int
#define pb push_back
// #define LOCAL_DEFINE
// #define LOCAL
#define deb(a) cout << #a << " = " << a << '\n'
#define deb2(a, b) cout << #a << " = " << a << ", " << #b << " = " << b << '\n'
#define rep(var,start,end) for(int var=start;var<end;var++)
#define erep(var,start,end) for(int var=start;var<=end;var++)
#define rrep(var,start,end) for(int var=start;var>=end;var--)
#define all(x) x.begin(),x.end()
#define pii pair<int,int>
#define pci pair<char,int>
#define pll pair<ll,ll>
#define test int t;cin>>t;while(t--)

ll expo(ll n, ll p, ll M){
	ll res = 1;
	while(p){
		if(p&1)
			res = (res * n)%M;
		n = (n*n)%M;
		p >>= 1;
	}
	return res;
}

void solve(){
	int n;
	cin >> n;
	string x;
	map<pii,int> cnt;
	rep(i,0,n){
		cin >> x;
		int dec = 0;
		bool start = false;
		ll val = 0;
		for(auto p: x){
			if(start) dec++;
			if(p == '.') start = true;
			else val = val*10 + (p - '0');

		}
		int c2 = 0, c5 = 0;// power of 2 and 5 in val;
		while(val % 2 == 0){
			c2++;
			val/=2;
		}
		while(val % 5 == 0){
			c5++;
			val/=5;
		}

		++cnt[{c2-dec, c5-dec}];
	}
	ll ans = 0;
	for(auto p1: cnt){
		for(auto p2: cnt){

			if(p1.first.first + p2.first.first >= 0 and p1.first.second + p2.first.second >= 0){
				// do nC2
				if(p1 < p2){
					ans += (ll) p1.second * p2.second; 
				}
				if(p1 == p2)
					ans += (ll) p1.second * (p1.second - 1)/2;
			}
		}
	}
	cout << ans;
}

int main()
{
	bs;
	#ifdef LOCAL
	freopen("Contest/input.txt","r",stdin);
	freopen("Contest/output.txt","w",stdout);
	#endif
	solve();
	// test{
	//    solve(); 
	// }
	#ifdef LOCAL_DEFINE
	cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	#endif
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=100000000000000000;


int main() {
    int n,m;
    cin >> n >> m;
    vector<vector<int>> e(n+1,vector<int>(0));
    ld ans;
    vector<ld> d(n+1,0);
    rep(i,m){
        int f,g;
        cin >> f >> g;
        e[f].push_back(g);
    }
    for (int i=n-1;i>0;i--){
        ld c=e[i].size();
        ld h=0;
        rep(j,e[i].size()){
            h+=1+d[e[i][j]];
        }
        d[i]=h/c;
    }
    ans=d[1];
    for (int k=1;k<n;k++){
        if (e[k].size()<2) continue;
        for (int i=n-1;i>0;i--){
        ld c=e[i].size(),p=0;
        if (k==i) c-=1;
        ld h=0;
        rep(j,e[i].size()){
            h+=1+d[e[i][j]];
            p=max(p,d[e[i][j]]+1);
        }
        if (k==i) h-=p;
        d[i]=h/c;
    }
    ans=min(ans,d[1]);
    }
    cout << fixed << setprecision(10) << ans << endl;
}


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

#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)

using namespace std;

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

const int MOD = 1'000'000'007;

struct mint {
  long long x;

  mint(long long x = 0) : x((x % MOD + MOD) % MOD) {}

  mint operator-() const { return mint(-x); }

  mint &operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }

  mint &operator-=(const mint a) {
    if ((x += MOD - a.x) >= MOD) x -= MOD;
    return *this;
  }

  mint &operator*=(const mint a) {
    (x *= a.x) %= MOD;
    return *this;
  }

  mint operator+(const mint a) const { return mint(*this) += a; }

  mint operator-(const mint a) const { return mint(*this) -= a; }

  mint operator*(const mint a) const { return mint(*this) *= a; }

  mint pow(long long t) const {
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(MOD - 2); }

  mint &operator/=(const mint a) { return *this *= a.inv(); }

  mint operator/(const mint a) const { return mint(*this) /= a; }
};

int main() {
  int n;
  string s;
  cin >> n >> s;
  map<char, int> mp;
  for (char c : s) {
    mp[c]++;
  }
  mint res = 1;
  for (auto x : mp) {
    res = res * (x.second + 1);
  }
  res -= 1;
  cout << res.x << endl;
  return 0;
}


Measured memory_bytes: 3772
n = gets.to_i
a = gets.split.map(&:to_i)
a.unshift(0)
a << 0
d = []
(0..n).each do |i|
  d << (a[i] - a[i+1]).abs
end
sum = d.inject(:+)
n.times do |i|
  puts sum - (d[i]+d[i+1]) + (a[i]-a[i+2]).abs
end

Measured memory_bytes: 12804
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;

ll dp[50][410][410];  // dp[i][j][k] : 薬品iまででタイプAの物質がjグラム、タイプBの物質がkグラムのときの必要な予算の最小値

int main() {
    ll n, Ma, Mb;
    cin >> n >> Ma >> Mb;

    vl a(n), b(n), c(n);
    rep(i, n) {
        cin >> a[i] >> b[i] >> c[i];
    }

    rep(i, 50) {
        rep(j, 410) {
            rep(k, 410) {
                dp[i][j][k] = INF;
            }
        }
    }

    dp[0][0][0] = 0;
    rep(i, n) {
        exrep(j, 0, 400) {
            exrep(k, 0, 400) {
                chmin(dp[i+1][j][k], dp[i][j][k]);
                if(j + a[i] <= 400 && k + b[i] <= 400) {
                    chmin(dp[i+1][j + a[i]][k + b[i]], dp[i][j][k] + c[i]);
                }
            }
        }
    }

    ll ans = INF;
    exrep(j, 1, 400) {
        exrep(k, 1, 400) {
            if(j*Mb == k*Ma) {
                chmin(ans, dp[n][j][k]);
            }
        }
    }

    if(ans == INF) {
        out(-1);
    }
    else {
        out(ans);
    }

    re0;
}

Measured memory_bytes: 69252
/*
[ ( ^ _ ^ ) ]
*/
// problem: atc/abc163_b
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1000000000



int main() {
    int n, m;
    scanf("%d %d", &n, &m);

    int s = 0;
    for(int i=0; i<m; i++) {
        int x;
        scanf("%d", &x);
        s += x;
    }

    if(n<s) {
        printf("-1\n");
    } else {
        printf("%d\n", n-s);
    }
}


Measured memory_bytes: 3832
S = input().strip()
C = {chr(i):0 for i in range(97,123)}
n = len(S)
for a in S:
    C[a] += 1
flag = 0
for i in range(97,123):
    if C[chr(i)]==0:
        x = S+chr(i)
        flag = 1
        break
if flag==0:
    cnt = -2
    while cnt>=-n:
        b = S[cnt]
        A = []
        for i in range(n+cnt+1,n):
            if ord(b)<ord(S[i]):
                A.append(S[i])
        if len(A)>0:
            A = sorted(A)
            x = S[:cnt]+A[0]
            flag = 1
            break
        cnt -= 1
if flag == 1:
    print(x)
else:
    print(-1)

Measured memory_bytes: 38256
#include <stdio.h>
#include<string.h>
#include<stdlib.h>
//if文は()の中身が0ならfalse 0以外ならture　writer:al19010
//scanf("%s",&a[0]);入力された文字列（空白文字の手前までを文字リテラルとしてa[0]から代入する。('\n'を'\0'に置き換えているともいえる)
//%sは&a[0]のようにアドレスで対応させる！！（忘れがちなので注意！！）
//gets(&a[0]);//これでやると入力された文字列（空白文字も含めて）を文字リテラルとしてa[0]から代入する。('\n'を'\0'に置き換えているともいえる)。ただし、バッファオーバーフローの温床になり得るのでgccコンパイラが警告を出す。
//fgets(&a[0],入力文字数,stdin(ファイルポインタをstdinによって標準入力化));//こっちは安全なget関数。警告も出ない。
//scanf("%[^\n]",&a[0]);これが一番文字入力でおすすめ！！
//strcmp(s1,s2) s1とs2が同じ文字列なら0を返す。#include<string.h>が必要　s1とs2はchar型のポインタでなければならない！
//fprint(fp,"");ファイルポインタの示すファイルに""の中身を入力                                      
//fscanf(fp,"");ファイルポインタの示すファイルから""のと合致する変数型の中身を取得
//fp=fopen("ファイル名.txt","r");　ファイルの中身はUTF-8である必要がある//

//double hyouji(int n,double a[][n])
typedef struct{
    int m;
    int f;
    int r;
    char result;
}id;
int main(void){//線形代数学p57参照（参考）
    //入力部
    id student[50];
    int i,n;
    for(i=0;i<50;i++){
        scanf("%d %d %d",&student[i].m,&student[i].f,&student[i].r);
        if(student[i].m==-1&&student[i].f==-1&&student[i].r==-1){
            n=i;
            break;
        }
    }
    //処理部
    for(i=0;i<n;i++){
        if(student[i].m+student[i].f>=80){
            student[i].result='A';
        }
        else if(student[i].m+student[i].f>=65&&student[i].m+student[i].f<80){
            student[i].result='B';
        }
        else if((student[i].m+student[i].f>=50&&student[i].m+student[i].f<65)||(student[i].m+student[i].f>=30&&student[i].m+student[i].f<50&&student[i].r>=50)){
            student[i].result='C';
        }
        else if((student[i].m==-1||student[i].f==-1)||(student[i].m+student[i].f<30)){
            student[i].result='F';
        }
        else if(student[i].m+student[i].f>=30&&student[i].m+student[i].f<50){
            student[i].result='D';
        }
       
    }
    //出力部
    //printf("n=%d,m=%d\n",n,m);
    for(i=0;i<n;i++){
        printf("%c",student[i].result);
        printf("\n");
        //if(i!=n-1) printf("\n");
    }

    return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<int, int> PII;

const int MM = 1e9 + 7;
const double eps = 1e-8;
const int MAXN = 2e6 + 10;

int n, m;

void prework(){

}

void read(){

}

void solve(int casi){
//	cout << "Case #" << casi << ": ";
	set<vector<ll> >mp;
	vector<ll> a(3);
	cin>>a[0]>>a[1]>>a[2];
	sort(a.begin(), a.end());
	mp.insert(a);
	int cnt = 0;
	ll s = a[0] + a[1] + a[2];
	for(int i = 1; ; i++){
		//puts("====");
		int flag = 0;
		for(int j = 0; j < 3; j++){
			if (a[j] & 1){
				flag = 1;
				break;
			}
		}
		if (flag == 1){
			cout<<cnt<<endl;
			return ;
		}
		vector<ll> b(3);
		for(int j = 0; j < 3; j++){
			b[j] = (s - a[j]) / 2;
		}
		sort(b.begin(), b.end());
		if (mp.find(b) != mp.end()){
			puts("-1");
			return ;
		}
		mp.insert(b);
		a.swap(b);
		cnt++;
	}
}

void printans(){

}

int main(){
//	std::ios::sync_with_stdio(false);
	prework();
	int T = 1;
//	cin>>T;
	for(int i = 1; i <= T; i++){
		read();
		solve(i);
		printans();
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;

ll GCD(ll a, ll b) {
    return (b > 0) ? GCD(b, a % b) : a;
}

ll LCM(ll a, ll b) {
    return a / GCD(a, b) * b;
}

int main() {
    int n;
    cin >> n;
    map<P, ll> mp;
    rep(i, n){
        ll a, b;
        cin >> a >> b;
        if(a<=0){
            a = -a;
            b = -b;
        }
        if(a!=0 && b!=0){
            ll gcd = GCD(a, abs(b));
            a /= gcd;
            b /= gcd;
        }
        mp[make_pair(a, b)]++;
    }

    ll a0 = 0;
    ll b0 = 0;
    ll ab = 0;
    ll mod = 1000000007;
    ll ans = 1;
    for(auto i = mp.begin(); i != mp.end(); i++){
        P p = i->first;
        ll c = i->second;
        ll a = p.first;
        ll b = p.second;
        if(a==0 && b==0){
            ab += c;
        }else if(a == 0){
            a0 += c;
        }else if(b == 0){
            b0 += c;
        }else if(b > 0){
            if(mp.find(make_pair(b, -a)) == mp.end()){
                ll m = 1;
                rep(j, c)m = m * 2 % mod;
                ans = ans * m % mod;
            }else{
                ll c2 = mp[make_pair(b, -a)];
                ll na = 1;
                ll nb = 1;
                rep(j, c){
                    na = na * 2 % mod;
                }
                rep(j, c2){
                    nb = nb * 2 % mod;
                }
                na--;
                nb--;
                ll mm = na + nb + 1;
                mm %= mod;
                ans = ans * mm % mod;
            }
        }else{
            if(mp.find(make_pair(-b, a)) == mp.end()){
                ll m = 1;
                rep(j, c)m = m * 2 % mod;
                ans = ans * m % mod;
            }
        }
    }

    ll na = 1;
    ll nb = 1;
    rep(i, a0){
        na = na * 2 % mod;
    }
    rep(i, b0){
        nb = nb * 2 % mod;
    }
    na--;
    nb--;
    ll mm = na + nb + 1;
    mm %= mod;
    ans = ans * mm % mod;
    ans = (ans + ab - 1 + mod) % mod;
    cout << ans << endl;
}

Measured memory_bytes: 15912
N = int(input())
pnt = [[0]*3]
for i in range(N):
  pnt.append(list(map(int, input().split())))
cnt = 0
for i in range(1, N+1):
  t = pnt[i][0] - pnt[i-1][0]
  x = abs(pnt[i][1] - pnt[i-1][1])
  y = abs(pnt[i][2] - pnt[i-1][2])
  if t >= x+y and (t-(x+y)) % 2 == 0:
    cnt += 1
if cnt == N: print("Yes")
else: print("No")


Measured memory_bytes: 90012
def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    D = [0] * N
    if sum(A) < sum(B):
        print(-1)
        return
    retval = 0
    minussum = 0
    for i in range(N):
        D[i] = A[i] - B[i]
        if D[i] < 0:
            minussum += D[i]
            retval += 1
    D.sort(reverse=True)

    for d in D:
        if minussum >= 0:
            break
        if d > 0:
            minussum += d
            retval += 1
    print(retval)


if __name__ == "__main__":
    main()


Measured memory_bytes: 80176
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int x;
		for (int i = 1; i <= n; i++) {
			x = i;
			if (x % 3 == 0) {
				System.out.print(" " + i);
			} else {
				while (x != 0) {
					if (x % 10 == 3) {
						System.out.print(" " + i);
						break;
					}
					x /= 10;
				}
			}
		}
		System.out.println();
	}

}

Measured memory_bytes: 28608
module ABC154A
  sub Main(ByVal args() as String)
    Dim S as String
    Dim T as String
    dim arr(2) as string
    arr=Split(Console.ReadLine())
    S = arr(0)
    T = arr(1)
    
    Dim A as Long
    Dim B as Long
    dim arr2(2) as string
    arr2=Split(Console.ReadLine())
    A = arr2(0)
    B = arr2(1)
    
    Dim U as String
    U = Console.ReadLine()
    
    If U = S Then
        A = A-1
    Else
        B = B-1
    End If

    Console.WriteLine("{0} {1}", A, B)
  end sub
end module


Measured memory_bytes: 28460
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int A,B,C,X,Y;
  cin >> A >> B >> C >> X >> Y;
  C *= 2;
  int ans = 0;
  if(X >= Y){
    ans = A*X + B*Y;
    ans = min(ans, C*X);
    ans = min(ans, C*Y + A*(X-Y));
  }else{
    ans = A*X + B*Y;
    ans = min(ans, C*Y);
    ans = min(ans, C*X + B*(Y-X));
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		int[] cards=new int[N*2+1];
		for(int i=0; i<2*N+1; i++) {
			cards[i]=i;
		}
		int syori=sc.nextInt();

		int mai=0;
		for(int i=0; i<syori; i++) {
			mai=sc.nextInt();
			if(mai>1) {
				int[] ue=new int[mai];
				int[] sita=new int[N*2-mai];

				for(int j=1; j<=mai; j++) {
					ue[j-1]=cards[j];
				}
				for(int j=1; j<=N*2-mai; j++) {
					sita[j-1]=cards[mai+j];
				}

				for(int j=1; j<=N*2; j++) {
					if(j<=N*2-mai) {
						cards[j]=sita[j-1];
					}
					else {
						cards[j]=ue[j-(N*2-mai)-1];
					}
				}
			}
			else if(mai==1){
				int ue=cards[1];
				for(int j=1; j<=N*2-1; j++) {
					cards[j]=cards[j+1];

				}
				cards[N*2]=ue;
			}
			else if(mai==0){
				int[] N1=new int[N];
				int[] N2=new int[N];

				for(int j=1; j<=N*2; j++) {
					if(j<=N) {
						N1[j-1]=cards[j];

					}
					else {
						N2[j-N-1]=cards[j];

					}
				}

				for(int j=1; j<=N*2; j++) {
					if(j%2==1) {
						cards[j]=N1[(j-1)/2];
					}
					else {
						cards[j]=N2[j/2-1];
					}
				}
			}
		}

		for(int i=1; i<=2*N; i++) {
			System.out.println(cards[i]);
		}
	}
}



Measured memory_bytes: 31876
#include <iostream>
  #include <iomanip>
  #include <algorithm>
  #include <cmath>
  #include <queue>
  #include <list>
  #include <limits>
  #include <string>
  #include <vector>
  #include <stack>
  using namespace std;
  typedef unsigned long long ll;

  typedef pair<ll, ll> curr;
  const int MOD = 998244353;


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

  ll calc(int a, int b, int p){
    if(b == 0) return 1;
    if(b % 2 == 0){
      ll d = calc(a, b/2, p);
      return (d*d)%p;
    }else{
      return (a*calc(a, b-1, p))%p;
    }

  }
  ll a[60];
  ll p[60];
  ll f(ll n, ll x){
    if(n == 0) return 0;
    if(x <= 0) return 0;
    if(x <= a[n-1]+1) return f(n-1,x-1);
    if(x == 2 + a[n-1]) return p[n-1]+1;
    if(x && x <= 2+2*a[n-1]) return p[n-1]+1+f(n-1 , x-2-a[n-1]);
    if(x == 3 + 2*a[n-1]) return 2*p[n-1]+1;
  }

  int main(){
    string s,t;
    cin >> s >> t;
    vector<int> s_str[26];
    vector<int> t_str[26];
    bool flag[26] = {};
    for(int i=0;i<s.length();i++){
      s_str[s[i]-'a'].push_back(i);
      t_str[t[i]-'a'].push_back(i);
    }
    for(int i=0;i<26;i++){
      for(int j=0;j<26;j++){
        if(s_str[i].size() != t_str[j].size()) continue;
        for(int k=0;k<s_str[i].size();k++){
          if(s_str[i][k] != t_str[j][k]) break;
          if(k == s_str[i].size()-1) flag[i] = true;
        }
      }
    }
    for(int i=0;i<26;i++){
      if(s_str[i].size() == 0) continue;
      if(!flag[i]){
        cout << "No";
        return 0;
      }
    }
    cout << "Yes";
  }

//sの一致文字列位置がtの一致文字列位置の部分集合

Measured memory_bytes: 3080
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
main(){
  char a,b;
  int cup[256]={};
  cup['A']=1;
  while(~scanf("%c,%c ",&a,&b)){
    swap(cup[a],cup[b]);
  }
  //  printf("%d %d %d\n",cup['A'],cup['B'],cup['C']);
  if(cup['A']==1) puts("A");
  else if(cup['B']==1) puts("B");
  else puts("C");
}

Measured memory_bytes: 1120
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define REP(i,a,b) for(int i=int(a);i<(int)b;++i)
#define Graph vector<vecctor<ll>>
#define pairs vector<pair<ll,ll>>
#define pb push_back



using namespace std;
using ll = long long;
const ll INF = 1e18;
const double PI = acos(-1);

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



int main(void)
{
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    string s,t;
    cin >> s >> t;
    int ans = 1e8;
    rep(i,s.size()-t.size()+1){
        int num = 0;
        rep(j,t.size()){
            if(s[i+j] != t[j])num++;
        }
        ans = min(ans,num);
    }

    cout << ans << endl;
    



    return 0;
}


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

public class Main {

    public static void main(String[] args) throws IOException {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String input = br.readLine();
        String[] strArray = input.split(" ");
        int n = Integer.parseInt(strArray[0]);  //n???
        int m = Integer.parseInt(strArray[1]);  //m???

        int[][] A = new int[n][m];
        int[] b = new int[m];

//      ?????????????????????A????????????????????????
        for(int i = 0; i < A.length; i++){
            input = br.readLine();
            strArray = input.split(" ");
            for(int j = 0; j < A[i].length; j++){
                A[i][j] = Integer.parseInt(strArray[j]);
            }
        }

//      ?????????????????????b?????????????????????
        for(int i = 0; i < b.length; i++){
            input = br.readLine();
            b[i] = Integer.parseInt(input);
        }

//      A??¨b??????????¨??????????
        for(int i = 0; i < A.length; i++){
            int ans = 0;
            for(int j = 0; j < A[i].length; j++){
                ans += A[i][j] * b[j];
            }
            System.out.println(ans);
        }
    }
}

Measured memory_bytes: 27596
n = int(input())
A = list(map(int, input().split()))

B = [0] * 9
for a in A:
    if a < 3200:
        B[a // 400] += 1
    else:
        B[8] += 1

count = 0
for b in B[:8]:
    if b:
        count += 1

print(max(count, 1), count + B[8])


Measured memory_bytes: 3060
#![allow(unused_imports)]
#![allow(unused_macros)]
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_variables)]
#![allow(unused_mut)]
#![allow(unused_assignments)]
use proconio::input;
use proconio::marker::Usize1;
use std::collections::*;
use std::cmp::*;
use std::f64::consts::*;

const MOD: u64 = 1000000007;
const INF: usize = std::usize::MAX / 4;

fn main() {
    input! {
        N: usize,
        K: usize,
    }

    let mut cnt = vec![0; N];

    for _ in 0..K {
        input! {
            D: usize,
            A: [Usize1; D],
        }
        for &a in &A {
            cnt[a] += 1;
        }
    }

    println!("{}", cnt.iter().filter(|&&c| c == 0).count());
}


Measured memory_bytes: 2180
<?php
  $num = trim(fgets(STDIN));
  $taro = 0;
  $hanako = 0;
  for($i = 0; $i < $num; $i++) {
    list($a, $b) = explode(" ", trim(fgets(STDIN)));
    if (strcasecmp($a, $b) == 0) {
      $taro += 1;
      $hanako += 1;
    } else if (strcasecmp($a, $b) > 0) {
      $taro += 3;
      $hanako += 0;
    } else if (strcasecmp($a, $b) < 0) {
      $taro += 0;
      $hanako += 3;
    }
  }
  print($taro . " " . $hanako);
?>

Measured memory_bytes: 6588
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

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

	vector<int> v(n);

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

	vector<int> d(n);

	d[1] = abs(v[0] - v[1]);

	for (int i = 2; i < n; i++)
	{
		d[i] = min(d[i-2] + abs(v[i] - v[i-2]), d[i-1] + abs(v[i] - v[i-1]));
	}

	cout << d[n-1];

	return 0;
}


Measured memory_bytes: 1024