akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    int N;
    cin >> N;
    ll A=1,B=1,C=1;
    rep(i,N){
        A*=10;
        A%=MOD;
        B*=9;
        B%=MOD;
        C*=8;
        C%=MOD;
    }
    ll ans = (A + MOD - 2*B%MOD +C)%MOD;
    cout << ans << endl;
    return 0;
}

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

int main() {
  int N, A, B, C, D;
  cin >> N;
  D = N % 10;
  C = (N % 100 - D) / 10;
  B = (N % 1000 - C * 10 - D) / 100;
  A = N / 1000;
  if(A+B+C+D == 7) {
    cout << A;
    cout << '+';
    cout << B;
    cout << '+';
    cout << C;
    cout << '+';
    cout << D;
    cout << "=7";
  }
  else if(A+B+C-D == 7) {
    cout << A;
    cout << '+';
    cout << B;
    cout << '+';
    cout << C;
    cout << '-';
    cout << D;
    cout << "=7";
  }
  else if(A+B-C+D == 7) {
    cout << A;
    cout << '+';
    cout << B;
    cout << '-';
    cout << C;
    cout << '+';
    cout << D;
    cout << "=7";
  }
  else if(A-B+C+D == 7) {
    cout << A;
    cout << '-';
    cout << B;
    cout << '+';
    cout << C;
    cout << '+';
    cout << D;
    cout << "=7";
  }
  else if(A+B-C-D == 7) {
    cout << A;
    cout << '+';
    cout << B;
    cout << '-';
    cout << C;
    cout << '-';
    cout << D;
    cout << "=7";
  }
  else if(A-B+C-D == 7) {
    cout << A;
    cout << '-';
    cout << B;
    cout << '+';
    cout << C;
    cout << '-';
    cout << D;
    cout << "=7";
  }
  else if(A-B-C+D == 7) {
    cout << A;
    cout << '-';
    cout << B;
    cout << '-';
    cout << C;
    cout << '+';
    cout << D;
    cout << "=7";
  }
  else if(A-B-C-D == 7) {
    cout << A;
    cout << '-';
    cout << B;
    cout << '-';
    cout << C;
    cout << '-';
    cout << D;
    cout << "=7";
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
int main(){
  int n ,a ,b;
  cin >> n >> a >> b;
  int Min = 0, Max = 0;
  int ans = a + b;
  Max = min(a,b);
  if(n > ans){
    Min = 0;
  } else {
    Min = abs(n - ans);
  }
  cout << Max <<" "<< Min  << endl;
  return 0;
}

Measured memory_bytes: 256
#![allow(unused_macros)]

// cf. [Rustで競技プログラミングの入力をスッキリ記述するマクロ - Qiita](https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8)
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)*}
    };
}

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

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, usize1) => {
        read_value!($next, usize) - 1
    };

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

fn main() {
    input! {
        N: usize,
        C: usize,
        D: [[usize; C]; C],
        c: [[usize1; N]; N],
    }
    let mut c_cnt = vec![vec![0; C]; 3];
    use std::cmp::min;
    let mut ans = 1 << 60;
    for i in 0..N {
        for j in 0..N {
            let r = (i + 1 + j + 1) % 3;
            c_cnt[r][c[i][j]] += 1;
        }
    }

    for x in 0..C {
        for y in 0..C {
            for z in 0..C {
                if x == y || y == z || z == x {
                    continue;
                }
                let mut diff = 0;
                for cc in 0..C {
                    diff += c_cnt[0][cc] * D[cc][x];
                    diff += c_cnt[1][cc] * D[cc][y];
                    diff += c_cnt[2][cc] * D[cc][z];
                }
                ans = min(ans, diff);
            }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 6396
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using TP = tuple<ll,ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
}
ll n;
void solve(ll a,ll b,ll c,vector<string> s){
  vector<char> ans(n,' ');
  vector<ll> le_b(n),le_c(n);
  map<char,ll> mp;
  mp['A'] = a;
  mp['B'] = b;
  mp['C'] = c;
  for(int i=0;i<n;i++){
  //  cout << mp['A']<<" "<<mp['B']<<" "<<mp['C']<<endl;
    if(mp['A']+mp['B']+mp['C']==0){
      cout << "No"<<endl;
      return;
    }else if(mp['A']+mp['B']+mp['C']==1){
      char ch;
      if(mp['A']) ch = 'A';
      else if(mp['B']) ch = 'B';
      else ch = 'C';
      if(s[i].find(ch)==string::npos){
        cout <<"No\n";
        return;
      }else{
        mp[ch]--;
        if(ch==s[i][0]){
          ans[i] = s[i][1];
          mp[s[i][1]]++;
        }
        else{
          ans[i] = s[i][0];
          mp[s[i][0]]++;
        }
      }
    }else{
      if(mp[s[i][0]]+mp[s[i][1]]==0){
        cout <<"No\n";
        return;
      }
      if(mp[s[i][0]]==0){
        mp[s[i][0]]++;
        mp[s[i][1]]--;
        ans[i] = s[i][0];
      }else if(mp[s[i][1]]==0){
        mp[s[i][1]]++;
        mp[s[i][0]]--;
        ans[i] = s[i][1];
      }else if(i!=n-1 && s[i] != s[i+1]){
        if(s[i+1].find(s[i][0])!=string::npos){
          mp[s[i][0]]++;
          mp[s[i][1]]--;
          ans[i] = s[i][0];
        }else{
          mp[s[i][1]]++;
          mp[s[i][0]]--;
          ans[i] = s[i][1];
        }
      }else{
        mp[s[i][0]]++;
        mp[s[i][1]]--;
        ans[i] = s[i][0];
      }
    }
  }
  cout <<"Yes"<<endl;
  for(int i=0;i<n;i++){
    cout << ans[i]<<endl;
  }
}
signed main(){
  init_io();
  ll a,b,c;
  cin >> n >> a >> b >> c;
  vector<string> s(n);
  for(int i=0;i<n;i++){
    cin >> s[i];
  }
  solve(a,b,c,s);
}


Measured memory_bytes: 11152
#include<stdio.h>
#define N 100

void draw(int, int *);

int main(){

  int n, a[N], v;
  int i, j;

  scanf("%d",&n);

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

  for(i = 1; i < n; i++){
 
    v = a[i];
    j = i - 1;
    //vをa[j]と比べて小ければaを右にシフトする
    while(j >= 0 && a[j] > v){
      a[j + 1] = a[j];
      j--;

    }

    a[j + 1] = v;

    draw(n, a);

  }

  return 0;
}

void draw(int n, int *a){

  int i;

  for(i = 0; i < n; i++){
    printf("%d",a[i]);

    if(i != n - 1) printf(" ");

  }
 
  printf("\n");
  
}

Measured memory_bytes: 604
d=gets.to_i
c=gets.split.map(&:to_i)
s=[]
d.times do
  s << gets.split.map(&:to_i)
end
l=[0]*26
(d-1).times do |i|
  m=0
  mi=0
  26.times do |j|
    l[j]+=1
  end
  26.times do |j|
    cs1=c[j]*l[j]+s[i][j]
    26.times do |k|
      cs2=c[k]*l[k]+s[i+1][k]
      if cs1+cs2>m
        m=cs1+cs2
        mi=j
      end
    end
  end
  puts mi+1
  l[mi]=0
end
m=0
mi=0
26.times do |j|
  l[j]+=1
end
26.times do |j|
  cs=c[j]*l[j]+s[d-1][j]
  if cs>m
    m=cs
    mi=j
  end
end
puts mi+1


Measured memory_bytes: 14392
N = int(input())

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

def check(S):
    if S ==1:
      return 1
    elif S == 2:
      return 1
    elif S == 3:
      return 2
    else:
      for i in range(S):
        if i <= S:
          S -= i
        else:
          return i-1

if N != 1:
  result = factorization(N) 

  a = 0
  for r in result:
    b = check(r[1])
    a += b
  print(a)

else:
  print(0)

Measured memory_bytes: 9496
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
using P = pair<int,int>;

struct edge {
  ll to, cost;
};

vector<edge> graph[100010];

int main()
{
  ll N;
  cin >> N;
  vector<vector<ll>> A(N-1,vector<ll>(3));
  REP(i, N-1){
    REP(j, 3){
      cin >> A.at(i).at(j);
    }
    A.at(i).at(0)--;
    A.at(i).at(1)--;
    edge e = {A.at(i).at(1),A.at(i).at(2)};
    graph[A.at(i).at(0)].push_back(e);
    edge e2 = {A.at(i).at(0),A.at(i).at(2)};
    graph[A.at(i).at(1)].push_back(e2);
  }

  vector<ll> ans(N,0);
  ans[0]=0;
  queue<ll> que;
  vector<ll> dist(N,-1);
  que.push(0);
  dist[0]=0;
  while(!que.empty()){
    ll v = que.front();
    que.pop();
    for(auto ne:graph[v]){
      ll nv = ne.to;
      if(dist[nv]!=-1) continue;
      dist[nv]=dist[v]+ne.cost;
      if(dist[nv]%2==0){
        ans[nv]=0;
      }else{
        ans[nv]=1;
      }
      que.push(nv);
    }
  }

  REP(i,N){
    cout << ans[i] << endl;
  }
}

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

int main(){
    int N;
    cin >> N;
    vector<int> a(N);
    for(int i=0; i<N; i++){
        cin >> a[i];
    }
    int min=1000000;
    for(int i=-100; i<=100; i++){
        int ans = 0;
        for(int j=0; j<N; j++){
            ans+=pow(i - a[j],2);
        }
        if(ans<min){
            min = ans;
        }
    }
    cout << min;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
//#include <stdio.h>
//#include <stack>
//#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
//#include <fstream>
//#include <list>
//#include <iomanip>
#include <stdlib.h>
#include <cctype>

using namespace std;

#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define ssort(z) sort(z.begin(),z.end())
#define rsort(z) sort(z.rbegin(),z.rend())
#define eerase(z) z.erase(unique(z.begin(),z.end()),z.end())
#define ccnt(z,w) count(z.begin(),z.end(),w)


void printVec(std::vector<int> & vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec2(std::vector<Int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

Int gcd(Int a, Int b) {
	return b != 0 ? gcd(b, a % b) : a;
}
Int lcm(Int a, Int b) {
	return a / gcd(a, b) *b;
	//a*bは64bit integer overflow
}

bool comp(const string a, const string b) {
	return a.length() < b.length();
}

bool integer(double num) {
	return floor(num) == num;
}

string gen(int num) {
	string str = "";
	for (int i = 0; i < num; i++) str += ".";
	return str;
}
Int fact(int num) {
	if (num == 0) return 1;
	else return num * fact(num - 1);
}


int main() {
	vector<vector<string>> s(3, vector<string>(3));
	string h;
	for (int i = 0; i < 3; i++) {
		cin >> h;
		for (int j = 0; j < 3; j++) {
			s[i][j]=h[j];
		}
	}
	cout << s[0][0] << s[1][1] << s[2][2];


	cout << endl;
	return 0;
}

Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
x = int(input())

cnt = 0
for an in range(a+1):
  for bn in range(b+1):
    for cn in range(c+1):
      if x == 500*an + 100*bn + 50*cn:
        cnt += 1
print(cnt)

Measured memory_bytes: 9068
import java.util.*;
public class Main {
    public static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) throws Exception {
    	int i, j, k;
    	
    	double a = sc.nextDouble();
    	double b = sc.nextDouble();
    	double c = sc.nextDouble();
    	
    	double S = a * b * Math.sin(Math.toRadians(c)) / 2;
    	double L = a + b + Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(Math.toRadians(c)));
    	double h = 2 * S / a;
    	
    	System.out.printf("%f\n%f\n%f", S, L, h);
    }
}


Measured memory_bytes: 28264
S = input()

ren = 0

if S[1] == "R":
    if S[0] == "R" and S[2] == "R":
        ren = 3
    elif S[0] == "R" or S[2] == "R":
        ren = 2
    else:
        ren = 1
elif S[0] == "R" or S[2] == "R":
    ren = 1
    
print(ren)


Measured memory_bytes: 9112
#include <cstdio>
#include <cstdint>
#include <algorithm>

int main() {
  intmax_t n;
  scanf("%jd", &n);

  intmax_t res = n;
  for (intmax_t i = 1; i*i <= n; ++i) {
    if (n % i != 0) continue;
    intmax_t j = n / i;
    res = std::min(res, i+j-2);
  }
  printf("%jd\n", res);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007,mod2 = 998244353;

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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL<<60;
ll gcd(ll a,ll b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    ll tmp = max(a*c,b*d);
    tmp = max(tmp,a*d);
    tmp = max(tmp,b*c);
    cout << tmp  << endl;
    return 0;
}

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

ll cal1(ll m){
    ll cnt = 0;
    for(ll i = 2;i * i <= m;i++){
        if(m % i == 0){
            cnt++; 
            if(i != m / i){
                cnt++;
            }
        }
    }
    if(m > 1)
        cnt++;
    return cnt;
}

ll cal2(ll m){
    ll cnt = 0;
    for(ll i = 2;i * i <= m;i++){
        if(m % i == 0){
            ll tmp = m;
            while(tmp % i == 0){
                tmp /= i;
            }
            if(tmp % i == 1){
                cnt++;
            }
        }
    }
    return cnt;
}

int main(){
    cin >> n;
    cout << cal1(n - 1) + cal2(n) + 1 << endl;
    return 0;
}


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

int main(){
	ll n;
	cin>>n;
	ll a[n];
	for(ll i=0; i<n; i++)
		cin>>a[i];
	ll gcd=a[0];
	for(ll i=0; i<n; i++){
		ll x=max(gcd,a[i]);
		ll y=min(gcd,a[i]);
		while(y!=0){
			ll temp=y;
			y=x%y;
			x=temp;
		}
		gcd=x;
		if(gcd==1)
			break;
	}
	cout<<gcd<<endl;


}

Measured memory_bytes: 1024
#include <stdio.h>
#define MAX 100000

int A[MAX], n;

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

int main(void) {
  int i, q;

  scanf("%d", &n);
  for(i=0; i<n; i++) scanf("%d",&A[i]);
  q = partition(0,n-1);

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

  return 0;
}

Measured memory_bytes: 2116
str = input()
num = int(str)
if num % 2 == 0:
  print('-1');
else:
  i = 1
  j = 7
  while j % num != 0 and i <= num:
    j = (j % num) * 10 + 7
    i += 1
  if i > num:
    print('-1');
  else:
    print(i);
  


Measured memory_bytes: 9160
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi acos(-1.0)

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    ll ans;
    ll a_sum = 0;
    VL v;
    cin >> n;
    REP(i, n){
        ll a;
        cin >> a;
        a_sum += a;
        if(i == n - 1) break;
        v.push_back(a_sum);
    }

    ans = abs(a_sum - 2 * v[0]);
    REP(i, v.size()){
        ans = min(abs(a_sum - 2 * v[i]), ans);
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 2420
#include <iostream>

#define MAX(a, b) (a > b ? a : b)
#define MIN(a, b) (a < b ? a : b)

constexpr auto NMAX = (int)2e5 + 20;
constexpr auto INF = 2000000000;
using namespace std;

typedef unsigned long long ull;

int n, m;
int a;

int main()
{
	cin >> n >> m;
	while (m--) 
	{
		cin >> a;
		n -= a;
	}
	cout << (n >= 0 ? n : -1) << '\n';
	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define pb push_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
typedef long long ll;
typedef multiset<ll> S;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll,vector<ll>,greater<ll>> SPQ;
using vi=vector<ll>;
using vvi=vector<vector<ll>>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
bool chmin(auto &a,auto b){if(a>b){a=b;return true;}return false;}
bool chmax(auto &a,auto b){if(a<b){a=b;return true;}return false;}

int main(){
    int n;cin>>n;
   vi v(n);
  rep(i,n)cin>>v[i];
  sort(all(v));
  ll a=0,b=0;
  rep(i,n){
    if(v[i]==v[0])a++;
    else if(v[i]==v[0]+1)b++;
    else {
      cout<<"No"<<endl;
      return 0;
    }
  }
  int m=-1;
  if(v[0]!=v[n-1])m++;
    if((v[0]+1-a)*2<=b&&m<v[0]+1-a){
      cout<<"Yes"<<endl;
      return 0;
    }
    if(v[0]==v[n-1]){
      if((v[0]-b)*2<=a&&m<v[0]-b){
        cout<<"Yes"<<endl;
        return 0;
      }
      }
      cout<<"No"<<endl;
}


Measured memory_bytes: 1024
#include <vector>
#include <iostream>
using namespace std;
const int mod = 1000000007;
int main() {
	int N, M;
	cin >> N >> M;
	vector<bool> ok(N + 1, true);
	for (int i = 0; i < M; ++i) {
		int x;
		cin >> x;
		ok[x] = false;
	}
	vector<int> dp(N + 1);
	dp[0] = 1;
	for (int i = 1; i <= N; ++i) {
		if (ok[i - 1]) dp[i] += dp[i - 1];
		if (i >= 2 && ok[i - 2]) dp[i] += dp[i - 2];
		if (dp[i] >= mod) dp[i] -= mod;
	}
	cout << dp[N] << endl;
	return 0;
}

Measured memory_bytes: 640
s=input()

if len(s)==1:
  if s[0]=="L":
    print("No")
    exit()
  else:
    print("Yes")
    exit()
if len(s)%2==1:
  if s[len(s)-1]=="L":
    print("No")
    exit()
for i in range(len(s)//2):
  if s[2*i]=="L":
    print("No")
    exit()
  elif s[2*i+1]=="R":
    print("No")
    exit()
print("Yes")

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

using ll = long long;
// #define int long long

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, r, n) for(int i = (n); i >= (r); --i) // from n to r
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
/***** MAIN *****/
signed main() {
  int a, b;
  scanf("%d%d", &a, &b);
  int total = a + b;
  if(total % 2 != 0) cout << "IMPOSSIBLE";
  else {
    cout << total / 2;
  }
  cout << "\n";
  return 0;
}
/***** MAIN *****/


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <string>
#include <cmath>
#include <map>
#include <cstring>

#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, init, n) for(int i = init; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define Cout(obj) cout << obj << endl
#define Size(obj) (int)(obj).size()
#define fcout cout << fixed << setprecision(10)
#define fi first
#define se second

using namespace std;
using ll = long long int;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using edge = struct
{
    int to, cost;
};

const int MOD = 1e9 + 7;
const int iINF = 1e9;
const long long int llINF = 1e18;
const double PI = acos(-1.0);

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

const int MaxV = 10000;
int V;
vector<int> graph[MaxV];
int match[MaxV];
bool used[MaxV];

void addEdge(int u, int v)
{
    graph[u].push_back(v);
    graph[v].push_back(u);
}

bool dfs(int v)
{
    used[v] = true;
    
    for(auto e : graph[v])
    {
        int u = e, w = match[u];

        if(w < 0 || !used[w] && dfs(w))
        {
            match[v] = u;
            match[u] = v;
            return true;
        }
    }

    return false;
}

int bipartiteMatcing()
{
    int res = 0;

    memset(match, -1, sizeof(match));

    REP(v, V)
    {
        if(match[v] < 0)
        {
            memset(used, 0, sizeof(used));

            if(dfs(v))
            {
                res++;
            }
        }
    }

    return res;
}

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

    int X, Y, E;
    cin >> X >> Y >> E;
    
    V = X + Y;

    REP(i, E)
    {
        int x, y;
        cin >> x >> y;

        addEdge(x, y + X);
    }

    Cout(bipartiteMatcing());

    return 0;
}


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

int main(){
    int a, b, t;
   cin >> a >> b >> t;

    cout <<  (t / a) * b << endl;
}


Measured memory_bytes: 256
/*我是萌新*/
#include<iostream>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include <iomanip> 
typedef long long LL;
const int mod = 1000000009;
using namespace std;
int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    LL n, r;
    while (cin >> n >> r)
    {
        LL ans = 0;
        while (n)
        {
            ans++;
            n /= r;
        }
        cout << ans << '\n';
    }
}



Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int AB = sc.nextInt();
        int BC = sc.nextInt();
        int CA = sc.nextInt();
        int min = AB;
        int max = AB;
        int ans = 1;

        min = Math.min(AB, BC);
        max = Math.max(AB, BC);

        ans *= min;

        min = Math.min(max, CA);

        ans *= min;
        System.out.println(ans/2);
    }
}

Measured memory_bytes: 23892
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#define ll long long

using namespace std;


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

   return 0;
}


Measured memory_bytes: 256
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}

void main()
{
  int x; readV(x);

  auto c = 0;
  foreach (i; 1..10^^5) {
    c += i;
    if (c >= x) {
      writeln(i);
      return;
    }
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(long long i=0;i<int(N);++i)
using ll = long long;
// const int INF = 2147483647;
const ll MOD = 1e9+7;
const ll INF = 1000000000000000000LL;
 
 
 int main() {
	 ll n;
	 cin >> n;
	 vector<int> a(n);
	 rep(i,n) cin >> a[i];
	 ll res=0;
	 for(int i=1;i<n;i++){
		 if(a[i-1]>a[i]){
			 res+=a[i-1]-a[i];
			 a[i] += a[i-1]-a[i];
		 }
	 }
	 cout << res << endl;
	 return 0;
 }

Measured memory_bytes: 3988
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<deque>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;


int main(void){
	ll K,c[100010];
	cin>>K;
	rep(i,K){
		c[i]=1e9;
	}
	deque<ll> Q;
	Q.push_front(1);
	c[1]=1;
	while(!Q.empty()){
		ll p = Q.front();Q.pop_front();
		if(c[(p+1)%K]>c[p]+1){
			c[(p+1)%K]=c[p]+1;
			Q.push_back( (p+1)%K );
		}
		if(c[(p*10)%K]>c[p]){
			c[(p*10)%K]=c[p];
			Q.push_front( (p*10)%K );
		}
	}
	printf("%lld\n",c[0]);
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define pf printf
#define sc(x) scanf("%d",&x);
#define scs(x) scanf("%s",x);
#define scl(x) scanf("%lld",&x);
#define rep(i,s,e) for(int i=s; i<=e; ++i)
#define dep(i,s,e) for(int i=s; i>=e; --i)
typedef long long ll;
using namespace std;
int a[33]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int main(){
	int k;
	sc(k);
	pf("%d\n",a[k-1]); 
}

Measured memory_bytes: 256
#include <cstdint>
#include <cstdio>
#include <algorithm>
#include <string>
#include <utility>
#include <vector>

int main() {
  char buf[200001];
  scanf("%s", buf);
  std::string s = buf;

  for (size_t i = s.length(); i--;) {
    if (s[i] != '?') continue;
    s[i] = 'D';
  }

  puts(s.data());
}


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

int main(){
  int n;
  string s;
  int ans = 1;
  
  cin >> n;
  cin >> s;
  
  for(int i = 0; i < n-1; i++){
    if(s[i]!=s[i+1])ans++;
  }
  
  cout << ans;
  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    ll A[100010];
    cin >> N;
    rep(i,0,N) cin >> A[i];
    ll sum = 0;
    rep(i,0,N) sum += abs(A[i]);
    bool ok = true;
    rep(i,0,N){
        if(A[i] < 0) ok = false;
    }
    if(ok){
        print(sum);
        return 0;
    }
    ll B[100010];
    rep(i,0,N) B[i] = A[i];
    rep(i,0,N-1){
        if(B[i] < 0){
            B[i] *= -1;
            B[i+1] *= -1;
        }
    }
    if(B[N-1] > 0){
        print(sum);
    }else{
        ll v = INF;
        rep(i,0,N){
            v = min(v, (ll)abs(A[i]));
        }
        print(sum - 2*v);
    }

}

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

const int N = 1e6+6;
int n, in[N], nxt[N][2], b[1001];

inline int idx(int a, int b){
	if(a > b) swap(a,b);
	return a*n + b;
}

int main(){
	memset(nxt, -1, sizeof(nxt));
	memset(in, 0, sizeof(in));
	scanf("%d", &n);
	for(int i=0;i<n;++i){
		for(int j=1;j<n;++j){
			scanf("%d", b+j);
			--b[j];
		}
		for(int j=1;j<n-1;++j){
			int m = idx(i, b[j+1]);
			++ in[m];
			if(i < b[j]) nxt[i*n+b[j]][0] = m;
			else nxt[b[j]*n + i][1] = m;
		}
		for(int j=0;j<=i;++j) in[i*n+j]=-1;
	}
	int cnt = 0, ans = 0;
	queue<int> q;
	for(int i=n*n-1;~i;--i) if(in[i]==0) q.push(i);
	
	while(q.size()){
		++ans;
		int m = q.size();
		cnt += m;
		while(m--){
			int i = q.front(); q.pop();
			if(~nxt[i][0] && 0 == --in[nxt[i][0]]) q.push(nxt[i][0]);
			if(~nxt[i][1] && 0 == --in[nxt[i][1]]) q.push(nxt[i][1]);
		}
	}
	if(cnt < n*(n-1)/2) printf("-1\n");
	else printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 12032
object Main extends App {
  @scala.annotation.tailrec
  def gcd(p: Int, q: Int): Int = if (p % q == 0) q else gcd(q, p % q)
  val sc = new java.util.Scanner(System.in)
  val range = 1 to sc.nextInt()
  println((for (i <- range; j <- range; k <- range) yield gcd(gcd(i, j), k)).sum)
}


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

const ll N = 2019;
vector<ll> cnt(N);

int main(){
  string S;
  cin >> S;
  
  reverse(S.begin(),S.end());
  
  ll rem = 0;
  ll ans = 0;
  ll x = 1;
  rep(i,S.size()){
    cnt.at(rem)++;
    rem += (S.at(i) - '0')*x;
    rem %= N;
    ans += cnt.at(rem);
    x = x * 10 % N;
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 3784
/*
   AOJ - ITP1_9_c
Date: 20181009
Author: Mikoron * ♡mikoiwate_351♡
*/

#define STRMAX 101

#include<stdio.h>
#include<stdlib.h>
#include<string.h>

typedef struct {
        char words[STRMAX];
        short score;
        short words_len;
} game_t;

int main(void) {
        short n, i, j, len;
        game_t taro, hanako;

        taro.score = hanako.score = 0;

        scanf("%hd", &n);
        for(i = 0; i < n; i++) {
                scanf("%s %s", taro.words, hanako.words);
                if(!(strcmp(taro.words, hanako.words))) {
                        taro.score++;
                        hanako.score++;
                        continue;
                }

                taro.words_len = (short)strlen(taro.words);
                hanako.words_len = (short)strlen(hanako.words);

                if(taro.words_len >= hanako.words_len) len = taro.words_len;
                else len = hanako.words_len;

                for(j = 0; j < len; j++) {
                        if(taro.words[j] == hanako.words[j]) continue;
                        else if(taro.words[j] > hanako.words[j]) {
                                taro.score += 3;
                                break;
                        }
                        else if(taro.words[j] < hanako.words[j]) {
                                hanako.score += 3;
                                break;
                        }
                }
        }
        printf("%hd %hd\n", taro.score, hanako.score);

        return 0;
}



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

int main() {
    int n; cin >> n;
    int min_num = 1e9;
    int max_num = -1;
    for (int i = 0; i < n; i++) {
        int tmp; cin >> tmp;
        min_num = min(min_num, tmp);
        max_num = max(max_num, tmp);
    }

    cout << max_num - min_num << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int k=sc.nextInt();
		long ans=1;
		for(int i=0;i<n;i++){
			if(i==0)ans*=k;
			else ans*=k-1;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 21844
from collections import defaultdict,deque
def hash(x,y):
    x,y =min(x,y),max(x,y)
    return x*(N+1)+y
s = set()
N = int(input())
edge = [[] for _ in range(N*N+N)]
ind = [0]*(N*N+N)
for i in range(1,N+1):
    A = list(map(int,input().split()))
    s.add(hash(i,A[0]))
    for j in range(N-2):
            edge[hash(i,A[j])].append(hash(i,A[j+1]))
            ind[hash(i,A[j+1])] += 1
d = deque()
nd = deque()
for hash in s:
    if ind[hash] == 0:
        d.append(hash)
ans = 0
finished = 0
while d:
    while d:
        hash = d.popleft()
        finished += 1
        for nhash in edge[hash]:
            ind[nhash] -= 1
            if ind[nhash] == 0:
                nd.append(nhash)
    d = nd
    nd = deque()
    ans += 1
if finished == N*(N-1)//2:
    print(ans)
else:
    print(-1)

Measured memory_bytes: 165968
#include <iostream>
#include <utility>
#include <algorithm>
using namespace std;
#define rep2(x,from,to) for(int x=(from);x<(to);++(x))
#define rep(x,to) rep2(x,0,to)
#define pint pair<int, int>
int main(){
	int n, m;
	while(cin >> n, n) {
		pint p[200];
		rep(i,n) {
			cin >> p[i].first >> p[i].second;
		}
		cin >> m;
		rep(i,m) {
			cin >> p[n+i].first >> p[n+i].second;
		}
		sort(p,p+m+n);
		int dp[200], ret = 0;
		rep(i,200) dp[i] = 1;
		rep2(i,1,m+n) {
			rep(j,i) {
				if(p[j].first < p[i].first && p[j].second < p[i].second) {
					dp[i] = max(dp[i], dp[j]+1);
				}
			}
			ret = max(ret,dp[i]);
		}
		cout << ret << endl;
	}
	return 0;
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
using namespace std;
int dp[100000][2];

int Solve(int chance, int rem, int n, int stn[]){

	int otherPlayer = (chance == 0)?1:0;
	
	if(rem <= 0){return otherPlayer;}

	if(dp[rem][chance] != -1) return dp[rem][chance];

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

		if(rem-stn[i] < 0) continue;

		int winner = Solve(otherPlayer, rem-stn[i], n, stn);

		// If winner is current player, return winner
		if(winner == chance) return dp[rem][chance] = chance;
	}
	return dp[rem][chance] = otherPlayer;
}

int main(){
	int n,k;
	cin >> n >> k;
	int stn[n];
	for(int i=0 ; i<n ; i++){
		cin >> stn[i];
	}

	for(int i=0 ; i<=k ; i++){
		dp[i][0] = -1;
		dp[i][1] = -1;
	}

	int winner = Solve(0, k, n, stn);

	if(winner == 0){
		cout << "First\n";
	}
	else{
		cout << "Second\n";
	}
	return 0;
}


Measured memory_bytes: 10368
#include<bits/stdc++.h>
#define ll long long
#define MOD 1000000007LL
#define N 10
#define endl '\n'

using namespace std;

char matrix[N][N];
int cpy[N][N], n, m, k, ans, tot, black;


int main() {
    ios_base::sync_with_stdio(0);
    cin >> n >> m >> k;

    for(int i=0; i < n; ++i) {
        for(int j=0; j < m; ++j) {
            cin >> matrix[i][j];
            tot += (matrix[i][j] == '#');
        }
    }
    for(int i=0; i < (1 << n); ++i) {
        for(int j=0; j < (1 << m); ++j) {

            black = 0;

            for(int u=0; u < n; ++u) {
                for(int v=0; v < m; ++v) {
                    if((((1 << u) & i) || ((1 << v) & j))) {
                        black += (matrix[u][v] == '#');
                    }
                }
            }

            if(tot - black == k) {
                ans++;
            }
        }
    }
    cout << ans << endl;


    return 0;

}


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

#define SIZE_OF_ARRAY(array) sizeof(array)/sizeof(array[0])

int main() {
    long long X;
    cin >> X;
    long long year = 0;
    for(long long i = 100; i < X;){
        i += i * 0.01;
        year++;
    }
    cout << year;
}

Measured memory_bytes: 3636
n, m = map(int, input().split())
ks = [list(map(int, input().split())) for _ in range(m)]
p = list(map(int, input().split()))
count = 0


def dfs(i, switch):
    if i == n:
        # check
        light_on_flag = True
        for a in range(m):
            switch_on_count = 0
            for b in range(ks[a][0]):
                if switch[ks[a][b + 1] - 1]:
                    switch_on_count += 1
            if not switch_on_count % 2 == p[a]:
                light_on_flag = False
                break
        if light_on_flag:
            global count
            count += 1
        return

    switch[i] = True
    dfs(i + 1, switch)
    switch[i] = False
    dfs(i + 1, switch)


switch = [False] * n
dfs(0, switch)
print(count)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define in insert
#define PI 3.1415926535897932384626433832795
#define F first
#define S second
#define aLL(str) (str).begin(), (str).end()
#define IOS                  \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0)
#define ll long long
#define ld long double
#define lcm(a, b) (a * b) / __gcd(a, b)
#define flu(i, a, b) for (ll i = a; i < b; i++)
#define blu(i, a, b) for (ll i = a; i >= b; i--)
#define upper(s) transform(s.begin(), s.end(), s.begin(), ::toupper)
#define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
#define Unique(X) (X).erase(unique(all(X)), (X).end())
#define all(v) v.begin(), v.end()
typedef vector<ll> vl;
typedef map<ll, ll> ml;
typedef vector<string> vs;
typedef vector<vector<int>> vvi;
char e = '\n';

ll MOD = 1e9 + 7;

ll i, j, le;

int sv(int x)
{
    int n = 200000;
    bool prime[n + 1];
    memset(prime, true, sizeof(prime));

    for (int p = 2; p * p <= n; p++)
    {
       
        if (prime[p] == true)
        {
            for (int i = p * p; i <= n; i += p)
                prime[i] = false;
        }
    }
    if (prime[x])
        return 1;
    else
        return 0;
}

int main()
{
    IOS;
    int t;
    //cin >> t;
 t=1;
    while (t--)
    {
        string s;
        cin>>s;
        ll sum=0;
        flu(i,0,s.size())
        sum+= s[i]-48;

        if(sum%9==0)cout<<"Yes"<<e;
        else cout<<"No"<<e;
    }
    return 0;
}

Measured memory_bytes: 3728
from sys import stdin

def main():
    from collections import deque
    input = stdin.readline
    n, q = map(int, input().split())
    a = [[] for _ in range(n)]
    for i in range(n - 1):
        x, y = map(int, input().split())
        a[x - 1].append(y - 1)
        a[y - 1].append(x - 1)
    p = [0] * n
    for i in range(q):
        x, y = map(int, input().split())
        p[x - 1] += y
    c = [0] * n
    c[0] = 1
    que = deque([])
    que.append(0)
    while len(que) > 0:
        e = que.popleft()
        for i in a[e]:
            if c[i] > 0:
                continue
            c[i] = 1
            p[i] += p[e]
            que.append(i)
    for i in range(n):
        print(p[i])
main()

Measured memory_bytes: 91852
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        //var num = ToInt32(ReadLine());
        var ar = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
        WriteLine(Min(ar[1], ar[2]) + " "+Max(0,(ar[1]+ar[2])-ar[0]));
    }
    private const string ALFA = "abcdefghijklmnopqrstuvwxyz";
    private const int MOD = 1000000007;
}


Measured memory_bytes: 11092
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <cstdio>
#include <complex>

using namespace std;
typedef long long ll;
#define loop(i,a,b) for(ll i=(a); i<ll(b); i++)
#define rep(i,b) loop(i,0,b)

typedef vector<int> vi;

int m[256];
string const w = "mcxi";

int f(string const& s){
    int res = 0;
    rep(i, s.size()){
        if (isdigit(s[i])) {
            res += (s[i] - '0')*m[s[i + 1]];
            i++;
        }
        else{
            res += m[s[i]];
        }
    }
    return res;
}

string invf(int n){
    vi v{
        n / 1000, n / 100 % 10, n / 10 % 10, n % 10
    };
    string res;
    rep(i, 4){
        if (v[i] == 0) continue;
        if (v[i] != 1) {
            res.push_back('0'+v[i]);
        }
        res.push_back(w[i]);
    }
    return res;
}

int main(){
    m['m'] = 1000;
    m['c'] = 100;
    m['x'] = 10;
    m['i'] = 1;
    int n;
    while (cin >> n){
        rep(i, n){
            string s, t; cin >> s >> t;
            cout << invf(f(s) + f(t)) << endl;
        }
    }
}
    

Measured memory_bytes: 1208
import math
a, b, h, m = map(int, input().split())
rad_long = (h * 60 + m) / (60) * 2 * math.pi
rad_short = (h * 60 + m) / (12 * 60) * 2 * math.pi

x_long, y_long = b * math.cos(rad_long), b * math.sin(rad_long)
x_short, y_short = a * math.cos(rad_short), a * math.sin(rad_short)

dis = ((x_long - x_short)**2 + (y_long - y_short)**2)**0.5
print(dis)

Measured memory_bytes: 62456
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int M = Integer.parseInt(sc.next());
		sc.close();

		if(N != 0 && M != 0) {
			int answer = N * (N - 1) / 2 + M * (M - 1)/2;
			System.out.println(answer);
		}else if( N == 0) {
			System.out.println(M * (M - 1)/2);
		}else if( M == 0) {
			System.out.println(N * (N - 1)/2);
		}
	}
}

Measured memory_bytes: 21460
#include<cstdio>
#include<cstring>
#include<map>
#include<iostream>
#include<algorithm>
#include<cstdlib>
#include<queue>
#include<string>
#include<cmath>
#define ll long long
using namespace std;
inline int read()
{
	int f=1,x=0;
	char c=getchar();
	while(c>'9'||c<'0'){
		if(c=='-') f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9'){
		x=x*10+c-'0';
		c=getchar();
	}
	return f*x;
}
int n,k;
ll as1,as2;
int main()
{
	n=read(),k=read();
	ll t1=n/k,t2=0;
//	as1=pow(tmp,3);
//	cout<<as1;
	if(!(k&1)&&k/2<=n)
	{
		t2=(n-k/2)/k+1;
	}
	printf("%lld",(ll)pow(t1,3)+(ll)pow(t2,3));
	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {


    public static void main(String args[] ) throws IOException {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        String[] origin = br.readLine().split("");
        String[] serch = br.readLine().split("");
        int plusi = PlusI(serch);

       // System.out.println( SameString(serch) );
        for(int i = 0; i < origin.length; ){
        	 //System.out.println(i);

           if( i + serch.length  <= origin.length && SearchWord(origin , serch, i)){
              System.out.println(i);
              //i++;


            	  i = i + plusi ;

           }else{

        	   i++;

           }



        }


    }


    public static int PlusI(  String[] Serch ){


    	for(int j = 0; j < Serch.length; j++ ){

    	    if( Serch[j].equals(Serch[0]) && 0 < j){
    	    	return j;
    	    }

    	}


        return Serch.length;


    }


    public static boolean SearchWord(String[] Origin , String[] Serch , int i){


    	boolean SerchCheck = false;
    	for(int j = i , k = 0; k < Serch.length; j++ , k++){

    	    if( Serch[k].equals(Origin[j]) ){
    	    	SerchCheck = true;
    	    }
    	    else{
    	    	return false;
    	    }



    	}


    	return SerchCheck;

    }


    public static boolean SameString(String[] Serch ){


    	boolean SerchCheck = false;
    	for(int i = 0 ; i < Serch.length; i++){

    	    if( Serch[0].equals(Serch[i]) ){
    	    	SerchCheck = true;
    	    }
    	    else{
    	    	return false;
    	    }



    	}


    	return SerchCheck;

    }



}

Measured memory_bytes: 24872
/*
 * wzorcowka
 * O(n * 3^n)
 * autor: Jakub Wasilewski
 */
#include <bits/stdc++.h>
using ll = long long;
using namespace std;

constexpr int nax = 15, maxm = nax * (nax - 1) / 2, mod = 1e9 + 7;
constexpr int pawns_starting_mask = (1 << 0) | (1 << 1);

int prepop[1 << nax];

inline int popcount(const int v)
{
    return prepop[v];
}

inline bool is_valid_mask(const int mask)
{
    return ((mask bitand pawns_starting_mask) == pawns_starting_mask) or
        ((mask bitand pawns_starting_mask) == 0);
}

int n, m, dp[1 << nax], pow2[maxm + 1];
uint32_t graph[nax];

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

    cin >> n >> m;

    for (int i = 0; i < (1 << n); ++i)
        prepop[i] = __builtin_popcount(i);

    pow2[0] = 1;
    for (int i = 1; i <= m; ++i)
    {
        pow2[i] = pow2[i - 1] * 2;
        if (pow2[i] >= mod)
            pow2[i] -= mod;
    }

    for (int i = 0; i < m; ++i)
    {
        int p, q; cin >> p >> q;
        --p, --q;
        graph[p] |= (1 << q);
    }

    dp[0] = 1;
    for (int mask = 1; mask < (1 << n); ++mask)
        if (is_valid_mask(mask))
            for (int sub = mask; ; sub = (sub - 1) bitand mask)
                if (is_valid_mask(sub))
                {
                    int result = 1;
                    for (int v = 0; v < n; ++v)
                        if ((mask - sub) bitand (1 << v))
                        {
                            int mult = pow2[popcount(graph[v] bitand sub)];
                            result = ((ll)result * mult) % mod;
                        }

                    for (int v = 0; v < n; ++v)
                        if (sub bitand (1 << v))
                        {
                            int mult = pow2[popcount(graph[v] bitand (mask - sub))] - 1;
                            result = ((ll)result * mult) % mod;
                        }

                    result = ((ll)result * dp[sub]) % mod;

                    dp[mask] += result;
                    if (dp[mask] >= mod)
                        dp[mask] -= mod;

                    if (not sub)
                        break;
                }

    int result = pow2[m] - dp[(1 << n) - 1];
    if (result < 0) result += mod;
    cout << result << '\n';
}


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

int main(){
    int n;
    cin >> n;
    int temp;
    set<int> ss;
    for(int i=0;i<n;i++){
        cin >> temp;
        ss.insert(temp);
    }
    cout << ss.size() << endl;
    return 0;
}

Measured memory_bytes: 256
def main():

    N = int(input())
    A = []
    for _ in range(N):
        A.append(int(input()))
    A.sort()

    if N % 2 == 0:
        A1 = A[:N//2]
        A2 = A[N//2:][::-1]
        B1 = []
        B2 = []
        k, l = 0, 0
        for i in range(N):
            if i % 2 == 0:
                B1.append(A1[k])
                B2.append(A2[k])
                k += 1
            else:
                B1.append(A2[l])
                B2.append(A1[l])
                l += 1
        B1 = [B1[-1]] + B1[:-1]
        B2 = [B2[-1]] + B2[:-1]

        cand1, cand2 = 0, 0
        for i in range(1, N):
            cand1 += abs(B1[i-1]-B1[i])
            cand2 += abs(B2[i-1]-B2[i])
        return max(cand1, cand2)
    else:
        A3 = A[:N//2]
        A4 = A[N//2:][::-1]
        A5 = A[:(N+1)//2]
        A6 = A[(N+1)//2:][::-1]
        B3 = []
        B4 = []
        k, l = 0, 0
        for i in range(N):
            if i % 2 == 0:
                B3.append(A4[k])
                B4.append(A5[k])
                k += 1
            else:
                B3.append(A3[l])
                B4.append(A6[l])
                l += 1
        B3 = [B3[-1]] + B3[:-1]
        B4 = [B4[-1]] + B4[:-1]

        cand3, cand4 = 0, 0
        for i in range(1, N):
            cand3 += abs(B3[i-1]-B3[i])
            cand4 += abs(B4[i-1]-B4[i])
        return max(cand3, cand4)


if __name__ == '__main__':
    print(main())

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

struct Node{
	int key;
	struct Node *right, *left , *parent;
};

struct Node *root , *NIL;

void insert(int k){
	struct Node *y = NIL;
	struct Node *x = root;
	struct Node *z;
	
	z = (struct Node *)malloc(sizeof(struct Node));
	z->key = k;
	z->left = NIL;
	z->right = NIL;
	
	while( x != NIL){
		y = x;
		if(z->key < x->key){
			x = x->left;
		}else{
			x = x->right;
		}
	}
	z->parent = y;
	if(y == NIL){
		root = z;
	}else{
		if(z->key < y->key){
			y->left = z;
		}else{
			y->right = z;
		}
	}
}

void inorder(struct Node *u){
	if( u == NIL) return;
	inorder(u->left);
	printf(" %d",u->key);
	inorder(u->right);
}

void preorder(struct Node *u){
	if( u == NIL) return;
	printf(" %d",u->key);
	preorder(u->left);
	preorder(u->right);
}

int main(void){
	int n,i,x;
	char  com[100];
	char A[] = "insert";
	char B[] = "print";
	scanf("%d",&n);
	
	for( i = 0; i < n; i++){
		while(scanf("%s",com) != EOF)
		if(strcmp(com,A)==0){
			scanf("%d",&x);
			insert(x);
		}else if( strcmp(com,B)==0){
			inorder(root);
			printf("\n");
			preorder(root);
			printf("\n");
		}
	}
	return 0;
}





Measured memory_bytes: 25236