akhauriyash/Code-Regression huggingface dataset:
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <cstdlib>
#define rep(i,x) for(int i=0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using namespace std;
using ld = long double;
using ll = long long;
const ll INF = 1001001001;
typedef pair<ll, ll> P;
const ll mod = 1000000007;
ll gcd(ll a, ll b) {//a>b
    if (a < b)swap(a, b);
    if (a % b == 0) return b;
    else return gcd(b, a % b);
}

int main() {
    ld H, W, h, w;
    cin >> W >> H >> w >> h;
    cout << W * H / 2 << " ";
    if (W / 2 == w && H / 2 == h)cout << "1" << endl;
    else cout << "0" << endl;
}


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

// 内部定数
#define D_BALL_MAX		200000									// 最大ボール数

// 内部変数
static int si1Ball[D_BALL_MAX + 5];								// ボール
static int siBCnt;												// ボール数
static int si1Kind[D_BALL_MAX + 5];								// 同一種類(個数)
static int siCCnt;												// 同一種類(個数)数

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpT, *szpFpA;
#endif

// ソート関数 - int昇順
int
fSortFnc(
	const void *pzpVal1			// <I> 値１
	, const void *pzpVal2		// <I> 値２
)
{
	int *lipVal1 = (int *)pzpVal1;
	int *lipVal2 = (int *)pzpVal2;

	// 昇順
	if (*lipVal1 >  *lipVal2) {
		return(1);
	}
	else if (*lipVal1 < *lipVal2) {
		return(-1);
	}

	return 0;
}

// 実行メイン
int
fMain(
	int piTNo					// <I> テスト番号 1～
)
{
	int i;
	char lc1Buf[1024], lc1Out[1024];

	// テストファイルオープン
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", piTNo);
	szpFpT = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", piTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#endif

	// ボール数・種類数取得
	int liKCnt;
#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpT);
#else
	fgets(lc1Buf, sizeof(lc1Buf), stdin);
#endif
	sscanf(lc1Buf, "%d%d", &siBCnt, &liKCnt);

	// ボール取得
	for (i = 0; i < siBCnt; i++) {
#ifdef D_TEST
		fscanf(szpFpT, "%d", &si1Ball[i]);
#else
		fscanf(stdin, "%d", &si1Ball[i]);
#endif
	}
#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpT);
#else
	fgets(lc1Buf, sizeof(lc1Buf), stdin);
#endif

	// ソート
	qsort(si1Ball, siBCnt, sizeof(int), fSortFnc);

	// 同一種類(個数)セット
	si1Kind[0] = 1;
	siCCnt = 1;
	for (i = 1; i < siBCnt; i++) {

		// １個前と比較
		if (si1Ball[i] == si1Ball[i - 1]) {		// 一致
			si1Kind[siCCnt - 1]++;
		}
		else {									// 不一致
			si1Kind[siCCnt] = 1;
			siCCnt++;
		}
	}

	// ソート
	qsort(si1Kind, siCCnt, sizeof(int), fSortFnc);

	// 不要な種類数
	liKCnt = siCCnt - liKCnt;

	// 不要なボール数
	int liBCnt = 0;
	for (i = 0; i < liKCnt; i++) {
		liBCnt += si1Kind[i];
	}

	// 結果セット
	sprintf(lc1Out, "%d\n", liBCnt);

	// 結果表示
#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, lc1Out)) {
		siRes = -1;
	}
#else
	printf("%s", lc1Out);
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpT);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", piTNo);
	}
	else {
		printf("NG %d\n", piTNo);
	}
#endif

	return 0;
}

int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		fMain(i);
	}
#else
	fMain(0);
#endif

	return 0;
}



Measured memory_bytes: 2156
import java.util.Scanner;

class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int a = sc.nextInt();
        int b = sc.nextInt();

        System.out.printf("%d %d %.10f\n",a/b,a%b,(double)a/b);
    }
}


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


int main()
{
    int n;
    cin>>n;
    
    vector<pair<long double, long double> > p(n);
    for (int i = 0; i < n; i++) {
      long double x,y;
      cin>>x>>y;
      p[i] = make_pair(x, y);
    }
    
    long double distance=0;
	vector<int> visit_order(n);
    for(int i=0;i<n;i++){
      visit_order.at(i)=i;
    }
  	
    double factorial=1;
    for(int i=1;i<=n;i++){
      factorial*=i;
    }
  
    do{
       for(int i=0;i<n-1;i++){
         long double wk1,wk2;
         int wk0=visit_order.at(i+1);
         int wk=visit_order.at(i);
         wk1=p.at(wk0).first-p.at(wk).first;
         wk2=p.at(wk0).second-p.at(wk).second;
         distance+=sqrt(wk1*wk1+wk2*wk2);
       }
    }while(next_permutation(visit_order.begin(),visit_order.end()));
    
    cout << fixed << setprecision(15) << distance/factorial<<endl;
    return 0;
}

Measured memory_bytes: 256
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define yes(n) cout << ((n) ? "yes" : "no"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define VSUM(V) accumulate(ALL(V), 0)
#define MID(a,b,c) (a) < (b) && (b) < (c)
#define MIDe(a,b,c) (a) <= (b) && (b) <= (c)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;
#define FIX cout << fixed << setprecision(15)

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define VVi vector<vector<ll>>
#define Vd vector<double>
#define Vb vector<bool>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

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

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b != 0 ? gcd(b, a % b) : a;} //最大公約数
int lcm(int a, int b){return a * b / gcd(a, b);}
string toStrUp(string str){char diff = 'A'-'a';REP(i,str.size()) str[i] += diff;return str;}
string gCh(string str, int key){return str.substr(key,1);}

signed main() {
  RAPID;
  // デフォルト変数定義
  int n=0,m=0,a=0,b=0,c=0,d=0,x=0,y=0,z=0;
  string s="",t="";
  //

  // ここから
  IN(n);
  Vs strs(n);
  VIN(strs)
  map<string,int> cmap;
  REP(i,n){
    cmap[strs[i]]++;
  }
  for(auto dat : cmap){
    z = max(z, dat.second);
  }
  Vs Ans;
  for(auto dat : cmap){
   if(z == dat.second){
     Ans.pb(dat.first);
   }
  }
  SORT(Ans);
  VOUT(Ans)
}

Measured memory_bytes: 27120
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <cassert>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define chmax(a,b) (a<(b)?(a=b,1):0)
#define chmin(a,b) (a>(b)?(a=b,1):0)
#define valid(y,x,h,w) (0<=y&&y<h&&0<=x&&x<w)
const int INF = 1<<29;
const double EPS = 1e-8;
const double PI = acos(-1);
typedef pair<int,int> pii;
typedef long long ll;

int stability[4][4];
int s[100];
double dp[101][101][11][11][3];

bool solve() {
  REP(i,4) {
    REP(j,4) {
      cin >> stability[i][j];
      if (stability[i][j] == -1) return 0;
    }
  }
  int L;
  cin >> L;
  REP(i,L) cin >> s[i];
  int A, B;
  cin >> A >> B;
  A/=100;B/=100;

  REP(i,L+1)REP(j,101)REP(k,11)REP(l,11)REP(m,3)dp[i][j][k][l][m] = 0;
  REP(k,11) REP(l,11) REP(m,3) dp[L][100][k][l][m] = 1;

  for (int i=L-1; i>=0; --i) {
    REP(j,101) {
      REP(k,11) {
        REP(l,11) {
          REP(m,3) {
            if (m==2&&k!=10) continue;
            if (i==0&&m!=2) continue;
            if (i&&s[i-1]==0&&m!=2) continue;
            double &DP = dp[i][j][k][l][m];
            if (s[i] == 0) {
              chmax(DP, dp[i+1][j][10][l][2]);
            } else {
              int score = A + B*l;
              REP(n,2) {
                int stab;
                if (m == 2) {
                  stab = 10;
                } else {
                  int cur = (s[i]-1)*2 + n;
                  int pre = (s[i-1]-1)*2 + m;
                  stab = max(0, stability[pre][cur]-10+k);
                }
                double prob = 0.1*stab;
                chmax(DP, dp[i+1][min(j+score,100)][stab][min(l+1,10)][n]*prob + dp[i+1][j][stab][0][n]*(1-prob));
              }
              chmax(DP, dp[i+1][j][10][0][2]);
            }
          }
        }
      }
    }
  }
  double ans = dp[0][0][10][0][2];

  printf("%.10f\n", ans);
  return 1;
}

int main() {
  while(solve());

}

Measured memory_bytes: 30112
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		int N = int.Parse(Console.ReadLine());
		string[] str = Console.ReadLine().Split();
		string[] str2 = Console.ReadLine().Split();
		int[]A = new int[N];
		int[]B = new int[N];
		var pq = new PriorityQueue<int>((x,y)=>B[y]-B[x]);
		for(var i=0;i<N;i++){
			A[i] = int.Parse(str[i]);
			B[i] = int.Parse(str2[i]);
			pq.Enqueue(i);
		}
		long ct = 0;
      	int[]F = new int[N];
		int[]G = new int[N];
		while(pq.Count>0){
			int a1 = pq.Dequeue();
			bool flag = false;
			int a0 = (a1+N-1)%N;
			int a2 = (a1+1)%N;
			while(B[a0]+B[a2]<=B[a1] && B[a1]-B[a0]-B[a2] >=A[a1]){
				int cta1 = (B[a1] - B[a0]-B[a2]-1) / (B[a0]+B[a2])+1;
				int cta2 = (B[a1] - A[a1]-1) / (B[a0]+B[a2])+1;
              	int cta = Math.Min(cta1,cta2);
				B[a1] -= (B[a0]+B[a2]) * cta;
            	ct += cta;
				flag = true;
            }
			if(flag){
              	if(F[a0]==1 && G[a0]==0){
                  	F[a0]=0;
					pq.Enqueue(a0);
                }
             	if(F[a2]==1 && G[a2]==0){
					pq.Enqueue(a2);
                	F[a2]=0;
	            }
              	if(B[a1] == A[a1]){
                  	G[a1] = 1;
                } else {
					pq.Enqueue(a1);
                }
			} else {
              	F[a1] = 1;
            }
		}
		for(var i=0;i<N;i++){
			if(A[i]!=B[i]){
				ct = -1;
            }
		}
		Console.WriteLine(ct);
	}
}

class PriorityQueue<T>
{
    private readonly List<T> heap;
    private readonly Comparison<T> compare;
    private int size;
    public PriorityQueue() : this(Comparer<T>.Default) {} 
    public PriorityQueue(IComparer<T> comparer) : this(16, comparer.Compare) { }
    public PriorityQueue(Comparison<T> comparison) : this(16, comparison) { }
    public PriorityQueue(int capacity, Comparison<T> comparison)
    {
        this.heap = new List<T>(capacity);
        this.compare = comparison;
    }
    public void Enqueue(T item)
    {
        this.heap.Add(item);
        var i = size++;
        while (i > 0)
        {
            var p = (i - 1) >> 1;
            if (compare(this.heap[p], item) <= 0)
                break;
            this.heap[i] = heap[p];
            i = p;
        }
        this.heap[i] = item;

    }
    public T Dequeue()
    {
        var ret = this.heap[0];
        var x = this.heap[--size];
        var i = 0;
        while ((i << 1) + 1 < size)
        {
            var a = (i << 1) + 1;
            var b = (i << 1) + 2;
            if (b < size && compare(heap[b], heap[a]) < 0) a = b;
            if (compare(heap[a], x) >= 0)
                break;
            heap[i] = heap[a];
            i = a;
        }
        heap[i] = x;
        heap.RemoveAt(size);
        return ret;
    }
    public T Peek() { return heap[0]; }
    public int Count { get { return size; } }
    public bool Any() { return size > 0; }
}


Measured memory_bytes: 45916
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

func main() {
	sc := NewScanner(os.Stdin)
	n := sc.Int()
	p := sc.Float64s(n)

	dp := make([]float64, n+2)
	dp[0] = 1 - p[0]
	dp[1] = p[0]

	for n, v := range p {
		if n == 0 {
			continue
		}

		for i := n + 1; i >= 0; i-- {
			if i == 0 {
				dp[i] = dp[i] * (1 - v)
				continue
			}
			dp[i] = dp[i-1]*v + dp[i]*(1-v)
		}
	}

	var sum float64
	for i := (n + 1) / 2; i <= n; i++ {
		sum += dp[i]
	}
	fmt.Println(sum)
}

// generated by https://github.com/murosan/gollect

func BytesToInt(b []byte) (n int) {
	var i int
	if b[0] == '-' {
		i++
	}
	for ; i < len(b); i++ {
		n *= 10
		n += int(b[i] - '0')
	}
	if b[0] == '-' {
		return -n
	}
	return
}

func BytesToFloat64(b []byte) float64 {
	i, f, idx := 0.0, 0.0, 0
	if b[0] == '-' {
		idx++
	}
	for ; idx < len(b) && b[idx] != '.'; idx++ {
		i *= 10
		i += float64(b[idx] - '0')
	}
	if idx < len(b) {
		for idx = len(b) - 1; idx >= 0 && b[idx] != '.'; idx-- {
			f += float64(b[idx] - '0')
			f *= 0.1
		}
	}
	if b[0] == '-' {
		return -(i + f)
	}
	return i + f
}

type Scanner struct{ *bufio.Scanner }

func NewScanner(r io.Reader) *Scanner {
	s := bufio.NewScanner(r)
	s.Split(bufio.ScanWords)
	return &Scanner{Scanner: s}
}

func (s *Scanner) Bytes() []byte { s.Scan(); return s.Scanner.Bytes() }

func (s *Scanner) Int() int { return BytesToInt(s.Bytes()) }

func (s *Scanner) Float64() float64 { return BytesToFloat64(s.Bytes()) }

func (s *Scanner) Float64s(len int) []float64 {
	a := make([]float64, len)
	for i := 0; i < len; i++ {
		a[i] = s.Float64()
	}
	return a
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>

using namespace std;

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

	int a, p;
	cin >> a >> p;
	cout << (3 * a + p) / 2 << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<math.h>
int main(){
int a,b;
char s[6];
int c;
double v;
scanf("%d%d",&a,&b);

sprintf(s,"%d%d",a,b);
c=atoi(s);
v=sqrt(c);
//printf("%d\n",c);
if(ceil(v)==floor(v)){
	
	
	printf("Yes\n");
	
	
}else{
	
	
	printf("No\n");
}
	return 0;
}

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

void step(int **G, long **cost, char *flag, int u, long *d) {
  int i,j;
  long t = d[u];
  for (i = 0;; i++) {
    j = G[u][i];
    if(j == -1) break;
    if(d[j] == -1 || d[j] > t+cost[u][i]) {
      flag[j] = 1;
      d[j] = t+cost[u][i];
    }
  }
}

void solve(int **G, long **cost, int n, long *d) {
  int i,j;
  char *flag,*new_flag;
  flag = (char*)malloc(sizeof(char) * n);
  new_flag = (char*)malloc(sizeof(char) * n);
  flag[0] = 1;
  for (i = 1; i < n; i++) flag[i] = 0;
  while(1) {
    for (i = 0; i < n; i++) new_flag[i] = 0;
    for (i = 0; i < n; i++) 
      if(flag[i] == 1) step(G,cost,new_flag,i,d);
    j = 0;
    for (i = 0; i < n; i++) {
      j += new_flag[i];
      flag[i] = new_flag[i];
    }
    if(j == 0) break;
  }
    
  return;
}

void sort(long *A, int *B, int a, int b){
  if(b == a+1) return;
  int m = a+(b-a)/2;
  sort(A,B,a,m);
  sort(A,B,m,b);
  int i,j,t;
  long *newA;
  int *newB;
  newA = (long*)malloc(sizeof(long)*(b-a));
  newB = (int*)malloc(sizeof(int) * (b-a));
  if(b-a == 0) printf("a");
  i = 0;j = 0;t = 0;
  while(t < b-a) {
    if((a+i < m && A[a+i] < A[m+j]) || m+j == b) {
      newA[t] = A[a+i];
      newB[t] = B[a+i];
      i++;
    }
    else{
      newA[t] = A[m+j];
      newB[t] = B[m+j];
      j++;
    }
    t++;
  }
  for (i = 0; i < b-a; i++) {
    A[a+i] = newA[i];
    B[a+i] = newB[i];
  }
  free(newA);
  free(newB);
}

int main()
{
  int n;
  int i,j,u,k,v;
  int **G;
  long **cost,c;
  long *d;
  scanf("%d",&n);
  G = (int**)malloc(sizeof(int*) * n);
  cost = (long**)malloc(sizeof(long*) * n);
  for (i = 0; i < n; i++) {
    scanf("%d %d", &u, &k);
    G[u] = (int*)malloc(sizeof(int) * (k+1));
    cost[u] = (long*)malloc(sizeof(long) * k);
    for (j = 0; j < k; j++) {
      scanf("%d %ld", &v, &c);
      G[u][j] = v;
      cost[u][j] = c;
    }
    if(k != 0)sort(cost[u],G[u],0,k);
    G[u][k] = -1;
  }
  d = (long*)malloc(sizeof(long) * n);
  d[0] = 0;
  for (i = 1; i < n; i++) {
    d[i] = -1;
  }
  solve(G,cost,n,d);
  for (i = 0; i < n; i++) {
    printf("%d %ld\n", i, d[i]);
  }
  return 0;
}

Measured memory_bytes: 6504
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int a,b;
  cin >> a >> b ;
  if(a<10 && a>= 1 && b <10 && b>=1)
  {
    cout << a*b << endl;
  }
  else
  {
    cout << -1 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    
    int64_t N;
    cin >> N;
    int64_t sum = 0;
    vector<int64_t> vec(N);
    for(int i=0; i<N; i++){
        cin >> vec[i];
        sum += vec[i];
    }
    int64_t ans = sum - N*(N-1);
    int64_t cnt = 0;
    if(ans > 0){
      for(int i=0; i<N; i++){
        vec[i] += ans - (N-1);
        int64_t x = (vec[i] + N) / (N+1);
        vec[i] -= x*(N+1);
        cnt += x;
      }
    }
  
    if(cnt > ans && ans > 0){
      for(int i=0; i<N; i++){
         vec[i] += cnt - ans;
      }
    }
  
    ans = cnt;
   
   if(ans > 0){
     for(int i=0; i<N; i++){
       vec[i] += N-1;
     }
   }
  
    while(true){
      sort(vec.rbegin(),vec.rend());
      if(vec[0] < N){
        break;
      }
      vec[0] -= N;
      for(int i=1; i<N; i++){
        vec[i]++;
      }
      ans++;
    }
    
    cout << ans << endl;
    
}



Measured memory_bytes: 3524
def printComparison(a, b): 
    """ 
    a: int
    b: int
    outputs the comparison result of a and b

    >>> printComparison(1, 2)
    a < b
    >>> printComparison(4, 3)
    a > b
    >>> printComparison(5, 5)
    a == b
    >>> printComparison(-20, -10)
    a < b
    """
    operator = ''
    if a > b:
        operator = '>' 
    elif a < b:
        operator = '<' 
    else:
        operator = '=='

    print('a', operator, 'b')


if __name__ == '__main__':
    ival = input().split(' ')
    printComparison(int(ival[0]), int(ival[1]))

Measured memory_bytes: 7664
#include <stdio.h>

int max(int a, int b, int c);

int main() {
	int A;
	int B;
	int sum, dif, mul;
	scanf("%d %d", &A, &B);
	sum = A + B;
	dif = A - B;
	mul = A * B;
	printf("%d", max(sum, dif, mul));
	return 0;
}

int max(int a, int b, int c) {
	int max;
	if (a > b) {
		max = a;
	} else {
		max = b;
	}
	if (max < c) {
		max = c;
	}
	return max;
}

Measured memory_bytes: 128
class UnionFind:
    def __init__(self,n):
        self.ps = [-1]*(n+1)
    def find(self,x):
        if self.ps[x]<0:
            return x
        else:
            self.ps[x]=self.find(self.ps[x])
            return self.ps[x]
    def unite(self,x,y):
        x=self.find(x)
        y=self.find(y)
        if x==y:
            return False
        if self.ps[x]>self.ps[y]:
            x,y = y,x
        self.ps[x] += self.ps[y]
        self.ps[y] = x
        return True
    def same(self,x,y):
        return self.find(x)==self.find(y)
    def size(self,x):
        x = self.find(x)
        return -self.ps[x]


N,M,K=map(int,input().split())
retu_n=[0]*N
block_n=[0]*N
uf = UnionFind(N)

for m in range(M):
  a,b=map(int,input().split())
  retu_n[a-1] +=1
  retu_n[b-1] +=1
  uf.unite(a,b)
  
  
for k in range(K):
  c,d=map(int,input().split())
  if uf.same(c, d):
    block_n[c-1] += 1
    block_n[d-1] += 1
    
  
for n in range(N):
  print(uf.size(n+1)-retu_n[n]-block_n[n]-1, end=" ")


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

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define RFOR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX

const double EPS = 1e-14;
const double PI  = acos(-1.0);


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

  vector<int> v(n);
  REP (i, n) {
    cin >> v[i];
  }

  int dp[n];
  REP (i, n) {
    dp[i] = INF;
  }
  dp[0] = 0;
  REP (i, n) {
    FOR (j, 1, k + 1) {
      if (i + j < n) {
        dp[i + j] = min(dp[i + j], dp[i] + abs(v[i] - v[i + j]));
      }
    }
  }

  cout << dp[n - 1] << endl;
}


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

#define pb            push_back
#define mp            make_pair
#define all(x)        x.begin(),x.end()
#define debug(X)      { cerr<<'\n'<<(#X)<<" = "<<(X)<<'\n'; }
//#define cerr if(0)cerr

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;


int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    double r;
    cin>>r;
    cout<<(double)(2*r*M_PI)<<'\n';
}



Measured memory_bytes: 3808
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
      
      int a[] =new int[N+1];
      
      for(int i=1; i<=N; i++){//出席番号をまわす
        int b =sc.nextInt();//出席番号iの生徒が登校してきた,i=2番の生徒が1番目に,i=3番の生徒が2番目に...
        a[b] = i;//出席番号1の生徒は何番目に登校してきた？→3番目,出席番号2の生徒→1番目...
      }
      for(int i=1; i<=N; i++){
      System.out.print(a[i]+" ");//出席番号1の生徒から順番に登校した順番を並べていく
      }
    }
}

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


#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;

/* vector<int> A(N); 
    vector<pair<int, int> > tasks; ＃ソートした場合、１つ目でソート
　tie(b, a) = p.at(i); #pairを分割
    tasks.emplace_back(b, a)  ＃配列tasksの最後に(b,a)を追加
　xの二乗:  pow(x, 2.0) 
    小さい順: sort(v.begin(), v.end());
    大きい順: reverse(v.begin(), v.end());
    int: -2,147,483,648 ～ 2,147,483,647
    ll: -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807
    // int型の2次元配列(3×4要素の)の宣言
    vector<vector<int>> data(3, vector<int>(4));
*/
 
int main() {
  
  int A, B, C, count=0, ans=0;
  string D, E;
  cin >> D;
  
  if(D.at(2)==D.at(3)&&D.at(4)==D.at(5)){
  	cout << "Yes" << endl;
  }
  else {
  	cout << "No" << endl;
  }
}

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

using namespace std;

int main(){
    int N;
    cin >> N;
    string S;
    cin >> S;
    vector<char> str(S.begin(), S.end());
    str.erase(unique(str.begin(), str.end()), str.end());
    cout << str.size() << endl;
}

Measured memory_bytes: 512
#include "bits/stdc++.h"
#define PRECISION(x) cout << fixed << setprecision(x)
#define FAST_IO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define ALLR(X) (X).rbegin(), (X).rend()
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define F first
#define S second

using namespace std;
 
template<class T> void max_self(T & a, const T & b) { if(a < b) a = b; }
template<class T> void min_self(T & a, const T & b) { if(a > b) a = b; }
typedef long long LL;
const int INF = 1e9 + 7;
const double PI = acos(-1.0);
const double EPS = (1e-9);


int main(){
  FAST_IO  
  
  int N, t = 0, x = 0, y = 0; cin >> N;

  for(int rep = 0; rep < N; ++rep){
    int t1, x1, y1; cin >> t1 >> x1 >> y1;
    int d = abs(x1 -x) + abs(y1 - y);
    int delt = t1 - t;
    if(d > delt || (delt - d) & 1){
      cout << "No\n";
      return 0;
    }
    t = t1;
    x = x1;
    y = y1;
  }

  cout << "Yes\n";


  return 0;
}

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

using namespace std;

#define FOR(i, n) for(int i = 0; i < (int) n; i++)
#define PB push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define F first
#define S second

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;

const int MOD = 998244353;

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

	ll a, b, c, d; cin >> a >> b >> c >> d;


	cout << max({a*c, a*d, b*c, b*d}) << '\n';


	return 0;
}


Measured memory_bytes: 3684
import math
import functools
import itertools
import numpy as np
import sys
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N = I()
s = S()
num = s.count("R")
if num <= N//2:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 21764
//#define LOCAL
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mem(ar) memset(ar,0,sizeof(ar))
#define go(i,a,b) for(int i=a;i<=b;++i)
#define f(i,n) for(int i=0;i<n;++i)


int main(){
#ifdef LOCAL
	freopen("data.in","r",stdin);
#endif
	int a[9] = {111,222,333,444,555,666,777,888,999};
	int n;
	scanf("%d",&n);
	for(int i=0;i<9;i++){
		if(a[i] >= n){
			printf("%d",a[i]);
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 256
R, C, N = map(int, input().split())
UP, RIGHT, DOWN, LEFT = [], [], [], []
for i in range(N):
    x1, y1, x2, y2 = map(int, input().split())

    # 2つとも周上にない
    if 0 < x1 < R and 0 < y1 < C:
        continue
    if 0 < x2 < R and 0 < y2 < C:
        continue

    # 2つとも周回上にある
    if x1 == 0: UP.append([i, y1])
    elif x1 == R: DOWN.append([i, y1])
    elif y1 == 0: LEFT.append([i, x1])
    elif y1 == C: RIGHT.append([i, x1])

    if x2 == 0: UP.append([i, y2])
    elif x2 == R: DOWN.append([i, y2])
    elif y2 == 0: LEFT.append([i, x2])
    elif y2 == C: RIGHT.append([i, x2])


# 時計回りに探索できるようにする
UP.sort(key=lambda x: x[1])
RIGHT.sort(key=lambda x: x[1])
DOWN.sort(key=lambda x: x[1], reverse=True)
LEFT.sort(key=lambda x: x[1], reverse=True)

# 全体を連結
Numbers = UP + RIGHT + DOWN + LEFT

# 時計回りに探索
stack = []
for n, z in Numbers:
    if stack and stack[-1] == n:
        stack.pop()

    else:
        stack.append(n)
print("NO" if stack else "YES")


Measured memory_bytes: 36616
local mod = 1000000007

local function bmul(x, y)
  return (x * y) % mod
end

local function badd(x, y)
  return (x + y) % mod
end

local function bsub(x, y)
  return x < y and x - y + mod or x - y
end

local function modpow(src, pow)
  local res = 1
  while 0 < pow do
    if pow % 2 == 1 then
      res = bmul(res, src)
      pow = pow - 1
    end
    src = bmul(src, src)
    pow = pow // 2
  end
  return res
end

local function modinv(src)
  return modpow(src, mod - 2)
end

local function getComb(n, k)
  local ret = 1
  local inv = 1
  for i = 1, k do
    ret = bmul(ret, n + 1 - i)
    inv = bmul(inv, i)
  end
  return bmul(ret, modinv(inv))
end

local x, y = io.read("*n", "*n")
if (x + y) % 3 ~= 0 then
  print(0) os.exit()
end
local z = (x + y) // 3
x, y = x - z, y - z
if x < 0 or y < 0 then
  print(0) os.exit()
end
print(getComb(x + y, x))

Measured memory_bytes: 2796
n = int(input())
vs = sorted(list(map(int, input().split())))

while len(vs) > 1:
    a = vs.pop(0)
    b = vs.pop(0)
    r = (a+b)/2
    
    for i, v in enumerate(vs):
        if v > r:
            vs.insert(i, r)
            break
    else:
        vs.append(r)
        
print(vs[0])

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
typedef long long ll;
const int INF = 1000000000;
const long INF64 = 1000000000000000ll;
const ll MOD = 1000000007ll;


int main(){
	int n;
	std::cin >> n;
	ll po=1;
	rep(i,n){
		po*=i+1;
		po%=MOD;
	}
	std::cout << po << std::endl;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use {
   proconio::{fastout, input, marker::*},
   std::cmp::*,
   std::collections::*,
};

#[fastout]
fn main() {
   input! {
      mut x: i64,
      mut k: usize,
      d: i64,
   }
   if k % 2 == 1 {
      x = x.abs() - d;
      k -= 1;
   }
   x = x.abs();

   let ans = if (k as i64) <= x / d {
      x - k as i64 * d
   } else {
      x %= 2 * d;
      min(x, 2 * d - x)
   };
   println!("{}", ans);
}


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

#define REP(i, x) for (int i = 0, i##_len = (int)(x); i < i##_len; i++)
#define REP1(i, x) for (int i = 1, i##_len = (int)(x); i <= i##_len; i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREP1(i, x) for (int i = ((int)(x)); i > 0; i--)
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << ": " << x << '\n'
#define pb(x) push_back(x)
#define mp(x, y) make_pair(x, y)
const int MOD = (int)1e9 + 7;
const int INF = 1000000009;
using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using l_l = pair<ll, ll>;
using d_d = pair<double, double>;
using vint = vector<int>;
using vll = vector<ll>;
using vbool = vector<bool>;

const int MAX_N = 100005;

int main() {
    // prime number
    vbool isprime(MAX_N, true);
    isprime[0] = isprime[1] = false;
    REP(i, MAX_N) {
        if (isprime[i]) {
            for (int j = i * 2; j < MAX_N; j += i) {
                isprime[j] = false;
            }
        }
    }

    // 2017like numbers
    vbool is2017like(MAX_N);
    REP(i, MAX_N) {
        if (isprime[i] && isprime[(i + 1) / 2]) {
            is2017like[i] = true;
        }
    }
    vint cum2017like(MAX_N);
    REP(i, MAX_N - 1) {
        cum2017like[i + 1] = cum2017like[i] + (is2017like[i + 1] ? 1 : 0);
    }

    int Q;
    cin >> Q;
    int l, r;
    REP(i, Q) {
        cin >> l >> r;
        cout << cum2017like[r] - cum2017like[l - 1] << endl;
    }
}

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

using namespace std;

int main(){
	int a,b;
	scanf("%d %d",&a,&b);
	for(int i=1;i<=100000;i++){
		int t1 ,t2;
		t1=i/10;
		t2=i*8/100;
		if(t1==b && t2==a){
			printf("%d\n",i );
			return 0;
		}

	}

	printf("-1\n");

}

// per compilare è figa e comoda if [ $( stat C.cpp -c "%Y") -gt $( stat a.out -c "%Y")  ]; then g++ -g C.cpp && echo "finish" && ./a.out ;else echo "finish";./a.out; fi;


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main() {
	int a, b,s,t1,t2,t3,t4;
	cin >> a >> b;
	t1 = a + b;
	s = t1;
	t2 = a - b;
	if (s < t2) {
		s = t2;
	}
	t3 = a * b;
	if (s < t3) {
		s = t3;
	}
	cout << s << endl;

}

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

int main(void)
{
  int n, p, d1, d2;
  int top, sum;

  while(1)
    {
      top = 1;
      sum = 0;

      cin >> n;
      if(n == 0) break;

      for(int i = 0 ; i < n ; i++)
	{
	  cin >> p >> d1 >> d2;
	  if(sum < d1 + d2)
	    {
	      top = p;
	      sum = d1 + d2;
	    }
	}
      cout << top << ' ' << sum << endl;
    }
  return 0;
}

Measured memory_bytes: 864
#define _CRT_SECURE_NO_WARNINGS // #pragma warning(disable:4996)
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <functional>
#include <sstream>
#include <cmath>
#include <set>
#include <map>
using namespace std; 

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define mp(a,b) make_pair(a,b)
#define all(a) a.begin(),a.end()

typedef pair<int, int> Pii;
typedef vector<int> V;
typedef vector<vector<int> > VV;
typedef long long ll;
const int inf = 2e9;
const int mod = 1e9 + 7;

int main()
{
	map<int, int> M;
	rep(i,0,3) {
		int t; cin >> t;
		M[t]++;
	}
	(M[5]==2 && M[7]==1)? cout << "YES" << endl: cout << "NO" << endl;

	return 0;
}

Measured memory_bytes: 256
N=io.read"*n"
X={}
for i=1,N do
	X[i]=io.read"*n"
end
b,c=0,0
for i=1,N do
	b=b-X[i]*2
	c=c+X[i]*X[i]
end
r=-math.floor(b/N*.5+.5)
print(N*r*r+b*r+c)

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // uint64_t

#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) > (b) ? (b) : (a))
#define BUF_SIZE 20
#define DIVISOR 1000000007

int get_int2(int *a1, int *a2) {
#ifdef BUF_SIZE
  char line[BUF_SIZE];
  if(!fgets(line, BUF_SIZE, stdin)) return -1;
  sscanf(line, "%d %d", a1, a2);
#else
#error
#endif
  return 0;
}
#define NUM_MAX 1000
#define K_MAX 1000

static uint64_t factorial[NUM_MAX+K_MAX+1];
static uint64_t inv_factorial[NUM_MAX+K_MAX+1];

struct pair {
    int x;
    int y;
};

struct pair gcdext(int a, int b) {
    if(a == 0) { return (struct pair){0, 1}; }
    struct pair p = gcdext(b%a, a);
    return (struct pair){p.y - (b/a)*p.x, p.x};
}

void prep_combi(int n) {
    // prep
    int i;
    factorial[0] = factorial[1] = 1;
    for(i = 2; i <= n; i++) {
        factorial[i] = (factorial[i-1] * i)%DIVISOR;
    }

    inv_factorial[0] = inv_factorial[1] = 1;
    for(i = 2; i <= n; i++) {
        struct pair p = gcdext(i, DIVISOR);
        int inv = (p.x + DIVISOR)%DIVISOR;
        inv_factorial[i] = (inv_factorial[i-1]*inv)%DIVISOR;
    }
}

uint64_t calc_combi(int n, int k) {
    uint64_t ans = 1;
    ans = (ans * factorial[n])%DIVISOR;
    ans = (ans * inv_factorial[k])%DIVISOR;
    ans = (ans * inv_factorial[n-k])%DIVISOR;
    return ans;
}

void init() {
    prep_combi(NUM_MAX+K_MAX);
}

int main(void) {
    int n, k;
    init();
    get_int2(&n, &k);
    uint64_t ans = 0;
    
    if(n >= k) ans = calc_combi(n-1, k-1);
    printf("%d\n", (int)ans);
    return 0;
}


Measured memory_bytes: 2088
from sys import stdin

operate = {
    '+': lambda lhs, rhs: lhs + rhs,
    '-': lambda lhs, rhs: lhs - rhs,
    '*': lambda lhs, rhs: lhs * rhs,
    '/': lambda lhs, rhs: lhs // rhs,
}

while True:
    arr = (stdin.readline().rstrip().split())
    a, op, b = int(arr[0]), arr[1], int(arr[2])

    if op == '?':
        break

    answer = operate[op](a, b)

    print(answer)



Measured memory_bytes: 5604
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
typedef long long ll;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define FOR(i,n) for(int i=0;i<n;i++)
#define all(s) s.begin(),s.end()
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e18;


signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int k,n;
    cin>>k>>n;
    vector<int>a(n);
    rep(i,0,n){
        cin>>a[i];
    }
    int ans = INF;
    rep(i,0,n-1){
        ans = min(ans,k-(a[i+1]-a[i]));
    }
    ans=min(ans,a[n-1]-a[0]);
    cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include <iostream>
#define D 6
using namespace std;

class dice {
    int f[D];
public:
    dice() {}
    
    void set(int n[]) {
        for (int i = 0; i < D; i++)
            f[i] = n[i];
    }
    
    void roll(int a, int b, int c, int d) {
        int t = f[a];
        f[a] = f[b];
        f[b] = f[c];
        f[c] = f[d];
        f[d] = t;
    }
    
    void rollX() { roll(0, 2, 5, 3); }
    void rollY() { roll(0, 1, 5, 4); }
    void rollZ() { roll(1, 2, 4, 3); }
    
    bool friend same(dice d1, dice d2);
};

bool same(dice d1, dice d2)
{
    for (int i = 0; i < D; i++) {
        for (int j = 0; j < 4; j++) {
            int k = 0;
            while (1) {
                if (d1.f[k] == d2.f[k]) {
                    k++;
                    if (k == D)
                        return true;
                } else {
                    break;
                }
            }
            d1.rollZ();
        }
        if (i % 2 == 0)
            d1.rollY();
        else
            d1.rollX();
    }
    return false;
}

int main()
{
    int num[D], n;
    
    cin >> n;
    dice d[n];

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < D; j++) {
            cin >> num[j];
        }
        d[i].set(num);
    }

    for (int i = 0; i < n - 1; i++) {
        for (int j = i + 1; j < n; j++) {
            if (same(d[i], d[j])) {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
#define rep(i, n) for (long long int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
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;
}
const long long INF = 1LL << 60;
int cnt = 0;
bool kaibun(string str)
{
    bool flag = true;
    for (int i = 0; i < str.length() / 2; i++)
    {
        if (str[i] != str[str.length() - i - 1])
        {
            flag = false;
            break;
        }
    }
    return flag;
}
int main()
{
    string s;
    cin >> s;
    string s1 = s.substr(0, s.length() / 2);
    string s2;
    if (s.length() % 2 == 0)
    {
        s2 = s.substr(s.length() / 2, s.length() / 2);
    }
    else
    {
        s2 = s.substr(s.length() / 2 + 1, s.length() / 2);
    }
    if (kaibun(s) && kaibun(s1) && kaibun(s2))
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#include <set>
#include <numeric>
#define rep(i,n) for (int i=0; i < (n); ++i)
#define all(a) a.begin(), a.end()
using ll = long long;
using namespace std;
 
// ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }




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

  double y=0;
  for (int i =0;i<n;i++) {
    double num;
    string s;
    cin >> num >> s;
    if (s=="BTC") {
      y += num*380000;
    }
    else {
      y += num;
    }
  }
  cout << y << endl;

}

Measured memory_bytes: 256
import sys

def input():
    return sys.stdin.readline().strip()

def main():

    N,M = map(int,input().split())
    A = sorted(list(map(int,input().split())))
    BC = [list(map(int,input().split())) for _ in range(M)]
    BC = sorted(BC,reverse=True,key=lambda x: x[1])
    D = []

    for B,C in BC:
        for b in range(B):
            if len(D) != N:
                D.append(C)
            else:
                break
        else:
            continue
        break

    for i in range(len(D)):
        if A[i] < D[i]:
            A[i] = D[i]
        else:
            break

    print(sum(A))

if __name__ == "__main__":
    main()

Measured memory_bytes: 33884
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cstring>
using namespace std;

const int N = 200200;
int n;
char s[N];

int main()
{
	int ans = 0;
	int bal = 0;
	scanf(" %s ", s);
	n = strlen(s);
	for (int i = 0; i < n; i++)
	{
		if (s[i] == 'T')
			bal++;
		else
			bal--;
		ans = max(ans, 2 * bal);
	}
	printf("%d\n", ans);

	return 0;
}

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

int H, W;
int N;
int x, y;
char S[200005], T[200005];
int U, D, L, R;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> H >> W >> N;
    cin >> x >> y;
    cin >> S;
    cin >> T;
    for (int i=0; i<N; i++){
        if (S[i] == 'U') U++;
        if (S[i] == 'D') D++;
        if (S[i] == 'L') L++;
        if (S[i] == 'R') R++;
        if (x-max(U, 0)<=0 || x+max(D, 0)>H || y-max(L, 0)<=0 || y+max(R, 0)>W){
            cout << "NO" << endl;
            return 0;
        }
        if (T[i] == 'U' && x+D-1>0) D--;
        if (T[i] == 'D' && x-U+1<=H) U--;
        if (T[i] == 'L' && y+R-1>0) R--;
        if (T[i] == 'R' && y-L+1<=W) L--;
        if (x-max(U, 0)<=0 || x+max(D, 0)>H || y-max(L, 0)<=0 || y+max(R, 0)>W){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout <<"YES" << endl;
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int k = Integer.parseInt(sc.next());
        long ans = k;
        for (int i = 0; i < n - 1; i++) {
            ans *= (k - 1);
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
int main(){
	string s, t; cin >> s >> t;
	int lens = s.size(), lent = t.size();
	vector<int> pref_s(lens + 1, 0), pref_t(lent + 1, 0);
	for(int i = 0; i < lens; i++){
		pref_s[i + 1] = pref_s[i] + (s[i] == 'A');
	}
	for(int i = 0; i < lent; i++){
		pref_t[i + 1] = pref_t[i] + (t[i] == 'A');
	}
	int q; cin >> q;
	for(int i = 0; i < q; i++){
		int a, b, c, d; cin >> a >> b >> c >> d;
		int sA = pref_s[b] - pref_s[a - 1], sB = b - a + 1 - sA;
		int tA = pref_t[d] - pref_t[c - 1], tB = d - c + 1 - tA;
		sA %= 3; sB %= 3;
		tA %= 3; tB %= 3;
		bool can = false;
		int nA = sA, nB = sB;
		for(int k = 0; k < 4; k++){
			nA += 2; nA %= 3;
			nB += 2; nB %= 3;
			if(nA == tA && nB == tB){
				can = true;
			}
		}
		if(can) printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}


Measured memory_bytes: 1792
//! ----------------------------------------------
//! 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 N = read!(usize);

    let mut ok = true;
    let mut t1 = 0;
    let mut x1 = 0;
    let mut y1 = 0;

    for _ in 0..N {
        let (t2, x2, y2) = read!(i64, i64, i64);

        t1 += (x2 - x1).abs() + (y2 - y1).abs();
        if t1 > t2 || (t2 - t1) % 2 != 0 {
            ok = false;
            break;
        }

        t1 = t2;
        x1 = x2;
        y1 = y2;
    }

    println!("{}", if ok { "Yes" } else { "No" })
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(i, n) for(int i=0; i<=n; i++)
#define repr(i, n) for(int i=n; i>0; i--)
#define REPR(i, n) for(int i=n; i>=0; i--)
const ll INF = 1LL<<60;
const int INT_INF = 1e9;
const ll MOD = 1e9+7;
template<class T> void puts(T x) { std::cout << x << std::endl; }
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; }
using namespace std;

struct UnionFind {
    vector<int> parent;

    // Constructor
    UnionFind(int n) {
        parent.resize(n);
        rep(i, n) parent[i] = i;
    }

    // 親を取得
    int root(int x) {
        if (parent[x] == x) {
            return x;
        } else {
            parent[x] = root(parent[x]);
            return parent[x];
        }
    }

    // 二つのデータを同じ木にくっつける
    void connect(int x, int y) {
        int rx = root(x);
        int ry = root(y);

        if (rx == ry) return; // 元から同じ木に属する場合は何もしない
        parent[rx] = ry;
    }

    // 二つのデータが同じ木に属するか判定
    bool check(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main() {
    int n, m; cin >> n >> m;
    UnionFind tree(n);
    rep(i, m) {
        int s, t; cin >> s >> t;
        tree.connect(s, t);
    }
    int q; cin >> q;
    rep(i, q) {
        int s, t; cin >> s >> t;
        cout << (tree.check(s, t) ? "yes" : "no") << endl;
    }
}



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

long long a;
vector<int> pos;

int f[20], g[20];

int main(){
	cin >> a;
	{
		long long n = a;
		while(n){
			pos.push_back(n % 10);
			n /= 10LL;
		}
		pos.push_back(0);
		reverse(pos.begin() , pos.end());
	}
	f[1] = pos[1];
	for(int i = 0 ; i < pos[1] ; i++)
		g[1] = i;

	for(int i = 2 ; i < pos.size() ; i++){
		f[i] = f[i - 1] + pos[i];
		g[i] = g[i - 1] + 9;
		if(pos[i] >= 1)
			g[i] = max(g[i] , f[i - 1] + pos[i] - 1);
	}
	cout << max(f[pos.size() - 1] , g[pos.size() - 1]) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  int N;
  cin >> N;
  int a[N], b[N], c[N], cost;
  int dp[N][3];
  for(int i=0; i<N; i++) cin >> a[i] >> b[i] >> c[i];
  dp[0][0] = a[0]; dp[0][1] = b[0]; dp[0][2] = c[0];
  for(int i=1; i<N; i++){
    dp[i][0] = max(dp[i-1][1]+a[i],dp[i-1][2]+a[i]);
    dp[i][1] = max(dp[i-1][0]+b[i],dp[i-1][2]+b[i]);
    dp[i][2] = max(dp[i-1][0]+c[i],dp[i-1][1]+c[i]);
  }
  cost = max(dp[N-1][0], dp[N-1][1]);
  cost = max(cost, dp[N-1][2]);
  cout <<  cost << endl;
  return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
ll gcd(int a,int b){if(a%b==0){return b;}else{return(gcd(b,a%b));}}
ll lcm(int a,int b){return a*b/gcd(a,b);}
const int INF=1e9;
const ll INFS=1e18;
const int MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
const double PI=acos(-1);

int main() {
  int n,y;
  cin>>n>>y;
  for(int i=0;i<=n;i++){
    for(int j=0;j<=n-i;j++){
      if(i*10000+j*5000+(n-i-j)*1000==y){
        cout<<i<<" "<<j<<" "<<(n-i-j)<<endl;
        return 0;
      }
    }
  }
  cout<<"-1 -1 -1"<<endl;
}

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

const ll INF = 100000000000;

int main() {
  int H, N;
  cin >> H >> N;
  vector<pair<ll, ll>> P(N);
  rep(i, N) {
    ll a, b;
    cin >> a >> b;
    P[i].first = a;
    P[i].second = b;
  }
  vector<ll> dp(H+1, INF);
  dp[H] = 0;
  for (int i = H; i >= 0; i--) {
    for (int j = 0; j < N; j++) {
      if (P[j].first + i > H) continue;
      else {
        ll r = dp[i + P[j].first] + P[j].second;
        dp[i] = min(r, dp[i]);
      }
    }
  }
  ll ans = INF;
  for (int i = 0; i < H+1; i++) {
    if (dp[i] == INF) continue;
    if (i == 0) ans = dp[i];
    for (int j = 0; j < N; j++) {
      if (i - P[j].first > 0) continue;
      ll h = dp[i] + P[j].second;
      ans = min(ans, h);
    }
  }
  cout << ans << endl;
}

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

#define INF (1<<30)

#define Rep0(i, n)  for (int i=0; i<n; i++)

int main() {
    int n;
    cin >>n;
    vector<int> a(n, 0);
    Rep0(i, n)
        cin >>a.at(i);
    vector<int> DP(n, INF);
    Rep0(i, n) {
        int A=a.at(i);
        int ix=lower_bound(DP.begin(), DP.end(), A)-DP.begin();
        DP.at(ix)=A;
    }
    cout <<lower_bound(DP.begin(), DP.end(), INF)-DP.begin() <<endl;
    return 0;
}


Measured memory_bytes: 3564