akhauriyash/Code-Regression huggingface dataset:
import sys,bisect,string,math,time,functools,random,fractions
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
from itertools import permutations,combinations,groupby
rep=range
def Golf():n,*t=map(int,open(0).read().split())
def I():return int(input())
def S_():return input()
def IS():return input().split()
def LS():return [i for i in input().split()]
def LI():return [int(i) for i in input().split()]
def LI_():return [int(i)-1 for i in input().split()]
def NI(n):return [int(input()) for i in range(n)]
def NI_(n):return [int(input())-1 for i in range(n)]
def StoLI():return [ord(i)-97 for i in input()]
def ItoS(n):return chr(n+97)
def LtoS(ls):return ''.join([chr(i+97) for i in ls])
def RA():return map(int,open(0).read().split())
def GI(V,E,ls=None,Directed=False,index=1):
    org_inp=[];g=[[] for i in range(V)]
    FromStdin=True if ls==None else False
    for i in range(E):
        if FromStdin:
            inp=LI()
            org_inp.append(inp)
        else:
            inp=ls[i]
        if len(inp)==2:
            a,b=inp;c=1
        else:
            a,b,c=inp
        if index==1:a-=1;b-=1
        aa=(a,c);bb=(b,c);g[a].append(bb)
        if not Directed:g[b].append(aa)
    return g,org_inp
def GGI(h,w,search=None,replacement_of_found='.',mp_def={'#':1,'.':0},boundary=1):
#h,w,g,sg=GGI(h,w,search=['S','G'],replacement_of_found='.',mp_def={'#':1,'.':0},boundary=1) # sample usage
    mp=[boundary]*(w+2);found={}
    for i in range(h):
        s=input()
        for char in search:
            if char in s:
                found[char]=((i+1)*(w+2)+s.index(char)+1)
                mp_def[char]=mp_def[replacement_of_found]
        mp+=[boundary]+[mp_def[j] for j in s]+[boundary]
    mp+=[boundary]*(w+2)
    return h+2,w+2,mp,found
def TI(n):return GI(n,n-1)
def accum(ls):
    rt=[0]
    for i in ls:rt+=[rt[-1]+i]
    return rt
def bit_combination(n,base=2):
    rt=[]
    for tb in range(base**n):s=[tb//(base**bt)%base for bt in range(n)];rt+=[s]
    return rt
def gcd(x,y):
    if y==0:return x
    if x%y==0:return y
    while x%y!=0:x,y=y,x%y
    return y
def show(*inp,end='\n'):
    if show_flg:print(*inp,end=end)
 
YN=['YES','NO'];Yn=['Yes','No']
mo=10**9+7
inf=float('inf')
FourNb=[(-1,0),(1,0),(0,1),(0,-1)];EightNb=[(-1,0),(1,0),(0,1),(0,-1),(1,1),(-1,-1),(1,-1),(-1,1)];compas=dict(zip('WENS',FourNb));cursol=dict(zip('LRUD',FourNb))
l_alp=string.ascii_lowercase
#sys.setrecursionlimit(10**7)
read=sys.stdin.buffer.read
readline=sys.stdin.buffer.readline
input=lambda: sys.stdin.readline().rstrip()


show_flg=False
show_flg=True
ans=0


#n,m=LI()
k=n=I()
s=input()

for i in range(n):
    0

print(s[:k]+'...'*(len(s)>k))


Measured memory_bytes: 78348
from numpy import*
(_,k),*t=[int64(t.split())for t in open(0)]
A,F=map(sort,t)
l=-1
r=10**12
while r-l>1:
 m=l+r>>1
 if sum(A-minimum(A,m//F[::-1]))>k:l=m
 else:r=m
print(r)

Measured memory_bytes: 37252
package main

import (
	"bufio"
	"fmt"
	"log"
	"os"
	"sort"
	"strconv"
	"strings"
)

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func main() {
	scanner := makeWordScanner()
	n := eGetInt(scanner)
	k := eGetInt(scanner)
	as := make([]int, n)
	for i := 0; i < len(as); i++ {
		as[i] = eGetInt(scanner)
	}
	acc := make(map[int]int)
	for i := 0; i < len(as); i++ {
		acc[as[i]]++
	}

	typeCount := 0
	counts := make([]int, len(acc))
	i := 0
	for _, v := range acc {
		if v > 0 {
			typeCount++
		}
		counts[i] = v
		i++
	}
	replaceCount := max(typeCount-k, 0)
	sort.Ints(counts)
	sum := 0
	for i := 0; i < replaceCount; i++ {
		sum += counts[i]
	}
	fmt.Println(sum)
}

////////////////////////////////////////////////////////////////////////////////
// ライブラリ
////////////////////////////////////////////////////////////////////////////////
func makeScanner(maxByte int) *bufio.Scanner {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]uint8, 0, 8192), maxByte)
	return scanner
}
func makeWordScanner() *bufio.Scanner {
	scanner := makeScanner(8192)
	scanner.Split(bufio.ScanWords)
	return scanner
}
func eGetLine(r *bufio.Scanner) string {
	if r.Scan() {
		return r.Text()
	}
	err := r.Err()
	if err != nil {
		log.Fatal(err)
	}
	// EOF
	return ""
}

func eGetInt(r *bufio.Scanner) int {
	line := eGetLine(r)
	return eAtoi(line)
}
func eGetInt64(r *bufio.Scanner) int64 {
	line := eGetLine(r)
	return eAtoInt64(line)
}
func eGetFields(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Fields(line)
}
func eGetInts(r *bufio.Scanner) []int {
	fields := eGetFields(r)
	ints := make([]int, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoi(fields[i])
	}
	return ints
}
func eGetInt64s(r *bufio.Scanner) []int64 {
	fields := eGetFields(r)
	ints := make([]int64, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoInt64(fields[i])
	}
	return ints
}
func eGetChars(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Split(line, "")
}
func eAtoi(s string) int {
	n, err := strconv.Atoi(s)
	if err != nil {
		log.Fatal(err)
	}
	return n
}
func eAtoInt64(s string) int64 {
	n, err := strconv.ParseInt(s, 10, 64)
	if err != nil {
		log.Fatal(err)
	}
	return n
}


Measured memory_bytes: 14848
n,m = map(int,input().split())
#0からn段の階段を作成
j = [True for i in range(n+1)]
#0,1段は1通り
ans = [1,1]+[0 for i in range(n-1)]
p = 10**9+7
#どこが壊れているかcheck
for i in range(m):
    j[int(input())] = False
    
#もし1段目が壊れていたら101となる
if j[1] == False:
    ans[1] = 0
    ans[2] = ans[0]
#二段目から調べる
for i in range(2,n+1):
    #壊れていない場合
    if j[i] == True:
        ans[i] = ans[i-1] + ans[i-2]
        ans[i] %= p
    #壊れている場合
    else:
        ans[i] = 0
        
print(ans[n]%p)

Measured memory_bytes: 7840
N,K = map(int, input().split())
A = [*map(lambda x:int(x)-1, input().split())]

cnt = [0]*N
pre = 0
for _ in range(N*2):
    cnt[pre] += 1
    now = A[pre]
    pre = now

one = 0
loops = 0
for c in cnt:
    if c == 1: one += 1
    elif c > 1: loops += 1

k = max(0, K-one) % loops + min(K, one)

pre = 0
for _ in range(k):
    now = A[pre]
    pre = now

ans = pre + 1
print(ans)


Measured memory_bytes: 32372
import java.util.Scanner;


public class Main {
    public static void main(String[] args) {
        int w, h;
       
        Scanner sc = new Scanner(System.in);
        while(true){
            h = sc.nextInt();
            w = sc.nextInt();
        if(w==0 && h==0){
        break;
        }
        else{
            for(int j = 0; j<h; j++){
        for (int i = 0; i<w; i++){
        System.out.print("#");
        }
        System.out.println();
            }
            System.out.println();
        }
        }
}}



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

int main() {
    int a[5];
    int k;
    rep(i,5) cin >> a[i];
    cin >> k;

    sort(a, a+5);
    if (a[4]-a[0] <= k) cout << "Yay!" << endl;
    else cout << ":(" << endl;;    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
int main()

{
    int x1,x2,x3,x4,x5;
    std::cin >> x1 >> x2 >> x3 >> x4 >>x5;

    if (x1+x2+x3+x4+x5==14)
    {
       std:: cout << "1" << std::endl;
    }

    if (x1+x2+x3+x4+x5==13)
    {
       std:: cout << "2" << std::endl;
    }

    if (x1+x2+x3+x4+x5==12)
    {
       std:: cout << "3" << std::endl;
    }

    if (x1+x2+x3+x4+x5==11)
    {
        std:: cout << "4" << std::endl;
    }

    if (x1+x2+x3+x4+x5==10)
    {
        std:: cout << "5" << std::endl;
    }
    
    return 0;
}

Measured memory_bytes: 3652
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
  int n;
  cin >> n;
  int c[n],v[n];
  rep(i,n)cin >> v[i];
  rep(i,n)cin >> c[i];
  int ans=0;
  rep(i,n){
    if(c[i]<=v[i])ans+=v[i]-c[i];
  }
  cout << ans << endl;
return 0;}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repl(i, l, r) for (ll i = (l); i < (r); i++)
#define rep(i, n) repl(i, 0, n)
#define CST(x) cout << fixed << setprecision(x)
using ll = long long;
const ll MOD = 1000000007;
const int inf = 1e9 + 10;
const ll INF = 4e18 + 10;
const int dx[9] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
const int dy[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0};
int main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);

	string s;
	cin >> s;
	if (s[s.size() - 1] == 's')
		s += "es";
	else
		s += "s";
	cout << s << endl;
	return 0;
}

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

int main()
{

    int a,b;

    scanf("%d%d",&a,&b);

    if(a>=3 && a<=20 && b>=3 && b<=20){
        if(a==b) printf("%d\n",a+a);
        if(a>b) printf("%d\n",a+(a-1));
        if(a<b) printf("%d\n",b+(b-1));
    }


    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
int main () {

  int i,j,n,v,a[1000];

  scanf("%d",&n);
  for(i=0 ; i<n ; i++){
    scanf("%d",&a[i]);
  }
  for(i=0 ; i<n ; i++){
    v=a[i];
    j=i-1;
    while(j >=0 && a[j]>v ){
      a[j+1] = a[j];
      j--;
      a[j+1]=v;
    }

    //output
    for(j=0 ; j<n ; j++){
      printf("%d",a[j]);

      if(j<n-1)
	printf(" ");
      
    }
    printf("\n");
    
  }
  
  return 0;
}

Measured memory_bytes: 2752
#include<iostream>
using namespace std;
int main(){
  int n;cin>>n;
  bool flag = false;
  for(int i = 0;i<n;i++){
    int t;
	cin >> t;
    if(t%2==0){
      if(t%3!=0&&t%5!=0){
        flag = true;
      }
    }
    if(flag) break;
  }
  if(flag)cout << "DENIED" << endl;
  else cout << "APPROVED"<< 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>;

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

	int a, b, m;
	cin >> a >> b >> m;
	vector<int> A(a), B(b);
	rep(i, a)
		cin >> A.at(i);
	rep(i, b)
		cin >> B.at(i);
	int minv;
	minv = *min_element(A.begin(), A.end()) + *min_element(B.begin(), B.end());
	rep(i, m)
	{
		int x, y, c;
		cin >> x >> y >> c;
		minv = min(minv, A.at(x - 1) + B.at(y - 1) - c);
	}
	cout << minv << endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define N 21
#define M 210
using namespace std;
int n, m, q;
int a[N];
//bool used[N][M];
bool solve(int i, int j){
    if(i > n) return false;
    if(j == 0) return true;
    bool f1 = solve(i+1, j), f2 = false;
    if(j-a[i] >= 0) f2 = solve(i+1, j-a[i]);
    return f1||f2;
}
int main() {
    scanf("%d", &n);
    for(int i = 0; i < n; i++) scanf("%d", &a[i]);
    scanf("%d", &m);
    for(int i = 0; i < m; i++){
        scanf("%d", &q);
        solve(0, q) ? puts("yes") : puts("no");
    }
    return 0;
}


Measured memory_bytes: 3156
def check(n, array):
    if 1.1 <= n:
        array[0] += 1
    elif 0.6 <= n < 1.1:
        array[1] += 1
    elif 0.2 <= n < 0.6:
        array[2] += 1
    else:
        array[3] += 1


left = [0] * 4
right = [0] * 4
while 1:
    try:
        l, r = map(float, input().split())
    except:
        break

    check(l, left)
    check(r, right)

for l, r in zip(left, right):
    print(l, r)


Measured memory_bytes: 5576
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+10;
ll sum[N];
ll n,x,mod;
int main() {
    cin >> n >> x >> mod;
    map<int, int> m;
    ll s=-1,e,i=1;//s是循环节起点，e是终点
    while(1) {
        sum[i]=x +sum[i-1];
        if (m[x] == 0) m[x]++;
        else if (m[x] == 1) {
            if(s==-1) s = i;
            m[x]++;
        } else{
            e = i - 1;
            break;
        }
        x=((x%mod)*(x%mod))%mod;
        i++;
    }
    ll k=(e-s+1);
    s-=k,e-=k;
    ll ans=0;
    ll res=sum[e]-sum[s-1];//循环节大小
    ans=sum[s-1]+res*((n-(s-1))/k)+(sum[s+(n-(s-1))%k-1]-sum[s-1]);
    cout<<ans;
    return 0;
}


Measured memory_bytes: 6688
#include <bits/stdc++.h>
#define ll long long
#define REP(i, n) for (ll (i) = 0; (i) < (n); (i)++)
#define REPI(i, a, b) for (ll (i) = (a); (i) < (b); (i)++)
#define int long long
using namespace std;
using P = pair<int, int>;
using VI = vector<int>;
using VVI = vector<VI>;
using VVVI = vector<VVI>;

int N, K;
VI A;

void solve() {
  sort(A.begin(), A.end());
  VI v;
  int num = 1;
  REPI (i, 1, N+1) {
    if (A[i] != A[i-1] || i == N) {
      v.push_back(num);
      num = 1;
    } else {
      num++;
    }
  }
  assert(num == 1);
  sort(v.begin(), v.end());
  int cur = v.size();
  int ans = 0;
  for (int x: v) {
    if (cur <= K) { break; }
    cur--;
    ans += x;
  }
  cout << ans << endl;
}

signed main() {
  cin >> N >> K;
  A = VI(N);
  REP (i, N) {
    cin >> A[i];
  }

  solve();
}


Measured memory_bytes: 3956
#include <iostream>
#include <string>
#include <vector>
#include <list>
//#include <cmath>
#include <random>
#include <algorithm>

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

using std::vector;
using std::list;
using std::string;

void func()
{
	string S;
	string T;
	cin >> S;
	cin >> T;
	int x = 0;
	if (S[0] == T[0]) {
		x++;
	}
	if (S[1] == T[1]) {
		x++;
	}
	if (S[2] == T[2]) {
		x++;
	}
	cout << x << endl;
}


int main() {
	func();

}




Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cassert>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repd(i, n) for (int i = n; i >= 1; i--)
#define mod 1000000007
#define MOD 998244353
#define inf 1e20
typedef long long int ll;
typedef pair<ll, ll> p;


int main() {
	int n,sub,ans=0;
	string s;
	cin >> n >> s;
	int xcnt[30],ycnt[30];
	rep(i, n) {
		sub = 0;
		rep(j, 30) {
			xcnt[j] = 0;
			ycnt[j] = 0;
		}
		rep(j, i) {
			xcnt[s[j] - 'a']++;
		}
		rep(j, n - i) {
			ycnt[s[j+i] - 'a']++;
		}
		rep(j, 30) {
			if (xcnt[j] > 0 && ycnt[j] > 0) {
				sub++;
			}
		}
		ans = max(ans, sub);
	}
	cout << ans << endl;
	return 0;
}

//Ctrl+Aを使わない

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int  long long 
#define speedrap ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
int be(int a,int b,int mod) {if(b == 0) return 1; if(b%2 == 1) return (a*be(a,b-1,mod))%mod; else return (be(a,b/2,mod)*be(a,b/2,mod))%mod;}
const int mod = 1e9 + 7;
#define PI 3.14159265359
#define pf push_front
#define pb push_back
#define bitcount __builtin_popcountll
#define setbitcnt __builtin_ctz
#define sc(a) scanf("%d", &a);
#define sz(s) (int)s.size()
#define eb emplace_back
#define pf push_front
#define mkp(x,y) make_pair(x,y)
#define all(x) x.begin(),x.end()
#define INF 0x3f3f3f3f
#define roundup(a,b)  std::cout << std::fixed;std::cout << std::setprecision(b); std::cout << a
const int siz = (1e6 + 10);
const int logi = 21;
const double epsilon = 1e-6;
bool cmp(const int &a,const int &b)
{
  return (abs(a-b)>1);
}



signed main()
{
	#ifndef ONLINE_JUDGE
 	freopen("in.txt", "r", stdin);
 	freopen("out.txt", "w", stdout);
 	#else
// // online submission
 	#endif 
	speedrap
	int t;
	t = 1;
	//cin>>t;
	int val = 0;
	while(t--)
	{
		int n;
		cin>>n;
		int k;
		cin>>k;
		int a[n];

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

		for(int i = k ; i < n ;i ++)
		{
			if(a[i] > a[i-k])
			{
				cout<<"Yes\n";
			}
			else
			{
				cout<<"No\n";
			}
		}
	}
}

Measured memory_bytes: 5204
#include<bits/stdc++.h>
using namespace std;
typedef signed long long ll;
 
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

int main(){
	int i,j,k,n,m,l,y,z; string s;
	cin >> n;
	string u[15];
	double x[15];

	rep(i, n){
		cin >> x[i] >> u[i];
	}

	double f = 0;
	rep(i, n){
		if(u[i] == "JPY"){
			f += x[i];
		}else{
			f += x[i] * 380000.0;
		}
	}

	cout << f << endl;
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <complex>
#include <regex>

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}

int main() {

    int N, M;
    cin >> N >> M;

    vector<int> a(N + 1, 0);
    vector<int> e(M);
    for (int i = 0; i < M; i++) cin >> e[i];

    vector<int> ans;
    for (int i = M - 1; i >= 0; i--) if (a[e[i]] == 0)ans.push_back(e[i]), a[e[i]] = 1;

    for (int i = 1; i <= N; i++) if (a[i] == 0) ans.push_back(i);

    for (auto x : ans) cout << x << endl;

    return 0;
}






























































Measured memory_bytes: 5104
#include<bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
	ll h, w;
	cin >> h >> w;
	vector<string> v(h);
	for (ll i = 0; i < h; ++i)cin >> v[i];
	vector<vector<ll>> dp(h, vector<ll>(w));
	if (v[0][0] == '.')dp[0][0] = 0;
	else dp[0][0] = 1;
	for (ll i = 1; i < w; ++i) {
		dp[0][i] = dp[0][i - 1] + (v[0][i] != v[0][i - 1]);
	}
	for (ll i = 1; i < h; ++i) {
		dp[i][0] = dp[i - 1][0] + (v[i][0] != v[i - 1][0]);
	}
	for (ll i = 1; i < h; ++i) {
		for (ll j = 1; j < w; ++j) {
			dp[i][j] = min(dp[i - 1][j] + (v[i][j] != v[i - 1][j]),
				dp[i][j - 1] + (v[i][j] != v[i][j - 1]));
		}
	}
	cout << (dp.back().back() + 1) / 2 << endl;
}


Measured memory_bytes: 3760
#define _USE_MATH_DEFINES
#include <math.h>
#include <time.h>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <iomanip>
#include <iterator>
#include <algorithm>

using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define reprrev(i, a, b) for (int i = (int)(b) - 1; i >= (int)(a); i--)
#define reprev(i, n) reprrev(i, 0, n)

#define PI M_PI
#define INF 1000000000
#define MOD 1000000007;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<bool>> vvb;



int main()
{
	int a, b;
	cin >> a >> b;

	if (a * b % 2 == 0) cout << "Even" << endl;
	else cout << "Odd" << endl;



	return 0;
}


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

#define int long long

using namespace std;

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

	vector<int> left;
	vector<int> right;

	vector<int> lrs;

	for (int i = 0; i < n; i++) {
		int v;
		cin >> v;
		lrs.emplace_back(v);
	}

	for (int i = 0; i < n; i++) {
		int val;
		cin >> val;
		if (lrs[i] == 1)left.emplace_back(val);
		else right.emplace_back(val);
	}

	sort(left.begin(), left.end());
	sort(right.begin(), right.end());

	if (left.size() == n || right.size() == n) {
		cout << 0 << endl;
	}
	else {
		cout << left[0] + right[0] << endl;
	}
}


Measured memory_bytes: 3164
#include<iostream>

using namespace std;

void sort(int *s, int n)
{
	int t;
	for (int i=0;i<n-1;i++)
		for (int j=i+1;j<n;j++)
			if (s[i] > s[j])
			{
				t = s[i]; s[i] = s[j]; s[j] = t;
			}
}

int main()
{
	int n, s[1000];
	int res = 0, d = 0;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> s[i];
		res += s[i];
	}
	sort(s, n);
	while (res % 10 == 0 && res > 0 && d < n)
	{
		if (s[d] % 10 != 0)
		{
			res -= s[d];
			break;
		}
		d++;
	}
	if (res % 10 == 0)
		cout << 0;
	else
		cout << res;
	return 0;
}

Measured memory_bytes: 256
import std.stdio;
import std.c.stdio;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.regex;
import std.typecons;
 
int[ulong] C(ulong[] X) {
    ulong[] Y = X.dup.sort.uniq.array;
    int[ulong] ret;
    foreach (int i, y; Y) {
        ret[y] = i;
    }
    return ret;
}

void main() {
    int N, K; readf("%d %d\n", &N, &K);
    ulong[] X, Y, Z;
    foreach (i; 0 .. N) {
        ulong x, y, z;
        readf("%d %d %d ", &x, &y, &z);
        X ~= x; Y ~= y; Z ~= z;
        readf("%d %d %d\n", &x, &y, &z);
        X ~= x; Y ~= y; Z ~= z;
    }
    auto xM = C(X), yM = C(Y), zM = C(Z);
    auto nx = xM.length,
         ny = yM.length,
         nz = zM.length;
    int[][][] count = new int[][][](nx, ny, nz);
    for (int i = 0; i < 2 * N; i += 2) {
        foreach (x; xM[ X[i] ] .. xM[ X[i + 1] ]) {
            foreach (y; yM[ Y[i] ] .. yM[ Y[i + 1] ]) {
                foreach (z; zM[ Z[i] ] .. zM[ Z[i + 1] ]) {
                    count[x][y][z]++;
                }
            }
        }
    }
    ulong[] _X = X.dup.sort.uniq.array,
            _Y = Y.dup.sort.uniq.array,
            _Z = Z.dup.sort.uniq.array;
    ulong ans = 0;
    foreach (x; 0 .. nx) {
        foreach (y; 0 .. ny) {
            foreach (z; 0 .. nz) {
                if (count[x][y][z] >= K) {
                    ans += (_X[x + 1] - _X[x]) * (_Y[y + 1] - _Y[y]) * (_Z[z + 1] - _Z[z]);
                }
            }
        }
    }
    ans.writeln;
}

Measured memory_bytes: 8056
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <iomanip>
#include <cassert>
#include <complex>
#include <functional>
 
using namespace std;
 
typedef long long ll;

const int N = 1e3 + 7;
const int K = 21;

int f[N];
int rf[N];

const int md = 1e9 + 7;

int mul(int a, int b) {
  return ((ll)a * b) % md;
}

int power(int a, ll b) {
  int res = 1;
  while (b > 0) {
    if (b & 1) res = mul(res, a);
    a = mul(a, a);
    b >>= 1;
  }
  return res;
}

int inv(int a) {
  return power(a, md - 2);
}

int C(int n, int k) {
  return mul(f[n], mul(rf[n - k], rf[k]));
}

int dp[K][N];

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef LOCAL
  freopen("input.txt", "r", stdin);
#endif
  f[0] = 1;
  for (int i = 1; i < N; ++i) {
    f[i] = mul(f[i - 1], i);
  }
  for (int i = 0; i < N; ++i) {
    rf[i] = inv(f[i]);
  }
  int n, k;
  cin >> n >> k;
  vector <int> a(k);
  for (int i = 0; i < k; ++i) {
    cin >> a[i];
  }
  dp[0][0] = 1;
  for (int i = 1; i <= k; ++i) {
    for (int j = 0; j <= a[i - 1]; ++j) {
      for (int k = 0; k + j <= n; ++k) {
        dp[i][k + j] += mul(mul(dp[i - 1][k], C(n - j, a[i - 1] - j)), inv(f[j]));
        dp[i][k + j] %= md;
      }
    }
  }
  cout << mul(dp[k][n], f[n]) << '\n';
}


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

int main() {
  int N, sum;
  cin >> N ;
  
  sum = 0 ;
  
  for(int i = 0 ; i<N; i++){
    int l, r ;
    
    cin >> l >> r ;
    
    sum += r - l + 1 ;
  } 
  
  cout << sum << endl ;
  
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int i,j;
  scanf("%d", &i);
  while (i>=500){
    j+=1000;
    i-=500;
  }
  while (i>=5){
    j+=5;
    i-=5;
  }
  printf("%d\n",j);
  return 0;
}

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

int main(int argc, char const* argv[])
{
	int d[6];
	for(int i = 0; i < 6; i++){
			cin >> d[i];
	}
	string str;
	cin >> str;
	int current = 6;
	int n = 5;
	int s = 2;
	int e = 3;
	int w = 4;
	int ot = 1;
	for(int i = 0; i < str.size(); i++){
			if(str[i] == 'N'){
					int temp = current;
					int temp2 = s;
					current = n;
					s = temp;
					n = ot;
					ot = temp2;
			}else if(str[i] == 'S'){
					int temp = current;
					int temp2 = n;
					current = s;
					n = temp;
					s = ot;
					ot = temp2;
			}else if(str[i] == 'W'){
					int temp = current;
					int temp2 = e;
					current = w;
					e = temp;
					w = ot;
					ot = temp2;
			}else if(str[i] == 'E'){
					int temp = current;
					int temp2 = w;
					current = e;
					w = temp;
					e = ot;
					ot = temp2;
			}
	}
	cout << d[ot-1] << endl;
	return 0;
}



Measured memory_bytes: 3188
#include <iostream>

using namespace std;

int main() {
  int n;
  int R[200000];
  
  cin >> n;
  for (int i=0; i<n; i++) cin >> R[i];
  
  int min = R[0], max = -(1e9+7);
  for (int i=1; i<n; i++) {
    if (max < R[i] - min) max = R[i] - min;
    if (R[i] < min) min = R[i];
  }
  
  cout << max << endl;
  return 0;
}


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

int main(){
	int n,t,a;
	cin >> n >> t >> a;
	vector<int> h(n);
	
	double ans = __INT_MAX__;
	
	rep(i, n){
		cin >> h.at(i);
		ans = min(ans, abs(a-(t-h.at(i)*0.006)));
	}

	rep(i, n){
		if(abs(a-(t-h.at(i)*0.006)) == ans){
			cout << i+1 << endl;
			break;
		}
	}
	
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#define ll long long int
using namespace std;

int main(){
    int n,m,denger_id;
    vector<int> a;
    vector<ll> step;

    cin>>n>>m;
    a.resize(m+10);
    for(int i=0; i<m; i++){
        cin>>a[i];
    }
    step.resize(n+1);
    for(int i=0; i<n+1; i++){
        step[i]=0;
    }

    step[0]=1;
    denger_id=0;
    if(a[denger_id]==1){
        step[1]=0;
        denger_id++;
    }else{
        step[1]=1;
    }
    if(step.size()<2){
        cout<<step[1]<<endl;
        return 0;
    }
    for(int i=2; i<n+1; i++){
        if(i==a[denger_id]){
            if(denger_id<a.size()-1){
                denger_id++;
            }
        }else{
            step[i]=(step[i-1]+step[i-2])%1000000007;
        }
    }
    cout<<step[n]%1000000007<<endl;
    return 0;
}

Measured memory_bytes: 1408
#include"bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp> 
using namespace __gnu_pbds; 
using namespace std;

#define double long double
#define int long long
#define pb push_back 
#define Z(c) (int)(c).size()
#define L(c) c[Z(c)-1]
#define F first
#define S second
#define nl "\n"
#define mii map<int,int> 
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define rep(i,iv,n) for(int (i)=(iv);(i)<(n);++(i))
#define FO fflush(stdout) 
#define D1(x) cerr <<"At line "<<__LINE__<<" "<<#x<<"="<<x<<nl
#define D2(x,y) cerr <<"At line "<<__LINE__<<" "<<#x<<"="<<x<<" "<<#y<<"="<<y<<nl
#define D3(x,y,z) cerr <<"At line "<<__LINE__<<" "<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<nl
#define tr(it,ct) for(auto &(it) : (ct))
#define pi acos(-1)
#define prt(ct) for(auto &(it) : (ct)) cerr<<it<<" "; cerr<<nl
#define prtp(ct) for(auto &(it) : (ct)) cerr<<it.F<<" "<<it.S<<nl; cerr<<nl

typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > pii;
typedef vector< pii > vp;
typedef tree<int, null_type, less<int>, rb_tree_tag, 
             tree_order_statistics_node_update> baap;

void swap(char &a,char &b)
{ auto tm=a; a=b; b=tm; }

void min(int &a,int b)
{ a=(a<b?a:b); }

void max(int &a,int b)
{ a=(a>b?a:b); }

  const int mod=1000000007;
  const int mod2=998244353;
  const int INF=1e16+18;
  const int N=1e5+13;
  const int M=1e2+12;
  
 int val[M][N];

 void fft()              
 { rep(i,0,M) rep(j,1,N) val[i][j]=INF;
   int n,w; cin>>n>>w;
   
   for(int i=0;i<n;++i){
     int x,y; cin>>x>>y;
      
     for(int j=0;j<N;++j) 
      min(val[i+1][j],val[i][j]);

     for(int j=0;j<N-y;++j)
      min(val[i+1][j+y],val[i][j]+x);
                                           
   }
 
   int ans=0;

   for(int j=0;j<N;++j) if(val[n][j]<=w) max(ans,j);

   cout<<ans; 

 }

signed main()
{ 
   ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

   
   int tc=1;                         
 //  cin>>tc;

  rep(i,1,tc+1)
  { // cout<<"Case #"<<i<<": ";
   fft();
   if(i<tc)
   cout<<nl;
  }
  
 return 0; 
}

Measured memory_bytes: 87808
#include <cstdio>

char P[] = "CODEFESTIVAL2016";

char S[20];

int main()
{
	scanf("%s", S);
	int Ans = 0;
	for (int i = 0; i < 16; i ++)
		if (S[i] != P[i])
			Ans ++;
	printf("%d\n", Ans);
	return 0;
}

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

const int MAX = 210000;
const ll MOD = 1000000007;

ll RS(ll N, ll P, ll M) {
  if(P == 0) return 1;
  if(P%2 == 0) {
      ll t = RS(N, P/2, M);
      return t*t % M;
  }
  return N * RS(N, P-1, M);
}

int main() {
  ll n, a, b;
  cin >> n >> a >> b;
  vector<ll> inv(MAX,1), finv(MAX,1);
  for (int i = 2; i < MAX; i++) {
    inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
    finv[i] = finv[i-1] * inv[i] % MOD;
  }
  //a!の逆元はfinv[a] COM(n,a) = A*finv[a] 
  ll A, B;
  ll p = 1;
  for (ll i = 0; i < b; i++) {
    p = p * (n-i) % MOD;
    if (i == a-1) A = p;
  }
  B = p;
  ll Q = A * finv[a] % MOD + B * finv[b] % MOD;
  ll k = RS(2,n,MOD)-1-Q%MOD;
  if (k >= MOD) k -= MOD;
  if (k < 0) k += MOD;
  cout << k << endl;
}

Measured memory_bytes: 6700
#include <iomanip>
#include <string>
#include <iostream>
#include <algorithm>
#include <math.h>
using namespace std;
int main()
{
	long long int a, b, c, d;
	cin >> a >> b >> c;
	a -= c;
	d = a / (b + c);
	cout << d << endl;
	return 0;
}

Measured memory_bytes: 256
//Δ2134
#include<iostream>
#include<cstdio>
#include<fstream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<bitset>
#include<cmath>
#include<cstring>
#include<cstdlib>
using namespace std;
typedef long long LL;
typedef double DB;
const int N = 222222;
int n,m,f[N];
int fnd(int x){
	if(f[x]==x)
		return x;
	return f[x]=fnd(f[x]);
}
priority_queue<pair<int,pair<int,int> > > Q;
int main()
{
	int i,x,y,z;
	LL s=0;
	scanf("%d%d",&n,&m);
	for(i=1;i<=n;i=i+1)
		f[i]=i;
	while(m--){
		scanf("%d%d%d",&x,&y,&z);
		Q.push(make_pair(-z,make_pair(x,y)));
		Q.push(make_pair(-(z+1),make_pair((x+1)%n,y)));
	}
	while(!Q.empty()){
		z=-Q.top().first;
		x=Q.top().second.first;
		y=Q.top().second.second;
		Q.pop();
		if(fnd(x)==fnd(y))
			continue;
		s+=z;
		f[fnd(x)]=fnd(y);
		Q.push(make_pair(-(z+2),make_pair((x+1)%n,(y+1)%n)));
	}
	cout<<s;
	return 0;
}

Measured memory_bytes: 9072
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1e7 + 1;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector < pair<ll, ll > > vp;
typedef vector <string> vs;
typedef vector <char> vc;
typedef list <ll> lst;

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

#define Endl endl

/*--------------------template--------------------*/


int main()
{
	cin >> n;
	vi v(n);
	REP(i, n) cin >> v[i];
	REP(i, n)
	{
		if (i + 1 == v[v[i] - 1]) cnt++;
	}
	cout << cnt / 2 << endl;
}

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

#define ioso ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define kholo freopen("input.txt","r",stdin), freopen("output.txt","w",stdout);
#define laglo cerr << "Ti : " << clock() * 1.0 / CLOCKS_PER_SEC  << endl;
#define endl '\n';
#define ll long long

int main() {
	ioso; //kholo;
	string s; cin >> s;
	ll k = s.length();
	for(int i=0;i<k;i++) {
		cout << "x";
	}
	cout << endl;
	//laglo;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define fort(i,n) for (int i = 1; i <= n; ++i)
#define pi pair<int,int>
#define pl pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define sz size()
#define er erase
#define fr first
#define sc second
#define rc(x) return cout << x, 0
using namespace std;



int32_t main()
{
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    int n,k;
    cin >> n >> k;
    if (k<=(n+1)/2) rc("YES");
    cout << "NO";
}


Measured memory_bytes: 256
/*
 * omg.cpp
 *
 *  Created on: 2019/06/03
 *      Author: J01003
 */
#include<iostream>
#include<vector>
#include<string>
using namespace std;
int main(){
	int N,T[110],M,P,X,sum,a,x;
	cin>>N;
	sum=0;
	for(x=1;x<N+1;x++){
		cin>>a;
		sum+=a;
		T[x]=a;
	}
	cin>>M;
	for(x=0;x<M;x++){
		cin>>P>>X;
		cout<<sum-T[P]+X<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
import math
 
n = int(input())
for i in range(n):
    x1,y1,x2,y2,x3,y3 = map(float,input().split())
    a1,b1,c1 = 2*(x2-x1),2*(y2-y1), (x1**2 - x2 **2 + y1 ** 2 - y2 ** 2)
    a2,b2,c2 = 2*(x3-x1), 2*(y3-y1), (x1**2 - x3 **2 + y1 ** 2 - y3 ** 2)
 
    p1 = (b1*c2 - b2*c1)/(a1*b2 - a2*b1)
    p2 = (c1*a2 - c2*a1)/(a1*b2 - a2*b1)
    r = math.hypot(x1-p1, y1-p2)
    temp = [p1,p2,r]
    ans = map(lambda x:round(x,3),temp)
    print("%03.3f %03.3f %03.3f"%(temp[0],temp[1],temp[2]))

Measured memory_bytes: 7708
/*
	submission # - User: herp_sy
	https://atcoder.jp/contests/
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdbool.h>

#define _CRT_SECURE_NO_WARNINGS
#define TLong long long
#define TBMod 1000000007

int main(int argc, char const *argv[])
{
	int n;
	char w[100][13];

	scanf("%d",&n);
	for (int i = 0; i < n; ++i)	scanf("%s",w[i]);
	
	for (int i = 0; i < n; ++i)
	{
		if(i >= 1){
			for (int j = 0; j < i; ++j)
			{
				if((w[i - 1][strlen(w[i - 1]) - 1] != w[i][0]) || strcmp(w[i],w[j]) == 0){
					puts("No");
					return 0;
				}
			}
		}
	}
	puts("Yes");
	return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#define ll long long
using namespace std;

int main() {
  ll n, a[100010];
  cin >> n;

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

  ll total = 0, count_f = 0, count_l = 0;
  for (ll i = 0; i < n; i++) {
    total += a[i];
    if (i % 2 == 0) { // 正の時
      if (total <= 0) { // 正でない場合
	count_f += 1 - total;
        total = 1;
      }
    } else { // 負のとき
      if (total >= 0) { // 負でない場合
	count_f += 1 + total;
	total = -1;
      }
    }
  }

  total = 0;
  for (ll i = 0; i < n; i++) {
    total += a[i];
    if (i % 2 == 0) { // 負の時
      if (total >= 0) { // 負でない場合
	count_l += 1 + total;
	total = -1;
      }
    } else { // 正のとき
      if (total <= 0) {
	count_l += 1 - total;
	total = 1;
      }
    }
  }

  cout << min(count_f, count_l) << endl;
  return 0;
}

Measured memory_bytes: 1024
#include<iostream>
using namespace std;
string s,t;
int nxt[2<<17][26];
int nownxt[26];
main()
{
	cin>>s>>t;
	int N=s.size();
	s+=s;
	for(int i=0;i<26;i++)nownxt[i]=-1;
	for(int i=s.size();i--;)
	{
		for(int j=0;j<26;j++)nxt[i][j]=nownxt[j];
		nownxt[s[i]-'a']=i;
	}
	int p=-1;
	long ans=0;
	for(int i=0;i<t.size();i++)
	{
		int q=(p<0?nownxt:nxt[p])[t[i]-'a'];
		if(q<0)
		{
			cout<<-1<<endl;
			return 0;
		}
		ans+=q-p;
		p=q%N;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 21376
#include "bits/stdc++.h"
#include <boost/range/irange.hpp>
using namespace std;
using boost::irange;

// 定義
typedef long long         ll;
typedef pair<ll, ll>      P;
#define ALL(x)            (x).begin(),(x).end()
#define REP(i, n)         for(ll i = 0 ; i < (ll)n ; ++i)
#define REPN(i, m, n)     for(ll i = m ; i < (ll)n ; ++i)
#define REVREP(i, n)      for(ll i = n - 1; i >= 0 ; i--)
#define VL                vector<ll>
#define VLL               vector<vector<ll>>
#define VLLL              vector<vector<vector<ll>>>
#define INF               2e9
#define INF_LL            1LL<<60
#define MOD               1000000007

ll Ceil(ll val, ll div)   { return (val + div - 1) / div; }
ll CeilN(ll val, ll div)  { return Ceil(val, div) * div; }
ll FloorN(ll x, ll n)     { return (x - x % n); }
bool IsOdd(ll x)          { return ((x & 1) == 1); }
bool IsEven(ll x)         { return ((x & 1) == 0); }
template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


// 処理
ll N;
ll D;
vector<P> vCoin(3);
map<ll, ll> memo;
ll dfs(ll nowVal)
{
	ll amari1;
	ll amari2;

	if (memo.count(nowVal)) {
		return memo[nowVal];
	}

	ll ansCoin;
	if (D * nowVal < 0) {
		ansCoin = INF_LL;
	} else {
		ansCoin = D * nowVal;
	}
	for (auto one : vCoin) {
		ll div = one.first;
		ll add = one.second;
		amari1 = nowVal % div;
		amari2 = div - nowVal % div;

		ll nextVal = (nowVal - amari1) / div;
		ll nextCoin = amari1 * D;
		if (nextVal != 0) {
			nextCoin += add;
		}
		chmin(ansCoin, dfs(nextVal) + nextCoin);
		if (amari1 != 0) {
			nextVal = (nowVal + amari2) / div;
			nextCoin = amari2 * D + add;
			chmin(ansCoin, dfs(nextVal) + nextCoin);
		}
	}

	memo[nowVal] = ansCoin;
	return ansCoin;
}

void Solve()
{
	ll T;
	cin >> T;

	vCoin[0].first = 2;
	vCoin[1].first = 3;
	vCoin[2].first = 5;
	REP(i, T) {
		cin >> N >> vCoin[0].second >> vCoin[1].second >> vCoin[2].second >> D;
		memo.clear();
		memo[0] = 0;
		memo[1] = D;
		cout << dfs(N) << endl;
	}
}

// メイン
int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Solve();
	return 0;
}


Measured memory_bytes: 4392
#ifdef _MSC_VER
#include "stdc++.h"
#endif
#ifdef __GNUC__
#include<bits/stdc++.h>
#endif
using namespace std;

using ll = long long;

//constant
const double EPS = 1e-10;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, s, e) for (ll i = s; i < e; i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(), (x).rend()

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

// vector
//template<typename T> vector<vector<T>> vv(ll H, ll W, T v) { return vector<vector<T>> vec(H, vector<T>(W, v)); }

// view vector
template<typename T> void view(T e) { cout << e << endl; }
template<typename T> void view(const vector<T>& v) { for (const auto& e : v) { cout << e << " "; } cout << endl; }
template<typename T> void view(const vector<vector<T> >& vv) { for (const auto& v : vv) { view(v); } }

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




// ***************************************

int main(){

    int N, A, B;
    cin >> N >> A >> B;

    cout << min(N*A, B) << endl;

    return 0;
}


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


int main()
{
  int n;
  pair<pair<string,int>, int> sp[110];
  cin >> n;
  for (int i = 0; i < n; i++)
    {
      cin >> sp[i].first.first >> sp[i].first.second;
      sp[i].first.second *= -1;
      sp[i].second = i;
    }
  sort(sp, sp + n);

  for (int i = 0; i < n; i++)  cout << sp[i].second + 1 << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    double ans = 0;
    rep(i, 0, N) {
        int now = i + 1;
        double p = 1;
        while (now < K) {
            now *= 2;
            p /= 2;
        }
        ans += p / N;
    }
    cout << fixed << setprecision(10) << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<deque>
#include<math.h>
using namespace std;
#define ll long long
int main(){
    ll N,M,X;
    cin >> N >> M >> X;
    ll C[N],A[N][M];
    ll i,j,k;
    for(i=0;i<N;i++){
        cin >> C[i];
        for(j=0;j<M;j++){
            cin >> A[i][j];
        }
    }
    ll tmp[M];
    ll tmpc;
    ll ans=-1;
    bool flag=0;
    for(i=0;i<(1<<N);i++){
        tmpc=0;
        for(j=0;j<M;j++){
            tmp[j]=0;
        }
        for(k=0;k<N;k++){
            if((i>>k)&1){
                for(j=0;j<M;j++){
                    tmp[j]+=A[k][j];
                }
                tmpc+=C[k];
            }
        }
        flag=1;
        for(j=0;j<M;j++){
            if(X>tmp[j])flag=0;
        }
        if(flag){
         if(ans==-1){
               ans=tmpc;
         }else{
             ans=min(ans,tmpc);
         }
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <utility>
typedef unsigned long ul;

using namespace std;

int gcd(ul a, ul b);

int main(){
	ul a, b, gcd_num;
	while(cin >> a >> b){
		if(a < b){
			swap(a,b);
		}
		gcd_num = gcd(a, b);
		cout << gcd_num << " " << (a*b)/gcd_num << endl;
	}
}

int gcd(ul a, ul b){
	ul r;
	while((r = a % b) != 0){
		a = b;
		b = r;
	}
	return b;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    int q;
    cin>>q;
    vector<int>a(1e5+1,0),l(q+1),r(q+1);
    rep(i,q)cin>>l[i]>>r[i];
    int cnt=0;
    vector<bool>x(1e5+1,true);
    for(int i=2; i<=1e5; ++i){
        bool ok=false;
        for(int j=2; j*j<=i; ++j){
            if(i%j==0)ok=true;
        }
        if(ok==false)x[i]=false;
    }
    for(int i=1; i<=1e5; ++i){
        if(x[i]==false&&x[(i+1)/2]==false)cnt++;
        a[i]=cnt;
    }
    rep(i,q){
        cout<<a[r[i]]-a[l[i]-1]<<endl;
    }
}

Measured memory_bytes: 1792
#include<stdio.h>

int main()
{
	int a, b, c;
	scanf("%d %d %d", &a, &b, &c);
	if((a==c&&b==a&&b==c) || (a!=c&&b!=a&&b!=c))
	printf("No");
	else
	printf("Yes");
	
	return 0 ;	
}

Measured memory_bytes: 3220
#include <iostream>
#include <algorithm>

using namespace std;
int gcd(long long int m,long long int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	// ユークリッドの方法
	while( m != n )
	{
		if ( m > n ) m = m - n;
		else         n = n - m;
	}
	return m;
}//gcd

int main(){
    long long int n,x;
    cin >> n >> x;
    long long int xi[n + 1];
    
    for(int i = 0;i < n;i++){
        cin >> xi[i];
    }
    xi[n] = x;
    sort(xi, xi+(n+1));
    long long int ans = xi[1] - xi[0];
    for(int i = 0;i < n;i++){
        ans = gcd(ans,xi[i + 1] - xi[i]);
    }

    cout << ans << endl;

    return 0;

}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <iomanip>
using namespace std;
int main()
{
	string s;
	int sum = 0;
	while (cin>>s,s!="0") {
		for (int i=0;i<s.size();i++) {
			sum += s[i]-'0';
		}
		cout << sum << endl;
		sum = 0;
	}

}




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

int main(){
  
  set<int>S; //ここに整数のリストをつくり，S.countで判定する
  
  //入力
  int X, N;
  cin >> X >> N;
  if(N == 0){
    cout << X << endl;
    return 0;
  }
  vector<int>A(110);
  rep(i,N){
    cin >> A[i];
    S.insert(A[i]);
  }
  
  //判定
  
  for(int i =0; i <= 100; i++){
    int a = X -i; //小さい方→大きい方の順で絶対値ごとにAに含まれているか確認する。見つけた時点で出力
    int b = X +i;
    if(!S.count(a)){ //X-iが含まれていなければ
      cout << a << endl;
      return 0;
    }
    else if(!S.count(b)){ //X+iが含まれていなければ
      cout << b << endl;
      return 0;
    }
    //←for文でi++してるのに！！！！！！お前がバグらせてたんじゃねえか！！！！！！！！！！！！！！！！！！！！！！！！
  }
  cout << "error" << endl;
}


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

const ll mod = 1e9 + 7;

ll mpow(ll x, ll n) {
    ll res = 1;
    while (n != 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n = n >> 1;
    }
    return res;
}

int main() {
    int n;
    cin >> n;
    vector<ll> c0(64, 0), c1(64, 0);
    for (int i = 0; i < n; i++) {
        ll a;
        cin >> a;
        for (int i = 0; i < 64; i++) {
            if (a % 2)
                c1[i]++;
            else
                c0[i]++;
            a = a >> 1;
        }
    }
    ll ans = 0;
    for (int i = 0; i < 64; i++) {
        ans = (ans + (mpow(2, i) * (c1[i] * c0[i] % mod)) % mod) % mod;
    }
    cout << ans << endl;
    return 0;
}

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

int main()
{
	int n,i,s=0;
	cin>>n;
	int t[n+1],x[n+1],y[n+1];
	for(i=1;i<=n;i++) cin>>t[i]>>x[i]>>y[i];
	i=0;
	x[0]=0,y[0]=0,t[0]=0;
	while(i<n)
	{
		i++;
		s=(abs(x[i]-x[i-1])+abs(y[i]-y[i-1]));
		if(s>abs((t[i]-t[i-1]))||s%2!=abs((t[i]-t[i-1]))%2) 
		{	
			cout<<"No";
			return 0;
		}
	}
	cout<<"Yes";
	return 0;
}

Measured memory_bytes: 1408
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.StringTokenizer;


//System.out.println();
public class Main implements Runnable { //クラス名はMain

    public static void main(String[] args) {
    	Thread.setDefaultUncaughtExceptionHandler((t,e)->System.exit(1));
        new Thread(null, new Main(), "", 16 * 1024 * 1024).start(); //16MBスタックを確保して実行
    }

    //2≤N≤10^5
    //1≤K≤100
    //1≤hi≤10^4
    public void run() {
    	FastScanner2 sc = new FastScanner2(System.in);

    	//Refer to https://qiita.com/drken/items/dc53c683d6de8aeacf5a
        int N = sc.nextInt();
        int K = sc.nextInt();
        int h[] = new int[N];
        int dp[] = new int[N];


        dp[0]=0;
        for(int i=0; i<N; i++) {
        	h[i] = sc.nextInt();
        }

        int left = -1_000_000;
        int right = 1_000_000;

        for(int i=1; i<N; i++) {
        	if(i == 1) {
        		dp[i] = Math.abs(h[i]-h[i-1]);
        	}else {
        		List<Integer> k = new ArrayList<Integer>();

        		for (int ki=0; ki < K; ki++) {
        			if(i >= ki + 1 ) {
        				k.add( Math.abs(h[i]-h[i-(ki+1)]) + dp[i-(ki+1)]);
        			}
        		}

        		/*
        		System.out.println("dp "+ Arrays.toString(dp));
        		System.out.println("k  "+ k);
        		System.out.println("min " + k.stream().min(Comparator.naturalOrder()));
        		*/

        		dp[i] = k.stream().min(Comparator.naturalOrder()).get();
        	}
        }

        System.out.println(dp[N-1]);

    }
}

//高速なScanner
class FastScanner2 {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScanner2(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

	public String next() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

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

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

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

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}


Measured memory_bytes: 106020