akhauriyash/Code-Regression huggingface dataset:
import sys
import numpy as np

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))


D = ini()
C = inl()
assert len(C) == 26
S = np.zeros((D, 26), dtype="int32")
for i in range(D):
    S[i, :] = inl()


def calc_score(sol):
    last = -np.ones((26, D + 1))
    score = 0
    for d in range(D):
        ct = sol[d]
        score += S[d, ct]
        for i in range(26):
            last[i, d + 1] = last[i, d]
        last[ct, d + 1] = d
        for i in range(26):
            score -= C[i] * (d - last[i, d + 1])
    return score, last


def main():
    sol = np.random.randint(0, 26, D)
    sol_bak = sol.copy()
    max_score, last = calc_score(sol)
    last_bak = last.copy()

    def update(d, before, after):
        score = max_score
        score -= S[d, before]
        score += S[d, after]
        lb = last[before, d]
        la = last[after, d]
        da = db = 0
        for x in range(d, D):
            if x > d and sol[x] == before:
                break
            last[before, x + 1] = lb
            db += 1
        score -= C[before] * (d - lb) * db
        for x in range(d, D):
            if x > d and sol[x] == after:
                break
            last[after, x + 1] = d
            da += 1
        score += C[after] * (d - la) * da
        sol[d] = after
        return score

    for i in range(10000):
        new_d = np.random.randint(0, D)
        c_after = np.random.randint(0, 26)
        c_before = sol[new_d]
        if c_before == c_after:
            continue
        new_score = update(new_d, c_before, c_after)
        if max_score < new_score:
            max_score = new_score
            sol_bak = sol.copy()
            last_bak[c_before, :] = last[c_before, :].copy()
            last_bak[c_after, :] = last[c_after, :].copy()
        else:
            sol = sol_bak.copy()
            last[c_before, :] = last_bak[c_before, :].copy()
            last[c_after, :] = last_bak[c_after, :].copy()

    print(*(sol + 1), sep="\n")


main()


Measured memory_bytes: 27608
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cctype>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>
#include <bitset>
#include <iterator>
#include <iomanip>
#include <sstream>
#define INF 2000000000
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
#define sym cout<<"-----------"<<endl;
#define ll long long
#define P pair<int,int>
#define mk make_pair
#define en endl
#define RE return 0
#define int ll


// B

int grid[105][105];

signed main(){
  int h,w;
  cin>>h>>w;
  for(int i=1; i<=h; i++) for(int j=1; j<=w; j++){
    char ch; cin>>ch;
    if(ch=='.') grid[i][j]=0;
    else grid[i][j]=1;
  }

  set<int> yoko;
  for(int i=1; i<=h; i++){
    bool black=false;
    for(int j=1; j<=w; j++){
      if(grid[i][j]==1) black=true;
    }
    if(black) continue;
    else yoko.insert(i);
  }
  set<int> tate;
  for(int j=1; j<=w; j++){
    bool black=false;
    for(int i=1; i<=h; i++){
      if(grid[i][j]==1) black=true;
    }
    if(black) continue;
    tate.insert(j);
  }

  for(int i=1; i<=h; i++){
    if(yoko.find(i)!=yoko.end()) continue;
    for(int j=1; j<=w; j++){
      if(tate.find(j)!=tate.end()) continue;
      if(grid[i][j]==1) cout<<'#';
      else cout<<'.';
    }
    cout<<en;
  }
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, s, e) for(int i = s; i < e; i++)
#define rrep(i, s, e) for(int i = s; i > (s)-(e); i--)
#define pr(s) std::cout << s << std::endl
#define prb(s) std::cout << s
using namespace std;



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


  int n, a;
  cin >> n >> a;

  pr(n*n -a);


  return 0;
}


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

int main() {
    int n;
    cin >> n;
    int t[n];
    for (int i = 0; i < n; i++) {
        cin >> t[i];
    }
    int m;
    cin >> m;
    int p[m], x[m];
    for (int i = 0; i < m; i++) {
        cin >> p[i] >> x[i];
    }
    for (int d = 0; d < m; d++) {
        int time = 0;
        for (int q = 0; q < n; q++) {
            if (q == p[d] - 1)
                time += x[d];
            else
                time += t[q];
        }
        cout << time << endl;
    }

    return 0;
}

Measured memory_bytes: 3596
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define enld endl //* missspell check
const ll INF = 1LL << 60;


void solve(long long N, long long K, std::vector<long long> a){
    vll s(N+1, 0);
    REP(i, N){
        s[i+1] = s[i]+a[i];
    }
    vll R;
    REP(i, N){
        for(ll j = i+1; j <= N; j++){
            R.emplace_back(s[j]-s[i]);
        }
    }
    vll rec;
    for(ll digit=63; digit >=0; digit --){
        ll tmp = 0;
        sort(ALL(R)); reverse(ALL(R));
        REP(i, R.size()){
            if(R[i] >> digit & 1){
                tmp++;
            }
        }
        if(tmp < K){
            REP(i, R.size()){
                R[i] = R[i] & ~(1LL<<digit);
            }
        }
        else{
            R.resize(tmp);
            rec.push_back(digit);
        }
    }
    ll res = 0;
    for(auto x: rec){
        res += 1LL<<x;
    }
    cout<<res<<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    std::vector<long long> a(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&a[i]);
    }
    solve(N, K, std::move(a));
    return 0;
}


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

int main()
{
    int n,k;
    cin>>n>>k;
    int a=0,b=0;
    for(int i=1;i<=n;i++)if(i%k==0)a++;
   if(k%2==0) for(int i=1;i<=n;i++)if(i%k==k/2)b++;
    long long ans=pow(a,3)+pow(b,3);
    cout<<ans<<endl;
}


Measured memory_bytes: 384
#include <stdio.h>

int main() {
  int A,B,C;
  scanf("%d %d",&A,&B);
  while((0>A)&&(B>23)){
     scanf("%d %d",&A,&B);
  }
  C=A+B;
  while(C>=24){
    C=C-24;
  }
  printf("%d",C);
  return 0;
}

Measured memory_bytes: 1704
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;


template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


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


#define ARRAY_MAX 100005
const int INF = 1e9 + 7;
const ll MOD = 1e9 + 7;

int dx4[4] = { 1,0,0,-1 };
int dy4[4] = { 0,1,-1,0 };
int dx2[2] = { 1,0 };
int dy2[2] = { 0,1 };

/******************************************************************************************/
typedef tuple<int,int,int> tpl;

int main() {

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

    int n,m;
    cin >> n >> m;
    vector<int> a(n);

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

    int cnt = 0;

    for (int i = 0; i < n; i++)
    {
        if(a[i]*4*m >= sum){
            cnt++;
        }
    }
    
    if(cnt >= m){
        cout << "Yes" << endl;
    }else
    {
        cout << "No" << endl;
    }
    

	return 0;
}



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

int main()
{
  std::string s, t, u;
  int a, b;
  std::cin >> s >> t >> a >> b >> u;
  
  if (s == u)
  {
    a--;
  }
  else
  {
    b--;
  }
  std::cout << a << " " << b;
  return 0;
}

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

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


Measured memory_bytes: 3112
#include <cstdio>
#include <iostream>

using namespace std;

int main(){
	int q;
	scanf(" %d", &q);
	for(int i=0; i<q; ++i){
		string a, b;
		cin >> a >> b;
		
		int m=a.size(), n=b.size();
		
		string x=" "+a;
		string y=" "+b;
		
		int c[1001][1001]={0};
		for(int i=1; i<=m; ++i) c[i][0]=0;
		for(int i=1; i<=n; ++i) c[0][n]=0;
		
		int ans=0;
		for(int i=1; i<=m; ++i){
			for(int j=1; j<=n; ++j){
				if(x[i]==y[j]) c[i][j]=c[i-1][j-1]+1;
				else c[i][j]=max(c[i][j-1], c[i-1][j]);
				
				ans=max(ans,c[i][j]);		
			}
		}
		
		printf("%d\n", ans);
	}
}



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

using namespace std;

int main() {
  string T;
  
  cin >> T;
  
  for (int i = 0; i < T.length(); i++) {
    if (T[i] == '?') {
      T[i] = 'D';
    }
  }
  
  cout << T << endl;
  
  return 0;
}

Measured memory_bytes: 3680
n, k=gets.split.map(&:to_i)

if k==0
  puts n*n
  exit 0
end

ret=0
((k+1)..n).each do |b|
  if n-b+1<b
    ret+=[(n-b+1)-k, 0].max
  else
    m=n-b+1
    ret+=m/b*(b-k)
    l=m/b*b
    ret+=[m-l-k, 0].max 
  end
end

puts ret+(n-k)*(n-k+1)/2

Measured memory_bytes: 1788
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.lang.StringBuilder
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val s = sc.nextLine()
    val n = s.length
    val first = Array(n) { 0 }
    var left = 0
    for (i in 0 until n) {
        if (s[i] == 'L') {
            if (i > 0 && s[i - 1] == 'R') {
                for (j in left until i) {
                    first[j] = i
                }
                left = i - 1
            }
            first[i] = left
        } else {
            if (i > 0 && s[i - 1] == 'L') {
                left = i
            }
        }
    }
    val ans = Array(n) { 0 }
    for (i in 0 until n) {
        val d = Math.abs(i - first[i])
        if (d % 2 == 0) {
            ans[first[i]]++
        } else if (s[first[i]] == 'L') {
            ans[first[i] - 1]++
        } else {
            ans[first[i] + 1]++
        }
    }
    println(ans.joinToString(" "))
}

fun main(args: Array<String>) {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}

Measured memory_bytes: 42856
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> a(m);
    vector<int> b = {-1, 2, 5, 5, 4, 5, 6, 3, 7, 6};
    rep(i, m)cin >> a[i];
    rep(i, 10){
        bool v = false;
        rep(j, m)if(i == a[j])v = true;
        if(!v)b[i] = -1;
    }
    vector<string> dp(n+1, "");
    for(int i = 0; i <= n; i++){
        for(int j = 9; j > 0; j--){
            if(b[j] == -1)continue;
            if(i + b[j] > n)continue;
            if(i > 0 && dp[i].size() == 0)continue;
            if(dp[i+b[j]].size() < dp[i].size() + 1){
                char c = '0' + j;
                dp[i+b[j]] = dp[i] + c;
            }else if(dp[i+b[j]].size() == dp[i].size() + 1){
                char c = '0' + j;
                string s = dp[i] + c;
                vector<int> cnt1(10), cnt2(10);
                rep(k, s.size()){
                    cnt1[s[k]-'0']++;
                    cnt2[dp[i+b[j]][k]-'0']++;
                }
                for(int k = 9; k > 0; k--){
                    if(cnt1[k] > cnt2[k]){
                        dp[i+b[j]] = s;
                        break;
                    }else if(cnt1[k] < cnt2[k])break;
                }
            }
        }
    }
    sort(dp[n].begin(), dp[n].end(), greater<char>());
    cout << dp[n] << endl;
}

Measured memory_bytes: 44032
#include<cstdio>
#include<string>
#include<iostream>
#include<queue>
using namespace std;

struct Node{
    string name;
    int time;
    Node(string name, int y):name(name), time(y){}
};

queue<Node> a;

int main(){
    int n, q;
    scanf("%d%d", &n, &q);
    for(int i = 0; i < n; i++){
        string name;
        int time;
        cin >> name >> time;
        a.push(Node(name, time));
    }
    int time = 0;
    while(!a.empty()){
        if(a.front().time > q){
            time += q;
            a.push(Node(a.front().name, a.front().time - q));
            a.pop();
        }
        else{
            time += a.front().time;
            cout << a.front().name << " " << time << endl;
            a.pop();
        }
    }
    return 0;
}



Measured memory_bytes: 6368
#include <iostream>
using namespace std;
int main(){
	int a,b,c,x,sum=0;
	cin>>a>>b>>c>>x;
	for(int i=0;i<=a;i++){
		for(int j=0;j<=b;j++){
			for(int k=0;k<=c;k++){
				if((i*500+j*100+k*50)==x) sum++;
			}
		}
	}
	cout<<sum;
}

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

int main(){
    int n;
    long R[200005]={};
    long R_min,R_max=-1e9;
    cin>>n;
    for(int i=0; i<n; i++){
        cin>>R[i];
    }
    R_min=R[0];
    for(int i=1; i<n; i++){
        R_max=max(R_max, R[i]-R_min);
        R_min=min(R_min, R[i]);
    }
    cout<<R_max<<endl;
}

Measured memory_bytes: 4676
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pf push_front

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

#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
int main(){
int n,m;
cin>>n>>m;

if(n>=m)
	cout<<0<<endl;
else{

vl v(m);
rep(i,m)
cin>>v[i];
sort(All(v));
vl diff(m-1);
rep(i,m-1)
diff[i]=v[i+1]-v[i];
sort(All(diff));
cout<<accumulate(diff.begin(),diff.end()-n+1,0)<<endl;
}

	return 0;
}

Measured memory_bytes: 1792
package main

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

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	var mask int
	k := getNextInt(scanner)
	for i := 0; i < k; i++ {
		b := getNextInt(scanner)
		mask = mask | (1 << uint(b))
	}
	for i := 0; i < 1<<uint(n); i++ {
		if mask != i&mask {
			continue
		}
		fmt.Fprintf(writer, "%d:", i)
		for j := 0; j < n; j++ {
			if (i>>uint(j))&1 == 1 {
				fmt.Fprint(writer, " ")
				fmt.Fprint(writer, j)
			}
		}
		fmt.Fprintln(writer, "")
	}
}



Measured memory_bytes: 5336
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 998244353;
const ll N = 720006;
const ll INF = 1e18;

ll f[N];
ll dp[N];

void upd(ll pos, ll val) {
    for(; pos < N; pos += pos & (-pos)) {
        f[pos] += val;
        f[pos] %= mod;
        f[pos] += mod;
        f[pos] %= mod;
    }
}
ll q(ll pos) {
    ll ans = 0;
    for(; pos; pos -= pos & (-pos)) {
        ans += f[pos];
        ans %= mod;
        ans += mod;
        ans %= mod;
    }
    return ans;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll n, k;
    cin >> n >> k;

    vector<pair<ll,ll>> in;
    for(int i = 1; i <= k; i++) {
        ll x, y;
        cin >> x >> y;
        in.pb({x, y});
    }

    upd(1, +1);
    upd(2, -1);
    
    for(int i = 1; i <= n; i++) {
        dp[i] = q(i);
        for(int j = 0; j < k; j++) {
            ll l = i + in[j].first;
            ll r = i + in[j].second;
            upd(l, +dp[i]);
            upd(r + 1, -dp[i]);
        }
    }

    cout << dp[n] << '\n';
    return 0;
}

Measured memory_bytes: 8288
import math,numpy, collections

a,b = map(int,input().split())
ans = 2018**2
if b-a >=2019:
    ans = 0
else:
    aa, bb = a%2019,b%2019
    for i in range(aa,bb):
        for j in range(i+1,bb+1):
            ans = min(ans,i*j%2019)

print(ans)

Measured memory_bytes: 12508
N = int(input())
F = []
for _ in range(N):
    Fi = list(map(int,input().split()))
    F.append(Fi)
P = []
for _ in range(N):
    Pi = list(map(int,input().split()))
    P.append(Pi)

l = ['0','1']
def n_ary1(l,d): # リストl中の文字でd桁を全列挙(sorted)
    if d == 1:
        return(l)
    ll = n_ary1(l,d-1)
    lll = []
    for i in l:
        for j in ll:
            lll.append(i+j)
            #lll.append(int(i+j)) ## n進数の場合
    return(lll)

def l_and(l1,l2):
    s = 0
    for i in range(len(l1)):
        s += int(l1[i])&int(l2[i])
    return(s)

JJ = n_ary1(l,10)[1:]
ans = -float('inf')
for J in JJ:
    C = [l_and(F[i],J) for i in range(N)]
    p = sum([P[i][C[i]] for i in range(N)])
    ans = max(ans,p)
print(ans)


Measured memory_bytes: 3316
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds ;
#define ll long long
#define ld long double
#define rep(i,a,b) for(ll i=a;i<b;i+=1)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define sz(a) (ll)a.size()
#define hell (ll)1000000007
#define f first
#define s second
#define sll(x) scanf("%lld",&x)
#define si(x) scanf("%d",&x)
typedef tree< ll , null_type , less<ll> , rb_tree_tag , tree_order_statistics_node_update > ordered_set ;
ll t = 1 , tt  , ttt ;
void solve()
{
    ll n , a , x , cur = 0 , ans = 1 ;
    cin >> n >> x ;
    rep( i , 0 , n )
    {
        cin >> a ;
        cur += a ;
        if( cur <= x )ans++;
    }
    cout << ans ;
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen("tourist.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //cin>>t;
    ttt = t ;
    tt = t ;
    while(t--)
        solve() ;
    return 0 ;
}


Measured memory_bytes: 256
//自称高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define MODA 1000000007 

int main() {
    int ans = 0;
	string s;
	cin >> s;
	if(s[0]==s[1] && s[2] == s[3] && s[0]!=s[2]) cout << "Yes" << endl;
	else if(s[0]==s[2] && s[1] == s[3] && s[0]!=s[1]) cout << "Yes" << endl;
	else if(s[0]==s[3] && s[1] == s[2]  && s[0]!=s[1]) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;

int gcd(int a, int b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}

int main() {
    int n; cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) cin >> a[i];
    vector<int> left(n + 1, 0), right(n + 1, 0);

    left[1] = a[0];
    for (int i = 2; i <= n; ++i) left[i] = gcd(left[i - 1], a[i - 1]);
    for (int i = n - 1; 0 <= i; --i) right[i] = gcd(right[i + 1], a[i]);

    int res = 0;
    for (int i = 0; i < n; ++i) {
        int tmp = gcd(left[i], right[i+1]);
        if (res < tmp) res = tmp;
    }

    cout << res << endl;
}


Measured memory_bytes: 1408
#include <cstdio>
#include <string>
#include <iostream>
#include <vector>
#include <list>
#include <cmath>
#include <iomanip>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>


typedef unsigned long long ULONG;
typedef long long LONG;
using namespace std;

#define PI 3.1415926535897932384626433
#define _DBG_





int main(void) {
	ULONG N;
	cin >> N;
//	N = 475254;
	vector<char> ans;
	

	while(true){
		int tmpi = N % (ULONG)26;
		if (tmpi == 0) {
			tmpi = 26;
			N = N - 1;
		}
		char anc = 'a' + tmpi - 1;
		ans.push_back(anc);

		N = N / 26;
		if (N == 0)break;

	}

	for (int i = ans.size() - 1; i >= 0; i--) {
		cout << ans[i];
	}
	cout << endl;



	return 0;
}

Measured memory_bytes: 3628
#include<iostream>
using namespace std;
int main(){
	int n,t;
	cin>>n>>t;
	int a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	int count=0;
	for(int i=0;i<n;i++){
		if(a[i]>=t){
			count++;
		}
		else if(a[i]<t){
			continue;
		}
	}
	cout<<count<<endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
typedef long long ll;
struct edge { ll s, t, x; };
typedef pair<ll, ll> P;
typedef pair<ll,P> event;
const ll MAX = 510000;
const ll MOD = 1000000007;
#define INF (ll)100000000000000
ll G[310][310];
ll L;
ll N,M,Q;
P dist[310][310];
int main() {
  cin>>N>>M>>L;
  rep(i,310){rep(j,310){G[i][j]=INF;}}
  rep(i,M){
    ll a,b,c;
    cin>>a>>b>>c;
    a--;b--;
    G[a][b]=c;
    G[b][a]=c;
  }
  cin>>Q;
  rep(i,310){
    rep(j,310){
      dist[i][j]=P(INF,INF);
    }
  }
  rep(i,310){dist[i][i]=P(0ll,0ll);}
  //始点をiとする。
  rep(i,N){
    bool used[N];
    rep(j,N){used[j]=false;}
    while(true){
      int v=-1;
      rep(u,N){
        if(!used[u]&&(v==-1||dist[i][u]<dist[i][v])){v=u;}
      }
      if(v==-1)break;
      used[v]=true;
      rep(u,N){
        auto x=dist[i][v].first;
        auto y=dist[i][v].second;
        if(G[u][v]>L){continue;}
        y+=G[u][v];
        if(y>L){y=G[u][v];x+=1ll;}
        auto g=P(x,y);
        dist[i][u]=min(dist[i][u],g);
      }
    }
  }
  rep(m,Q){
    int s,t;cin>>s>>t;
    s--;t--;
    if(dist[s][t].first==INF){cout<<-1<<endl;}
    else{cout<<dist[s][t].first<<endl;}
  }
  
}

Measured memory_bytes: 5884
using System;
using System.Linq;

class Pratice
{
    public static void Main()
    {
        string[] str = Console.ReadLine().Split(' ');
        int r = int.Parse(str[0]), c = int.Parse(str[1]);
        int[,] sheet = new int[r + 1, c + 1];
        for (int i = 0; i < r; ++i)
        {
            string[] row = Console.ReadLine().Split(' ');
            for (int j = 0; j < c; ++j)
            {
                sheet[i, j] = int.Parse(row[j]);
                sheet[i, c] += sheet[i, j];
            }
        }
        for (int i = 0; i < r; ++i)
        {
            for (int j = 0; j <= c; ++j)
            {
                sheet[r, j] += sheet[i, j];
            }
        }
        for (int i = 0; i <= r; ++i)
        {
            for (int j = 0; j <= c; ++j)
            {
                if (j != 0) Console.Write(' ');
                Console.Write(sheet[i, j]);
            }
            Console.WriteLine();
        }
    }
}


Measured memory_bytes: 17896
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define sz(a) a.size()
#define re return
#define all(a) a.begin(),a.end()
using namespace std;
signed main()
{
	long long x;
	cin>>x;
	long long z=-1000;
	for (long long i=0;;i++){
		long long y=i*i*i*i*i;
		y-=x;
		while (z*z*z*z*z<y)  z++;
		if (z*z*z*z*z==y){
			cout<<i<<' '<<z;
			re 0;
		}
	}
	re 0;
}

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

int main() {
  int a, b, c;
  scanf("%d %d %d", &a, &b, &c);
  string ans = "NO";
  for(int i = 1; i <= b; i++) {
    if(a * i % b == c) {
      ans = "YES";
      break;
    }
  }
  cout << ans;
}

Measured memory_bytes: 3668
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;
typedef vector<P> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<ll,vector<ll>,greater<ll>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
const int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30);
const int INF = (1LL << 60);
const double EPS = (1 >> 30);
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }
template< typename T > istream &operator>>(istream &is, vector< T > &v) { for(T &in : v) is >> in; return is; }



signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    int x;
    cin>>x;
    int memo=0;
    rep(i,INF){
        memo+=i;
        if(memo>=x){
            cout<<i<<endl;
            break;
        }
    }
    
}

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

int main(){
  int n;
  cin >> n;
  vector<string> city(n);
  vector<int> point(n);
  vector<pair<string, int>> x(n);
  rep(i, n){
    cin >> city[i] >> point[i];
    x[i].first = city[i];
    x[i].second = -1*point[i];
  }
  
  sort(x.begin(), x.end());
  rep(i, n){
    rep(j, n){
      if(x[i].first == city[j] && x[i].second == -1*point[j]) cout << j+1 << endl;
    }
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
#define SIZE_OF_ARRAY(a) (sizeof(a)/sizeof(a[0]))

unsigned GetDigit(unsigned num){
    return std::to_string(num).length();
}



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int ans  = 0;
    string ans2;
    int A,B;
    string C;
    cin >> A >> B;
    for(int i = A;i <= B;i++){
        C = to_string(i);
        if(C.at(0) == C.at(4) && C.at(1) == C.at(3))
            ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include "iostream"
#include "string"
#include "vector"
#include "algorithm"
#include "functional"
#include "cmath"

using namespace std;

#define INF (INT32_MAX / 2)

int main() {
    // get values from input
    int N, M;
    cin >> N >> M;

    vector<int> a(M), b(M), c(M);
    // dp[i][j]: shortest length from node i to node j
    vector<vector <int>> dp(N, vector<int>(N, INF));

    for (int i = 0; i < M; ++i) {
        int ai, bi, ci;
        cin >> ai >> bi >> ci;

        ai--;
        bi--;
        a[i] = ai;
        b[i] = bi;
        c[i] = ci;
        dp[ai][bi] = ci;
        dp[bi][ai] = ci;
    }

    // main procedure
    for (int i = 0; i < N; ++i) {
        dp[i][i] = 0;
    }

    int answer = 0;

    for (int i = 0; i < N; ++i) {
        for (int a = 0; a < N; ++a) {
            for (int b = 0; b < N; ++b) {
                dp[a][b] = min(dp[a][b], dp[a][i] + dp[i][b]);
            }
        }
    }

    // ###DEBUG###
    // ========================================
//    for (auto row : dp) {
//        for (auto s : row) {
//            cout << s << " ";
//        }
//        cout << endl;
//    }
    // ========================================

    for (int i = 0; i < M; ++i) {
        bool is_shortest = false;
        for (int x = 0; x < N - 1; ++x) {
            for (int y = x + 1; y < N; ++y) {
                if (dp[x][y] < INF && dp[x][y] == dp[x][a[i]] + dp[b[i]][y] + c[i]) {
                    is_shortest = true;
                    break;
                }
                if (dp[x][y] < INF && dp[x][y] == dp[x][b[i]] + dp[a[i]][y] + c[i]) {
                    is_shortest = true;
                    break;
                }
            }
            if (is_shortest) {
                break;
            }
        }
        if (!is_shortest) {
            answer++;
        }
    }

    // output
    cout << answer << endl;
    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
    ll N, M; cin >> N >> M;
    if(N == 1 && M == 1) {
        cout << 1 << endl;
        return 0;
    }
    else if(N == 1) {
        cout << M - 2 << endl;
        return 0;
    }
    else if(M == 1) {
        cout << N - 2 << endl;
        return 0;
    } else {
        cout << (N - 2) * (M - 2) << endl;
    }
	return 0;
}

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

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

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

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

#define en "\n"

const double EPS = 1e-9;
const double PI  = acos(-1.0);
const int INF = 2147483647;
const long long LINF = 1LL<<60;
const long long MOD = 1000000007; // 998244353

#define CLR(a) memset((a), 0, sizeof(a))

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

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

VI dp;
VVI v;

int rec(int n){
    if(dp[n] != -1) return dp[n];
    int ret = 0;
    VI cand;
    for(int i : v[n]){
        cand.push_back(rec(i));
    }
    SORT(cand); REVERSE(cand);
    REP(i,cand.size()) chmax(ret, cand[i]+i);
    return dp[n] = ret + 1;
}

int main(void){
    int N; cin >> N;
    dp.assign(N,-1); v.resize(N);
    VI a(N); REP(i,N-1) cin >> a[i+1];
    REP(i,N-1){
        v[a[i+1]-1].push_back(i+1);
    }
    REP(i,N) dp[i] = rec(i);
    cout << dp[0]-1 << en;
    return 0;
}

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

using namespace std;

string s[55];
int cnt[300][55];

int main() { 
    int t, n;
    cin >> t;
    for (int i = 0; i < t; ++i) {
        cin >> s[i];
        n = s[i].length();
        for (int j = 0; j < n; ++j) cnt[s[i][j]][i]++;
    }
    for (int j = 'a'; j <= 'z'; ++j) {
        int mx = 55;
        for (int i = 0; i < t; ++i) {
            mx = min(cnt[j][i], mx);
        }
        while (mx) {
            cout << (char)j;
            --mx;
        }
    }
    cout << "\n";

    return 0;
}


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

typedef long long ll;
typedef complex<double> Vec;

string S;
vector<ll> R;

int main() {
  cin >> S;
  R.resize(S.size());
  for (ll k = 0; k < S.size() - 1; ++k) {
    if (S[k] == 'R' && S[k + 1] == 'L') {
      for (ll i = k; i >= 0; --i) {
        if (S[i] == 'L') break;
        ++R[(k - i) % 2 == 0 ? k : k + 1];
      }
      for (ll i = k + 1; i < S.size(); ++i) {
        if (S[i] == 'R') break;
        ++R[(i - (k + 1)) % 2 == 0 ? k + 1 : k];
      }
    }
  }
  bool first = true;
  for (ll r : R) {
    cout << (first ? "" : " ") << r;
    first = false;
  }
  cout << endl;
  return 0;
}


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

using namespace std;

typedef long long int ll;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
#define endl "\n"

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    
    ll A, B, C;
    cin >> A >> B >> C;

    ll x = 10*max(A, max(B, C));

    if(A==max(A, max(B, C)))
    {
        cout << x+B+C << endl;
    }

    else if(B==max(A, max(B, C)))
    {
        cout << x+A+C << endl;
    }

    else
    {
        cout << x+A+B << endl;
    }


    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stack>
#include <math.h>

using namespace std;

int n;

bool rangeCheck(int row,int col){
	if(row >= 0 && row <= n-1 && col >= 0 && col <= n-1)return true;
	return false;
}


int main(){

   int max,tmp,row,col,tmp_row,tmp_col;
   char table[255][256];

   while(true){
	   scanf("%d",&n);
	   if(n == 0)break;

	   for(int i=0; i < n; i++){
		   scanf("%s",table[i]);
	   }

	   max = 0;

	   //?¨???????????????§??????
	   for(int i=0; i < n; i++){
		   tmp = 0;
		   for(int k=0;k < n;k++){
			   if(table[i][k] == '1'){
				   tmp++;
				   if(k == n-1){
					   max = (max >= tmp)?max:tmp;
				   }
			   }
			   else{
				   max = (max >= tmp)?max:tmp;
				   tmp = 0;
			   }
		   }
	   }

	   //?????????????????§??????
	   for(int i=0; i < n; i++){
		   tmp = 0;
		   for(int k= 0; k < n; k++){
			   if(table[k][i] == '1'){
				   tmp++;
				   if(k == n-1){
					   max = (max >= tmp)?max:tmp;
				   }
			   }
			   else{
				   max = (max >= tmp)?max:tmp;
				   tmp = 0;
			   }
		   }
	   }

	   //????????????????????§??????:????§?????????§
	   for(row = 1; row < n;row++){
		   tmp_row = row;
		   col = 0;
		   tmp = 0;
		   while(rangeCheck(tmp_row,col)){
			   if(table[tmp_row][col] == '1'){
				   tmp++;
				   if(rangeCheck(tmp_row-1,col+1) == false){
					   max = (max >= tmp)?max:tmp;
					   tmp = 0;
				   }
			   }
			   else{
				   max = (max >= tmp)?max:tmp;
				   tmp = 0;
			   }
			   tmp_row -= 1;
			   col += 1;
		   }
	   }

	   //????????????????????§??????:????§?????????????
	   for(col = 1;col < n-1; col++){
		   tmp_col = col;
		   row = n-1;
		   tmp = 0;
		   while(rangeCheck(row, tmp_col)){
			   if(table[row][tmp_col] == '1'){
				   tmp++;
				   if(rangeCheck(row-1, tmp_col+1) == false){
					   max = (max >= tmp)?max:tmp;
					  tmp = 0;
				   }
			   }
			   else{
				   max = (max >= tmp)?max:tmp;
				   tmp = 0;
			   }
			   row -= 1;
			   tmp_col += 1;
		   }
	   }

	   //????????????????????§??????:????§?????????§
	   for(row =1; row < n;row++){
		   tmp_row = row;
		   col = n-1;
		   tmp = 0;
		   while(rangeCheck(tmp_row,col)){
			   if(table[tmp_row][col] == '1'){
				   tmp++;
				   if(rangeCheck(tmp_row-1,col-1) == false){
					   max = (max >= tmp)?max:tmp;
					  tmp = 0;
				   }
			   }
			   else{
				   max = (max >= tmp)?max:tmp;
				   tmp = 0;
			   }
			   tmp_row -= 1;
			   col -= 1;
		   }
	   }

	   //????????????????????§??????:????§?????????????
	   for(col = n-2; col > 0; col--){
		   tmp_col = col;
		   row = n-1;
		   tmp = 0;
		   while(rangeCheck(row,tmp_col)){
			   if(table[row][tmp_col] == '1'){
				   tmp++;
				   if(rangeCheck(row-1,tmp_col-1) == false){
					   max = (max >= tmp)?max:tmp;
					  tmp = 0;
				   }
			   }
			   else{
				   max = (max >= tmp)?max:tmp;
				   tmp = 0;
			   }
			   row -= 1;
			   tmp_col -= 1;
		   }
	   }

	   printf("%d\n",max);
   }

    return 0;
}

Measured memory_bytes: 2724
S = gets.chomp.chars
N = S.size

ans = Array.new(N,0)
%w(R L).each do |dir|
  c = 0
  S.each_with_index do |a,i|
    if a == dir
      c += 1
    else
      ans[i] += c/2
      ans[i-1] += (c+1)/2
      c = 0
    end
  end
  ans.reverse!
  S.reverse!
end

puts ans.join(" ")

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


int main(){
	string s;
	int mu = 1000;
	cin >> s;
	for (int i = 0; i < s.size() - 2; i++) {
		int ta = stoi(s.substr(i, 3));
		if (mu > max(753,ta)-min(753,ta))mu = max(753, ta) - min(753, ta);
	}
	cout << mu << endl;
	return 0;
}

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

int main() {
int N;
cin >> N;
vector <char> mo(N);
vector <char> zi(N);
for (int i = 0; i < N; i++){cin >> mo.at(i);}
for (int i = 0; i < N; i++){cin >> zi.at(i);}
for (int i = 0; i < N; i++){cout << mo.at(i) << zi.at(i);}  
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        try (Scanner s = new Scanner(System.in)) {
            final int A = s.nextInt(),
                      B = s.nextInt(),
                      H = s.nextInt(),
                      M = s.nextInt();
            double hAngle = 2 * Math.PI * (H * 60 + M) / (60 * 12);
            double mAngle = 2 * Math.PI * M / 60;
            double theta = Math.abs(hAngle - mAngle);
            System.out.println(Math.sqrt(A*A + B*B - 2*A*B*Math.cos(theta)));
        }
    }
}


Measured memory_bytes: 35768
//C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

//ここまで毎回include
//以下プログラム

using namespace std;

long gcd(long a, long b) {
	long r = -1;
	if (a < b) {
		swap(a, b);
	}
	while (r != 0) {
		r = a % b;
		if (r == 0) {
			return b;
		}
		else {
			a = b;
			b = r;
		}
	}
}

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

int main() {
	long a, b, c;
	cin >> a >> b >> c;
	long A, B, C;
	long result = 0;
	for (int i = 0; i < 10000000; i++) {
		if (a % 2 == 1 || b % 2 == 1 || c % 2 == 1) {
			cout << result << endl;
			return 0;
		}
		A = a / 2;
		B = b / 2;
		C = c / 2;
		a = B + C;
		b = A + C;
		c = A + B;
		result++;
	}
	cout << "-1" << endl;
}



Measured memory_bytes: 256
<?php
$n = trim(fgets(STDIN)); 
$a = explode(" ",trim(fgets(STDIN)));
$ans = 0;
             
rsort($a);

foreach($a as $key => $value) {
  if($key % 2 == 0) {
    $ans += $value;
  }else {
    $ans -= $value;
  }
}
echo $ans;

Measured memory_bytes: 4604
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int j,n,m,po,no,flag,cnt=0,cnt2,ans,ar[100000],x,y,i,co[100000],sum=0,k;
    string str[1000],ptr,sr,tr,rtr,rt;
    vector<long long int>v(100000,0);
    set<string>s;
    queue<long long int>qu;
    set<string>::iterator it;
    cin>>n;
    for(i=1; i<=n; i++)
    {
        for(j=1; j<=n; j++)
        {
            for(k=1; k<=n; k++)
            {
               sum=sum+__gcd(i,__gcd(j,k));
            }
        }

    }
    cout<<sum<<endl;

}


Measured memory_bytes: 3872
//It is made by M_sea
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <cmath>
#define re register
using namespace std;

inline int read() {
    int X=0,w=1; char c=getchar();
    while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }
    while (c>='0'&&c<='9') X=X*10+c-'0',c=getchar();
    return X*w;
}

const int N=100000+10;

int n,m;

struct Edge { int v,nxt; } e[N<<1];
int head[N],cnt=0;

inline void addEdge(int u,int v) {
    e[++cnt]=(Edge){v,head[u]},head[u]=cnt;
}

namespace task1 {
    int s,c[N],sum[N];
    inline void dfs(int u,int fa) {
        sum[u]=c[u],s+=c[u];
        for (re int i=head[u];i;i=e[i].nxt) {
            int v=e[i].v; if (v==fa) continue;
            c[v]=-c[u],dfs(v,u),sum[u]+=sum[v];
        }
    }
    
    inline void work() {
        c[1]=1,dfs(1,0);
        if (s) { puts("-1"); return; }
        int ans=0;
        for (re int i=1;i<=n;++i) ans+=abs(sum[i]);
        printf("%d\n",ans);
    }
}

namespace task2 {
    int c[N],sum[N],fa[N];
    int s,isodd,st,ed;
    
    namespace odd {
        inline void work() {
            if (s&1) { puts("-1"); return; }
            int dlt=s/2,ans=abs(dlt);
            for (re int i=st;i;i=fa[i]) sum[i]-=dlt;
            for (re int i=ed;i;i=fa[i]) sum[i]-=dlt;
            for (re int i=1;i<=n;++i) ans+=abs(sum[i]);
            printf("%d\n",ans);
        }
    }

    namespace even {
        int tmp[N],mark[N],w;
        inline void work() {
            if (s) { puts("-1"); return; }
            int top=0;
            for (re int i=ed;i!=st&&i;i=fa[i])
                tmp[++top]=sum[i],mark[i]=1;
            sort(tmp+1,tmp+top+1);
            if (top&1) w=tmp[(top+1)/2];
            else w=(tmp[top/2]+tmp[top/2+1])/2;
            int ans=abs(w);
            for (re int i=1;i<=n;++i) {
                if (mark[i]) ans+=abs(sum[i]-w);
                else ans+=abs(sum[i]);
            }
            printf("%d\n",ans);
        }
    }

    inline void dfs(int u,int f) {
        sum[u]=c[u],s+=c[u],fa[u]=f;
        for (re int i=head[u];i;i=e[i].nxt) {
            int v=e[i].v; if (v==f) continue;
            if (c[v]) {
                if (c[u]==c[v]) isodd=1;
                st=u,ed=v;
            }
            else c[v]=-c[u],dfs(v,u),sum[u]+=sum[v];
        }
    }
    
    inline void work() {
        c[1]=1,dfs(1,0);
        if (isodd) odd::work();
        else even::work();
    }
}

int main() {
    n=read(),m=read();
    for (re int i=1;i<=m;++i) {
        int u=read(),v=read();
        addEdge(u,v),addEdge(v,u);
    }
    if (m==n-1) task1::work();
    else task2::work();
    return 0;
}

Measured memory_bytes: 7296
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <tuple>
#include <algorithm>
#include <map>
#include <cmath>
#include <tuple>
using namespace std;
long long int MOD = 1000000000 + 7;
using ll = long long;
ll LARGE = 1000000;


int main() {
	ll n;
	cin >> n;
	map<string, int> s;
	ll m = 0;
	for (ll i = 0; i < n; ++i) {
		string k;
		cin >> k;
		if (s.find(k) != s.end()) {
			s[k]++;
		}
		else {
			s[k] = 0;
		}
		if (m < s[k]) {
			m = s[k];
		}
	}

	for (auto it = s.begin(); it != s.end(); ++it) {
		if (it->second == m) {
			cout << it->first << endl;
		}
	}
	return 0;
}


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



int main(){
    int n,k;
    cin>>n>>k;
    int ans=0;
    for(int i=0;i<n;i++){
        int h;
        cin>>h;
        if(h>=k)ans++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX = 200000;

int main(){
    int R[MAX],n;
    
    cin >> n;
    for(int i = 0;i<n;i++) cin >> R[i];
    
    int maxv = -2000000000;
    int minv = R[0];
    
    for(int i = 1;i<n;i++){
        maxv = max(maxv,R[i]-minv);
        minv = min(minv,R[i]);
    }
    
    cout << maxv << endl;
    
    return 0;
}


Measured memory_bytes: 3872