akhauriyash/Code-Regression huggingface dataset:
import sys
import math
from itertools import accumulate as acc

input=sys.stdin.readline

N,C=map(int,input().split())


a=[[0 for i in range(10**5+1)] for i in range(C+1)]

rec=[0 for i in range(10**5+1)]

for i in range(N):
    s,t,c=map(int,input().split())
    recs,rect=a[c][s],a[c][t]
    if recs==0 and rect==0:
        rec[s-1]+=1
        rec[t]-=1
    elif recs==0 and rect==1:
        rec[s-1]+=1
        rec[t-1]-=1
    elif recs==1 and rect==0:
        rec[s]+=1
        rec[t]-=1
    elif recs==1 and rect==1:
        rec[s]+=1
        rec[t-1]-=1

    a[c][s],a[c][t]=1,1

print(max(list(acc(rec))))

Measured memory_bytes: 29128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        // Scanner scan = new Scanner(System.in);
        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
        double a;
        double pi = 3.1415926535;
        try {
            a = Double.parseDouble(bf.readLine());
            System.out.printf("%.10f %.10f\n", a * a * Math.PI, 2 * a * Math.PI);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}


Measured memory_bytes: 24912
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(){
    string S;
    cin>>S;
    string A="ACGT";
    int count=0;int ans=0;
    for(int i=0;i<S.size();i++){
        bool K=false;
        for(int j=0;j<A.size();j++){

            if(S.at(i)==A.at(j)){K=true;}
    }
        if(!K){count=0;}
        else {count++;ans=max(count,ans);}}
        cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
using namespace std;
#define ll int64_t
const long MOD = 1e9 + 7;
const long LINF = 1e13;
const long LLINF = 1e18;

template <class T>
void Swap(T& r, T& l) {
  T tmp = r;
  r = l;
  l = tmp;
}



int main() {

  long n;
  cin >> n;
  vector<long> a(n);
  vector<long> accum(n, 0);

  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    accum[i] = a[i];
    if (i > 0)accum[i] += accum[i - 1];
  }


  vector<long> accumtmp(n, 0);
  copy(accum.begin(), accum.end(), accumtmp.begin());



  long ans = 0;
  long count = 0;

  long tmpcount = 0;
  for (int i = 0; i < n; ++i) { //最初 0 が負の数
    long accump = accumtmp[i] + tmpcount;
    if (i % 2 == 1) { //負の数にする
      if ( accump >= 0 ) {
        long tmpc = - (- 1 - accump );
        count += tmpc;
        accumtmp[i] = -1;
        tmpcount -= tmpc;
      }
    } else {
      if (accump <= 0) {
        long tmpc = 1 - accump;
        count += tmpc;
        tmpcount += tmpc;
      }
    }
  }



  ans = count;

  count = 0;

  copy(accum.begin(), accum.end(), accumtmp.begin());
  tmpcount = 0;
  for (int i = 0; i < n; ++i) { //最初 0 が負の数
    long accump = accumtmp[i] + tmpcount;

    if (i % 2 == 0) { //負の数にする
      if ( accump >= 0 ) {
        long tmpc = - (- 1 - accump );
        count += tmpc;
        accumtmp[i] = -1;
        tmpcount -= tmpc;
      }
    } else {
      if (accump <= 0) {
        long tmpc = 1 - accump;
        count += tmpc;
        tmpcount += tmpc;
      }
    }
  }



  ans = min(ans, count);



  cout << ans;




}

Measured memory_bytes: 2560
MOD = 10**9+7
n = int(input())
all_cnt = pow(10,n,MOD)
no09 = pow(8,n,MOD)
yes09 = all_cnt-no09

no0 = pow(9,n,MOD)
yes0 = all_cnt-no0
yes9 = yes0

ans = yes0+yes9-yes09
print(ans%MOD)

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

int main(){
    long long N, A, B; 
    cin >> N >> A >> B;
    if((B - A) % 2 == 0 ){
        cout << (B - A) / 2 << endl;
        return 0;
    }
    else {
        long long d_a, d_b; d_a = A-1; d_b = N-B;
        //cout << d_a << d_b << endl;
        if(d_a < d_b){ //左
            A = 1; B = B - d_a - 1;
            if(A == B){
                cout << d_a + 1 << endl;
            }
            else{
                cout << d_a + 1 + (B-A) / 2 << endl;
            }
        }
        else{
            A = A + d_b + 1; B = N;
            //cout << A << B << endl;
            if(A == B){
                cout << d_b + 1 << endl;
            }
            else{
                cout << d_b + 1 + (B - A)/2 << endl;
            }

        }
    }
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <iostream>
#include <set>
#include <queue>
#include <vector>

using namespace std;

constexpr static int MAXN = 3000 + 10;
constexpr static int MOD = 998244353;

int64_t cnt[MAXN][MAXN];

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

    int A, B, C, D;
    cin >> A >> B >> C >> D;

    cnt[A][B] = 1;
    for (int a = A; a <= C; a++) {
        for (int b = B; b <= D; b++) {
            if (a > A && b > B) {
                cnt[a][b] += cnt[a - 1][b] * b;
                cnt[a][b] += cnt[a][b - 1] * a;
                cnt[a][b] -= cnt[a - 1][b - 1] * (a - 1) % MOD * (b - 1) % MOD;
                cnt[a][b] += MOD;
                cnt[a][b] %= MOD;
            }
            else if (a > A) {
                cnt[a][b] = cnt[a - 1][b] * b % MOD;
            }
            else if (b > B) {
                cnt[a][b] = cnt[a][b - 1] * a % MOD;
            }
        }
    }
    cout << cnt[C][D] << endl;
}


Measured memory_bytes: 73580
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>
#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>
#include <math.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define repf(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define repr(i, a, b) for (ll i = (ll)a; i > (ll)b; i--)
#define repv(x, arr) for (auto &x : arr)
#define all(v) (v).begin(), (v).end()
#define vec(name, num) vector<ll> name((num), 0);
#define mp(a, b) make_pair(a, b)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int infi = 2147483600;
const ll infl = 1e17;

int main()
{
    ll s;
    cin >> s;
    ll nine = 1e9;
    cout << 0 << " " << 0 << " ";
    if (s<=1e9){
        cout << s << " " << 0 << " " << 0 << " " << 1 << endl;
        return 0;
    }
    else if (s%nine==0){
        cout << nine << " " << 0 << " " << 0 << " " << s / nine << endl;
    }
    else {
        ll x2 = nine;
        ll x3=nine-s%nine;
        ll y2=1;
        ll y3=1 + s/nine;
        cout << x2 << " " << y2 << " " << x3 << " " << y3 << endl;
    }
}


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

int main() {
  int S, W;
  cin >> S >> W;
  if(S<=W) cout << "unsafe" << endl;
  else cout << "safe" << endl;
}

Measured memory_bytes: 3624
import functools, sys

x, y = map(int, input().split())

mod = 10 ** 9 + 7

def modpow(x, y):
    z = 1
    while y > 0:
        if y % 2 == 0:
            x = (x * x) % mod
            y //= 2
        else:
            z = (z * x) % mod
            y -= 1
    return z

def modinv(x):
    return modpow(x, mod - 2)

def c(n, r):
    if n == r or r == 0:
        return 1

    fct = [None] * (n + 1)
    fct[0] = 1
    for i in range(1, n + 1):
        fct[i] = fct[i - 1] * i % mod
    return fct[n] * (modinv(fct[n - r]) * modinv(fct[r]) % mod) % mod

def f():
    if 2 * y - x < 0 or (2 * y - x) % 3 != 0:
        return 0
    a = (2 * y - x) // 3
    b = y - 2 * a
    if b < 0:
        return 0
    
    return c(a + b, a)

print(f())

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

using namespace std;

using ll = long long;

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

    vector<ll> s(n + 1);

    for (int i = 0; i < n; i++) {
        int p;
        cin >> p;
        s[i + 1] = s[i] + p;
    }

    double ans = 0;
    int left = 0, right = k;
    while (right <= n) {
        ans = max(ans, (double)((double)s[right] - (double)s[left] + k) / 2);
        left++; right++;
    }

    cout << fixed << setprecision(10) << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int64_t ans = 0, all = 0b00000000;
vector<vector<int64_t>> Graph(8);

void dfs(int node, int bit)
{
  if (bit & (1 << node))
    return;
  bit |= (1 << node);
  if (bit == all)
  {
    ans++;
    return;
  }
  int nextBit = bit;
  for (int i = 0; i < Graph.at(node).size(); i++)
  {
    int nextNode = Graph.at(node).at(i);
    dfs(nextNode, nextBit);
  }
}

int main()
{
  int64_t N, M, a, b;
  cin >> N >> M;
  for (int i = 0; i < M; i++)
  {
    cin >> a >> b;
    a--;
    b--;
    Graph.at(a).push_back(b);
    Graph.at(b).push_back(a);
  }
  for (int i = 0; i < N; i++)
  {
    all |= (1 << i);
  }
  dfs(0, 0b00000000);
  cout << ans << endl;
}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
r,g,b=[-1],[-1],[-1]
ans=1
for i in range(n):
    f=1
    count=0
    if r[-1]==a[i]-1:
        count+=1
        r.append(a[i])
        f=0
    if g[-1]==a[i]-1:
        count+=1
        if f:
            g.append(a[i])
            f=0
    if b[-1]==a[i]-1:
        count+=1
        if f:
            b.append(a[i])
            f=0
    if f:
        print(0)
        exit()
    ans=(ans*count)%(10**9+7)
print(ans)

Measured memory_bytes: 20816
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define itn int
#define fi first
#define se second
#define be begin()
#define en end()
#define reverse
const int mod=1000000007;
const int INFi=2147483647;
const long long INFl=9223372036854775807LL;
template<typename T> T abs(T a,T b){
  return max(a,b)-min(a,b);
}
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  itn n,k;
  int d,a,ans=0;
  int date[100000]={};
  cin>>n>>k;
  for(int i=0;i<k;i++){
    cin>>d;
    for(int j=0;j<d;j++){
      cin>>a;
      date[a]++;
    }
  }
  for(int i=1;i<=n;i++){
    if(date[i]==0) ans++;
  }
  cout<<ans<<"\n";
}


Measured memory_bytes: 4396
N, M = map(int, input().split())
switch = [list(map(int, input().split())) for _ in range(M)]
p = list(map(int, input().split()))
ans = 0

for i in range(2**N):
    for j in range(M):
        tmp = 0
        for s in switch[j][1:]:
            if i & 2**(s-1) == 2**(s-1):
                tmp = 1-tmp
        if tmp != p[j]:
            break
    else:
        ans += 1

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long int;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1e9;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
int main(){
    string s,t;
    cin >> s >> t;
    if (s.length() < t.length()){
        printf("UNRESTORABLE");
        return 0;
    }
    bool ok = 0;
    string u;
    for(int i = s.length()-t.length();i >= 0;i--){
        ok = 0;
        u = s;
        if (s[i] == t[0] || s[i] == '?'){
            rep(j,t.length()){
                if (s[i+j] == '?' || s[i+j] == t[j]){
                    u[i+j] = t[j];
                }
                else break;
                if (j == t.length()-1) ok = 1;
            }
        }
        if (ok){
            rep(i,u.length()){
                if (u[i] == '?') u[i] = 'a';
            }
            PRINT(u);
            return 0;
        }
    }
    printf("UNRESTORABLE");
}

Measured memory_bytes: 256
// Dmitry _kun_ Sayutin (2019)

#include <bits/stdc++.h>

using std::cin;
using std::cout;
using std::cerr;

using std::vector;
using std::map;
using std::array;
using std::set;
using std::string;

using std::pair;
using std::make_pair;

using std::tuple;
using std::make_tuple;
using std::get;

using std::min;
using std::abs;
using std::max;
using std::swap;

using std::unique;
using std::sort;
using std::generate;
using std::reverse;
using std::min_element;
using std::max_element;

#ifdef LOCAL
#define LASSERT(X) assert(X)
#else
#define LASSERT(X) {}
#endif

template <typename T>
T input() {
    T res;
    cin >> res;
    LASSERT(cin);
    return res;
}

template <typename IT>
void input_seq(IT b, IT e) {
    std::generate(b, e, input<typename std::remove_reference<decltype(*b)>::type>);
}

#define SZ(vec)         int((vec).size())
#define ALL(data)       data.begin(),data.end()
#define RALL(data)      data.rbegin(),data.rend()
#define TYPEMAX(type)   std::numeric_limits<type>::max()
#define TYPEMIN(type)   std::numeric_limits<type>::min()

int main() {
    std::iostream::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    // code here

    int n = input<int>();

    const int many = 21000;
    vector<int> a(n), b(n);
    for (int i = 0; i != n; ++i) {
        a[i] = (i + 1) * many;
        b[i] = (n - i) * many;
    }
    
    for (int i = 0; i != n; ++i) {
        a[input<int>() - 1] += i;
    }

    for (int i = 0; i != n; ++i)
        cout << a[i] << " \n"[i + 1 == n];

    for (int i = 0; i != n; ++i)
        cout << b[i] << " \n"[i + 1 == n];

    return 0;
}


Measured memory_bytes: 768
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace cf
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            if (s.IndexOf("YAKI") == 0)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 13280
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#ifdef _DEBUG_
	#define debug(...) printf(__VA_ARGS__)
#else
	#define debug(...) (void)0
#endif
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;

const int MAXN = 100000 + 50;
int A[MAXN];

void bad() {
	puts("NO");
	exit(0);
}
void good() {
	puts("YES");
	exit(0);
}

int main() {
	int N;
	scanf("%d", &N);
	for(int i = 0; i < N; i++)
		scanf("%d", &A[i]);
	ll sum = 0;
	for(int i = 0; i < N; i++)
		sum += A[i];
	ll one = 1ll * N * (N + 1) / 2;
	if(sum % one != 0) bad();
	ll num_op = sum / one;
	ll cnt_op = 0;
	A[N] = A[0];
	debug("!\n");
	for(int i = 0; i < N; i++) {
		ll x = A[i + 1] - A[i];
		if((num_op - x) % N != 0) bad();
		ll tmp = (num_op - x) / N;
		if(tmp < 0) bad();
		cnt_op += tmp;
	}
	if(cnt_op != num_op) bad();
	good();
	return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        {
            Scanner input = new Scanner(System.in);
            int a = input.nextInt();
            String s = input.next();
            if(a < 3200)
                System.out.println("red");

            else
                System.out.println(s);
        }
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

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

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> S(N);
  rep(i, N) cin >> S[i];
  vector<int> T(M);
  rep(i, M) cin >> T[i];

  vector<vector<ll>> dp(N + 1, vector<ll>(M + 1, 0));
  dp[0][0] = 1;
  rep(i, N + 1) {
    rep(j, M + 1) {
      if (i >= 1 && j >= 1 && S[i - 1] == T[j - 1]) {
        dp[i][j] += dp[i - 1][j - 1];
        dp[i][j] %= MOD;
      }
      if (i >= 1) {
        dp[i][j] += dp[i - 1][j];
        dp[i][j] %= MOD;
      }
      if (j >= 1) {
        dp[i][j] += dp[i][j - 1];
        dp[i][j] %= MOD;
      }
      if (i >= 1 && j >= 1) {
        dp[i][j] -= dp[i - 1][j - 1];
        dp[i][j] %= MOD;
        if (dp[i][j] < 0) dp[i][j] += MOD;
      }
    }
  }
  cout << dp[N][M] << endl;
}

Measured memory_bytes: 31616
#input : 問題数N、それぞれの難易度d_1からd_nまで
#output : 問題をちょうど半分に分けることができるような難易度Kの値の個数

N = int(input())
d = list(map(int,input().split()))
d.sort()
ARC = []
ABC = []

for i in range(N//2):
    ABC.append(d[i])
    ARC.append(d[-(i+1)])

boundaryARC = min(ARC)
boundaryABC = max(ABC)

if boundaryABC == boundaryARC:
    print(0)

else:
    print(boundaryARC-boundaryABC)

Measured memory_bytes: 14428
N = int(input())
A = list(map(int,input().split()))
MAX = max(A)
MIN = min(A)

print(2 * N - 1)

if MAX >= -1 * MIN:
    j = A.index(MAX)
    for i in range(N):
        print(*[j+1, i+1])
    for i in range(N-1):
        print(*[i+1, i+2])
else:
    j = A.index(MIN)
    for i in range(N):
        print(*[j+1, i+1])
    for i in range(N-1,0,-1):
        print(*[i+1, i])

Measured memory_bytes: 3064
using System;
class Program{
	static void Main(){
		int[] s=Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
		int[] a=new int[4];
		a[0]=s[2]-(s[3]-s[1]);
		a[1]=s[3]+s[2]-s[0];
		a[2]=a[0]-(a[1]-s[3]);
		a[3]=a[1]+a[0]-s[2];
		Console.WriteLine("{0} {1} {2} {3}",a[0],a[1],a[2],a[3]);
	}
}

Measured memory_bytes: 13268
import java.util.*;
import java.io.*;
import static java.lang.Math.*;

public class Main {
    public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		int m = sc.nextInt();
		int k = sc.nextInt();
		
		
		// 計算
		long result = 0;
		int MOD = 998244353;
		Combination comb = new Combination(n);
		for(int i = 0; i <= k; i++){
		    result += comb.combination(n-1, i)*m%MOD*pow(m-1, n-i-1, MOD);
		    result %= MOD;
		}
		
		// 出力
		System.out.println(result);
	}
	
	public static long pow(long a, long n, long MOD) {
		long res=1;
		while (n>0) {
			if ((n-n/2*2)==1) {
				res=(res*a)%MOD;
			}
			a=(a*a)%MOD;
			n>>=1;
		}
		return res%MOD;
	}
	
	public static class Scanner {
		private BufferedReader br; private StringTokenizer tok;
		public Scanner(InputStream is) throws IOException { br = new BufferedReader(new InputStreamReader(is));}
		private void getLine() throws IOException { while(!hasNext()) tok = new StringTokenizer(br.readLine());}
		private boolean hasNext() { return tok != null && tok.hasMoreTokens();}
		public String next() throws IOException { getLine(); return tok.nextToken();}
		public int nextInt() throws IOException { return Integer.parseInt(next());}
		public long nextLong() throws IOException { return Long.parseLong(next());}
		public double nextDouble() throws IOException { return Double.parseDouble(next());}
	}
}

class Combination {
	static final int MOD = 998244353;
	long[] fact;
	long[] invFact;
	long[] inv;
	
	public Combination (int n) {
		fact = new long[n+1];
		invFact = new long[n+1];
		inv = new long[n+1];
		fact[0] = 1;
		fact[1] = 1;
		invFact[0] = 1;
		invFact[1] = 1;
		inv[1] = 1;
		for (int i = 2; i < n+1; i++) {
			fact[i] = fact[i - 1] * i % MOD;
			inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
			invFact[i] = invFact[i - 1] * inv[i] % MOD;
		}
	}
	
	public long combination(int n, int k) {
		if (n < k || n < 0 || k < 0) {
			return 0;
		}
		return fact[n] * (invFact[k] * invFact[n - k] % MOD) % MOD;
	}
}

Measured memory_bytes: 30884
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define vlli vector<ll>
#define vi vector<int>
#define vs vector<string>
#define vplli vector< pair< ll,ll> >
#define plli pair< ll,ll >
#define vps vector< pair< string, string> >
#define vpi vector< pair< int, int> >
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn(i,a,n) for(ll i=a;i<n;i++)
#define forr(i,n,a) for(ll i=n-1;i>=a;i--)
#define scan(arr,a,n) for(int i=(a);i<(n);i++)cin>>(arr)[i];
#define print(arr,a,n) for(int i=(a);i<(n);i++)cout<<(arr)[i]<<' ';

const ll inf = 1e18;

ll add(ll x, ll y) {ll res = x + y; return (res >= mod ? res - mod : res);}
ll mul(ll x, ll y) {ll res = x * y; return (res >= mod ? res % mod : res);}
ll sub(ll x, ll y) {ll res = x - y; return (res < 0 ? res + mod : res);}
ll power(ll x, ll y) {ll res = 1; x %= mod; while (y) {if (y & 1)res = mul(res, x); y >>= 1; x = mul(x, x);} return res;}
ll mod_inv(ll x) {return power(x, mod - 2);}

int main(){
	fast;
	string s;
	cin>>s;
	map<char, ll> m;
	forn(i, 0, 3){
		m[s[i]]++;
	}
	if(m['a']>0 && m['b']>0 && m['c']>0){
		cout<<"Yes"<<endl;
	} else {
		cout<<"No"<<endl;
	}
}

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

int main(void){
  string s;
  cin >> s;
  for(int i=s.size()-1;i>=0;--i){
    string ss = s.substr(0,i);
    if(ss.size()%2!=0) continue;
    string s1=ss.substr(0,ss.size()/2), 
    s2=ss.substr(ss.size()/2, ss.size()/2);
    if(s1==s2){
      cout << ss.size() << endl;
      break;
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

bool kaibun(int n) {
  string s = to_string(n);
  for (int i = 0; i < s.size() / 2; i++) {
    if (s[i] != s[s.size() - i - 1]) return false;
  }
  return true;
}

int main() {
  int a, b;
  cin >> a >> b;
  int ans = 0;
  for (int i = a; i <= b; i++) {
    if (kaibun(i)) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3656
//全然閃かない・・・
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

int P[200001], P1[200001];
int Find(int A) {
	if (P[A] < 0) return A;
	return P[A] = Find(P[A]);
}
int Find1(int A) {
	if (P1[A] < 0) return A;
	return P1[A] = Find1(P1[A]);
}

ll root[200001];
ll tmp[200001];
void pakuripair_sort(int N, ll A[], int B[]) {
	const int b = 9;
	rep(k, 4) {
		int kazu[1 << b] = {}, kazu2[1 << b] = {};
		rep(i, N) kazu[A[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu[i + 1] += kazu[i];
		for (int i = N - 1; i >= 0; i--) {
			tmp[--kazu[A[i] >> k * b & ((1 << b) - 1)]] = A[i];
			P1[kazu[A[i] >> k * b & ((1 << b) - 1)]] = B[i];
		}
		k++;
		rep(i, N) kazu2[tmp[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu2[i + 1] += kazu2[i];
		for (int i = N - 1; i >= 0; i--) {
			A[--kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = tmp[i];
			B[kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = P1[i];
		}
	}
}

const int dm = 1 << 21;
char dn[dm], * di = dn;
inline void putint(int X) {
	int keta = 0;
	char C[10];
	while (X) {
		*(C + keta) = '0' + X % 10;
		X /= 10;
		keta++;
	}
	for (int i = keta - 1; i >= 0; i--)* di++ = (*(C + i));
	*di++ = ' ';
}

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


	int N = getint(), K = getint(), L = getint();
	rep1(i, N) P[i] = -1;
	rep(i, K) {
		int p = getint(), q = getint();
		p = Find(p);
		q = Find(q);
		if (p != q) {
			if (P[p] > P[q]) swap(p, q);
			P[p] += P[q];
			P[q] = p;
		}
	}

	rep1(i, N) P1[i] = -1;
	rep(i, L) {
		int p = getint(), q = getint();
		p = Find1(p);
		q = Find1(q);
		if (p != q) {
			if (P1[p] > P1[q]) swap(p, q);
			P1[p] += P1[q];
			P1[q] = p;
		}
	}
	rep1(i, N) root[i] = Find(i) + ((ll)Find1(i) << 18);

	rep1(i, N) P[i] = i;
	pakuripair_sort(N, root + 1, P + 1);

	int mae = 1;
	for (int i = 2; i <= N; i++) {
		if (root[mae] != root[i]) {
			for (int j = mae; j < i; j++) P1[P[j]] = i - mae;
			mae = i;
		}
	}
	for (int j = mae; j <= N; j++) P1[P[j]] = N + 1 - mae;

	rep1(i, N) putint(P1[i]);

	fwrite(dn, 1, di - dn, stdout);

	Would you please return 0;
}

Measured memory_bytes: 6016
import itertools
from collections import Counter
from collections import defaultdict
import bisect
from heapq import heappush, heappop

def main():
    n, m = map(int, input().split())
    if n * 2 > m:
        print(m//2)
    else:
        rest = m - n * 2
        from_c_count = rest // 4
        print(n + from_c_count)

if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
#include <iostream>
#include<cmath>
#include<stdio.h>
using namespace std;

int main(){
	
	double a,b,C,S,L,h;//a,b?????????C????§????
	cin >> a >> b >> C;
	
	S = a * b * sin((C / 180) * M_PI)/2; //sin(????????¢?????????)
	L = a + b + sqrt(a*a + b*b - 2*a*b*cos((C / 180) * M_PI)) ; 
	h = S * (double)2/a; //??¢????????????a * ??????h/2?????? 
	
	printf("%.8f\n %.8f\n %.8f\n", S,L,h);
	return 0;
	
}

Measured memory_bytes: 1240
#include <iostream>
#include <algorithm>
#define INF 100000000

using namespace std;
int dd[100][100];
int v[100];
int n,m;

void init(){
  for(int i = 0 ; i < n ; i++ ){
  for(int j = 0 ; j < n ; j++ ){
    dd[i][j] = INF;
  }
  }
}

void dijkstra(int s){
  bool visited[100];
  fill(visited,visited+100,false);
  fill(v,v+100,INF);
  v[s] = 0;

  while(1){
    int vv = -1;

    for(int i = 0 ; i < n ; i++ ){
      if(!visited[i] && (vv == -1 || v[i] < v[vv]))vv = i;
    }

    if(vv == -1)break;

    visited[vv] = true;
    for(int i = 0 ; i < n ; i++ ){
      v[i] = min(v[i],v[vv] + dd[vv][i]);
    }
  }
}

int main(){

  cin >> n >> m;
  n++;

  int a,b,c,d;
  char ch;
  init();
  for(int i = 0 ; i < m ; i++ ){
       cin >> a >> ch >> b >> ch >> c >> ch >> d;
    dd[a][b] = c;
    dd[b][a] = d;
  }
  int spos,gpos,mone,hasira;
  cin >> spos >> ch >> gpos >> ch >> mone >> ch >> hasira;
  dijkstra(spos);
  int go,back; 
  go = v[gpos];

  dijkstra(gpos);

  back = v[spos];
  cout << mone-(go+back+hasira) << endl;
  return 0;
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
#include<string.h>
#define ll long long
#define pf printf
#define sf scanf
#define ff first
#define ss second
#define clr clear()
#define sz size()
#define pb push_back
#define mk make_pair
#define pi acos(-1)
#define inf 20000000000000000
#define mod 1000000007
#define ull unsigned long long int
#define f(i,k,n) for(i=k;i<n;i++)
#define fr(i,n,k) for(i=n;i>=k;i--)
#define ent(a) scanf("%lld",&a)
#define ent2(a,b) scanf("%lld%lld",&a,&b)
#define ent3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define mem(a) memset(a,0,sizeof(a))
#define vec(v,s) vector<ll>v[s]
#define arr(a,s) ll a[s];
/*#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/
//knight and king//
int dr[]= {2,2,-2,-2,1,-1,1,-1};
int dc[]= {1,-1,1,-1,2,2,-2,-2};
int dr1[]= {0,0,1,1,1,-1,-1,-1};
int dc1[]= {1,-1,1,0,-1,0,1,-1};
int dr2[]= {0,0,1,-1};
int dc2[]= {1,-1,0,0};
////////////////////////////
using namespace std;
#define ma 1000005

ll get(ll x)
{
    if(x<600)return 8;
    if(x<800)return 7;
    if(x<1000)return 6;
    if(x<1200)return 5;
    if(x<1400)return 4;
    if(x<1600)return 3;
    if(x<1800)return 2;
    if(x<2000)return 1;

}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    ll n,k,i,j,x;
    while(cin>>n)
    {
       cout<<get(n)<<endl;
    }
    return 0;
}


Measured memory_bytes: 3612
/*
{By GWj
*/
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
#define ff fflush(stdout)
#define fastio ios::sync_with_stdio(false)
#define R(a) cin>>a
#define R2(a,b) cin>>a>>b
#define check_min(a,b) a=min(a,b)
#define check_max(a,b) a=max(a,b)
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
/*}
*/
int n,a[101][2];
int main(){
	fastio;
	R(n);
	rb(i,1,n)
		cin>>a[i][0]>>a[i][1];
	rb(i,1,n-3+1){
		if(a[i][0]==a[i][1])
			if(a[i+1][0]==a[i+1][1])
				if(a[i+2][0]==a[i+2][1]){
					cout<<"Yes\n";
					return 0;
				}
	}
	cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define ii pair<int,int>
#define iii pair<int,ii>

using namespace std;

int n,e,parent[10004];
vector<iii>graph;

void init(int n,int e){
    for(int i=0; i<e; i++){
        int u,v,w;
        cin>>u>>v>>w;
        graph.push_back(iii(w,ii(u,v)));
    }
}

int findParent(int r){
    if(parent[r]==r)return r;
    return parent[r]=findParent(parent[r]);
}

int krus(){
    int cntEdge=0,cost=0;
    for(int i=0; i<n; i++)parent[i]=i;
    sort(graph.begin(),graph.end());

    for(int i=0; i<graph.size(); i++){
        int u=findParent(graph[i].second.first),
            v=findParent(graph[i].second.second),
            w=graph[i].first;
        if(u!=v){
            parent[u]=v;
            cost+=w;
            cntEdge++;
        }if(cntEdge==n-1)break;
    }

    return cost;
}

int main(){
    cin>>n>>e;
    init(n,e);
    cout<<krus()<<endl;
return 0;
}



Measured memory_bytes: 4528
from numpy import cumsum
n,q=map(int,input().split())
*s,=input()
l=[0]*q
r=[0]*q
for i in range(q):
    l[i],r[i]=map(int,input().split())
a=[0]*n
for i in range(n-1):
    if s[i]=="A" and s[i+1]=="C":
        a[i]=1
b=[0]+list(cumsum(a))
for i in range(q):
    print(b[r[i]-1]-b[l[i]-1])

Measured memory_bytes: 28296
N = [int(i) for i in input().split()][0]

ls = []
for i in range(N):
  a,b = [i for i in input().split()]
  tmp = [str(a),int(b)]
  ls.append(tmp)

new_ls = sorted(ls, key=lambda x:x[1], reverse=True)
new_ls = sorted(new_ls, key=lambda x:x[0])

for next,l in enumerate(new_ls):
  for i,tmp in enumerate(ls):
    if l[0]==tmp[0] and l[1]==tmp[1]:
      print(i+1)

Measured memory_bytes: 3064
n = int(input())
ab = [[] for _ in range(n)]
for i in range(n):
    ab[i] = list(map(int, input().split()))
ab.sort(key=lambda x: x[1])
r = 0
flag = True
for a, b in ab:
    r += a
    if r > b:
        flag = False
        break

print("Yes") if flag else print("No")


Measured memory_bytes: 46892
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <numeric>
#include <tuple>

template <class T, class U>
inline bool chmin(T &lhs, const U &rhs) {
  if (lhs > rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

template <class T, class U>
inline bool chmax(T &lhs, const U &rhs) {
  if (lhs < rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

// [l, r) from l to r
struct range {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { ++i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr range(int l_, int r_): l(l_), r(std::max(l_, r_)) { }
  constexpr itr begin() const { return l; }
  constexpr itr end() const { return r; }
};

// [l, r) from r to l
struct revrange {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { --i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr revrange(int l_, int r_): l(l_ - 1), r(std::max(l_, r_) - 1) { }
  constexpr itr begin() const { return r; }
  constexpr itr end() const { return l; }
};

class disjoint_set_union {
private:
  std::vector<int> parent;
  std::vector<bool> namori;

public:
  disjoint_set_union(int size_) {
    parent.assign(size_, -1);
    namori.assign(size_, 0);
  }


  int find(int x) {
    if (parent[x] < 0) return x;
    return parent[x] = find(parent[x]);
  }

  bool add_edge(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) {
      if (namori[x]) return false;
      namori[x] = true;
    }
    else {
      if (namori[x] && namori[y]) return false;
      if (parent[x] > parent[y]) std::swap(x, y);
      parent[x] += parent[y];
      parent[y] = x;
      namori[x] = namori[x] || namori[y];
    }
    return true;
  }

};

int main() {
  int N, H, W;
  std::cin >> N >> H >> W;
  using edge_type = std::tuple<int, int, int>;
  std::vector<edge_type> edge;
  edge.reserve(N);
  for (int i: range(0, N)) {
    int r, c, a;
    std::cin >> r >> c >> a;
    --r; --c;
    edge.emplace_back(a, r, c + H);
  }
  std::sort(edge.rbegin(), edge.rend());
  long long ans = 0;
  disjoint_set_union dsu(H + W);
  for (const auto &e: edge) {
    int a, r, c;
    std::tie(a, r, c) = e;
    if (dsu.add_edge(r, c)) {
      ans += a;
    }
  }
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 2176
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
typedef unsigned int ui;
struct edge { ll from,to, cost; };
edge G[2001];
int main() {
	int n;
	string s;
	cin >> n >> s;
	int i;
	int a, b; a = 0; b = 0; string t="";
	for (i = 0; i < n; i++) {
		if (s[i] == '(')a++;
		else if(s[i]==')')b++;
		if (a < b) {
			t += "("; a++;
		}
	}
	string u="";
	for (i = 0; i < a - b; i++) {
		u += ")";
	}
	cout << t + s + u << endl;
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = 2147483647;
const ld PI = 3.14159265358979323846;

//------------↓------------- M -------------- E ---------------- M --------------- O ---------------↓--------------//
// コンパイル 
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
// 
//
//
//
//
//
// 
//------------↑------------- M -------------- E ---------------- M --------------- O ---------------↑--------------//




int main() {

    int N; cin >> N;
    int a[N+1];
    for (int i = 1; i <= N; ++i) cin >> a[i];

    int b[N+1]; rep(i,N+1) b[i] = -1;
    vector<int> ans;
    for (int i = N; i >= 1; --i) {
        int j = 2;
        int sum = 0;
        while (i*j <= N) {
            sum += b[i*j];
            ++j;
        }
        b[i] = (a[i] + sum) % 2;
        if (b[i] == 1) ans.push_back(i);
    }


    cout << ans.size() << endl;
    rep(i,ans.size()) cout << ans[i] << " ";
    cout << endl;

    return 0;
}





Measured memory_bytes: 5404
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

class Node {
public:
  int location;
  int p, l, r;
  Node() {}
};

class Point {
public:
  int id, x, y;
  Point() {}
  Point(int id, int x, int y) : id(id), x(x), y(y) {}
  bool operator < (const Point &p) const {
    return id < p.id;
  }
  void print() {
    printf("%d\n", id);
  }
};

static const int MAX = 1 << 20;
static const int NIL = -1;

int N;
Point P[MAX];
Node T[MAX];
int np;

bool lessX(const Point &p1, const Point &p2) { return p1.x < p2.x; }
bool lessY(const Point &p1, const Point &p2) { return p1.y < p2.y; }

int makeKDTree(int l, int r, int depth) {
  if (!(l < r)) return NIL;
  int mid = (l + r) / 2;
  int t = np++;
  if (depth % 2 == 0) {
    sort(P + l, P + r, lessX);
  } else {
    sort(P + l, P + r, lessY);
  }
  T[t].location = mid;
  T[t].l = makeKDTree(l, mid, depth + 1);
  T[t].r = makeKDTree(mid + 1, r, depth + 1);
  return t;
}

void find(int v, int sx, int tx, int sy, int ty, int depth, vector<Point> &ans) {
  int x = P[T[v].location].x;
  int y = P[T[v].location].y;
  if (sx <= x && x <= tx && sy <= y && y <= ty) {
    ans.push_back(P[T[v].location]);
  }
  if (depth % 2 == 0) {
    if (T[v].l != NIL) {
      if (sx <= x) find(T[v].l, sx, tx, sy, ty, depth + 1, ans);
    }
    if (T[v].r != NIL) {
      if (x <= tx) find(T[v].r, sx, tx, sy, ty, depth + 1, ans);
    }
  } else {
    if (T[v].l != NIL) {
      if (sy <= y) find(T[v].l, sx, tx, sy, ty, depth + 1, ans);
    }
    if (T[v].r != NIL) {
      if (y <= ty) find(T[v].r, sx, tx, sy, ty, depth + 1, ans);
    }
  }
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N;
  for (int i = 0; i < N; i++) {
    int x, y;
    cin >> x >> y;
    P[i] = {i, x, y};
    T[i].l = T[i].r = T[i].p = NIL;
  }
  np = 0;
  int root = makeKDTree(0, N, 0);

  int Q;
  cin >> Q;
  for (int i = 0; i < Q; i++) {
    int sx, tx, sy, ty;
    cin >> sx >> tx >> sy >> ty;
    vector<Point> ans;
    find(root, sx, tx, sy, ty, 0, ans);
    sort(ans.begin(), ans.end());
    for (auto j : ans) j.print();
    printf("\n");
  }

  return 0;
}


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

vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back({a, ex});
    }

    // 最後に残った数について
    if (N != 1) res.push_back({N, 1});
    return res;
}

int main() {
    long long N;
    cin >> N;
    const auto &res = prime_factorize(N);
    int ans = 0;
    for (auto p : res) {
        // for (int i = 0; i < p.second; ++i) cout << " " << p.first;
      int cnt = 1;
      int m = p.second;
      while(m>0){
        if(m>=cnt){
          m-=cnt;
          ans++;
          cnt++;
        }
        else break;
      }     
    }
    cout << ans << endl; 
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define ll long long 
#define pb push_back
#define ff first
#define ss second
#define setbits(x)          __builtin_popcountll(x)
#define lp(a,n) for(ll i=a; i<n; i++)
#define lpi(a,n) for(int i=a; i<n; i++)
#define w(t) int t; cin>>t; while(t--)
#define vi vector<int> 
#define vll vector<ll>
#define pll pair<ll, ll>
#define pii pair<int, int>
#define inf 1e9
#define PI 3.141592653589793238
const int  mod =1e9 + 7;
using namespace std;
ll gcd(ll a,ll b){
    if(a==0)return b;
    return gcd(b%a,a);
}
ll lcm(ll a, ll b){
    return (a*b)/gcd(a,b);
}
void FIO(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("inputPrayag.txt", "r", stdin);
    freopen("outputPrayag.txt", "w", stdout);
    #endif
}
ll power(ll x, ll y) 
{ 
    ll res = 1;     
    while (y > 0) 
    { 
        if (y & 1) 
            res = res*x; 
   
        y = y>>1;
        x = x*x;  
    } 
    return res; 
}

signed main(){
 //FIO();
      long double a,b,h,m;
      cin>>a>>b>>h>>m;
      int tot=h*60+m;
      long double x=tot%(12*60);
      x*=(360.0)/(12*60);
      long double y=(tot%60);
      y*=(360.0)/(60);
      x*=(PI/180);
      y*=PI/180;
      x=abs(x-y);
      long double ans=sqrt(a*a+b*b-2*a*b*cos(x));
      cout<<fixed<<setprecision(12)<<ans;

}


Measured memory_bytes: 4104
#include <bits/stdc++.h>
using namespace std;
int A,B,C,D,N,M;

int main() {
  ios::sync_with_stdio(false);
  cin >> A >> B;
  int d = max(A,B);
  int c;
  if(d == A) A=A-1;
  else B = B-1;
  int f = max(A,B);
  cout << d+f;


  return 0;
}


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

#define mod 1000000007

#define rep(i, n) for(int i=1; i<n; ++i)

using namespace std;
typedef long long ll;
const long long INF = 1LL << 60;
 
int main(void){
	
	int N;
    cin >> N;

    bool ans = false;

    rep(i, 10){
        if(N % i == 0 && N / i < 10){
            ans = true;
            break;
        }
    }
    if(ans)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    long long int a;
    long long int money;
    long long int year;
    money = 100;
    year = 0;
    cin >> a;
    while(money<a)
    {
        money = money*(101.0/100.0);
        year = year + 1;
        
    }
    cout << year;
    return 0;
}

Measured memory_bytes: 3572
#include<bits/stdc++.h>
#define ll          long long int
#define ld          long double
#define pb          push_back
#define mp          make_pair
#define ff          first
#define se          second
#define endl        '\n'
#define fd(n)       fixed<<setprecision(n)
#define MAX         100000000000001
#define MAXN        200005
#define mod         1000000007
using namespace std;
 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,i,sum=0;
    cin>>n;
    ll a[n+1],b[n+1],c[n+1];
    for(i=1;i<=n;i++){
        cin>>a[i];
    }
    for(i=1;i<=n;i++){
        cin>>b[i];
        sum+=b[i];
    }
    for(i=1;i<n;i++){
        cin>>c[i];
    }
    for(i=1;i<=n-1;i++){
        if(a[i]+1==a[i+1]){
            sum+=c[a[i]];
        }
    }
    cout<<sum;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
    int n,m,k;
    scanf("%d%d",&n,&m);
    int *ar=new int[n*2],*temp=new int[n*2];
    for(int i=0;i<n*2;i++){
        ar[i]=i;
    }
    for(int ix=0;ix<m;ix++){
        scanf("%d",&k);
        if(k==0){
            copy(ar,ar+n*2,temp);
            for(int i=0;i<n*2;i++){
                if(i%2==0) ar[i]=temp[i/2];
                else ar[i]=temp[(i-1)/2+n];
            }
        }else rotate(ar,ar+k,ar+n*2);
    }
    for(int i=0;i<n*2;i++){
        printf("%d\n",ar[i]+1);
    }
}

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

using namespace std;

#define MAX_V 100000
#define INF 1e9
typedef pair<int,int> pii;

struct edge{
  int to,d;
};

int V,E;
int weight[MAX_V];
vector<edge> G[MAX_V];

void dijkstra(int r){
  priority_queue<pii,vector<pii>,greater<pii> > Q;
  Q.push(pii(0,r));
  weight[r] = 0;
  while(!Q.empty()){
    pii p = Q.top(); Q.pop();
    int v = p.second;
    if(weight[v] < p.first){ continue; }
    for(int i = 0 ; i < (int)G[v].size() ; i++){
      edge &e = G[v][i];
      if(weight[v] + e.d < weight[e.to]){
        weight[e.to] = weight[v] + e.d;
        Q.push(pii(weight[e.to],e.to));
      }
    }
  }
}

void init(){
  for(int i = 0 ; i < MAX_V ; i++){
    G[i].clear();
    weight[i] = INF;
  }
}

int main(){
  int r,s,t,d; init();
  cin >> V >> E >> r;
  for(int i = 0 ; i < E ; i++){
    cin >> s >> t >> d;
    G[s].push_back((edge){t,d});
  }
  dijkstra(r);
  for(int i = 0 ; i < V ; i++){
    if(weight[i] == INF){
      cout << "INF" << endl;
    }else{
      cout << weight[i] << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 13068
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

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

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let x: usize = iterator.next().unwrap().parse().unwrap();
    let y: usize = iterator.next().unwrap().parse().unwrap();
    let a: usize = iterator.next().unwrap().parse().unwrap();
    let b: usize = iterator.next().unwrap().parse().unwrap();
    let c: usize = iterator.next().unwrap().parse().unwrap();

    let mut p: Vec<usize> = (0..a)
        .map(|_| iterator.next().unwrap().parse().unwrap())
        .collect();
    let mut q: Vec<usize> = (0..b)
        .map(|_| iterator.next().unwrap().parse().unwrap())
        .collect();
    let r: Vec<usize> = (0..c)
        .map(|_| iterator.next().unwrap().parse().unwrap())
        .collect();

    p.sort();
    p.reverse();
    q.sort();
    q.reverse();

    let mut d: Vec<usize> = Vec::new();
    for i in 0..x {
        d.push(p[i]);
    }
    for i in 0..y {
        d.push(q[i]);
    }
    for i in 0..c {
        d.push(r[i]);
    }

    d.sort();

    let mut ans: usize = 0;
    for _ in 0..x + y {
        ans += d.pop().unwrap();
    }
    return ans.to_string();
}


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

using namespace std;

using ll = long long;
using ld = long double;
using D = double;
using uint = unsigned int;

#ifdef WIN32
    #define LLD "%I64d"
#else
    #define LLD "%lld"
#endif

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second

char s[20];

int main()
{
	scanf("%s", s);
	for (int i = 0; i < 4; i++) printf("%c", s[i]);
	printf(" ");
	for (int i = 4; i < 12; i++) printf("%c", s[i]);
	printf("\n");
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N,M;
  cin >> N >> M;
  vector<int>a(N);
  vector<int>b(N);
  for (int i = 0; i < N; i++) {
    cin >> a.at(i) >> b.at(i);
  }
  vector<int>c(M);
  vector<int>d(M);
  for (int i = 0; i < M; i++) {
    cin >> c.at(i) >> d.at(i);
  }
  
  vector<int>A(M);
  for (int j = 0; j < N; j++) {
    int MIN = 1000000000; 
    int B = 1;
    for (int i = 0; i < M; i++) {
      A.at(i) = abs(a.at(j)-c.at(i)) + abs(b.at(j)-d.at(i));
      if (A.at(i) < MIN){
        MIN = A.at(i);
        B = i+1;
      }
    }
    cout << B << endl;
  }
}
    
  

Measured memory_bytes: 3588