akhauriyash/Code-Regression huggingface dataset:
use std::io::*;
use std::str::FromStr;

//https://qiita.com/tubo28/items/e6076e9040da57368845
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

//https://onlinejudge.u-aizu.ac.jp/solutions/problem/ALDS1_5_B/review/2709881/arsenic28/Rust
trait Joinable {
    fn join(self, sep: &str) -> String;
}

impl<U: ToString, T: Iterator<Item = U>> Joinable for T {
    fn join(self, sep: &str) -> String {
        self.map(|x| x.to_string()).collect::<Vec<_>>().join(sep)
    }
}

fn main() {
    let mut n:u64 = read();

    let mut res:Vec<char> = Vec::new();

    while n != 0 {
        n -= 1;
        res.push(('a' as u8 + (n%26) as u8) as char);
        n /= 26;
    }

    res.reverse();
    println!("{}",res.iter().join(""));

}

Measured memory_bytes: 2168
#include<stdio.h>
#include<limits.h>
#define NIL -1
static const int MAX = 1005;
static const int INFTY = (1<<21);

main(){
  int n, i, j, v, c, u, k, minV;
  int M[MAX][MAX], A[MAX], key[MAX], p[MAX];
  /*your code*/

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

  for ( i = 0; i < n; i++ ){
    scanf("%d %d", &u, &k);
    for ( j = 0; j < k; j++ ){
      scanf("%d %d", &v, &c);
      M[u][v] = c;
    }
  }

  /*your code*/
  for(i = 0; i < n; i++){
    key[i] = INT_MAX;
    p[i] = NIL;
    A[i] = NIL;
  }
  
  key[0]=0;
  
  while(1){
    
    u = NIL;
    
    minV = INT_MAX;
    
    for(i = 0;  i < n; i++){
      
      if(key[i] < minV && A[i] == NIL){
	
	u = i;
	
	minV = key[i];
	
      }
      
    }  
    if(u == NIL)break;
    
    A[u] = u; 
    
    for(v = 0; v < n; v++){
      if((M[u][v]+key[u]) < key[v] && A[v] == NIL){
	key[v] = (M[u][v]+key[u]);
	p[v] = u;
      }
    }
  }
  
  for ( i = 0; i < n; i++ ){
    printf("%d %d\n", i, (key[i]==INFTY?-1:key[i]));
  }

  return 0;

}

Measured memory_bytes: 1428
import qualified Data.ByteString.Char8 as BS
import Data.List
import Data.Maybe

readInt = fromIntegral . fst . fromJust . BS.readInteger
readIntList = map readInt . BS.words

getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
  n <- getInt
  ds <- getIntList
  let num = n `div` 2
  let ds' = sort ds
  let a = ds' !! (num -1)
  let b = ds' !! num
  print $ b - a

Measured memory_bytes: 16764
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <numeric>
#include <fstream>
#include <iomanip>

typedef long double ld;
typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

// Split
namespace util {

std::vector< std::string > split(std::string s, char delimiter)
{
  std::vector< std::string > vs;
  std::string sub;
  for (auto c : s) {
    if (c == delimiter) vs.push_back(sub), sub.clear();
    else sub += c;
  }
  vs.push_back(sub);
  return vs;
}

} // namespace util

// Minimum, Maximum
template<class T> T minimum(T head, T tail) { return std::min(head, tail); }
template<class H, class... T> H minimum(H head, T... tail) { return std::min(head, minimum(tail...)); }
template<class T> T maximum(T head, T tail) { return std::max(head, tail); }
template<class H, class... T> H maximum(H head, T... tail) { return std::max(head, maximum(tail...)); }

// Output
template<class T> std::ostream& operator << (std::ostream& os, std::vector< T > v)
{
  for (ll i = 0; i < (ll)v.size(); i++){ os << " [" << i << "]" << v[i]; if (i % 10 == 9) os << std::endl; }
  return os;
}

template<class T, class S> std::ostream& operator << (std::ostream& os, std::vector< std::pair<T, S> > vp)
{
  ll i = 0;
  for (auto p : vp){os << " [" << i++ << "]" << p.first << " " << p.second; if (i % 10 == 0) os << std::endl;}
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

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

  ll N;
  std::cin >> N;
  std::vector<ll> va(N, 0LL);

  ll ans = 0LL;
  for (ll i = 0; i < N; i++) {
    std::cin >> va[i];
  }

  for (ll i = 0; i < N; i++) {
    ans += va[i] - 1;
  }

  print(ans);
  return 0;
}


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

class Dice
{
  private:
    int top, front, right, left, back, bottom, temp;

  public:
    void set(int *nums)
    {
        this->top = nums[0];
        this->front = nums[1];
        this->right = nums[2];
        this->left = nums[3];
        this->back = nums[4];
        this->bottom = nums[5];
    }
    void showTop()
    {
        cout << this->top << endl;
    }
    void east()
    {
        this->temp = this->top;
        this->top = this->left;
        this->left = this->bottom;
        this->bottom = this->right;
        this->right = this->temp;
    }
    void west()
    {
        this->temp = this->top;
        this->top = this->right;
        this->right = this->bottom;
        this->bottom = this->left;
        this->left = this->temp;
    }
    void north()
    {
        this->temp = this->top;
        this->top = this->front;
        this->front = this->bottom;
        this->bottom = this->back;
        this->back = this->temp;
    }
    void south()
    {
        this->temp = this->top;
        this->top = this->back;
        this->back = this->bottom;
        this->bottom = this->front;
        this->front = this->temp;
    }
};

int main(int argc, char *argv[])
{
    Dice dice;
    int nums[6];
    for (int i = 0; i < 6; i++) { cin >> nums[i]; }
    dice.set(nums);
    string direction;
    cin >> direction;

    for (int i = 0; i < direction.size(); i++)
    {
        switch (direction[i])
        {
        case 'E':
            dice.east();
            break;
        case 'W':
            dice.west();
            break;
        case 'N':
            dice.north();
            break;
        case 'S':
            dice.south();
            break;
        default:
            break;
        }
    }

    dice.showTop();

    return 0;
}


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

#define		OPERAND			100+100+10
#define		OPERATOR		100+100+10		// +, -, *

int		pop(void);
void	push(int);

char		str[OPERAND+OPERATOR]={'\0'};
int			stack[OPERAND+OPERATOR]={0};

int		SUFX=0;

int		main(void)
{
	char		*p;
	int			x, y;
	int			rst;

	// 1???????????? ??°???????????????????????????
	fgets(str, sizeof(str), stdin);
	p = strtok( str, " " );

	// ?????????????????????????????°???
	push(atoi(p));
	//printf("p=%d\n",atoi(p));

	while(1)
	{
		p = strtok( NULL, " " );
		if( p == NULL )
		{
			break;
		}

		// ??????????????´???
		if(( *p=='+') || ( *p=='-') || ( *p=='*'))
		{
			y=pop();
			x=pop();
			if( *p=='+')
			{
				push(x+y);
				//printf("x+y=%d\n",x+y);
			}
			else if( *p=='-')
			{
				push(x-y);
			}
			else if( *p=='*')
			{
				push(x*y);
			}
		}
		else
		{
			// ??°???
			//printf("p=%d\n",atoi(p));
			push(atoi(p));
		}
	}
	rst = pop();
	printf("%d\n",rst);
	return 0;
}

void	push(int num)
{
	stack[SUFX] = num;
	SUFX+=1;
	return;
}

int		pop(void)
{
	SUFX-=1;
	return( stack[SUFX]);
}

Measured memory_bytes: 528
import sys

n = int(input())

la = []
for i in range(n):
	a = [int(i) for i in input().split()] 
	la.append(a)

la.sort(key = lambda x:x[1])

t = 0
for i in range(n):
	s = la[i][1]
	t += la[i][0]
	if t > s:
		print("No")
		sys.exit()

print("Yes")

Measured memory_bytes: 41184
a, b, k = map(int, input().split())
l = []
for i in range(k):
    if i + a <= b:
        l.append(i+a)
    if b-i>=a:
        l.append(b-i)
l = sorted(list(set(l)))
for j in range(len(l)):
    print(l[j])

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

using namespace std;

typedef long long ll;

int main(){
  int N, a, b, c, ds;
  cin >> N;
  int ans = 0;
  vector<int> L(N);
  for(int i = 0; i < N; i++){
    cin >> L.at(i);
  }
  sort(L.begin(), L.end());
  for(int i = N-1; i >= 1; i--){
    a = L.at(i);
    for(int j = i-1; j >= 0; j--){
      b = L.at(j);
      auto idx_lower = min(lower_bound(L.begin(), L.end(), a-b+1), L.begin()+j);
      //cout << *idx_lower << *(L.begin()+j) << endl;
      ds = distance(idx_lower, L.begin()+j);
      ans += ds;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a,n;
string b[105];
int main()
{
    cin>>a>>n;
    for(int i=0;i<a;i++)
    {
        cin>>b[i];
    }
    sort(b,b+a);
    for(int i=0;i<a;i++)
    cout<<b[i];
    cout<<endl;
}

Measured memory_bytes: 256
fn read_line() -> String {
    let mut return_ = format!("");
    std::io::stdin().read_line(&mut return_).ok();
    return_.trim().to_string()
}

fn main() {
    println!("{:?}", read_line().split_whitespace().map(|x| x.parse::<i32>().unwrap()).fold(0, |x, y| x + y));
}


Measured memory_bytes: 5032
fun main(args: Array<String>) {
    val (N, K) = readLine()!!.split(" ").map { it.toInt() }
    val xs = readLine()!!.split(" ").map { it.toLong() }

    var ans = (0 .. xs.size - K)
            .map { Pair(it, it + K - 1) }
            .map {
                if (xs[it.second] <= 0 || 0 <= xs[it.first]) {
                    Math.max(Math.abs(xs[it.first]), Math.abs(xs[it.second]))
                } else {
                    var time1 = xs[it.second] * 2 + Math.abs(xs[it.first])
                    var time2 = Math.abs(xs[it.first]) * 2 + xs[it.second]
                    Math.min(time1, time2)
                }
            }
            .min()

    println(ans)
}

Measured memory_bytes: 59856
#include <iostream>
using namespace std;
#include <math.h>
#include <cstdio>


int main()
{
  double dis = 0.0 , x1 , x2 , y1 , y2 , f = 0.0;
  
  cin >> x1 >> y1 >> x2 >> y2;
  
  if( x1 >= x2 && y1 >= y2 ) f = ( x1 - x2 ) * ( x1 - x2 ) + ( y1 - y2 ) * ( y1 - y2 );
  else if( x1 <= x2 && y1 <= y2 ) f = ( x2 - x1 ) * ( x2 - x1 ) + ( y2 - y1 ) * ( y2 - y1 );
  else if( x1 >= x2 && y1 <= y2 ) f = ( x1 - x2 ) * ( x1 - x2 ) + ( y2 - y1 ) * ( y2 - y1 );
  else if( x1 <= x2 && y1 >= y2 ) f = ( x2 - x1 ) * ( x2 - x1 ) + ( y1 - y2 ) * ( y1 - y2 );
  
  // f = x1 * x2 * y1 * y2;
  dis = sqrt(f); 
  
  printf("%.8f\n",dis);
  
  return 0;
}

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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define ll1 1ll
#define ONE 1ll
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>
istream &operator>>(istream &is, pair<T, S> &p) {
  is >> p.first >> p.second;
  return is;
}
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> &p) {
  os << p.first << " " << p.second;
  return os;
}

template <typename T> void printvv(const vector<vector<T>> &v) {
  cerr << endl;
  rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
    if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
      cerr << "INF";
    } else
      cerr << v[i][j];
    cerr << (j == v[i].size() - 1 ? '\n' : ' ');
  }
  cerr << endl;
}
/*
   typedef __int128_t Int;
   std::ostream &operator<<(std::ostream &dest, __int128_t value) {
   std::ostream::sentry s(dest);
   if (s) {
   __uint128_t tmp = value < 0 ? -value : value;
   char buffer[128];
   char *d = std::end(buffer);
   do {
   --d;
 *d = "0123456789"[tmp % 10];
 tmp /= 10;
 } while (tmp != 0);
 if (value < 0) {
 --d;
 *d = '-';
 }
 int len = std::end(buffer) - d;
 if (dest.rdbuf()->sputn(d, len) != len) {
 dest.setstate(std::ios_base::badbit);
 }
 }
 return dest;
 }

 __int128 parse(string &s) {
 __int128 ret = 0;
 for (int i = 0; i < s.length(); i++)
 if ('0' <= s[i] && s[i] <= '9')
 ret = 10 * ret + s[i] - '0';
 return ret;
 }
 */

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

signed main(signed argc, char *argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);

  int H, W;
  cin >> H >> W;
  vector<string> v;
  W+=2;
  v.eb(string(W, '#'));
  rep(i, 0, H) {
    string t;
    cin >> t;
    v.eb("#" + t + "#");
  }
  v.eb(string(W, '#'));

  for(auto s:v)cout<<s<<endl;

  return 0;
}


Measured memory_bytes: 256
private val scanner = java.util.Scanner(System.`in`)

private fun readInts(n: Int) = Array(n) { scanner.nextInt() }
private fun readLongs(n: Int) = Array(n) { scanner.nextLong() }
private fun readLineInts() = readLine()!!.split(" ").map { it.toInt() }.toTypedArray()
private fun readLineLongs() = readLine()!!.split(" ").map { it.toLong() }.toTypedArray()

fun main(args: Array<String>) {
    val (a, b, c) = readLineInts()
    
    println(when {
        a == b -> c
        b == c -> a
        c == a -> b
        else -> ""
    })
}

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

int main() {
  int N,X;
  cin >> N >> X;
 
  vector<int> L(N);
  for (int i = 0; i < N; i++){
    cin >> L.at(i);
  }
  
   int count =1;
   vector<int> D(N+1);
   for (int j=1;j<N+1;j++){
     D.at(j)=D.at(j-1)+L.at(j-1);
     if(D.at(j)<=X){
       count++;
     }
   }
   cout << count << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
#ABC119 D

import sys
import math
import bisect
from heapq import heappush, heappop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
mod = 10**9 + 7


a,b,q = map(int,input().split())
s = [-float('inf')] + [int(input()) for _ in range(a)] + [float('inf')]
t = [-float('inf')] + [int(input()) for _ in range(b)] + [float('inf')]

for _ in range(q):
    x = int(input())
    sr,tr = bisect.bisect_right(s,x),bisect.bisect_right(t,x)
    ans = float('inf')
    for S in [s[sr-1],s[sr]]:
        for T in [t[tr-1],t[tr]]:
            d1,d2 = abs(S-x) + abs(T-S), abs(T-x) + abs(S-T)
            ans = min(ans,d1,d2)
    print(ans)


Measured memory_bytes: 14540
#include <iostream>
#include <cassert>
#include <vector>
#include <set>
#include <map>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <math.h>
#define MODD 1000000007
#define MAXN 120000
#define ll long long
using namespace std;

int Ask(int x) {
    printf("%d\n",x);
    fflush(stdout);
    string S;
    cin>>S;
    if (S == "Male")
        return 0;
    if (S == "Female")
        return 1;
    return -1;
}

int main() {
    int N;
    cin>>N;
    
    // N=0
    
    int b = Ask(0);
    
    if (b == -1) {
        return 0;
    }
    
    // 0 has b
    
    
    int low = 0;
    int high = N-1;
    
    while(low < high) {
        
        int mid = (low + high)/2;
        int bmid = Ask(mid);
        if (bmid == -1) {
            return 0;
        }
        
        if (bmid == (mid+b)%2) {
            low = mid+1;
        } else {
            high = mid;
        }
    }
    
    int x = Ask(low);
    if (x != -1) {
        exit(-1);
    }
    
}


Measured memory_bytes: 852
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    n = int(input())
    A = readInts()
    now = 1
    i = 0
    cnt = 0
    while i < n:
        if A[i] == now:
            now += 1
        else:
            cnt += 1
        i += 1
    if cnt == n:
        print('-1')
    else:
        print(cnt)
if __name__ == '__main__':
  main()


Measured memory_bytes: 27164
#include <bits/stdc++.h>
#include <numeric>
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
    int n,k,ans=0;
    cin >> n >> k;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        int b;
        cin >> b;
        a.at(b-1)++;
    }
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());
    for(int i=k;i<n;i++){
        ans+=a.at(i);
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
using namespace std;


typedef long long ll;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)

const int mod = 1000000007;


int main(){
  int a, b;
  cin >> a >> b;
  int ans = max(a + b, max(a * b, a - b));
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main()
{
    int a, b, c, x;
    cin >> a >> b >> c >> x;
    int cnt = 0;
    for (int i = 0; i <= a; i++)
    {
        for (int j = 0; j <= b; j++)
        {
            for (int k = 0; k <= c; k++)
            {
                if (x == 500 * i + 100 * j + 50 * k)
                {
                    cnt++;
                }
            }
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3644
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;


int main() {

	Int N;
	cin >> N;

	vector<Int> d(N);
	for (int i = 0; i < N; i++) cin >> d[i];

	sort(d.begin(), d.end());

	Int len = d.size();

	Int ans = 0;
	if (d[len / 2 - 1] != d[len / 2])ans = d[len / 2] - d[len / 2 - 1];

	cout << ans << endl;


}

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


int main() {
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    for (int i = 0; i < k; i++) {
        if (b <= a) b *= 2;
        else if (c <= b) c *= 2;
        else c *= 2;
    }

    if (a < b && b < c) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

int main(){
	int H, W, i, j;
	
	while(1){
		cin >> H >> W;
		if (H == 0 && W ==0){
			break;
		}
		for(i = 0; i < H; i++){
			for(j = 0; j < W;j++){
				if(j == 0 || j == W -1 || i == 0 || i == H -1){
				cout << '#';
				}else{
					cout << '.';
				}
			}
			cout << endl;

		}
		cout << endl;
	}
    return 0;
}

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
using ull = unsigned long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  int x1,y1,x2,y2; cin >> x1 >> y1 >> x2 >> y2;
  int x3 = x2 - (y2-y1),y3 = y2 + (x2-x1);
  int x4 = x3 - (y3-y2),y4 = y3 + (x3-x2);
  cout << x3 << ' ' << y3 << ' ' << x4 << ' ' << y4 << endl;
}


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


int main(){
    int n;
    string a,b;
    cin >> n;
    cin >> a;
    b = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    for (int x = 0; x < a.size() ; x++){
        for (int i = 0; i < 26 ; i++){
            if (a.at(x) == b.at(i)){
                if (i < 26 - n)
                    cout << b.at(i + n);
                else
                    cout << b.at(i - 26 + n);
            }
        }
    }
    cout << endl;
    
}
 

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		if(((a < c )&&( c < b ))||(
				(b < c )&&( c < a))) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 23764
import sys

def main():
    N = int(input())

    flds = input().split(' ')
    pt_A, pt_B = int(flds[0]), int(flds[1])

    flds = input().split(' ')
    points = [-1]*N
    for i in range(N):
        points[i] = int(flds[i])

    e, m, h = 0, 0, 0
    for i in range(N):
        if points[i] <= pt_A:
            e += 1
        elif points[i] <= pt_B:
            m += 1
        else:
            h += 1
    ans = min(e, m, h)
    print(ans)

if __name__ == "__main__":
    main()


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

#define ED return 0;
#define UP(a,b) ((a+(b-1))/b)
#define SORT(vec) sort(vec.begin(),vec.end());
#define DOUBLECHANGE(count) cout << setprecision(count);
#define REV(vec) reverse(vec.begin(),vec.end());
#define ipow(x,y) long(pow(x,y))
const long long int mod = 1000000007;
unsigned long long int gcd(unsigned long long int a, unsigned long long int b){
    if(b == 0) return a;
    return gcd(b, a % b);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S, T;
    cin >> S >> T;
    vector<char> vec (26,'*');
    int time = 0;
    for(int i = 0;i < S.size();i++){
        bool test = false;
        for(int j = 0;j < 26;j++){
            if(S.at(i) == vec.at(j)){
                S.at(i) = j;
                test = true;
                break;
            }
        }
        if(test == false){
            vec.at(time) = S.at(i);
            S.at(i) = time;
            time++;
        }
    }

    vector<char> vec1 (26,'*');
    int time1 = 0;
    for(int i = 0;i < T.size();i++){
        bool test = false;
        for(int j = 0;j < 26;j++){
            if(T.at(i) == vec1.at(j)){
                T.at(i) = j;
                test = true;
                break;
            }
        }
        if(test == false){
            vec1.at(time1) = T.at(i);
            T.at(i) = time1;
            time1++;
        }
    }

    if(S == T){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}


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

int main() {
  int H, W, K;
  cin >> H >> W >> K;
  vector<vector<char>> cake(H, vector<char>(W));
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) cin >> cake[i][j];
  }
  vector<bool> strawberry(H);
  int last_berry = 0;
  for (int i = 0; i < H; i++) {
    strawberry[i] = false;
    for (int j = 0; j < W; j++) {
      if (cake[i][j] == '#') {
        strawberry[i] = true;
        last_berry = i;
        break;
      }
    }
  }
  vector<vector<int>> cut_cake(H, vector<int>(W));
  int cnt = 0;
  for (int i = last_berry; i >= 0; i--) {
    if (!strawberry[i]) {
      cut_cake[i] = cut_cake[i+1];
      continue;
    }
    int tmp = 0;
    cnt++;
    for (int j = 0; j < W; j++) {
      if (cake[i][j] == '#') {
        tmp++;
        if (tmp > 1) cnt++;
      }
      cut_cake[i][j] = cnt;
    }
  }
  for (int i = last_berry+1; i < H; i++) {
    cut_cake[i] = cut_cake[last_berry];
  }
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cout << cut_cake[i][j];
      if (j == W-1) cout << endl;
      else cout <<" ";
    }
  }
}


Measured memory_bytes: 4104
#include<algorithm>
#include<cstdio>
using namespace std;
const int mod=1e9+7;
int n,m,sl,fh,cnt,ans,a[610],b[610],c[610],f[610][310][310];
int rd()
{
	sl=0;fh=1;
	char ch=getchar();
	while(ch<'0'||'9'<ch) {if(ch=='-') fh=-1; ch=getchar();}
	while('0'<=ch&&ch<='9') sl=sl*10+ch-'0',ch=getchar();
	return sl*fh;
}
void upd(int &x,int y) {x+=y; if(x>=mod) x-=mod;}
int main()
{
	n=rd();
	for(int i=1;i<=n*2;++i) a[i]=rd();
	for(int i=1;i<=n*2;i+=2)
		if(a[i]!=-1&&a[i+1]!=-1) b[a[i]]=b[a[i+1]]=2;
		else if(a[i]!=-1) b[a[i]]=1;
		else if(a[i+1]!=-1) b[a[i+1]]=1;
		else cnt++;
	for(int i=1;i<=n*2;++i)
		if(b[i]&1) m++;
		else if(!b[i]) c[++m]=1;
	f[m][0][0]=1;
	for(int x,i=m;i;--i)
		for(int j=0;j<=m&&j<=n;++j)
			for(int k=0;k<=m&&k<=n;++k)
			{
				if(!(x=f[i][j][k])) continue;
				if(j) upd(f[i-1][j-1][k],x);
				if(!c[i]) upd(f[i-1][j][k+1],x);
				else
				{
					upd(f[i-1][j+1][k],x);
					if(k) f[i-1][j][k-1]=(f[i-1][j][k-1]+1ll*x*k)%mod; 
				}
			}
	ans=f[0][0][0];
	for(int i=2;i<=cnt;++i) ans=1ll*ans*i%mod;
	printf("%d\n",ans);
	return 0;
}

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

namespace ConsoleApp
{
    class Program
    {

        static void Main(string[] args)
        {
            var ar = ReadLine().Split().Select(int.Parse).ToArray();
            var n = ar[0];
            var m = ar[1];
            if(m == 0){
                if (n == 1) { WriteLine("0"); return; }
                else{
                    var tmp = "1";
                    for (int i = 1; i < n;i++)
                        tmp = tmp + "0";
                    WriteLine(tmp);
                    return;
                }
            }
            

            var s = new int[m];
            var c = new int[m];

            var res = new int[n];
            for (int i = 0; i < n; i++) res[i] = -1;

            for (int i = 0; i < m; i++)
            {
                ar = ReadLine().Split().Select(int.Parse).ToArray();
                s[i] = ar[0];
                c[i] = ar[1];

                if (res[s[i] - 1] == -1)
                {
                    if (n > 1 && s[i] == 1 && c[i] == 0) 
                    { 
                        WriteLine("-1"); return; 
                    }
                    res[s[i] - 1] = c[i];
                }
                else
                if (res[s[i] - 1] != c[i])
                {
                    //矛盾
                    WriteLine("-1");
                    return;
                }
            }
            if(n > 1)
                if (res[0] == -1) res[0] = 1;
            else
                if(res[0] == -1) res[0] = 0;
            

            for (int i = 1; i < n; i++)
            {
                if (res[i] == -1) res[i] = 0;
            }
            string str = "";
            for (int i = 0; i < n; i++) 
                str = str + res[i];

            WriteLine(str);
        }



    }

}


Measured memory_bytes: 13396
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    ll x;
    cin >> x;
    for (ll a = -5000; a <= 5000; ++a) {
        for (ll b = -5000; b <= 5000; ++b) {
            if (a * a * a * a * a - b * b * b * b * b == x) {
                cout << a << " " << b << endl;
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
const int INF = 1e+9;

int main()
{
	int n, k = 0;
	string s;
	cin >> n;
	cin >> k;
	cin >> s;

	for (int i = 0; i < n; i++)
	{
		s[k - 1] = tolower(s[k - 1]);
	}
	cout << s << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <queue>
#include <cstring>
#include <string>
#include <stack>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#include <ctime> 
using namespace std;

#define pb push_back
#define All(a) a.begin(), a.end()
#define met(a, b) memset(a, b, sizeof(a))
#define rep1(i, l, r) for(int i = l; i <= r; ++i)
#define rep2(i, l, r) for(int i = l; i < r; ++i) 
#define per(i, r, l) for(int i = r; i >= l; --i)
typedef long long ll;
typedef double db;
typedef long double ldb;
const int NIL = -1;
const int oo = 0x3f3f3f3f;
const ll INF = 2e18;
const db eps = 1e-8;
const db PI = acos(-1.0);

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

inline void write(int x)
{
	if(x < 0) { putchar('-'); x = -x; }
    if(x >= 10) write(x/10); 
	putchar(x%10+'0'); 
}

int main(void)
{
	int n = read();
	int M, m = read();
	M = m;
	rep2(i, 1, n)
	{
		int v = read();
		M = max(M, v);
		m = min(m, v);
	}
	printf("%d", M - m);
	
	return 0;
} 

Measured memory_bytes: 384
#include <bits/stdc++.h>
 
#define pii pair<int, int>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long 
#define ull unsigned long long 
#define ld long double
#define sz(v) int(v.size())
#define all(v) v.begin(), v.end()
 
#define y1 what

using namespace std;
 
const int N = (int) 1e5 + 10;
const int M = (int) 101;
const ll big =  (1LL << 51);
const ll LINF = (ll) 1e18;
const int INF = (int) 1e9 + 7;
const int INF1 = (int) 1e9 + 3;
const double EPS = (double) 1e-6;
const double PI =  3.14159265359;

int n, c, k;
int t[N], dp[N];

int main() {
    #define fn "balls"
    #ifdef witch
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #else
//        freopen(fn".in", "r", stdin);
//        freopen(fn".out", "w", stdout);
    #endif
    srand(time(0));
    cin >> n >> c >> k;
    for (int i = 1; i <= n; i++) {
      cin >> t[i];
    }
    sort(t + 1, t + n + 1);
    multiset<int> st;
    st.insert(0);
    for (int i = 1, l = 0; i <= n; i++) {
      while (l < i && (t[l + 1] + k < t[i] || i - l > c)) {
        st.erase(st.find(dp[l]));
        ++l;
      }
      dp[i] = *st.begin() + 1;
      st.insert(dp[i]);
      continue;
      dp[i] = INF;
      for (int j = 0; j < i; j++) {
        if (i - j <= c && t[j + 1] + k >= t[i]) {
          dp[i] = min(dp[i], dp[j] + 1);
        }
      }
    }
    cout << dp[n];
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

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

    int a = 1, b = 1;
    if (n < 2) {
        cout << 1 << endl;
    } else {
        int ans;
        for (int i = 2; i <= n; ++i) {
            ans = a + b;
            b = a;
            a = ans;
        }

        cout << ans << endl;
    }

    return 0;
}


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

int main(void){
	int i,n,m,s;
	scanf("%d",&n);
	
	int a[n];
	
	for(i=0;i<n;i++)
	scanf("%d",&a[i]);
	
	m=0;
	s=1000000001;
	
	for(i=0;i<n;i++){
		if(m<a[i])
		m=a[i];
		if(s>a[i])
		s=a[i];
	}
	
	printf("%d",m-s);
}


Measured memory_bytes: 128
/*
	Name:
	Author: xiaruize
	Date:
*/
#pragma GCC optimize(2)
#include<algorithm>
#include<bitset>
#include<cctype>
#include<cerrno>
#include<clocale>
#include<cmath>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<utility>
#include<vector>
#include<cwchar>
#include<cwctype>
using namespace std;
#define ull unsigned long long
#define MOD 1000000007
#define ALL(a) (a).begin(), (a).end()
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define ll long long
#define form(i,j,n) for(int i=int(j);i<=int(n);i++)
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define pis pair<int,string>
#define sec second
#define sz(a) int((a).size())

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

int main()
{
 	ios::sync_with_stdio(false);
	cin.tie(0);
 	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int n;
	cin>>n;
	int a=n%10;
	if(a==2||a==4||a==5||a==7||a==9)
	{
		cout<<"hon"<<endl;
	}
	else if(a==0||a==1||a==6||a==8)
	{
		cout<<"pon"<<endl;
	}
	else
	{
		cout<<"bon"<<endl;
	}
	return 0;
}


Measured memory_bytes: 3644
func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

func main() {
    let line = readInts()
    let x = line[0]
    let y = line[1]
    
    for i in 0...x {
        if i * 2 + (x - i) * 4 == y {
            print("Yes")
            return
        }
    }
    print("No")
}

main()


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

using namespace std;

int main(){
    
    int n, m;
    cin>>n>>m;
    int ans = 0;
    if (n>=2){
        ans+= (n*(n-1))/2;
    }
    if (m>=2){
        ans+= (m*(m-1))/2;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>

char c, buf[256];

int main() {
    while (scanf("%c", &c) != EOF) {
        ++buf[c];
    }

    for (char i = 'A'; i <= 'Z'; ++i) {
        buf[i + 'a' - 'A'] += buf[i];
    }

    for (char i = 'a'; i <= 'z'; ++i) {
        printf("%c : %d\n", i, buf[i]);
    }

    return 0;
}

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

using namespace std;

int main(){

    int a, b, c;
    
  	int arr[3];
  	
  	cin >> arr[0] >> arr[1] >> arr[2];
  	
  	sort(arr, arr + 3);
  	
  	if(arr[2] == 7 && arr[1] == 5 && arr[0] == 5){
  		printf("YES\n");
	}
	else{
		printf("NO\n");
	}
   
    return 0;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
}

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

func main() {
	N := nextInt()
	fmt.Printf("%d", N * N * N)
}


Measured memory_bytes: 640
from fractions import gcd
def check():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    if K > max(A):
        return False
    g = A[0]
    for i in range(1,N):
        g = gcd(g,A[i])
    if K%g != 0:
        return False
    return True
if check():
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Measured memory_bytes: 16280
import heapq

def root(x):
    path_to_root = []
    while P[x] != x:
        path_to_root.append(x)
        x = P[x]
    for node in path_to_root:
        P[node] = x
    return x
def is_same_set(x,y):
    return root(x) == root(y)
def unite(x,y):
    P[root(x)] = root(y)

W = 0
N = int(input().strip())
P = [i for i in range(N)]
A = []
for i in range(N):
    v = list(map(int,input().strip().split(' ')))
    A.append(v)
edges = [] 
for i in range(N):
    for j in range(i,N):
        edge = [A[i][j],i,j]
        heapq.heappush(edges,edge)
while len(edges) > 0:
    e = heapq.heappop(edges)
    I = e[1]
    J = e[2]
    if e[0] != -1:
        if not is_same_set(I,J):
            unite(I,J)
            W += e[0]
print(W)



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

int main() {
  int n;
  cin>>n;
  vector<int> v(n),p(n),q(n);
  rep(i,n){
    v[i]=i+1;
  }
  rep(i,n){
    cin>>p[i];
  }
  rep(i,n){
    cin>>q[i];
  }
  int tmp=0,a,b;
  do{
    tmp++;
    if(v==p){
      a=tmp;
    }
    if(v==q){
      b=tmp;
    }
  }while(next_permutation(v.begin(),v.end()));
  cout<<abs(a-b)<<endl;
}

Measured memory_bytes: 256
###==================================================
### import
#import bisect
#from collections import Counter, deque, defaultdict
#from copy import deepcopy
#from functools import reduce, lru_cache
#from heapq import heappush, heappop
#import itertools
#import math
#import string
import sys
### stdin
def input(): return sys.stdin.readline()
def iIn(): return int(input())
def iInM(): return map(int, input().split())
def iInM1(): return map(int1, input().split())
def iInLH(): return list(map(int, input().split()))
def iInLH1(): return list(map(int1, input().split()))
def iInLV(n): return [iIn() for _ in range(n)]
def iInLV1(n): return [iIn()-1 for _ in range(n)]
def iInLD(n): return [iInLH() for _ in range(n)]
def iInLD1(n): return [iInLH1() for _ in range(n)]
def sInLH(): return list(input().split())
def sInLV(n): return [input().rstrip('\n') for _ in range(n)]
def sInLD(n): return [sInLH() for _ in range(n)]
### stdout
def OutH(lst, deli=' '): print(deli.join(map(str, lst)))
def OutV(lst): print('\n'.join(map(str, lst)))
### setting
sys.setrecursionlimit(10 ** 6)
### utils
int1 = lambda x: int(x) - 1
### constants
INF = int(1e9)
MOD = 1000000007
dx = (-1, 0, 1, 0)
dy = (0, -1, 0, 1)
###---------------------------------------------------

A, B, C = iInM()

if A == B:
    print(C)
elif B == C:
    print(A)
else:
    print(B)

Measured memory_bytes: 62304
#include <bits/stdc++.h>
using namespace std;
const int N=100005;

int main(){
    int n,t[N]={0},x[N]={0},y[N]={0},d;
    cin>>n;
    bool ok=1;
    for(int i=1;i<=n;i++){
        cin>>t[i]>>x[i]>>y[i];
        d=abs(x[i]-x[i-1])+abs(y[i]-y[i-1]);
//        cout<<d<<'\n';
        if(t[i]-t[i-1]<d||(t[i]-t[i-1])%2!=d%2){
            ok=0;
        }
    }
    if(ok)cout<<"Yes\n";
    else cout<<"No\n";
}


Measured memory_bytes: 1408
#include <stdio.h>

int main(void) {
  int i, j, k;
  int r, c;
  scanf("%d %d", &r, &c);
  int a[r + 2][c + 2];

  for (i = 0; i < r + 1; i++) {
    for (j = 0; j < c + 1; j++)
      a[i][j] = 0;
  }

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

  for (i = 0; i < r + 1; i++) {
    for (j = 0; j < c + 1; j++) {
      if (j == c) {
        for (k = 0; k < c; k++)
          a[i][j] += a[i][k];
        printf("%d\n", a[i][j]);
      } else if (i == r) {
        for (k = 0; k < r; k++)
          a[i][j] += a[k][j];
        printf("%d ", a[i][j]);
      } else {
          printf("%d ", a[i][j]);
        }
    }
  }

}



Measured memory_bytes: 2140
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define IFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define RPT(i,a,b) for(int i=(a);i<((a)+(b));++i)
#define IRPT(i,a,b) for(int i=((a)+(b)-1);i>=(a);--i)
#define ALL(x) x.begin(),x.end()

void solve(){
  int x, y, z; cin >> x >> y >> z;
  swap(x,y); swap(x,z);
  cout << x  << ' ' << y << ' ' << z;
}

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long int n;
  cin>>n;
  long long ans=0;
  for (int i=1; i<n+1; i++)
  {
    if (i%3==0||i%5==0||i%15==0)
      continue;
    else
        ans = ans + i;
  }
  cout<<ans;
  
}

Measured memory_bytes: 3636
#include <iostream>
#include <math.h>
using namespace std;

int main(){
    int N, T, A;
    double tdiff = 100000;
    int ans, x;
    ans = 0;
    cin >> N >> T >> A;
    for(int i = 0; i < N; i++){
        cin >> x;
        if(tdiff > fabs(A - (T - x * 0.006))){
            tdiff = fabs(A - (T - x * 0.006));
            ans = i+1;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm>
#include <map>
#include <set>
using namespace std;

vector<string> rotate(vector<string> src,int t[]){
	vector<string> tmp(6);
	for(int i = 0 ; i < 6 ; i++){
		tmp[t[i]] = src[i];
	}
	return tmp;
}


vector<string> le(vector<string> src){
	//int s[] = {0,1,2,3,4,5};
	int t[] = {0,2,4,1,3,5};
	return rotate(src,t);
}
vector<string> no(vector<string> src){
	//int s[] = {0,1,2,3,4,5};
	int t[] = {1,5,2,3,0,4};
	return rotate(src,t);
}

vector<string> we(vector<string> src){
	//int s[] = {0,1,2,3,4,5};
	int t[] = {3,1,0,5,4,2};
	return rotate(src,t);
}
int main(){
	int n;
	while(cin >> n && n){
		set< vector<string> > c;
		int k = 0;
		for(int i = 0 ; i < n ; i++){
			vector<string> s;
			for(int j = 0 ; j < 6 ; j++){
				string t;cin >> t;
				s.push_back(t);
			}
			if( c.count(s) ) k++;
			for(int x = 0 ; x < 4 ; x++){
				for(int y = 0 ; y < 4 ; y++){
					for(int z = 0 ; z < 4 ; z++){
						c.insert(s);
						s = we(s);
					}
					s=le(s);
				}
				s=no(s);
			}
		}
		cout << k << endl;
	}
}

Measured memory_bytes: 1300
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> VI;
typedef pair <int,int> ii;
typedef long long LL;
#define pb push_back
const int INF = 2147483647;
const int N = 500005;

int n, m, res;

int main() {
scanf("%d %d", &n, &m);
res = n * (n - 1) / 2 + m * (m - 1) / 2;
printf("%d\n", res);
return 0;
}

Measured memory_bytes: 256
def mapint_inp():
    return map(int, input().split())

def intinp():
    return int(input())

A, B, H, M = mapint_inp()

# H時M分の時針の角度、M分の分針進んだ角度を求める

def get_hour_hand_angle(h, m):
    return (h*30)+(0.5*m)

def get_minute_hand_angle(m):
    return 6*m

# 時針と分針がなす角の短い方を求める
def get_formed_angle(hour_hand_angle, minute_hand_angle):
    diff = abs(hour_hand_angle - minute_hand_angle)
    if diff > 180:
        return 360 - diff
    return diff

# 2辺とその間の角がわかったので余弦定理で角もう一辺の長さを計算する

import math

def get_ans():
    hha = get_hour_hand_angle(H,M)
    mha = get_minute_hand_angle(M)
    fa = get_formed_angle(hha, mha)
    c = math.cos(math.radians(fa))
    return math.sqrt((A**2)+(B**2)-(2*A*B*c))


print(get_ans())




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

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

    vector<int> d(N);
    rep(i, N) {
        cin >> d.at(i);
    }

    sort(d.begin(), d.end());

    int ans = 1;
    rep(i, N - 1) {
        if (d.at(i) != d.at(i + 1)) {
            ans++;
        }
    }
    cout << ans << endl;
};


Measured memory_bytes: 256
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let n: usize = read();
    let mut l: Vec<i32> = (0..n).map(|_| read()).collect();
    l.sort();
    let max = l.iter().max().unwrap();
    let sum: i32 = l.iter().sum();
    println!("{}", if *max < sum - max { "Yes" } else { "No" });
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


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

ll Q;

/*
  a をソートして中間の値を返すには?
  priority_queue 2個で
*/

int main(){
	cin >> Q;
	
	priority_queue<ll,vector<ll>,less<ll>> ql;
	priority_queue<ll,vector<ll>,greater<ll>> qr;
	
	ll qlsum = 0; // ql に入っているaの合計
	ll qrsum = 0; // qr に入っているaの合計
	ll bsum = 0;
	
	auto qlpush = [&](ll a){
		ql.push(a);
		qlsum += a;
	};
	auto qrpush = [&](ll a){
		qr.push(a);
		qrsum += a;
	};
	auto qlpop = [&](){
		ll a = ql.top();
		ql.pop();
		qlsum -= a;
		return a;
	};
	auto qrpop = [&](){
		ll a = qr.top();
		qr.pop();
		qrsum -= a;
		return a;
	};
	

	
	for ( int i = 0; i < Q; i++ ){
		int q;
		cin >> q;
		if ( q == 1 ){
			ll a, b;
			cin >> a >> b;
			bsum += b;
			
			if ( ql.size() == 0 ){
				qlpush(a);
			}
			else if ( ql.top() < a ){
				qrpush(a);
				
				if ( ql.size() < qr.size() ){
					qlpush(qrpop());
				}
			}
			else {
				qlpush(a);
				
				if ( ql.size() > qr.size()+1 ){
					qrpush(qlpop());
				}
			}
		}
		else {
			ll a = ql.top();
			ll fx = bsum + (a*ql.size() - qlsum) + (qrsum - a*qr.size());
			cout << a << " " << fx << "\n";
		}
	}
	
	
	return 0;
}



Measured memory_bytes: 3828
l = list(map(int, input().split()))
n = l[0]
t = l[1]

l = list(map(int, input().split()))
maxdiff = 0
count = 0
currentmin = 10000000000

for i in l:
    if i - currentmin > maxdiff:
        maxdiff = i - currentmin
        count = 1
    elif i - currentmin == maxdiff:
        count += 1
    elif i < currentmin:
        currentmin = i
print(count)


Measured memory_bytes: 14252
#include <bits/stdc++.h>
#include <cstring>
#include <map>
#include <set>
#define int long long int
#define cons 1000000007 
using namespace std;


signed main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    #ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    //  freopen("output.txt", "w", stdout);
    #endif
    
    string s;
    cin>>s;
    int f = 10, i, sum=0;
    reverse(begin(s), end(s));
    int dp[s.length()][13]={0};
    if(s[0]=='?'){
        dp[0][0]=1;
        dp[0][1]=1;
        dp[0][2]=1;
        dp[0][3]=1;
        dp[0][4]=1;
        dp[0][5]=1;
        dp[0][6]=1;
        dp[0][7]=1;
        dp[0][8]=1;
        dp[0][9]=1;
    }
    else{
        int x = (int)s[0] - (int)'0';
        dp[0][x]=1;
    }
    for(i=1;i<s.length();i++){
        if(s[i]!='?'){
            int x = (int)s[i] - (int)'0';
            for(int rem=0;rem<13;rem++){
                dp[i][(rem+x*f)%13]+=dp[i-1][rem];
                dp[i][(rem+x*f)%13]= dp[i][(rem+x*f)%13]%cons;
            }
        }
        else{
            for(int ii=0;ii<10;ii++){
                for(int rem=0;rem<13;rem++){
                    dp[i][(rem+ii*f)%13]+=dp[i-1][rem];
                    dp[i][(rem+ii*f)%13]= dp[i][(rem+ii*f)%13]%cons;
                }
            }
        }
        f=(f*10)%13;
    }
    cout<<dp[s.length()-1][5]<<endl;

}




Measured memory_bytes: 10704
def solve(left, right)
  return if left > right
  x = $preorder[$cur]
  $cur += 1
  solve(left, $arr[x]-1)
  solve($arr[x]+1, right)
  $postorder << x
end
n = gets.to_i
$preorder = gets.split.map(&:to_i)
$inorder = gets.split.map(&:to_i)
$postorder = []
$arr = Array.new(n)
$cur = 0
n.times{ |i| $arr[$inorder[i]] = i }
solve(0, n-1)
puts $postorder.join(" ")

Measured memory_bytes: 8708
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <tuple>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <cstdio>
#include <numeric>
#define REP(i, n) for(LL i = 0;i < n;i++)
#define REPR(i, n) for(LL i = n;i >= 0;i--)
#define FOR(i, m, n) for(LL i = m;i < n;i++)
#define FORR(i, m, n) for(LL i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define INF (LL)1e15
#define MOD 1000000007
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;
typedef pair<int, P> PP;
typedef pair<LL, LP> LPP;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

/*************** using variables ***************/
string s;
int cnt = 0;
int pre_stone = 0;
char stone[2] = {'W', 'B'};
/**********************************************/

int main(){
    cin >> s;
    if(s[0] == 'B') pre_stone = 1;
    REP(i, s.size()){
        if(s[i] != stone[pre_stone]){
            cnt++;
            pre_stone = (pre_stone + 1) % 2;
        }
    }

    cout << cnt << endl;
}


Measured memory_bytes: 512