akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main(void) {

	char n[11];
	int year, month, day;
	year = month = day = 0;

	int i;

	scanf("%s", n);
	int omomi;

	omomi = 1000;
	for (i = 0; i < 4; i++) {
		year = year + (n[i]-0X30) * omomi;
		omomi=omomi / 10;
	}


	omomi = 10;
	for (i = 5; i < 7; i++) {
		month = month + (n[i]-0X30) * omomi;
		omomi=omomi / 10;
	}

	omomi = 10;
	for (i = 8; i < 10; i++) {
		day = day + (n[i]-0X30) * omomi;
		omomi = omomi / 10;
	}

	if (year == 2019 && month > 4 ) {
		printf("TBD\n");
	}
	else {
		printf("Heisei\n\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
 
#define pii pair<int,int>
#define pll pair<ll,ll>
#define eb emplace_back
#define ll long long
#define nl '\n'
#define in() ( { int a ; scanf("%d",&a); a; } )
 
const int N = 3e5 + 9;
const int mod = 1e9 + 7;
//int dx[]={1,0,-1,0,1,-1,-1,1};
//int dy[]={0,1,0,-1,1,1,-1,-1};
ll inv[N];

ll nck(ll n, ll r)
{
    ll ans = 1;
    for (int i = 1; i <= r; i++){
        ans = ans * (n - i + 1) % mod * inv[i] % mod;
    }
    return ans % mod;
}
ll bigmod(ll a, ll b)
{
    if(!b)
        return 1;
    ll x = bigmod(a, b / 2);
    x = (x * x) % mod;
    if(b&1)
        x = (x * a) % mod;
    return x;
}
int main()
{
    ll n, a, b, i;
    cin >> n >> a >> b;
    inv[1] = 1;
    for (i = 2; i <= 200005; i++){
        inv[i] = (mod - (mod / i) * inv[mod % i] % mod) % mod;
    }
    cout << (bigmod(2, n) + mod-nck(n, a)-nck(n, b)+mod-1)% mod << nl;
}

Measured memory_bytes: 1792
from sys import stdin

lines = stdin.readlines()
N, M = map(int, lines[0].split())
sn = [[int(j) for j in i.split()[1:]] for i in lines[1:-1]]
pn = (int(i) for i in lines[-1].split())
# s[スイッチID]
# 2進数における桁はそのスイッチを使用している電球
s = [0] * N
for i in range(M):
    for j in sn[i]:
        s[j - 1] |= (1 << i)
# p
# 2進数における桁は電球 ゼロイチをそのまま2進数とする
p = 0
for i, j in enumerate(pn):
    p |= (1 << i) if j == 1 else 0


def f(P, i):
    # 再帰
    # 順にスイッチを見ていく
    if len(s) == i:
        return 1 if P == p else 0
    # 場合の数
    # そのスイッチを使用しなかった場合 + 使用した場合
    return f(P, i + 1) + f(P ^ s[i], i + 1)


def main():
    print(f(0, 0))


main()


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

int main()
{
	char c;
	int english[26] = { 0 };

	while (cin >> c) {
		if ('A' <= c&&c <= 'Z') {
			english[c - 'A']++;
		}
		else if ('a' <= c&&c <= 'z') {
			english[c - 'a']++;
		}
	}

	for (char i = 'a'; i != '{'; i++) {
		cout << i << " : " << english[i - 'a'] << endl;
	}

	return 0;
}


Measured memory_bytes: 3088
A, B, M = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
price1 = min(a) + min(b)

for _ in range(M):
  x, y, c = map(int,input().split())
  price2 = a[x-1] + b[y-1] - c
  if price1 > price2:
    price1 = price2
print(price1)

Measured memory_bytes: 18612
#include <iostream>
#include <vector>

std::vector<long long> common_divisors(long long a, long long b) {
	if (a > b) std::swap(a, b);
	std::vector<long long> ret(0), st(0);
	for (int i = 1; i <= a / i; i++) {
		if (a % i == 0) {
			if (b % i == 0) ret.push_back(i);
			if (b % (a / i) == 0 && i < a / i) st.push_back(a / i);
		}
	}
	while (st.size()) {
		ret.push_back(st.back());
		st.pop_back();
	}
	return ret;
}

bool is_prime(long long n) {
	if (n < 2) return false;
	if (n == 2) return true;
	if (n % 2 == 0) return false;
	for (int i = 3; i <= n / i; i += 2) {
		if (n % i == 0) return false;
	}
	return true;
}

int main() {
	long long a, b;
	std::cin >> a >> b;
	std::vector<long long> v = common_divisors(a, b);
	long long ans = 1;
	for (auto i : v) {
		if (is_prime(i)) ans++;
	}
	std::cout << ans << '\n';

	return 0;
}

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

int main(){
  	int n,k,i;
	cin>>n>>k;
  	bool snukes[n+1];
  	for(i = 0; i<=n; i++){
    	snukes[i] = false;
    }
  	for(int j = 0; j<k; j++){
    	int d;
      	cin>>d;
      	for(i = 0; i<d; i++){
        	int s;
          	cin>>s;
          	snukes[s] = true;
        }
    }
  	int count = 0;
  	for(i = 1; i<=n; i++){
    	if(snukes[i] == false) count++;
    }
  	cout<<count<<endl;
}


Measured memory_bytes: 3648
#include<algorithm>
using namespace std;
int n,ans,a[100001];
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++)scanf("%d",&a[i]);
	for (int i=1;i<=n;i++)
		if (a[i]==i)
		{
			swap(a[i+1],a[i]);
			ans++;
		}
	printf("%d",ans);
}

Measured memory_bytes: 2076
#include <bits/stdc++.h>
#include <limits>
#include <math.h>
#include <cmath>
#include <cctype>
#include <cstdio>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pll = pair<ll, ll> ;
using vs = vector<string>;
using vb = vector<bool>;
using vll = vector<long long>;
using vvll = vector<vector<long long >>;
#define PI  3.1415926535
#define rep(i, k, n) for(ll i = k; i < n; i++)

vector<vector<char>> maze; //迷路を表す文字列
vvll cnt; //何回目の操作後に黒になったか
ll INF = 10000000000;

ll r, c; 
ll dy[4] = {0, 1, 0, -1};
ll dx[4] = {1, 0, -1, 0};

void bfs(){
  queue<pll> que;
  
  //黒の位置をキューに入れる
  rep(i, 0, r){
    rep(j, 0, c){
      if(maze[i][j] == '#'){que.push(pll(i, j)); cnt[i][j] = 0;}
    }
  }
  
  //キューが空になるまでループ
  while(que.size()){
    //キューの先頭を取り出す
    pll p = que.front();
    que.pop();
    
    //移動四方向ループ
    rep(i, 0, 4){
      //移動後の点(nx,ny)
      ll ny = p.first + dy[i];
      ll nx = p.second + dx[i];
      //移動可能か、すでに訪れているか判定
      if(ny >= 0 && ny < r && nx >= 0 && nx < c && cnt[ny][nx] == INF && maze[ny][nx] != '#'){
        //移動できるならキューに入れ、その点をpの距離＋１にする
        que.push(pll(ny, nx));
        cnt[ny][nx] = cnt[p.first][p.second] + 1;
      }
    }
  }
      
  return;
}
      

int main(){
  cin >> r >> c;
  
  maze = vector<vector<char>> (r,vector<char>(c));
  cnt = vvll (r,vll(c,INF));
  ll ans = 0;
  
  rep(i, 0, r){
    rep(j, 0, c){
      cin >> maze[i][j];
    }
  }
  
  bfs();
  
  rep(i, 0, r){
    rep(j, 0, c){
      if(cnt[i][j] > ans){ans = cnt[i][j];}
    }
  }
  cout << ans << endl;
}






Measured memory_bytes: 28288
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int N,A,B;
ll v[50];

ll mem[100][100];
ll nCr(ll n,ll r){
  if(mem[n][r]>0)return mem[n][r];
  if(r==n)return 1;
  if(r==0)return 1;
  return mem[n][r]=nCr(n-1,r-1)+nCr(n-1,r);
}

int main(){
  cin>>N>>A>>B;
  for(int i=0;i<N;i++){
    cin>>v[i];
    v[i]*=-1;
  }
  sort(v,v+N);
  
  ll sum=0;
  ll p=v[A-1];
  for(int i=0;i<A;i++){
    sum-=v[i];
  }
  
  printf("%.10f\n", (double)sum / (double)A );
  
  ll si=lower_bound(v,v+N,p) - v;
  ll ti=upper_bound(v,v+N,p) - v;

  ll ans=0;
  for(ll i=A;i<=B;i++){
    
    if(ti<i)break;
    if(si>0&&i>A)break;
    ll j=i-si;

    

    ans+= nCr(ti-si, j);
  }
  cout<< ans <<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

void chmax(P &a, P b){if(a < b) a = b;}

bool operator < (P a, P b){
    return a.first * (b.first + b.second) < b.first * (a.first + a.second);
}

int main(){
    int A, B, C, D, E, F; cin >> A >> B >> C >> D >> E >> F;
    P res = P(0, 100*A);
    for(int a = 0; a <= F; a += 100*A){
        for(int b = 0; a + b <= F; b += 100*B){
            int water = a+b;
            int mx = min(F-water, E*(water/100));
            for(int c = 0; c <= mx; c += C){
                for(int d = 0; c + d <= mx; d += D){
                    int sugar = c + d;
                    P tmp = P(sugar, water);
                    //chmax(res, tmp);
                    if(res.first*(tmp.first+tmp.second) < tmp.first*(res.first+res.second)){
                        res = tmp;
                    }
                }
            }
        }
    }
    cout << res.first + res.second << " " << res.first << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  ll n;
  cin >> n;
  ll tmp = 0;
  rep(i, n) {
    ll a; cin >> a;
    if (a%2) tmp++;
  }
  if (tmp) cout << "first" << endl;
  else cout << "second" << endl;
}

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

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

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

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)
#define FORR(i,n,m) for(int i=n-1;i>=m;i--)
#define ARR(array) for(int i=0;i<array.size();i++)
#define all(in) in.begin(),in.end()
#define ALL(in,K) in,in+K
#define INF 1e18
#define MOD 100000007
#define SIZE 10005
#define PI 	3.14159265358979323846

unsigned euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

ll input(){
  ll a;
  cin >> a;
  return a;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,a,b,c,d;
    string s;
    cin >> n >> a >> b >> c >> d >> s;
    bool arr[200050];
    REP(i,n)arr[i]=(s[i]=='#'?1:0);
    bool ok=1;
    if(c<d){
      FOR(i,b-1,d-1){
        if(arr[i]==1&&arr[i+1]==1){
          ok=0;
          break;
        }
      }
    }else{
      ok=0;
      FOR(i,b-1,d){
        if(arr[i-1]==0&&arr[i]==0&&arr[i+1]==0){
          ok=1;
          arr[i] = 1;
          b = i;
          break;
        }
      }
    }

    FOR(i,a-1,c-1){
      if(arr[i]==1&&arr[i+1]==1){
        ok=0;
        break;
      }
    }
    if(c>d){
      FOR(i,b-1,d-1){
        if(arr[i]==1&&arr[i+1]==1){
          ok=0;
          break;
        }
      }
    }
    if(ok){
      cout << "Yes" << endl;
      return 0;
    }else{
      cout << "No" << endl;
      return 0;
    }
}


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

int s;
bool used[10];

int countup( int n, int sum, int pre ){
    if( n == 0 ){
        if( sum == s ){
            return 1;
        }
        return 0;
    }
    int ret = 0;
    for( int i=pre; i<10; i++ ){
        if( !used[i] ){
            used[i] = true;
            ret += countup( n-1, sum+i, i+1 );
            used[i] = false;
        }
    }
    return ret;
}

int main(){
    int n;
    while( cin >> n >> s, n||s ){
        for( int i=0; i<10; i++ )
            used[i] = false;
        cout << countup(n, 0, 0) << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
# Stone Monument
a,b = gets.chomp.split(" ").map(&:to_i)
array = Array.new()
for i in 1..999 do
    if i == 1
    array[i-1] = i
    else
        array[i-1] = array[i-2] + i
    end
end
for i in 0..array.length-2 do
    if array[i+1] - array[i] == b - a 
        puts (array[i] - a)
        break
    end
end

Measured memory_bytes: 1788
//Author: Fuadul Hasan(fuadul202@gmail.com)
//BSMRSTU,Gopalganj
#include<bits/stdc++.h>
using namespace std;int tc = 1;
#define happy ios::sync_with_stdio(false);
#define coding  cin.tie(0);
#define F first
#define S second
#define mp make_pair
#define ll long long
#define Pi atan(1)*4
#define pb  push_back
#define vpr vector<pr> 
#define pr pair<int, int> 
#define vi std::vector<int>
#define vll std::vector<ll>
#define YES printf("YES\n");
#define NO printf("NO\n");
#define Yes printf("Yes\n");
#define No printf("No\n");
#define all(n) n.begin(),n.end()
#define point(x) setprecision(x)
#define Test printf("Case %d: ",tc++);
#define Unique(c) (c).resize(unique(all(c))-(c).begin())
#define vout(v) for (auto z: v) cout << z << " "; cout << endl;

#define error(args...) {vector<string>_v=split(#args,',');err(_v.begin(),args);cout<<endl;}
vector<string> split(const string &s, char c) {vector<string>v; stringstream ss(s); string x;
while (getline(ss, x, c))v.emplace_back(x); return move(v);} void err(vector<string>::iterator it) {}
template<typename T, typename... Args>void err(vector<string>::iterator it, T a, Args...args) {
cout << it->substr((*it)[0] == ' ', it->length()) << " = " << a << " "; err(++it, args...);}

const int M = 1e9 + 7;
const ll  Inf = (ll)2e18 + 5;
const int N   = 2e5 + 5;
ll vis[N],res[N];

int solve() 
{
    //happy coding

    int n,m;
    int mn = INT_MAX;
    cin>>n>>m;
    for(int i=0;i<n;i++){
        int a,b;
        cin>>a>>b;
        if(b<=m){
            mn = min(mn,a);
        }
    }

   if(mn == INT_MAX) cout<<"TLE"<<endl;
   else cout<<mn<<endl;
    

    
    return 0;
}
int main(){
    int test = 1;
      //scanf("%d", &test);
      while (test--)solve();return 0;
}

Measured memory_bytes: 256
n, m, x = map(int, input().split())
a = list(map(int, input().split()))

cost_l = 0
cost_r = 0

# left
for i in range(x-1, -1, -1):
    if i in a:
        cost_l += 1

#right
for i in range(x+1, n+1, 1):
    if i in a:
        cost_r += 1

print(min(cost_l, cost_r))

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


int main(){
    string S; cin >> S;
    int res=0;
    int count=0;
    rep(i, S.size()) {
        if(S[i] == 'A' || S[i] == 'T' || S[i] == 'G' || S[i] == 'C') count++;
        else {
            res = max(res, count);
            count = 0;
        }
    }
    cout << max(res, count) << endl;
}
   

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

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

bool check[100][100][4] = { false };
int cost[100][100][4];

class Node{
public:
	int x;
	int y;
	int way;//0 -> up, 1 -> right, 2 -> down, 3-> left
	int num;

	Node(){ x = 0; y = 0; way = 0; num = 0; }
	Node(int x, int y, int way, int num) : x(x), y(y), way(way), num(num){}

};

bool operator< (const Node &n1, const Node &n2){
	return n1.num < n2.num;
}

bool operator>(const Node &n1, const Node &n2){
	return n1.num > n2.num;
}

int main(void){

	int w, h;
	int map[100][100];
	int c[4];

	while (cin >> w >> h, w, h){
		for (int i = 0; i < 100; i++){
			for (int j = 0; j < 100; j++){
				cost[j][i][3] = cost[j][i][2] = cost[j][i][1] = cost[j][i][0] = INF;
			}
		}

		for (int i = 0; i < 100; i++){
			for (int j = 0; j < 100; j++){
				check[j][i][3] = check[j][i][2] = check[j][i][1] = check[j][i][0] = false;
			}
		}

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

		cin >> c[0] >> c[1] >> c[2] >> c[3];

		priority_queue<Node, vector<Node>, greater<vector<Node>::value_type> > que;

		que.push(Node(0, 0, 1, 0));

		while (!que.empty()){
			Node buff = que.top();
			que.pop();

			//cout << "hoge!" << endl;

			if (check[buff.y][buff.x][buff.way]) continue;
			check[buff.y][buff.x][buff.way] = true;
			cost[buff.y][buff.x][buff.way] = min(cost[buff.y][buff.x][buff.way] , buff.num);

			if ((buff.x == w - 1) && (buff.y == h - 1)){
				cout << buff.num << endl;
				break;
			}

			if (map[buff.y][buff.x] != 4){
				int next_way = (buff.way + map[buff.y][buff.x]) % 4;
				int next_x = buff.x + dx[next_way];
				int next_y = buff.y + dy[next_way];
				if (0 <= next_x && next_x < w && 0 <= next_y && next_y < h)
					que.push(Node(next_x, next_y, next_way, buff.num));
			}

			for (int i = 0; i < 4; i++){
				int next_x = buff.x + dx[i];
				int next_y = buff.y + dy[i];
				if (0 <= next_x && next_x < w && 0 <= next_y && next_y < h)
					que.push(Node(next_x, next_y, i, buff.num + c[(4 + i - buff.way) % 4]));

			}


		}
		/*
		for (int j = 0; j < h; j++){
			for (int i = 0; i < w; i++){
				cout << min(cost[j][i][0], min(cost[j][i][1], min(cost[j][i][2], cost[j][i][3]))) << "\t";
			}
			cout << endl;
		}
		*/

	}

	return 0;
}

/*
for(i=0;i<N;i++){
cin >> X[i];
}


for(i=0;i<N;i++){
for(j=0;j<N;j++){
cin >> X[i][j];
}
}
*/

Measured memory_bytes: 1664
def main():
    k, n = map(int, input().split(" "))
    a = list(map(int, input().split(" ")))
    d =[min(a)+k-max(a)]
    for i in range(n-1):
        d.append(a[i+1]-a[i])
    print(k-max(d))
    

if __name__ == "__main__":
    main()

Measured memory_bytes: 32252
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
# define ALL(x)     (x).begin(),(x).end()
# define UNIQ(c)    (c).erase(unique(ALL((c))), end((c)))
# define mp         make_pair
# define eb         emplace_back
# define FOR(i,a,b) for(int i=(a);i<(b);++i)
# define REP(i,n)   FOR(i,0,n)
# define INIT       std::ios::sync_with_stdio(false);std::cin.tie(0);

LL n, m, k, a[200100];
LL memo[200100];

LL dp(LL p) {
	LL res = LINF, minl = LINF, maxl = -1;
	if (p == 0)return memo[p] = k;
	if (p == -1)return 0;
	if (memo[p] != -1)return memo[p];
	for (LL c = 1; c <= m; c++) {
		if (p - c + 1 < 0)break;
		minl = min(minl, a[p - c + 1]);
		maxl = max(maxl, a[p - c + 1]);
		res = min(res, dp(p - c) + k + c*(maxl - minl));
	}
	return memo[p] = res;
}

int main() {
	for (int i = 0; i < 200100; i++)memo[i] = -1;
	cin >> n >> m >> k;
	for (int i = 0; i < n; i++)cin >> a[i];
	cout << dp(n - 1) << endl;
}

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

string J(string s){
  if(s.length()==0)return s;
  string ret="";
  ret+=s[s.length()-1];
  for(int i=0; i<s.length()-1; i++)ret+=s[i];
  return ret;
}
string C(string s){
  if(s.length()==0)return s;
  string ret="";
  for(int i=1; i<s.length(); i++)ret+=s[i];
  ret+=s[0];
  return ret;
}
string E(string s){
  if(s.length()==0)return s;
  string ret1="", ret2="";
  for(int i=0; i<s.length()/2; i++)ret1+=s[i];
  for(int i=(s.length()+1)/2; i<s.length(); i++)ret2+=s[i];
  if(s.length()%2==1)ret2+=s[s.length()/2];
  return ret2+ret1;
}
string A(string s){
  reverse(s.begin(), s.end());
  return s;
}
string P(string s){
  for(int i=0; i<s.length(); i++){
    if('0'<=s[i]&&s[i]<='9'){
      if(s[i]=='0')s[i]='9';
      else s[i]-=1;
    }
  }
  return s;
}
string M(string s){
  for(int i=0; i<s.length(); i++){
    if('0'<=s[i]&&s[i]<='9'){
      if(s[i]=='9')s[i]='0';
      else s[i]+=1;
    }
  }
  return s;
}

int main(){
  int n;
  cin>>n;
  while(n--){
    string p, m;
    cin>>p;
    cin>>m;
    for(int i=p.length()-1; i>=0; i--){
      if(p[i]=='J')m=J(m);
      if(p[i]=='C')m=C(m);
      if(p[i]=='E')m=E(m);
      if(p[i]=='A')m=A(m);
      if(p[i]=='P')m=P(m);
      if(p[i]=='M')m=M(m);
    }
    cout<<m<<endl;
  }
  return 0;
}

Measured memory_bytes: 1216
#include <cstdio>

int main() {
    int x, a, b;
    scanf("%d %d %d", &x, &a, &b);

    int eat = -a + b;
    if (eat <= 0)
        printf("delicious");
    else if (eat <= x)
        printf("safe");
    else
        printf("dangerous");

    return 0;
}


Measured memory_bytes: 128
import java.math.*;
import java.util.*;
import java.util.function.*;
 
public class Main {
  private static long path(int[][] edge, int parent_node, int src_node, int target_node) {
    int[] dist_edges = edge[src_node];
    for (int dist_node = 1; dist_node < dist_edges.length; dist_node++) {
      int edge_no = dist_edges[dist_node];
      if (edge_no == 0) continue;
      if (dist_node == parent_node) continue;
      if (dist_node == target_node) return 1L << edge_no - 1;
      long path = path(edge, src_node, dist_node, target_node);
      if (path == 0) continue;
      return  (1L << edge_no - 1) | path;
    }
    return 0L;
  }

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] a = new int[N];
    int[] b = new int[N];
    for (int i = 1; i < N; i++) {
      a[i] = sc.nextInt();
      b[i] = sc.nextInt();
    }
    int M = sc.nextInt();
    int[] u = new int[M];
    int[] v = new int[M];
    for (int i = 0; i < M; i++) {
      u[i] = sc.nextInt();
      v[i] = sc.nextInt();
    }
    sc.close();

    int[][] edge = new int[N + 1][N + 1];
    for (int i = 1; i < N; i++) {
      edge[a[i]][b[i]] = i;
      edge[b[i]][a[i]] = i;
    }

    long[] path = new long[M];
    for (int i = 0; i < M; i++)
      path[i] = path(edge, 0, u[i], v[i]);

    long ans = 0;
    long mmax = 1L << M;
    for (long i = 0; i < mmax; i++) {
      long p = 0;
      long m = i;
      for (int j = 0; m != 0 && j < M; j++) {
        if ((m & 1) == 1) p |= path[j];
        m >>>= 1;
      }
      long ng_case = 1L << (N - 1 - Long.bitCount(p));
      if ((Long.bitCount(i) & 1) == 1) {
        ans -= ng_case;
      } else {
        ans += ng_case;
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 23380
import java.util.Scanner;

public class Main {


	public static final long pow(long x, long n) {
	    long sum = 1;
	    while (n > 0) {
	        if ((n & 1) == 1) {
	            sum *= x;
	        }
	        x *= x;
	        n >>= 1;
	    }
	    return sum;
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int men = sc.nextInt();
		int mokuhyo = sc.nextInt();
		double answer=0;
		double dicekakuritu = (double)1 / men;
		for (int i = 1; i <= men; i++) {

			int coinnum = 0;
			int value = i;
			while (value < mokuhyo) {
				value *=2;
				coinnum++;
			}
			if(coinnum==0) {
				answer+=dicekakuritu;
			}else {
			double coinkakuritu =(double)1/ pow(2, coinnum);
			answer+=dicekakuritu*coinkakuritu;
			}
		}
		System.out.println(answer);
	}


}



Measured memory_bytes: 22868
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>
#include <cstring>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
signed main() {
    int N, K;
    cin >> N >> K;
    if (K == 1) {
        cout << 0 << endl;
        return 0;
    }

    cout << N - K << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;



int main()
{
	string S;
	cin >> S;
	bool step = true;
	int size = 0;
	size = S.size();
	for (int i = 0; i < size; i++) {
		if (i % 2 == 0) {
			if (S[i] == 'L') {
				step = false;
			}
		}
		else if (i % 2 == 1) {
			if (S[i] == 'R') {
				step = false;
			}
		}
		
	}
	if (step == false) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
	int N;
	double R;
	cin >> N;
	if (N%2 == 0){
		cout << 0.5 << endl;
	}
	else {
		R = (N/2+1.0)/N;
		cout << R << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
constexpr int64_t mod=1e9+7;

std::vector<string> v={"SS","SW","WS","WW"};
std::map<string, char> mp_o={
  {"WW",'S'},
  {"WS",'W'},
  {"SS",'S'},
  {"SW",'W'},
},mp_x={
  {"WW",'W'},
  {"WS",'S'},
  {"SS",'W'},
  {"SW",'S'},
};
int main()
{
  int n;
  cin>>n;
  string s;
  cin>>s;
  vector<char> vec(n+1);
  
  for(auto&& e: v) {
    vec[0]=e[0];
    vec[1]=e[1];
    for (int i = 1; i < n; ++i)
    {
      if(s[i]=='o'){
        string tmp={vec[i-1]};
        tmp+=vec[i];
        vec[i+1]=mp_o[tmp];
      }
      else{
        string tmp={vec[i-1]};
        tmp+=vec[i];
        vec[i+1]=mp_x[tmp];
      }
    }
    if(vec[n]==vec[0]){
      string tmp={vec[n-1]};
      tmp+=vec[0];
      char judge;
      if(s[0]=='o') judge=mp_o[tmp];
      else judge=mp_x[tmp];
      if(judge==vec[1]) {
        for (int i = 0; i < n; ++i)
        {
          cout<<vec[i];
        }
        return 0;
      }
    }
  }
  cout<<-1;
}

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

int main(void) {
	int X,mod;
	cin>>X;
	mod=X/100;
	
    
	if(mod*5-(X-100*mod)>=0){
		cout<<1<<endl;
	}
	else{
		cout<<0<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h> 

using namespace std;
int main(){
	int n;
	cin>>n;
	string s;
	cin>>s;
	int x=0,mx=0;
 for(int i=0;i<n;++i){
    if(s[i]=='I')
        x++;
    mx=max(x,mx);
    if (s[i]=='D')
        x--;
 }
 cout<<mx<<endl;
	return 0;
}

Measured memory_bytes: 256
/* template.cpp(shinobu_menkoi) {{{ */
#include <bits/stdc++.h>
using namespace std;

// clang-format off
#define GET_MACRO(_1, _2, _3, _4, NAME, ...) NAME
#define rep(...) GET_MACRO(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rep1(n) rep2(_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, n) rep4(i, a, n, 1)
#define rep4(i, a, n, s) for (lint i = (a); i < (lint)(n); i += (s))
#define rrep(...) GET_MACRO(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define rrep1(a) rrep2(_, a)
#define rrep2(i, a) rrep3(i, a, 0)
#define rrep3(i, a, n) rrep4(i, a, n, 1)
#define rrep4(i, a, n, s) for (lint i = (a); i >= (lint)(n); i -= (s))
#define each(i, ctn) for (auto &&i : (ctn))

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define all(v) begin(v), end(v)
#define debug(x) cerr << (x) << " (L:" << __LINE__ << ")" << '\n'
#define TEMP_T template <class T>
#define TEMP_TU template <class T, class U>

TEMP_T using vec = vector<T>;
TEMP_T using heap = priority_queue<T>;
TEMP_T using minheap = priority_queue<T, vec<T>, greater<T>>;
using lint = long long;
using ulint = unsigned long long;
using ld = long double;
using vi = vec<int>;
using vvi = vec<vi>;
using vvvi = vec<vvi>;
using pii = pair<int, int>;
using vs = vec<string>;

TEMP_TU ostream &operator<<(ostream &os, const pair<T, U> &p) { return os << p.fi << " " << p.se; }
TEMP_TU istream &operator>>(istream &is, pair<T, U> &p) { return is >> p.fi >> p.se; }

const int INF{1001001001};
const lint LINF{1001001001001001001ll};
const int MOD{(int)1e9 + 7};
const double EPS{1e-9};
const double PI{acos(-1)};
const int dx[]{0, 1, 0, -1, 1, -1, 1, -1}, dy[]{1, 0, -1, 0, 1, -1, -1, 1};

inline bool inside(int y, int x, int h, int w) { return y >= 0 && x >= 0 && y < h && x < w; }
TEMP_T inline bool chmin(T &a, const T &b) { if (a > b) a = b; return a > b; }
TEMP_T inline bool chmax(T &a, const T &b) { if (a < b) a = b; return a < b; }
TEMP_T inline void print(const T &x) { cout << x << '\n'; }
TEMP_T inline void print(const vec<T> &v, string d = "\n") { rep(i, v.size()) cout << v[i] << (i == (lint)v.size() - 1 ? "\n" : d); }
template <class T = int> inline T in() { T x; cin >> x; return x; }
template <class T = string> vec<T> split(const string &s, char d = ',') {
  vec<T> v; stringstream ss(s); for (string b; getline(ss, b, d); ) {
    stringstream conv(b); T t; conv >> t; v.eb(t); } return v;
}
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(12); } } pre__;
// clang-format on
/* }}} */

signed main() {
  int n = in();
  vi v(n);
  rep(i, n) v[i] = in();
  print(*max_element(all(v)) - *min_element(all(v)));
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int mn=1e5+10;
typedef long long ll;
int x,y,z;
struct node {
	ll a,b,c;
} d[mn];
ll sc,ans,l[mn],r[mn];
struct cmp {
	bool operator() (ll x,ll y) {
		return x>y;
	}
};
priority_queue<ll,vector<ll>,cmp> q,p;
bool cmp(node x,node y) {
	return x.a-x.b<y.a-y.b;
}
int main() {
	scanf("%d %d %d",&x,&y,&z);
	for (int i=1;i<=x+y+z;i++)
		scanf("%lld %lld %lld",&d[i].a,&d[i].b,&d[i].c);
	sort(d+1,d+(x+y+z+1),cmp);
	sc=0;
	for (int i=1;i<=x+y+z;i++) {
		d[i].a-=d[i].c;
		d[i].b-=d[i].c;
		sc+=d[i].c;
	}
	l[0]=0;
	int t;
	for (int i=1;i<=y;i++) {
		t=d[i].b;
		q.push(t);
		l[i]=l[i-1]+t;
	}
	for (int i=y+1;i<=x+y+z;i++) {
		if (d[i].b<=q.top()) {
			l[i]=l[i-1];
			continue;
		}
		t=d[i].b;
		q.push(t);
		l[i]=l[i-1]+t;
		l[i]-=q.top();
		q.pop();
	}
	r[x+y+z+1]=0;
	for (int i=x+y+z;i>y+z;i--) {
		t=d[i].a;
		p.push(t);
		r[i]=r[i+1]+t;
	}
	for (int i=y+z;i>=1;i--) {
		if (d[i].a<=p.top()) {
			r[i]=r[i+1];
			continue;
		}
		t=d[i].a;
		p.push(t);
		r[i]=r[i+1]+t;
		r[i]-=p.top();
		p.pop();
	}
	for (int i=y;i<=y+z;i++)
		if (i==y)
			ans=l[i]+r[i+1];
		else ans=max(ans,l[i]+r[i+1]);
	printf("%lld\n",ans+sc);
	return 0;
}

Measured memory_bytes: 5240
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#include<queue>
#include<stack>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)

using namespace std;

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

    ll N;
    string A, B, C;
    cin >> N >> A >> B >> C;

    ll ans = 0;
    Rep (i, N) {
        set<char> letter;
        letter.insert(A[i]);
        letter.insert(B[i]);
        letter.insert(C[i]);

        ans += letter.size() - 1;
    }

    cout << ans << endl;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;

int a, b;

int main() {
    cin >> a >> b;
    cout << (a + b) % 24 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}


int main()
{
    int n, m;
    cin >> n >> m;
    cout << (n*(n-1)/2) + (m*(m-1)/2) << endl;

}



Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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

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

vector<int> ps;

int main(void) {
    int N, K;
    cin >> N >> K;

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

    double cand = 0.0;
    for (int i = 0; i < K; i++) {
        cand += (double(ps[i]) + 1.0) / 2.0;
    }

    double ans = cand;
    // printf("ans: %f, cand: %f\n", ans, cand);

    for (int i = K; i < N; i++) {
        cand -= (double(ps[i - K]) + 1.0) / 2.0;
        cand += (double(ps[i]) + 1.0) / 2.0;
        chmax(ans, cand);
        // printf("ans: %f, cand: %f\n", ans, cand);
    }

    printf("%.7f\n", ans);

    return 0;
}


Measured memory_bytes: 1024
A, B, C, D = map(int, input().split())


# 最大公約数
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


# 最小公倍数
def lcm(a, b):
    return a * b // gcd(a, b)


LCM = lcm(C, D)


def calc(n):
    div_c = n // C
    div_d = n // D
    div_c_d = n // LCM
    return n - div_c - div_d + div_c_d


print(calc(B) - calc(A - 1))


Measured memory_bytes: 3064
#include <iostream>
#include <utility>
#include <cmath>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#define MAX_N 100005
#define PRINT_NAME(Variable) cout<<(#Variable)<<": "<<(Variable)<<endl;


using namespace std;
typedef long long ll;

int N,Q;
vector<ll> A;
vector<ll> sum,esum; //i*2番目までの偶数番目の和
ll X;

int main(){
    int N,Q;
    cin >> N >> Q;
    A.resize(N);
    sum.resize(N);
    esum.resize((N+1)/2);
    for(int i = 0;i < N;i++){
        cin>>A[i];
    }
    sum[0]=A[0];
    esum[0]=A[0];
    for(int i = 1;i < N;i++){
        sum[i]=sum[i-1]+A[i];
    }
    for(int i = 1;i < (N+1)/2;i++){
        esum[i]=esum[i-1]+A[i*2];
    }
//    for(int i = 0;i < N;i++){
//        cout<<sum[i]<<" "<<esum[i]<<endl;
//    }

    for(int fjsa=0;fjsa<Q;fjsa++){
        cin>>X;
        ll ans = 0;
        int I,J;
        int left = 0,right = N;
        int Acount,Tcount;
        while(right-left>1){
            int mid = (left+right)/2;
            ll range = A[mid]-X;
            if(range<0){
                left = mid;
                continue;
            }
            Acount = mid+1-(lower_bound(A.begin(),A.end(),X-range)-A.begin());
            Tcount = N-mid-1;
            if(Acount>Tcount){
                right = mid;
            }else{
                left = mid;
            }
        }
        J=left;
        Tcount = N-J-1;
        I=J-Tcount;
//        cout<<"I: "<<I<<" J: "<<J<<endl;
        ans += sum[N-1]-sum[J];
        if(I>=0){
            if(I%2==1){
                ans += sum[I] - esum[I/2];
            }else{
                ans += esum[I/2];
            }
        }
        cout<<ans<<endl;
    }
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  ll A,B;
  cin >> A >> B;
  ll GCD = __gcd(A,B);
  vector<pair<ll,ll>> prime;
  ll cnt = -1;
  for (ll i = 2; i * i < GCD; i++) {
    if (GCD % i == 0) {
      prime.push_back(make_pair(i,0));
      cnt++;
      while (GCD % i == 0) {
        GCD /= i;
        prime[cnt].second++;
      }
    }
  }
  if (GCD != 1) prime.push_back(make_pair(GCD,1));
  cout << prime.size() + 1 << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = 1e9 + 7;
ll power(ll x, ll n)
{
    if (n == 0)
        return 1;
    if (n == 1)
        return x;
    ll y = power(x, n / 2) % MOD;
    return (y * y % MOD) * power(x, n % 2) % MOD;
}
int main()
{
    int n;
    cin >> n;
    cout << ((power(10, n) - power(9, n) - power(9, n) + power(8, n)) % MOD + MOD) % MOD << endl;
}


Measured memory_bytes: 3516
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }     //最小公倍数
using Graph = vector<vector<ll>>;
ll inf=300000000000000000;
const double PI = 3.14159265358979323846;

struct UnionFind {
  vector<int> data;
  UnionFind(int size) : data(size, -1) { }
  bool unionSet(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool findSet(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};

int main(){
  int h,w;
  cin >> h >> w;
  int k[h][w];
  rep(i,h){
    string s;
    cin >> s;
    rep(j,w){
      if(s[j]=='#')k[i][j]=0;
      else k[i][j]=1;
    }
  }
  //rep(i,h)rep(j,w)cout << k[i][j] << endl;
  UnionFind u(h*w);
  rep(i,h){
    rep(j,w){
      if(i!=0){
        if(k[i][j]!=k[i-1][j]){
          u.unionSet(i*w+j,(i-1)*w+j);
          //cout << i << " " << j << " " << u.size(i*w+j) << " " << u.root(i*w+j) <<  endl;        
        }
      }
      if(j!=0){
        if(k[i][j]!=k[i][j-1]){
          u.unionSet(i*w+j,i*w+j-1);
          //cout << -111111 << " " << i << " " << j << endl;
        }
      }
    }
  }
  vector<ll> black(160000,0);
  vector<ll> white(160000,0);
  rep(i,h){
    rep(j,w){
      if(k[i][j]==0)black[u.root(i*w+j)]++;
      else white[u.root(i*w+j)]++;
    }
  }
  ll ans=0;
  rep(i,160000){
    //cout << i << " " << black[i] << " " << white[i] << endl;
    ans+=black[i]*white[i];
  }
  cout << ans << endl;
}   


Measured memory_bytes: 3968
def main():
  n,k=map(int,input().split())
  a=list(map(int,input().split()))
  b=1
  seen=[-1]*n
  c=0
  while seen[b-1]==-1:
    seen[b-1]=c
    b=a[b-1]
    c+=1
  start=seen[b-1]
  end=c
  k=min(k,start+(k-start)%(end-start))
  b=1
  for _ in range(k):
    b=a[b-1]
  print(b)
if __name__=='__main__':
  main()


Measured memory_bytes: 32308
N = int(input())
xy = [list(map(int,input().split())) for i in range(N)]

total = 0
for i in range(N-1):
    for j in range(i+1,N):
        total += ((xy[i][0]-xy[j][0])**2+(xy[i][1]-xy[j][1])**2)**0.5
        
        
n = 2/N
ans = total*n
print(ans)

Measured memory_bytes: 3188
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<climits>
#include<numeric>
#include<cmath>
#include<cstring>
#include<deque>
#include<map>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define VSORT(v) sort(v.begin(), v.end());
#define VE vector<int>
#define VEP vector<pair<int,int>>
#define llong long long
#define pb(a) push_back(a)
using namespace std;
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}
int main() {
	int n;
	string str;
	cin >> n;
	cin >> str;
	if (n >= 3200) {
		cout << str << endl;
	}
	else {
		cout << "red" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int w = scan.nextInt();
        int n = scan.nextInt();
        int[] ab = new int[w+1];
        for(int i=1;i<=w;i++)ab[i]=i;
        for(int i=0;i<n;i++){
            String s = scan.next();
            String[] x = s.split(",");
            int aa = Integer.parseInt(x[0]);
            int bb = Integer.parseInt(x[1]);
            int t = ab[aa];
            ab[aa] = ab[bb];
            ab[bb]=t;
        }
        for(int i=1;i<=w;i++){
            System.out.println(ab[i]);
        }
    }
}


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

#define int long long
#define ll unsigned long long
#define pb push_back
#define mp make_pair
#define reset(a, b) memset(a, b, sizeof(a))
#define rep(i,b) for(int i=0; i<b; i++)
#define F first 
#define S second
/*----------------------------------------*/


signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    int T;
    T=1;
//    cin>>T;

while(T--){
    
    int a,b,h,m;
    cin>>a>>b>>h>>m;
    
    float h1,m1;
    h1=((h*60+m)*(0.5));
    m1=((h*60+m)*6)%360;
    
    long double ang=abs(h1-m1), ans;
    ans= sqrt(a*a+b*b-2*a*b*cos((ang/180.0)*M_PI));
    
    printf("%.9Lf",ans);
    
}
    
    return 0;
}

Measured memory_bytes: 4088
#include<bits/stdc++.h>
#define int long long
#define RG register

using namespace std;
template<class T> inline void read(T &x) {
    x = 0; RG char c = getchar(); bool f = 0;
    while (c != '-' && (c < '0' || c > '9')) c = getchar(); if (c == '-') c = getchar(), f = 1;
    while (c >= '0' && c <= '9') x = x*10+c-48, c = getchar();
    x = f ? -x : x;
    return ;
}
template<class T> inline void write(T x) {
    if (!x) {putchar(48);return ;}
    if (x < 0) x = -x, putchar('-');
    int len = -1, z[20]; while (x > 0) z[++len] = x%10, x /= 10;
    for (RG int i = len; i >= 0; i--) putchar(z[i]+48);return ;
}

int n, m, p, tot;

const int N = 2000010;

struct node {
    int ls, rs;
}t[N << 2];

struct Graph {
    int to, nxt, w;
}g[N * 5];
int last[N << 1], gl, pos[N];
inline void add(int x, int y, int z) {
    g[++gl] = (Graph) {y, last[x], z};
    last[x] = gl;   
}

inline void build1(int &rt, int l, int r) {
    rt = ++tot;
    if (l == r) {
        pos[l] = rt;
        return ;
    }
    int mid = (l + r) >> 1;
    build1(t[rt].ls, l, mid), build1(t[rt].rs, mid + 1, r);
    add(t[rt].ls, rt, 0), add(t[rt].rs, rt, 0);
    return ;
}

inline void build2(int &rt, int l, int r) {
    rt = ++tot;
    if (l == r) {
        add(rt, pos[l], 0);
        return ;
    }
    int mid = (l + r) >> 1;
    build2(t[rt].ls, l, mid), build2(t[rt].rs, mid + 1, r);
    add(rt, t[rt].ls, 0), add(rt, t[rt].rs, 0);
    return ;
}

inline void link1(int rt, int l, int r, int L, int R, int C) {
    if (L <= l && r <= R) {
        add(rt, tot, C);
        return ;
    }
    int mid = (l + r) >> 1;
    if (L <= mid)
        link1(t[rt].ls, l, mid, L, R, C);
    if (R > mid)
        link1(t[rt].rs, mid + 1, r, L, R, C);
    return ;
}

inline void link2(int rt, int l, int r, int L, int R,int C) {
    if (L <= l && r <= R) {
        add(tot, rt, C);
        return ;
    }
    int mid = (l + r) >> 1;
    if (L <= mid)
        link2(t[rt].ls, l, mid, L, R, C);
    if (R > mid)
        link2(t[rt].rs, mid + 1, r, L, R, C);
    return ;
}

priority_queue<pair<int, int>, vector<pair<int, int> >, greater<pair<int, int> > >q;

int dis[N << 1];
bool vis[N << 1];

void dijkstra() {
    memset(dis, 127/3, sizeof(dis));
    dis[pos[1]] = 0;
    q.push(make_pair(0, pos[1]));
    while (!q.empty()) {
        while (vis[q.top().second] && !q.empty()) q.pop();
        if (q.empty()) break;
        int u = q.top().second; q.pop();
        vis[u] = 1;
        for (RG int i = last[u]; i; i = g[i].nxt) {
            int v = g[i].to;
            if (dis[v] > dis[u] + g[i].w) {
                dis[v] = dis[u] + g[i].w;
                q.push(make_pair(dis[v], v));
            }
        }
    }
    return ;
}

signed main() {
    read(n), read(m);
    int rt1, rt2;
    rt1 = rt2 = 0;
    build1(rt1, 1, n); build2(rt2, 1, n);
    while (m--) {
        int a, b, c;
        read(a),read(b),read(c);
        ++tot; link1(rt1, 1, n, a, b, c); link2(rt2, 1, n, a, b, c);
        ++tot; link1(rt1, 1, n, a, b, c); link2(rt2, 1, n, a, b, c);
    }
    dijkstra();
    int ans=dis[pos[n]]/2;
    if(ans>1e16) ans=-1;
    printf("%lld",ans);
    return 0;
}

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

int main(){
  int a, b, c;
  
  cin >> a >> b >> c;
  int d = b - a;
  int e = c - b;
  if (d == e){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 3636
from fractions import gcd
from collections import deque
n = int(raw_input())
q = deque()
x = 2
s = 0
for i in xrange(n - 1):
    for j in xrange(x, 30001):
        if j % 2 == 0 or j % 3 == 0 or j % 5 == 0:
            q.append(j)
            x = j + 1
            s += j
            break
while 1:
    for j in xrange(x, 30001):
        if (s + j) % 30 == 0 and gcd(s, j) != 1:
            q.append(j)
            break
    else:
        for j in xrange(x, 30001):
            if j % 2 == 0 or j % 3 == 0 or j % 5 == 0:
                q.append(j)
                s -= q.popleft()
                x = j + 1
                s += j
                break
        continue
    break
while q:
    print q.popleft(),


Measured memory_bytes: 5032
/*
	Author: Luis Manuel Díaz Barón (LUISMO)
	Problem:
	Online Judge:
	Link:
	Idea:
*/
#include<bits/stdc++.h>
// Types
#define ll long long
#define ull unsigned long long
// IO
#define sf scanf
#define pf printf
#define mkp make_pair
#define fi first
#define se second
#define endl "\n"

using namespace std;

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const ll inf = 1e16 + 3;
const int mod = 1e9 + 7;
const int lim = 2e5 + 2;

long double N, A, B;

void solve()
{
	// cout << 99 * 0.1 << endl;
	cin >> A >> B;

	for(int i = 0; i < 1000000; i++)
	{
		long double x = i;
		long double k8 = (x * 0.08);
		long double k10 = (x * 0.1);

		// cout << k8 << " " << k10 << endl;

		if(floor(k8) == A && floor(k10) == B && k8 >= 1)
		{
			cout << x;
			return;
		}
	}
	cout << -1;
}

void fastIO()
{
	cin.sync_with_stdio(false);
	cin.tie(0);
}

void IO()
{
	if(fopen("d:\\lmo.in","r") != NULL)
	{
		freopen("d:\\lmo.in","r",stdin);
	}
	else if(fopen("/media/Beijing/lmo.in","r") != NULL)
	{
		freopen("/media/Beijing/lmo.in", "r", stdin);
	}
}

int main()
{
	IO();

	fastIO();

	solve();
}


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

int main(){
	string str;
	cin >> str;
	size_t size = str.length();
	int ans = 0;
	for (int i = 0; i < size; i++){
		for (int j = 0; j < size - i + 1; j++){
				string s;
				s = str.substr(i, j);
				int count = 0;
				for (int k = 0; k < j; k++){
					if(s[k] == 'A' || s[k] == 'T' || s[k] == 'C' || s[k] == 'G'){
						count++;
					}
				}
				if (count == j){
					if( ans < j){
						ans = j;
					}
				}
		}
	}

	cout << ans << endl;

}

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

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


}



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

void selectionsort(int A[], int N){
  int minj;
  for(int i=N-1;i>=0;i--){
    minj = i;
    for(int j=i-1;j>=0;j--){
      if(A[j]<A[minj]) minj = j;
    }
    if(minj != i){
      swap(A[minj], A[i]);
    }
  }
}

int main(){
  int n, m;
  while(1){
    int sum = 0;
    cin>>n>>m;
    if(!(n * m)) return 0;
    int  P[1000];
    for(int i=0;i<n;i++){
      cin>>P[i];
      sum += P[i];
    }
    selectionsort(P, n);
    for(int i=1;i<=n/m;i++){
      sum -= P[i*m-1];
    }
    cout<<sum<<endl;
  }
}



Measured memory_bytes: 3064
n = int(input())
s = []
for i in range(n):
    s.append(input())
tmp_nums = {"M":0, "A":0, "R":0, "C":0, "H":0}
for i in range(n):
    if s[i][0] in tmp_nums.keys():
        tmp_nums[s[i][0]] += 1
nums=[]
for i in tmp_nums.values():
    nums.append(i)
p = [0,0,0,0,0,0,1,1,1,2]
q = [1,1,1,2,2,3,2,2,3,3]
r = [2,3,4,3,4,4,3,4,4,4]
sum = 0
for i in range(10):
    sum += nums[p[i]]*nums[q[i]]*nums[r[i]]
print(sum)


Measured memory_bytes: 9772