akhauriyash/Code-Regression huggingface dataset:
{-# LANGUAGE FlexibleInstances    #-}
{-# LANGUAGE TypeSynonymInstances #-}

import           Control.Applicative
import           Control.DeepSeq
import           Control.Monad
import           Control.Monad.ST
import qualified Data.Array                  as A
import qualified Data.Array.IArray           as IA
import qualified Data.Array.IO               as AI
import qualified Data.Array.MArray           as MA
import qualified Data.Array.ST               as STA
import qualified Data.Array.Unboxed          as AU
import           Data.Bits
import qualified Data.ByteString.Char8       as BS
import           Data.Char
import qualified Data.Graph                  as G
import           Data.Int
import qualified Data.IntMap                 as IM
import qualified Data.IntSet                 as IS
import           Data.List
import qualified Data.Map.Strict             as M
import           Data.Maybe
import           Data.Ord
import qualified Data.Sequence               as SQ
import qualified Data.Set                    as S
import           Data.Time
import qualified Data.Tree                   as T
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

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

readIntegers :: Int -> IO [[Integer]]
readIntegers n = replicateM n readInteger

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)

count :: Eq a => a -> [a] -> Int
count a as = length $ filter (== a) as

put :: Show a => a -> IO ()
put = putStr . show

putLn :: Show a => a -> IO ()
putLn = print

putList :: Show a => [a] -> IO ()
putList [n] = put n
putList (n:ns) = do
  put n
  putStr " "
  putList ns

putStrList :: [String] -> IO ()
putStrList [n] = putStr n
putStrList (n:ns) = do
  putStr n
  putStr " "
  putStrList ns

yesNoUpper b
  | b = putStrLn "YES"
  | otherwise = putStrLn "NO"

yesNo b
  | b = putStrLn "Yes"
  | otherwise = putStrLn "No"

main = do
  r <- getLine
  yesNo $ '9' `elem` r


Measured memory_bytes: 508
import java.util.*;
import java.math.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double a = sc.nextDouble();
        double b = sc.nextDouble();
        double h = sc.nextDouble();
        double m = sc.nextDouble();
        double arc = ( 5.5 * ( 60.0 * h + m ) ) % 360 * Math.PI / 180;
        double answer = Math.sqrt( a * a + b * b - 2 * a * b * Math.cos(arc) );
        System.out.println(String.format("%.20f", answer));
    }
}

Measured memory_bytes: 37392
n=int(input())
l=[]
for i in range(n):
  a,b=list(map(int,input().split()))
  l.append([a+b,a,b])

l.sort()
l.reverse()
s=0
for i in range(0,n,2):
  s+=l[i][1]
for i in range(1,n,2):
  s-=l[i][2]
print(s)

Measured memory_bytes: 89196
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
const int inf = INT_MAX / 2;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }


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

    int N, K, h[110000];
    cin >> N >> K;
    rep(i, N) cin >> h[i];

    int DP[110000];
    rep(i, N) DP[i] = inf;
    DP[0] = 0;
    for (int i = 0; i < N; i++) {
        for (int j = 1; j < K+1; j++) {
            chmin(DP[i+j], DP[i] + abs(h[i] - h[i+j]));
        }
    }

    cout << DP[N-1] << endl;
}

Measured memory_bytes: 4396
#include<iostream>
#include<algorithm>
#include<string>
#include<stdio.h>
using namespace std;
int main(){

	int A,B,C;
	cin >> A >> B >> C;
	if(A==B)
		cout << C << endl;
	else if(B==C)
		cout << A << endl;
	else
		cout << B << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	long long n, K, A, B;
	scanf("%lld %lld %lld", &K, &A, &B);
	if(K<=A)
		n = 1;
	else if(A<=B)
		n = -1;
	else
		n = (K-B)/(A-B);
	if(n>0)
	{
		while(n*A-(n-1)*B<K)
			n++;
		printf("%lld\n", n*2-1);
	}
	else
		printf("-1\n");
	return 0;
} 

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            List<int> GetUserS = new List<int>();
            List<int> GetUserH = new List<int>();
            List<int> GetUserC = new List<int>();
            List<int> GetUserD = new List<int>();
            string[] Card;


           int CrentCard =  int.Parse(Console.ReadLine());


            for(int i = 0; CrentCard > i; i++) 
            {
                string CardType = Console.ReadLine();

                Card = CardType.Split(' ');

                    switch (Card[0])
                    {
                     case "S":
                            GetUserS.Add(int.Parse(Card[1]));
                            break;

                    case "H":
                            GetUserH.Add(int.Parse(Card[1]));
                            break;

                    case "C":
                        GetUserC.Add(int.Parse(Card[1]));
                        break;

                    case "D":
                        GetUserD.Add(int.Parse(Card[1]));
                        break;
                }

            }


            GetUserS = PrintData(GetUserS);

            foreach(var result in GetUserS)
            {
                Console.WriteLine("S {0}", result);
            }

            GetUserH = PrintData(GetUserH);

            foreach (var result in GetUserH)
            {
                Console.WriteLine("H {0}", result);
            }


            GetUserC = PrintData(GetUserC);

            foreach (var result in GetUserC)
            {
                Console.WriteLine("C {0}", result);
            }


            GetUserD = PrintData(GetUserD);

            foreach (var result in GetUserD)
            {
                Console.WriteLine("D {0}", result);
            }

        }

        private static List<int> PrintData(List<int> vList)
        {
            List<int> result = new List<int>();
            for (int x = 1; x <= 13; x++)
            {
                if (vList.Contains(x)) continue;

                result.Add(x);
            }

            return result;
        }

    }
}

Measured memory_bytes: 9584
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#include<cmath>
#include<cstdint>
// 多倍長整数型
/* ---------------------- ここから ---------------------- */
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
using Real = mp::number<mp::cpp_dec_float<1024>>;
/* ---------------------- ここまで ---------------------- */
     
#define INF 1e9
#define LINF 1e19
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()
#define chmin(a, b) a = min(a, b)
#define chmax(a, b) a = max(a, b)
     
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<ll, ll>;
     
const ll MOD = 1e9 + 7;

int main(){
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    rep(i, n)cin >> a[i];
    ll lb = 0, ub = INF + INF;
    ll mx = 0;
    if(k == 0){
      rep(i, n)chmax(mx, a[i]);
      cout << mx << endl;
      return 0;
    }

    while(ub - lb > 1){
        ll mid = (ub + lb) / 2;
        ll tmp = 0;
        rep(i, n){
          if(a[i] < mid)continue;
          tmp += ((a[i] + mid - 1) / mid) - 1;
        }
      //cout << mid << " " << tmp << endl;
        if(tmp <= k)ub = mid;
        else lb = mid;
    }
    cout << ub << endl;
}





Measured memory_bytes: 4472
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1e18
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"
int mp[2000][2000];


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int n,x;
  cin>>n>>x;
  rep(i,n) cin>>mp[0][i];
  int ans=INF,sum=0;
  repi(i,1,n){
    sum=0;
    rep(j,n){
      mp[i][j]=min(mp[i-1][j],mp[0][(j-i+n)%n]);
      sum+=mp[i][j];
    }
    ans=min(ans,sum+(x*i));
    //cout<<sum<<endl;
  }

  // cout<<ans<<endl;
  sum=0;
  rep(i,n){
    sum+=mp[0][i];
    // cout<<sum<<endl;
  }
   ans=min(ans,sum);
  cout<<ans<<endl;
    

  return 0;
}


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

const int N = 1e5 + 5;
vector<int> adj[N];
int ans[N];
int vis[N][15];
int v[N], d[N], c[N];
int n, m, q;

void dfs(int u, int d, int c) {
	if (vis[u][d])
		return;
	if (!ans[u])
		ans[u] = c;
	vis[u][d]++;
	if (!d)
		return;
	for (int nxt : adj[u]) {
		dfs(nxt, d - 1, c);
	}
}

int main() {

	int a, b;
	scanf("%d%d", &n, &m);
	for (int i = 0; i < m; i++) {
		scanf("%d%d", &a, &b);
		adj[a].push_back(b);
		adj[b].push_back(a);
	}

	scanf("%d", &q);
	for (int i = 0; i < q; i++) {
		scanf("%d%d%d", &v[i], &d[i], &c[i]);
	}

	for (int i = q - 1; ~i; i--) {
		dfs(v[i], d[i], c[i]);
	}

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

	return 0;
}


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

int main(){
  int n,i;
  cin>>n;
  int h[n];
  for(i=0;i<n;i++) cin>>h[i];

  i=n-1;
  n=h[i];
  for(i=i-1;i>=0;i--){
    if(h[i]<=n) n=h[i];
    else if(h[i]-1==n) continue;
    else break;
  }

  if(i==-1) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

  return 0;
}

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

int main()
{
    int n, f, b;
    ll res = 0;
    cin >> n;

    for(int i = 1; i <= n; ++i)
    {
        f = i % 3 == 0, b = i % 5 == 0;
        
        if(!f && !b) res += i; 
    }

    cout << res << "\n";
    return 0;
}

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

#define FOR(i, a, b) for(int i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(int i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)
#define DEBUG_PRINT(...) fprintf(stderr, __VA_ARGS__)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<int, int> pi;
typedef vector<int> vi;
void print_pair(pi a){
  cerr<<"("<<a.first<<", "<<a.second<<") ";
}
template<int T1, int T2>
void print_2d(int a[T1][T2], int x, int y){
  For(i, x){
    For(j, y){
      cerr<<a[i][j]<<" ";
    }
    cerr<<endl;
  }
}
template<class T>
void print_array(T a[],size_t n){
  cerr<<"array:";
  REP(n-1)cerr<<a[i]<<",";
  cerr<<a[n-1]<<endl;
}

ll A,B,C;

int main(){
  cin>>A>>B>>C;
  ll ans=0;
  if(A+B>=C-1){
    ans=B+C;
  }else{
    ans=B+A+B+1;
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    int A[100][100], b[100], c[100] = {};
    int n, m;
    scanf("%d %d", &n, &m);
    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++){
            scanf("%d", &A[i][j]);
        }
    }
    for(int i=0; i<m; i++){
        scanf("%d", &b[i]);
    }
    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++){
            c[i] += A[i][j]*b[j];
        }
        printf("%d\n", c[i]);
    }
    return 0;
}


Measured memory_bytes: 2112
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        int h = scanner.nextInt();
        int w = scanner.nextInt();
        for (int i = 0; i < h; i++) {
            String c = scanner.next();
            System.out.println(c);
            System.out.println(c);
        }
    }
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int ctoi(const char c) {
    if ('0' <= c && c <= '9') return (c - '0');
    return -1;
}
vector<int> input(int n) {
    vector<int> vec(n);
    for (int i = 0; i < n; i++) {
        cin >> vec.at(i);
    }
    return vec;
}
void output(vector<int> vec) {
    for (int i = 0; i < vec.size(); i++) {
        cout << vec[i] << " ";
    }
    return;
}
vector<vector<int>> input(int n, int m) {
    vector<vector<int>> table(n, vector<int>(m));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> table. at(i).at(j);
        }
    }
    return table;
}
void output(vector<vector<int>> table) {
    for (int i = 0; i < table.size(); i++) {
        for (int j = 0; j < table.at(0).size(); j++) {
            cout << table.at(i).at(j) << " ";
        }
        cout << endl;
    }
}
long long perm(int n, int r) {
    if (n < r) {
        cout << "error" << endl;
        return 0;
    }
    long long perm = 1;
    for (int i = n; i > n - r; i--) {
        perm *= i;
    }
    return perm;
}
long long comb(int n, int r) {
    if (n < r) {
        cout << "error" << endl;
        return 0;
    }
    long long comb = perm(n,r);
    for (int i = r; i > 0; i--) {
        comb /= i;
    }
    return comb;
}
long long homo(int n, int r) {
    return comb(n + r - 1, n - 1);
}
long long fact(int n) {
    long long fact = 1;
    for (int i = n; i > 0; i--) {
        fact *= i;
    }
    return fact;
}
int gcd(int a, int b){
    if (a % b == 0){
        return(b);
    }else{
        return(gcd(b, a % b));
    }
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
bool isprime(int n){
    if (n < 2) return false;
    else if (n == 2) return true;
    else if (n % 2 == 0) return false;

    for (int i = 3; i <= sqrt(n); i += 2){
        if (n % i == 0){
            return false;
        }
    }
    return true;
}
void sayYes(bool f) {
    if (f) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}
void sayYES(bool f) {
    if (f) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
}

int main() {
  int n,d,ans=0;
  cin >> n >> d;
  vector<vector<int>> table=input(n,d);
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      int norm=0;
      for(int k=0;k<d;k++){
        int diff=abs(table[i][k]-table[j][k]);
        norm+=diff*diff;
      }
      bool f=false;
      for(int k=0;k<=norm;k++){
        if(k*k==norm){
          f=true;
        }
      }
      if(f){
        ans++;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
using namespace std;
int main(){
int n,a[1000][3],i,j,g=0,t,z;
scanf("%d",&n);
for(z=0;z<n;z++){
scanf("%d %d %d",&a[z][0],&a[z][1],&a[z][2]);
for(i=0;i<3;i++){
	for(j=i+1;j<3;j++){
		if(a[z][i]>a[z][j]){
			t=a[z][i];
			a[z][i]=a[z][j];
			a[z][j]=t;
		}
	}
}
}
for(i=0;i<n;i++){
	for(j=0;j<n;j++){
		if(a[i][0]==0||i==j){
			break;
		}
		if(a[j][0]==0){
			t=i;
		}
		else if(a[i][0]==a[j][0]&&a[i][1]==a[j][1]&&a[i][2]==a[j][2]){
		g++;
		a[j][0]=0;
		}
	}
}
printf("%d\n",g);
return 0;
}

Measured memory_bytes: 3224
#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 - 1; 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)

ll mod = 1e09;

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

  char x, y;
  cin >> x >> y;

  for(char c = 'A'; c <= 'F'; c++){
    if(c == x && c == y){
      cout << '=' << endl;
      return 0;
    }
    else if(c == x){
      cout << '<' << endl;
      return 0;
    }
    else if(c == y){
      cout << '>' << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 256
n = int(input())
m = len(str(n))
ans = 0

if m % 2 == 0:
  m = m-1
else:
  ans += n-10**(m-1)+1
  m = m-2

while m > 0:
  ans += 10**m-10**(m-1)
  m = m-2

print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    string S;
    cin >> S;
    int ans = 0;
    rep(0, i, 3)
    {
        if (S[i] == '1')
        {
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#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(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define bit(n) (1<<(n))
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template < typename T > string tost( const T& n ) { ostringstream stm; stm << n; return stm.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;}
int const INF = 1001001001;


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

string S; cin >> S;
cout << "ABC" + S << endl;

return 0;
}

Measured memory_bytes: 256
import numpy as np
n, k = list(map(int,input().split()))

ans = 0
mut_ori = n//k
for a in range(1, k + 1):
    b_cand = list(range(k - a%k,k+1,k))
    for b in b_cand:
        c_cand = list(range(k - b%k,n+1,k))
        for c in c_cand:
            if a <= n%k:
                mut = mut_ori + 1
            else:
                mut = mut_ori
            if b <= n%k:
                mut *= (mut_ori + 1)
            else:
                mut *= mut
            if (a + c) % k == 0:
                ans += mut
#             print(a,b,c,mut)
print(ans)



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

#define pb     push_back
#define mp     make_pair
#define all(v) v.begin() , v.end()
#define allr(v) v.rbegin(), v.rend()
const ll INF =  0x3f3f3f3f;
const int MOD = 1e9+7;
const int MAX = 2e5+5;

int n, m, a, b;
vector<bool> reach1(MAX, false);
vector<bool> reach2(MAX, false);


int main(int argc, char const *argv[])
{
  ios_base::sync_with_stdio(false);
  
  // #ifndef ONLINE_JUDGE
  // freopen("in","r",stdin);
  // freopen("out","w",stdout);
  // #endif

  bool poss = false;

  scanf("%d %d" , &n, &m);
  for(int i = 1 ; i <= m ; i++){
  	scanf("%d %d" , &a, &b);
  	if(a == 1)
  		reach1[b] = true;
  	else if(b == n)
  		reach2[a] = true;
  }

  for(int i = 1 ; i <= n ; i++){
  	if(reach1[i] && reach2[i])
  		poss = true;
  }

  if(poss)
  	printf("POSSIBLE");
  else
  	printf("IMPOSSIBLE");		



  return 0;
} 

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		while(true){
			int n = in.nextInt();
			if(n==0) break;
			int[] k = new int[n];
			for(int i=0; i<n; i++){
				k[i] = in.nextInt();
			}
			char[] s = in.next().toCharArray();
//			int[] num = new int[s.length];
			for(int i=0; i<s.length; i++){
				int val = 'a'<=s[i]&&s[i]<='z'?s[i]-'a' : s[i]-'A'+26;
				val = (val + 52 - k[i%n])%52;
				s[i] = (char) ((val < 26)? 'a'+val: 'A'+val-26);
			}
			System.out.println(String.valueOf(s));
		}
	}
}

Measured memory_bytes: 25060
package main

import "fmt"

func main() {
	var N, p int
	fmt.Scan(&N)

	var max, add int
	for i := 0; i < N; i++ {
		fmt.Scan(&p)
		add += p
		if max < p {
			max = p
		}
	}

	fmt.Println(add - max/2)
}


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

static const int sgn[8][3] = {{1, 1, 1}, {1, 1, -1}, {1, -1, 1}, {1, -1, -1},
  {-1, 1, 1}, {-1, 1, -1}, {-1, -1, 1}, {-1, -1, -1}};

int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  vector<vector<long long>> a(n, vector<long long>(3));
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < 3; ++j)
      scanf("%lld", &a[i][j]);

  long long ans = 0;
  for (int i = 0; i < 8; ++i) {
    vector<long long> t(n);
    for (int j = 0; j < n; ++j) {
      long long s = 0;
      for (int k = 0; k < 3; ++k)
        s += a[j][k] * sgn[i][k];
      t[j] = s;
    }
    sort(t.begin(), t.end(), greater<long long>());
    long long s = 0;
    for (int j = 0; j < m; ++j)
      s += t[j];
    ans = max(ans, s);
  }
  printf("%lld\n", ans);
  
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

// 最大積載量がPのとき運べる荷物の数を求める
int loadable(int n, int k, int w[], int P) {
    int i;
    int j = 0;
    for (i = 1; i <= k; i++) {
        int sum = 0;
        while (sum + w[j] <= P) {
            sum += w[j];
            j++;
            if (j == n) {
                return j;
            }
        }
    }
    return j;
}

// 荷物をすべて運べる最小の最大積載量Pを求める
int min(int n, int k, int w[]) {
    int left = 0;
    int right = 100000 * 10000; // 確実に運べる積載量
    while (right - left > 1) {
        int mid = (left + right) / 2;
        if (loadable(n, k, w, mid) < n) {
            left = mid;
        } else {
            right = mid;
        }
    }
    return right;
}

int main(void) {
    int i, n, k;
    int w[100000];
    scanf("%d %d", &n, &k);
    for (i = 0; i < n; i++) {
        scanf("%d", &w[i]);
    }
    printf("%d\n", min(n, k, w));
    return 0;
}



Measured memory_bytes: 2248
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <cmath>   
#include<cctype>
#include<string>
#include<set>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <typeinfo>
#include <utility> 

#define rep(i,m,n) for(int i = m;i < n;++i)
using namespace std;
using ll = long long;
using R = double;
const ll inf = 1LL << 50;
const ll MOD = 1e9 + 7;

struct edge { ll to; ll from; ll cost; };
bool comp(const edge& e1, const edge& e2) {
	return e1.cost < e2.cost;
}


ll V, E;


class UnionFind {
public:
	vector<int> r, p;

	UnionFind() {}
	UnionFind(int size) {
		r.resize(size, 0);
		p.resize(size, 0);
		rep(i, 0, size)makeSet(i);
	}

	void makeSet(int x) {
		p[x] = x;
		r[x] = 0;
	}

	bool same(int x, int y) {
		return findSet(x) == findSet(y);
	}

	void unite(int x, int y) {
		link(findSet(x), findSet(y));
	}

	void link(int x, int y) {
		if (r[x] > r[y]) {
			p[y] = x;
		}
		else {
			p[x] = y;
			if (x == y) {
				r[y]++;
			}
		}
	}


	int findSet(int x) {
		if (x == p[x]) {
			return x;
		}
		else {
			return p[x] = findSet(p[x]);
		}
	}
};



ll kruskal(vector<edge>edges) {
	sort(edges.begin(), edges.end(),comp);
	UnionFind un = UnionFind(V);
	ll res = 0;
	rep(i, 0, edges.size()) {
		edge e = edges[i];
		if (!un.same(e.from, e.to)) {
			un.unite(e.from, e.to);
			res += e.cost;
		}
	}
	return res;
}

int main() {
	cin >> V;
	vector<pair<ll,ll>>x_d;
	vector<pair<ll,ll>>y_d;
	vector<edge>edges;

	rep(i, 0, V) {
		ll x, y;
		cin >> x >> y;
		x_d.push_back({ x,i });
		y_d.push_back({ y,i });
	}

	sort(x_d.begin(), x_d.end());
	sort(y_d.begin(), y_d.end());
	
	rep(i, 0, V - 1) {
		edges.push_back({x_d[i].second,x_d[i+1].second,x_d[i+1].first- x_d[i].first });
		edges.push_back({x_d[i+1].second,x_d[i].second,x_d[i + 1].first - x_d[i].first });
		edges.push_back({y_d[i].second,y_d[i + 1].second,y_d[i + 1].first - y_d[i].first });
		edges.push_back({y_d[i+1].second,y_d[i].second,y_d[i + 1].first - y_d[i].first });
	}


	cout << kruskal(edges) << endl;

}

Measured memory_bytes: 25688
n = int(input())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
c = [int(x) for x in input().split()]


a.sort()
c.sort()

from bisect import bisect_left,bisect_right
cnt = 0
for i in b:
    cnt += bisect_left(a,i)*(n-bisect_right(c,i))

print(cnt)

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

main(){
	int n ;
	int p[1010][5] ;
	int P[4] ;
	while( cin >> n , n ){
		for( int i=0 ; i<n ; i++ ){
			for( int j=0 ; j<4 ; j++ ) cin >> p[i][j] ;
			p[i][4] = p[i][1]*4 + p[i][2]*9 + p[i][3]*4 ;
		}
		for( int j=0 ; j<4 ; j++ ) cin >> P[j] ;
		
		int c=0 ;
		for( int i=0 ; i<n ; i++ ){
			int cnt = 0 ;
			for( int j=0 ; j<4 ; j++ ){
				if( p[i][j+1] <= P[j] ) cnt++ ;
			}
			if( cnt==4 ){
				cout << p[i][0] << endl ;
				c++ ;
			}
		}
		
		if( !c ) cout << "NA" << endl ;
		
	}
}

Measured memory_bytes: 1180
//! ----------------------------------------------
//! Framework <https://github.com/vain0x/procon>
//!
//! See the bottom of file for solution.
//! ----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn main() {
    let A = read!(usize);
    let B = read!(usize);

    println!("{}", 1 ^ 2 ^ 3 ^ A ^ B)
}


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

#define SAFE_DELETE( x ) { if ( x ){ delete x; x = NULL; } }
#define SAFE_DELETE_ARRAY( x ) { if ( x ){ delete[] x; x = NULL; } }

struct tCell{
	tCell() : board( NULL ), prev( NULL ), next( NULL ){}

	int* board;
	tCell *prev, *next;
};

class MyArray{
public:
	MyArray() : mSize( 0 ), head( NULL ), tail( NULL ){
		head = new tCell;
		tail = new tCell;
		head->next = tail;
		tail->prev = head;
	}
	~MyArray(){
		for ( int i = mSize; i > 0; --i ){
			tCell* cell = tail->prev;
			SAFE_DELETE_ARRAY( cell->board );
			cell->prev->next = cell->next;
			cell->next->prev = cell->prev;
			SAFE_DELETE( cell );
		}
		SAFE_DELETE( tail );
		SAFE_DELETE( head );
	}

	void pushBack( int* b ){
		++mSize;
		tCell* cell = new tCell;
		cell->board = b;
		cell->prev = tail->prev;
		cell->next = tail;
		cell->prev->next = cell;
		cell->next->prev = cell;
	}
	int size(){ return mSize; }

	tCell operator[]( int d ){
		tCell* cell = head->next;
		if ( d >= mSize ){
			cell = NULL;
			return *cell;
		}
		for ( int i = 0; i < d; ++i ){
			cell = cell->next;
		}
		return *cell;
	}

private:
	int mSize;
	tCell *head, *tail;
};

string checkModel( int* b ){
	string model;
	bool find = false;
	int x = 0, y = 0;
	for ( y = 0; y < 10; ++y ){
		for ( x = 0; x < 10; ++x ){
			if( b[ y*10 + x ] ){
				find = true;
				break;
			}
		} if ( find ) break;
	}

	if ( b[ y*10 + ( x+1 ) ] ){	//model A, C, E, G
		if ( b[ y*10 + ( x+2 ) ] ){	//model C
			model = "C";
		}else if ( b[ ( y+1 )*10 + ( x-1 ) ] ){	//model G
			model = "G";
		}else if ( b[ ( y+1 )*10 + ( x+2 ) ] ){	//model E
			model = "E";
		}else{	//model A
			model = "A";
		}
	}else{	//model B, D, F
		if ( b[ ( y+2 )*10 + x ] ){	//model B
			model = "B";
		}else if ( b[ (y+2)*10 + ( x-1 ) ] ){	//model D
			model = "D";
		}else{	//model F
			model = "F";
		}
	}

	return model;
}

int main(){
	bool first = true;
	int cnt = 0;
	int* board;
	string s;
	MyArray ma;

	while ( cin >> s ){
		if( first ){
			board = new int[ 10 * 10 ];
			for ( int i = 0; i < 10*10; ++i ){
				board[ i ] = 0;
			}
			cnt = 0;
			first = false;
		}
		for ( int i = 0; i < 8; ++i ){
			board[ (cnt+1)*10 + i+1 ] = static_cast< int >( s[ i ] - '0' );
		}

		++cnt;
		if ( cnt == 8 ){
			ma.pushBack( board );
			board = NULL;
			first = true;
		}
	}

	for ( int i = 0; i < ma.size(); ++i ){
		cout << checkModel( ma[ i ].board ) << endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define ENDL '\n'
#define all(a) begin(a), end(a)
#define sz(a) (int)(a.size())
#define deb(a) cout << #a << ": " << a << ENDL
#define fore(i, a, b) for(int i(a), ThkMk(b); i < ThkMk; ++i)
#define _ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

typedef long long lli;
typedef long double ld;
typedef unsigned long long ulli;
typedef pair<lli, lli> ii;
typedef vector<lli> vi;

struct SegTree{
    #define mid ( l + r ) / 2
    #define left(u) (u + 1)
    #define right(u) (u + ((mid - l + 1) << 1))

    struct Node{
        lli s;
        Node(lli s = 0): s(s){}
        Node operator+(const Node &n) const {
            return Node(max(s, n.s));
        }
    };

    int n;
    Node z;
    vector<Node> st;

    SegTree(int n): n(n) {
        st.resize(2 * n);
    }
    void update(int u, int l, int r, int kth, lli v) {
        if( l == r) {
            st[u].s = v;
            return;
        }
        if( kth <= mid ) {
            update(left(u), l, mid, kth, v);
        } else {
            update(right(u), mid + 1, r, kth, v);
        }
        st[u] = st[left(u)] + st[right(u)];
    }
    lli query(int u, int l, int r, int ll, int rr) {
        if( r < ll || rr < l || r < l) return 0;
        if( ll <= l and r <= rr) return st[u].s;
        return  max(query(left(u), l, mid, ll, rr),query(right(u), mid + 1, r, ll, rr));
    }
};


int main()
{   _
    lli MX = 3e5 + 5;
    SegTree segtree(MX);
   /// fore(i, 0, MX) segtree.update(0, 0, MX - 1, i, 0);
    lli n, k, m; cin >> n >> k;
    fore(i, 0, n) {
        cin >> m;
        lli l = max(0LL, m - k);
        lli r = min(MX - 1LL, m + k);
        lli mx  = segtree.query(0, 0, MX - 1, l, r);
        segtree.update(0, 0, MX - 1, m, mx + 1);
    }
    cout << segtree.query(0, 0, MX - 1, 0, MX - 1) << ENDL;
    return 0;
}


Measured memory_bytes: 7896
#include<stdio.h>

int main(){
 int A,B,C;
  scanf("%d %d",&A,&B);
  if(A>=B){
   C=A;
    A--;
  }else{
   C=B;
    B--;
  }
  if(A>=B){
   C+=A; 
  }else{
   C+=B;
  }
  printf("%d\n",C);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
 
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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

int main(){
    int n,a,b;
    cin>>n>>a>>b;
    if(abs(a-b)%2==0) cout<<"Alice"<<endl;
    else cout<<"Borys"<<endl;
    
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.lang.*;

public class Main {
    static final int INF = 1000000000;     
    
    public static void main(String[] args) throws Exception {                
        Scanner input = new Scanner(System.in);
        int a, b;
        a = input.nextInt();
        b = input.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: 17352
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;

ll func(ll n, ll x){
  if(n==-1) return 0;
  else return n/x+1;
}

int main() {
	ll a, b, x;
	cin >> a >> b >> x;
  cout << func(b, x) - func(a-1, x) << endl;
}

Measured memory_bytes: 256
//#include<bits\stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstring>
#include<string>
#include<ctime>
#include<cmath>
#include<cctype>
#include<cstdlib>
#include<queue>
#include<deque>
#include<stack>
#include<vector>
#include<algorithm>
#include<utility>
#include<bitset>
#include<set>
#include<map>
#define ll long long
#define db double
#define INF 10000000000000010ll
#define ldb long double
#define pb push_back
#define put_(x) printf("%d ",x);
#define get(x) x=read()
#define gt(x) scanf("%d",&x)
#define gi(x) scanf("%lf",&x)
#define put(x) printf("%d\n",x)
#define putl(x) printf("%lld\n",x)
#define gc(a) scanf("%s",a+1)
#define rep(p,n,i) for(RE int i=p;i<=n;++i)
#define go(x) for(int i=lin[x],tn=ver[i];i;tn=ver[i=nex[i]])
#define fep(n,p,i) for(RE int i=n;i>=p;--i)
#define vep(p,n,i) for(RE int i=p;i<n;++i)
#define pii pair<int,int>
#define mk make_pair
#define RE register
#define P 1000000007
#define gf(x) scanf("%lf",&x)
#define pf(x) ((x)*(x))
#define uint unsigned long long
#define ui unsigned
#define EPS 1e-8
#define sq sqrt
#define S second
#define F first
#define mod 998244353
using namespace std;
char buf[1<<15],*fs,*ft;
inline char getc()
{
    return (fs==ft&&(ft=(fs=buf)+fread(buf,1,1<<15,stdin),fs==ft))?0:*fs++;
}
inline int read()
{
    RE int x=0,f=1;RE char ch=getc();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getc();}
    while(ch>='0'&&ch<='9'){x=((ll)x*10+ch-'0')%mod;ch=getc();}
    return x*f;
}
const int MAXN=110,G=3;
int n,m;
char a[MAXN][MAXN];
int f[MAXN][MAXN];
int main()
{
	//freopen("1.in","r",stdin);
	gt(n);gt(m);
	rep(1,n,i)scanf("%s",a[i]+1);
	memset(f,0x3f,sizeof(f));
	f[1][1]=a[1][1]=='#';
	rep(1,n,i)rep(1,m,j)
	{
		if(i-1>=1)f[i][j]=min(f[i][j],f[i-1][j]+(a[i-1][j]==a[i][j]?0:a[i][j]=='#'));
		if(j-1>=1)f[i][j]=min(f[i][j],f[i][j-1]+(a[i][j-1]==a[i][j]?0:a[i][j]=='#'));
	}
	put(f[n][m]);
	return 0;
}


Measured memory_bytes: 3868
import sys
sys.setrecursionlimit(10**6)

n = int(input())

d = {(i-97+1):chr(i) for i in range(97,97+26)}
d[0] = 'z'

l = []

while n > 0:
    tmp = n%26
    l.append(tmp)
    if tmp == 0:
        n = n//26-1
    else:
        n //= 26

ans = ''

for i in l[::-1]:
    ans += d[i]
    
print(ans)

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

int main() {
    int a, b;
    cin >> a >> b;
    cout << max({a+b,a-b,a*b}) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
using namespace std;
const double PI = acos(-1.0);
const string alp = "abcdefghijklmnopqrstuvwxyz";
const string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n+1)
#define SUM(c) accumulate((c).begin(),(c).end(),0)
#define UNIQ(c) (c).erase(unique((c).begin(), (c).end()), (c).end());
#define Yn(b) puts(b?"Yes":"No")
#define YN(b) puts(b?"YES":"NO")
 
bool isprime(int p) {
  if (p==1) return false;
  FOR(i,2,p) {
    if (p%i==0) return false;
  }
  return true;
}
 
int main(){
  int a,b;
  string s;
  cin >> a >> b >> s;
  REP(i,s.length()){
    if(i==a) {
      if (s[i]!='-') {
        puts("No");
        return 0;
      }
    } else {
      if (s[i]=='-') {
        puts("No");
        return 0;
      }
    }
  }
  puts("Yes");
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <sstream>
#include <cmath>
#include <climits>
#include <set>
#include <map>

using namespace std;

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

typedef vector<int> vi;

int main()
{
	int n;
	scanf("%d%*c", &n);
	rep(i, n){
		char str[258];
		fgets(str, 258, stdin);

		set<string> words;
		stringstream stin(str);
		string tmp;
		while(stin >> tmp){
			if(tmp.size() == 4)
				words.insert(tmp);
		}

		int alpha=0, beta=0;
		bool keep = true;
		for(int i=1; keep; ++i){
			if(i%2==0 || i%13==0)
				continue;
			rep(j, 26){
				char samples[][5] = {"that", "this"};
				rep(k, 2){
					rep(l, 4) samples[k][l] = ((samples[k][l]-'a')*i+j)%26+'a';
					if(words.count(string(samples[k]))){
						alpha = i;
						beta = j;
						j=100;
						keep = false;
						break;
					}
				}
			}
		}

		map<char, char> conv;
		rep(i, 26)
			conv.insert(make_pair((i*alpha+beta)%26+'a', i+'a'));
		rep(i, strlen(str))
			putchar(isalpha(str[i]) ? conv[str[i]] : str[i]);
	}

	return 0;
}

Measured memory_bytes: 0
class Main{public static void main(String[]z){java.util.Scanner s=new java.util.Scanner(System.in);for(int n,i,j,b,c,k,r,g[],p;(i=r=n=s.nextInt())>0;System.out.println(r>0?"No":"Yes")){for(g=new int[n],p=210;i-->0;)g[i]=s.nextInt()+20*s.nextInt();for(i=s.nextInt();i-->0;p+=k*b){c=k=1;switch(s.next().charAt(0)){case'N':k=-1;case'S':k*=-20;c=0;break;case'W':k=-1;}for(j=n,b=s.nextInt();j-->0;)if((k<0?p+k*b<=g[j]&&g[j]<=p:p<=g[j]&&g[j]<=p+k*b)&&(c>0||(g[j]-p)%k==0))r+=g[j]=-1;}}}}

Measured memory_bytes: 32984
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "functional"
#include "ctime"

using namespace std;

//constexpr long long int MOD = 1000000007;
constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-8;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;



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

	cin >> H >> W;
	vector<vector<int>>v(H, vector<int>(W));
	for (auto &i : v)for (auto &j : i)cin >> j;
	vector<int>from;
	vector<int>to;
	vector<string>cost;
	for (int i = 0; i < 200; i++) {
		from.push_back(i + 1);
		to.push_back(i + 2);
		if (i < 100)cost.push_back("X");
		else cost.push_back("Y");
	}
	for (int i = 0; i < H*W; i++) {
		int h = i / W;
		int w = i % W;
		h++;
		w++;
		int nj = -1;
		int nk = -1;
		for (int j = 0; j <= 100; j++) {
			for (int k = 0; j + k <= 100&&k<100; k++) {
				int add = v[h - 1][w - 1] - j * h - k * w;
				if (add < 0)continue;
				if (!i&&add)continue;
				bool flag = true;
				for (int l = 0; l < H*W; l++) {
					if (i == l)continue;
					int nh = l / W;
					int nw = l % W;
					nh++;
					nw++;
					if (j*nh + k * nw + add < v[nh - 1][nw - 1]) {
						flag = false;
					}
				}
				if (flag) {
					nj = j;
					nk = k;
				}
			}
		}
		if (nj == -1) {
			cout << "Impossible\n";
			return 0;
		}
		//cout << i << endl;
		if (!i) {
			from.push_back(nj + 1);
			to.push_back(201 - nk);
			cost.push_back(to_string(0));
		}
		else {
			//	cout << i << endl;
			from.push_back(nj + 1);
			to.push_back(201 + i);
			cost.push_back(to_string(0));
			from.push_back(201 + i);
			to.push_back(201 - nk);
			cost.push_back(to_string(v[h - 1][w - 1] - nj * h - nk * w));
		}
	}
	cout << "Possible\n";
	cout << 200 + H * W << " " << from.size() << endl;
	for (int i = 0; i < from.size(); i++) {
		cout << from[i] << " " << to[i] << " " << cost[i] << endl;
	}
	cout << 1 << " " << 201 << endl;
}

Measured memory_bytes: 256
'use strict'

const main = (INPUT) => {
  const input = INPUT.split('\n')[0].split(' ').map(n => Number(n))
  const N = input[0]
  const P = input[1]

  let ans
  if (N == 1) {
    ans = P
  } else {
    for (let i = 0; Math.pow(i, N) <= P; i++) {
      if (P % Math.pow(i, N) == 0) {
        ans = i
      }
    }
  }
  console.log(ans)
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 9932
n,x=map(int,input().split())
a=[int(i)for i in input().split()]
c=0
if a[0]>x:
  c=a[0]-x
  a[0]=x
for i in range(n-1):
  if a[i]+a[i+1]>x:
    c+=a[i]+a[i+1]-x
    a[i+1]=x-a[i]
print(c)

Measured memory_bytes: 14132
N, Y = map(int, input().split())
check = 0
for i in range(N + 1):
    if check == 1: break
    for j in range(N - i + 1):
        k = N - i - j
        if 10000 * i + 5000 * j + 1000 * k == Y:
            print(str(i) + ' ' + str(j) + ' ' + str(k))
            check = 1
            break
if check == 0: print("-1 -1 -1")

Measured memory_bytes: 3064
fun main(args:Array<String>) {
    val (h,n) = readLine()!!.split(" ").map(String::toInt)
    val al:List<Int> = readLine()!!.split(" ").map(String::toInt)
    if (h > al.sum()) {
        println("No")
    }
    else {
        println("Yes")
    }
}

Measured memory_bytes: 48812
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <iomanip>
#include <string>
#include <queue>
#include <numeric>
#include <functional>
#include <array>
#include <map>
#include <set>

#define INF 1000000007 //1000000000000000003
#define MOD 1000000007
#define MAX 2000005

#define ll long long

//printf("%.10f", );
//cout << fixed << setprecision(10) << heikin << endl;
//vector<vector<int>> data(3, vector<int>(4, -1));
//left + 1 < top

using namespace std;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using edge = struct { int to; long long dist; };
const double PI = 3.141592653589793;
long long fact[MAX], inv[MAX];
int dx[] = { -1,0,1,0 };
int dy[] = { 0,-1,0,1 };

//////////////////////////////////

vector<vector<int>> tree(100005);
int color[100005];
map<P, int>colorMap;
int m = 0;

struct BridgeInfo {
	int town1;
	int town2;
	int year;
	BridgeInfo(int t1, int t2, int y) {
		town1 = t1;
		town2 = t2;
		year = y;
	}
};

struct People {
	int index;
	int town;
	int year;
	People(int i, int t, int y) {
		index = i;
		town = t;
		year = y;
	}
};

bool compare_by_second(pair<int, int> a, pair<int, int> b) {
	if (a.second != b.second) {
		return a.second < b.second;
	}
	else {
		return a.first < b.first;
	}
}

struct UnionFind {
	vector<int>uf;
	
	UnionFind(int size) :uf(size, -1) {};

	int root(int target) {
		if (uf[target] < 0)return target;
		else return uf[target] = root(uf[target]);
	}

	void merge(int a, int b) {
		a = root(a);
		b = root(b);
		if (a == b)return;
		if (uf[b] < uf[a])swap(a, b);
		uf[a] += uf[b];
		uf[b] = a;
	}
};

ll CalcPow(ll num, ll power) {
	if (power == 0)return 1;
	if (power % 2 == 0) {
		ll half = CalcPow(num, power / 2);
		return (half * half) % MOD;
	}
	else return (num * CalcPow(num, power - 1)) % MOD;
}

ll combination(ll all, ll select) {
	if (all < select) return 0;
	if (all < 0 || select < 0) return 0;
	return fact[all] * (inv[select] * inv[all - select] % MOD) % MOD;
}

void initCombination(int max) {
	fact[0] = fact[1] = 1;
	for (int i = 2; i <= max; ++i) {
		fact[i] = fact[i-1] * i % MOD;
	}

	inv[max] = CalcPow(fact[max], MOD - 2);
	for (int i = max - 1; 0 <= i; --i) {
		inv[i] = (inv[i + 1] * (i + 1)) % MOD;
	}
}

void dfs(int from) {
	int c = 1;
	for (auto t : tree[from]) {
		c = c != color[from] ? c : c + 1;
		color[t] = c;
		colorMap[make_pair(from, t)] = c;
		m = max(c, m);
		dfs(t);
		c++;
	}
}

int main() {
	ll H;
	cin >> H;
	ll ans = 0;
	ll count = 0;
	while (1 < H) {
		H /= 2;
		ans += pow(2, count);
		count++;
	}
	ans += pow(2, count);
	cout << ans << endl;
}

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

int main(){
	string s1, s2;
	cin >> s1;
	cin >> s2;

	string ss1(s1), ss2(s2);
	reverse(ss1.begin(), ss1.end());
	reverse(ss2.begin(), ss2.end());


	if(s1 == ss2 && s2 == ss1) {
		cout << "YES\n";
	}else
		cout << "NO\n";


	return 0;
}


Measured memory_bytes: 256
//#pragma GCC target ("avx2")
//#pragma GCC optimize ("Ofast")
//#pragma GCC optimize ("unroll-loops")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define int long long

using namespace std;
using namespace __gnu_pbds;

template <class T> using ordered_set =
tree<T, null_type, less<T>,
rb_tree_tag, tree_order_statistics_node_update>;

const int N = (int)(1e6 + 5);
const int M = (int)(1e9 + 7);
const int INF = (int)(1e18 + 9);
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};

signed main() {
  ios_base :: sync_with_stdio(0);
  cin.tie(0);
  int r, d, x;
  cin >> r >> d >> x;
  for (int i = 1; i <= 10; ++i) {
    cout << x * r - d << "\n";
    x = x * r - d;
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
#include<vector>
#define vi vector<int>
#define lli long long int
#define fo(i,n) for(int i=1;i<=n;i++)
#define foo(i,n) for(int i=0;i<n;i++)
#define ff first
#define ss second
#define pb push_back
#define vii vector<lli>

#define ok ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
#define vp vector<pair<lli,lli>>
#include <map>           
lli mod=1000000007;      

//vi r(300003),c(300003);   

vii row(300004),col(300004);
map<lli,lli> points;
vii candx,candy;

lli has(lli x,lli y){
return x*1000000000000+y;
}

int main(){
    lli r,c,m;
    lli maxr,maxc;
    bool flag=true;
    maxr=maxc=0;
    cin>>r>>c>>m;
    foo(i,m){
    	lli x,y;
    	cin>>x>>y;
    	row[x]++;
    	col[y]++;
    	points[has(x,y)]++;
	}
	fo(i,r){
		maxr=max(maxr,row[i]);
	}
	fo(i,c){
		maxc=max(maxc,col[i]);
	}
	lli ans=maxr+maxc-1;
	
	fo(i,r){
		if(row[i]==maxr) candx.pb(i);
	}
	fo(i,c){
		if(col[i]==maxc) candy.pb(i);
	}
	
	foo(i,candx.size()){
		foo(j,candy.size()){
			if(points.find(has(candx[i],candy[j]))==points.end()){
				flag=false;
				ans++;
				break;
			}
		}
		if(!flag) break;
	}
	
	cout<<ans;
}




Measured memory_bytes: 34960
use text_io::*;
use std::collections::HashMap;
use std::process::exit;

fn main() {
    let t:usize = read!();
    let a:usize = read!();
    let b:usize = read!();
    if t*a<b {
        println!("{}",t*a);
    }
    else {
        println!("{}",b);
    }
}

Measured memory_bytes: 2136