akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

typedef long long lol;
int _w;

char str[101];
int n , bac[19][19];
long long ans , x , bin[19];

lol Read( void ) {
  static int len;
  _w = scanf("%s",str+1);
  len = strlen( str + 1 );
  int cur = 0;
  for( int i = 1 ; i <= len + 1 ; ++i )
    if( str[i] == '\0' || str[i] == '.' ) {
      cur = i;
      break;
    }
  lol res = 0;
  for( int i = 1 ; i <= len ; ++i ) {
    if( i == cur ) continue;
    if( i < cur ) 
      res += ( str[i] - '0' ) * bin[cur - i + 8];
    else res += ( str[i] - '0' ) * bin[9 + cur - i];
  }
  return res;
}

int main( void ) {
  _w = scanf("%d",&n);
  bin[0] = 1;
  for( int i = 1 ; i <= 18 ; ++i ) bin[i] = bin[i - 1] * 10;
  for( int i = 1 , cnt2 , cnt5 ; i <= n ; ++i ) {
    x = Read();
    cnt2 = cnt5 = 0;
    while( ~x & 1 ) ++cnt2 , x /= 2;
    while( x % 5 == 0 ) ++cnt5 , x /= 5;
    cnt2 = min( cnt2 , 18 );
    cnt5 = min( cnt5 , 18 );
    for( int j = 18 - cnt2 ; j <= 18 ; ++j )
      for( int k = 18 - cnt5 ; k <= 18 ; ++k )
        ans += bac[j][k];
    ++bac[cnt2][cnt5];
  }
  cout << ans;
  return 0;
}


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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

// ====================================================================

int main() {
  int n, m;
  cin >> n >> m;
  vector<pair<int, int>> joken(m);
  for (int i = 0; i < m; i++) cin >> joken[i].first >> joken[i].second;

  for (int i = 0; i <= 1500; i++) {
    string s = to_string(i);
    bool can = (s.size() == n);
    for (int j = 0; j < m; j++) {
      if (s[joken[j].first - 1] - '0' != joken[j].second) can = false;
    }
    if (can) {
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1001001001
#define LINF 1001001001001001001
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LLP;

int main() {

  ll N, D;
  cin >> N >> D;

  int ans = 0;
  rep(i,N) {
    ll X, Y;
    cin >> X >> Y;
    if (X * X + Y * Y <= D * D) ans++;
  }

  cout << ans << endl;

  return 0;
}

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

const double PI = 3.14159265358979323846;
//using namespace boost::multiprecision;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 1e15;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
//const ll mod = 1e10;
typedef priority_queue<long long, vector<long long>, greater<long long> > PQ_ASK;


int main() {

    int n;
    cin >> n;
    vector<ll> as(n), bs(n);
    rep(i, n) cin >> as[i];
    rep(i, n) cin >> bs[i];

    ll a_all = accumulate(as.begin(), as.end(), 0ll),
            b_all = accumulate(bs.begin(), bs.end(), 0ll);
    if (a_all > b_all) {
        cout << "No" << endl;
        ret();
    }

    ll turn = b_all - a_all;

    ll a_count = 0;

    for (int i = 0; i < n; i++) {
        if (as[i] == bs[i]) continue;
        if (as[i] < bs[i]) {
            a_count += (bs[i] - as[i] + 1) / 2;
        }
    }

    if (a_count <= turn) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }


}


Measured memory_bytes: 384
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2")
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<vector>
#include<set>
#include<unordered_map>
#include<assert.h>
#include<time.h>
#include<stdlib.h>
#include<random>
#include<queue>
using namespace std;
using lld = long long int;
using pll = pair<lld, lld>;
using lf = double;
using pff = pair<lf, lf>;
using pif = pair<int, lf>;
using pii = pair<int, int>;
using pli = pair<lld, int>;
using pil = pair<int, lld>;
using piii = pair<int, pii>;
#define M 1000000007
lld d[2][4];
int main() {
	int i, j, k, l;
	int t = 1, tv = 0;
	//scanf("%d", &t);
	while (t--) {
		lld n;
		scanf("%lld", &n);
		for (i = 0; i < 4; i++) {
			d[0][i] = d[1][i] = 0;
		}
		d[0][0] = 1;
		int cur = 0;
		int nxt = 1;
		for (int k = 0; k < n; k++) {
			for (i = 0; i < 4; i++) {
				d[nxt][i] = 0;
			}
			d[nxt][0] = (d[cur][0] * 8) % M;
			d[nxt][1] = (d[cur][0] + d[cur][1] * 9) % M;
			d[nxt][2] = (d[cur][2] * 10 + d[cur][1] * 2) % M;
			cur ^= 1;
			nxt ^= 1;
		}
		printf("%lld\n", d[cur][2]);
	}
	return 0;
}

Measured memory_bytes: 1728
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author cherrypi59
 */

#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FFOR(i, a, b) FOR(i, a, b+1)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cerr<<__LINE__<<' '<<#x<<"="<<(x)<<endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

using namespace std;
using lint = long long;
using pii =  pair<int, int>;
using pll =  pair<lint, lint>;
template <typename T> using vc = vector<T>;
template <typename T> using vvc = vector<vector<T>>;
template <typename T> inline bool chmax(T &a, T b){if(a<b){a = b; return true;} return false;}
template <typename T> inline bool chmin(T &a, T b){if(a>b){a = b; return true;} return false;}

constexpr lint ten(int n) {return n==0 ? 1 : ten(n-1)*10;}

class A01Matrix {
public:
    void solve(std::istream& in, std::ostream& out){
        ios_base::sync_with_stdio(false);
        in.tie(nullptr), out.tie(nullptr);
        int H, W, A, B;
        in>>H>>W>>A>>B;
        REP(i, H){
            if(i<B){
                REP(j, A) out<<"1";
                REP(j, W-A) out<<"0";
            }else{
                REP(j, A) out<<"0";
                REP(j, W-A) out<<"1";
            }
            out<<"\n";
        }
    }
};


int main() {
	A01Matrix solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

#define REP(A, H) for(int A = 0; A < H; A++)
#define RREP(A, B, H, W) for(int A = 0; A < H; A++) for (int B = 0; B < W; B++)
#define MAX(A, B) (A = std::max(A, B))
#define MIN(A, B) (A = std::min(A, B))

typedef long long ll;

struct POINT {
  int x; int y;
  POINT(int x, int y) : x(x), y(y) {}
};

POINT operator +(const POINT& a, const POINT& b) {
  return POINT(a.x + b.x, a.y + b.y);
}

POINT operator -(const POINT& a, const POINT& b) {
  return POINT(a.x - b.x, a.y - b.y);
}

/* std::cout << ;*/
/* std::cout << << std::endl; */

int main(void) {
  std::string s;
  std::cin >> s;

  bool f = (s[0] == s[1]) || (s[1] == s[2]) || (s[2] == s[3]);

  std::cout << (f ? "Bad" : "Good") << std::endl;

  return 0;
}

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

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

  vector<int> x(n), y(n);
  for(int i=0;i<n;i++){
    scanf("%d%d",&x[i],&y[i]);
  }

  if(n%2){
    puts("NA");
  }else{
    set< pair<int,int> > med;
    for(int i=0;i<n/2;i++){
      med.insert( make_pair( x[i]+x[i+n/2], y[i]+y[i+n/2] ) );
    }
    if(med.size() != 1){
      puts("NA");
    }else{
      pair<int,int> ans = *med.begin();
      printf("%.2f %.2f\n",ans.first/2.0,ans.second/2.0);
    }
  }
}

Measured memory_bytes: 1224
#pragma GCC optimze("Ofast")
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define mod 1000000007
#define md 998244353
#define trace(...)
#define ll long long int
#define ld long double
#define fi first
#define se second
#define fr(i,a,b) for(ll i=a;i<=b;i++)
#define frr(i,b,a) for(ll i=b;i>=a;i--)
#define mem(a) memset(a, 0, sizeof(a))
#define vpi std::vector<pair<int,int>>
#define pii pair<int,int>
#define pll pair<ll,ll> 
#define pb push_back
#define sall(v) sort(v.begin(),v.end())
#define all(v) (v.begin(),v.end())
#define minf -10000000
#define vi vector<int>
const ll infl=0x3f3f3f3f3f3f3f3fLL;
const int infi=0x3f3f3f3f;
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
auto clk=clock();
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
    uniform_int_distribution<int> uid(0,lim-1);
    return uid(rang);
}
ll power(ll x, ll y,ll p) { 
    ll res = 1;      // Initialize result 
    x = x % p;  // Update x if it is more than or equal to p 
    while (y > 0) {  
        if (y & 1) // If y is odd, multiply x with result
            res = (res*x) % p;  
        y = y>>1; // y = y/2 // y must be even now
        x = (x*x) % p;   
    } 
    return res; 
}
ll power(ll x, ll y) { 
    ll res = 1;      // Initialize result 
    while (y > 0) {    
        if (y & 1)// If y is odd, multiply x with result 
            res = (res*x) ;  
        y = y>>1; // y = y/2 // y must be even now 
        x = (x*x);   
    } 
    return res; 
}
 
ll max3(ll a,ll b,ll c){
    return max(a,max(b,c));
}
ll min3(ll a,ll b,ll c){
    return min(a,min(b,c));
}
bool isPrime(ll n) { // Corner cases 
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
    for (ll i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
    return true; 
}
const int d4i[4]={-1, 0, 1, 0}, d4j[4]={0, 1, 0, -1};
const int d8i[8]={-1, -1, 0, 1, 1, 1, 0, -1}, d8j[8]={0, 1, 1, 1, 0, -1, -1, -1};
const int nax=1e5+10;

void solve(){
    int x;cin>>x;
    cout<<(x^1)<<endl;
    return;
}

int main(){
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    cout<<fixed<<setprecision(8);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    #endif
    int t;
    // cin>>t;
    t=1;
    while(t--){
        solve();
    }
    #ifndef ONLINE_JUDGE
    cout<<endl<<endl<<endl<<endl<<"Time elapsed: "<<(double)(clock()-clk)/CLOCKS_PER_SEC<<endl;
    #endif
    return 0;
}

Measured memory_bytes: 3552
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc= new Scanner(System.in);
		int A=sc.nextInt(),B=sc.nextInt(),C=sc.nextInt(),D=sc.nextInt();
		int train,bus;
		if(A<B){
			train=A;
		}else{
			train=B;
		}
		if(C<D){
			bus=C;
		}else{
			bus=D;
		}
		System.out.println(train+bus);
	}
}


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

int main(){
  int n,k;
  cin>>n>>k;
  int a[n];
  int max=0;
  for(int i=0;i<n;i++){
    cin>>a[i];
    if(max<a[i]){
      max=a[i];
    }
  }
  
  int num[n]={0};
  int count=0;
  for(int i=0;i<n;i++){
    num[a[i]]++;
    if(num[a[i]]==1){
      count++;
    }
  }
  sort(num,num+n,greater<int>());
  int p=0;
  for(int i=0;i<k;i++){
     n-=num[i];
  }
   if(n>0){
    cout<<n<<endl;
  }else{
     cout<<0<<endl;
   }
}
 


Measured memory_bytes: 1792
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    A, B, C = map(int, readline().split())

    if A + B >= C:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()


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

namespace ConsoleApp15
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] nums = Console.ReadLine().Split(' ').Select(c => int.Parse(c)).ToArray();

            int N = nums[0];
            int K = nums[1];

            Combination combination = new Combination(2000);

            for (int i = 1; i <= K; i++)
            {
                long product = ((long)combination[N - K + 1, i] * (long)combination[K - 1, i - 1]);
                Console.WriteLine( product % (long)(Math.Pow(10, 9) + 7));
            }
        }
    }

    class Combination
    {
        private int Devisor = (int)(Math.Pow(10, 9) + 7);

        public int this[int index1, int index2] => data[index1, index2];

        private int[,] data;

        public Combination(int N)
        {
            data = new int[N + 1, N + 1];

            data[0, 0] = 1; //0C0=1

            for (int i = 1; i <= N; i++)
            {
                for (int j = 0; j <= i; j++)
                {
                    if (j == 0)
                    {
                        data[i, j] = data[i - 1, j] % Devisor;
                    }
                    else if (j == i)
                    {
                        data[i, j] = data[i - 1, j - i] % Devisor;
                    }
                    else
                    {
                        data[i, j] = (data[i - 1, j - 1] + data[i - 1, j]) % Devisor;
                    }
                }
            }
        }

    }
}

Measured memory_bytes: 28512
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define x first
#define y second
#define ll long long
#define dl double
#define pii pair<int,int>
#define pb push_back
#define all() begin(),end()
#define nl '\n'
#define adm(a,b,m) ((a+b)%m)
#define gum(a,b,m) ((a*1LL*b)%m)
#define lo(i,j,n) for(int i=j;i<n;i++)


int main(){
	int a;
	cin>>a;
	if(a&1)a<<=1;
	cout<<a<<nl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)


def dfs(v, c, C, visited, G):
    visited[v] = True
    C[v] = c

    for nv, w in G[v]:
        if visited[nv]:
            continue
        dfs(nv, c^w, C, visited, G)


def main():
    N = int(input())
    
    G = [[] for _ in range(N)]
    for _ in range(N-1):
        u, v, w = map(int, input().split())
        G[u-1].append([v-1, w%2])
        G[v-1].append([u-1, w%2])
    # print(G)

    C = [0]*N
    visited = [False]*N
    dfs(0, 0, C, visited, G)
    for c in C:
        print(c)
    
        


if __name__ == '__main__':
    main()

Measured memory_bytes: 158640
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int T; pair<int, int>x[9], y[9];
vector<int>vec;
int main() {
	cin >> T;
	for (int i = 0; i < T; i++) {
		for (int j = 0; j < 9; j++) { cin >> y[j].second; }
		for (int j = 0; j < 9; j++) {
			char c; cin >> c;
			if (c == 'R') { y[j].first = 0; }
			if (c == 'G') { y[j].first = 1; }
			if (c == 'B') { y[j].first = 2; }
		}
		bool OK2 = false;
		int a[9] = { 0,1,2,3,4,5,6,7,8 };
		do {
			for (int j = 0; j < 9; j++) {
				x[a[j]] = y[j];
			}
			bool OK = true;
			for (int j = 0; j < 3; j++) {
				if (x[j * 3].first != x[j * 3 + 1].first) { OK = false; }
				if (x[j * 3 + 1].first != x[j * 3 + 2].first) { OK = false; }
				if (x[j * 3].second != x[j * 3 + 1].second) { goto E; }
				if (x[j * 3 + 1].second != x[j * 3 + 2].second) { OK = false; }
				goto F; E:;
				if (x[j * 3].second + 1 != x[j * 3 + 1].second) { OK = false; }
				if (x[j * 3 + 1].second + 1 != x[j * 3 + 2].second) { OK = false; }
			F:;
			}
			if (OK == true) { OK2 = true; }
		} while (next_permutation(a, a + 9));
		if (OK2 == true) { vec.push_back(1); }
		else { vec.push_back(0); }
	}
	for (int i = 0; i < vec.size(); i++) { cout << vec[i] << endl; }
	return 0;
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
using namespace std;
 
int dp[8005][16005];
int a[8001];
string s;
int x,y;
int k,w;
int main()
{
	getline(cin,s);
	cin>>x>>y;
	for(int i=0;i<=s.size()-1;i++)
	{
		if(s[i]=='T')
		{
			k++;
			a[k]=w;
			w=0;
		}
		else
			w++;
	}
	k++;
	a[k]=w;
	
	dp[1][a[1]+8000]=1;
	for(int i=3;i<=k;i+=2)
		for(int j=0;j<=16000;j++)
		{
			if(j+a[i]<=16000)
				dp[i][j]=dp[i-2][j+a[i]];
			if(j-a[i]>=0)
				dp[i][j]=dp[i][j]||dp[i-2][j-a[i]];
		}
	
	dp[0][8000]=1;
	for(int i=2;i<=k;i+=2)
		for(int j=0;j<=16000;j++)
		{
			if(j+a[i]<=16000)
				dp[i][j]=dp[i-2][j+a[i]];
			if(j-a[i]>=0)
				dp[i][j]=dp[i][j]||dp[i-2][j-a[i]];
		}
	int ans=0;
	if(k%2==1)
		ans=dp[k][x+8000]&&dp[k-1][y+8000];
	else
		ans=dp[k][y+8000]&&dp[k-1][x+8000];
	
	if(ans==0) cout<<"No";
	else cout<<"Yes";
	return 0;
}

Measured memory_bytes: 497792
#include <algorithm>
#include <iostream>
#include <numeric>
#include <string>
using namespace std;

int
main()
{
  string s;
  cin >> s;
  uint64_t sum = 0;
  for (char c : s) {
    sum += c - '0';
  }
  if (sum % 9) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
  return 0;
}


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

typedef long long int lli;
typedef unsigned long long int ulli;
typedef pair<int,int> pii;
typedef priority_queue< int, vector< int >, greater< int > >  minHeap;

#define ones(x) __builtin_popcount(x)
#define onesl(x) __builtin_popcountl(x)
#define onesll(x) __builtin_popcountll(x)

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define scn(n) scanf("%d",&n)
#define scnll(n) scanf("%lld",&n)
#define scn2(n,m) scanf("%d%d",&n,&m)
#define scn3(n,m,w) scanf("%d%d%d",&n,&m,&w)
#define scn2ll(n,m) scanf("%lld%lld",&n,&m)
#define atoz(v) v.begin(),v.end()
#define ratoz(v) v.rbegin(),v.rend()
#define Fill(a,v) memset(a,v,sizeof(a))
#define fi first
#define se second
#define inf 1e9
#define pi acos(-1.0)
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define mod 1000000007
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define bug(x) cerr << __LINE__ << " says: " << #x << " = " << (x) << "\n"

int Set(int N,int pos)
{
    return N=N | (1<<pos);
}
int reset(int N,int pos)
{
    return N = N & ~(1<<pos);
}
bool check(int N,int pos)
{
    return (bool)(N & (1<<pos));
}


inline int addmod(int x,int y)
{
    return (x%mod + y%mod)%mod;
}
inline int submod(int x,int y)
{
    return (x%mod - y%mod + mod)%mod;
}
inline int mulmod(int x,int y)
{
    return (x%mod *1LL* y%mod)%mod;
}

inline int nextSubMask(int i, int mask)
{
    return (i-1)&mask;   /// returns next  submask
}

template<typename T>
void we_r_done(T mssg)
{
    cout<<mssg;
    exit(0);
}


int main()
{
    ///freopen("output.txt","w",stdout);
    // freopen("input.txt","r",stdin);
    //FastIO;

    lli a,b;
    cin>>a>>b;
    lli g = __gcd(a,b);
    int cnt = 1;

    for(lli i=2; (i*i)<=g; i++){
        if(g%i) continue;
        cnt++;
        while(g%i == 0) g /= i;
    }
    if(g>1) cnt++;
    cout<<cnt;
    return 0;

}

///sin and cos expect input in radians not degrees. so use , sin(degrees * pi / 180)
///using bs = bitset<MX>; // how many distinct number can be form?
///sort(atoz(v), [](const data x, const data y){return (x.a==y.a?x.b>y.b : x.a<y.a);});


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incID(i, l, r) for(LL i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(LL i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(LL i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(LL i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC static_cast
#define SI(v) SC<int>(v.size())
#define SL(v) SC<LL >(v.size())
#define RF(e, v) for(auto & e: v)
#define ef else if
#define UR assert(false)

// ---- ----

int a;
string s;

int main() {
	cin >> a >> s;
	
	cout << (a >= 3200 ? s : "red") << endl;
	
	return 0;
}


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

typedef long long int ll;
#define INF 1999999999
#define MODA 1000000007
#define PI 3.1415926535897932384626433

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    for(int i = 1; i <= 9; i++){
        for(int j = 1; j <= 9; j++){
            if(i*j == n){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}



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

using namespace std;

using ll = long long;

constexpr char newl = '\n';

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

    int n;
    cin >> n;

    int maxv = 0;
    ll ans = 0;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;

        maxv = max(maxv, a);
        if (i > 0) ans += maxv - a;
    }
    cout << ans << newl;

    return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; 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 SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

	ll n;
	cin >> n;
	vll x(n), y(n), h(n);
	ll hmax = 0;
	REP(i, n){
		cin >> x[i] >> y[i] >> h[i];
		hmax = max(hmax, h[i]);
	}

	REP(sx, 101){
		REP(sy, 101){
			std::set<int> hset;
			REP(i, n){
				if(h[i]) hset.insert(h[i] + abs(sx - x[i]) + abs(sy - y[i]));
			}
			if(hset.size() == 1){
				ll flg = 1;
				REP(i, n){
					if(max(*hset.begin() - abs(sx - x[i]) - abs(sy - y[i]), 0LL) != h[i]) flg = 0;
				}
				if(flg) cout << sx << " " << sy << " " << *hset.begin() << endl;
			}
		}
	}
    return 0;
}

Measured memory_bytes: 256
import java.io.*;

class Main{
	public static void main(String[] args){
		try{
			int area, line;
			BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));
			String str = buf.readLine();
			String[] n = str.split(" ");
			int a = Integer.parseInt(n[0]);
			int b = Integer.parseInt(n[1]);
			area = a*b;
			line = 2 * (a + b);
			System.out.println(area + " " + line);
		}catch(IOException e){
		}
	}
}



Measured memory_bytes: 24216
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <iterator>
#include <limits>
#include <numeric>
#include <utility>
#include <cmath>
#include <cassert>
#include <cstdio>

// #include <unordered_set>
// #include <unordered_map>

#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())

#define pb push_back
#define mp make_pair

int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}

typedef std::pair<int, int> P;
typedef long long ll;
typedef long double ld;

const int MOD = 1000000007;
const int INF = 1e9;
const ll LINF = INF * 1ll * INF;
const ld DINF = 1e200;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

using namespace std;

// #define int long long

int main(){
  

    ios::sync_with_stdio(false);
    cin.tie(0);
	//cin高速化

    int a,b,c;
    cin>>a>>b>>c;

    int tmp=a-b;
    cout<<tmp%c<<endl;

	


}

Measured memory_bytes: 256
N, W = map(int, input().split())
w, v = [0]*(N+1),[0]*(N+1)
for i in range(N):
    w[i+1], v[i+1] = [int(_) for _ in input().split()]
V = sum(v)

dp = [[10**12]*(V+1) for _ in range(N+1)]
dp[0][0] = 0
# dp[i][j]:i番目以前の商品を見たときの価値総和jとしたときの重さの最小値

ans = 0
for i in range(1,N+1):
    for j in range(V+1): # なんか間違えて1スタートにしててハマった
        if v[i] <= j: #v[i]が入るとjになるときの計算なので，v[i]がjよりでかいのはあり得ない。j-v[i]>0だしね。
            # i-1番目までの商品で価値jの場合とi番目の商品を入れて価値jの場合の比較
            dp[i][j] = min(dp[i-1][j], dp[i-1][j-v[i]] + w[i])
        else:
            dp[i][j] = dp[i-1][j]


for j in range(V+1):
    if dp[N][j] <= W:
        ans = max(ans, j)

print(ans)

Measured memory_bytes: 119788
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7

s = STR()
print(s[:4] + ' ' + s[4:])

Measured memory_bytes: 5184
if __name__ == '__main__':
    a = int(input())
    list = []

    for x in range(31, 0, -1):
        for y in range(10, 1, -1):
            if pow(x, y) > a:
                pass
            elif a >= pow(x, y):
                list.append(pow(x, y))

    print(max(list))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const double pi = 3.14159265358979;
signed main(){
    double a,b,x;
    cin >> a >> b >> x;
    x/=a;
    if(x > a*b/2) {
        cout << fixed << setprecision(10) << atan2((a*b-x)*2,a*a)*180/pi << endl;
    }
    else {
        cout << fixed << setprecision(10) << atan2(b*b,x*2)*180/pi << endl;
    }
}

Measured memory_bytes: 4056
N, M = map(int, input().split())
MOD = 10 ** 9 + 7

def permutation(n):
  res = 1
  for i in range(1, n + 1):
    res = (res * i) % MOD
  return res

if abs(N - M) >= 2:
  print(0)
else:
  if N == M:
    print((permutation(N) * permutation(M) * 2) % MOD)
  else:
    N, M = max(N, M), min(N, M)
    print((permutation(N) * permutation(M)) % MOD)

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

int main()
{
  int n;
  cin >> n;
  
  vector <int> a(3 * n);
  for (int i = 0; i < 3 * n; i++){
    cin >> a.at(i);
  }
  sort(a.begin(), a.end());
  
  long int ans = 0;
  for (int i = n; i < 3 * n; i += 2){
    ans += a.at(i);
  }
  cout << ans << endl;
}

Measured memory_bytes: 1408
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll MOD=1e9+7;
static const int MAX = 100;
static const int INF = (1<<23);
template<class T> T gcd(T a, T b){return b? gcd(b,a%b) : a;}
template<class T> T lcm(T a,T b){return a / gcd(a,b)*b;}

int main(){
    
    
    const ll ma = 1e18;
    ll n;
    cin>>n;
    vector<ll> a(n);
    bool f = false;
    rep(i,n){
        cin>>a[i];
        if(a[i]==0)f=true;
    }
    if(f){
        cout<<0<<endl;
        return 0;
    }
    ll sum=1;
    rep(i,n){
        if(ma/sum>=a[i])sum*=a[i];
        else{
            cout<<-1<<endl;
            return 0;
        }
        
    }
    cout<<sum<<endl;
    
    
    
return 0;
}


Measured memory_bytes: 4004
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;

/*BigInteger
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/rational.hpp>
namespace xxx = boost::multiprecision;
using Bint = xxx::cpp_int;
using Real = xxx::number<xxx::cpp_dec_float<1024>>;
*/

#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0LL, sizeof(x))
#define mm(x) memset((x), -1LL, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define Bit(n) (1LL << (n))
#define Bitset(a, b) (a) |= (1LL << (b))
#define Bitunset(a, b) (a) &= ~(1LL << (b))
#define Bitcheck(a, b) ((((a) >> (b)) & 1LL) == 1LL)
#define Bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
constexpr int INF = (int)1e18;
constexpr int MOD = (int)1e9 + 7;
constexpr double PI = (double)acos(-1);
constexpr double EPS = (double)1e-10;
constexpr int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
constexpr int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

signed main() {
  int N;
  cin >> N;
  vector<double> p(N);
  for (int i = 0; i < N; i++) {
    cin >> p[i];
  }

  static double dp[3030][3030];
  m0(dp);
  dp[0][0] = 1.0;

  for (int i = 0; i < N; i++) {
    for (int k = 0; k < N; k++) {
      if (k == 0) dp[i + 1][k] = dp[i][k] * (1.0 - p[i]);
      dp[i + 1][k + 1] += dp[i][k] * p[i] + dp[i][k + 1] * (1.0 - p[i]);
    }
  }

  double ans = 0.0;
  for (int i = N / 2 + 1; i <= N; i++) {
    ans += dp[N][i];
  }

  cout << fixed << setprecision(12) << ans << endl;
  return 0;
}


Measured memory_bytes: 71936
#include <iostream>
using namespace std;
int main(void){
    // Here your code !
    
int A,B,C,D,E,F;

cin >> A;
cin >> B;
cin >> C;
cin >> D;

E = A * B;
F = C * D;

if( E > F ){
  cout << E;
}
else if( E < F ){
  cout << F;
}
else{
  cout << E;
}

return 0;
}


Measured memory_bytes: 384
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <stack>
#include <vector>
using namespace std;
typedef long long ll;
int main(){
  ll a,b,x;
  cin >> a >> b >> x;

  if(a == 0){
    cout << b/x + 1 << endl;
  }
  else{
    cout << b/x - (a-1)/x << endl;
  }

}

Measured memory_bytes: 256
n, m = map(int, input().split())
A = []
B = []
for i in range(n):
    a = list(input())
    A.append(a)
for i in range(m):
    b = list(input())
    B.append(b)

for i in range(n - m + 1):
    for j in range(n - m + 1):
        ok = True
        for h in range(m):
            if not ok:
                break
            for w in range(m):
                # print(A[i + h][j + w])
                if A[i + h][j + w] != B[h][w]:
                    ok = False
                    break
        if ok:
            print("Yes")
            exit()
print("No")

Measured memory_bytes: 64888
n=int(input())
j,k=map(int,input().split())
f=1
if k-j>=n:
  print('OK')
  f=0
else:
  for i in range(j,k+1):
    if i%n==0:
      print('OK')
      f=0
      break
if f==1:
  print("NG")

Measured memory_bytes: 9084
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, x int
	fmt.Scan(&n, &x)
	ar := make([]int, n)
	for i := range ar {
		fmt.Scan(&ar[i])
	}
	sort.Ints(ar)
	sum := 0
	for _, v := range ar {
		if v <= x {
			sum++
			x -= v
		}
	}
	if sum == n && x > 0 {
		sum--
	}
	fmt.Println(sum)
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))


ll N, Q;
string s;
char t[200010], d[200010];

int main()
{
	cin >> N >> Q;
	cin >> s;
	for (ll i = 0; i < Q; i++)
	{
		cin >> t[i] >> d[i];
	}
	//入力完了
	
	//後ろから順番にどんぐらいLとRについてつづいてっか調べる
	//Rのとき

	ll ans = 0;
	ll r = N - 1;

	for (ll i = Q - 1; i >= 0; i--)
	{
		if (d[i] == 'R')
		{
			//r番目の文字が一致してたら足す
			if (t[i] == s[r])
			{
				ans++;
				r--;
			}
		}

		if (r == Q - 1) continue;

		if (d[i] == 'L')
		{
			if (t[i] == s[r + 1])
			{
				ans--;
				r++;
			}
		}
	}

	ll l = 0;

	//このループは後ろからやる
	for (ll i = Q - 1; i >= 0; i--)
	{
		if (d[i] == 'L')
		{
			//r番目の文字が一致してたら足す
			if (t[i] == s[l])
			{
				ans++;
				l++;
			}
		}

		if (l == 0) continue;

		if (d[i] == 'R')
		{
			if (t[i] == s[l - 1])
			{
				ans--;
				l--;
			}
		}
	}

	cout << N - ans << endl;
}

Measured memory_bytes: 900
#include <stdio.h>

int main(void){
  int a, b, coin;

  scanf("%d %d", &a, &b);
  coin=0;
  if(a<b){
    coin+=b;
    b-=1;
    if(a<b){
      coin+=b;
      b-=1;
    }else{
      coin+=a;
      a-=1;
    }
  }else{
    coin+=a;
    a-=1;
    if(a<b){
      coin+=b;
      b-=1;
    }else{
      coin+=a;
      a-=1;
    }
  }
  printf("%d\n", coin);
  return 0;
}


Measured memory_bytes: 128
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>
using namespace std;

#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using uint = unsigned int;

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
default_random_engine generator;
// mt19937 rnd(1);

const int INF = 1e9 + 100;

int main() {
#ifdef LOCAL
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);  
#endif 

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0); 
    cout << setprecision(12) << fixed;
    cerr << setprecision(12) << fixed;      

    int n;
    cin >> n;
    vector<pii> seg(n);


    int res = 0;

    for (int i = 0; i < n; ++i) {
        cin >> seg[i].first >> seg[i].second;
        ++seg[i].second;
        res = max(res, seg[i].second - seg[i].first);
        
    }
    sort(all(seg));
    
    int id = 0;
    for (int i = 0; i < n; ++i) {
        if (seg[i].second < seg[id].second) {
            id = i;
        }
    }

    int x = seg[id].second;

    set<pii> lf, rg;

    for (int i = 0; i < n; ++i) {
        if (i == id) {
            continue;
        }
        lf.insert({seg[i].first, i});
        rg.insert({seg[i].second, i});
    }

    int u = (--lf.end())->first;
    int v = (rg.begin())->first;
    if (u < v) {
        res = max(res, seg[id].second - seg[id].first + v - u);
    }

    for (int i = 0; i < n; ++i) {
        if (i == id) {
            continue;
        }

        if (seg[i].first >= x) {
            break;
        }

        lf.erase({seg[i].first, i});
        rg.erase({seg[i].second, i});

        if (sz(lf) == 0 && sz(rg) == 0) {
            break;
        }

        int u = (--lf.end())->first;
        int v = (rg.begin())->first;

        if (u < v) {
            res = max(res, x - max(seg[id].first, seg[i].first) + v - u);
        }
    }

    for (int i = 0; i < n; ++i) {
        lf.insert({seg[i].first, i});
        rg.insert({seg[i].second, i});
    }

    for (int i = 0; i < n; ++i) {
        lf.erase({seg[i].first, i});
        rg.erase({seg[i].second, i});

        int u = (--lf.end())->first;
        int v = (rg.begin())->first;

        if (u < v) {
            res = max(res, seg[i].second - seg[i].first + v - u);
        }

        lf.insert({seg[i].first, i});
        rg.insert({seg[i].second, i});

    }

    cout << res << endl;

#ifdef LOCAL
    cerr << "Time: " << double(clock()) / CLOCKS_PER_SEC << endl;
#endif
}

 

Measured memory_bytes: 10368
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define piii pair<pii, int>
#define pb push_back
#define fs first
#define sc second
#define ppb pop_back
//#define LOCAL
//#define endl "\n"
#define d0(x) cout<<x<<" "
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<x<<" "<<y<<" "<<z<<endl
#define d4(x,y,z,w) cout<<x<<" "<<y<<" "<<z<<" "<<w<<endl
#define d5(x,y,z,w,s) cout<<x<<" "<<y<<" "<<z<<" "<<w<<" "<<s<<endl
#define fifo ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const ll mod = 1e9+7;



int n; 
ll x[1000001],y[1000001],x1[1000001],y11[1000001];
void solve()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>x[i]>>y[i];
		x1[i] = x[i]+y[i];
		y11[i] = x[i]-y[i]; 
	}

	sort(x1,x1+n);
	sort(y11,y11+n);

	ll xx = abs(x1[0]-x1[n-1]);
	ll yy = abs(y11[0]-y11[n-1]);
	ll zz = max(xx,yy);

	cout<<zz<<endl;
}


int main()
{
	fifo
	ll t=1;
	//cin>>t;
	//cout<<t<<endl;
	for(ll test_case=1;test_case<=t;++test_case)
	{
		//cout<<"#"<<test_case<<endl;
		solve();
	}
}


Measured memory_bytes: 9920
N,M=map(x->parse(Int,x),split(readline()))
A=Array{Tuple{Int,Int}}(0)
for a=map(x->parse(Int,x),split(readline()))
	push!(A,(-a,1))
end
for i=1:M
	b,c=map(x->parse(Int,x),split(readline()))
	push!(A,(-c,b))
end
sort!(A)
ans=0
for (b,c)=A
	if N>c
		ans-=b*c
		N-=c
	else
		ans-=b*N
		N=0
	end
end
println(ans)


Measured memory_bytes: 158256
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
using namespace std;

int main() {
    int n; cin >> n;
    string s; cin >> s;
    vector<map<string, int>> cnt(n + 1);
    for (int mask = 0; mask < 1 << n; mask++) {
        string t1, t2;
        for (int i = 0; i < n; i++) {
            (mask >> i & 1 ? t1 : t2) += s[i];
        }
        reverse(begin(t2), end(t2));
        cnt[t1.size()][t1 + t2]++;
    }
    long long ans = 0;
    for (int mask = 0; mask < 1 << n; mask++) {
        string t1, t2;
        for (int i = 0; i < n; i++) {
            (mask >> i & 1 ? t1 : t2) += s[n + i];
        }
        reverse(begin(t2), end(t2));
        ans += cnt[t2.size()][t2 + t1];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 68224
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		String[] c = new String[h];
		for(int i=0; i<h; i++){
			c[i] = sc.next();
			System.out.println(c[i]);
			System.out.println(c[i]);
		}
	}
}

Measured memory_bytes: 24404
#pragma GCC optimize("O3")
#pragma GCC target("sse4")

#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <typeinfo>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T>
using Tree =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i = a; i < (b); i++)
#define F0R(i, a) for (int i = 0; i < (a); i++)
#define FORd(i, a, b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i, a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001;  // check the limits, dummy

typedef long long ll;
const int inf = INT_MAX / 2;
const ll infl = 1LL << 60;
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}

template <class T>
void print(const vector<T> v) {
  cout << "[ ";
  F0R(i, v.size()) { cout << v[i] << ' '; }
  cout << "]" << '\n';
}

int mod(int i, int j) {
  return (i % j) < 0 ? (i % j) + 0 + (j < 0 ? -j : j) : (i % j + 0);
}

// --------------------------------------------------------
// This is tool
// --------------------------------------------------------
void Main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);

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

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
}

Measured memory_bytes: 3640
"use strict";
main(require("fs").readFileSync("/dev/stdin", "utf8").replace(/\r?\n$/, "").split(/\r?\n/));

function main(lines){
	var rows = lines.slice(1).map(function(str){return str.split(" ").map(Number)});
	rows.forEach(function(row){
		row.push(row.reduce(function(a,b){return a+b;}));
	});
	rows.push(rows[0].map(function(_,i){
		return rows.reduce(function(a,b){return a+b[i];}, 0);
	}));
	console.log(rows.map(function(a){return a.join(" ")}).join("\n"));
}

Measured memory_bytes: 17440
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
#define _GLIBCXX_DEBUG
//vector<vector<vector<int>>> dp(101, vector<vector<int>>(101, vector<int>(101)));  
int main(){
    int h,n;cin>>h>>n;
    vin a(n),b(n);
    rep(i,n)cin>>a[i]>>b[i];
    vvin dp(n,vin(h+1));
    rep(i,h+1)dp[0][i]=ceil((double)i/a[0])*b[0];
    rep(i,n)dp[i][0]=0;
    rep(i,n-1){
        rep2(j,1,h+1){
            dp[i+1][j]=min(dp[i][j],dp[i+1][j-a[i+1]>0?j-a[i+1]:0]+b[i+1]);
        }
    }
    cout<<dp[n-1][h]<<endl;
}

Measured memory_bytes: 39424
#include <string>
#include <sstream>
#include <iostream>
#include <vector>
#include <math.h>
#include <algorithm>
#include <functional>
#include <map>
#include <climits>
#include <queue>

using namespace std;


class Main {
public:
	bool hasCf(string str) {
		int ci = -1;
		for (int i = 0;i < str.size();i++) {
			if (str[i] == 'C') {
				ci = i;
				break;
			}
		}

		int fi = -1;
		for (int i = str.size()-1;i>=0;i--) {
			if (str[i] == 'F') {
				fi = i;
				break;
			}
		}

		return (ci != -1) && (fi != -1) && (ci < fi);
	}
};


int main()
{
	Main m;
	string str;

	cin >> str;

	cout << (m.hasCf(str) ? "Yes" : "No") << endl;

    return 0;
}



Measured memory_bytes: 256
import sys
input = sys.stdin.readline

A,V=map(int,input().split())
B,W=map(int,input().split())
T=int(input())

if V<=W:
    print("NO")
else:
    D=abs(A-B)
    if (V-W)*T>=D:
        print("YES")
    else:
        print("NO")

Measured memory_bytes: 9188
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <bitset>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <queue>

#define mp make_pair
#define pb push_back


typedef long long ll;
typedef long double ld;

using namespace std;


int main() {
	string s;
	cin >> s;
	int fl = 0;
	for (int i = 0; i < s.size(); ++i) {
		if (s[i] == 'C')
			fl = 1;
		if (s[i] == 'F' && fl) {
			cout << "Yes\n";
			return 0;
		}
	}
	cout << "No\n";
	return 0;
}




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

// headers {{{
using namespace std;
// using namespace rel_ops;
 
const double pi=acos(-1.0);
const double eps=1e-11;
const int INF=0x7FFFFFFF;
template<class T> inline bool checkmin(T &a,T b){return b<a?a=b,1:0;}
template<class T> inline bool checkmax(T &a,T b){return b>a?a=b,1:0;}
template<class T> inline T sqr(T x){return x*x;}
template<class T> inline bool bit(T a, int b) {return (a>>b)&1;}
inline int popcount(int n) { return __builtin_popcount(n); }
inline int popcount(long long n) { return __builtin_popcountll(n); }
typedef long long int64;
typedef unsigned long long uint64;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
#define MP(A,B) make_pair(A,B)
#define PB(X) push_back(X)
#define eb(args...) emplace_back(args)
#define rep(i,n) for(int i=0; i<(int)n; i++)
#define ff first
#define ss second
#define sz(g) int(g.size())
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
#ifdef LOCAL
#define dout cerr 
void out() { dout << endl; }
template<typename A, typename... B> void out(A a, B... b) { dout << ' ' << a; out(b...); }
#define dbg(args...) dout << __LINE__ << ":(" << #args << ") -> ", out(args)
template<class T>void show(T a, int n){for(int i=0; i<n; ++i) cout<<a[i]<<' '; cout<<endl;}
template<class T>void show(T a, int r, int l){for(int i=0; i<r; ++i)show(a[i],l);cout<<endl;}
constexpr bool local = true;
#else
#define dbg(...)
#define dout if(true);else cerr
#define out(...)
#define show(...)
constexpr bool local = false;
#endif
// }}}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL); 
        // int T; cin >> T; rep(cas, T)
    int64 N;
    while (cin >> N) {
        string s;
        N--;
        while (true) {
            if (N < 26) {
                s += 'a' + N;
                break;
            }
            s += (N % 26 + 'a');
            N /= 26;
            N--;
        }
        reverse(s.begin(), s.end());
        cout << s <<endl;
    }
    return 0;
}



Measured memory_bytes: 3652