akhauriyash/Code-Regression huggingface dataset:
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log,sin,cos
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

n=ii()
arr=limii()
chk=0
ans=[]

for i in range(2,n,2):
    chk+=arr[i-1]

x1 = sum(arr)-chk*2
#print(sum(arr),chk)
ans.append(x1)
for i in range(1,n):
    ans.append(2*arr[i-1] - ans[i-1])
print(*ans)
            
            
            
        
        
        
        
        
    







Measured memory_bytes: 90644
fun main(args: Array<String>) {
    val (N, K) = readLine()!!.split(" ").map(String::toInt)
    val S = readLine()!!.toCharArray()
    val d = 'a' - 'A'
    S[K - 1] = S[K - 1] + d
    println(S.joinToString(""))
}

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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define rrev(i, m, n) for(int (i)=(n)-1; (i)>=(m); (i)--)
#define erev(i, m, n) for(int (i)=(n); (i)>=(m); (i)--)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define mp            make_pair
#define pb            push_back
template<class T, class S> inline bool minup(T& m, S x){ return m>(T)x ? (m=(T)x, true) : false; }
template<class T, class S> inline bool maxup(T& m, S x){ return m<(T)x ? (m=(T)x, true) : false; }

const int    INF = 1000000000;
const ll     MOD = 1000000007LL;
const double EPS = 1E-12;

struct Point : public complex<double>
{
public:
  Point() { this->real(0);  this->imag(0); }
  Point(const double& x, const double& y) { this->real(x);  this->imag(y); }
  Point(const complex<double> w)  { this->real(w.real());  this->imag(w.imag()); }
  inline double dot(Point p){ return (conj(*this) * p).real(); }  // ??????
  inline double det(Point p){ return (conj(*this) * p).imag(); }  // ??????
};

namespace std
{
  bool operator < (const Point& a, const Point& b)
  {
    return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
  }
}

typedef vector<Point> Polygon;
#define currPoint(P, i) P[i]
#define nextPoint(P, i) P[(i+1)%P.size()]

double getArea(Polygon& P)
{
  double A = 0.0;
  rep(i, P.size()) A += currPoint(P, i).det(nextPoint(P, i));
  return A / 2.0;
}

template<typename T> ostream& operator <<(ostream& r, const vector<T> t){vrep(v,t)r<<*v<<(v+1==t.end()?"":" ");return r;}
template<typename T> ostream& operator <<(ostream& r, const pair<vector<T>, int> p){int n=p.second;minup(n,p.first.size());rep(i,n-1)r<<p.first[i]<<' ';r<<p.first[n-1];return r;}
template<typename T> ostream& operator <<(ostream& r, const pair<T*, int> p){int n=p.second-1;rep(i,n)r<<p.first[i]<<' ';return r<<p.first[n];}
template<typename T, size_t S> ostream& operator <<(ostream& r, const T (&a)[S]){rep(i,S-1)r<<a[i]<<' ';return r<<a[S-1];}


Polygon Plg;
double x, y;

int main()
{
  while(~scanf("%lf,%lf", &x, &y)) Plg.pb(Point(x, y));

  printf("%.15f\n", abs(getArea(Plg)));

  return 0;
}

Measured memory_bytes: 1244
n = int(input())
red = [tuple(map(int, input().split())) for i in range(n)]
blue = [tuple(map(int, input().split())) for i in range(n)]
blue = sorted(blue)

INF = 1000000000
min_dif = INF
min_index = -1
pair = 0

while len(blue):
    min_dif = INF
    min_index = -1
    for i in range(len(red)):
        if blue[0][0] > red[i][0] and blue[0][1] > red[i][1]:
            dif = blue[0][1] - red[i][1]
            if dif < min_dif:
                min_dif = dif
                min_index = i
    blue.pop(0)
    if min_index != -1:
        red.pop(min_index)
        pair += 1


print(pair)




Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <string>

using namespace std;

const int mod = 1e9 + 7;
using VL = vector<long long>;
using VVL = vector<VL>;
using VVVL = vector<VVL>;
// dp[i][j] i文字目までみる　ABCのうちj文字採用

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

	int n = s.size();

	VL memo1(4, 0);
	auto memo2 = memo1;
	memo1[0] = 1;

	for (int i = 0; i < n; i++) {
		auto memo2 = memo1;
		switch (s[i]) {
			case 'A':
				memo2[1] += memo1[0];
				memo2[1] %= mod;
				break;
			case 'B':
				memo2[2] += memo1[1];
				memo2[2] %= mod;
				break;
			case 'C':
				memo2[3] += memo1[2];
				memo2[3] %= mod;
				break;
			case '?':
				memo2[0] *= 3;
				memo2[1] *= 3;
				memo2[2] *= 3;
				memo2[3] *= 3;
				memo2[1] += memo1[0];
				memo2[2] += memo1[1];
				memo2[3] += memo1[2];
				memo2[0] %= mod;
				memo2[1] %= mod;
				memo2[2] %= mod;
				memo2[3] %= mod;
				break;
		}

		// printf("%2d, %c: %3lld, %3lld, %3lld, %3lld\n", i, s[i],
		// memo2[0], memo2[1], memo2[2], memo2[3]);
		memo1 = memo2;
	}

	cout << memo1[3] << endl;
	return 0;
}


Measured memory_bytes: 888
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<map>
#include<algorithm>
#include<set>
#include <stdexcept>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
typedef long long ll;
int ceil(int a,int b){// a以上でｂの倍数の最小値を出力//
    return (a+b-1)/b*b;
}
int stoii(string s){//stoi関数の代用 文字列を数値として読み取りint型に変換//
    return atoi(s.c_str());
}
int main (){
    char a[3][3];
    rep(i,3){
        rep(j,3){
            cin>>a[i][j];
        }
    }
    cout<<a[0][0]<<a[1][1]<<a[2][2]<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	
	int n;
	scanf("%d",&n);
	
	int a[n];
	
	int i;
	
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	
	int j;
	int c=0; //count
	int t;
	int min, mini;
	
	for(i=0;i<n;i++){
		min = a[i];
		mini = i;
		for (j = i+1; j < n; j++) {
			if( min > a[j]) {
				min = a[j];
				mini = j;
			}
		}
		if(i==mini){
			;
		}
		else{
			t = a[i];
			a[i] = min;
			a[mini] = t;
			c++;
		}
	}

	for(j=0; j<n; j++) {
		if(j>0){
			printf(" ");
		}
		printf("%d",a[j]);
	}
	
	printf("\n%d\n",c);

	return 0;
}


Measured memory_bytes: 2052
# include <cstdio>
# include <iostream>
# define R register int
# define ll long long

using namespace std;

const int N=1003;
int n,h,vis[10004],pri[10004];
ll a[N][N];

void pre()
{
    for (R i=2;i<=10000;++i)
    {
        if(!vis[i]) pri[++h]=i;
        for (R j=1;j<=h&&i*pri[j]<=10000;++j)
        {
            vis[ i*pri[j] ]=1;
            if(i%pri[j]==0) break;
        }
    }
}

ll gcd (ll a,ll b)
{
    return b?gcd(b,a%b):a;
}

ll lcm (ll a,ll b)
{
    if(!a||!b) return a+b;
    return a/gcd(a,b)*b;
}

int main()
{
    scanf("%d",&n);
    if(n==2)
    {
        puts("2 5");
        puts("9 4");
        return 0;
    }
    pre();
    for (R i=1;i<=n;++i)
        for (R j=(i&1)?1:2;j<=n;j+=2)
            a[i][j]=pri[ (i+j)/2 ]*pri[ (j-i)/2+n/2+n+1 ];
    for (R i=1;i<=n;++i)
        for (R j=1;j<=n;++j)
        {
            if(a[i][j]) continue;
            a[i][j]=lcm(lcm(a[i-1][j],a[i][j-1]),lcm(a[i+1][j],a[i][j+1]))+1;
        }
    for (R i=1;i<=n;++i)
    {
        for (R j=1;j<=n;++j)
            printf("%lld ",a[i][j]);
        printf("\n");
    }
    return 0;
}


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

int test(int *h, int n){
	int *dp = new int[n];
	dp[0] = 0;
	dp[1] = abs(h[1]-h[0]);
	for(int i = 2; i < n; i++){
		dp[i] = min(dp[i-1] + abs(h[i]-h[i-1]), dp[i-2] + abs(h[i]-h[i-2]));
	}
	return dp[n-1];
}

int main(){
	#ifndef ONLINE_JUDGE
	freopen("/home/afzalrao/Desktop/Academics/2nd Year/3rd Sem/ESO207/CP/Text Files/input.txt", "r", stdin);
	freopen("/home/afzalrao/Desktop/Academics/2nd Year/3rd Sem/ESO207/CP/Text Files/output.txt", "w", stdout);
	#endif
	int n, *h;
	cin >> n;
	h = new int[n];
	for(int i = 0; i < n; i++){
		cin >> h[i];
	}
	cout << test(h, n);
	delete[] h;
	return 0;
}


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

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define mp make_pair
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }

ll calcproduct(int n) {
  ll ans = 1;
  for (int i = 1; i <= n; i++) {
    ans *= i;
    ans %= MOD;
  }
  return ans;
}

ll mod_pow(ll x, ll n) {
  if (n == 0) return 1;
  ll res = mod_pow(x * x % MOD, n / 2);
  if (n & 1) res = res * x % MOD;
  return res;
}

ll combination(int n, int k) {
  ll a = calcproduct(n);
  ll b = calcproduct(k);
  ll c = calcproduct(n-k);
  b = mod_pow(b, MOD-2);
  c = mod_pow(c, MOD-2);
  ll ans = ((a*b)%MOD*c)%MOD;
  return ans;
}

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

  int S;
  cin >> S;
  ll ans = 0;
  for (int i = 1; i <= S / 3; i++) {
    ans += combination(S-2*i-1, i-1);
    ans %= MOD;
  }
  cout << ans << endl;
}


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

int top, S[1000];

/*int calculation(char){
  for(i=0; pol_f[i]!='0'; i++){
  if('1'<=pol_f[i] && pol_f[i]<='9') push(&sp, pol_f[i]);
  }
  return pop();
  }*/

void push(int num){
  S[++top] = num;
}

int pop(void){
  top--;
  return S[top+1];
}

int main(){
  int a, b;
  top = 0;
  char s[100];

  while(scanf("%s", s)!=EOF){
    if(s[0]=='+'){
      a = pop();
      b = pop();
      push(a+b);
    }
    else if(s[0]=='-'){
      a = pop();
      b = pop();
      push(b-a);
    }
    else if(s[0]=='*'){
      a = pop();
      b = pop();
      push(a*b);
    }
    else push(atoi(s));
  }
  
  printf("%d\n", pop());
  
  return 0;
}



Measured memory_bytes: 2048
class Dice2():
    def front(self,up,front,dice):
        #index == 5
        if(up==dice[2] and front==dice[1])or(up==dice[1] and front==dice[3])or(up==dice[3] and front==dice[4])or(up==dice[4] and front==dice[2]):
            return dice[5]
        #index == 4
        elif(up==dice[0] and front==dice[2])or(up==dice[2] and front==dice[5])or(up==dice[5] and front==dice[3])or(up==dice[3] and front==dice[0]):
            return dice[4]
        #index == 3
        elif(front==dice[5] and up==dice[4])or(front==dice[4] and up==dice[0])or(front==dice[0] and up==dice[1])or(front==dice[1] and up==dice[5]):
            return dice[3]
        #index == 2
        elif(up==dice[5] and front==dice[4])or(up==dice[4] and front==dice[0])or(up==dice[0] and front==dice[1])or(up==dice[1] and front==dice[5]):
            return dice[2]
        #index == 1
        elif(front==dice[0] and up==dice[2])or(front==dice[2] and up==dice[5])or(front==dice[5] and up==dice[3])or(front==dice[3] and up==dice[0]):
            return dice[1]
        #index == 0
        else:
            return dice[0]

dice = [int(i) for i in input().split()]
p = int(input())
dc2 = Dice2()
ans = []
for i in range(p):
    up,front = map(int,input().split())
    ans.append(dc2.front(up,front,dice))
for i in range(p):
    print(ans[i])


Measured memory_bytes: 5616
#include <iostream>
using namespace std;
#define N 100000
int main(){
  long long i,n,z;
  scanf("%lld",&n);
  long long a[n+1];
  for(i=0;i<=n;i++) a[i]=0;

  for(i=1;i<=n;i++){
    scanf(" %lld",&z);
    if(z>n) continue;
    a[z]++;
  }
  long long all=0,t=0;
  for(i=1;i<=N;i++){
    if(n-all<i) break;
    all+=a[i];
    if(i==a[i]) continue;
    else if(i<a[i]) t+=a[i]-i;
    else t+=a[i];
  }
  t+=n-all;
  printf("%lld",t);
  return 0;
}


Measured memory_bytes: 1024
n = gets.to_i
a = gets.split.map(&:to_i)

if n.even?
  b = (n-1).step(1, -2).map{|i| a[i]}
  b += 0.step(n-2, 2).map{|i| a[i]}
else
  b = (n-1).step(0, -2).map{|i| a[i]}
  b += 1.step(n-2, 2).map{|i| a[i]}
end

puts b.join(' ')

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

using namespace std;

#define ll long long


void solve() {

	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	vector<ll> arr = {a * c, a * d, b * c, b * d};
	cout << *max_element(arr.begin(), arr.end());
	
}

int main() {

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

	return 0;
}

Measured memory_bytes: 3660
import java.util.Scanner;
 
public class Main {
 
	public static final MyScanner in = new MyScanner();
 
	public static void main(String[] args) {
 
		double A = in.nextInt();
		double B = in.nextInt();
		double H = in.nextInt();
		double M = in.nextInt();

		double mS = 360.0 / 60 * M;
		double hS = (360.0 / 12 * H) + (360.0 / 12 / 60 * M);

		hS = s(hS);
		mS = s(mS);

		hS = Math.toRadians(hS);
		mS = Math.toRadians(mS);

		double answer = Math.sqrt(
				Math.pow(B*Math.cos(mS) - A*Math.cos(hS),2) +
				Math.pow(B*Math.sin(mS) - A*Math.sin(hS), 2)
				);


		System.out.println(answer);
 
	}

	public static double s(double d) {
		if(d <= 90) {
			return 90 - d;
		}else {
			return 90 + 360 - d;
		}
	}
 
	public static class MyScanner {
		Scanner sc = new Scanner(System.in);
		String next() { return sc.next();}
		int nextInt() { return Integer.valueOf(sc.next());}
		long nextLong() { return Long.valueOf(sc.next()); }
	}
}

Measured memory_bytes: 35900
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define LINF 1e18
#define INF 1e9
using namespace std;

int main(){
    ll a,b,c;
    cin >> a >> b >> c;
    cout << c << " " << a << " " << b << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ll p,q,r;
	cin>>p>>q>>r;
	ll d = (p+q);
	ll d1 = (q+r);
	ll d2 = (p+r);
	cout<<min(min(d,d1),d2)<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>                 // [PRIMES]               1777 ~2^10.80
using namespace std;                     //                       10333 ~2^13.33
using ll = long long;                    // seq 1 128 | factor   100333 ~2^16.61
using vl = vector<ll>;                   //   | grep -v ' .* '  1300111 ~2^20.31
using vvl = vector<vl>;                  //                    10300777 ~2^23.30
using pll = pair<ll,ll>;                 //                   100400999 ~2^26.58
using vb = vector<bool>;                 //                  1300400999 ~2^30.28
const ll oo = 0x3f3f3f3f3f3f3f3fLL;      //                 10200500333 ~2^33.25
const double eps = 1e-9;                 //                100200400777 ~2^36.54
#define sz(c) ll((c).size())             //               1200300700111 ~2^40.13
#define all(c) begin(c),end(c)           //              10200300500777 ~2^43.21
#define mp make_pair                     //             100200300400777 ~2^46.51
#define mt make_tuple                    //            1200300400600999 ~2^50.09
#define pb push_back                     //           10200300400600111 ~2^53.18
#define eb emplace_back                  //          100200300400600333 ~2^56.48
#define xx first                         //         1200300400500800999 ~2^60.06
#define yy second                       
#define has(c,i) ((c).find(i) != end(c))
#define FOR(i,a,b) for (ll i=(a); i<(ll)(b); i++)       
#define FORD(i,a,b) for (ll i=ll(b)-1; i>=(a); i--)
/// ({ ... }) avoids some problems: http://kernelnewbies.org/FAQ/DoWhile0
/// In non-contest code it is probably better to use: do { ... } while(0)
#define TR(X) ({ if(1) cerr << "DBGDO: " << (#X) << " = " << (X) << endl; })

struct suffix_array {
	struct entry {
		pll nr;
		ll p;
		bool operator <(const entry &other) {
			return nr < other.nr;
		}
	};
	vl s;
	ll n;
	vvl P;
	vector<entry> L;
	vl idx;
	suffix_array(vl s) : s(s), n(sz(s)) {
		L = vector<entry>(n);
		P.pb(vl(n));
		idx = vl(n);
		FOR(i,0,n) {
			P[0][i] = s[i];
		}
		for (ll stp = 1, cnt = 1; (cnt >> 1) < n; stp++, cnt <<= 1) {
			P.pb(vl(n));
			FOR(i,0,n) {
				L[i].p = i;
				L[i].nr = mp(P[stp - 1][i], i + cnt < n ? P[stp - 1][i + cnt] : -1);
			}
			sort(all(L));
			FOR(i,0,n) {
				if (i > 0 && L[i].nr == L[i - 1].nr) {
					P[stp][L[i].p] = P[stp][L[i - 1].p];
				} else {
					P[stp][L[i].p] = i;
				}
			}
		}
		FOR(i,0,n) {
			idx[P[sz(P) - 1][i]] = i;
		}
	}
	//longest common prefix der Suffixe beginnend an Index x und y in O(log(n))
	ll lcp(ll x, ll y) {
		ll res = 0;
		if (x == y) return n - x;
		for (ll k = sz(P) - 1; k >= 0 && x < n && y < n; k--) {
			if (P[k][x] == P[k][y]) {
				x += 1 << k;
				y += 1 << k;
				res += 1 << k;
			}
		}
		return res;
	}
};

int main() {
    ll N;
    string S;
    cin >> N >> S;
    ll maxi = 0;
    vl data;
    for(char c : S) data.pb((ll)c);
    suffix_array ar(data);
    FOR(i,0,N)FOR(j,i+1,N){
        ll d = abs(ar.idx[j]-ar.idx[i]);
        ll l = ar.lcp(ar.idx[i],ar.idx[j]);
        if(l <= maxi) continue;
        ll r = min(d,l);
        maxi = max(maxi, r);
    }
    cout << maxi << endl;
}


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

int main() {
	int K, S;
	cin >> K >> S;

	int ans = 0;
	for (int x = 0; x <= K; x++) {
		for (int y = 0; y <= K; y++) {
			int z = S - x - y;
			if (z >= 0 && z <= K) ans++;
		}
	}

	cout << ans << endl;

	return 0;
}


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

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

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

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

    long long count=0;
    for(int i=0;i<N-K;i++){
        count += H[i];
    }

    cout << count << endl;

}

Measured memory_bytes: 1792
n=int(input())
count=0
maxs=0
for _ in range(n):
    d1,d2=map(int,input().split())
    if d1==d2:
        count+=1
    else:
        maxs=max(maxs,count)
        count=0

maxs=max(count,maxs)
if maxs>=3:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9104
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll INF = 3000000000000000000; //10^18
const int inINF = 1000000000; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;

int main(){
    int x;
    cin >> x;
    int ans;
    ans = 360/__gcd(x,360);
    printf("%d\n", ans);
}


Measured memory_bytes: 3688
#include <bits/stdc++.h>
using namespace std;
int main() {
	int sx, sy, tx, ty;
	scanf("%d%d%d%d", &sx, &sy, &tx, &ty);
	for(int i=sy;i<ty;++i) printf("U");
	for(int i=sx;i<tx;++i) printf("R");
	for(int i=sy;i<ty;++i) printf("D");
	for(int i=sx;i<tx;++i) printf("L");
	printf("L");
	for(int i=sy;i<=ty;++i) printf("U");
	for(int i=sx;i<=tx;++i) printf("R");
	printf("DR");
	for(int i=sy;i<=ty;++i) printf("D");
	for(int i=sx;i<=tx;++i) printf("L");
	printf("U\n");
}

Measured memory_bytes: 256
s = input()
prev = s[0]
count = 1

divide = []
for v in s[1:]:
    if v != prev:
        divide.append(count)
        prev = v
        count = 1
    else:
        count += 1
divide.append(count)
cum_divide = [0]*len(divide)
cum_divide[0] = divide[0]
for i in range(len(divide)-1):
    cum_divide[i+1] = cum_divide[i] + divide[i+1]
ans = [0]*len(s)
for i in range(len(divide)):
    if i%2 == 0:
        d = divide[i]
        c = cum_divide[i]
        r = (d+1)//2
        l = d - r
        ans[c-1] += r
        ans[c] += l
    else:
        d = divide[i] 
        c = cum_divide[i-1]
        l = (d+1)//2
        r = d-l
        ans[c] += l
        ans[c-1] += r
print(' '.join(map(str,ans)))
    

Measured memory_bytes: 15176
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <stdio.h>
#include <string>
using namespace std;
#define ll long long
#define mod 1000000007;

int main() {
	int n, k, x[110];
	ll ans = 0;
	cin >> n >> k;
	for (int i = 0; i < n; i++)cin >> x[i];
	for (int i = 0; i < n; i++) {
		int a, b;
		a = abs(x[i]);
		b = abs(x[i] - k);
		ans += min(a*2, b*2);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.math.*;
import java.io.*;
import java.lang.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int w = sc.nextInt();
        int h = sc.nextInt();
        int n = sc.nextInt();
        int[] x = new int[n];
        int[] y = new int[n];
        int[] a = new int[n];
        int cnt = 0;
        for (int i = 0; i < n; i++) {
            x[i] = sc.nextInt();
            y[i] = sc.nextInt();
            a[i] = sc.nextInt();
        }
        boolean[][] masu = new boolean[w+1][h+1];
        for (int i = 0; i < w+1; i++) {
            for (int j = 0; j < h+1; j++) {
                masu[i][j] = true;
            }
        }

        for (int i = 0; i < n; i++) {
            for (int j = 0; j < w; j++) {
                for (int k = 0; k < h; k++) {
                    if(a[i] == 1 && x[i] > j){
                        masu[j][k] = false;
                    }else if (a[i] == 2 && x[i] <= j){
                        masu[j][k] = false;
                    }else if (a[i] == 3 && y[i] > k){
                        masu[j][k] = false;
                    }else if (a[i] == 4 && y[i] <= k){
                        masu[j][k] = false;
                    }
                }
            }
        }
        for (int i = 0; i < w; i++) {
            for (int j = 0; j < h; j++) {
                if(masu[i][j]){
                    cnt++;
                }
            }
        }
        System.out.println(cnt);

    }
}

class io{
    public static void br(){
        System.out.println("");
    }

    public static void YesNo(boolean f) {
        System.out.println(f?"Yes":"No");
    }
    public static void YESNO(boolean f) {
        System.out.println(f?"YES":"NO");
    }

}

class Algo{
    public static boolean isOdd(int n){
        return n % 2 == 1;
    }
    public static boolean isEven(int n){
        return n % 2 == 0;
    }


}



Measured memory_bytes: 22356
import sys
N ,M = map(int, input().split())
ans = [-1]*N
for _ in range(M):
    s, c = map(int, input().split())
    if ans[s-1] != -1 and ans[s-1] != c:
        print(-1)
        sys.exit()
    else:
        ans[s-1] = c
if N == 1:
    if ans[0] == -1:
        print(0)
    else:
        print(ans[0])
else:
    if ans[0] == 0:
        cnt = -1
    else:
        if ans[0] == -1:
            cnt = 1
        else:
            cnt = ans[0]
        for i in range(1, N):
            if ans[i] == -1:
                cnt *= 10
            else:
                cnt = cnt*10 + ans[i]
    print(cnt)

Measured memory_bytes: 3064
#include "bits/stdc++.h"

// clang-format off
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 * b / gcd(a, b); }
template <typename T> T clamp(T val, T min, T max) { return val < min ? min : (max < val ? max : val); }
template <typename T> size_t max_index(T begin, T end) { return distance(begin, max_element(begin, end)); }
template <typename T> size_t min_index(T begin, T end) { return distance(begin, min_element(begin, end)); }
// clang-format on

#define int long long
#define YES "Yes"
#define NO  "No"

using namespace std;

signed main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);

  bool flag = false;
  string s; cin >> s;
  if (s == "abc") flag = true;
  if (s == "acb") flag = true;
  if (s == "bac") flag = true;
  if (s == "bca") flag = true;
  if (s == "cab") flag = true;
  if (s == "cba") flag = true;

  cout << (flag ? "Yes" : "No") << endl;
  
  return 0;
}


Measured memory_bytes: 256
n = int(input())
grid = [list(map(int, input().split())), list(map(int, input().split()))]
dist = [[0 for _ in range(n)] for _ in range(2)]
dist[0][0] = grid[0][0]
for i in range(2):
  for j in range(n):
    if j < n - 1:
      dist[i][j + 1] = max(dist[i][j + 1], dist[i][j] + grid[i][j + 1])
    if i == 0:
      dist[1][j] = max(dist[1][j], dist[0][j] + grid[1][j])
print(dist[-1][-1])

Measured memory_bytes: 3064
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include <unordered_map>
#include <math.h>
using namespace std;


int main() {
	int N,A,B,C,dec;
	cin >> N>>A>>B>>C;
	string ans,x;
	vector<string> s;
	for (int i = 0; i < N; ++i)
	{
		cin >> x;
		s.push_back(x);
	}
	for (int i = 0; i < N; ++i)
	{
		if (s[i] == "AB")
		{
			if (A < B)
			{
				if (B == 0)
				{
					cout << "No" << endl;
					return 0;
				}
				--B;
				++A;
				ans.push_back('A');
			}
			else if (A == B && A == 1 && i<N-1 && C==0 && s[i]!=s[i+1])
			{
				if (s[i + 1] == "BC")
				{
					B = 2;
					A = 0;
					ans.push_back('B');
				}
				else
				{
					B = 0;
					A = 2;
					ans.push_back('A');
				}
			}
			else
			{
				if (A == 0)
				{
					cout << "No" << endl;
					return 0;
				}
				--A;
				++B;
				ans.push_back('B');

			}
		}
		else if (s[i] == "BC")
		{
			if (C < B)
			{
				if (B == 0)
				{
					cout << "No" << endl;
					return 0;
				}
				--B;
				++C;
				ans.push_back('C');
			}
			else if (C == B && B == 1 && i < N - 1 && A == 0 && s[i] != s[i + 1])
			{
				if (s[i + 1] == "AB")
				{
					B = 2;
					C = 0;
					ans.push_back('B');
				}
				else
				{
					B = 0;
					C = 2;
					ans.push_back('C');
				}
			}
			else
			{
				if (C == 0)
				{
					cout << "No" << endl;
					return 0;
				}
				--C;
				++B;
				ans.push_back('B');

			}
		}
		else
		{
			if (C < A)
			{
				if (A == 0)
				{
					cout << "No" << endl;
					return 0;
				}
				--A;
				++C;
				ans.push_back('C');
			}
			else if (C == A && A == 1 && i < N - 1 && B == 0 && s[i] != s[i + 1])
			{
				if (s[i + 1] == "AB")
				{
					A = 2;
					C = 0;
					ans.push_back('A');
				}
				else
				{
					C = 2;
					A = 0;
					ans.push_back('C');
				}
			}
			else
			{
				if (C == 0)
				{
					cout << "No" << endl;
					return 0;
				}
				--C;
				++A;
				ans.push_back('A');

			}
		}
	}
	cout << "Yes" << endl;
	for (int i = 0; i < ans.length(); ++i)
	{
		cout << ans[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 7424
#include<iostream>
#include <iomanip>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <deque>
#include <numeric>
using namespace std;

int main() {
    int H, W;
    cin >> H >> W;
    vector<string>C(H);
    for (int i = 0; i < H; i++) {
            cin >> C[i];
    }

    for (int i = 0; i < H; i++) {
        for (int j = 0; j < 2; j++) {
            cout << C[i] << endl;
        }
    }

    return 0;
}

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

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

  vector<long long> A(N + 1);
  for(int i = 0; i < N + 1; i++){
    cin >> A[i];
  }

  long long ans = 0;
  for(int i = 0; i < N; i++){
    long long b;
    cin >> b;
    
    long long diff1 = min(b, A[i]);
    ans += diff1;
    b -= diff1;

    long long diff2 = min(b, A[i + 1]);
    ans += diff2;
    A[i + 1] -= diff2;
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
<?php
$ans = 0;
$memo = [];
$mod = 10**9+7;
fscanf(STDIN, '%d', $cnt);
$nums = array_map('intval', explode(' ', trim(fgets(STDIN))));
for ($i=0; $i < 60; $i++) { 
    $tmp = 0;
    foreach ($nums as $num) {
        $tmp += ($num>>$i) & 1;
    }
    $ans += ((($tmp % $mod) * ($cnt-$tmp)) % $mod) * ((1<<$i) % $mod);
    $ans %= $mod;
}
echo $ans."\n";


Measured memory_bytes: 40936
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

#define REP(i, n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i, n) for(ll i=(ll)(n-1);i>=0;i--)
#define FOR(i, a, b) for(ll i=(ll)(a), i<=(ll)(b); i++)
#define RFOR(i, a, b) for(ll i=(ll)(a);i>=(ll)(b); i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

signed main()
{
	string S, T;
	cin >> S >> T;
	ll A, B;
	cin >> A >> B;
	string U;
	cin >> U;
	if(S==U){
		cout << A-1 << " " << B;
	}else{
		cout << A << " " << B-1;
	}
	cout << endl;
}


Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <list>
#include <time.h>
#include <math.h>
#include <random>
#include <deque>
#include <queue>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>
#include <sstream>

using namespace std;

typedef long long ll;

mt19937 rnd(228);

int main()
{
#ifdef ONPC
    freopen("a.in", "r", stdin);
#endif
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    vector <int> a(n);
    int two = 0;
    two++;
    two++;
    vector <int> cnt(two);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        cnt[a[i] % two]++;
    }
    if (cnt[two / two] % two)
    {
        cout << "NO\n";
    }
    else
    {
        cout << "YES\n";
    }
}


Measured memory_bytes: 640
use std::io;
use std::cmp;


/// https://beta.atcoder.jp/contests/agc001/tasks/agc001_a
fn main() {
    let _ = read_one::<usize>();
    let mut ln = read::<isize>();
    ln.sort();
    let mut ans = 0;
    for i in 0..ln.len() {
        if i % 2 != 0 { continue; }
        ans += cmp::min(ln[i], ln[i + 1]);
    }
    println!("{}", ans);
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

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

using namespace std;


typedef long long ll;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;

#define rep(i,b) for(i=0;i<b;++i)
#define repp(i,a,b) for(i=a;i<b;++i)

int main() {
    string s;
    cin >> s;
    int l;
    l = s.length();
    cout << string(l,'x');
    return 0;
}
/*
         ,--"""",--.__,---[],-------._
       ,"   __,'            \         \--""""""==;-
     ," _,-"  "/---.___     \       ___\   ,-'',"
    /,-'      / ;. ,.--'-.__\  _,-"" ,| `,'   /
   /``""""-._/,-|:\       []\,' ```-/:;-. `. /
             `  ;:::      ||       /:,;  `-.\
                =.,'__,---||-.____',.=
                =(:\_     ||__    ):)=
               ,"::::`----||::`--':::"._
             ,':::::::::::||::::::::::::'.
    .__     ;:::.-.:::::__||___:::::.-.:::\     __,
       """-;:::( O )::::>_|| _<::::( O )::::-"""
   =======;:::::`-`:::::::||':::::::`-`:::::\=======
    ,--"";:::_____________||______________::::""----.          , ,
         ; ::`._(    |    |||     |   )_,'::::\_,,,,,,,,,,____/,'_,
       ,;    :::`--._|____[]|_____|_.-'::::::::::::::::::::::::);_
      ;/ /      :::::::::,||,:::::::::::::::::::::::::::::::::::/
     /; ``''''----------/,'/,__,,,,,____:::::::::::::::::::::,"
     ;/                :);/|_;| ,--.. . ```-.:::::::::::::_,"
    /;                :::):__,'//""\\. ,--.. \:::,:::::_,"
   ;/              :::::/ . . . . . . //""\\. \::":__,"
   ;/          :::::::,' . . . . . . . . . . .:`::\
   ';      :::::::__,'. ,--.. . .,--. . . . . .:`::`
   ';   __,..--'''-. . //""\\. .//""\\ . ,--.. :`:::`
   ;    /  \\ .//""\\ . . . . . . . . . //""\\. :`::`
   ;   /       . . . . . . . . . . . . . . . . .:`::`
   ;   (          . . . . . . . . . . . . . . . ;:::`
   ,:  ;,            . . . . . . . . . . . . . ;':::`
   ,:  ;,             . . . . . . . . . . . . .;`:::
   ,:   ;,             . . . . . . . . . . . . ;`::;`
    ,:  ;             . . . . . . . . . . . . ;':::;`
     :   ;             . . . . . . . . . . . ,':::;
      :   '.          . . . . . . . .. . . .,':::;`
       :    `.       . . . . . . . . . . . ;::::;`
        '.    `-.   . . . . . . . . . . ,-'::::;
          `:_    ``--..___________..--'':::::;'`
             `._::,.:,.:,:_ctr_:,:,.::,.:_;'`
________________`"\/"\/\/'""""`\/"\/""\/"____________________________

*/


Measured memory_bytes: 256
D=int(input())
clist=list(map(int,input().split()))
smat=[[int(x) for x in input().split()] for _ in range(D)]
#print(clist)
#print(smat)

max_index_c=-1
max_c=-1
for i in range(26):
  if max_c<clist[i]:
    max_index_c=i+1
    max_c=clist[i]

for d in range(D):
  max_index=-1
  max_sd=-1
  for i in range(26):
    if max_sd<smat[d][i]:
      max_index=i+1
      max_sd=smat[d][i]
      
  if max_index_c==max_index:
    print(max_index)
  else:
    if max_c>max_sd:
      print(max_index_c)
    else:
      print(max_index)

Measured memory_bytes: 74892
#include <stdio.h>
int main() {int N;double x1,x2,x3,x4,y1,y2,y3,y4;scanf("%d",&N);while (N--) {scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4);double A1=y2-y1,A2=y4-y3,B1=x1-x2,B2=x3-x4;if (A1*B2==A2*B1) puts("YES"); else puts("NO");}return 0;}

Measured memory_bytes: 0
/*
 * Created by Dipta Das on 16-05-2019
 * Title: 
 * Problem Link: 
 * Editorial: 
 * Source Code: 
 * Comments: 
*/

#include <bits/stdc++.h>
#include <stdio.h>
#define fin freopen("input", "r", stdin)
#define whatis(x) cerr << #x << ": " << x << endl;

using namespace std;
using ll = long long;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);

    int a, b, c;
    cin >> a >> b >> c;
    vector<int> ans;

    for (int i = 1; i <= min(a, b); ++i) {
        if (a % i == 0 && b % i == 0) ans.push_back(i);
    }

    cout << ans[ans.size() - c] << endl;
    


    return 0;
}



Measured memory_bytes: 256
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

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

    int a, b;
    cin >> a >> b;
    if (a > b) swap(a, b);

    for (int i = 0; i < b; i++) {
        cout << a;
    }
    cout << '\n';
    return 0;
}

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

int cnt[15], ans;
bool may[27];

inline void check()
{
    //printf("! 0");
    int tmp = 12;
    for (int i = 1, j = 0; i <= 24; ++i)
    {
        if (may[i])
        {
            //printf(" %d", i);
            int diff = i - j;
            if (diff > 12)
            {
                diff = 24 - diff;
            }
            tmp = tmp < diff ? tmp : diff;
            j = i;
        }
    }
    ans = ans > tmp ? ans : tmp;
    //printf("\n");
}

void dfs(int deep)
{
    if (deep == 13)
    {
        check();
        return;
    }
    if (cnt[deep] == 0)
    {
        dfs(deep + 1);
    }
    else if (cnt[deep] == 1)
    {
        may[deep] = true;
        dfs(deep + 1);
        may[deep] = false;
        may[24 - deep] = true;
        dfs(deep + 1);
        may[24 - deep] = false;
    }
    else
    {
        may[deep] = true;
        may[24 - deep] = true;
        dfs(deep + 1);
        may[deep] = false;
        may[24 - deep] = false;
    }
}

int main()
{
    int n;
    while (scanf("%d", &n) != EOF)
    {
        memset(cnt, 0, sizeof cnt);
        cnt[0] = 2;
        cnt[12] = 1;
        bool flag = false;
        for (int i = 0; i < n; ++i)
        {
            int t;
            scanf("%d", &t);
            ++cnt[t];
            if (cnt[t] > 2)
            {
                flag = true;
            }
        }
        if (flag)
        {
            printf("0\n");
            continue;
        }
        if (cnt[12] == 1)
        {
            cnt[12] = 0;
        }
        ans = 0;
        //memset(may, false, sizeof may);
        dfs(0);
        printf("%d\n", ans);
    }
    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <algorithm>
#include <iostream>
using namespace std;

// Self settings
// clang-format off
#define MAX_N 10000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
void myscanf(const char *fmt, int num, int *s, int *v) { REP(i,num) scanf(fmt, &s[i], &v[i]); }
void myscanf(const char *fmt, int num, int *s) { REP(i,num) scanf(fmt, &s[i]); }
// clang-format on

int n;
int w[101];

int main(void)
{
  cin >> n;
  REP(i, n) cin >> w[i];
  int diff = 10000;
  for (int t = 0; t < n; ++t) {
    int j = 0;
    int diffL = 0;
    while (j <= t) {
      diffL += w[j];
      j++;
    }

    j = t + 1;
    int diffR = 0;
    while (j < n) {
      diffR += w[j];
      j++;
    }
    diff = min(diff, abs(diffL - diffR));
  }
  cout << diff << endl;
  return 0;
}


Measured memory_bytes: 256
<?php

fscanf(STDIN, "%d %d", $n, $k);
$list = explode(" ", trim(fgets(STDIN)));

for($i = $n; $i <= 100000; $i++){

    $na = str_split($i);
    $cnt = 0;

    foreach($na as $value){

        if(in_array($value, $list)){
            continue 2;
        };

        $cnt += 1;

        if($cnt == count($na)){
            print($i);
            exit;
        }

    }

}


Measured memory_bytes: 4604
import java.util.Scanner;
public class Main{
    public static void main(String args[]){
      int n,i;
      int[] a;
      a = new int[100];
      
      Scanner scan = new Scanner(System.in);
      n = scan.nextInt();
      for(i=0;i<n;i++){
          a[i] = scan.nextInt();
      }

      for(i=n-1;i>0;i--){
          System.out.print(a[i]+" ");
      }
      System.out.println(""+a[0]);
      
    }
    
}


Measured memory_bytes: 26296
import math
n, k = map(int, input().split())
"""
def cmb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

mod = 10**9+7
"""
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 2000
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

for i in range(1, k + 1):
    print((cmb(n - k + 1, i, mod) * cmb(k - 1, i - 1, mod)) % mod)
    #print(cmb(n - k + 1, i))
    #print(cmb(k - 1, i - 1))


Measured memory_bytes: 3572
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
int main(void) {
  int n, a, b;
  cin >> n >> a >> b;
  vector<int> x(n);
  cin >> x[0];
  ll ans = 0;
  for (int i = 1; i < n; i++) {
    cin >> x[i];
    ans += min(1LL * (x[i] - x[i - 1]) * a, 1LL * b);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <math.h>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define rrep(i,a) for(int i = a; i >= 0; i--)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

/*
// 最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

// 最小公倍数
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}*/

vector<ll> cnt(5, 0);

ll solve(int a, int b, int c) {
	return cnt[a] * cnt[b] * cnt[c];
}

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

	int n;
	cin >> n;
	vector<string> s(n);
	rep(i, n) cin >> s[i];

	// MARCHのどれかしか選べない

	// 5C3=10通りやる
	vector<char> c{ 'M', 'A', 'R', 'C', 'H' };
	// m a r c hから始まる人の数
	rep(i, n) {
		rep(j, 5) {
			if (s[i][0] == c[j]) {
				cnt[j]++;
			}
		}
	}

	ll ans = 0;
	ans += solve(0, 1, 2);
	ans += solve(0, 1, 3);
	ans += solve(0, 1, 4);
	ans += solve(0, 2, 3);
	ans += solve(0, 2, 4);
	ans += solve(0, 3, 4);
	ans += solve(1, 2, 3);
	ans += solve(1, 2, 4);
	ans += solve(1, 3, 4);
	ans += solve(2, 3, 4);

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 5760
#include<cstdio>
int main(void){
int w;
int h;
for(;;){
scanf("%d %d",&w,&h);
if(w==0&&h==0) break;

else{
for(int i=0;i<w;i++){
for(int j=0;j<h;j++){
if((i+j)%2==0)printf("#");
else printf(".");
}
printf("\n");
}
printf("\n");
}
}
return 0;
}

Measured memory_bytes: 2592
#include <bits/stdc++.h>
#include<iostream>
#include<cmath>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
using ll=long long;
using P=pair<int,int>;
const int INF=1001001001;

int main(){
   int a,b,c,d; cin>>a>>b>>c>>d;
   if((abs(b-a)<=d&&abs(c-b)<=d) || abs(c-a)<=d) cout<<"Yes"<<endl;
   else cout<<"No"<<endl;
   return 0;
}


Measured memory_bytes: 256
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
from math import sqrt, pi
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul, itemgetter
from functools import reduce
from bisect import bisect_left, bisect_right

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

#############
# Main Code #
#############

n, k = getNM()
imos = [[0 for i in range(k)] for j in range(k)]
white = 0
for i in range(n):
    x, y, c = input().split()
    x = int(x)
    y = int(y)
    if c == "W":
        c = 1
    else:
        c = 0
    x %= 2*k
    y %= 2*k

    if x > k-1:
        x -= k
        c += 1
    if y > k-1:
        y -=k
        c += 1
    c %= 2

    if c == 1:
        white += 1
        imos[x][y] -= 1
    else:
        imos[x][y] += 1

for i in range(k):
    for j in range(k-1):
        imos[i][j+1] += imos[i][j]

for j in range(k):
    for i in range(k-1):
        imos[i+1][j] += imos[i][j]

ans = 0
for i in range(k):
    for j in range(k):
        exp = imos[k-1][k-1] - imos[k-1][j] - imos[i][k-1] + 2 * imos[i][j] + white
        ans = max(ans, max(exp, n - exp))

print(ans)

Measured memory_bytes: 93900
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
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; }
//------------------------------------------------------------------------------
const int MAX_N = 200000;
int white[MAX_N + 10];
//------------------------------------------------------------------------------
void _main()
{
    int N;
    string S;
    cin >> N >> S;
    white[0] = S[0] == '.' ? 1 : 0;
    rep(i, 1, N)
    {
        if (S[i] == '.')
        {
            white[i] = white[i - 1] + 1;
        }
        else
        {
            white[i] = white[i - 1];
        }
    }
    int ans = N;
    bool find = false;
    rep(i, 0, N - 1)
    {
        if (S[i] == '.' && S[i + 1] == '#')
        {
            int cnt = 0;
            cnt += i + 1 - white[i];
            cnt += white[N - 1] - white[i];
            ans = min(ans, cnt);
            find = true;
        }
    }
    if (!find)
    {
        ans = min(white[N - 1], N - white[N - 1]);
    }
    cout << ans << endl;
}


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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = 1001001001;
#define mins(x, y) x = min(x, y)
#define maxs(x, y) x = max(x, y)

typedef tuple<string, int, int> T;

int main() {

    ll r, d, x2000;

    cin >> r >> d >> x2000;

    ll now = x2000;
    for (ll i = 0; i < 10; i++) {
        now = now * r - d;
        cout << now << endl;
    }

}



Measured memory_bytes: 256
import sys

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def main():
    N = ii()
    A = [0]+list(mi())+[0]
    S = sum(abs(A[i]-A[i+1]) for i in range(N+1))
    l = [S-abs(A[i]-A[i+1])-abs(A[i+1]-A[i+2])+abs(A[i]-A[i+2]) for i in range(N)]
    print(*l, sep='\n')


if __name__ == '__main__':
    main()


Measured memory_bytes: 90880