akhauriyash/Code-Regression huggingface dataset:
import java.lang.Math.abs
import java.math.BigDecimal
import java.util.*

fun main(args : Array<String>) {
    val scanner = Scanner(System.`in`)
    println(inOutExec(scanner))
}

fun inOutExec(scanner: Scanner): String {
    val num = scanner.nextInt()
    val tempAve = scanner.nextInt()
    val tempExpected = scanner.nextInt()
    var result = 0
    var temp = 1000000.0f
    repeat(num) {
        val height = scanner.nextInt()
        val xx = tempAve - BigDecimal(height * 6).divide(BigDecimal(1000)).toFloat()
        val yy = abs(tempExpected - xx)
        if (temp > yy) {
            temp = yy
            result = it
        }
    }

    return (result+1).toString()
}

Measured memory_bytes: 38760
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long llu;
const ll inf = 1e9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const ll MAX = 1e7 + 20;
#define fast ios_base:: sync_with_stdio( false ); cin.tie(0); cout.tie(0);
#define eb              emplace_back
#define em              emplace
#define pb              push_back
#define Mp              make_pair
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define rep(i,n)        for(int i=0;i<n;i++)
#define rep1(i,n)       for(int i=1;i<=n;i++)
#define rrep(i,a,n)     for(int i=a;i<=n;i++)
#define per(i,n,a)      for(int i=n;i>=a;i--)
#define pf(n)           printf("%lld",n)
#define pfi(n)          printf("%d",n)
#define sp              printf(" ")
#define ln              "\n"

template< class T > T gcd(T a, T b)
{
    return (b != 0 ? gcd<T>(b, a%b) : a);
}
template< class T > T lcm(T a, T b)
{
    return (a / gcd<T>(a, b) * b);
}
char y[1000],z[1000];
int main()
{
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    fast

    double a,b,c,d,sum=0;
    cin>>a;
    vector<int>v1,v2;
    for(int i=0; i<a; i++)
    {
        cin>>b>>c;
        v1.push_back(b);
        v2.push_back(c);
    }

    for(int i=0; i<a; i++)
    {
        for(int j=0; j<a; j++)
        {
            if(i!=j)
            {
                sum=sum+sqrt(((v1[i]-v1[j])*(v1[i]-v1[j]))+((v2[i]-v2[j])*(v2[i]-v2[j])));
            }
        }
    }
    printf("%.10f\n",sum/(a*1.0)*1.0);
}


Measured memory_bytes: 256
import           Control.Monad
import           Control.Monad.ST
import qualified Data.Array                    as A
import qualified Data.Array.ST                 as ST
import qualified Data.Array.Unboxed            as AU
import qualified Data.ByteString.Char8         as BS
import           Data.Char
import           Data.Int
import qualified Data.IntMap                   as IM
import           Data.List
import qualified Data.Map                      as M
import           Data.Maybe
import           Data.Ord
import qualified Data.Set                      as S
import qualified Data.Vector                   as V
import qualified Data.Vector.Mutable           as VM
import qualified Data.Vector.Unboxed           as VU
import qualified Data.Vector.Unboxed.Mutable   as VUM

readInt :: IO [Int]
readInt = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine

readInts :: Int -> IO [[Int]]
readInts n = replicateM n readInt

readString :: IO [String]
readString = map BS.unpack . BS.words <$> BS.getLine

readStrings :: Int -> IO [[String]]
readStrings n = replicateM n <$> readString

toPair :: [a] -> (a, a)
toPair [x, y] = (x, y)

main = do
  ns <- concat <$> replicateM 5 readInt
  print $ solve ns

solve ns = minimum $ map f nss where nss = permutations ns

f ns =
  last ns
    + (sum $ map
        (\x ->
          let (d, m) = x `divMod` 10 in if m == 0 then d * 10 else (d + 1) * 10
        )
        (init ns)
      )


Measured memory_bytes: 508
#include <iostream>
#include <vector>

using namespace std;
using int_vec = vector<int>;

void heapify(int_vec& v, int i) {
    int max;

    auto h = v.size();
    auto l = i * 2 + 1;
    auto r = i * 2 + 2;
    if (l < h && v[l] > v[i]) {
        max = l;
    } else {
        max = i;
    }
    if (r < h && v[r] > v[max]) {
        max = r;
    }

    if (max != i) {
        swap(v[i], v[max]);
        heapify(v, max);
    }
}

void heapify(int_vec& v) {
    for (int i = v.size() / 2; i >= 0; --i) {
        heapify(v, i);
    }
}

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

    int_vec v;
    for (auto i = 0; i < n; ++i) {
        int x;
        cin >> x;
        v.push_back(x);
    }
    heapify(v);

    for (auto& a: v) {
        cout << " " << a;
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 4856
#include <cstdio>
#include <algorithm>
#define INF 1000000007

using namespace std;

int n, c, k;
int a [1000000];

int main () {
    scanf ("%d%d%d", &n, &c, &k);
    int nowP = 0, nowM = -INF, ans = 0;
    for (int i = 0; i < n; ++i) scanf ("%d", &a[i]);
    sort (a, a + n);
    for (int i = 0; i < n; ++i) {
        if (a[i] > nowM + k || nowP == c) {
            ans += 1;
            nowP = 1;
            nowM = a[i];
        }
        else
            nowP += 1;
    }
    printf ("%d\n", ans);
    return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;

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

        if(a < b){
            System.out.println("a < b");
        }else if (a > b){
            System.out.println("a > b");
        }else
            System.out.println("a == b");
    }
}

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

typedef long long ll;
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define debug(x) cerr << #x << ": " << x << '\n'

int main()
{
    int A, B, K;
    cin >> A >> B >> K;
    if (A > B)
    {
        swap(A, B);
    }
    vector<int> ans;
    rep(i, A + 1)
    {
        if (i != 0 && A % i == 0 && B % i == 0)
        {
            ans.push_back(i);
        }
    }
    reverse(ans.begin(), ans.end());
    cout << ans[K - 1] << endl;
}


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

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

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

int main(){
  
  int W, H;
  cin>>W>>H;

  int x, y, r;
  cin>>x>>y>>r;
  
  if(x - r >= 0 && x + r <= W && y - r >= 0 && y + r <= H) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}



Measured memory_bytes: 3120
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

// container util
#define all(x) (x).begin(), (x).end()

// debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x)                                         \
  cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
       << " " << __FILE__ << endl;

// typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

// constant
const long long MOD = (long long)1e9 + 7;
const int INF = (int)1e18;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

// conversion
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

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

/* べき乗(mのn乗)を計算する関数. O(logn) */
template <typename T>
T modpow(T m, T n, const T& p) {
  if (n == 0) return 1;
  T ret = modpow(m * m % p, n / 2, p);
  if (n % 2) ret *= m;
  return ret % p;
}
/* フェルマーの小定理を使って二項係数を計算. O(r) */
template <typename T>
T binomial(T n, T r, const T& p) {
  if (r > n - r) return binomial(n, n - r, p);
  T ansMul = 1;
  T ansDiv = 1;
  for (T i = 0; i < r; i++) {
    ansMul *= (n - i);
    ansDiv *= (i + 1);
    ansMul %= p;
    ansDiv %= p;
  }
  // ansDivの逆元
  T ans = (ansMul * modpow(ansDiv, p - 2, p)) % p;
  return ans;
}

lint x, y;

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

  cin >> x >> y;
  if (x * 2 == y || y * 2 == x) {
    cout << 1 << endl;
    return 0;
  }

  lint tx = x, ty = y, a = 0, b = 0;
  while (tx != 0 || ty != 0) {
    if (tx == 2 * ty) {
      tx -= 2;
      ty -= 1;
      b++;
    } else if (2 * tx == ty) {
      tx -= 1;
      ty -= 2;
      a++;
    } else if (1 <= tx && 2 <= ty) {
      tx -= 1;
      ty -= 2;
      a++;
    } else if (2 <= tx && 1 <= ty) {
      tx -= 2;
      ty -= 1;
      b++;
    } else {
      cout << 0 << endl;
      return 0;
    }
  }

  lint n = a + b + 1;
  lint k = min(a, b) + 1;
  cout << binomial(n - 1, k - 1, MOD) % MOD << endl;

  return 0;
}

Measured memory_bytes: 256
$arr = [1, 1, 1]
def calc(n)
  $arr = ($arr[2]...n).reduce($arr[0,2]){ |b, i| [b[0] * i + b[1], b[1] * i] }.push(n)
  $arr[0,2]
end
while true
  n, k, m, r = gets.split.map(&:to_i)
  break if n == 0
  if m == 0 then x, y = 1, n
  else
    x, y = calc(n)
    y *= n
    g = x.gcd y
    x /= g; y /= g
  end 
  x, mod = x.divmod y
  print x, '.'
  x = mod * 10
  r.times.reduce(x){ |t, _| t, mod = t.divmod y; print t; mod * 10 }
  puts
end

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

int n,ans;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(cin >> n,n){
        ans=0;
        for (int i=n+1;i<=2*n;++i){
            int prime=1;
            for (int j=2;j*j<=i;++j){
                if (i%j==0){prime=0; break;}
            }
            ans+=prime;
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3216
import kotlin.math.*

fun str() = readLine()!!
fun int() = str().toInt()
fun long() = str().toLong()

fun read(d:String = " ") = str().split(d)
fun <T> list(d:String = " ",f:String.()->T) = read(d).map {f(it)}
fun list() = list {toInt()}

fun <T> MutableList<T>.removeLast() = this.removeAt(this.lastIndex)

const val mod = 1000000007L

fun main() {
	abc000X()
}

fun abc000X() {
	println(int() xor 1)
}


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

int main() {
  long h,w,ans=0,b=0;
  cin >> h >> w;
  vector<string> a(h);
  vector<vector<bool>> is_black(h,vector<bool>(w,false));
  queue<vector<long>> q;
  for(long i=0;i<h;i++) cin >> a[i];

  for(long i=0;i<h;i++) {
    for(long j=0;j<w;j++) {
      if(a[i][j]=='#') {
        b++;
        is_black[i][j]=true;
        q.push({i,j});
      }
    }
  }
  while(b<h*w) {
    ans++;
    long x=q.size();
    for(long c=0;c<x;c++) {
      long i=q.front()[0],j=q.front()[1];
      if(i!=0) {
        if(!(is_black[i-1][j])) {
          b++;
          is_black[i-1][j]=true;
          q.push({i-1,j});
        }
      }
      if(i+1!=h) {
        if(!(is_black[i+1][j])) {
          b++;
          is_black[i+1][j]=true;
          q.push({i+1,j});
        }
      }
      if(j!=0) {
        if(!(is_black[i][j-1])) {
          b++;
          is_black[i][j-1]=true;
          q.push({i,j-1});
        }
      }
      if(j+1!=w) {
        if(!(is_black[i][j+1])) {
          b++;
          is_black[i][j+1]=true;
          q.push({i,j+1});
        }
      }
      q.pop();
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 56884
#include<iostream>
#include<iomanip>
#include<stack>
#include<queue>
#include<numeric>
#include<algorithm>
#include<string>
#include<map>
#include<bitset>
#include<set>
#include<cmath>
#define int long long
#define inf 8938103643641919514ll
#define oku 1000000007ll
using namespace std;
int a,b,c,d,e,f,g,n,m;
int dx[]={0,-1,0,1,0};
int i,j,k;
int p[100001],q[100000];
signed main(){
	cin>>n;
	for(i=0;i<n;i++){
		cin>>p[i];
		a+=p[i];
	}
	b=n*(n+1);
	b/=2;
	if(a%b!=0){
		cout<<"NO"<<endl;
		return 0;
	}
	a/=b;
	p[n]=p[0];
	for(i=1;i<=n;i++){
		int u=(p[i]-p[i-1])%n;
		if(u<0)
			u+=n;
		if(a%n!=u){
			cout<<"NO"<<endl;
			return 0;
		}
		if(p[i]-p[i-1]<a){
			int v=(p[i-1]+a)-p[i];
			if(v%n!=0){
				cout<<"NO"<<endl;
				return 0;
			}
			c+=v/n;
		}
	}
	if(c!=a){
		cout<<"NO"<<endl;
		return 0;
	}
	cout<<"YES"<<endl;
}

Measured memory_bytes: 1024
n, m = gets.split.map(&:to_i)
arr=[]
min = 1000000000
n.times{arr.push(gets.to_i)}
arr.sort!
(n-m+1).times do |i|
    tmp = arr[i+m-1]-arr[i]
    min = tmp if tmp < min 
end

p min

Measured memory_bytes: 4016
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int i,j,k,n,m,ans,a[110001],s[110001];
int main(){
	while (scanf("%d",&n)!=EOF){
		memset(a,0,sizeof(a));
		for (i=m=1;i<=n;i++) scanf("%d",&k),a[k]++,m=max(m,k);
		for (i=1,s[0]=0;i<=m;i++) s[i]=s[i-1]+a[i];
		for (i=1,ans=n,j=m;i<=j;){
			while (a[i]<=1&&i<=j) i++;
			while (a[j]<=1&&i<=j) j--;
			if (i>j) break;
			if (i!=j) k=min(a[i],a[j])-1,a[i]-=k,a[j]-=k,ans-=2*k;else{
				if (a[i]&1) ans-=(a[i]-1);else ans-=a[i];
				break;
			}
		}
		printf("%d\n",ans);
	}
	return 0;
}

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

typedef long long ll;
typedef vector <ll> v_ll;
typedef vector <vector <ll> > vv_ll;
typedef vector < pair <ll,ll> > vp_ll;
typedef pair <ll,ll> p_ll;

bool TEST=false;
ll MOD = 1000000007;

void show(){if (TEST){cout << endl;}}
void show(string x){if (TEST){cout << x;}}
void show(string x,bool enter){
  if (TEST){if (enter) cout << "<#> " << x << endl;else cout << x;}
}
void show(ll x){if (TEST){cout << x;}}
void show(ll x,bool enter){
  if (TEST){if (enter) cout << "<#> " << x << endl;else cout << x;}
}
void show(p_ll p){
  if (TEST){cout << "{ ";show(p.first);cout << " ";show(p.second);cout << " }";}
}
void show(v_ll v){
  if (TEST){
    cout << "<begin> ";
    for (ll i=0;i<v.size();i++){show(v[i]); cout << " ";}cout <<"<end>"<< endl;
}}
void show(vv_ll v){
  if (TEST){
    cout << "//////////" << endl;
    for (ll i=0;i<v.size();i++){
      show(v[i]); cout << endl;
}}}
void show(vp_ll v){
  if (TEST){
    cout << "//////////" << endl;
    for (ll i=0;i<v.size();i++){
      show(v[i]); cout << endl;
}}}

ll mod(ll x){
  ll n=MOD;
  ll ret=x%n;
  if (ret<0)ret+=n;
  return ret;
}
void mod_self(ll &x){
  x=mod(x);
}
ll mod_inv(ll x){
  ll n=MOD;
  ll y = x,z = n-2, ret=1;
  y=mod(y);
  while (z>0){
    if(z%2==1) ret=mod(ret*y);
    y=mod(y*y);
    z/=2;
  }
  return ret;
}
ll mod_pow(ll x,ll a){
  ll y = x,z = a,ret=1;
  y=mod(y);
  if (z<0)z=-z;
  while (z>0){
    if(z%2==1) ret=mod(ret*y);
    y=mod(y*y);
    z/=2;
  }
  if (a<0) ret=mod_inv(ret);
  return ret;
}
v_ll mod_nck(ll n){
  v_ll nck(n+1,0);
  nck[0]=1;
  for (ll i=1;i<=n;i++){
    nck[i]=mod(nck[i-1]*(n+1-i));
    nck[i]=mod(nck[i]*mod_inv(i));
  }
  return nck;
}
v_ll mod_factorial(ll n){
  v_ll fct(n+1,0);
  fct[0]=1;
  for (ll i=1;i<=n;i++){
    fct[i]=mod(fct[i-1]*i);
  }
  return fct;
}

ll N,K;
int main(){
  cin >> N >> K;
  if (K==1) {cout << 0 << endl; return 0;}
  else {cout << N-K << endl; return 0;}
}


Measured memory_bytes: 384
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.OutputStream;
import java.util.StringTokenizer;
import java.io.Writer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author palayutm
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        TaskF solver = new TaskF();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskF {
        public void solve(int testNumber, InputReader in, OutputWriter out) {
            int n = in.nextInt();
            long ans = 0;
            for (int i = 0; i < n; i++) {
                long A = in.nextInt(), B = in.nextInt();
                if (A >= B) {
                    while (true) {
                        if (A < B) {
                            break;
                        }
                        long x = A / B + 1;
                        long k = (A - A / B * B) / x;
                        A -= k * x;
                        if (A % B == 0) {
                            ans ^= (A / B);
                            break;
                        }
                        A -= x;
                    }
                }
            }
            if (ans != 0) {
                out.println("Takahashi");
            } else {
                out.println("Aoki");
            }

        }

    }

    static class OutputWriter extends PrintWriter {
        public OutputWriter(OutputStream out) {
            super(out);
        }

        public OutputWriter(Writer out) {
            super(out);
        }

        public void close() {
            super.close();
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

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

    }
}



Measured memory_bytes: 23636
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

	public static void solve() {
		int n =s.nextInt();
		String str = s.next();
		for (int i=0;i<str.length();i++)	{
			int val = str.charAt(i)-'A';
			val= (val+n)%26;
			out.print((char)(val+'A'));
		}
	}

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

	public static FastReader s;
	public static PrintWriter out;

	public static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

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

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

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

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

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (Exception e) {
				e.printStackTrace();
			}
			return str;
		}
	}

	
}


Measured memory_bytes: 22740
<?php
// Your code here!
    $N = fgets(STDIN);
    //$result = ["AC", "WA", "TLE", "RE"];
    $AC = 0;
    $WA = 0;
    $TLE = 0;
    $RE = 0;

    for($i = 0; $i < $N; $i++){
        $S = trim(fgets(STDIN));
        switch ($S) {
            case "AC":
                $AC++;
                break;
            case "WA":
                $WA++;
                break;
            case "TLE":
                $TLE++;
                break;
            case "RE":
                $RE++;
                break;
        }
    }
    echo "AC x ".$AC."\n";
    echo "WA x ".$WA."\n";
    echo "TLE x ".$TLE."\n";
    echo "RE x ".$RE."\n";
?>

Measured memory_bytes: 16136
#define TEMPLATE_USED
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) for(ll i=0;i<(n);++i)
#define _rep3(i,a,b) for(ll i=(ll)(a);i<(ll)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2)(__VA_ARGS__)
#define _repe2(i,n) for(ll i=0;i<=(ll)(n);++i)
#define _repe3(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);++i)
#define repe(...) _overload3(__VA_ARGS__,_repe3,_repe2)(__VA_ARGS__)
#define _rrep2(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define _rrep3(i,a,b) for(ll i=(ll)(b)-1;i>=(ll)(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2)(__VA_ARGS__)
#define _rrepe2(i,n) for(ll i=(ll)(n);i>=0;i--)
#define _rrepe3(i,a,b) for(ll i=(ll)(b);i>=(ll)(a);i--)
#define rrepe(...) _overload3(__VA_ARGS__,_rrepe3,_rrepe2)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
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;}

void solve();

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

const ll INF1=(1LL<<31)-1;
struct Node{
    ll x;
    static Node e;
    Node(ll x):x(x){}
    Node operator*(const Node &node)const{
        return Node(min(x,node.x));
    }
};
Node Node::e=Node(INF1);

template<typename T>
struct SegmentTree{
    vector<T> data;
    ll sz=1;
 
    SegmentTree(ll n){
        while(sz<n)sz<<=1;
        data.resize(2*sz,T::e);
    }
 
    void set(ll k,T node){
        data[k+sz]=node;
    }
 
    void build(){
        rrep(i,1,sz)data[i]=data[2*i]*data[2*i+1];
    }
 
    void update(ll k,T node){
        k+=sz;
        data[k]=node;
        while(k>1){
            k>>=1;
            data[k]=data[2*k]*data[2*k+1];
        }
    }
 
    T query(ll a,ll b,ll l=0,ll r=-1,ll k=1){
        if(r==-1)r=sz;
        if(r<=a||b<=l)return T::e;
        if(a<=l&&r<=b)return data[k];
        return query(a,b,l,(l+r)/2,2*k)*query(a,b,(l+r)/2,r,2*k+1);
    }
 
    T operator[](const ll &k)const{
        return data[k+sz];
    }
};

void solve(){
    ll n,q;cin>>n>>q;

    SegmentTree<Node> seg(n);

    while(q--){
        ll op,x,y;cin>>op>>x>>y;
        if(!op)seg.update(x,Node(y));
        else cout<<seg.query(x,y+1).x<<endl;;
    }
}



Measured memory_bytes: 4948
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
using namespace std;

int main(){
	int n1,n2;
	cin>>n1>>n2;
	if(n1==n2){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	
	return 0;
}

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

int main() {
    int n; cin >> n;
    vector<int> p(n);
    for (auto &pi: p) cin >> pi;
    vector<int> q(n);
    for (auto &qi: q) cin >> qi;
    vector<int> a(n);
    iota(a.begin(), a.end(), 1);
    int ord_p = -1, ord_q = -1, cnt = 0;
    do {
        if (p == a) ord_p = cnt;
        if (q == a) ord_q = cnt;
        cnt++;
    } while (next_permutation(begin(a), end(a)));
    cout << abs(ord_p - ord_q) << endl;
    return 0;
}


Measured memory_bytes: 256
/*
LANG:C++
PROB:

*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#include <iostream>
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)


using namespace __gnu_pbds;
using namespace std;


typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update>
    ordered_set;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;
typedef unsigned long long ui64;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }
const int mod=1000000007;
  i64 poww(i64 a, i64 b)
  {
    a%=mod;
    i64 res=1;
    while(b)
      {
if(b&1)res=res*a%mod;

      a=a*a%mod;
      b/=2;

      }
      return res;
  }
  i64 inv(i64 a)
  {
    return poww(a,mod-2);
  }


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

    // ifstream fin(".in");
    // ofstream fout(".in");


string s;
cin>>s;
int n=s.size();
for(int i=0;i<n;i++)
{
  if(s[i]=='?')
  {
    s[i]='D';
  }

}
cout<<s;

    return 0;
  }


Measured memory_bytes: 3772
#include <iostream>

using namespace std;

int main() {
  long h;
  int n;
  cin >> h >> n;
  long sum = 0;
  for (int i = 0; i < n; i++) {
    long d;
    cin >> d;
    sum += d;
  }
  cout << (h > sum ? "No" : "Yes") << endl;
}


Measured memory_bytes: 504
#include <bits/stdc++.h> 
using namespace std;
using ll = long long;
template<typename T> using v2 = vector<vector<T>>;
template<typename T> inline v2<T> fill(int r, int c, const T& t){ return v2<T>(r, vector<T>(c, t)); }
#define F first
#define S second

void solve(){
    int x;
    cin >> x;
    cout << !x << '\n';
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define int long long
#define fill(x, v) memset(x, v, sizeof(x))
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#define ios std::ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
template <typename Arg1>
void __f(const char *name, Arg1 &&arg1)
{
    cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args)
{
    const char *comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | ";
    __f(comma + 1, args...);
}
/*
std::cout << std::setprecision(9) << f << '\n';//3.141590000;
map<char,int>::reverse_iterator rit;
for(rit = mp.rbegin(); rit!=mp.rend(); rit++)
*/
double dp[3000][3000];
int32_t main()
{
    ios;
    int n;
    cin >> n;
    double head[n];
    dp[0][0] = 1;
    for (int i = 0; i < n; i++)
    {
        cin >> head[i];
        dp[i + 1][0] = dp[i][0] * (1 - head[i]);
    }
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= n; j++)
        {
            dp[i][j] = dp[i - 1][j] * (1 - head[i - 1]) + dp[i - 1][j - 1] * head[i - 1];
        }
    double ans;
    for (int i = 1; i <= n; i++)
        if (i > n - i)
            ans += dp[n][i];
    std::cout << std::setprecision(10) << ans << '\n';
}


Measured memory_bytes: 70528
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
typedef long long ll;

bool isOK(int A, int B) {
  if(A > 8) return false;
  if(B > 8) return false;
  return true;
}

int main(void) {
  int A, B;
  cin >> A >> B;
  puts(isOK(A, B) ? "Yay!" : ":(");
  
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <cstdarg>
#include <sys/time.h>
#include <fstream>
//#include "cout.h"

using namespace std;

#define SZ(x) ((int)x.size())
#define MSET(x,a) memset(x, a, (int)sizeof(x))
#define PB push_back
#define VI vector < int >
#define PII pair < int, int >
#define LL long long
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define FIT(it,v) for (__typeof((v).begin()) it = (v).begin(); it != (v).end(); it++)
#define OUT(A) cout << #A << " = "<< (A) << endl
#define OUT2(A, B) cout << "(" << #A << ", " << #B << ") = (" << (A) << ", "<< (B) << ")" << endl
template<class T> void chmin(T &t, T f) { if (t > f) t = f; } 
template<class T> void chmax(T &t, T f) { if (t < f) t = f; } 

#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())


	const double INF = 1e20;

	const int MAX_V = 1010;
	double cost[MAX_V][MAX_V]; // cost[u][v] は辺 e = (u, v) のコストが最初に入っている。存在しない場合はINF。
	double d[MAX_V]; // d[v]は最終的に「スタートの頂点sから頂点vの最短距離」が入る。
	bool used[MAX_V];
	int V; // Vに値を入れることも忘れずに！

	void dijk(int s){
		fill(used, used+V, false);
		fill(d, d+V, INF);
		d[s] = 0;
		while(1){
			int v = -1;
			REP(i, V) if(!used[i] && (v == -1 || d[i] < d[v])) v = i;
			if(v == -1) break;
			used[v] = true;
			REP(i, V) if(d[i] > d[v] + cost[v][i]){
                d[i] = d[v] + cost[v][i];
            }
		}
	}

	double dst(double x1, double y1, double x2, double y2){
		return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
	}

double x[1010], y[1010], r[1010];

void init() {
}

void input() {
	double xs, ys, xt, yt;
	cin >> xs >> ys >> xt >> yt;
	int n;
	cin >> n;
	x[0] = xs; y[0] = ys; r[0] = 0;
	x[n+1] = xt; y[n+1] = yt; r[n+1] = 0;
	REP(i, n) cin >> x[i+1] >> y[i+1] >> r[i+1];
	V = n+2;
}

void solve() {
	REP(i, V) REP(j, V) cost[i][j] = max(0.0, dst(x[i], y[i], x[j], y[j])-r[i]-r[j]);
	dijk(0);
	printf("%.10lf\n", d[V-1]);
}

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








Measured memory_bytes: 8192
S = (input())
l = len(S)
for i,c in enumerate(S[2:],2):
    if c == "C":
        break
tmp = S[1:i]+S[i+1:]
if (i != l-1) and (S[0]=="A") and(tmp.lower()==tmp):
    print("AC")
else:
    print("WA")

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		boolean ans = true;
		for(int i = 0; i < s.length(); i++) {
			if(i % 2 == 0 && s.charAt(i) == 'L') {
				ans = false;
			} else if(i % 2 == 1 && s.charAt(i) == 'R') {
				ans = false;
			}
		}
		if(ans) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}

}


Measured memory_bytes: 22612
#include <stdio.h>

int main(){
	long long int n;
	scanf("%lld", &n);
	long long int total = 0;
	
	if(n >= 1){
		total = total + 1;
	}
	if(n >= 2){
		total = total + 2;
	}
	if(n > 3 ){
		for(int i = 3; i <= n; i++){
		if(i % 3 == 0 || i % 5 == 0){
			continue;
		}
		total = total + i;
		}
	}
	printf("%lld", total);
	return 0;
}

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

#define _sel(_1, _2, x, ...) x
#define repn(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, ...) _sel(__VA_ARGS__, reps, repn)(i, __VA_ARGS__)
#define reppn(i, n) for (ll i = 1; i <= (n); i++)
#define repps(i, a, b) for (ll i = (a); i <= (b); i++)
#define repp(i, ...) _sel(__VA_ARGS__, repps, reppn)(i, __VA_ARGS__)
#define rrepn(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, a, b) for (ll i = (b) - 1; i >= (a); i--)
#define rrep(i, ...) _sel(__VA_ARGS__, rreps, rrepn)(i, __VA_ARGS__)
#define rreppn(i, n) for (ll i = (n); i >= 1; i--)
#define rrepps(i, a, b) for (ll i = (b); i >= (a); i--)
#define rrepp(i, ...) _sel(__VA_ARGS__, rrepps, rreppn)(i, __VA_ARGS__)

#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define rng(v) (v).begin(), (v).end()
#define rrng(v) (v).rbegin(), (v).rend()
#define _shv(v) for (auto _t1 : v) cerr << _t1 << " "; cerr << endl;
#define dg(x) cerr << #x << ": " << (x) << endl;
#define dgv(v) cerr << #v << ": "; _shv(v);
#define dgm(m) cerr << #m << ":" << endl; for (auto _t2 : m) { _shv(_t2); }

using namespace std;
using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using vvs = vector<vector<string>>;

const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
const int DX[4] = {1, 0, -1, 0};
const int DY[4] = {0, 1, 0, -1};

template<typename T> inline void pt(T x) { cout << x << endl; }
template<typename T> inline void inv(T& v) { for (auto& t : v) cin >> t; }
template<typename T> inline int siz(T& x) { return x.size(); }
template<typename T> inline ll pow2(T n) { return 1ll << n; }
template<typename T, typename U> inline int bit(T x, U n) { return x >> n & 1; }
template<typename T, typename U>
inline bool umax(T& m, U x) { if (m < x) { m = x; return true; } return false; }
template<typename T, typename U>
inline bool umin(T& m, U x) { if (m > x) { m = x; return true; } return false; }


int calc(vvi& dp, vi& w, int l, int r) {
    if (dp[l][r] != -1) return dp[l][r];
    if (l == r) return dp[l][r] = 0;
    if (r - l == 1)  {
        if (abs(w[l] - w[r]) <= 1)
            return dp[l][r] = 2;
        else
            return dp[l][r] = 0;
    }
    int ret = 0;
    rep(i, l, r) {
        umax(ret, calc(dp, w, l, i) + calc(dp, w, i + 1, r));
    }
    if (calc(dp, w, l + 1, r - 1) == r - l - 1 && abs(w[l] - w[r]) <= 1)
        umax(ret, calc(dp, w, l + 1, r - 1) + 2);
    return dp[l][r] = ret;
}

int main() {
    while (true) {
        int n; cin >> n;
        if (n == 0) break;
        vi w(n); inv(w);
        vvi dp(n, vi(n, -1));
        calc(dp, w, 0, n - 1);
        pt(dp[0][n - 1]);
    }

    return 0;
}



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

int main(){
#ifdef _DEBUG
	freopen("in" , "r", stdin );
	freopen("out", "w", stdout);
#endif
	ios::sync_with_stdio(0); cin.tie(0);
	int n, k, x, y; cin >> n >> k >> x >> y;
	if(n <= k) cout << n * x << '\n';
	else cout << k * x + (n - k) * y << '\n';
}


Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;

    vector<pair<pair<string,int>,int>>data(n);
    for (int i=0;i<n;i++) {
        string s;
        int p;
        cin>>s >>p;
        data[i]=make_pair(make_pair(s,-p),i+1);
    }

    sort(data.begin(),data.end());

    for(int i=0;i<n;i++){
        cout<<data[i].second<<endl;
    }
}



Measured memory_bytes: 256
package main

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

func countDiff(s, t string) int {
	diff := 0
	for i := 0; i < len(s); i++ {
		if s[i] != t[len(s)-1-i] {
			diff++
		}
	}
	return diff
}

func main() {
	scanner := makeWordScanner()
	s := eGetLine(scanner)
	count := 0
	for i := 0; i < len(s)/2; i++ {
		if s[i] != s[len(s)-1-i] {
			count++
		}
	}
	fmt.Println(count)
}

////////////////////////////////////////////////////////////////////////////////
// ライブラリ
////////////////////////////////////////////////////////////////////////////////
func makeScanner(maxByte int) *bufio.Scanner {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]uint8, 0, 8192), maxByte)
	return scanner
}
func makeCharScanner() *bufio.Scanner {
	scanner := makeScanner(8192)
	scanner.Split(bufio.ScanRunes)
	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: 640
string = []
kind = 0

alphabet = "abcdefghijklmno"

def dfs(n):
    global string, kind
    if n == 0:
        print("".join(string))
        return
    for i in range(kind):
        string.append(alphabet[i])
        dfs(n-1)
        string.pop()
    string.append(alphabet[kind])
    kind += 1
    dfs(n-1)
    kind -= 1
    string.pop()

dfs(int(input()))

Measured memory_bytes: 4340
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using Pair = pair<int64_t, int64_t>;
constexpr int64_t kInf = INT64_MAX / 2L;

// std::cout << std::setprecision(20) << 1.1 << endl;

char buff[100];

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

  int64_t N;
  string S;
  cin >> N >> S;
  int64_t result = 0;
  for (int64_t i = 0; i < 1000; ++i) {
    snprintf(buff, sizeof(buff), "%03ld", i);
    string temp(buff);
    int64_t j = 0;
    bool is_okay = true;
    for (int64_t t = 0; t < 3; ++t) {
      while (j < N && temp[t] != S[j]) {
        ++j;
      }
      if (j >= N) {
        is_okay = false;
        break;
      }
      ++j;
    }
    if (is_okay) {
      ++result;
    }
  }
  cout << result << endl;
  return 0;
}


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

using namespace std;

int main(){
	int array[3];
	for(int i = 0; i < 3; i++) scanf("%d",&array[i]);
	for(int i = 2; i > 0; i--){
		for(int j = 0; j < i; j++){
			if(array[j] > array[j+1])swap(array[j],array[j+1]);
		}
	}
	printf("%d %d %d\n",array[0],array[1],array[2]);
}

Measured memory_bytes: 1028
#include<stdio.h>
#include<stdlib.h>
int main(void) {
	int sum1 = 0, sum2 = 0, i, j, k, n, w[200], sa = 214748364;;
	scanf("%d", &n);
	for (i = 0; i < n; i++)
		scanf("%d", &w[i]);
	for (i = 0; i < n; i++) {
		for (j = 0; j <= i; j++)
			sum1 += w[j];
		for (k = j; k < n; k++)
			sum2 += w[k];
		if (sa > abs(sum1 - sum2)) {
			sa = abs(sum1 - sum2);
		}
		sum1 = 0;
		sum2 = 0;
	}
	printf("%d", sa);
	return 0;
}

Measured memory_bytes: 128
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int max = 0;
    int ans = 0;
    for (int i = 0; i < 5; i++) {
      int t = sc.nextInt();
      int ceil = (int)Math.ceil(t/10.0)*10;
      ans += ceil;
      max = Math.max(max, ceil-t);
    }
    System.out.println(ans-max);
  }
}

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

char str[3][101];
int cur[3] = {0, 0, 0};
int len[3];

int main(int argc, char *argv[])
{
    char who;

    scanf("%s", str[0]);
    scanf("%s", str[1]);
    scanf("%s", str[2]);
    len[0] = strlen(str[0]);
    len[1] = strlen(str[1]);
    len[2] = strlen(str[2]);
    who = 0;
    while (cur[who] < len[who]) {
        who = str[who][cur[who]++] - 0x61;
    }

    printf("%c\n", who + 0x41);
    return 0;
}


Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Runtime;
using System.Numerics;
using System.Linq;

namespace ABC153
{
    class B
    {
        static void Main(string[] args)
        {

            int[] hn = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
            string ans = "";
            if (hn[0] > a.Sum()) { ans = "No"; }
            else { ans = "Yes"; }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 19680
def min_toll(x, n, tolls):
    toll_to_0 = toll_to_n = 0
    for i in range(1, x):
        toll_to_0 += i in tolls
    for i in range(x + 1, n + 1):
        toll_to_n += i in tolls
    return min(toll_to_0, toll_to_n)


if __name__ == '__main__':
    n, _, x = map(int, input().split())
    tolls = list(map(int, input().split()))
    print(min_toll(x, n, tolls))

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <tuple>
#include <bitset>
#include <random>
#define REP(i,n) for(int i=0;i<n;i++)
#define INF 100000000000007
using namespace std;
using pii=pair<int,int>;
using LL=int64_t;





int main(){
    int n;
    cin>>n;
    vector<int> c(4,0);
    REP(i,n){
        string s;
        cin>>s;
        if(s=="AC"){
            c.at(0)++;
        }else if(s=="WA"){
            c.at(1)++;
        }else if(s=="TLE"){
            c.at(2)++;
        }else{
            c.at(3)++;
        }

    }
    cout<<"AC x "<<c.at(0)<<endl;
    cout<<"WA x "<<c.at(1)<<endl;
    cout<<"TLE x "<<c.at(2)<<endl;
    cout<<"RE x "<<c.at(3)<<endl;

    
    return 0;
}

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

bool dp[2][100011] = {};
bool vis[2][100011] = {};
int a[100011] = {};
int N;

bool f(int k, char p) {
	// printf("%d %d\n", k, p);
	if(k == 0) return false;
	if(vis[p][k]) return dp[p][k];
	vis[p][k] = true;
	bool ret = true;
	for(int i=0;i<N;i++) {
		if(k>=a[i]) ret &= f(k-a[i], p^1);
	}
	dp[p][k] = !ret;
	return dp[p][k];
}

int main() {
	int K;
	cin >> N >> K;
	for(int i=0;i<N;++i) {
		cin >> a[i];
	}
	dp[0][0] = dp[1][0] = false;
	for(int i=1;i<=K;i++) {
		for(int p=0;p<2;p++) {
			bool chk = true;
			for(int j=0;j<N;j++) {
				if(i>=a[j]) {
					chk &= dp[p^1][i-a[j]];
				}
			}
			dp[p][i] = !chk;
		}
	}

	if(dp[0][K]) {
		cout << "First";
	} else {
		cout << "Second";
	}
}

Measured memory_bytes: 384
#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define PB(a) push_back(a)
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[a]; if (a != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

const int dx[8] = { 1,1,0,-1,-1,-1,0,1 };
const int dy[8] = { 0,1,1,1,0,-1,-1,-1 };


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
///(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)///
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n, a, b;
	cin >> n >> a >> b;
	if (n == 1 && a != b || a > b)cout << 0 << endl;
	else cout << (n - 2)*(b - a) + 1 << endl;
	return 0;
}


Measured memory_bytes: 256
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <math.h>

#define P 1000000007

int comp(const void *a, const void *b){return *(int*)a-*(int*)b;}

int main(void){
	int n, m;
	scanf("%d%d", &n, &m);
	long ans;
	if(n==1){
		if(m==1){
			ans=1;
		}else{
			ans=m-2;
		}
	}else{
		if(m==1){
			ans=n-2;
		}else{
			ans=((long)n-2)*(m-2);
		}
	}
	printf("%ld\n", ans);
}


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

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

    if(a > b){
        if(c < a && c > b){
            cout << "Yes" << endl;
        }
        else{
            cout << "No" << endl;
        }
    }
    if(a < b){
        if(c > a && c < b){
            cout << "Yes" << endl;
        }
        else{
            cout << "No" << endl;
        }
    }


}

Measured memory_bytes: 256
#include <stdio.h>

//問題文より、入力されるデータの最大個数
#define MAXCOUNT 100

//ソートの結果と交換回数を出力する関数
void print(int array[], int size, int count);

int main(void)
{
	//i、jは繰り返し変数、countはループの回数を、tempは交換するデータを格納、min_indexは交換するデータの添字
	int i, j, count, temp, min_index;
	//sizeは配列の要素数を、arrayは入力される数値を格納
	int size;
	int array[MAXCOUNT];

	//データの個数を入力
	scanf("%d", &size);

	//データを入力
	for(i = 0; i < size; i++){
		scanf("%d", &array[i]);
	}

	count = 0;
	//配列の終端の一つ前まで走査
	for(i = 0; i < (size - 1); i++){
		min_index = i;
		//比較元の一つ後ろから比較開始
		for(j = (i + 1); j < size; j++){
			//小さい値から確定する
			if(array[j] < array[min_index]){
				min_index = j;
			}
		}
		//昇順に並び替える
		if(min_index != i){
			temp = array[min_index];
			array[min_index] = array[i];
			array[i] = temp;

			//交換回数を加算
			count++;
		}
	}

	//結果を出力
	print(array, size, count);

	return 0;
}

void print(int array[], int size, int count)
{
	int i;

	//配列の中身を1行で表示し、最後に改行する
	for(i = 0; i < (size - 1); i++){
		printf("%d ", array[i]);
	}

	printf("%d\n", array[i]);
	//交換回数を表示
	printf("%d\n", count);
}


Measured memory_bytes: 2048
#154D
def main():
    import sys
    N, K =map(int, sys.stdin.readline().split())
    P = list(map(int, sys.stdin.readline().split()))
    #期待値の計算
    #print(P)
    P = list(map(lambda x:((x*(x+1)//2)/x), P))
    #print(P)
    #累積和
    for i in range(N-1):
        P[i+1] +=P[i]
    #print(P)
    ans = P[K-1]
    for i in range(N-K):
        ans = max(ans, P[K+i]-P[i])
    print(ans)
    
if __name__=='__main__':
    main()


Measured memory_bytes: 25632
/**
 * File    : D.cpp
 * Author  : Kazune Takahashi
 * Created : 2018-9-1 21:31:09
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>   // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set>
#include <functional>
#include <random> // auto rd = bind(uniform_int_distribution<int>(0, 9), mt19937(19920725));
#include <chrono> // std::chrono::system_clock::time_point start_time, end_time;
// start = std::chrono::system_clock::now();
// double elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end_time-start_time).count();
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.

typedef long long ll;

// const int dx[4] = {1, 0, -1, 0};
// const int dy[4] = {0, 1, 0, -1};

// const int C = 1e6+10;
// const ll M = 1000000007;

typedef tuple<int, int> path;

ll L;
int N;
vector<path> V[100];

void flush()
{
  int M = 0;
  for (auto i = 0; i < N; i++)
  {
    M += (int)V[i].size();
  }
  cout << N << " " << M << endl;
  for (auto i = 0; i < N; i++)
  {
    for (auto x : V[i])
    {
      cout << i + 1 << " " << get<0>(x) + 1 << " " << get<1>(x) << endl;
    }
  }
}

void add_edge(int x, int y, int c)
{
  V[x].push_back(path(y, c));
}

int main()
{
  cin >> L;
  N = 0;
  for (auto i = 0; i < 200; i++)
  {
    if ((L >> i) == 0)
    {
      N = i;
      break;
    }
  }
  assert(0 < N && N <= 20);
  int pow = 1;
  for (auto i = 0; i < N - 1; i++)
  {
    add_edge(i, i + 1, 0);
    add_edge(i, i + 1, pow);
    pow *= 2;
  }
  for (auto i = 0; i < N - 1; i++)
  {
    if ((L >> i) & 1)
    {
      int cost = L & (((1 << N) - 1) << (i + 1));
      add_edge(i, N - 1, cost);
    }
  }
  flush();
}

Measured memory_bytes: 256