akhauriyash/Code-Regression huggingface dataset:
import math
a,b,x=map(int,input().split())
V=a*a*b
if 2*x<=V:
    print(90-math.degrees(math.atan((2*x)/(a*b*b))))
else:
    print(math.degrees(math.atan((2*(a*a*b-x))/(a*a*a))))

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

#define pb push_back
#define MAX 100005
#define ff first
#define M 1000000007
#define ss second
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

typedef long long ll;
ll dp[1<<22];
int n;
int a[22][22];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n;
    for(int i = 0; i<n; ++i){
        for(int j = 0; j<n; ++j)
            cin>>a[i][j];
    }
    memset(dp,0,sizeof(dp));
    dp[0]=1;
    for(int mask = 0; mask<(1<<n); ++mask){
        int  i = __builtin_popcount(mask);
        for(int j =0; j<n; ++j){
            if(((mask>>j)^1)==0)continue;
            if(!a[i][j])continue;
            int nxt_mask = mask^(1<<j);
            dp[nxt_mask] += dp[mask];
            if(dp[nxt_mask]>=M)
                dp[nxt_mask] -= M;
        }
    }
    cout<<dp[(1<<n)-1]<<"\n";
    return 0;
}

Measured memory_bytes: 33024
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n,m,v,p = LI()
a = LI()
a.sort(reverse=True)
x = a[p-1]
a = a[p-1:]
l = list(accumulate(a))
ans = p

for i in range(n-p):
    if a[i+1] + m < x:
        continue
    s = (n-(p+i+1))*m + p*m
    s += (a[i+1] + m) * (i+1)
    s -= l[i]
    if s >= m*v:
        ans += 1
print(ans)

Measured memory_bytes: 60184
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;

signed main(){
  string s; cin >> s;
  int n = s.size();
  vector<vector<ll> > dp(n + 1, vector<ll> (13, 0));
  dp[0][0] = 1;
  for(int i = 0; i < n; i++){
    for(int j = 0; j < 13; j++){
      if(s[i] == '?'){
        for(int k = 0; k < 10; k++){
          (dp[i + 1][(10 * j + k) % 13] += dp[i][j]) %= MOD;
        }
      }
      else{
        int num = s[i] - '0';
        (dp[i + 1][(10 * j + num) % 13] += dp[i][j]) %= MOD;
       }
    }
  }
  printf("%lld\n", dp[n][5]);
}

Measured memory_bytes: 16728
#include<bits/stdc++.h>
#include <assert.h>
#define ll long long int
using namespace std;
ll gcd(ll x, ll y){
    if(y == 0) return x;
    return gcd(y,x%y);
    
}

int main(){
    long long x,y;
    cin >> x >> y;
    long long g=gcd(x,y);
    long long ans=0;
    for(long long i=2;i<= g / i; i++)
    {
        if(g%i==0)
        {
            ans++;
            while(g%i==0) g/=i;
        }
    }
    if(g > 2) ans++;
    cout << ans+1 << endl;
    
}

Measured memory_bytes: 256
#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
using namespace std;


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

    if (R < 1200) {
        cout << "ABC" << endl;
    }
    else if (R >= 1200 && R < 2800) {
        cout << "ARC" << endl;
    }
    else {
        cout << "AGC" << endl;
    }
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll r, g, b, n;
  cin >> r >> g >> b >> n;
  ll ans = 0;
  rep(i, 3001) rep(j, 3001) {
    ll now = n - r * i - g * j;
    if(now >= 0 && now % b == 0) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3544
#include<iostream>
#include<iomanip>
#include <stdlib.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <vector>
#include <numeric>
typedef long long int ll;
using namespace std;

int main(){
	ll S,a,b;
	cin>>S;
	a=S/500;
	b=(S-500*a)/5;
	cout<<1000*a+b*5<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<iomanip>
#include<string>
#include<cmath>
#include<stack>
#include<cstring>
#include<cstdio>
using namespace std;
const int maxn =  10 + 8;

int n;
int g[maxn];

int main()
{
    scanf("%d", &n);
    while(n--)
    {
        memset(g, 0, sizeof g);
        stack<int> p,q;
        p.push(0); q.push(0);
        for(int i = 0; i < 10; ++i) cin >> g[i];
        int i = 0;
        while(true)
        {
            if(i == 10) break;
            if(g[i] > p.top()) {p.push(g[i]);}
            else {
                if(g[i] > q.top())
                {
                    q.push(g[i]);
                }
            }
            i++;
        }
        if(p.size() + q.size() == 12) printf("YES\n");
        else printf("NO\n");
    }
    return 0;
}

Measured memory_bytes: 3088
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <unordered_map>
using namespace std;

int main()
{
	int N;
	cin >> N;
	int a_i;
	vector<int> A;
	for (int i = 0; i < N; ++i)
	{
		cin >> a_i;
		A.push_back(a_i);
	}
	int sentinel = A[0];
	int flag = -1;
	int count = 0;
	for (int i = 1; i < N; ++i)
	{
		if (flag == -1)
		{
			if (A[i] > sentinel)
				flag = 1;
			if (A[i] < sentinel)
				flag = 0;
			if (A[i] == sentinel)
				flag = -1;
			sentinel = A[i];
			continue;
		}

		if(A[i] < sentinel&&flag==1)
		{
			count++;
			flag = -1;
		}

		if (flag==0&&A[i] > sentinel)
		{
			count++;
			flag = -1;
		}

		sentinel = A[i];
	}

	
	cout << count+1 << endl;

	return 0;
}

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

int main()
{
    int n, k, out=0;
    cin >> n >> k;
    int l[n];
    rep(i,n){
        cin >> l[i];
    }
    sort(l, l+n, greater<int>());
    for (int i=0;i<k;++i){
        out+=l[i];
    }
    cout << out << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;
const ll MOD = ll(1e9) + 7;

struct UnionFind {
  vector<int> size, parents;
  UnionFind() {}
  UnionFind(int n) {  // make n trees.
    size.resize(n, 0);
    parents.resize(n, 0);
    for (int i = 0; i < n; i++) {
      makeTree(i);
    }
  }
  void makeTree(int x) {
    parents[x] = x;  // the parent of x is x
    size[x] = 1;
  }
  bool isSame(int x, int y) { return findRoot(x) == findRoot(y); }
  bool unite(int x, int y) {
    x = findRoot(x);
    y = findRoot(y);
    if (x == y) return false;
    if (size[x] > size[y]) {
      parents[y] = x;
      size[x] += size[y];
    } else {
      parents[x] = y;
      size[y] += size[x];
    }
    return true;
  }
  int findRoot(int x) {
    if (x != parents[x]) {
      parents[x] = findRoot(parents[x]);
    }
    return parents[x];
  }
  int treeSize(int x) { return size[findRoot(x)]; }
};

int main() {
  int n, m;
  cin >> n >> m;
  UnionFind tree(n);
  int a, b;
  rep(i, m) {
    cin >> a >> b;
    tree.unite(a - 1, b - 1);
  }
  int ans = 0;
  rep(i, n) { ans = max(ans, tree.treeSize(i)); }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 4808
#include<bits/stdc++.h>
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define show(x) std::cerr << #x << "=" << x << std::endl
using namespace std;
typedef long long ll;
const double eps=1e-8;
const int maxn = 2e5+5;
const int mod = 1e9+7;
const int inf = 0x3f3f3f3f;
int t;
int n,m;
int main()
{
    char a;
    cin>>a;
    if(a>='A' && a<='Z') puts("A");
    else puts("a");

    return 0;
}


Measured memory_bytes: 3616
#include <stdlib.h>
#include <stdio.h>
int compare(const void *a,const void *b){
    if(*(int *)a>*(int *)b)return 1;
    return -1;
}
int main()
{
    int n;
    scanf("%d",&n);
    int a[n],cnt=0,i;
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
        if(a[i]<0)cnt++;
    }long long ans=0;
    for(i=0;i<n;i++){
        a[i]=abs(a[i]);
        ans+=a[i];
    }
    
    if(cnt%2==1){
        qsort(a,n,sizeof(int),compare);
        ans-=2*a[0];
    }
    printf("%lld",ans);
    return 0;
}


Measured memory_bytes: 892
# -*- coding: utf-8 -*-
import numpy as np
n, m = map(int, input().split())

gate = []
for i in range(m):
    l, r = map(int, input().split())
    gate.append([l, r])

gate = np.array(gate)

l = gate[:, 0].max()
r = gate[:, 1].min()

if r+1-l>0:
    print(r+1-l)
else:
    print(0)

Measured memory_bytes: 30068
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <map>
#include <bitset>
#include <cmath>
#include <set>
#include <utility>

#define INF 1000000000000
#define MOD 1000000007 //10^9+7:合同式の法

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

int main(){
    string s;
    cin >> s;
    bool fla = true;

    for(int i = 0;i < s.size();i++){
        if(i % 2 == 0 and s.at(i) == 'L'){
            fla = false;
            break;
        }else if(i % 2 != 0 and s.at(i) == 'R'){
            fla = false;
            break;
        }
        else
            continue;
    }

    if(fla)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
} 

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


int main() {
	long long int q,h,s,d,n;
	cin>>q>>h>>s>>d;
	cin>>n;
	
	long long int q_l=q*8;long long int h_l=h*4;
	long long int s_l=s*2;long long int d_l=d;
	
	long long int cheapest=min({q_l,h_l,s_l,d_l});
	long long int cheaper = min({q_l,h_l,s_l});
	
	cout<<(n/2)*cheapest+(n%2)*(cheaper)/2<<endl;
}

Measured memory_bytes: 256
N,M,K = map(int,input().split())
lA = list(map(int, input().split()))
lB = list(map(int, input().split()))
aA = []
aB = []
m = 0
k = 0
for A in lA:
    nx = k + A
    if nx > K:
        break
    aA.append(A)
    k = nx
    m += 1
for B in lB:
    nx = k + B
    if nx > K:
        break
    aB.append(B)
    k = nx
    m += 1
aA.reverse()
aB.reverse()
M = m
i = len(aB)
for A in aA:
    k = k - A
    m -= 1
    while i < len(lB):
        nx = k + lB[i]
        if nx > K:
            break
        k = nx
        m += 1
        if m > M:
            M = m
        i += 1
print(M)
        

Measured memory_bytes: 119332
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using std::cin;
using std::cout;
using std::endl;

using std::string;
using std::pair;

using std::vector;
using std::sort;

int main(){
    int a,b;
    cin >> a >> b;
    string s;
    cin >> s;

    bool ok=true;
    for(int i=0;i<a&&ok;i++){
        if(s[i]<'0' || '9'<s[i]){
            ok=false;
        }
    }
    ok=ok?s[a]=='-':ok;
    for(int i=a+1;i<a+b+1&&ok;i++){
        if(s[i]<'0' || '9'<s[i]){
            ok=false;
        }
    }

    if(ok){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}



Measured memory_bytes: 256
import sys

# 関数 solve は，もちろん，問題に応じて書き換える
def solve(a,b):
    if a >= 9 or b >= 9:
        return ':('
    else:
        return 'Yay!'
# ここから下は，入力・出力形式が同じであれば，変えなくて良い．
def readQuestion():
    line = sys.stdin.readline().rstrip()
    [str_a, str_b] = line.split(' ')
    return (int(str_a), int(str_b))

def main():
    a, b = readQuestion()
    answer = solve(a, b)
    print(answer)
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int[] x=new int[n];
		int[] y=new int[n];
		for(int i=0;i<n;i++){
			x[i]=sc.nextInt();
		}
		for(int i=0;i<n;i++){
			y[i]=sc.nextInt();
		}
		double D1=0,D2=0,D3=0,D=0;
		for(int i=0;i<n;i++){
			int d=Math.abs(x[i]-y[i]);
			D1+=d;
			D2+=d*d;
			D3+=d*d*d;
			if(D<d){
				D=d;
			}
		}
		System.out.printf("%.6f\n", D1);
		System.out.printf("%.6f\n", Math.sqrt(D2));
		System.out.printf("%.6f\n", Math.cbrt(D3));
		System.out.printf("%.6f\n", D);
	}
}

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

int main(){
  int A,B,M,x,y,c,Amin=INT_MAX,Bmin=INT_MAX,tmp1,tmp2,tmp2min=INT_MAX,result;
  cin >> A >> B >> M;
  int a[A],b[B];

  for(int i=0;i<A;i++){
    cin >> a[i];
    if(a[i]<Amin){
      Amin = a[i];
    }
  }
  for(int i=0;i<B;i++){
    cin >> b[i];
    if(b[i]<Bmin){
      Bmin = b[i];
    }
  }

  for(int i=0;i<M;i++){
    cin >> x >> y >> c;
    tmp2 = a[x-1] + b[y-1] - c;
    if(tmp2 < tmp2min){
      tmp2min = tmp2;
    }
  }

  tmp1 = Amin + Bmin;
  if(tmp1<tmp2min){
    result = tmp1;
  }else{
    result = tmp2min;
  }

  cout << result << endl;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<string.h>
int main(void)
{
	char str[1001];
	int i;

	scanf("%s",str);
	for (i = 0; i < strlen(str); i++) {
		if (str[i] >= 'A' && str[i] <= 'Z') {
			str[i] = (str[i] - 'Z' - 3) % 26 + 'Z';
		}
	}
	printf("%s\n",str);
	return 0;
}

Measured memory_bytes: 524
N, Z, W = list(map(int, input().split()))
a = list(map(int, input().split()))

if abs(a[N-1] - W) >= abs(a[N-2] - a[N-1]):
    print(abs(a[N-1] - W))
elif abs(a[N-1] - W) <= abs(a[N-2] - a[N-1]):
    print(abs(a[N-2] - a[N-1]))

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define LL long long
LL a[110000];
const int mod=1e9+7;
int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    if(abs(n-m)>1)puts("0");
    else
    {
        a[0]=1;
        for(int i=1; i<=max(n,m); i++)
            a[i]=a[i-1]*i%mod;
        LL ans=a[n]*a[m]%mod;
        if(m==n)ans=ans*2%mod;
        printf("%lld\n",ans);
    }
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

int main(){
  int A,B;
  cin >> A >> B;
  cout << (A + B) / 2 << endl;
}



Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ll long long
template <typename T>
bool PN(T x){ if (x <= 1) return false; if (x == 2) return true; for (int i = 2; i < sqrt(x) + 1; i++) if (x % i == 0) return false; return true;}

const ll MOD = 1e9+7;
long long Comb(int n, int i){long long ans = 1; if(i>n || i < 0) return 0; if(i == 0 || i == n) return 1; else {for(int j = 1; j <= i; ++j){ans *=(n+1-j); ans /= j; ans %= MOD;} }return ans;}
template<typename T> T gcd(T a, T b){if(b == 0) return a;else return gcd(b, a%b);}
template<typename T> T lcm(T a, T b){if(b > a) swap(a, b); T g = gcd(a, b);return a / g * b;}

void solve(){
  ll a, b, c, d; cin >> a >> b >> c >> d;
  ll ans;
  ans = max(b * d, max(a * d, max(b * c, a * c)));
  cout << ans << endl;
}

int main(void){
  solve();
  return 0;
}


Measured memory_bytes: 3632
#include<stdio.h>

void insertionSort(int *,int);

int main(){
  int i,N,A[1000];

  scanf("%d",&N);
  for(i=0;i<N;i++) scanf("%d",&A[i]);

  for(i=0;i<N-1;i++) printf("%d ",A[i]);
  printf("%d\n",A[i]);

  insertionSort(A,N);
  
  return 0;
  
}

void insertionSort(int *A,int N){
  int i,j,k,v;
  
  for(i=1;i<N;i++){
    v=A[i];
    j=i-1;
    while(j>=0 && A[j]>v){
      A[j+1]=A[j];
      j--;
    }
    A[j+1]=v;
    
    /*計算の途中経過表示*/
    for(k=0;k<N-1;k++) printf("%d ",A[k]);
    printf("%d\n",A[k]);
  }
}



Measured memory_bytes: 2052
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define int long long
using namespace std;

typedef pair<int, int> Pii;

template<typename T>
void readvec(vector<T> &a);
void readindex(vector<int> &a);

vector<bool> proceed_dp(vector<bool> &dp, int n, int N){

    vector<bool> dp2(2 * N + 1, false);
    FOR(i, n, 2 * N - n + 1){
        if(dp[i]){
            dp2[i + n] = true;
            dp2[i - n] = true;
        }
    }

    return dp2;

}

signed main(){

    string s;
    int x, y;
    cin >> s >> x >> y;
    int N = s.size();

    vector<bool> dpx(2 * N + 1, false), dpy(2 * N + 1, false);
    bool x_direction = true;
    int count = 0;
    //dpx[N] = true;
    dpy[N] = true;
    bool first = true;

    REP(i, N){
        if(s[i] == 'F'){
            count++;
        }
        if(s[i] == 'T' || i == N - 1){
            if(first){
                dpx[N + count] = true;
                first = false;
            }else{
                if(x_direction){
                    dpx = proceed_dp(dpx, count, N);
                }else{
                    dpy = proceed_dp(dpy, count, N);
                }
            }
            x_direction = !x_direction;
            count = 0;
        }
    }

    if(dpx[x + N] && dpy[y + N]){
        cout << "Yes";
    }else{
        cout << "No";
    }


    return 0;
}


template<typename T>
void readvec(vector<T> &a){
    REP(i, a.size()){
        cin >> a[i];
    }
}
void readindex(vector<int> &a){
    REP(i, a.size()){
        cin >> a[i];
        a[i]--;
    }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();

        int result = 0;
        for(int i = 1; i <= n; i++) {
            if((i + k - 1) <= n ) {
                result++;
            }
        }
        System.out.print(result);
        sc.close();
    }
}

Measured memory_bytes: 24916
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import itertools
import random
from decimal import *

input = sys.stdin.readline

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
def inputStr(): return input()[:-1]

inf = float('inf')
mod = 1000000007

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-

def main():
	D = inputInt()
	C = inputList()
	S = []
	ans = []
	for i in range(D):
		s = inputList()
		S.append(s)

	for i in range(D):
		tmp = inputInt()
		ans.append(tmp)

	scezhu = [inf for i in range(26)]
	sco = 0
	for i,val in enumerate(ans):
		tmp = S[i][val-1]
		scezhu[val-1] = i
		mins = 0
		for j,vol in enumerate(C):
			if scezhu[j] == inf:
				mins = mins + (vol * (i+1))
				#if i == 1:
					#print(vol * (i+1))
			else:
				mins = mins + (vol * ((i+1)-(scezhu[j]+1)))
				#if i == 1:
					#print(scezhu[i]+1)
		#print(mins)
		tmp -= mins
		sco += tmp
		print(sco)

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
if __name__ == "__main__":
	main()


Measured memory_bytes: 78572
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> using lim = numeric_limits<T>;
template <typename T> istream& operator>>(istream& is, vector<T>& a) { for(T& x : a) { is >> x; } return is; }
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> d(n);
    cin >> d;
    int ans = 0;
    for(int i = 0; i < n; i++) {
        for(int j = i + 1; j < n; j++) {
            ans += d[i] * d[j];
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fst first
#define snd second
#define rep(n) for(lint I = 0; (I) < (lint)(n); ++(I))
#define repeat(i, n) for(lint i = 0; (i) < (lint)(n); ++(i))
#define repeat_to(i, n) for(lint i = 0; (i) <= (lint)(n); ++(i))
#define repeat_from(i, m, n) for(lint i = (m); (i) < (lint)(n); ++(i))
#define repeat_from_to(i, m, n) for(lint i = (m); (i) <= (lint)(n); ++(i))
#define repeat_reverse_from_to(i, m, n) for(lint i = (m); (i) >= (lint)(n); --(i))
#define el cout<<endl
#define dump(x) cout<<" "<<#x<<"="<<x
#define vdump(v) for(size_t I=0; I<v.size(); ++I){cout<<" "<<#v<<"["<<I<<"]="<<v[I];} cout<<endl
using namespace std;
using lint = long long;
using ld = long double;

int main(void) {
    lint n, k; cin >> n >> k;
    lint ans = 0;
    
    if (k == 0) {
        cout << n * n << endl;
        return 0;
    }
    
    repeat_from_to (b, k+1, n) {
        lint p = n / b;
        lint q = n % b;
        ans += (b - k) * p;
        //dump(p); dump(q); dump((b-k)*p); dump(ans); el;
        if (q >= k) {
            ans += (q - k + 1);
            //dump(q-k+1); dump(ans); el;
        }
        //el;
    }
    cout << ans << endl;
}

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

const ll INF = 1LL << 60;

ll N;
vector<ll> X;
// ll grundy[1001001001];
map<ll, ll> grundy;

int main() {
    cin >> N;
    X.resize(N);
    rep(i, N) cin >> X[i];

    ll all_even = true; 

    // 初期値から1以上減らして、偶数にできるか
    // 全部偶数ならダメ
    rep(i, N) {
        if (X[i] % 2 != 0) {
            all_even = false;
            break;
        }
    }

    // 判定
    if (all_even) {
        cout << "second" << endl;
    } else {
        cout << "first" << endl;
    }
}

Measured memory_bytes: 1152
#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 <numeric>
#include <ctime>
#include <complex>
#include <bitset>
#include <random>
#include <climits>
#include <stack>

using namespace std;

typedef long long ll;
typedef long double ld;

#define int ll
#define double ld
#define loop(i, n) for(int i = 0; i < (int)n; ++i)
#define loop1(i, n) for(int i = 1; i <= (int)n; ++i)
#define F first
#define S second
#define pb push_back
#define pi pair <int, int>
#define all(x) begin(x), end(x)
#define ti tuple <int, int, int>
#define Point Vect
#define no {cout << 0; return;}
#define mkp make_pair
#define mkt make_tuple
#define cerr if(0) cerr

const int N = 2e5 + 7, MOD = 1e9 + 7;

int a[N], f[N] = { 1 }, rf[N] = { 1 };

int binpow(int x, int d) {
    int ans = 1;
    while (d) {
        if (d & 1)
            ans = ans * x % MOD;
        x = x * x % MOD;
        d >>= 1;
    }
    return ans;
}

int binom(int n, int k) {
    if (n < k)
        return 0;
    return f[n] * rf[k] % MOD * rf[n - k] % MOD;
}

void solve() {
    loop1(i, N - 1) {
        f[i] = f[i - 1] * i % MOD;
        rf[i] = binpow(f[i], MOD - 2);
    }
    int n, k;
    cin >> n >> k;
    loop(i, n)
        cin >> a[i];
    sort(a, a + n);
    int ans = 0;
    loop(i, n)
        ans = (ans + a[i] * binom(i, k - 1) % MOD - a[i] * binom(n - i - 1, k - 1) % MOD + MOD) % MOD;
    cout << ans;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //int t; cin >> t; loop(i, t)
    solve();
    return 0;
}

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

ll count5(ll a, ll b, ll c, ll d, ll e){
  ll ans=0;
  ans+=a*b*c;
  ans+=a*b*d;
  ans+=a*b*e;
  ans+=a*c*d;
  ans+=a*c*e;
  ans+=a*d*e;
  ans+=b*c*d;
  ans+=b*c*e;
  ans+=b*d*e;
  ans+=c*d*e;
  return ans;
}

int main(){
  ll N; cin>>N;
  vector<ll> M(5);
  vector<ll> count(5);
  for(int i=0; i<N; i++){
    string s; cin>>s;
    if(s[0]=='M'){
      M[0]++;
      if(count[0]==0) count[0]++;
    }
    if(s[0]=='A'){
      M[1]++;
      if(count[1]==0) count[1]++;
    }
    if(s[0]=='R'){
      M[2]++;
      if(count[2]==0) count[2]++;
    }
    if(s[0]=='C'){
      M[3]++;
      if(count[3]==0) count[3]++;
    }
    if(s[0]=='H'){
      M[4]++;
      if(count[4]==0) count[4]++;
    }
  } //s
  ll sum=0;
  for(int i=0; i<5; i++) sum+=count[i];
  if(sum<3) cout<<0<<endl;
  if(sum==3){
    ll ans=1;
    for(int i=0; i<5; i++){
      if(count[i]!=0) ans*=M[i];
    }
    cout<<ans<<endl;
  }
  if(sum==4){
    ll sum=1;
    for(int i=0; i<5; i++){
      if(count[i]!=0) sum*=M[i];
    }
    ll ans=0;
    for(int i=0; i<5; i++){
      if(count[i]!=0) ans+=sum/M[i];
    }
    cout<<ans<<endl;
  }
  if(sum==5){
    ll ans=count5(M[0], M[1], M[2], M[3], M[4]);
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 256
import           Control.Applicative
import           Control.Monad
import           Data.List
import           Data.Maybe          (fromJust)

newtype Dice =
    Dice [Int]
    deriving (Eq, Show)

dice :: Dice
dice = Dice [0,1,2,3,4,5]

roll :: Char -> Dice -> Dice
roll 'E' (Dice ds) = Dice [ds !! (i-1) | i <- [4,2,1,6,5,3]]
roll 'N' (Dice ds) = Dice [ds !! (i-1) | i <- [2,6,3,4,1,5]]
roll 'S' (Dice ds) = Dice [ds !! (i-1) | i <- [5,1,3,4,6,2]]
roll 'W' (Dice ds) = Dice [ds !! (i-1) | i <- [3,2,6,1,5,4]]

rollH :: Dice -> [Dice]
rollH d = take 4 (iterate f d)
  where
    f (Dice ds) = Dice [ds !! (i-1) | i <- [1,4,2,5,3,6]]

rollTop :: Int -> Dice -> Dice
rollTop 0 ds = ds
rollTop 1 ds = roll 'N' ds
rollTop 2 ds = roll 'W' ds
rollTop 3 ds = roll 'E' ds
rollTop 4 ds = roll 'S' ds
rollTop 5 ds = roll 'S' $ roll 'S' ds

isEqual :: [Int] -> [Int] -> Bool
isEqual d1 d2 =
    if null $ filter (== d1) bss
        then False
        else True
  where
    ass = concatMap rollH $ fmap (flip rollTop dice) [0 .. 5]
    bss = fmap (\(Dice ds) -> fmap (d2 !!) ds) ass

hasSame :: (a -> a -> Bool) -> [a] -> Bool
hasSame _ [] = False
hasSame p (x:xs)
    | any (x `p`) xs = True
    | otherwise      = hasSame p xs

main :: IO ()
main = do
    getLine
    dss <- fmap (fmap read . words) . lines <$> getContents :: IO [[Int]]
    if hasSame isEqual dss
       then putStrLn "No"
       else putStrLn "Yes"



Measured memory_bytes: 4120
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

long gcd(long a, long b){
	long t;
	if(a<b){
		t=a; a=b; b=t;
	}
	t=a%b;
	while(t!=0){
		a=b; b=t; t=a%b;
	}
	return b;
}

int main(void){
	int n, m, i;
	scanf("%d%d", &n, &m);

	int a;
	scanf("%d", &a);
	a/=2;
	int t=a&(-a);
	int l=a;
	for(i=1; i<n; i++){
		scanf("%d", &a);
		a/=2;
		int T=a&(-a);
		int b = l/gcd(l, a);
		if(t!=T || __builtin_smul_overflow(b, a, &l)) break;
	}
	if(i<n){
		puts("0");
		return 0;
	}
	printf("%d\n", (m/l+1)/2);
}


Measured memory_bytes: 128
# from fractions import Fraction
from decimal import Decimal
li = input().split()
n = int(li[0])
k = int(li[1])

# n面サイコロ kは得点

# 1/nの確率で1~nが出る
# 勝つためにx回表を出し続ければ良い
# 目 * 2^x >= kとなればよい

answer = 0
for i in range(n):
    dicenum = i + 1
    winline = dicenum
    x = 0
    while winline < k:
        x += 1
        winline = dicenum * (2**x)
    if dicenum == 1:
        first_x = x
        bunbo = n * 2**x #initialize
        bunsi = 1 #initialize
    elif x == 0:
        bunsi += 2**first_x
    else:
        bunsi += 2**(first_x - x)

answer = Decimal(str(bunsi)) / Decimal(str(bunbo))
print("{:.12f}".format(answer))

Measured memory_bytes: 5588
import java.util.*;
class Main
{
    public static void main (String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int k = sc.nextInt();
        int ans = 0;
        int sum = 0;

        for(int i=0; i<=k; i++){
            for(int j=0; j<=k-i; j++){
                sum = (int) ( a * Math.pow(2,i) + b * Math.pow(2,j) + c * Math.pow(2,k-i-j) );
                if(sum > ans) ans = sum;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 23124
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;

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

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

const int MAX_N = 1010;

ll fact[MAX_N], finv[MAX_N];
ll comb(int n, int r){
    if(n < r || r < 0) return 0;
    return fact[n] * finv[n-r] % MOD * finv[r] % MOD;
}

void comb_init(int n){
    fact[0] = finv[0] = 1;
    for(int i=1; i<=n; i++){
        fact[i] = (fact[i-1] * i) % MOD;
        finv[i] = modpow(fact[i], MOD - 2);
    }
}

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

    int n, k; cin>>n>>k;

    comb_init(1005);

    ll ans = 0;
    for(int i=0; i<=k; i++){
        int rest = k - i;
        ll cur = comb(k, i) * modpow(rest, n) % MOD;

        if(i % 2 == 0) ans = (ans + cur) % MOD;
        else           ans = (ans - cur + MOD) % MOD;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3240
#include <iostream>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
const long long INF = 1e9 + 7;
using namespace std;
map<int, int> mp;
int main()
{
	char s[222];
	cin >> s;
	int n = strlen(s);
	for (int i = n - 2; i; i -= 2) {
		if (strncmp(s, s + i / 2, i / 2) == 0) {
			cout << i << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main()
{
    int n, q, l, r;
    string s;

    cin >> n >> q >> s;
    vector<int> data(n+1, 0);
    for(int i = 1; i < n; i++){
        if(s[i-1] == 'A' && s[i] == 'C'){
            data[i] += 1;
        }
        data[i] += data[i-1]; 
    }
    data[n] += data[n-1]; 

    for(int i = 0; i < q; i++){
        scanf("%d%d", &l, &r);
        printf("%d\n", data[r-1] - data[l-1]);
    }

    return 0;
}


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

int main() 
{
  	int n;
    cin >> n;
    int a[n+1];
    for(int i=0;i<n;i++)
    	cin >> a[i];
    int dp[n];
    dp[0] = 0;
    dp[1] = abs(a[1] - a[0]);
    for (int i = 2; i < n; i++) {
        dp[i] = min(dp[i - 1] + abs(a[i] - a[i - 1]), dp[i - 2] + abs(a[i] - a[i - 2]));
    }
  
    cout << dp[n - 1] << "\n";
    return 0;
}


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

int main(){
    string str,ans;
    cin >> str;
    for(int i=0; i<str.length(); i++){
        if(str[i] == '0'){
            ans.push_back('0');
        }else if(str[i] == '1'){
            ans.push_back('1');
        }else if(str[i] == 'B'){
            if(!ans.empty()) ans.pop_back();
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	long long a,b;
	scanf("%lld %lld", &a, &b);

	for (long long i=1; i<=b; i++){
		if ( (a*i)%b == 0 ){
			printf("%lld\n", a*i);
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
using namespace std;
 
int main(){
	int N, K;
	cin >> N >> K;

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

    sort(h,h+N);
	
    int sub_min;
    int sub_prev;
    for(int i=0; i<N-(K-1); i++){
        if(i==0){
            int sub_init=0;
            for(int j=0; j<(K-1); j++){
                sub_init += h[j+1]-h[j];
            }
            sub_min  = sub_init;
            sub_prev = sub_init;
        }else{

            int sub_curr;
            sub_curr = sub_prev + (h[i+K-1]-h[i+K-2]) - (h[i]-h[i-1]);

            if(sub_min > sub_curr){sub_min=sub_curr;}

            sub_prev = sub_curr;
        }
    }

    cout << sub_min << endl;

    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N;
  cin>>N;
  vector<ll> L(N);
  for(int i=0;i<N;++i) {
    cin>>L[i];
  }
  sort(L.begin(), L.end());
  int ans = 0;
  for(int i=0;i<N;++i) {
    for(int j=i+1;j<N;++j) {
      for(int k=j+1;k<N;++k) {
        if(L[i]==L[j] || L[j]==L[k]) continue;
        if(L[k]<L[i]+L[j]) ans++;
      }
    }
  }
  cout<<ans<<endl;
}



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

#define y1 dmytxdy
#define pb push_back
#define fi first
#define se second
#define mp make_pair

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef long double ld;

template <typename T> bool chkmin(T &x,T y){return x>y?x=y,1:0;}
template <typename T> bool chkmax(T &x,T y){return x<y?x=y,1:0;}

int readint(){
	int x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

int n,m,tot;
int vis[1005],c[1005][1005],d[1005][1005];
vector<pii> adj[1005];
bool ans[200005];

void dfs1(int u,int f){
	c[f][u]=1;
	for(auto v:adj[u]){
		if(vis[v.fi]) continue;
		vis[v.fi]=1;
		dfs1(v.fi,f);
	}
}

void dfs2(int u,int x,int f){
	for(auto v:adj[u]){
		if(v.fi==x||vis[v.fi]) continue;
		vis[v.fi]=f;
		dfs2(v.fi,x,f);
	}
}

int main(){
	n=readint(); m=readint();
	int x,y;
	for(int i=1;i<=m;i++){
		x=readint(); y=readint();
		adj[x].pb(mp(y,i));
	}
	for(int i=1;i<=n;i++){
		memset(vis,0,sizeof(vis));
		vis[i]=1;
		dfs1(i,i);
	}
	for(int i=1;i<=n;i++){
		memset(vis,0,sizeof(vis));
		for(auto v:adj[i]){
			if(!vis[v.fi]){
				vis[v.fi]=v.fi;
				dfs2(v.fi,i,v.fi);
			}
		}
		for(auto v:adj[i]) if(vis[v.fi]!=v.fi) d[i][v.fi]=1;
		reverse(adj[i].begin(),adj[i].end());
		memset(vis,0,sizeof(vis));
		for(auto v:adj[i]){
			if(!vis[v.fi]){
				vis[v.fi]=v.fi;
				dfs2(v.fi,i,v.fi);
			}
		}
		for(auto v:adj[i]) if(vis[v.fi]!=v.fi) d[i][v.fi]=1;
	}
	for(int i=1;i<=n;i++) for(auto v:adj[i]) if(c[v.fi][i]==d[i][v.fi]) ans[v.se]=1;
	for(int i=1;i<=m;i++){
		if(ans[i]) printf("same\n");
		else printf("diff\n");
	}
	return 0;
}

Measured memory_bytes: 14544
#include<iostream>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)


int main()
{
	int n;
	while (1)
	{
		int arr[26] = {};
		int MAX1st = 0;
		int index1 = 0;
		int MAX2nd = 0;
		int index2 = 0;
		cin >> n;
		if (n == 0)break;
		int i;
		for (i = 0; i < n; i++)
		{
			if (n - i + MAX2nd < MAX1st)break;
			char c;
			cin >> c;
			arr[c - 'A']++;
			if (MAX1st < arr[c - 'A'])
			{
				MAX1st = arr[c - 'A'];
				index1 = c - 'A';
			}
			else if (MAX2nd < arr[c - 'A'])
			{
				MAX2nd = arr[c - 'A'];
				index2 = c - 'A';
			}
		}
		if (i == n && MAX2nd==MAX1st)
		{
			FOR(j, i,n)
			{
				char hoge;
				cin >> hoge;
			}
			cout << "TIE" << endl;
		}
		else
		{
			FOR(j, i, n)
			{
				char hoge;
				cin >> hoge;
			}
			cout << char(index1 + 'A') << " " << i << endl;
		}

	}
	return 0;
}

Measured memory_bytes: 3068
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;
const LL LINF=1LL<<62;
const int INF=1<<30;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};

vector<int> G[1<<11];

int dfs(int u,int v,int c,int p){
    int ret = 0;
    for(auto g:G[u]){
        if(g==v) continue;
        ret += dfs(g,u,c+1,p);
    }
    if(c > p) ret++;
    return ret;
}


int main(){
    int n,k;
    cin >> n >> k;
    for (int i = 0; i < n-1; i++) {
        int a,b;cin >> a >> b;
        a--,b--;
        G[a].pb(b);
        G[b].pb(a);
    }
    int ans = INF;
    if(k%2==0){
        for (int i = 0; i < n; i++) {
            int tmp = dfs(i,i,0,k/2);
            ans = min(ans,tmp);
        }
    }
    else{
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < G[i].size(); j++) {
                int tmp = dfs(i,G[i][j],0,k/2)+dfs(G[i][j],i,0,k/2);
                ans = min(ans, tmp);
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
while True:
    n=input()
    if n==0:
        break
    dp=[[0 for i in range(n+1)]for j in range(n+1)]
    for i in range(1,n+1):
        j=0
        line=" "+raw_input()
        for c in line:
            if c == ".":
                dp[i][j]=min(dp[i-1][j],dp[i][j-1],dp[i-1][j-1])+1
            j+=1
    allmax=0
    for i in range(n+1):
        if allmax<max(dp[i]):
            allmax=max(dp[i])
    print allmax

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

int main(){
  int n;
  cin >> n;
  int ans = 0;
  if(n < 10){
    ans = n;
  }
  else{
    ans += 9;
    if(99 < n){
      if(n < 1000){
        ans += n-99;
      }
      else{
        ans += 900;
        if(9999 < n){
          if(n < 100000){
            ans += n - 9999;
          }
          else{
            ans += 90000;
          }
        }
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
<?php
//error_reporting(0);
$S = trim(fgets(STDIN));
//list($N,$K) =  explode(" ",trim(fgets(STDIN)));
//$B = explode(" ",trim(fgets(STDIN)));

$sok = true;
for($i=0;$i<strlen($S);$i++) {
  if (($i %2)  == 0) {
    if ($S[$i]=='L') {
      $sok = false;
      break;
    }
  }
  else {
    if ($S[$i]=='R') {
      $sok = false;
      break;
    }
  }
}
printf("%s\n",$sok?'Yes':'No');


Measured memory_bytes: 4856
#include<bits/stdc++.h>
using namespace std;
 
int main(){
    int N, a;
    cin >> N;
	a = N % 10;
    if(a == 0 || a == 1 || a == 6 || a == 8){
        cout << "pon" <<endl;
    }else if(a == 3){
        cout << "bon" <<endl;
    }else{
      cout << "hon" <<endl;
	}
}

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

using namespace std;
using ll = long long;

using Field = vector<vector<int>>;
using Graph = vector<vector<int>>;
using VI = vector<int>;
using VC = vector<char>;
using PI = pair<int, int>;

#define REP(i, n) for (int i = 0; i < (n); i++)
#define ALL(x) x.begin(), x.end()

const long long INF = 1LL<<60;
const int mod = 1000000007;

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

int N;

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

    cin >> N;
    set<string> S;
    REP (i, N) {
        string s;
        cin >> s;
        S.insert(s);
    }

    cout << S.size() << endl;
    
    return 0;
}

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

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

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

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

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

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

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

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

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

fn main() {
    input! {
        n: usize,
        a: [i64; n],
    }

    let mut a = a;
    a.sort();

    let mut g = 0;
    let mut prev = 0i64;

    for (i, a) in a.iter().enumerate() {
        // a, i - prev

        if (*a - prev) % 2 != 0 {
            g ^= n - i;
        }

        prev = *a;
    }

    let ans = if g == 0 { "second" } else { "first" };

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


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

using namespace std;

#define loop(i, n) for(int i = 0;i < int(n);i++)
#define rloop(i, n) for(int i = int(n);i >= 0;i--)
#define range(i, a, b) for(int i = int(a);i <= int(b);i++)
#define SZ(c) int(c.size())
#define ALL(c) c.begin(), c.end()
#define RALL(c) c.rbegin(), c.rend()
#define PI acos(-1)
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define sfi1(v) scanf("%d",&v)
#define sfi2(v1, v2) scanf("%d %d",&v1,&v2)
#define sfi3(v1, v2, v3) scanf("%d %d %d",&v1,&v2,&v3)
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1, v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1, v2, v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
#define endl '\n'

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


int main() {

#ifndef ONLINE_JUDGE
    freopen("in.in", "r", stdin);
    //freopen("out.in", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    const int MOD = 1e9 + 7;
    int n;
    cin >> n;
    int ans = 1;
    range(i, 1, n)ans = 1LL * ans * i % MOD;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3584
#include <stdio.h>

int partition(int a[], int p, int r)
{
  int x = a[r];
  int i = p-1;
  for (int j = p; j <= r-1; j++) {
    if (a[j] <= x) {
      i++;
      int temp = a[i];
      a[i] = a[j];
      a[j] = temp;
    }
  }
  int temp = a[i+1];
  a[i+1] = a[r];
  a[r] = temp;
  return i+1;
}

int main(void)
{
  int n, i, x;
  int a[100000];
  scanf("%d", &n);
  for (i = 0; i < n; i++)
    scanf("%d", &a[i]);
  x = partition(a, 0, n-1);
  printf("%d", a[0]);
  for (i = 1; i < n; i++) {
    if (i == x)
      printf(" [%d]", a[i]);
    else
      printf(" %d", a[i]);
  } printf("\n");
}



Measured memory_bytes: 2096
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  string s;
  cin>>s;
  int co=1;
  rep(i,s.size()-1)if(s[i]!=s[i+1])co++;
  if(s[0]!=s[s.size()-1])co--;
  else if(s[0]=='x')co++;
  if(co%2)cout<<'o'<<endl;
  else cout<<'x'<<endl;
}

Measured memory_bytes: 1176
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>

#define CK(N,A,B) (A<=N&&N<B)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define RREP(i,a,b) for(int i=(b-1);a<=i;i--)
#define F first
#define S second
#define ll long long

const int INF = 1e9;
const long long  LLINF = 1e18;

using namespace std;


/*==================================================*/

/*==================================================*/


int main(){

  string S;
  cin>>S;
  bool flag = false;

  REP(i,0,S.size()){
    if(S[i] == 'C' && !flag){
      flag = true;
    }
    if(S[i] == 'F' && flag){
      cout<<"Yes"<<endl;
      return 0;
    }
  }

  cout<<"No"<<endl;

  return 0;
}


Measured memory_bytes: 256
package main

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

const mod = 998244353

var memo [3005][3005]int
var visited [3005][3005]bool

func solve(n, s int, a []int) int {
	if s < 0 {
		return 0
	}
	if visited[n][s] {
		return memo[n][s]
	}
	if n == 1 {
		if s == a[0] {
			return 1
		} else if s == 0 {
			return 2
		}
		return 0
	}
	memo[n][s] = (solve(n-1, s-a[n-1], a) + solve(n-1, s, a)*2) % mod
	visited[n][s] = true
	return memo[n][s]
}

var sc = bufio.NewScanner(os.Stdin)

func NextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	n := NextInt()
	s := NextInt()

	A := make([]int, n)
	for i := 0; i < n; i++ {
		A[i] = NextInt()
	}
	fmt.Println(solve(n, s, A))
}


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

using namespace std;

#define ll long long
#define vv vector<vector<ll>>

const int mxN = 55;
const ll mo=1e9+7;

vv mul(vv a, vv b) {
    int n = a.size();
    vv product(n, vector<ll>(n, 0));
    for (int i=0; i<n; i++) {
        for (int j=0; j<n; j++) {
            for (int k=0; k<n; k++) {
                product[i][j]+=(a[i][k]*b[k][j])%mo;
            }
            product[i][j] %= mo;
        }
    }
    return product;
}

vv power(vv a, ll p) {
    int n = a.size();
    vv product(n, vector<ll>(n, 0));
    for (int i=0; i<n; i++) {
        product[i][i]=1;
    }
    vv temp=a;

    while (p) {
        if (p & 1) {
            product=mul(product,temp);
        }
        p >>=1;
        temp=mul(temp,temp);
    }
    return product;
}

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

    int n;
    ll k;
    cin >> n >> k;

    vv a(n, vector<ll>(n));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            cin >> a[i][j];
        }
    }

    vv ansv = power(a, k);
    ll ans=0;
    for (int i=0; i<n; i++) {
        for (int j=0; j<n; j++) {
            ans = (ans + ansv[i][j]) %mo;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 384
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

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

		if (a <= b){
			System.out.println(a);
		} else {
			System.out.println(a - 1);
		}

	}
}

Measured memory_bytes: 21716