akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        FastReader s = new FastReader();
        int n = s.nextInt();
        int m =s.nextInt();
        System.out.println(n*m);

    }

    private static boolean isPrime(int n) {
        if (n == 2)
            return true;
        else if ((n % 2 == 0 && n > 2) || n < 2)
            return false;
        else {
            for (int i = 3; i <= (int) Math.sqrt(n); i += 2) {
                if (n % i == 0)
                    return false;
            }
            return true;
        }


    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

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

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

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

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

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

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

}

Measured memory_bytes: 25348
#include <cstdio>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
  int i;
  int N;
  scanf("%d", &N);
  int num_max = 1;
  for (i = 1; i*(i+1) < 2*N; i++) {
    num_max += 1;
    //printf("%d ", num_max);
  }
  int ans[10000] = {};
  int index = 0;
  while (N > 0 && num_max >= 1) {
    if (N >= num_max) {
      ans[index] = num_max;
      N -= num_max;
      index += 1;
    }
    num_max -= 1;
  }
  for (i = 0; i < index; i++) {
    printf("%d\n", ans[i]);
  }
  return 0;
}

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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    int n, l;
    cin >> n >> l;
    vector<int> a(n);
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    int nr = -1;
    for (int i = 0; i < n - 1; ++i)
        if (a[i] + a[i + 1] >= l)
            nr = i;
    if (nr == -1)
        cout << "Impossible";
    else
    {
        vector<int> odp;
        cout << "Possible" << endl;
        odp.push_back(nr);
        for (int i = nr - 1; i >= 0; --i)
            odp.push_back(i);
        for (int i = nr + 1; i < n - 1; ++i)
            odp.push_back(i);
        for (int i = odp.size() - 1; i >= 0; --i)
            cout << odp[i] + 1 << endl;
    }
    return 0;
}


Measured memory_bytes: 1784
#include<stdio.h>
#include<stdlib.h>

#define INF 1000000
#define NIL NULL
#define WHITE 5000
#define BLACK 5001

void prim(void);

int A[101][101];
int *d,*pi,*color;
int n;

int main(){
  int i,j,re=0;

  scanf("%d",&n);

  d = malloc(sizeof(int)*(n+1));
  pi = malloc(sizeof(int)*(n+1));
  color = malloc(sizeof(int)*(n+1));

  for(i = 1;i <= n;i++){
    for(j = 1;j <= n;j++){
      scanf("%d",&A[i][j]);
    }
  }

  prim();

  for(i = 1;i <= n;i++){
    re = re + d[i];
  }

  printf("%d\n",re);

  return 0;
}

void prim(){
  int i,j,mincost,u,v;

  for(u = 1;u <= n;u++){
    d[u] = INF;
    pi[u] = NIL;
    color[u] = WHITE;
  }

  d[1] = 0;

  while(1){
    mincost = INF;

    for(i = 1;i <= n;i++){
      if(color[i] != BLACK && d[i] < mincost){
	mincost = d[i];
	u = i;
      }
    }

    if(mincost == INF)break;

    color[u] = BLACK;

    for(v = 1;v <= n;v++){
      if(color[v] != BLACK && A[u][v] < d[v] && A[u][v] != -1){
	pi[v] = u;
	d[v] = A[u][v];
      }
    }
  }
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n)  for (int i = 0; i < (int) (n); i++)
#define REP1(i, n) for (int i = 1; i <= (int) (n); i++)
#define all(x)     (x).begin(), (x).end()
#define SZ(x)      ((int) (x).size())
using ll = long long;
const ll mod = 1e9 + 7;
int main() {
  ll x;
  cin >> x;
  ll a, b, ansa, ansb;
  for (a = -200; a <= 200; a++) {
	  for (b = -200; b <= 200; b++) {
		  if (a * a * a * a * a - b * b * b * b * b == x) {
			  ansa = a;
			  ansb = b;
			}
		}
	}
  cout << ansa << " " << ansb << endl;
  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define REP(i, j, n) for (int i = j; i < (n); ++i)
#define SORT(a) sort(a.begin(), a.end())
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;

ll gcd(ll a, ll b)
{
    if (a < b) {
        a ^= b;
        b ^= a;
        a ^= b;
    }
    
    return b ? gcd(b, a % b) : a;
}

ll lcm(ll a, ll b)
{
    return a * b / gcd(a, b);
}

int main(){
    ll a,b;
    cin >> a >>b;
    cout<< lcm(a, b)<<endl;  
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC128
{
    class A
    {
        static void Main(string[] args)
        {
            int[] a = Console.ReadLine().Split(' ').Select(cc => int.Parse(cc)).ToArray();
            int A = a[0], P = a[1];
            int apple = (A * 3 + P) / 2;
            Console.WriteLine(apple);

        }
    }
}


Measured memory_bytes: 11348
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <list>
#include <stack>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#include <functional>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi   vector<int> 
#define   co(x)  cout << x << '\n' 
#define   dbg(x)  cerr << #x << " = " << x << '\n' 
#define   bitcount(x)  (int)__builtin_popcount(x) 
#define   sz(x)  (int)x.size()
#define   all(a) a.begin(),a.end() 
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

int n,m,r;
vector <vi> dis(201,vi (201,1e9));

signed main()
{
    cin >> n >> m >> r ; 
    vi a(r);
    for (int &it: a) cin >> it ; 
    for (int i=1;i<=m;i++){
        int  x, y, c ; 
        cin >> x >> y >> c ; 
        dis[x][y] = dis[y][x] = min(dis[x][y], c) ; 
    }
    for (int k=1;k<=n;k++) {
        for (int i=1;i<=n;i++) {
            for (int j=1;j<=n;j++) {
                dis[i][j] = min( dis[i][j], dis[i][k]+dis[k][j] ) ; 
            }
        }
    }
    int ans = 1e9 ; 
    sort(all(a));
    do {
        int sum = 0;
        for (int i=1;i<r;i++){
            sum += dis[a[i]][a[i-1]];
        }
        ans = min(ans, sum) ; 
    }
    while (next_permutation(a.begin(),a.end()));
    co ( ans ) ; 
    return 0;
}


Measured memory_bytes: 3908
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;
#define loop(i,N) for(ll (i)=0; (i)<(N);++(i))
struct _OMAZINAI_ { _OMAZINAI_() { std::ios::sync_with_stdio(false); std::cin.tie(0); } } __omazinai_instance__;
#define INF (1LL<<61 + 1<<29)
#define YesNo(x) {std::cout << ((x)?"Yes":"No") << std::endl;}
#define YESNO(x) {std::cout << ((x)?"YES":"NO") << std::endl;}
#define OddEven(x) {std::cout << ((x)%2?"Odd":"Even") << std::endl;}
#define ODDEVEN(x) {std::cout << ((x)%2?"ODD":"EVEN") << std::endl;}
typedef long long int ll;
void _INPUT_IMPL_() {};
template <class T, class... Args> void _INPUT_IMPL_(T& dest, Args&... args) { cin >> dest; _INPUT_IMPL_(args...); }
void _OUTPUT_IMPL_() {};
template <class T, class... Args> void _OUTPUT_IMPL_(T dest, Args... args) { cout<< dest << (sizeof...(Args)?" ":""); _OUTPUT_IMPL_(args...); }
#define in(type, ...) type __VA_ARGS__; _INPUT_IMPL_(__VA_ARGS__)
#define in_v(type, name, cnt) vector<type> name(cnt); loop(i, cnt) cin >> name[i];
#define sort_v(v) std::sort(v.begin(), v.end())
#define out(...) _OUTPUT_IMPL_(__VA_ARGS__)
//小さい方に寄る
#define space_op(x, y, a, b, c) ([](auto x_, auto y_, auto a_, auto b_, auto c_){if(x_<y_)return a_;if(x_>y_)return c_;return b_;}(x,y,a,b,c))
#define space_out(x, y, a, b, c) out(space_op(x, y, a, b, c))

int main() {
	in(int, a, b, c, d);
	out(max(a*b, c*d));
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
	int n, num[20], q, value;

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

	cin >> q;
	for (int i = 0; i < q; i++) {
		cin >> value;

		bool dp[2001] = { true };
		for (int j = 0; j < n; j++) {
			for (int k = value; k >= 0; k--) {
				if (dp[k] == true && k + num[j] <= value) {
					dp[k + num[j]] = true;
				}
			}
		}
		if (dp[value] == true) {
			cout << "yes" << endl;
		}
		else {
			cout << "no" << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1156
from collections import defaultdict


n = int(input())
A = list(map(int, input().split()))

A.sort()

dict = defaultdict(int)

count = 0
select = []
for _ in range(n):
    length = A.pop()

    if dict[length] > 0:
        dict[length] -= 1
        select.append(length)
        count += 1
    else:
        dict[length] += 1

    if count == 2:
        break

if len(select) < 2:
    print(0)
else:
    a = select.pop()
    b = select.pop()
    print(a*b)


Measured memory_bytes: 14636
#include<bits/stdc++.h>
#define rep(n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int SIZE = 401;
ll dp[SIZE][SIZE], Sum[SIZE][SIZE];
void init(){
    dp[0][0] = 1;
    rep(SIZE) Sum[0][i] = 1;
    Sum[0][0] = 0;
    for (int i = 1; i < SIZE; i++)
        for (int j = 1; j < SIZE; j++){
            Sum[i][j] = Sum[i-1][j] * j;
            Sum[i][j] %= MOD;
        }
    for (int i = 0; i < SIZE; i++)
        for (int j = 1; j < SIZE; j++){
            Sum[i][j] += Sum[i][j-1];
            Sum[i][j] %= MOD;
        }
}
ll AtoB(int Ai, int Bi, int n){
    return (MOD + Sum[n][Bi] - Sum[n][Ai-1]) % MOD;
}
int main(){
    int N, C; cin >> N >> C;
    int A[SIZE], B[SIZE];
    rep(N) cin >> A[i];
    rep(N) cin >> B[i];
    init();
    for (int i = 0; i < N; i++)
        for (int j = 0; j <= C; j++)
            for (int k = 0; k <= j; k++){
                dp[i+1][j] += dp[i][j-k] * AtoB(A[i], B[i], k);
                dp[i+1][j] %= MOD;
            }
    cout << dp[N][C] << endl;
}

Measured memory_bytes: 2816
#include <algorithm>
#include <vector>
#include <iostream>
#include <map>
#include <utility>
using namespace std;

int main()
{
	int N, M;
	cin >> N >> M;
	int a, b;
	multimap<int,int> list;


	for (size_t i = 0; i < M; i++)
	{
		cin >> a >> b;
		list.emplace(a, b);
	}
	auto count = list.equal_range(1);

	for (auto it = count.first; it != count.second; ++it)
	{
		auto scount = list.equal_range(it->second);
		for (auto sit = scount.first; sit != scount.second; ++sit)
		{
			if (sit->second == N)
			{
				cout << "POSSIBLE" << endl;
				return 0;
			}

		}



		
	}

	cout << "IMPOSSIBLE" << endl;


	return 0;
}

Measured memory_bytes: 9600
import java.util.*;
import java.util.HashMap;
import java.util.Map.Entry;

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

        ArrayList<ArrayList<String>> list = new ArrayList<ArrayList<String>>();
        
        Scanner sc = new Scanner(System.in);

        while(true){
            int N = Integer.parseInt(sc.nextLine());
            if(N == 0){
                break;
            }

            HashMap<String, String> henkan = new HashMap<String, String>();

            for(int i=0; i<N; i++){
                String line = sc.nextLine();
                String[] data = line.split(" ");
                henkan.put(data[0], data[1]); 
            }


            ArrayList<String> retu = new ArrayList<String>();
            int M = Integer.parseInt(sc.nextLine());
            for(int i=0; i<M; i++){
                String nyuryoku = sc.nextLine();
                if(henkan.containsKey(nyuryoku)){
                    retu.add(henkan.get(nyuryoku));
                }else{
                    retu.add(nyuryoku);
                }
                
            }
            list.add(retu);
        }
        
        
        for(int i=0; i<list.size(); i++){
            for(int k=0; k<list.get(i).size(); k++){
                System.out.print(list.get(i).get(k));
            }
            System.out.println();
        }

        /*System.out.println("HashMap--???????????????");
        int max = 0;
        
        for(Entry<Integer, Integer> entry : re.entrySet()){
                if(max < entry.getValue()){
                    max = entry.getValue();
                }
        }
        */
    }
}

Measured memory_bytes: 152708
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <string>
#include <string.h>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <map>
#include <set>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(s) s.begin(), s.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
const int DIV = 1e9+7;

ll n, a, b;
vl x;
ll ans = 0;

int main(){
  cin >> n >> a >> b;
  x.resize(n);
  rep(i, n){
    cin >> x[i];
    if(i == 0) continue;
    if((x[i] - x[i-1]) * a < b) ans += (x[i] - x[i-1]) * a;
    else ans += b;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#[allow(unused_macros)]
macro_rules! input {
        (source = $s:expr, $($r:tt)*) => {
            let mut iter = $s.split_whitespace();
            let mut next = || { iter.next().unwrap() };
            input_inner!{next, $($r)*}
        };
        ($($r:tt)*) => {
            let stdin = std::io::stdin();
            let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
            let mut next = move || -> String{
                bytes
                    .by_ref()
                    .map(|r|r.unwrap() as char)
                    .skip_while(|c|c.is_whitespace())
                    .take_while(|c|!c.is_whitespace())
                    .collect()
            };
            input_inner!{next, $($r)*}
        };
    }

#[allow(unused_macros)]
macro_rules! input_inner {
        ($next:expr) => {};
        ($next:expr, ) => {};

        ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
            let $var = read_value!($next, $t);
            input_inner!{$next $($r)*}
        };

        ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
            let mut $var = read_value!($next, $t);
            input_inner!{$next $($r)*}
        };
    }

#[allow(unused_macros)]
macro_rules! read_value {
        ($next:expr, ( $($t:tt),* )) => {
            ( $(read_value!($next, $t)),* )
        };

        ($next:expr, [ $t:tt ; $len:expr ]) => {
            (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        };

        ($next:expr, chars) => {
            read_value!($next, String).chars().collect::<Vec<char>>()
        };

        ($next:expr, bytes) => {
            read_value!($next, String).into_bytes()
        };

        ($next:expr, usize1) => {
            read_value!($next, usize) - 1
        };

        ($next:expr, $t:ty) => {
            $next().parse::<$t>().expect("Parse error")
        };
    }

fn main() {
    input! {
            n: i32,
            d: i32
        }

    let ans = (n as f32 / (d * 2 + 1) as f32).ceil() as i32;

    println!("{}", ans);
}


Measured memory_bytes: 4352
package main

import (
	"fmt"
)

func main() {
	var s, t string
	fmt.Scan(&s, &t)
	ss := []rune(s)
	tt := []rune(t)
	for i := 0; i < len(ss); i++ {
		if ss[i] == tt[i] {
			continue
		} else {
			a := ss[i]
			b := tt[i]
			for j := 0; j < i; j++ {
				switch ss[j] {
				case a:
					fmt.Println("No")
					return
				case b:
					fmt.Println("No")
					return
				default:
					continue
				}
			}
			for j := i; j < len(ss); j++ {
				switch ss[j] {
				case a:
					ss[j] = b
				case b:
					ss[j] = a
				default:
					continue
				}
			}
		}
	}
	fmt.Print("Yes")
}


Measured memory_bytes: 3840
import java.util.*;

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

        String str1 = str.replaceAll("apple","りんご");
        String str2 = str1.replaceAll("peach","apple");
        String str3 = str2.replaceAll("りんご","peach");

        System.out.println(str3);
    }
}


Measured memory_bytes: 26064
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll N;
    cin>>N;
    ll h[N];
    rep(i,0,N) cin>>h[i];
    ll res1=0, res2=0;
    int i=0,j=0;
    while(i<N){
        while(j<N&&h[i]==h[j]){
            j++;
        }
        if(i==0&&(h[i]>h[j]||j==N)) res1+=h[i];
        if(i!=0&&h[i-1]<h[i]&&(h[i]>h[j]||j==N))  res1+=h[i];
        if(i!=0&&j!=N&&(h[i-1]>h[i]&&h[i]<h[j]))  res2+=h[i];
        i=j;
    }
    cout <<res1-res2<<"\n";
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var a, b float64
	c := make([]float64, 3)

	fmt.Scan(&a, &b)
	c[0] = a + b
	c[1] = a - b
	c[2] = a * b

	fmt.Println(max(c))
}

func max(a []float64) float64 {
	max := a[0]
	for _, i := range a {
		if i > max {
			max = i
		}
	}
	return max
}


Measured memory_bytes: 512
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"

using namespace std;

typedef long int li;
typedef long double ld;
typedef long long ll;
typedef pair<ll, ll> pt;

#define fi first
#define se second
#define lson (p<<1)+1
#define rson (p<<1)+2
#define dump(x) cout << #x << " = " << x << endl
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

string s;

int main () {
    fastIO;
    cin >> s;
    for(auto i : s) cout << "x";
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(void)
{
    int a[1100],b,m,n,i,j=0,k=0,l=0,p=0,x=0,y=0,z=0;
    char s[1000],ss[1000],c;

    scanf("%s",s);
    n=strlen(s);

    for (size_t i = 0; i < n; i++)
    {
        printf("x");
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 128
N = int(input())
S = list(input())

alphabet = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L",
            "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L",
            "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", ]

result = []
for i in range(len(S)):
    al = alphabet.index(S[i])
    result.append(alphabet[al+N])

print("".join(result))


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

int main(){
  int n;
  cin>>n;
  if(n%2==0)cout << n;
  else cout << 2 * n;

}


Measured memory_bytes: 256
m,n,xn,yn = gets.strip.split.map(&:to_i)
x = gets.strip.split.map(&:to_i).push(xn).max
y = gets.strip.split.map(&:to_i).push(yn).min
puts x < y ? "No War" : "War" 
# if !(x < y)
#   puts 'War'
#   exit
# else 
#   (x+1).upto(y) do |z|
#     if !(xn < z || yn >= z)
#       puts 'War'
#       exit
#     end
#   end
# end
# puts 'No War'

Measured memory_bytes: 1788
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
#include<cassert>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};

ll x,d,k;

void solve(){
    cin >> x >> k >> d;
    ll s=-x/d;
    ll ans=INF;
    Rep(i,-50,50){
        ll t=s+(ll)i;
        //cout << t << endl;
        if(t<-k || k<t) continue;
        if(abs(t%2)!=k%2) continue;
        ans=min(ans,abs(x+t*d));
    }
    if(s<-k+10){
        ans=min(ans,abs(x-k*d));
    }
    if(s>k-10){
        ans=min(ans,abs(x+k*d));
    }
    cout << ans << endl;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(50);
    solve();
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
#define mem(a) memset(a,0,sizeof(a))
#define pd(a) printf("%.10f\n",a)
#define pb(a) push_back(a)
#define in(a) insert(a)
#define pi M_PI
#define R cin>>
#define F first
#define S second
#define C class
#define ll long long
#define ln cout<<'\n'
template<C T>void pr(T a){cout<<a;ln;}
template<C T,C T2>void pr(T a,T2 b){cout<<a<<' '<<b;ln;}
template<C T,C T2,C T3>void pr(T a,T2 b,T3 c){cout<<a<<' '<<b<<' '<<c;ln;}
template<C T>void PR(T a,int n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
bool check(int n,int m,int x,int y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<60,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  string r;
  R r;
  int n=r.size();
  int ans=0;
  REP(t,1,1<<n) {
    if(__builtin_popcount(t)<=2) continue;
    string s="";
    rep(i,n) if(t&(1<<i)) s+=r[i];
    bool f=1;
    int m=s.size();
    rep(i,m) {
      char c=s[i],c2=s[s.size()-i-1];
      if(c=='i'&&c2!='i') f=0;
      if(c=='w'&&c2!='w') f=0;
      if(c=='('&&c2!=')') f=0;
      if(c==')'&&c2!='(') f=0;
      if(c=='['&&c2!=']') f=0;
      if(c==']'&&c2!='[') f=0;
      if(c=='{'&&c2!='}') f=0;
      if(c=='}'&&c2!='{') f=0;
    }
    if(f&&m%2) {
      if(s[m/2-1]!='i'||s[m/2]!='w'||s[m/2+1]!='i') continue;
      bool ff=1;
      rep(i,m/2-1) {
        if(isalpha(s[i])) ff=0;
        if(isalpha(s[m-i-1])) ff=0;
      }
      if(ff) ans=max(ans,(int)s.size());
    }
  }
  pr(ans);
}

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


Measured memory_bytes: 1204
def check_mm(string):
    if int(string) <= 12 and int(string) > 0:
        return True
    return False


S = input()
former = S[:2]
latter = S[2:]
former_mm = check_mm(former)
latter_mm = check_mm(latter)
if former_mm and latter_mm:
    print('AMBIGUOUS')
elif former_mm:
    print('MMYY')
elif latter_mm:
    print('YYMM')
else:
    print('NA')

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <sstream>
#include <string>
#include <queue>
#include <cstdio>
#include <map>
#include <set>
#include <utility>
#include <stack>
#include <cstring>
#include <cmath>
#include <vector>
#include <ctime>
#include <bitset>
using namespace std;
#define pb push_back
#define sd(n) scanf("%d",&n)
#define sdd(n,m) scanf("%d%d",&n,&m)
#define sddd(n,m,k) scanf("%d%d%d",&n,&m,&k)
#define sld(n) scanf("%lld",&n)
#define sldd(n,m) scanf("%lld%lld",&n,&m)
#define slddd(n,m,k) scanf("%lld%lld%lld",&n,&m,&k)
#define sf(n) scanf("%lf",&n)
#define sff(n,m) scanf("%lf%lf",&n,&m)
#define sfff(n,m,k) scanf("%lf%lf%lf",&n,&m,&k)
#define ss(str) scanf("%s",str)
#define ans() printf("%d",ans)
#define ansn() printf("%d\n",ans)
#define anss() printf("%d ",ans)
#define lans() printf("%lld",ans)
#define lanss() printf("%lld ",ans)
#define lansn() printf("%lld\n",ans)
#define fansn() printf("%.5f\n",ans)
#define r0(i,n) for(int i=0;i<(n);++i)
#define r1(i,e) for(int i=1;i<=e;++i)
#define rn(i,e) for(int i=e;i>=1;--i)
#define rsz(i,v) for(int i=0;i<(int)v.size();++i)
#define szz(x) ((int)x.size())
#define mst(abc,bca) memset(abc,bca,sizeof abc)
#define lowbit(a) (a&(-a))
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pli pair<ll,int>
#define mp make_pair
#define lrt rt<<1
#define rrt rt<<1|1
#define X first
#define Y second
#define PI (acos(-1.0))
#define sqr(a) ((a)*(a))
typedef long long ll;
typedef unsigned long long ull;
const int mod = 1000000000+7;
const double eps=1e-9;
const int inf=0x3f3f3f3f;
const ll infl = 10000000000000000;
const int maxn=  200000+10;
const int maxm = 10000+10;

int in(int &ret)
{
    char c;
    int sgn ;
    if(c=getchar(),c==EOF)return -1;
    while(c!='-'&&(c<'0'||c>'9'))c=getchar();
    sgn = (c=='-')?-1:1;
    ret = (c=='-')?0:(c-'0');
    while(c=getchar(),c>='0'&&c<='9')ret = ret*10+(c-'0');
    ret *=sgn;
    return 1;
}


char s[maxn];
int cnt[30];
int main()
{
#ifdef LOCAL
    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);
#endif // LOCAL

//    freopen("kingdom.in","r",stdin);
//    freopen("kingdom.out","w",stdout);

    ss(s+1);
    int n = strlen(s+1);
    for(int i=1;i<=n;++i)
    {
        int idx = s[i]-'a';
        cnt[idx]++;
    }
    ll ans = 1LL*(n-1)*n/2 +1 ;
    for(int i=0;i<26;++i)
    {
        int a = cnt[i];
        ans -= 1LL*(a-1)*a/2;
    }
    lansn();
    return 0;
}


Measured memory_bytes: 384
import time
import random
t1 = time.time()

D = int(input())

last_list = [0 for i in range(27)]
c_list = list(map(int, input().split()))
c_list = [""] + c_list
# print(c_list)
S_list = [[]for i in range(D)]
P_list = [0 for i in range(27)]
for i in range(D):
    S_list[i] = list(map(int, input().split()))
    S_list[i] = [""] + S_list[i]
S_list = [""] + S_list
# print(S_list)


t_list = [""]
for i in range(D):
    t_list.append(random.randint(1,26))

for i in range(1,D+1):
    S = 0
    t = t_list[i]
    for j in range(1,27):
        if j == t:
            P_list[j] += S_list[i][j]
            last_list[j] = i
            # print(S_list[i][j])
        else:
            P_list[j] -= c_list[j] * (i-last_list[j])
    for i in range(1,27):
        S += P_list[i]
    # print(S)

t2 = time.time()
Time = t2 - t1
# print(M)
while t2 - t1 <= 1.5:
    last_list = [0 for i in range(27)]
    P_list = [0 for i in range(27)]
    C_A = random.randint(1,D)
    C_B = random.randint(1,26)
    t_new = t_list
    t_new[C_A] = C_B
    for i in range(1,D+1):
        S_new = 0
        t = t_new[i]
        for j in range(1,27):
            if j == t:
                P_list[j] += S_list[i][j]
                last_list[j] = i
                # print(S_list[i][j])
            else:
                P_list[j] -= c_list[j] * (i-last_list[j])
        for i in range(1,27):
            S_new += P_list[i]
    if S_new >= S:
        S = S_new
        t_list = t_new
    t2 = time.time()

for i in range(1,D+1):
    print(t_list[i])


Measured memory_bytes: 80128
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7
#s=input().rstrip()

n,h=MI()
A=[]
B=[]
for i in range(n):
    a,b=MI()
    A.append(a)
    B.append(b)
#print(B)
A.sort(reverse=True)
B.sort(reverse=True)
ace=A[0]
throw=[]
for b in B:
    if b>ace:
        throw.append(b)
if h>sum(throw):
    slash1=ceil((h-sum(throw))/ace)
    h-=ace*slash1
    ans=slash1+len(throw)
else:
    for i in range(len(throw)):
        h-=throw[i]
        if h<=0:
            ans=i+1
            break
print(ans)

Measured memory_bytes: 12404
#include<algorithm>
#include <bits/stdc++.h>
#include <math.h>
#include <queue>
using namespace std;
int main(void){
	int i,n,k,ans=0;
	cin>>n>>k;
	int l[n];
	for(i=0;i<n;i++)cin>>l[i];
	sort(l,l+n);
	for(i=n-1;i>=n-k;i--)ans+=l[i];
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
import sys
import numpy as np
from numba import njit
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
s_readline = sys.stdin.readline


def main():

    N, K = map(int, readline().split())
    A = np.array(list(map(int, readline().split())), np.int32)

    K = min(N, K)
    ans = solve(N, K, A).tolist()
    print(' '.join(map(str, ans)))


@njit('i4[:](i4,i4,i4[:])', cache=True)
def solve(N, K, A):

    for k in range(K):

        B = np.zeros(N, np.int32)
        for i in range(N):
            l = max(0, i - A[i])
            r = i + A[i] + 1
            B[l] += 1
            if r <= N - 1:
                B[r] -= 1

        s = B[0]
        for i in range(N - 1):
            B[i + 1] = B[i + 1] + B[i]
            s += B[i + 1]

        A = B

        if s == N * N:
            break

    return A


if __name__ == '__main__':
    main()


Measured memory_bytes: 130696
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <map>
#include <ctime>
#include <cstdlib>
#include <set>
#include <queue>
using namespace std;

#define X first
#define Y second
#define Mod 1000000007
#define N 4010
#define M 101

typedef long long ll;

const int INF=1<<30;

int a,b,n,top;
int stack[N];
int res[N];

void Ask(int p,int q)
{
	printf("? %d %d\n",p,q);
	fflush(stdout);
}

int main()
{
	//freopen("in.in","r",stdin);
	//freopen("out.out","w",stdout);
	
	cin >> a >> b ; n = a + b;
	if (a <= b) printf("Impossible\n"),fflush(stdout);
	else
	{
		for (int i=0;i<n;i++)
		{
			if (!top) stack[++top]=i;
			else
			{
				Ask(stack[top],i);
				char ans; scanf(" %c",&ans);
				if (ans=='N') top--;
				else stack[++top]=i;
			}
		}
		for (int i=0;i<n;i++)
		{
			Ask(stack[top],i);
			char ans; scanf(" %c",&ans);
			if (ans=='N') res[i]=0;
			else res[i]=1;
		}
		printf("! ");
		for (int i=0;i<n;i++) printf("%d",res[i]);
		printf("\n");
		fflush(stdout);
	}
	
	return 0;
}

Measured memory_bytes: 724
// Aaradhya Beri
#pragma GCC optimze("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef long double f80;
#define double long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define sz(x) ((long long)x.size())
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define rep(a,b,c) for(int a=b; a<c; a++)
#define trav(a,x) for(auto &a:x)
#define all(con) con.begin(),con.end()
const ll infl=0x3f3f3f3f3f3f3f3fLL;
const int infi=0x3f3f3f3f;
//const int mod=998244353;
const int mod=1000000007;
typedef vector<int> vi;
typedef vector<ll> vl;

int powm(int a, int b) {
    int res=1;
    while(b) {
        if(b&1)
            res=(res*a)%mod;
        a=(a*a)%mod;
        b>>=1;
    }
    return res;
}
string s1,s2;


void solve() {
    cin>>s1>>s2;
    int l1 = s1.length();
    int l2 = s2.length();
    int dp[l1+1][l2+1];
    fr(i,0,l1)
    {
        fr(j,0,l2)
        {
            if(i == 0 || j == 0)
                dp[i][j] = 0;
            else if(s1[i-1] == s2[j-1])
                dp[i][j] = 1 + dp[i-1][j-1];
            else
                dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
        }
    }

    int i = l1,j = l2;
    string s ="";
    while(i > 0 && j > 0)
    {
        if(s1[i-1] == s2[j-1])
        {
            s += s1[i-1];
            i--;j--;
        }
        else if(dp[i-1][j] > dp[i][j-1])
            i--;
        else 
            j--;
    }
    reverse(s.begin(),s.end());
    cout<<s<<endl;
}
 
signed main() {
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    cout<<fixed<<setprecision(8);
    int t = 1;
    //cin>>t;
    while(t--)
        solve();
    return 0;
}

Measured memory_bytes: 35456
#include<bits/stdc++.h>
using namespace std;
int a[3001][3001];
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int n,i,j,m;
    string s1,s2,s3="";
    cin>>s1>>s2;
    n=s1.length();
    m=s2.length();
    for(i=0;i<=n;i++)
    {
        for(j=0;j<=m;j++)
        {
            a[i][j]=0;
        }
    }
    for(i=0;i<n;i++)
    {
       for(j=0;j<m;j++)
       {
          if(s1[i]==s2[j])
          {
              a[i+1][j+1]=/*a[i][j]+1;*/max(a[i+1][j+1],a[i][j]+1);
          }
          else
          {
             a[i+1][j+1]=/*max(a[i+1][j],a[i][j+1]);/*/max(a[i+1][j+1],max(a[i+1][j],a[i][j+1]));
          }
       }
    }
   /* for(i=1;i<=n;i++)
    {
        for(j=1;j<=m;j++)
        {
            cout<<a[i][j]<<" ";
        }cout<<endl;
    }*/
    i=n;
    j=m;
    while(i>0&&j>0)
    {
        /*if(a[i][j]==a[i-1][j-1]+1)
        {
            s3=s3+s1[i-1];
            i--;
            j--;
        }
        else*/ if(a[i][j]==a[i-1][j])
        {
            i--;
        }
        else if(a[i][j]==a[i][j-1])
        {
            j--;
        }
        else
        {  s3=s3+s1[i-1];
            i--;
            j--;
        }
    }
    reverse(s3.begin(),s3.end());
    cout<<s3<<endl;
    return 0;
}




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

int main(){
    int n, k, q;
    cin >> n >> k >> q;
    vector<int> A(n, k - q);
    for (int i = 0; i < q; i++){
        int a;
        cin >> a;
        A[--a]++;
    }

    for (const auto &a: A)
        puts(a > 0 ? "Yes" : "No");
}

Measured memory_bytes: 1024
<?php
$n = intval(trim(fgets(STDIN)));
$a = array_map("intval", explode(" ", trim(fgets(STDIN))));
$sum = 0;
$mod = 10**9+7;
for($i = 0; $i <= 60; $i++){
  $c = 0;
  foreach($a as $b){
    $c += ($b >> $i) & 1; 
  }
  $c *= $n-$c;
  $c %= $mod;
  $c *= (1<<$i) % $mod;
  $c %= $mod;
  $sum += $c;
  $sum %= $mod;
}
echo $sum;


Measured memory_bytes: 40936
#include<iostream>
#include<string>
using namespace std;
int main(){
	string s,tmp,res;
	cin >>s;
	tmp =s.substr(0,2);
	res =s.substr(2,2);
	if("00"<tmp&&tmp<="12" ){
		if("00"< res && res <="12"){
			cout <<"AMBIGUOUS";
			}
		else cout <<"MMYY";
	}
	else{
		if("00"<res&& res <="12") cout <<"YYMM";
		else cout <<"NA";
		};
	return 0;
	}


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

int N, a[MAXN + 3], smallest[MAXN + 3], answer[MAXN + 3], currentLIS;
vector<int> adj[MAXN + 3];

void DFS(int u, int prv) {
    int pos = lower_bound(smallest, smallest + currentLIS, a[u]) - smallest;

    int prvValue = smallest[pos];
    bool increaseLIS = (pos == currentLIS);

    if (pos == currentLIS)
        currentLIS += 1;

    smallest[pos] = a[u];
    answer[u] = currentLIS;

    for (auto v: adj[u]) {
        if (v != prv)
            DFS(v, u);
    }

    //Undo everything
    if (increaseLIS)
        currentLIS -= 1;

    smallest[pos] = prvValue;
}

int main() {
    scanf("%d", &N);
    for (int i = 1; i <= N; i++)
        scanf("%d", &a[i]);

    for (int i = 1; i < N; i++) {
        int u, v;
        scanf("%d%d", &u, &v);

        adj[u].push_back(v);
        adj[v].push_back(u);
    }

    currentLIS = 0;
    for (int i = 0; i <= N; i++)
        smallest[i] = INF;

    DFS(1, 1);

    for (int i = 1; i <= N; i++)
        printf("%d\n", answer[i]);
}


Measured memory_bytes: 31492
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
#define mem(a,v) memset((a), (v), sizeof (a))
#define enl printf("\n")
#define case(t) printf("Case #%d: ", (t))
#define ni(n) scanf("%d", &(n))
#define nl(n) scanf("%lld", &(n))
#define nai(a, n) for (int i = 0; i < (n); i++) ni(a[i])
#define nal(a, n) for (int i = 0; i < (n); i++) nl(a[i])
#define pri(n) printf("%d\n", (n))
#define prl(n) printf("%lld\n", (n))
#define pii pair<int, int>
#define pil pair<int, long long>
#define pll pair<long long, long long>
#define vii vector<pii>
#define vil vector<pil>
#define vll vector<pll>
#define vi vector<int>
#define vl vector<long long>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef cc_hash_table<int,int,hash<int>> ht;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;
const double pi = acos(-1);
const int MOD = 1e9 + 7;
const ll INF = 1e18 + 7;
const int MAXN = 2e5 + 5;
const double eps = 1e-9;
ll nx[MAXN][62];
int a[MAXN], lst[MAXN];

int main() {
	mem(lst, -1);
	ll n, k;
	scanf("%lld %lld", &n, &k);
	for (int i = 0; i < n; i++) {
		ni(a[i]);
		if (~lst[a[i]])
			nx[lst[a[i]]][0] = i - lst[a[i]] + 1;
		lst[a[i]] = i;
	}
	for (int i = 0; i < n; i++) {
		if (~lst[a[i]])
			nx[lst[a[i]]][0] = i - lst[a[i]] + 1 + n;
		lst[a[i]] = -1;
	}
	for (int i = 1; i < 62; i++)
		for (int j = 0; j < n; j++)
			nx[j][i] = min(INF,nx[j][i-1] + nx[(j+nx[j][i-1]) % n][i-1]);
	k *= n;
	ll cur = 0;
	for (int i = 61; ~i; i--)
		while (cur + nx[cur % n][i] <= k)
			cur += nx[cur % n][i];
	vi ans;
	while (cur < k) {
		int val = a[cur % n];
		if (~lst[val]) {
			while (ans.back() != val) {
				lst[ans.back()] = -1;
				ans.pop_back();
			}
			lst[ans.back()] = -1;
			ans.pop_back();
		} else {
			lst[val] = 1;
			ans.pb(val);
		}
		cur++;
	}
	for (int i: ans)
		printf("%d ", i);
	enl;
	return 0;
}


Measured memory_bytes: 100852
#include <iostream>
using namespace std;
int main(int argc, char const *argv[])
{
	string s;
	cin>>s;
	long long int i=0;
	int sm=0;
	while(s[i]!='\0'){
		sm+=(s[i]-'0');
		sm%=9;
		i++;
	}
	//cout<<i<<" "<<s[0]<<" "<<sm;
	if(sm==0) cout<<"Yes";
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 3748
#include <bits/stdc++.h>
#define REP(type, i, a, b) for( type i = a; i < b; i++ )
using namespace std;
const int MAX = 100001;

int main(){
    int n, m, a, b, ans;
    int h[MAX], nice[MAX];
    vector<int> G[MAX];
    cin >> n >> m;
    REP(int,i,1,n+1){ 
        cin >> h[i];
        nice[i] = 1;
    }
    REP(int,i,0,m){
        cin >> a >> b;
        if(h[a]>h[b]){
            nice[b]=0;
        }else if(h[a]==h[b]){
            nice[a]=0;
            nice[b]=0;
        }else{
            nice[a]=0;
        }
    }

    ans=0;
    REP(int,i,1,n+1){
        if(nice[i]) ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 6752
X, K, D = map(int, input().split(" "))

if abs(X) >= abs(K*D):
    print(abs(X)-abs(K*D))
else:
    rK = K - int(abs(X)/abs(D))
    if rK % 2 == 0:
        print(abs(abs(X)  - D*(int(abs(X)/abs(D)))))
    else:
        print(abs(abs(X)  - D*(1+int(abs(X)/abs(D)))))


Measured memory_bytes: 9060
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<ll,ll>;

int main() {
  int n,k;
  cin >> n >> k;
  vector<P> v(n);
  rep(i,n) cin >> v[i].first >> v[i].second;
  sort(v.begin(),v.end());

  ll ans = 5L*1e18L;
  rep(l,n-k+1){
    vector<ll> y;
    rep(i,k-1) y.push_back(v[l+i].second);
    for(int r=l+k-1;r<n;++r){
      y.push_back(v[r].second);
      sort(y.begin(),y.end());
      ll dx = v[r].first - v[l].first;
      ll dy = 1e18L;
      rep(i,y.size()-k+1) dy = min(dy,y[i+k-1]-y[i]); 
      ans = min(ans,dx*dy);
    }
  }
  cout << ans << endl;
}

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

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

  int h[100010],ma[100010]={0};

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

  for(int j=0; j<m; j++){
    int a,b;
    cin >> a >> b;

    if(h[a-1]<h[b-1])
      ma[a-1] = 0;
    else if(h[a-1]>h[b-1])
      ma[b-1]=0;
    else{
      ma[a-1]=0;
      ma[b-1]=0;
    }
  }

  int ans=0;

  for(int k=0; k<n; k++){
    if(ma[k]==1)ans++;
  }

  cout << ans << endl;
}

Measured memory_bytes: 4420
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#define mod 1000000007ll
typedef long long ll;
using namespace std;


int main(void) {
  ll i, j, k, n;
  scanf("%lld", &n);
  vector<ll> vec[200000];
  ll dp[n], c[n], num[200000];
  for(i = 0; i < 200000; ++i) num[i] = 0;
  for(i = 0; i < n; ++i) dp[i] = 0;
  for(i = 0; i < n; ++i) {
    scanf("%lld", &c[i]);
    --c[i];
    if(!i || c[i - 1] != c[i]) vec[c[i]].push_back(i);
  }
  dp[0] = 1;
  for(i = 0; i < n; ++i) {
    if(i) dp[i] += dp[i - 1], dp[i] %= mod;
    if(vec[c[i]][num[c[i]]] == i && num[c[i]] < vec[c[i]].size() - 1) dp[vec[c[i]][++num[c[i]]]] += dp[i], dp[vec[c[i]][num[c[i]]]] %= mod;
  }
  printf("%lld", dp[n - 1]);
  return 0;
}

Measured memory_bytes: 15872
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#include <vector>
using namespace std;
int main(){
  int a,b,c;
  cin >> a >> b >> c;
  int sum = a + b + c;
  cout << sum - max({a, b, c}) << endl;
  return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
# from math import *


def input(): return sys.stdin.readline()[:-1]


sys.setrecursionlimit(10**8)
inf = float('inf')
mod = 10**9+7

n, q = map(int, input().split())
s = input()
td = []
for i in range(q):
    td.append(input().split())



def solve_binary1(mid):
    for t, d in td:
        if s[mid] == t:
            mid = mid-1 if d == 'L' else mid+1
        if mid == -1 or mid == n:
            break
    if mid == -1:
        return 1
    else:
        return 0



def binary_search1():
    ok = 0
    ng = n
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if solve_binary1(mid):
            ok=mid
        else:
            ng=mid
    return ok


def solve_binary2(mid):
    for t, d in td:
        if s[mid] == t:
            mid = mid-1 if d == 'L' else mid+1
        if mid == -1 or mid == n:
            break
    if mid == n:
        return 1
    else:
        return 0


def binary_search2():
    ok = n
    ng = 0
    while abs(ok-ng) > 1:
        mid = (ok+ng)//2
        if solve_binary2(mid):
            ok = mid
        else:
            ng = mid
    return ok


#左に集まる中でもっとも右の点を探す
ok1=binary_search1()

#右に集まる中でもっとも左の点を探す
ok2=binary_search2()

# ok2 = n
# left = 0
# right = n
# while left < right:
#     mid = (left+right)//2
#     tmp = mid
#     for t, d in td:
#         if s[tmp] == t:
#             tmp = tmp-1 if d == 'L' else tmp+1
#         if tmp == n or tmp == -1:
#             break
#     if tmp == n:
#         right = mid
#         ok2 = min(ok2, mid)
#     else:
#         left = mid+1

print(max(0, ok2-ok1-1))
# print(ok2,ok1)
# print(ok1)


Measured memory_bytes: 84300
// https://atcoder.jp/contests/agc035/tasks/agc035_c
//
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! dvec {
    ($t:expr ; $len:expr) => {
        vec![$t; $len]
    };

    ($t:expr ; $len:expr, $($rest:expr),*) => {
        vec![dvec!($t; $($rest),*); $len]
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    input! {
        n: usize,
    };

    let mut nn = n;
    while nn > 1 && nn % 2 == 0 {
        nn /= 2;
    }
    if nn == 1 {
        println!("No");
        return;
    }


    let mut edges = vec![];
    edges.push((1, 2));
    edges.push((2, 3));
    edges.push((3, n+1));
    edges.push((n+1, n+2));
    edges.push((n+2, n+3));

    let mut k = 5;
    while k <= n {
        let l = k-1;
        edges.push((1, l));
        edges.push((l, k));
        edges.push((1, n+k));
        edges.push((n+k, n+l));
        k += 2;
    }
    if n % 2 == 0 {
        let mut w = 2;
        loop {
            if n & w == w {
                let c = n - w;
                edges.push((w, n));
                edges.push((n+c+1, 2*n));
                break;
            }
            w <<= 1;
        }
    }

    println!("Yes");
    for &e in &edges {
        println!("{} {}", e.0, e.1);
    }
}


Measured memory_bytes: 11512
#include <stdio.h>

int main(){
	int a,b[3]={0,0,0};
	for(int i=0;i<10;i++){
		scanf("%d",&a);
		if(a>=b[2]){
			if(a>=b[1]){
				if(a>=b[0]){
					b[2]=b[1];
					b[1]=b[0];
					b[0]=a;
				}else{
					b[2]=b[1];
					b[1]=a;
				}
			}else{
				b[2]=a;
			}
		}
	}
	for(int i=0;i<3;i++){
		printf("%d\n",b[i]);
	}
}

Measured memory_bytes: 1028