akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
long long a[5010];
long long dp[5010];
int main()
{
	int n, k;
	while(~scanf("%d%d",&n, &k))
	{
		for(int i=1; i<=n;i++)
		scanf("%lld",&a[i]);
		
		sort(a+1, a+1+n);
		
		long long  sum = 0;
		for(int i=1;i<=n;i++)
		{
			sum += a[i];
		}
		if(sum<k)
		{
			printf("%d\n",n);
			continue;
		}
		memset(dp,0,sizeof dp);
		dp[1] = a[1]<k?1:0;
		for(int i=2;i<=n;i++)
		{
			if(a[i] >= k)
			dp[i] = dp[i-1];
			else 
			{
				sum = 0;
				for(int j=1;j<=dp[i-1];j++)
				sum += a[j];
				sum += a[i];
				
				if(sum < k)
				{
					if(dp[i-1] == i-1)
					dp[i] = i;
					else dp[i] = dp[i-1];
					continue;
				}
				long long ans = 0;
				for(int j=1;j<=dp[i-1];j++)
				{
					if(sum-a[j] >= k)
					{
						ans++;
						sum -= a[j];
					}
				}
				dp[i] = ans;
			}
			
			/*for(int j=1;j<=dp[i-1];j++)
			{
			if(a[j]+a[i] >= k && a[i]<k)
			{
				break;
			}
			else if(a[i] == a[i-1]);
			else 
			dp[i]++;
			}
			
			if(dp[i] == i-1 && a[i] < k)//&& a[i] < k)
			{
				int ans = 0;
				sum = 0;
				for(int j=1;j<=i;j++)
				sum += a[j];
				if(sum < k)
				dp[i] = i;
				else 
				{
				for(int j=1;j<=i;j++)
				{
					if(sum-a[j] >= k)
					{
						ans++;
						sum -= a[j];
					}
				}
				dp[i] = ans;}
			}*/
		}
		
		printf("%lld\n", dp[n]);
	}
	return 0;
}

Measured memory_bytes: 256
def divides_u(x,y):
    return x // y
def divides_d(x,y):
    return (x+y-1) // y
def gcd(a,b):
    if a < b:
        a, b = b, a
    while b >= 1:
        a, b = b, a % b
    return a
def lcd(a,b):
	return a * b // gcd(a,b)


a, b, c, d =  [ int(v) for v in input().split() ]
e = lcd(c,d)
n = b - a + 1

m1 = divides_u(b,c) - divides_d(a,c) + 1
m2 = divides_u(b,d) - divides_d(a,d) + 1
m3 = divides_u(b,e) - divides_d(a,e) + 1


print(n-m1-m2+m3)


Measured memory_bytes: 38256
#include<stdio.h>

int main(void){
	int r,d,x;
	int i=0;

	setvbuf(stdout,NULL,_IONBF,0);
	scanf("%d %d %d",&r,&d,&x);
	for(i=0;i<10;i++){
		x=r*x-d;
		printf("%d\n",x);
	}
	return 0;
}

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

int main()
{
  int64_t ans = 0;
  string S, prev = "";
  cin >> S;
  for (int i = 0; i < S.size(); i++)
  {
    string sub = to_string(S.at(i));
    if (sub != prev)
    {
      ans++;
      prev = sub;
      continue;
    }
    for (int j = i + 1; j < S.size(); j++)
    {
      sub = sub + S.at(j);
      if (sub != prev)
      {
        ans++;
        prev = sub;
        i = j;
        break;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
import           Control.Monad
import           Control.Monad.ST
import           Data.Array
import           Data.Array.ST
import qualified Data.ByteString.Char8 as BS
import           Data.Maybe
import qualified Data.Vector           as V
import qualified Data.Vector.Mutable   as M
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector.Unboxed.Mutable as UM

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getIntList = readIntList <$> BS.getLine

main=do
    getLine
    a <- getIntList
    {-let cnt = (runST $ do
            vec <- U.replicate m 0
            forM_ a $ \ai ->
                forM_ (primeFactor ai) $ \j ->
                    UM.modify vec (+1) j
            return vec) :: M.MVector s Int-}

    let f = (do v <- UM.replicate m 0
                forM_ a $ \ai ->
                    forM_ (primeFactor ai) $ \j -> UM.modify v (+1) j
                return v) :: ST s (U.MVector s Int)
        cnt = U.toList $ U.create f
    putStrLn$
        if all (<=1) cnt
        then "pairwise coprime"
        else if foldl1 gcd a == 1
            then  "setwise coprime"
            else  "not coprime"
    --return()
m = 10^6+1

table :: V.Vector Int
table = runST $ do
    vec <- V.thaw $ V.fromList [0..m]
    forM_ (takeWhile (\i -> i*i < m) [2..]) $ \i -> do
        arri <- M.read vec i
        when (arri >= i)$
            forM_ [i,i+i..m-1] $ \j -> do
                v <- M.read vec j
                when (v == j) $ M.write vec j i
    V.freeze vec

primeFactor :: Int -> [Int]
primeFactor 1 = []
primeFactor n = if null prev || head prev /= p
    then p:prev
    else prev
    where p = table V.! n
          prev = primeFactor (n `div` p)


Measured memory_bytes: 90584
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Xml.Schema;
using static System.Console;

namespace ConsoleApp2
{
    class Program
    {
        static public int[] Sarray() { return ReadLine().Split().Select(int.Parse).ToArray(); }
        static public List<int> Slist() { return new List<int>(ReadLine().Split().Select(int.Parse)); }
        static void Main(string[] args)
        {
            var N = Sarray()[0];
            var An = Sarray();
            var ans = An[0];
            for(var i=1;i<N;i++)
            {
                ans = gcd(ans, An[i]);
            }
            WriteLine(ans);
        }
        static int gcd(int a,int b)
        {
            if (b == 0) return a;
            return gcd(b, a % b);
        }
    }
}

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

int main()
{
	int N;
	cin >> N;
	map<int, int> m;
	long long sum = 0;
	for(int i = 1; i <= N; i++){
		int tmp = 0;
		cin >> tmp;
		m[i] = tmp;
		sum += tmp;
	}
	int M;
	cin >> M;
	long long ans[M];
	for(int i = 0; i < M; i++){
		int p, x;
		cin >> p >> x;
		ans[i] = sum - m[p] + x;
	}
	for(int i = 0; i < M; i++) cout << ans[i] << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#define N 10000
using namespace std;
int Change(string);
int Change_sup(string);
struct data{
  int s,g;
  bool operator<(const data & right)const{
    if(s!=right.s) return s<right.s;
    return g<right.g;
  }
};
int main(){
  int n,flag[N],com,cnt,i,j;
  string ins,ing;
  struct data d[N];
  while(1){
    cin >> n;
    if(n==0) break;
    for(i=0;i<n;i++){
      cin >> ins >> ing;
      d[i].s=Change(ins);
      d[i].g=Change(ing);
      flag[i]=0;
    }
    sort(d,d+n);
    cnt=0;
    for(i=0;i<n;i++){
      if(flag[i]==0){
    flag[i]=1;
    cnt++;
    com=d[i].g;
    for(j=i+1;j<n;j++){
      if(com<=d[j].s&&flag[j]==0){
        flag[j]=1;
        com=d[j].g;
      }
    }
      }
    }
    cout << cnt << endl;
  }
  return 0;
}
int Change(string str){
  int r;
  string a,b,c;
  a=str.substr(0,2);
  b=str.substr(3,2);
  c=str.substr(6,2);
  r=Change_sup(a+b+c);
  return r;
}
int Change_sup(string str){
  int len=str.size(),x=1,ret=0,i=0;
  while(len){
    ret=ret*x+(str[i]-'0');
    x=10;
    i++;
    len--;
  }
  return ret;
}

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


public class Main {
	private	static	BufferedReader	br = null;

	static {
		br = new BufferedReader(new InputStreamReader(System.in));
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		int[]	number = null;

		while ((number = parseNumber()) != null) {
			for (int len = number.length; len > 1; len--) {
				for (int m = 0; m < len - 1; m++) {
					number[m] = (number[m] + number[m + 1]) % 10;
				}
			}

			System.out.println(number[0]);
		}
	}

	private static int[] parseNumber() {
		String	stdin  = null;
		int[]	number = null;

		if ((stdin = parseStdin()) != null) {
			number = new int[stdin.length()];
			for (int n = 0; n < number.length; n++) {
				number[n] = stdin.charAt(n) - '0';
			}
		}

		return number;
	}

	private static String parseStdin() {
		String	stdin = null;

		try {
			String line = br.readLine();
			if (line != null) {
				if (!line.isEmpty()) {
					stdin = line;
				}
			}
		}
		catch (IOException e) {}

		return stdin;
	}
}

Measured memory_bytes: 16936
//的場梨沙★担当
//結城晴★副担当
//日野茜★副担当
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string.h>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <cctype>
#include <complex>
#include <regex>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <stdio.h>


using namespace std;

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

    cout<<(N+D*2)/(D*2+1)<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		int[] point = new int[6];
		int q;
		Scanner scan = new Scanner(System.in);
		for(int i = 0; i<6; i++){
			point[i]=scan.nextInt();
		}
		Dice2 dice = new Dice2(point);
		q=scan.nextInt();
		for(int i=0;i<q;i++){
			int t=scan.nextInt();
			int f=scan.nextInt();
			while(true){
				if(t==dice.T){
					if(f==dice.F){
						break;
					}
					else
						dice.Move('R');
				}
				else if(f==dice.F){
					dice.Move('S');
				}
				else if(f==dice.T){
					dice.Move('S');
				}
				else if(t==dice.F){
					dice.Move('N');
				}
				else{
					dice.Move('R');
				}
			}
			System.out.println(dice.R);
		}
		scan.close();
	}
}
class Dice2{
	int T,F,R,L,B,D;

	public Dice2(int[] point){
		this.T=point[0];
		this.F=point[1];
		this.R=point[2];
		this.L=point[3];
		this.B=point[4];
		this.D=point[5];
	}
	public void Move(char move){
		int temp;
		switch(move){
			case 'E':
				temp=this.D;
				this.D=this.R;
				this.R=this.T;
				this.T=this.L;
				this.L=temp;
				break;
			case 'S':
				temp=this.D;
				this.D=this.F;
				this.F=this.T;
				this.T=this.B;
				this.B=temp;
				break;
			case 'W':
				temp=this.D;
				this.D=this.L;
				this.L=this.T;
				this.T=this.R;
				this.R=temp;
				break;
			case 'N':
				temp=this.D;
				this.D=this.B;
				this.B=this.T;
				this.T=this.F;
				this.F=temp;
				break;
			case 'R':
				temp=this.F;
				this.F=this.R;
				this.R=this.B;
				this.B=this.L;
				this.L=temp;
		}
	}
}


Measured memory_bytes: 26296
import sys

sys.setrecursionlimit(100000)
n = int(input())
bfs_dic = [{} for i in range(n)]
ans = [0 for i in range(n-1)]

def bfs(pn, pc, node):
    c = 1
    max_c = 0
    
    if len(bfs_dic[node]) != 1 or pc == 0: #葉は見ない(葉でも最初だけは子を見る)
        for k,v in bfs_dic[node].items():
            if k == pn: continue #親と同じなら無視
            if pc == c:                 #親と色被っちゃったら色変え
                c+=1
            ans[v] = c
            maxable_c = bfs(node, c, k)
            if max_c < maxable_c:
                max_c = maxable_c
            c+=1                        #子と自分の間に色割り当てて色変える
        if max_c < c-1:
            return c-1
        else:
            return max_c
    return 1                                        #葉やったら1色しか使っとらん
            
for i in range(n-1):
    a,b = map(int, input().split())
    a-=1
    b-=1
    bfs_dic[a][b] = i
    bfs_dic[b][a] = i

print(bfs(-1, 0, 0))
for i in ans:
    print(i)

Measured memory_bytes: 87604
import java.util.*;

// https://atcoder.jp/contests/dp/tasks/dp_a
public class Main {
    public static void main(String args[]) {
        runCode();
    }

    private static void runCode() {
        try (Scanner scan = new Scanner(System.in)) {
            int n = scan.nextInt();
            int[][] days = new int[n][];
            for (int i = 0; i < n; i++) {
                days[i] = new int[] {
                  scan.nextInt(),
                  scan.nextInt(),
                  scan.nextInt()
                };
            }
            System.out.println(new UsingDP().maxHappiness(days));
        }
    }
    

    public static class UsingDP {
        public int maxHappiness(int[][] days) {
            int[] happiness = days[0], temp = new int[happiness.length];
            for (int day = 1; day < days.length; ++day) {
                int[] activities = days[day];
                //System.out.println(day);
                //System.out.println(Arrays.toString(happiness));
                //System.out.println(Arrays.toString(activities));
                for (int i = 0; i < 3; ++i) {
                    for (int j = 0; j < 3; ++j) {
                        if (i == j) continue;
                         temp[i] = Math.max(temp[i], happiness[j] + activities[i]);
                    } 
                }
                //System.out.println(Arrays.toString(temp));
                int[] swap = happiness;
                happiness = temp;
                temp = swap;
            }
            //System.out.println(Arrays.toString(happiness));
            int ans = 0;
            for (int i = 0; i < happiness.length; ++i)
               ans = Math.max(ans, happiness[i]);
            return ans;
        }
    }
}


Measured memory_bytes: 94452
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    int A[n];
    int i;
    for(i=0;i<n;i++)
        cin>>A[i];
    int j,k;
    sort(A,A+n);
    int count=0;
    for(i=0;i<n-2;i++){
        for(j=i+1;j<n-1;j++){
            for(k=j+1;k<n;k++){
                if(A[i]+A[j]>A[k] && A[i]!=A[j] && A[j]!=A[k] ){
                    count++;
                    //cout<<A[i]<<A[j]<<A[k]<<endl;
                }
                    
                
                
            }
        }
    }
    
    
    cout<<count<<endl;
}

Measured memory_bytes: 3648
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

H, W = mapint()
Ss = [input() for _ in range(H)]
from collections import deque
Q = deque()

dirc = ((1, 0), (0, 1), (-1, 0), (0, -1))
Q.append((0, 0))
dist = [[10**18]*W for _ in range(H)]
dist[0][0] = 1
while Q:
    y, x = Q.popleft()
    if y==H-1 and x==W-1:
        break
    for dy, dx in dirc:
        ny, nx = dy+y, dx+x
        if ny<0 or ny>=H or nx<0 or nx>=W:
            continue
        if Ss[ny][nx]=='#':
            continue
        if dist[ny][nx]>dist[y][x]+1:
            dist[ny][nx] = dist[y][x]+1
            Q.append((ny, nx))

white = 0
for s in Ss:
    white += s.count('.')
if dist[H-1][W-1]>=10**17:
    print(-1)
else:
    print(white-dist[H-1][W-1])

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

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;

#define mem(a, b) memset(a, b, sizeof(a))
#define MOD 1000000007
#define MAX (int) 1e9
#define PI 3.141592653589793238462643383279502884

template <typename T, typename U>
T max(T x, U y) {
    return x > y ? x : y;
}

template <typename T, typename U>
T min(T x, U y) {
    return x < y ? x : y;
}

template<typename T>
void debug(string msg, T t) {
	cout << msg << ": " << t << "\n";
}

template<typename T>
T& abs(T& a, T& b) {
	return a > b ? a - b : b - a;
}

inline int toDigit(char c) { return c - '0'; }

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(0); 

	int n, m, x;
	cin >> n >> m >> x;
	int c[n], a[n][m];
	
	for(int i = 0; i < n; i++) {
		cin >> c[i];
		for(int j = 0; j < m; j++) {
			cin >> a[i][j];
		}
	}

	int minCost = -1;

	// iterate through all combinations of books.
	for(int mask = 0; mask < (1 << n); mask++) {
		int cost = 0;
		int u[m] = {0}; // understanding of algorithms
		for(int i = 0; i < n; i++) {
			if(((1 << i) & mask) == 0) {
				continue;
			}

			for(int j = 0; j < m; j++) {
				u[j] += a[i][j];
			}

			cost += c[i];
		}
		
		bool good = true;
		for(int j = 0; j < m; j++) {
			if(u[j] < x) { good = false; break; }
		}

		if(good) {
			minCost = minCost == -1 ? cost : min(minCost, cost);
		}
	}

	cout << minCost << "\n";

	return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

// #define DEBUG_MODE
#ifdef DEBUG_MODE
#define dump(x) cout << #x << " : " << x << endl
#define LINE cout << "line : " << __LINE__ << endl
#define dumpV(v) cout << #v << " : ["; for(auto& t : v) cout << t << ", "; cout<<"]" << endl
#define STOP assert(false)
#else
#define dump(x) ;
#define LINE     ;
#define dumpV(v);
#define STOP     ;
#endif
#define mp make_pair

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fi<<", "<<a.se<<')';
    return out;
  }
}


using S = vector<string>;

bool isNum(char c) {
    return c >= '0' && c <= '9';
}

S change(const string& s){
    S ret;
    string tmp;
    int n = s.size();
    int i = 0;
    while(i < n) {
        if(tmp.empty()) tmp += s[i++];
        else if(isNum(tmp.back()) ^ isNum(s[i])) {
            ret.pb(tmp);
            tmp.clear();
        }
        else {
            tmp += s[i++];
        }
    }
    if(!tmp.empty()) ret.pb(tmp);
    return ret;
}

bool cmp(const string& s, const string& t) {
    auto x = change(s), y = change(t);
    int n = x.size();
    rep(i, n) {
        if(y.size() <= i) {
            LINE;
            return false;
        }
        auto& s = x[i];
        auto& t = y[i];
        if(s == t) continue;
        if(isNum(s[0])) {
            if(isNum(t[0])) {
                if(s.size() != t.size()) {
                    LINE;
                    return s.size() < t.size();
                }
                rep(j, s.size()) if(s[j] != t[j]) {
                    LINE;
                    return s[j] < t[j];
                }
            }
            else {
                LINE;
                return true;
            }
        }
        else if(isNum(t[0])) {
            LINE;
            return false;
        }
        else {
            LINE;
            return s < t;
        }
    }
    if(x.size() < y.size()) {
        LINE;
        return true;
    }
    LINE;
    return false;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    string s;
    cin >> s;
    rep(i, n) {
        string t;
        cin >> t;
        if(cmp(t, s)) cout << '-' <<'\n';
        else cout << '+' << '\n';
    }
    return 0;
}


Measured memory_bytes: 3228
#include <iostream>
#include <iomanip>

int main()
{
	int h, w;
	std::cin >> h >> w;
	while (h != 0 || w != 0) {
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if ((i + j) % 2 == 0) {
					std::cout << "#";
				}
				else {
					std::cout << ".";
				}
			}
			std::cout << std::endl;
		}
		std::cout << std::endl;
		std::cin >> h >> w;
	}
    return 0;
}


Measured memory_bytes: 3080
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

    	Scanner sc= new Scanner(System.in);
    	int num = 0;

    	num = sc.nextInt();

    	int[] a = new int[num];

    	for ( int i = 0 ; i < num ; i++ ) {
    		a[i] = sc.nextInt();
    	}

    	for ( int i = num-1 ; i >= 0 ; i-- ) {
    		System.out.print( a[i] );
    		if ( i != 0 ) {
        		System.out.print( " ");    			
    		}
    	}
		System.out.print( "\n" );
    	sc.close();
    }
}


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

int main(){
	
	int a, b, c;
	cin >> a >> b >> c;
	int x = max(a, max(b,c));
	while(1){
		if((3*x-a-b-c) % 2 == 0) break;
		x++;
	}
	
	cout << (3*x-a-b-c) / 2 << endl;

	return 0;
}

Measured memory_bytes: 256
import sys

input = sys.stdin.readline

N = int(input())
S = [int(x) for x in list(input().strip())]

nxtind = [[-1]*(N+1) for i in range(10)]

for i in range(N-1,-1,-1):
	si = S[i]
	for j in range(10):
		if j==si:
			nxtind[j][i] = i
		else:
			nxtind[j][i] = nxtind[j][i+1]

ans = 0
for i in range(10):
	ff = nxtind[i][0]
	if ff==-1: continue
	for j in range(10):
		ss = nxtind[j][ff+1]
		if ss==-1: continue
		for k in range(10):
			tt = nxtind[k][ss+1]
			if tt==-1:
				continue
			else:
				ans += 1

print(ans)

Measured memory_bytes: 44400
k = gets.chomp.to_i
numbers = []
k.times do |i|
  numbers << i + 1
end

guusuu = []
kisuu = []

guusuu = numbers.select{|n| n % 2 == 0 }
kisuu = numbers.select{|n| n % 2 != 0}

p guusuu.length * kisuu.length

Measured memory_bytes: 1788
// orz dxm
#include<bits/stdc++.h>

using namespace std;

#define PH push
#define MP make_pair
#define PB push_back
#define fst first
#define snd second
#define FOR(i, x, y) for(int i = (x); i < (y); ++i)
#define REP(i, x, y) for(int i = (x); i <= (y); ++i)
#define y0 yORZDXM
#define y1 yORZDXM
#define y2 yORZDXM
typedef double db;
typedef long long ll;
typedef long double ldb;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1e9 + 7;
const int maxn = 2e5 + 5;

int n;
ll ans = 1;
int a[maxn];
char s[maxn];

int main(){
	scanf("%d", &n);
	n <<= 1;
	scanf("%s", s);
	FOR(i, 0, n){
		a[i] = ((s[i] == 'B') ^ (n - i - 1)) & 1;
		if(i < n / 2) (ans *= (i + 1)) %= INF;
		//printf("%d ", a[i]);
	}
	//puts("");
	int cnt = 0;
	FOR(i, 0, n) cnt += a[i];
	if(cnt != n / 2){
		puts("0");
		return 0;
	}
	cnt = 0;
	for(int i = n - 1; i; --i){
		if(a[i]) ++cnt;
		else (ans *= cnt) %= INF, --cnt;
	}
	printf("%lld\n", ans);
	return 0;
}



Measured memory_bytes: 1280
#include <iostream>

using namespace std;

int main()
{
  int r,c,rlu;

  while(1){
    cin>>r>>c;

    if(r == 0 && c == 0){
      break;
    }

    rlu = r	* c;

    if(rlu % 2 == 0){
      cout<<"yes"<<endl;
    }
    else{
      cout<<"no"<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3072
#include <bits/stdc++.h>
#include <set>
#include <numeric>
#define rep(i,n) for (int i=0; i < (n); ++i)
#define all(a) a.begin(), a.end()
using ll = long long;
using namespace std;
 
// ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }


// const double PI = acos(-1);
// int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
// int a[12][12];
//平方根　= sqrt


bool check(string s);

int main() {
  string s;
  cin >> s;

  if (check(s)) {
    cout << "AC" << endl;
  }
  else {
    cout << "WA" << endl; 
  }
  return 0;
}

  bool check(string s){
    if (s[0] != 'A') return false;
    int c=0;
    // ３文字目からCがあるかしらべる
    for (int i=2;i<s.size()-1;i++) {
      if (s[i]=='C') {
        c++;
      }
    }

    if (c != 1) return false;

    int upper =0;
    for (int i=0;i<s.size(); i++) {
      if (s[i] >= 'A' && s[i] <= 'Z') {
        upper++;
      }
    }
    if (upper != 2) return false;
    return true;
  }


Measured memory_bytes: 256
import sys
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

s = ns()
s = list(s)
 
print(min(s.count('0'),s.count('1'))*2)

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

int main () {
  string S;
  cin >> S;
  
  if (S.at(5) == '1') {
    cout << "TBD" << endl;
  }
  else if (S.at(6) <= '4') {
    cout << "Heisei" << endl;
  }
  else {
    cout << "TBD" << endl;
  }
}

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

int a[1000001];

int main() {
	int n;
	cin >> n;
	
	int sum = 0;
	
	for (int i = 1; i <= n; ++ i)
		cin >> a[i];
	for (int i = 1; i <= n; ++ i) {
		for (int j = i + 1; j <= n; ++ j) {
			sum += (a[i] * a[j]);
		}
	}
	
	cout << sum;
	return 0;
}

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

int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;

  while (true) {
    c = c-b;
    if ( c <= 0 ) break;
    a = a-d;
    if ( a <= 0 ) break;
    
  }
  if (a>c) cout << "Yes" << endl;
  if (c>a) cout << "No" << endl;


}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define rrep(i, a, b) for (int i = (a); i < (b); ++i)
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using LP = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using tl = tuple<ll, ll, ll>;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
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; }

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

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

    clock_t start = clock();

    ll d; cin>>d;
    vl cs(26); cin>>cs;
    vvl ss(d, vl(26)); cin>>ss;

    std::random_device rnd;
    std::mt19937 mt(rnd());
    std::uniform_int_distribution<> rd(0, d - 1);
    std::uniform_int_distribution<> rq(0, 25);

    ll ans = 0;
    vl last(26);
    rep(i, 26) last[i] = -1;
    vl ts;
    rep(i, d) {
        ll q = rq(mt);
        ts.push_back(q);
    }
    rep(i, d) {
        ans += ss[i][ts[i]];
        last[ts[i]] = i;
        rep(j, 26) {
            ans -= cs[j] * (i - last[j]);
        }
    }

    clock_t end = clock();
    while (static_cast<double>(end - start) / CLOCKS_PER_SEC * 1000.0 < 1900.0) {
        ll e = rd(mt);
        ll q = rq(mt);
        while (ts[e] == q) {
            e = rd(mt);
            q = rq(mt);
        }
        ll temp = 0;
        ll p = ts[e];
        ts[e] = q;
        rep(i, d) {
            temp += ss[i][ts[i]];
            last[ts[i]] = i;
            rep(j, 26) {
                ans -= cs[j] * (i - last[j]);
            }
        }
        if (temp < ans) ts[e] = p;
        else ans = temp;
        end = clock();
    }
    rep(i, d) cout<<ts[i] + 1<<endl;
}

Measured memory_bytes: 3800
#include <bits/stdc++.h>
 using namespace std;
 void insertionSort(int*, int);
 
 int main(void){
 	int n;
	cin >> n;
	int a[n];
	for(int i=0; i<n; i++){
		cin >> a[i];
	}
	insertionSort(a, n);
	return 0;
 }
 
 void insertionSort(int* a, int n){
 	for(int i=0; i<n; i++){
		int v = a[i];
		int j = i - 1;
		while(j>=0 && a[j] > v){
			a[j+1] = a[j];
			j--;
		}
		a[j+1] = v;
		//puts
		cout << a[0];
		for(int i=1; i<n; i++){
			cout << " " << a[i];
		}
		cout << endl;
	}
	return;
 }


Measured memory_bytes: 3092
#include <stdio.h>

int main(void) {
  int a, b, c, n,i;
  scanf("%d", &n);
  for(i = 0; i < n; ++i) {
    scanf("%d%d%d", &a, &b, &c);
    a *= a, b *= b, c *= c;
    if(a + b == c || b + c == a || c + a == b) printf("YES\n");
    else printf("NO\n");
  }
  return 0;
}


Measured memory_bytes: 2532
#include <algorithm>
#include <bitset>
#include <boost/dynamic_bitset.hpp>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <typeindex>
#include <typeinfo>
#include <vector>

#define DEBUG(x) cout << #x << ": " << x << endl
#define INFILE() freopen("input.txt", "r", stdin)
#define REP(i, a, b) for (int i = (a); i < (b); i++)
#define REPC(i, a) REP(i, 0, a)
#define ALL(s) begin(s), end(s)
#define RALL(s) rbegin(s), rend(s)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_i = pair<ll, int>;
using i_ll = pair<int, ll>;
using d_i = pair<double, int>;
using ll_ll = pair<ll, ll>;
using d_d = pair<double, double>;

static constexpr ll LL_MOD = 1000000009;
static constexpr int I_MOD = 1000000007;
static constexpr double EPS = numeric_limits<double>::epsilon();
static constexpr double PI = 3.14159265358979323846264338327950288;

template <class T> static void scan(vector<T> &v);
static void scan(vector<string> &v, bool isWord = true);
static boost::dynamic_bitset<> scan(char trueValue = 'o');

int main(int argc, char *argv[]) {
  // INFILE();
  ll n, x, count = 0;
  cin >> n >> x;
  vector<ll> c(n);
  scan(c);

  REP(i, 1, n) {
    ll left = c[i - 1] + c[i];

    if (left > x) {
      ll diff = ((left - x) <= c[i]) ? left - x : c[i];
      count += diff;
      c[i] -= diff;
    }
  }

  for (int i = n - 2; i >= 0; i--) {
    ll right = c[i] + c[i + 1];

    if (right > x) {
      ll diff = ((right - x) <= c[i]) ? right - x : c[i];
      count += diff;
      c[i] -= diff;
    }
  }

  cout << count << endl;
  return 0;
}

template <class T> static void scan(vector<T> &v) {
  map<type_index, const char *const> m = {{typeid(int), "%d"},
                                          {typeid(ll), "%lld"},
                                          {typeid(double), "%lf"},
                                          {typeid(char), "%c"}};

  auto tFormat = m[typeid(T)];

  for (T &n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string> &v, bool isWord) {
  if (isWord) {
    for (auto &n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}

static boost::dynamic_bitset<> scan(char trueValue) {
  string s;
  getline(cin, s);

  if (s.size() == 0) {
    getline(cin, s);
  }

  for_each(begin(s), end(s),
           [trueValue](char &c) { c = (c == trueValue) ? '1' : '0'; });
  return boost::dynamic_bitset<>(string(rbegin(s), rend(s)));
}


Measured memory_bytes: 1024
import java.util.Collections;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;

public class Main{
	public static int max(int[][] ar, int ind1, int ind2){
		if(ind2 == 1){
			return Math.max(ar[ind1][2], ar[ind1][3]);
		}
		else if(ind2 == 2){
			return Math.max(ar[ind1][1], ar[ind1][3]);
		}
		else {
			return Math.max(ar[ind1][1], ar[ind1][2]);
		}
	}
	public static void main(String[] args) {
		Reader rd = new Reader();
		int n = rd.nextInt();
		int[][] ar = new int[n+1][4];
		int[][] dp = new int[n+1][4];
		for(int i=0; i<=n; i++){
			ar[i][0] = 0;
		}
		Arrays.fill(ar[0], 0);
		for(int i=1; i<=n; i++){
			for(int j=1; j<=3; j++){
				ar[i][j] = rd.nextInt();
			}
		}
		
		dp[1] = ar[1];
		int ii;
		//System.out.println(Arrays.toString(dp[1]));
		for(ii=2; ii<=n; ii++){
			/*
			for(int[] k : dp){
				System.out.println(Arrays.toString(k));
			}
			* */
			for(int jj=1; jj<=3; jj++){
				dp[ii][jj] = ar[ii][jj] + max(dp, ii-1, jj);
			}
		}
		/*
		for(int[] i : dp){
			System.out.println(Arrays.toString(i));
		}
		*/
		System.out.println(Math.max(Math.max(dp[ii-1][1], dp[ii-1][2]),dp[ii-1][3]));
	
	}

	static void sort(int[] ar){
		ArrayList<Integer> ls = new ArrayList<>();
		for(int i=0; i<ar.length; i++) ls.add(ar[i]);
		Collections.sort(ls);
		for(int i =0; i<ls.size(); i++) ar[i] = ls.get(i);
	}
}

class Reader { 
	static BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
	static StringTokenizer tok = new StringTokenizer("");
	static String next() {
		while(!tok.hasMoreTokens()){
			try{
				tok = new StringTokenizer(bf.readLine());
			}
			catch(IOException e) {
				e.printStackTrace();
			}
		}
		return tok.nextToken();
	} 
	static int nextInt() {
		return Integer.parseInt(next());
	}
}


Measured memory_bytes: 63088
n,k=map(int,input().split())
*v,=map(int,input().split())
motimono=[]
ans=[]
if k>=n:
    k-=n
    ans.append(sum(v))
    v.sort()
    for i in range(min(k,len(v))):
        v[i]=0
        ans.append(sum(v))
    print(max(ans))
else:
    v*=2
    for j in range(1,k+1):
        for i in range(n-j,n+1):
            motimono=v[i:i+j]
            ans.append(sum(motimono))
            motimono.sort()
            for i in range(min(k-j,len(motimono))):
                motimono[i]=0
                ans.append(sum(motimono))
    print(max(ans))


Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <unordered_map>
#include <cmath>
#include <utility> // pair make_pair
#include <algorithm>
#include <functional>
#include <iomanip>
#include <climits> // LLONG_MAX, LLONG_MIN, INT_MIN, INT_MAX
#include <assert.h>

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define ll long long
#define int ll
#define INF INT_MAX/10

using namespace std;
using Pi = pair<int, int>;
using Graph = vector<vector<int> >;
using WeightGraph = vector<vector<Pi> >;

int Input[100100];

signed main() {
  long double W, H, x, y; cin >> W >> H >> x >> y;
  if (x == W/2 && y == H/2) {
    cout << W*H/2 << " " << 1 <<  endl;
  } else {
    cout << W*H/2 << " " << 0 << endl;
  }
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
/*
#ifndef ONLINE_JUDGE
    #define cin f
    #define cout g
    ifstream cin("a.in");
    ofstream cout("a.out");
#endif
*/
int n,v[1<<19];
bool viz[1<<19];
vector <int> Q;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>n;
    int N=1<<n;
    for(int i=1;i<=N;++i) cin>>v[i];
    sort(v+1,v+N+1);
    reverse(v+1,v+N+1);
    Q.push_back(v[1]);
    viz[1]=1;
    for(int i=0;i<n;++i)
    {
        int ind=2;
        for(int j=0;j<(1<<i);++j)
        {
            while(ind<=N&&(v[ind]>=Q[j]||viz[ind])) ind++;
            if(ind==N+1)
            {
                cout<<"No";
                return 0;
            }
            viz[ind]=1;
            Q.push_back(v[ind]);
        }
        sort(Q.begin(),Q.end());
        reverse(Q.begin(),Q.end());
    }
    cout<<"Yes";
    return 0;
}


Measured memory_bytes: 2680
//
// Created by gkashish on 16/05/20.
//

#include <bits/stdc++.h>

using namespace std;
#define mod 1e9+7
#define ll long long
#define rev_rep(it, last, first) for(int it=last-1;it>=first;--it)
#define out(x) cout << x;
#define pln(x) cout << x << "\n";
#define debug(x) cout << "Debug: " << x << "\n";
#define in(x) cin >> x;
#define rep(it, start, end) for(int it=start;it<end;++it)
#define x first
#define y second


void set_io(int inp) {
#ifndef ONLINE_JUDGE
    string folder = string(getenv("HOME")) + "/CLionProjects/CompetitiveProgramming/inputs/";
    string input_file = folder + "input-" + to_string(inp) + ".txt";
    string output_file = folder + "output-" + to_string(inp) + ".txt";
    freopen(input_file.c_str(), "r", stdin);
    freopen(output_file.c_str(), "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

}

int main() {
    set_io(2);

    int n, k;
    in(n >> k);
//    n = k =200000;
    vector<int> arr(n);
    rep(i, 0, n)in(arr[i])
//    rep(i, 0, n)arr[i] = 0;
    while (k--) {
        int brk = true;
        vector<int> cpy(n, 0);
        rep(i, 0, n) {
            int start = max(i - arr[i], 0);
            int end = i + arr[i] + 1;
            if (end < n)
                cpy[end] -= 1;
            cpy[start]++;
        }
        rep(i, 1, n) {
            cpy[i] = cpy[i - 1] + cpy[i];
            if (cpy[i] < n)
                brk = false;
        }
        arr = cpy;
        if (brk) {
            break;
        }
    }
    rep(i, 0, n)out(arr[i] << " ");

    return 0;
}


Measured memory_bytes: 4996
c=(0..M=50).map{[0]*20}
p`sed 1d`.split.sum{|a|n=(a.to_r*10**9).to_i
i=j=0
i+=1while n[i]<1
(j+=1;n/=5)while n%5<1
s=c[[0,18-i].max..].sum{_1[[18-j,0].max..].sum}
c[i][j]+=1;s}

Measured memory_bytes: 32928
#include<bits/stdc++.h>
using namespace std;
const bool DBG = 1;

#define TRACE(x)    x
#define WATCH(x)    TRACE(cout << #x" = " << x << endl)
#define WATCHR(a,b) TRACE(for(auto it=a; it!=b;) cout<<*(it++)<<" ";cout<<endl)
#define WATCHC(V)   TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})
#define all(x) (x).begin(), (x).end()

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#define f first
#define s second
#define resz resize

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

#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 trav(a, x) for (auto& a : x)

#define sort_by(x, y) sort(all(x), [&](const auto& a, const auto& b) { return y; })

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;

using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;

using vpii = vector<pii>;
using vvpii = vector<vpii>;
using vpll = vector<pll>;
using vvpll = vector<vpll>;
using vpdd = vector<pdd>;
using vvpdd = vector<vpdd>;

template<typename T> void ckmin(T& a, const T& b) { a = min(a, b); }
template<typename T> void ckmax(T& a, const T& b) { a = max(a, b); }

void solve() {
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cout << fixed << setprecision(15);

    string S; cin >> S;
    vi m(2019);
    m[0]++;
    int cur = 0;
    int pow10 = 1;
    F0Rd(i,S.size()) {
        cur += pow10*(S[i]-'0');
        cur %= 2019;
        m[cur]++;
        pow10 *= 10;
        pow10 %= 2019;
    }
    ll ans = 0;
    F0R(i,2019) {
        if(m[i] > 1) {
            ans += m[i]*(m[i]-1)/2;
        }
    }
    cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3732
'use strict';
process.stdin.on('data', function(chunk) {
    var inputs = chunk.toString().trim();
    var data = inputs.split(' ').map(Number);
    var a = data[0];
    var b = data[1];
    var c = data[2];
    var count = 0;
    for (var i = a; i < b + 1; i++) {
        if (c % i === 0) {
            count++;

        }
    }
    console.log(count);
});
process.stdin.resume();
process.stdin.setEncoding('utf8');

Measured memory_bytes: 15580
//~ while (clock()<=69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")
//~ #pragma GCC optimize("O3")
//~ #pragma GCC optimize("Ofast")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//~ #pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
#define pb push_back
#define SZ(x) ((int)(x).size())
#define ALL(x) x.begin(),x.end()
#define all(x) x.begin(),x.end()
#define fi first
#define se second
#define _upgrade ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

using namespace std;

typedef long long LL;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;
typedef vector<PII> VPII;
typedef vector<PLL> VPLL;
typedef vector<LL> VLL;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long double LD;
typedef pair<LD,LD> PLD;
typedef vector<LD> VLD;
typedef vector<PLD> VPLD;

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<" = "<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<" = "<<h<<", "; _dbg(sdbg+1, a...);
}

#ifdef LOCAL
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define dbg(...)
#define cerr if(0)cout
#endif

const int maxn = (1e6)+7;
const int maxk = 20;
const int inf = (1e9)+7;
const LL LLinf = (1e18)+7;
const LD eps = 1e-9;
const LL mod = 1e9+7;

// ***************************** CODE ***************************** //

void solve()
{
	LL a, b, c, d;
	cin>>a>>b>>c>>d;
	if(d < b || a - b < 0)
	{
		cout<<"No\n";
		return ;
	}
	LL D = __gcd(b, d);
	LL xd = c - b - a;
	LL sr = (xd / D) * D;
	while(sr <= xd)
		sr += D;
	if(sr < -a)
		cout<<"No\n";
	else
		cout<<"Yes\n";

}

int main()
{
      _upgrade
	int t;
	cin>>t;
	while(t--)
		solve();
      return 0;
}

Measured memory_bytes: 256
N = int(input())
A = [int(x) for x in input().split()]

count = 0

for i in range(N):
    minj = i
    for j in range(i,N):
        if A[j] < A[minj]:
            minj = j
    if not i == minj:
        A[i], A[minj] = A[minj], A[i]
        count += 1
        
print(" ".join(map(str, A)))
print(count)


Measured memory_bytes: 5604
#include <bits/stdc++.h>
using namespace std;
#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++)


int main() {
  long a;
  cin>>a;
  vector<char>s;
  while(a>0){
    s.push_back('a'+(a-1)%26);
    a=(a-1)/26;
  }
  for(int i=s.size()-1;i>=0;i--){
    cout<<s.at(i);
  }
  cout<<endl;
}




Measured memory_bytes: 3628
#pragma GCC optimize("Ofast",3,"inline")
#include<bits/stdc++.h>
using namespace std;
#define fir first
#define sec second
#define m_p make_pair
#define y1 ygftgfgcdtfgxffgx
#define y2 yfdsesgvtyghftfvv
#define x1 xvyr6cf6fgcfgf676
#define x2 xcr6rfc5r66y6r6fr
#define up_bound upper_bound
#define low_bound lower_bound
#define next_per next_permutation
#define pb push_back
#define i_to_s to_string
typedef priority_queue<int> p_queue;
typedef priority_queue<int, vector<int>, greater<int> > min_p_queue;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int mon[20]={31,28,31,30,31,30,31,31,30,31,30,31};
ll gcd(ll x,ll y){return ((y==0)?x:gcd(y,x%y));}
ll n,pos;
ll a[200010],b[200010];
vector<pll >s;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	cin>>n;for(int i=0;i<n;i++)cin>>a[i]>>b[i],s.pb(m_p(b[i],a[i]));sort(s.begin(),s.end());
	vector<pll >::iterator it=s.begin();
	for(;it!=s.end();it++){
		pll p=*it;
		pos+=p.sec;
		if(pos>p.fir){
			cout<<"No";
			return 0;
		}
//		cout<<pos-p.sec<<"-->"<<pos<<"   "; 
	}
	cout<<"Yes";
	return 0;
}
//code by myj128128

Measured memory_bytes: 8432
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif

#define FILE_IO freopen("input.txt","r",stdin)
#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define bp __builtin_popcount
#define debug(x) cerr << #x << " = " << x << endl;

const int MOD = 1e9 + 7;
const int INF = 1e18;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>void print(T t){for(auto &it : t)cout<<it<<" ";}
inline int powerexp(int a, int b, int m = MOD){ int res = 1;while(b){if(b&1)res = res * a % m;a = a * a % m,b >>= 1;}return res % m;}
inline int modinv(int a){ return powerexp(a,MOD-2,MOD);}
inline int lcm(int a, int b){ int g = __gcd(a,b);return a/g*b;}
inline int add(int x, int y){ x += y; if (x >= MOD) x -=  MOD; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % MOD;}
inline int sub(int x, int y){ x -= y; if (x<0) x += MOD; return x ;}

//-------------------< start here >-------------------------// 

void solve(){
   int a, b;
   cin >> a >> b;
   cout << a * b <<  " " << 2 * (a + b) << endl;
}

//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
   IOS;
   solve();
   //find();
   #ifdef LOCAL_DEFINE
   cerr << "time elapsed " << (double)clock()/CLOCKS_PER_SEC << endl;
   #endif
}



Measured memory_bytes: 3156
import bisect
from itertools import accumulate
n,m,k=map(int,input().split())
a=list(accumulate(map(int,input().split())))
b=list(accumulate(map(int,input().split())))
ans=0
j=bisect.bisect_right(b,k)
ans=max(ans,j)
for i,x in enumerate(a):
    y=k-x
    if y>0:
        j=bisect.bisect_right(b,y)
        ans=max(ans,i+j+1)
i=bisect.bisect_right(a,k)
ans=max(ans,i)
for j,y in enumerate(b):
    x=k-y
    if x>0:
        i=bisect.bisect_right(a,x)
        ans=max(ans,i+j+1)
print(ans)


Measured memory_bytes: 47400
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long int a,b,c,d;
  cin>>a>>b>>c>>d;
  long long int s,t,u,v;
  s=a*c;
  t=a*d;
  u=b*c;
  v=b*d;
  vector<long long int>A;
  A={s,t,u,v};
  long long int x=s;
  for(int i=0;i<3;i++){
    if(A.at(i+1)>x)x=A.at(i+1);
  }
  cout<<x<<endl;
}

Measured memory_bytes: 3624
#MLE注意！0や1のケースに注意

def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    import math
    #from math import gcd

    #inf = 10**17
    #mod = 10**9 + 7

    s = input().rstrip()
    if s == 'ABC':
        print('ARC')
    else:
        print('ABC')

if __name__ == '__main__':
    main()

Measured memory_bytes: 65148
#include <stdio.h>

int main(void) {
    int a, b, ans;
    scanf("%d %d", &a, &b);
    ans = a * b;
    if(ans % 2 == 0) {
        printf("Even\n");
    } else {
        printf("Odd\n");
    }
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define hackcyborg shresth_walia
#define ll long long int
#define ld long double
#define FOR(i,a,b) for (auto i = (a); i != (b); i = (a)<(b)? i+1 : i-1)
#define pb push_back
#define mod 1000000007
long long binpow(long long a, long long b, long long m=mod) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n=3,k;
    cin>>k;
    ll dp[k+1]={0};
    ll ans=0;
    for(ll x=k;x>=1;x--)
    {   dp[x]=binpow((k/x),n);
        for(ll y=2*x;y<=k;y+=x)
        {
           dp[x]=(mod+dp[x]-dp[y])%mod;
        }
        ans+=dp[x]*x;
        ans%=mod;
    }
    cout<<ans;
}


Measured memory_bytes: 3648
using System;

namespace AOJ
{
    class Program
    {
        static void Main(string[] args)
        {

            string read = Console.ReadLine();
            var temp = read.Split(' ');
            int a = int.Parse(temp[0]), b = int.Parse(temp[1]), c = int.Parse(temp[2]);
            string msg;

            if(a<b&&b<c)
            {
                msg = "Yes";
            }
            else
            {
                msg = "No";
            }
            Console.WriteLine(msg);
            Console.ReadLine();
        }
    }
}

Measured memory_bytes: 8896
#include<iostream>
#include<numeric>
#include<algorithm>
#include<utility>

using namespace std;

int bit[100001];

int sum(int i){
  int s=0;
  while(i){
    s+=bit[i];
    i&=i-1;
  }
  return s;
}

void inc(int i){
  while(i<=100000){
    bit[i]++;
    i+=i&-i;
  }
}

int main(){
  for(int N,R;cin>>N>>R,N;){
    int a[100000];
    iota(begin(a),end(a),0);
    while(R--){
      int s,t;
      cin>>s>>t;
      swap(a[s-1],a[t-1]);
    }
    fill(begin(bit),end(bit),0);
    long long ans=0;
    for(int i=0;i<N;i++){
      ans=(ans*(N-i)+a[i]-sum(a[i]))%1000000007;
      inc(a[i]+1);
    }
    cout<<ans<<endl;
  }
}

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

int main() {

  int A, B; cin >> A >> B;
  int answer = 0;
  if (A > B) {
    answer += A;
    A -= 1;
  } else {
    answer += B;
    B -= 1;
  }

  if (A > B) {
    answer += A;
  } else {
    answer += B;
  }

  cout << answer << endl;
}



Measured memory_bytes: 256
#include "iostream"
#include "algorithm"
using namespace std;

int main() {
  int n;
  cin >> n;
  int a[110], b[110];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a, a + n, greater<int>());

  b[0] = 1;
  for (int i = 1; i < 110; i++) {
    b[i] = b[i - 1] * (-1);
  }

  int ans = 0;
  for (int i = 0; i < n; i++) {
    ans += a[i] * b[i];
  }

  cout << ans << endl;
}

Measured memory_bytes: 256