akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(), T = sc.nextInt(), H = sc.nextInt(), l = sc.nextInt();
		int t[] = new int[n], h[] = new int[n];
		int min = 7754666, m = 0;
		int a;
		int money = 0;
		for(int i=0;i<n;i++){
			t[i] = sc.nextInt();
			h[i] = sc.nextInt();
			if(min > t[i]){
				min = t[i];
				m = i;
			}
		}

		a = n*(min-1)+m+1;

		int i=0; flag: while(true){
			if(t[i] > 0){
				T++;
				t[i]--;
				money += 10;
			}else if(h[i] > 0){
				H++;
				h[i]--;
				money += 100;
			}else{
				break flag;
			}

			if(T > l)
				break flag;

			if(money >= 90){
				if(T*10 < money - 90)
					break flag;
				else{
					T -= money/10 - 9;
					t[i] += money/10 - 9;
					money = 0;
				}
			}

			i = (i+1)%n;
		}

		System.out.println(i+1);
	}
}

Measured memory_bytes: 26436
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(all(x));
#define RSORT(x) sort(rall(x));
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int inf = 1<<29;
const ll mod = 1000000007;
const double eps = 1e-9;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

int main () {
  int N; cin >> N;
  vi H(N); rep(i,N) cin >> H.at(i);

  bool flag = true;
  bool cantsage = false;
  rep(i,N-1) {
    if(H.at(i)-H.at(i+1)<0) {
      cantsage = false;
    }
    else if(H.at(i)-H.at(i+1)==1) {
      if(cantsage) {
        flag = false;
        break;
      }
      H.at(i) -= 1;
      cantsage = true;
    }
    else if(H.at(i)-H.at(i+1)>1) {
      flag = false;
      break;
    }
  }
  cout << (flag?"Yes":"No") << endl;
}

Measured memory_bytes: 640
#include<iostream>
#include<functional>
#include<algorithm>

using namespace std;

int N, C;
int D[33][33];

int c[505][505];

long long int Cost[3][33];

int main(void) {

	cin >> N >> C;

	int tmp;
	for (int i = 1; i <= C; i++) {
		for (int j = 1; j <= C; j++) {
			cin >> tmp;
			D[i][j] = tmp;
		}
	}

	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= N; j++) {
			cin >> tmp;
			c[i][j] = tmp;
		}
	}


	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= N; j++) {
			for (int k = 1; k <= C; k++) {
				Cost[(i + j) % 3][k] += D[c[i][j]][k];
			}
		}
	}

	long long int min_val = 99999999999;

	int R[3];
	long long int sum;
	for (int I = 1; I <= C; I++) {
		for (int J = 1; J <= C; J++) {
			if (I == J) { continue; }
			for (int K = 1; K <= C; K++) {
				if (I == K || J == K) { continue; }
				//===============================//
				/*R[0] = I; R[1] = J; R[2] = K;
				sum = 0;
				for (int i = 1; i <= N; i++) {
					for (int j = 1; j <= N; j++) {
						sum += D[c[i][j]][R[(i + j) % 3]];
					}
				}*/
				//===============================//
				sum = Cost[0][I] + Cost[1][J] + Cost[2][K];
				min_val = min(min_val, sum);
			}
		}
	}

	cout << min_val << endl;

	//system("pause");
	return 0;
};

Measured memory_bytes: 1280
let words str =
  let len = String.length str in
  let buf = Buffer.create 10 in
  let rec loop acc = function
      i when i = len -> acc, (Buffer.contents buf |> int_of_string)
    | i ->
      loop
        (match str.[i] with
         | ' ' ->
           let v = Buffer.contents buf |> int_of_string in
           Buffer.clear buf; v
         | c ->
           Buffer.add_char buf c; acc)
        (i+1)
  in loop 0 0

let bsearch predicate maxv =
  let rec loop minp maxp =
    match compare minp maxp with
      0 -> minp
    | _ ->
      let middle =
        match maxp+minp with
          v when v mod 2 = 0 -> v/2
        | v -> v/2 + 1 in
      if middle = maxp then (if predicate minp then minp else maxp) else
        match predicate middle with
          true -> loop minp middle
        | false -> loop middle maxp
  in
  loop 1 maxv


let check num_of_truck goods capacity =
  let rec loop acc = function
      _, [] -> true
    | 0, _  -> false
    | rem_truck, (first::rest as l) -> match first+acc with
        x when x > capacity -> loop 0 (rem_truck-1,l)
      | x -> loop x (rem_truck,rest)
  in
  loop 0 (num_of_truck,goods)

let set_goods n =
  let rec loop acc sum = function
      0 -> acc,sum
    | i ->
      let v = read_int () in
      loop (v::acc) (sum+v) (i-1)
  in
  loop [] 0 n

let abc sum goods =
  print_endline "fin"
    
let () =
  let n,num_of_truck = read_line () |> words in
  let goods,sum = set_goods n in
  bsearch (check num_of_truck goods) sum |> Printf.printf "%d\n"

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

using namespace std;

struct INFO {
	int zhou,ord;
	bool operator < (const INFO &b) const {
		return zhou < b.zhou;
	}
}X[100010],Y[100010];
int N,fa[100010];

int fin (int u) {
	if(fa[u] == u)
		return u;
	return fa[u] = fin(fa[u]);
}

struct edge {
	int u,v,w;
	bool operator < (const edge &b) const {
		return w < b.w;
	}
}e[200010];

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

	for(int i = 1;i <= N;++i) {
		scanf("%d%d",&X[i].zhou,&Y[i].zhou);
		X[i].ord = i;
		Y[i].ord = i;
	}
	sort(X + 1,X + 1 + N);
	sort(Y + 1,Y + 1 + N);

	int l = 0,r = 1000000000;
	int mid,cnt;
	while(l <= r) {
		mid = (l + r) >> 1;
		cnt = 0;
		for(int i = 1;i <= N;++i)
			fa[i] = i;

		for(int i = 2;i <= N;++i) {
			if(X[i].zhou - X[i - 1].zhou <= mid) {
				if(fin(X[i].ord) != fin(X[i - 1].ord)) {
					fa[fin(X[i].ord)] = fin(X[i - 1].ord);
					++cnt;
				}
			}
			if(Y[i].zhou - Y[i - 1].zhou <= mid) {
				if(fin(Y[i].ord) != fin(Y[i - 1].ord)) {
					fa[fin(Y[i].ord)] = fin(Y[i - 1].ord);
					++cnt;
				}
			}
		}
		if(cnt == N - 1)
            r = mid - 1;
		else l = mid + 1;
	}
	mid = r + 1;
	cnt = 0;
	for(int i = 2;i <= N;++i) {
		if(X[i].zhou - X[i - 1].zhou <= mid) {
			e[++cnt].u = X[i].ord;
			e[cnt].v = X[i - 1].ord;
			e[cnt].w = X[i].zhou - X[i - 1].zhou;
		}
		if(Y[i].zhou - Y[i - 1].zhou <= mid) {
			e[++cnt].u = Y[i].ord;
			e[cnt].v = Y[i - 1].ord;
			e[cnt].w = Y[i].zhou - Y[i - 1].zhou;
		}
	}
	int ans = 0;
	sort(e +1,e + 1 + cnt);
	for(int i = 1;i <= N;++i)
		fa[i] = i;
	for(int i = 1;i <= cnt;++i) {
		if(fin(e[i].u) != fin(e[i].v)) {
			fa[fin(e[i].u)] = fin(e[i].v);
			ans += e[i].w;
		}
	}
	printf("%d\n",ans);

}


Measured memory_bytes: 4480
let make_fib_memo () =
  let m = Array.make 45 0 in
  m.(0) <- 1;
  m.(1) <- 1;
  fun n ->
    let rec doit i =
      if m.(i) <> 0 then m.(i)
      else begin
        m.(i) <- doit (i - 2) + doit (i - 1);
        m.(i);
      end in
    doit n

let () =
  let fib_memo = make_fib_memo () in
  read_int () |> fib_memo |> Printf.printf "%d\n"

Measured memory_bytes: 2312
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>

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

    int cnt = 0;
    for(int i = 0;i <= a;i++){
        for(int j = 0;j <= b;j++){
            for(int k = 0;k <=c;k++){
                if(500 * i + 100 * j + 50 * k == x){
                    ++cnt;
                }
            }
        }
    }
    std::cout<<cnt<<std::endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int x = sc.nextInt();
        int[] points = new int[m];

        int left = 0;
        int right = 0;

        for (int point : points) {
            point = sc.nextInt();
            if (point < x) {
                left++;
            } else {
                right++;
            }
        }
        System.out.println(Math.min(left, right));
    }
}


Measured memory_bytes: 23252
# -*- coding: utf-8 -*-


def main():
    """Function."""
    n = int(input())
    a = list(map(int, input().split()))

    counter = 1
    flag, last = 0, a[0]
    for i in range(n-1):
        temp = a[i+1]
        if flag == 0:
            if temp == last:
                pass
            elif temp > last:
                flag = 1
            elif temp < last:
                flag = -1

        if flag == 1:
            if temp == last:
                pass
            elif temp > last:
                pass
            elif temp < last:
                counter += 1
                flag = 0

        if flag == -1:
            if temp == last:
                pass
            elif temp > last:
                counter += 1
                flag = 0
            elif temp < last:
                pass

        last = temp

    print(counter)


if __name__ == "__main__":
    main()


Measured memory_bytes: 14436
import java.io.IOException;
import java.io.InputStream;
import java.util.*;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int n = sc.nextInt();
		int m = sc.nextInt();
		int k = sc.nextInt();
		for (int i = 0; i <= n; i++) {
			for (int j = 0; j <= m; j++) {
				if (n * j + m * i - 2 * i * j == k) {
					System.out.println("Yes");
					return;
				}
			}
		}
		System.out.println("No");
	}
}


class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}
	private int readByte() {
		if (hasNextByte()) {
			return buffer[ptr++];
		} else {
			return -1;
		}
	}
	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}
	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
			ptr++;
		}
		return hasNextByte();
	}
	public String next() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	public long nextLong() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || Integer.MAX_VALUE < nl) {
			throw new NumberFormatException();
		}
		return (int) nl;
	}
	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  ll N;
  cin >> N;
  ll M = N%11;
  ll ans = 0;
  if(M>6)
  {
    ans += 2;
  }
  else if(M == 0)
  {
    ans = 0;
  }
  else
  {
    ans ++;
  }
  ans += N/11 * 2;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3636
#include <vector>
#include <iostream>
#include <cmath>
#include <iomanip>
#include <string>
#include <utility>
#include <stack>
#include <numeric>
#include <random>
#include <algorithm>
#include <queue>
#include <functional>
#include <iterator>
#include <list>
#include <unordered_map>
#include <deque>
using namespace std;

#define rep(i, b, e) for(i = b; i < e; ++i)
#define repr(i, b, e) for (i = b; i >= e; --i)
#define ull unsigned long long int
#define ll long long int
#define pint pair<int, int>

#define M_DEBUG 1
#define PI 3.141592653589793

#define E '\n'

#define print(x) cout << (x) << endl;
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << "\n";}
#define INF (1e18)

const ll MAX = 1000000000;
const ll MOD = 1e9 + 7;

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

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

ll aabs(ll a) {
    if (a < 0) return -a;
    return a;
}

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

//fast combination
ll comb(ll n, ll a) {
    ll b = 1, c = 1;
    for (ll i = 1; i <= a; ++i) {
        b = b * i % MOD;
        c = c * (n - i + 1) % MOD;
    }

    return c * calc(b, MOD - 2) % MOD;
}


int main(void) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> h >> w;
    if (h == 1 || w == 1) cout << 1 << endl;
    else if (h % 2 && w % 2) cout << (h * w) / 2 + 1 << endl;
    else cout << (h * w) / 2 << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
using vl=vector<ll>;
using vb=vector<bool>;
using vs=vector<string>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
const ll oo =0x3f3f3f3f3f3f3f3fLL;
const double eps=1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define FOR(i,a,b) for(ll i=(a); i<(b); i++)
#define FORD(i,a,b) for(ll i=ll(b)-1;i>=(a);i--)
#define TR(X) ({if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })
vvl adj;

vl col;

bool dfs(ll cur, ll curcol) {
        if (col[cur] != -1) return col[cur] == curcol;

        col[cur] = curcol;
        for (ll nei : adj[cur]) {
                if (!dfs(nei, !curcol)) return false;
        }
        return true;
}

int main(){ cin.sync_with_stdio(0);
        ll N, M; cin >> N >> M;
        adj.resize(N);

        FOR(i, 0, M) {
                ll a, b; cin >> a >> b;
                a--, b--;
                adj[a].pb(b);
                adj[b].pb(a);
        }
        col.assign(N, -1);
        bool bipartite = dfs(0, 0);

        if (!bipartite) {
                cout << (N*(N-1)/2 - M) << endl;
        } else {
                ll a = count(all(col), 1ll);
                ll b = N - a;
                cout << a*b-M << endl;
        }

} //cin.tie(0) bei schnellem Wechseln


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

int main(void){
    string s;
    int a = 0;
    int b = 0;
    int c = 0;

    for(int i = 0; i < 3; i++){
        cin >> s[i];
        if(s[i] == 'a')
            a++;
        else if(s[i] == 'b')
            b++;
        else if(s[i] == 'c')
            c++;
    }

    if(a == 1 && b == 1 && c == 1)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1 << 31;
// clang-format on

int main(void)
{
  string S, T;
  cin >> S >> T;

  string SS = S + S;

  int j = 0;
  for (int i = 0; i < SS.length(); i++) {
    if (SS[i] == T[j]) {
      j++;
      if (j == T.size() - 1) break;
    }
    else {
      j = 0;
    }
  }

  cout << (j == (T.size() - 1) ? "Yes" : "No") << endl;

  return 0;
}


Measured memory_bytes: 888
N, M = map(int, input().split())
py = [list(map(int, input().split())) for _ in range(M)]
pyi = []
for i, x in enumerate(py):
    x.append(i)
    pyi.append(x)
pyi.sort()

dic = {}
number_list = []
for p, y, i in pyi:
    w = ''
    w = "0" * (6 - len(str(p))) + str(p)

    if p in dic:
        dic[p] += 1
    else:
        dic[p] = 1
    w += "0" * (6 - len(str(dic[p]))) + str(dic[p])
    number_list.append([i, w])
number_list.sort()
for i in range(len(number_list)):
    print(number_list[i][1])


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

typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;

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

const ll INF = 1e18;
const ll MOD = 998244353;
const ll MX = 1000001;

ll A, B, N;

void solve() {
    cin >> A >> B >> N;
    cout << A * min(B - 1, N) / B;
}

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
    ll T = 1; // cin >> T;
    while (T--) solve();
    return 0;
    // You should actually read the stuff at the bottom
}

/* Stuff to Look For
 * -----------------
 * Int overflow, array bounds
 * Initializing all variables, avoid weird behavior
 * Edge cases(n = 0, n = 1)
 * Just return 0 after result
 */


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
#define ll long long
 
const ll INF= 1LL << 60;
 
//入力
ll N;
ll W;
ll w[110];
ll v[110];
//dp
ll dp[110][100010];
 
 
void chmin(ll& a, ll b){
  if(a>b){
    a=b;
  }
}
 
 
void chmax(ll& a, ll b){
  if(a<b){
    a=b;
  }
}
 
ll valuemax(ll i,ll j){
  //i番目の荷物をとった時の重さjのときの最大価値を返す．
  if(dp[i][j]!=-1){
    return dp[i][j];
  }else if(i==N|j==W){
    return 0;//これ以上詰められない
  }else{
    if(j+w[i]<=W){
      dp[i][j]=max(valuemax(i+1,j),valuemax(i+1,j+w[i])+v[i]);
    }else{
      dp[i][j]=valuemax(i+1,j);
    }
    return dp[i][j];
  }
}
 
int main(){
  cin >> N >> W;
  for(int i=0;i<N;i++){
    cin >> w[i] >> v[i];
  }
 
  for(int i=0;i<110;i++){
    for(int j=0;j<100010;j++){
          dp[i][j]=-1;
    } 
  }
  cout << valuemax(0,0) << endl;
}

Measured memory_bytes: 86144
#include<iostream>
#include<algorithm>
using namespace std;
const int Maxn=1e6+300;
int a[Maxn],b[Maxn];
int n,h,cnt=0;
int main()
{
	cin>>n>>h;
	for(int i=0;i<n;i++)
	  cin>>a[i]>>b[i];
	sort(a,a+n);reverse(a,a+n);
	sort(b,b+n);reverse(b,b+n);
	for(int i=0;i<n;i++)
	  if(b[i]>a[0]&&h>0)
	  {
	  	cnt++;
	  	h-=b[i];
	  }
	while(h>0)
	{
		cnt++;
		h-=a[0];
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
bool isBomb(char a[][50],int i,int j){
    if(a[i][j]=='#') return true;
    else return false;
}
char bombNum(char a[][50],int i,int j,int h,int w){
    int n=0;
    if(j>0){
        if(i>0&&isBomb(a,i-1,j-1)) n++;
        if(isBomb(a,i,j-1)) n++;
        if(i+1<h&&isBomb(a,i+1,j-1)) n++;
    }
    if(j+1<w){
        if(i>0&&isBomb(a,i-1,j+1)) n++;
        if(isBomb(a,i,j+1)) n++;
        if(i+1<h&&isBomb(a,i+1,j+1)) n++;
    }
    if(i>0&&isBomb(a,i-1,j)) n++;
    if(i+1<h&&isBomb(a,i+1,j)) n++;
    return n+'0';
}
int main(){
    int h,w;
    char a[50][50];
    cin >> h >> w;
    for(int i=0;i<h;i++) {
        for(int j=0;j<w;j++){
            cin >> a[i][j];
        }
        cin.ignore();
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(a[i][j]=='#') continue;
            a[i][j] = bombNum(a,i,j,h,w);
        }
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cout << a[i][j];
        }
        cout << "\n";
    }
}

Measured memory_bytes: 256
#int input
n = int(input())

def another_dice_game(goal):
    d,m = divmod(goal,11)
    if m == 0:
        return d * 2
    elif m <= 6:
        return d * 2+ 1
    else:
        return d * 2 + 2

print(another_dice_game(n))

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
 
using ll = long long;
using pll = pair<ll, ll>;
#define all(x) (x).begin(), (x).end()
#define call(x) (x).cbegin(), (x).cend()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define sz(x) ((x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
const double PI = acos(-1);
const int mod = 1e9+7;
const long long INF = (1LL << 60);
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}
ll ceil(ll a, ll b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmax(T &a, const T &b){ if(a < b){ a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(a > b){ a=b; return 1; } return 0; }

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

  ll n, k;
  cin >> n >> k;
  vector<ll> a(n);
  rep(i, 0, n) cin >> a[i];
  sort(all(a));
  ll g = a[0];
  rep(i, 1, n) g = gcd(g, a[i]);
  //cout << g << endl;
  if(a[n-1] >= k && k % g == 0) cout << "POSSIBLE" << endl;
  else cout << "IMPOSSIBLE" << endl;
  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define pb          push_back
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define endl        "\n"
#define fast        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define int         long long int
#define mod         1000000007
#define test        int t;cin>>t;while(t--)
#define REP(i,a,b)  for(int i=a,i<=b;i++)
#define MAXN        200001

int h,w;
pair<int,int> src,dest;
int mat[1001][1001];
bool vis[1001][1001];
int res[1001][1001];

int x_mov[]={1,-1,0,0};
int y_mov[]={0,0,-1,1};

bool is_valid(int x,int y){

    if(x< 0 || y<0 || x>=h || y>=w || !mat[x][y] || vis[x][y])
        return false;

    return true;
}

void bfs(){

    memset(vis,false,sizeof(vis));
    memset(res,0,sizeof(res));

    // for(int i=0;i<h;i++){
    //     for(int j=0;j<w;j++){
    //         cout<<res[i][j]<<" ";
    //     }
    //     cout<<endl;
    // }

    deque<pair<pair<int,int>,int>> q;
    q.push_front({src,0});
    // vis[src.F][src.S]=true;

    while(!q.empty()){
        // cout<<"Im in loop"<<endl;
        pair<int,int> pp =q.front().F;
        int cost=q.front().S;

        // cout<<pp.F<<" "<<pp.S<<" -->"<<cost<<endl;
        q.pop_front();
        if(vis[pp.F][pp.S]) continue;
        vis[pp.F][pp.S]=true;
        
        if(pp.F==dest.F && pp.S==dest.S){
            cout<<cost<<endl;
            return;
        }

        for(int i=0;i<4;i++){
            int new_x=pp.F + x_mov[i];
            int new_y=pp.S + y_mov[i];

            if(is_valid(new_x,new_y)){

                // vis[new_x][new_y]=true;
                q.push_front({{new_x,new_y},cost+0});
                res[new_x][new_y]=min(cost,res[new_x][new_y]);
                // cout<<new_x<<"  -->"<<new_y<<" "<<res[new_x][new_y]<<endl;
            }
        }

        for(int i=-2;i<=2;i++){
            for(int j=-2;j<=2;j++){
                int new_x=pp.F + i;
                int new_y=pp.S + j;

                if(is_valid(new_x,new_y)){

                    // cout<<new_x<<" === "<<new_y<<endl;
                    // vis[new_x][new_y]=true;
                    q.push_back({{new_x,new_y},cost+1});
                    res[new_x][new_y]=cost+1;
                }
            }
        }
    }

    cout<<-1<<endl;
}

int32_t main()
{
    cin>>h>>w;

    cin>>src.F>>src.S;
    cin>>dest.F>>dest.S;

    src.F--;src.S--;dest.F--;dest.S--;
    memset(mat,0,sizeof(mat));
    for(int i=0;i<h;i++){
        string str;cin>>str;
        for(int j=0;j<w;j++){
            if(str[j]=='.')
                mat[i][j]=1;
        }
    }

    // for(int i=0;i<h;i++){
    //     for(int j=0;j<w;j++){
    //         cout<<mat[i][j]<<" ";
    //     }
    //     cout<<endl;
    // }

    bfs();
    return 0;
}


Measured memory_bytes: 21452
#include<bits/stdc++.h>
using namespace std;
namespace FAST_IO
{
	template<typename T> void read(T &a)
	{
		a=0;
		int f=1;
		char c=getchar();
		while(!isdigit(c))
		{
			if(c=='-')
			{
				f=-1;
			}
			c=getchar();
		}
		while(isdigit(c))
		{
			a=a*10+c-'0';
			c=getchar();
		}
		a=a*f;
	}
	template <typename T> void write(T a)
	{
		if(a<0)
		{
			a=-a;
			putchar('-');
		}
		if(a>9)
		{
			write(a/10);
		}
		putchar(a%10+'0');
	}
	template <typename T> void writeln(T a)
	{
		write(a);
		puts("");
	}
}
int to[100001],use[100001],now=1;
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>to[i];
	}
	for(int i=1;;i++)
	{
		use[now]=true;
		now=to[now];
		if(now==2)
		{
			cout<<i;
			return 0;
		}
		if(use[now])
		{
			cout<<-1;
			return 0;
		}
	}
}

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
typedef tuple<int, int, int> T;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define MP make_pair
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define fst first
#define snd second

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

int board[128][128];
int geta = 64;

int main() {
  ios_base::sync_with_stdio(false);

  while (1) {
    int t, n;
    cin >> t >> n;
    if (t == 0 && n == 0) break;
    memset(board, 0, sizeof(board));
    REP(i, n) {
      int x, y;
      cin >> x >> y;
      board[y+geta][x+geta] = -1;
    }
    int sx, sy;
    cin >> sx >> sy;

    queue<T> que;
    que.push(T(sx, sy, t));

    while (!que.empty()) {
      int x, y, rest;
      tie(x, y, rest) = que.front();
      que.pop();

      if (rest < 0 || board[y+geta][x+geta] != 0) continue;

      board[y+geta][x+geta] = 1;
      REP(i, 6) {
	int nx = x + dx[i], ny = y + dy[i];
	  que.push(T(nx, ny, rest - 1));
      }
    }      
      
    int ans = 0;
    REP(i, 128) REP(j, 128) ans += board[i][j] > 0;
    cout << ans << endl;
  }
    
  return 0;
}

Measured memory_bytes: 1304
<?php
fscanf(STDIN, "%d%d", $h, $w);
for($i = 0; $i < $h; $i++){
  $map[] = trim(fgets(STDIN));
}
$count = 0;
for($i = 0; $i < $h; $i++){
  for($j = 0; $j < $w; $j++){
    if($map[$i][$j] == "#")$count++;
  }  
}
echo ($count == $h+$w-1) ? "Possible" : "Impossible";
echo "\n";

Measured memory_bytes: 4604
import numpy as np
Num = np.zeros((3,3),dtype=int)
Flag = False
for T in range(0,3):
    Num[T,:] = np.array([int(X) for X in input().split()])
for T in range(0,3):
    Num[:,T] -= Num[0,T]
for A2 in range(min(Num[1,:]),max(Num[1,:])+1):
    AB2 = np.array([A2+Num[0,0],A2+Num[0,1],A2+Num[0,2]])
    if np.all(AB2==Num[1,:]):
        for A3 in range(min(Num[2,:]),max(Num[2,:])+1):
            AB3 = np.array([A3+Num[0,0],A3+Num[0,1],A3+Num[0,2]])
            if np.all(AB3==Num[2,:]):
                Flag = True
                break
    if Flag:
        break     
if Flag:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 27356
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <math.h>
#include <string.h>
#include <stack>
#include <cctype>

using namespace std;




int main(){

	while(1){
		int n,m;
		int sum_a=0,sum_b=0,ans_a=1000,ans_b=1000;

		cin>>n>>m;
		if(n==0&&m==0){
			break;
		}
		int a[n],b[m];

		for(int i=0;i<n+m;i++){
			if(i<n){
				cin>>a[i];
				sum_a+=a[i];
			}else{
				cin>>b[i-n];
				sum_b+=b[i-n];
			}
		}
		for(int i=0;i<n;i++){
			for(int j=0;j<m;j++){
				if(2*abs(a[i]-b[j])==abs(sum_a-sum_b)){		//(sum_a-sum_b)/2は差が奇数だと× 
					if((sum_a-sum_b)*(a[i]>b[j])>=0){		//交換後、sum_a==sum_bの場合のみ。差が開いちゃ×
						if((ans_a+ans_b)>(a[i]+b[j])){
							ans_a=a[i],ans_b=b[j];
						}
					}
				}
			}
		}
		if(ans_a+ans_b>0&&ans_a+ans_b<2000){
			cout<<ans_a<<" "<<ans_b<<endl;
		}else{
			cout<<"-1"<<endl;
		}
	}

	return 0;
}

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

int hikaku(int A0, int A1, int T0, int T1){
	if(A0 + T0 > A1){
    	T1 = (A0 + T0 - A1);
    }
  	else{
    	T1 = 0;
    }
  return T1;
}

int main()
{
    // 整数の入力
    int N;
    cin >> N;
  
	// 身長
    vector<int> A(N);
  	// 台の高さ
	vector<int> T(N);
	for(int i = 0; i < N; i++){
		cin >> A.at(i);
	}
  
	unsigned long long x = 0;
	for(int i = 0; i < N-1; i++){
		T.at(i+1) = hikaku(A.at(i), A.at(i+1), T.at(i), T.at(i+1));
     	x += T.at(i+1);
	} 
    // 出力
    cout << x << endl;
    return 0;
}

Measured memory_bytes: 4760
N = gets.to_i
A = N.times.map{ gets.to_i }

max1 = A.max
num_max1 = A.count(max1)
if num_max1 == 1
  as = A.clone
  as.delete(max1)
  max2 = as.max
end

A.each do | a |
  if num_max1 == 1
    if a == max1
      puts max2
    else
      puts max1
    end
  else
    puts max1
  end
end

Measured memory_bytes: 7476
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;

int main(){

    int a,b;
    cin >> a >> b;

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

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>

using namespace std;

int main() {
	int n, ans = 0;
	cin >> n;
	int arr[n], sorted[n];
	bool visit[n] = { false };
	map<int, int> mp;

	for (int i = 0; i < n; i++) {
		cin >> arr[i];
		sorted[i] = arr[i];
	}
	sort(sorted, sorted + n);

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (arr[i] == sorted[j]) {
				mp[i] = j;
			}
		}
	}

	while (1) {
		int suffix = -1;
		for (int i = 0; i < n; i++) {
			if (visit[i] == false) {
				suffix = i;
			}
		}
		if (suffix == -1) {
			break;
		}

		int m = 0, min_in = 10001, min_out = 10001, sum = 0;
		bool used[n] = { false };
		while (used[suffix] == false) {
			m++;
			sum += arr[suffix];
			min_in = min(min_in, arr[suffix]);

			used[suffix] = visit[suffix] = true;
			suffix = mp[suffix];
		}

		if (m > 1) {
			for (int i = 0; i < n; i++) {
				if (used[i] == false) {
					min_out = min(min_out, arr[i]);
				}
			}

			ans += sum + min((m - 2) * min_in, min_in + (m + 1) * min_out);
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3184
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>

using namespace std;


int main(){

	int s_len,t_len,s_index,t_index;
	char S[1001],T[1001];

	scanf("%s",S);
	scanf("%s",T);

	for(s_len = 0;S[s_len] != '\0';s_len++);
	for(t_len = 0;T[t_len] != '\0';t_len++);

	for(s_index = 1,t_index = 0;s_index < s_len && t_index < t_len; s_index += 2){
		for(;t_index < t_len && T[t_index] != S[s_index];t_index++);
		if(t_index == t_len)break;
		t_index += 1;
	}
	if((s_len%2 == 1 && s_index == s_len) || (s_len%2 == 0 && s_index > s_len)){
		printf("Yes\n");
		return 0;
	}

	for(s_index = 0,t_index = 0;s_index < s_len && t_index < t_len; s_index += 2){
		for(;t_index < t_len && T[t_index] != S[s_index];t_index++);
		if(t_index == t_len)break;
		t_index += 1;
	}
	if((s_len %2 == 1 &&  s_index > s_len) || (s_len%2 == 0 && s_index == s_len)){
		printf("Yes\n");
		return 0;
	}

	printf("No\n");

	return 0;
}

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

#define REP(i,num) for(ll i=0;i<(num);++i)
#define FOR(i,c,num) for(ll (i)=(c);(i)<(num);++(i))
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=ll>
T in(){ T x; cin >> x; return (x); }
template<typename T=ll,typename C=vector<T>>
C vecin(int N){ C x(N);REP(i,N){ x[i]=in<T>(); }return x; }

void vout(){ cout << endl; }
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){ cout << ' ' << h;vout(forward<Tail>(t)...); }
void out(){ cout << endl; }
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){ cout << h;vout(forward<Tail>(t)...); }

template<typename T>
bool chmax(T& a,T b){ if(a<b){ a=b;return true; }return false; }
template<typename T>
bool chmin(T& a,T b){ if(a>b){ a=b;return true; }return false; }

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

	auto N=in();

	map<ll,ll> M;

	REP(x,100){
		REP(y,100){
			REP(z,100){
				ll xx=(x+1)*(x+1);
				ll xy=(x+1)*(y+1);
				ll xz=(x+1)*(z+1);
				ll yy=(y+1)*(y+1);
				ll yz=(y+1)*(z+1);
				ll zz=(z+1)*(z+1);
				M[xx+xy+xz+yy+yz+zz]++;
			}
		}
	}
	REP(i,N){
		out(M[i+1]);
	}

	return 0;
}


Measured memory_bytes: 6056
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
  int a,b;
  cin >> a >> b;
  double fa=a,fb=b;
  //cout << (a/b) <<" "<<(a%b)<<" "<<(fa/fb)<<endl;
  printf("%d %d %.5f\n",(a/b),(a%b),(fa/fb));
  return 0;
}


Measured memory_bytes: 3224
/*
     Author:Raghav Bansal
     IIIT Una
                  */
#include <bits/stdc++.h>
#define int long long int
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define BOLT ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define X first
#define Y second
#define endl "\n"
using namespace std;
void solve() {
	int n, m;
	cin >> n >> m;
	vector<int> v(n);
	int sum = 0;
	for (auto &it : v) {
		cin >> it;
		sum += it;
	}
	int cnt = 0;
	int check;
	int flag = 4 * m;
	if (sum % flag == 0)
		check = sum / flag;
	else
		check = sum / flag + 1;
	for (int i = 0; i < n; i++) {
		if (v[i] >= check)
			cnt++;
	}
	if (cnt >= m) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
}
int32_t main() {
	int t;
	t = 1;
	int cnt = 1;
	while (t--)
	{
		solve();
	}
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
typedef unsigned int uint;
using namespace std;
const ll INF = 1LL << 60;

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

    int N, W;
    cin >> N >> W;
    int w[N];
    ll v[N];
    for (int i = 0; i < N; i++) {
        cin >> w[i] >> v[i];
    }

    ll dp[W+1];
    fill(dp, dp+W+1, 0LL);

    for (int i = 0; i < N; i++) {
        for (int j = W; j > 0; j--) {
            if (dp[j] > 0LL && j + w[i] <= W) {
                dp[j+w[i]] = max(dp[j+w[i]], dp[j] + v[i]);
            }
        }
        dp[w[i]] = max(dp[w[i]], v[i]);
    }

    cout << *max_element(dp, dp+W+1) << "\n";
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>

using namespace std;

const int maxn = 1e5 + 9;

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

	int n, m;
	cin >> n >> m;
	string s;
	cin >> s;
	int dp[maxn];
	for (int i = 0; i < n; i++) {
		dp[i + 1] = dp[i] + (s[i] == 'C' && s[i - 1] == 'A');
	}
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		cout << dp[b] - dp[a] << '\n';
	}

	return 0;
}


Measured memory_bytes: 1488
n, k = map(int, input().split())
x = [int(i) for i in input().split()]
d = []
for i in range(n-k+1):
    l, r = x[i], x[i+k-1]
    d.append(abs(l-r) + min(abs(l), abs(r)))
print(min(d))

Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
int n, m, u, v, dp[100005], indeg[100005];
vector<int>edges[100005];
stack<int>st;
bool vis[100005];
void dfs(int x) {
  if (vis[x]) return;
  vis[x]=true;
  for (auto y: edges[x]) {
    dfs(y);
  }
  st.push(x);
}
int main () {
  scanf("%d %d", &n, &m);
  for (int i=0; i<m; i++) {
    scanf("%d %d", &u, &v);
    edges[u].push_back(v);
    indeg[v]++;
  }
  for (int i=1; i<=n; i++) {
    if (indeg[i]==0) {
      dfs(i);
    }
  }
  while (!st.empty()) {
    int t = st.top();
    for (auto y: edges[t]) {
      dp[y] = max(dp[y], dp[t] + 1);
    }
    st.pop();
  }
  int ans=0;
  for (int i=1; i<=n; i++) ans = max(ans, dp[i]);
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 11648
N,K = map(int,input().split())
src = list(map(int,input().split()))

if N == 1:
    print(0)
    exit()

ans = float('inf')
for bs in range(1<<(N-1)):
    colors = 1
    cost = 0
    tmp = src[0]
    for k in range(N-1):
        if tmp < src[k+1]:
            colors += 1
            tmp = src[k+1]
            continue
        if bs&(1<<k):
            cost += tmp - src[k+1] + 1
            colors += 1
            tmp += 1
    if colors >= K:
        ans = min(ans, cost)

print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
#define int long long
#define mod(int)(1000000007)
using namespace std;
int test[213456], cnt[213456][2];
signed main() {
	int n, m, a, b, sum = 0, ans = 0; string s, t; cin >> n;
	if (n == 1) { cout << 1 << endl; }
	if (n == 2) { cout << 1 << endl; }
	if (n == 3) { cout << 1 << endl; }
	if (n == 4) { cout << 2 << endl; }
	if (n == 5) { cout << 1 << endl; }
	if (n == 6) { cout << 2 << endl; }
	if (n == 7) { cout << 1 << endl; }
	if (n == 8) { cout << 5 << endl; }
	if (n == 9) { cout << 2 << endl; }
	if (n == 10) { cout << 2 << endl; }
	if (n == 11) { cout << 1 << endl; }
	if (n == 12) { cout << 5 << endl; }
	if (n == 13) { cout << 1 << endl; }
	if (n == 14) { cout << 2 << endl; }
	if (n == 15) { cout << 1 << endl; }
	if (n == 16) { cout << 14 << endl; }
	if (n == 17) { cout << 1 << endl; }
	if (n == 18) { cout << 5 << endl; }
	if (n == 19) { cout << 1 << endl; }
	if (n == 20) { cout << 5 << endl; }
	if (n == 21) { cout << 2 << endl; }
	if (n == 22) { cout << 2 << endl; }
	if (n == 23) { cout << 1 << endl; }
	if (n == 24) { cout << 15 << endl; }
	if (n == 25) { cout << 2 << endl; }
	if (n == 26) { cout << 2 << endl; }
	if (n == 27) { cout << 5 << endl; }
	if (n == 28) { cout << 4 << endl; }
	if (n == 29) { cout << 1 << endl; }
	if (n == 30) { cout << 4 << endl; }
	if (n == 31) { cout << 1 << endl; }
	if (n == 32) { cout << 51 << endl; }

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <sstream>
#include <fstream>
#include <complex>

using namespace std;

// deq notes ½Êô½É¨¯éxNgZ http://www.deqnotes.net/acmicpc/2d_geometry/
typedef complex<double> P;

#define EPS (1e-10)
#define EQ(a,b) (abs((a)-(b)) < EPS)

// OÏ (cross product) : a~b = |a||b|sinÆ
double cross(P a, P b) {
	return (a.real() * b.imag() - a.imag() * b.real());
}

// 2¼üÌ½s»è: a//b <=> cross(a, b) = 0
int is_paralell (P a, P b) {
	return EQ ( cross(a, b), 0.0 );
}

int main()
{
	string str = "";
	int n;
	int i,j;

	getline (cin, str );
	stringstream ssn(str);
	ssn >> n;

	for (i = 0; i < n; ++i){

		P p[4];	// A,B,C,D order
		getline (cin, str );
		stringstream ss(str);

		for (j = 0; j < 4; ++j){
			ss >> p[j].real() >> p[j].imag();
		} // end for

		if (is_paralell (p[1] - p[0], p[3] - p[2] ) ) {
			cout << "YES" << endl;
		}else{
			cout << "NO" << endl;
		} // end if

	} // end for
		
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define REP(i,n) for(int i=0;i<n;i++)
#define FORq(i, m, n) for(int i = m;i <= n;i++)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define PRINTD(n) printf("%d\n",n)
#define DEBUG printf("%s\n","debug")
using namespace std;
//////////////////////////////////////////////////////
int intgcd(int x,int y){
	if (x<y) return intgcd(y,x);
	if (y==0) return x;
	int r = x % y;
	return intgcd(y,r);
}

int main(){
	int N,K; SCD2(N,K);
	vector<int>A;
	REP(i,N){
		int x; SCD(x);
		A.push_back(x);
	}
	
	int g,M;
	g = A[0];
	M = A[0];
	
	FORq(i,1,N-1){
		g = intgcd(g,A[i]);
		M = max(M,A[i]);
	}

	if (M<K) {
		printf("IMPOSSIBLE\n");
		return 0;
	}
	
	if (K % g == 0){
		printf("POSSIBLE\n");
	}else{
		printf("IMPOSSIBLE\n");
	}
	
	
	return 0;
}








Measured memory_bytes: 892
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#include <boost/rational.hpp>
*/
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define repr4(i,s,n) for(ll i = (n);i>=(s);i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
using Graphw = vector<vector<pair<ll,ll>>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;
#define MOD 1000000007;
/*
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using Real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
// 有理数型
using Rat = boost::rational<Bint>;
*/


int main(){
 // 頂点数と辺数
    int N; cin >> N;

    // グラフ入力受取 (ここでは無向グラフを想定)
    vector<vector<pair<ll,ll>>> G(N+1);
    for (int i = 0; i < N-1; ++i) {
        int a, b;
        ll c;
        cin >> a >> b>>c;
        G[a].push_back(make_pair(b,c));
        G[b].push_back(make_pair(a,c));
    }

    // BFS のためのデータ構造
    vector<ll> dist(N+1, -1); // 全頂点を「未訪問」に初期化
    queue<ll> que;
    int Q,K;
    cin>>Q>>K;

    // 初期条件 (頂点 0 を初期ノードとする)
    dist[K] = 0;
    que.push(K); // 0 を橙色頂点にする

    // BFS 開始 (キューが空になるまで探索を行う)
    while (!que.empty()) {
        int v = que.front(); // キューから先頭頂点を取り出す
        que.pop();

        // v から辿れる頂点をすべて調べる
        rep(j,G[v].size()) {
            if (dist[G[v][j].first] != -1) continue; // すでに発見済みの頂点は探索しない

            // 新たな白色頂点 nv について距離情報を更新してキューに追加する
            dist[G[v][j].first] = dist[v] + G[v][j].second;
            que.push(G[v][j].first);
        }
    }
ll ans[Q];
rep(i,Q){
    int x,y;
    cin>>x>>y;
    ans[i]=dist[x]+dist[y];

}
rep(i,Q){
    cout<<ans[i]<<endl;
}

return 0;
}

Measured memory_bytes: 12792
use std::io;
use std::cmp;
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::collections::HashSet;
use std::f64::consts::PI;

fn read_line() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    buf
}

fn main() {
    let s: Vec<char> = read_line().trim().chars().collect();
    let line: Vec<i32> = read_line().split_whitespace().map(|s| s.parse().unwrap()).collect();
    let mut x = line[0];
    let y = line[1];

    let mut tmp = 0;
    let mut dir = false;
    let mut xs = Vec::new();
    let mut ys = Vec::new();
    for i in 0..s.len() {
        if s[i] == 'T' {
            if tmp > 0 {
                if dir {
                    ys.push(tmp);
                } else {
                    xs.push(tmp);
                }
                tmp = 0;
            }

            dir = !dir;
        } else {
            tmp+= 1;
        }
    }

    if tmp > 0 {
        if dir {
            ys.push(tmp);
        } else {
            xs.push(tmp);
        }
    }

    if s[0] == 'F' && xs.len() > 0 {
        x -= xs[0];
        xs.remove(0);
    }

    let mut ans = true;

    let mut table = vec![false; 8010];
    table[0] = true;
    for i in 0..xs.len() {
        let mut tmp = vec![false; 8010];
        for j in 0..table.len() {
            if table[j] {
                let n = (j as i32 - xs[i]).abs() as usize;
                tmp[n] = true;
                let n = (j as i32 + xs[i]).abs() as usize;
                tmp[n] = true;
            }
        }
        table = tmp.clone();
    }
    if (x.abs() as usize) < table.len() {
        ans &= table[x.abs() as usize];
    } else {
        ans = false;
    }
    
    let mut table = vec![false; 8010];
    table[0] = true;
    for i in 0..ys.len() {
        let mut tmp = vec![false; 8010];
        for j in 0..table.len() {
            if table[j] {
                let n = (j as i32 - ys[i]).abs() as usize;
                tmp[n] = true;
                let n = (j as i32 + ys[i]).abs() as usize;
                tmp[n] = true;
            }
        }
        table = tmp.clone();
    }
    if (y.abs() as usize) < table.len() {
        ans &= table[y.abs() as usize];
    } else {
        ans = false;
    }

    if ans {
        println!("Yes");
    } else {
        println!("No");
    }
}


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

int main(){
    int n, x, y;
    cin >> n >> x >> y;
    int ans[n];
    for (int i = 0; i<n; ++i){
        ans[i] = 0;
    }

    int ind;
    for (int a = 1; a<=n; ++a){
        for (int b = a+1; b<=n; ++b){
            ind = min({abs(a-x) + abs(b-y) + 1,  b-a});
            ans[ind-1]+=1;
        }
    }

    for (int i = 0; i<n-1; ++i){
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 256
N, M = map(int, input().split())
X = [int(x) for x in input().split()]
X.sort()

if N >= M:
    print(0)
    exit()

r = [X[i] - X[i-1] for i in range(1, M)]
r.sort(reverse=True)

print((X[-1] - X[0]) - sum(r[:N-1]))

Measured memory_bytes: 13840
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define vl vector<ll>
#define pl pair<ll,ll>
#define TC int t;cin>>t;while(t--)
#define in(n) ll n;cin>>n;
#define inarr(n) ll n;cin>>n;vector<ll>arr;
int main(void){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    in(a);
    cout<<a+(a*a)+(a*a*a)<<endl;
    return 0;
}

Measured memory_bytes: 3644
//
//  main.cpp
//  A
//
//  Created by Hashizo on 2019/12/29.
//  Copyright © 2019 Hashizo. All rights reserved.
//

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <regex>
#include <cmath>

using namespace std;
 
#undef LONG_MAX
#undef LONG_MIN
 
#define LONG_MAX    9223372036854775807
#define LONG_MIN    (-LONG_MAX  -1)
 
#define ll long long
 
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
 
#define SORT(c) sort((c).begin(), (c).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
int main(int argc, const char * argv[]) {

	string s,t;
	cin >> s >> t;


	cout << t+s << endl;
	return 0;
}


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

using ll = long long;

int main() {
  int n, k;
  while (true) {
    cin >> n >> k;
    if (!n && !k) break;
    vector<int> a(n);
    for (int i{}; i < n; ++i) cin >> a[i];

    // 累積和
    vector<ll> s(n + 1, 0);
    for (int i{}; i < n; ++i) {
      s[i + 1] = s[i] + a[i];
    }

    ll ans{numeric_limits<ll>::min()};
    for (int i{}; i <= n - k; ++i) {
      ans = max(ans, s[i + k] - s[i]);
    }

    cout << ans << endl;
  }
  return 0;
}



Measured memory_bytes: 3800
#include<stdio.h>
int main(void){
	int n;
	int i, j, k, w;
	int min, cnt = 0;
	int A[100];

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

	for(i = 0; i < n-1; i++){
		min = i;
		for(j=i; j<n; j++){
			if(A[j] < A[min]){
				min = j;
			}
		}
		if(i!=min){
			w = A[i];
			A[i] = A[min];
			A[min] = w;
			cnt++;
		}
	}

	for(k=0; k<n-1; k++){
		printf("%d ", A[k]);
	}
	printf("%d\n", A[n-1]);
	printf("%d\n", cnt);
	return 0;
}

Measured memory_bytes: 1772
import java.util.Scanner;
import java.util.Random;
import java.util.Arrays;

class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		
		int num = a/15;
		
		System.out.println(800*a - num*200);
	}
}

Measured memory_bytes: 23636