akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int                     long long   
#define double                  long double
#define endl                    "\n"
#define pb                      push_back
#define PI                      3.1415926535897932384626433832795l
#define F                       first
#define S                       second
#define mp                      make_pair
#define f(i,n)                  for(int i=0;i<n;i++)
#define fastio                  ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v)                  (v).begin(),(v).end()
#define rall(v)                 (v).rbegin(),(v).rend()
#define gcd(a,b)                __gcd((a),(b))
#define fill(a,value)           memset(a,value,sizeof(a));
#define minn(v)                 *min_element(v.begin(), v.end());
#define maxx(v)                 *max_element(v.begin(), v.end());
#define print(x)                cout<<(x)<<endl;
#define sum(v)+x                accumulate(v.begin(), v.end(),x);
#define debug(x)                cout<<#x<<'='<<(x)<<endl;
typedef pair<int,int>           pii;
typedef vector<int>             vi;
signed main() 
{
    fastio;
    cout << fixed << setprecision(12);
    int n;
    cin>>n;
    string s;
    cin>>s;
    int i=0;
    int j=n-1;
    int ans=0;
    while(i<j)
    {
        if(s[i]=='W' and s[j]=='R')
        {
            i++;
            j--;
            ans++;
        }
        else if(s[i]=='W')j--;
        else if(s[j]=='R')i++;
        else
        {
            i++;j--;
        }
        
    }
    print(ans)
    return 0;
}


Measured memory_bytes: 3768
from sys import stdin
import statistics
from math import factorial
import math
from itertools import permutations

n = int(stdin.readline().rstrip())
li = [list(map(int,stdin.readline().rstrip().split())) for _ in range(n)]

lis = []
lin = list(permutations(li,n))

for i in range(len(lin)):
    liv = []
    for j in range(1,len(lin[0])):
        a = (lin[i][j-1][1]-lin[i][j][1])**2
        b = (lin[i][j-1][0]-lin[i][j][0])**2
        c = math.sqrt(a+b)
        liv.append(c)
    lis.append(sum(liv))
print(sum(lis)/len(lin))

Measured memory_bytes: 11548
#include <iostream>
#include <algorithm>
using namespace std;
static const int NMax = 200000;

int main()
{
	int R[NMax] = { 0 };
	int maxv, minv;
	int n;

	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> R[i];
	}

	maxv = -2000000000;
	minv = R[0];
	for (int i = 1; i < n; i++) {
		maxv = max(maxv, R[i] - minv);
		minv = min(minv, R[i]);
	}

	cout << maxv << endl;

	return 0;
}


Measured memory_bytes: 3896
#include <stdio.h>

#define MAX_H 500000
int H;

int parent(int i) {return i / 2;}
int left(int i) {return 2 * i;}
int right(int i) {return 2 * i + 1;}


void MaxHeapif(int A[], int i) {
	int l, r, largest, tmp;
	l = left(i);
	r = right(i);
	
	if (l <= H && A[l] > A[i]) {
		largest = l;
	} else {
		largest = i;
	}

	if (r <= H && A[r] > A[largest]) {
		largest = r;
	}

	if (largest != i) {
		tmp = A[i];
		A[i] = A[largest];
		A[largest] = tmp;
		MaxHeapif(A, largest);
	}
}

void buildMaxHeap(int A[]) {
	int i;
	for (i = H/2; i > 0; --i) {
		MaxHeapif(A, i);
	}
	return;
}

int main(void) {
	int i, A[MAX_H+1] = {0};
	
	scanf("%d", &H);
	for (i = 1; i <= H; ++i) {
		scanf(" %d", &A[i]);
	}

	buildMaxHeap(A);
	
	for (i = 1; i <= H; ++i) {
		printf(" %d", A[i]);
	}
	putchar('\n');
	/* for (i = 1 ; i <= H; i++) { */
	/* 	printf("node %d: key = %d, ", i, A[i]); */
	/* 	if (parent(i) >= 1) printf("parent key = %d, ", A[parent(i)]); */
	/* 	if (left(i) <= H) printf("left key = %d, ", A[left(i)]); */
	/* 	if (right(i) <= H) printf("right key = %d, ", A[right(i)); */
	/* 	printf("\n"); */
	/* } */
	
	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define __ <<' '<<
#define ___ <<' '
#define bash push_back
#define ALL(x) x.begin(),x.end()
//#define int long long

struct IoSetup {IoSetup() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout <<fixed<<setprecision(12);
    cerr <<fixed<<setprecision(12);
}}IoSetup;

using ll = long long;
using pii = pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int SMOD = 1000000007;
constexpr int NMOD = 998244353;
constexpr int dx[]={1,0,-1,0,1,1,-1,-1};
constexpr int dy[]={0,1,0,-1,-1,1,-1,1};

inline bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>bool chmax(T &a, const T &b){return(a<b?a=b,true:false);}
template<class T>bool chmin(T &a, const T &b){return(a>b?a=b,true:false);}
inline int qp(int a,ll b,int mo){ll ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}


signed main() {

    int n, d;

    cin >> n >> d;


    cout << max(-1, (n + d * 2) /(d * 2 + 1) ) << endl;
  
    return 0;
}



Measured memory_bytes: 256
get_number(Number) :-
    get_string(String),
    number_string(Number, String).

get_string(String) :-
    current_input(Input),
    read_string(Input, ' \n', '', _, String).

/* memo
    code(int)
    string_code(1, S, C), (C: code)
    char_code(X, Y) (X: char, Y: code)
    string_chars(S, S2)

    f(0, [], []).
    f(Z, [X|Xs], [Y|Ys]) :- X = Y, f(Z1, Xs, Ys), Z is Z1 + 1.
    f(Z, [_|Xs], [_|Ys]) :- f(Z, Xs, Ys).
*/

f([A,A,B,B]) :- A \= B.
f([A,B,A,B]) :- A \= B.
f([B,A,B,B]) :- A \= B.
f([A,B,B,A]) :- A \= B.
f([B,A,B,A]) :- A \= B.
f([B,B,A,A]) :- A \= B.

main :-
    get_string(S),
    string_chars(S, S2),
    (f(S2)) -> writeln("Yes") ; writeln("No").


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

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

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

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

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

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

const long long mod = 998244353;

// auto mod int
struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

// combination mod prime
struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};

int main(){
    int n, m, k;
    cin >> n >> m >> k;
    mint tmp = m, ans = 0;
    combination c(n-1);
    repr(i, n) {
        if (i <= k) ans += tmp * c(n-1, i);
        tmp *= m - 1;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6428
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pii pair<int,int>
#define pli pair<long long int,int>
#define pbi pair<bool,int>
#define pob pop_back
#define all(a) a.begin(),a.end()
#define fio ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
#define i64 long long int
#define mem(x,y) memset(x,y,sizeof(x))
#define fill(arr,b) fill(arr, arr+sizeof(arr)/sizeof(arr[0]), b)
#define maxarr(n,arr,m) m =-1e9;for(int i=0;i<n;i++)if(arr[i]>m) m=arr[i];
#define read freopen("input.txt","r",stdin);

const double pi = acos(-1.0);
const int maxn = (i64)2e9+5;

int main()
{
   double r;
   cin >> r;
   cout << 2.0*pi*r;
   return 0;
}


Measured memory_bytes: 3796
import sys,collections,math,random;sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

n,m = Is()
left,right = 0,n
for i in range(m):
    l,r = Is()
    left = max(left,l)
    right = min(right,r)
#    print(left,right)
if right-left < 0:
    print(0)
else:
    print(right-left+1)

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

using i32 = int_fast32_t;
using i64 = int_fast64_t;

vector<i32> num;

void solve(i64 n) {
    if (n >= 1e10) return;
    num.push_back(n);
    i64 d = n % 10;
    for (i32 i = max(0l, d-1); i <= min(9l, d+1); i++) {
        solve(n * 10 + i);
    }
}

int main() {
    i32 k;
    cin >> k;
    for (i32 i = 1; i < 10; i++) {
        solve(i);
    }

    sort(begin(num), end(num));
    cout << num[k-1] << endl;
}


Measured memory_bytes: 2420
import scala.io.StdIn.readLine

object Main extends App {
  def gcd(x:Int,y:Int):Int = if(y>0) { if(x>=y) gcd(y,x%y) else gcd(x,y%x) } else x

  val Array(x,y) = readLine.split(" ").map(_.toInt)
  println(gcd(x,y))
}

Measured memory_bytes: 44012
#include <bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(false); //cin.tie(NULL); cout.tie(NULL)
#define mp make_pair
#define pb push_back
#define fs first
#define sc second

using namespace std;
typedef long long ll;
typedef long double ld;

/* BIEN CUC BO BEGIN*/
	ll t, n, A[3][102], w;
	
	ll DD[200012], ans;
/* BIEN CUC BO END*/

int main(){ FIO;
	cin >> n >> w;
	for (int i=1; i<=n; ++i){
		cin >> A[1][i] >> A[2][i];
		for (int j=w; j>=0; --j){
			DD[j+A[1][i]] = max(DD[j+A[1][i]], DD[j] + A[2][i]);
		}
	}
	
	for (int i=0; i<=w; ++i){
		ans = max(ans,DD[i]);
	}
	
	cout << ans;
return 0;}	

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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define sumvec(v) accumulate(all(v),0)
#define mapmax(v) v.rbegin()->first
#define mapmin(v) v.begin()->first
#define pb push_back
#define pf push_front
#define mod 1000000007
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK puts("OK")
#define OK1 puts("OK1")
#define OK2 puts("OK2")
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n

typedef long long ll;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;

typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

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

void YES(bool b) {cout << (b?"YES\n":"NO\n");}
void Yes(bool b) {cout << (b?"Yes\n":"No\n");}
void yes(bool b) {cout << (b?"yes\n":"no\n");}
void Yay(bool b) {cout << (b?"Yay!\n":":(\n");}

ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

int main()
{
	ll n,k,sum=0;
	cin >> n >> k;
	for(ll i=1;i<=n;i++){
		sum+=n/i*max(0LL,i-k)+max(0LL,n%i-k+1);
	}
	if(k==0) sum-=n;
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=200010;
ll h[N];
ll n,ans;
map<ll,ll> m;
int main()
{
	scanf("%lld",&n);
	for(ll i=1;i<=n;++i){
		scanf("%lld",&h[i]);
		++m[i-h[i]];
	}
	ans=0;
	for(ll i=1;i<=n;++i){
		//--m[i-h[i]];
		ans+=m[i+h[i]];
	}
	printf("%lld\n",ans);
}

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

int main() {
	for(int i=1; i<=3000; i++){
		int x, y;
		cin >> x >> y;
		if(x == 0 && y == 0) return 0;
		if(x > y) cout << y << " " << x << endl;
		else cout << x << " " << y << endl;
	}
	return 0;
}


Measured memory_bytes: 3092
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#include <deque>
#include <iterator>
#include <map>
#include <queue>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
using namespace std;

#define EPS (1e-10)
using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define equals(a, b) (fabs((a) - (b)) < EPS)
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;}

const ll MOD = 1000000007;
const ll HIGHINF = 1e18;

// 点を表すクラス
class Point{
public:
  double x, y;
  Point(double x=0, double y=0): x(x), y(y) {}

  Point operator + (Point p) {return Point(x+p.x, y+p.y);}
  Point operator - (Point p) {return Point(x-p.x, y-p.y);}
  Point operator * (double a) {return Point(a*x, a*y);}
  Point operator / (double a) {return Point(x/a, y/a);}

  double abs() {return sqrt(norm());}
  double norm() {return x*x + y*y;}

  bool operator < (const Point &p) const {
    return x != p.x ? x < p.x: y < p.y;
  }

  bool operator == (const Point &p) const {
    return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS;
  }
};
typedef Point Vector;  // ベクトルを表す構造体（成分表示）

double dot(Vector a, Vector b) {  // ベクトルの内積
  return a.x*b.x + a.y*b.y;
}
double cross(Vector a, Vector b) {  // ベクトルの外積
  return a.x*b.y - a.y*b.x;
}

struct Segment {Point p1, p2;};  // 線分を表す構造体(p1:始点、p2:終点)
typedef Segment Line;  // 直線を表す構造体（直線は無限長にする必要あり）

// 直交判定
bool isOrthogonal(Vector a, Vector b) {  // ベクトル同士の直交判定
  return equals(dot(a, b), 0.0);
}
bool isOrthogonal(Point a1, Point a2, Point b1, Point b2) {  // a1とa2、b1とb2をそれぞれ端点にもつ線分の直交判定
  return isOrthogonal(a1-a2, b1-b2);
}
bool isOrthogonal(Segment s1, Segment s2) {  // 線分s1、s2の直交判定
  return equals(dot(s1.p2-s1.p1, s2.p2-s2.p1), 0.0);
}

// 平行判定
bool isParallel(Vector a, Vector b) {  // ベクトル同士の平行判定
  return equals(cross(a, b), 0.0);
}
bool isParallel(Point a1, Point a2, Point b1, Point b2) {  // a1とa2、b1とb2をそれぞれ端点にもつ線分の平行判定
  return isParallel(a1-a2, b1-b2);
}
bool isParallel(Segment s1, Segment s2) {  // 線分s1、s2の平行判定
  return equals(cross(s1.p2-s1.p1, s2.p2-s2.p1), 0.0);
}

// 線分sに対する点pの射影
Point project(Segment s, Point p) {
  Vector base = s.p2 - s.p1;
  double r = dot(p - s.p1, base) / base.norm();
  return s.p1 + base * r;
}

// 線分sを対称軸とした点pの線対称な点
Point reflect(Segment s, Point p) {
  return p + (project(s, p) - p) * 2.0;
}

class Circle {  // 円を表す構造体
public:
  Point c;  // 中心
  double r;  // 半径
  Circle(Point c=Point(), double r=0.0): c(c), r(r) {}
};

typedef V<Point> Polygon;  // 多角形を表す構造体（頂点座標の配列）

int main() {
  ll x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  Segment seg; seg.p1 = Point(x1, y1); seg.p2 = Point(x2, y2);
  ll q; cin >> q;
  REP(i, q) {
    ll x, y; cin >> x >> y;
    Point p = reflect(seg, Point(x, y));
    cout << fixed << setprecision(10) << p.x << ' ' << p.y << endl;
  }
  return 0;
}



Measured memory_bytes: 3268
#include<bits/stdc++.h>
using namespace std;
 
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
 
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define ld long double
#define forn(low,high,i) for(i = low;i < high;i++)
#define forrev(high,low,i) for(i = high; i >= low;i--)
#define trace(x) cerr << #x << ": " << x << " " << endl;
#define all(v) v.begin(),v.end()
#define sz(v) (int)v.size()
#define line cout << __LINE__;
#define prv(a) for(auto x : a) cout << x << ' ';cout << '\n';
#define decimal_digits cout << fixed << setprecision(15);
#define dbg2(a,b) cerr << #a << " = " << a << " " << #b << " = " << b << '\n';        
#define debug(x) cerr << __LINE__ << ' ' << #x << " = " << x << '\n';
#define dln cerr << '\n';
#define dsp cerr << ' ';
#define pln cout << '\n';
#define psp cout << ' ';
 
typedef unordered_map<int,int> umi;
typedef unordered_map<ll,ll> uml;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
const int inf = 1e9;
const ll INF = 1e18;
const ll mod = 1e9 + 7;

inline ll add(ll a, ll b){
  return ((a % mod) + (b % mod)) % mod;
}
inline ll sub(ll a, ll b){
  return ((a % mod) - (b % mod) + mod) % mod;
}
inline ll mul(ll a, ll b){
  return ((a % mod) * (b % mod)) % mod;
}
inline ll modexpo(ll a, ll b){
  ll res = 1;
  while(b){
    if(b & 1){
      res = mul(res, a);
    }
    a = mul(a, a);b /= 2;
  }
  return res;
}
inline ll divide(ll a, ll b){
  return mul(a, modexpo(b, mod - 2));
}
 
clock_t time_p = clock();
 
void ktj(){
  time_p = clock() - time_p;
  cerr << "Time elapsed : " << (float)(time_p)/CLOCKS_PER_SEC << "\n";
}
  
int main(){
  fastio
  string s, t;
  cin >> s >> t;
  int ans = (s[0] == t[0]);
  ans += (s[1] == t[1]);
  ans += (s[2] == t[2]);
  cout << ans << '\n'; 
  ktj();
}

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

#define range 100005
#define mod 1000000007
#define eps 1e-9
#define PI 3.14159265358979323846
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define ALL(V) V.begin(), V.end()
#define _ <<" "<<

using namespace std;

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

int dp[200000][3];

int main(int argc, char const *argv[])
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	//freopen("test.txt","r",stdin);
	int n;
	cin>>n;
	int a[n+1],b[n+1],c[n+1];
	for (int i = 1; i <=n; i++) {
	    cin>>a[i]>>b[i]>>c[i];
	}
	dp[1][0] = a[1];
	dp[1][1] = b[1];
	dp[1][2] = c[1];
	for (int i = 2; i <=n; i++) {
	    dp[i][0] = max(dp[i-1][1],dp[i-1][2]) + a[i];
	    dp[i][1] = max(dp[i-1][0],dp[i-1][2]) + b[i];
	    dp[i][2] = max(dp[i-1][0],dp[i-1][1]) + c[i];
	}
	cout<<max(max(dp[n][0],dp[n][1]) , max(dp[n][1],dp[n][2]));
	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#include <regex>
#ifdef _DEBUG
#include "debug.h"
#endif
#define int ll
#define FOR(i, s, e) for (int i = int(s); i < int(e); ++i)
#define REP(i, e) FOR(i, 0, e)
#define mkpr make_pair
#define mktp make_tuple
#define tv(tp, i) get<(i)>(tp)
#define CLEAR(obj) obj = decltype(obj)()
#define var auto
#define OUT(type) type &
#define IN(type) const type &
#define self (*this)
#define in :
#define True true
#define False false
using namespace std; using str = string; using cstr = const str;
using ll = long long; using ull = unsigned long long; using cint = const int; using cll = const ll;
using vi = vector<int>; using vvi = vector<vi>; using vl = vector<ll>; using vvl = vector<vl>;
using vb = vector<bool>; using vvb = vector<vb>; using vd = vector<double>; using vvd = vector<vd>;
using vc = vector<char>; using vvc = vector<vc>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>; using pdd = pair<double, double>; using psl = pair<string, ll>;
using tiii = tuple<int, int, int>; using tlll = tuple<ll, ll, ll>;
static const int MGN = 10; static const int ARYSZ_MAX = (int)1e7;
static const ll LINF = LLONG_MAX/2;
#ifdef int
static const int INF = LINF;
#else
static const int INF = INT_MAX/2;
#endif
static double EPS = 1e-9;
static inline bool DBLEQ(double a, double b) {return abs(a - b) < EPS;}
static inline void EPR(str msg) {cerr << msg << endl;}
static inline void AST(bool exp, str msg) {if(!exp){EPR(msg);} assert(exp);}
static inline void TAST(bool exp, str msg) {if(!exp){EPR(msg);} while(!exp){}}


int32_t main(int32_t argc, char* argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef _DEBUG
    vs args(argv, argv+argc);
    string sample = make_sample(args, 1);
    ifstream ifs(sample); cin.rdbuf(ifs.rdbuf());
#endif


    int X,Y,Z; cin>>X>>Y>>Z;

    swap(X,Y);
    swap(X,Z);

    cout << X << " " << Y << " " << Z << endl;


    return 0;
}


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

int main()
{
	int a,b,c,l;cin>>a>>b>>c;
	l=a%b;
	for(int i=2;;i++)
	{
		if(a*i%b==c) {puts("YES");return 0;}
		if(a*i%b==l) {puts("NO");return 0;}
	}
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string.h>
#include<cmath>
#include<deque>
#include<set>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define INF 1LL << 60
#define MAX 1000000000
const double PI = 3.14159265358979323846;
int gcd(int a, int b) { return a % b == 0 ? b : gcd(b, a % b); }
int main() {
	int N, M, s = 0, t;
	scanf("%d%d", &N, &M);
	rep(i, 0, M)scanf("%d", &t), s += t;
	if (N - s >= 0)printf("%d\n", N - s);
	else printf("-1\n");
	return 0;
}

Measured memory_bytes: 1736
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
vector<int>ar[200001];
int vis[200001];
int s;
int maximum=INT_MIN;
void DFS(int node){
   vis[node]=1;
   s++;
   
   for(int child:ar[node]){
       if(!vis[child]){
         DFS(child);
       }
   }

}
int main(){
  int n,m,a,b;
  cin>>n>>m;
  for(int i=1;i<=m;i++){
      cin>>a>>b;
     ar[a].push_back(b);
     ar[b].push_back(a); 

  }
 for(int i=1;i<=n;i++){
    if(!vis[i]){
      s=0;
      DFS(i);
     maximum=max(maximum,s);
    }
 }
	
cout<<maximum<<endl;
	return 0;
}

Measured memory_bytes: 21472
import math
def I(): return int(input())
##################################################
N = I()
ans = 0
for i in range(1,N+1):
    for j in range(1,N+1):
        temp = math.gcd(i,j)
        for k in range(1,N+1):
            ans += math.gcd(temp,k)
print(ans)


Measured memory_bytes: 9176
#include<bits/stdc++.h>
#define L long long
using namespace std;
const L m=1000000000000000000ll;
L a,b,c,d,n,p;
inline L orz(L c,L a,L b)
{
    if(a==-1 || b==-1 || m/c<(a+b))
      return -1;
    else
      return c*(a+b);
}
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int i;
	scanf("%lld%lld%lld%lld",&a,&b,&c,&n);
	if(n&1)
	  printf("%lld\n",b-a);
	else
	  printf("%lld\n",a-b);
	return 0;
}


Measured memory_bytes: 256
#include <stdbool.h>
#include <stdio.h>
int n, m, x, c[12], a[12][12] = {0};
int b[12];
int cost = 1e9;
void dfs(int bit, int len) {
	if (len == n) {
		int u[12] = {0};
		int co = 0;
		for (int i = 0; i < n; i++) {
			if (b[i]) {
				co += c[i];
				for (int j = 0; j < m; j++) {
					u[j] += a[i][j];
				}
			}
		}
		bool isOK = true;
		for (int i = 0; i < m; i++) {
			if (u[i] < x) {
				isOK = false;
				break;
			}
		}
		if (isOK && cost > co) {
			cost = co;
		}
		return;
	}
	b[len] = bit;
	for (int i = 0; i < 2; i++) {
		dfs(i, len + 1);
	}
	return;
}
int main() {
	scanf("%d%d%d", &n, &m, &x);
	for (int i = 0; i < n; i++) {
		scanf("%d", &c[i]);
		for (int j = 0; j < m; j++) {
			scanf("%d", &a[i][j]);
		}
	}
	dfs(0, 0);
	dfs(1, 0);
	printf("%d\n", cost == (int)1e9 ? -1 : cost);
	return 0;
}


Measured memory_bytes: 1736
import networkx as nx
room, route_count = map(int,input().split())
route = [list(map(int,input().split())) for _ in range(route_count)]

G = nx.Graph()
G.add_nodes_from(range(1,room+1))
G.add_edges_from(route)
pre = nx.predecessor(G, 1)

print('Yes')
for i in range(2,room+1):
  print(pre[i][0])


Measured memory_bytes: 225240
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<bitset>

using namespace std;
typedef long long ll;
#define i_7 1000000007
#define i_5 1000000005

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
#define inf 100000000/*10^8*/



////////////////////////////////////////



int main(){
    int n;cin>>n;
    char s[55][55];for(int i=0;i<=n-1;i++)cin>>s[i];
    int a[55][30];memset(a,0,sizeof(a));
    for(int i=0;i<=n-1;i++){
        int len=strlen(s[i]);
        for(int j=0;j<len;j++){
            a[i][s[i][j]-'a']++;
        }
    }
    for(int i=0;i<=25;i++){
        int min=inf;
        for(int j=0;j<=n-1;j++){
            if(a[j][i]<min)min=a[j][i];
        }
        a[54][i]=min;
    }
    for(int i=0;i<=25;i++){
        while(a[54][i]--){
            cout<<char('a'+i);
        }
    }cout<<endl;
    
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"strings"
	"unicode"
)

func main() {
	var s string
	fmt.Scan(&s)

	fmt.Println(solve(s))
}

func solve(s string) string {
	// Cond1
	if string(s[0]) != "A" {
		return "WA"
	}

	// Cond2
	if strings.Count(s[2:len(s)-1], "C") != 1 {
		return "WA"
	}

	// Cond3
	cnt := 0
	for _, r := range s {
		if unicode.IsUpper(r) {
			cnt++
		}
	}
	if cnt != 2 {
		return "WA"
	}
	return "AC"
}

Measured memory_bytes: 640
#define _DEBUG 1
#define _GLIBCXX_DEBUG

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

using ll = long long;

#ifdef _DEBUG
#define dump(x) cerr << #x << "=" << x << endl
#define dump2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define dump3(x, y, z)                                                     \
  cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z \
       << endl
#define check(s) cerr << s << endl
#else
#define dump(x)
#define dump2(x, y)
#define dump3(x, y, z)
#define check(s)
#endif

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());

const ll LINF = 2e18;
const int INF = 1e9;

void solve(std::string S) {
  if (S == "ABC") {
    cout << "ARC" << endl;
  } else {
    cout << "ABC" << endl;
  }
}

int main() {
  std::string S;
  std::cin >> S;
  solve(S);
  return 0;
}


Measured memory_bytes: 3628
#include <stdio.h>

int main(){
	
	int h[305],w[305],i,j,k,l;
	
	i=0;
	do {
		scanf ("%d %d", &h[i], &w[i]);
		i++;
	} while (h[i-1] != 0 && w[i-1] != 0);
	
	for (j=0;j<i-1;j++){
		for (l=0;l<h[j];l++){
			for (k=0;k<w[j];k++){
				printf ("#");
			}
			printf ("\n");
		}
		printf ("\n");
	}
	
return 0;
}


Measured memory_bytes: 2080
import java.io.PrintWriter

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextLongList() = nextList().map(String::toLong)
fun nextDoubleList() = nextList().map(String::toDouble)

val pw = PrintWriter(System.out)
fun print(s: Any = "") = pw.print(s)
fun println(s: Any = "") = pw.println(s)

fun <T> Iterable<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)
fun <T> Array<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)

fun main(args: Array<String>) {
    main()
    pw.flush()
}

fun main() {
    val a = nextLong()
    val b = nextLong()
    val h = nextLong()
    println((a + b) * h / 2)
}

Measured memory_bytes: 33628
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = s; i < (int)(n); i++)
#define out(x) cout << x << endl;
#define INF 1ll<<60;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

using namespace std;
using ll = long long;
typedef pair<int, int> P;

int main(){
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;

    int x3, y3, x4, y4 ;
    int d1, d2;
    d1 = x2 - x1;
    d2 = y2 - y1;

    x4 = x1-d2;
    y4 = y1+d1;

    x3 = x1+(d1-d2);
    y3 = y1+(d2+d1);

    cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;


}

Measured memory_bytes: 3576
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define LB(a,x) lb(all(a),x)-a.begin()
#define UB(a,x) ub(all(a),x)-a.begin()
#define mod 1000000007
#define FS fixed<<setprecision(15)
using namespace std;
typedef long long ll;
const double pi=3.141592653589793;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const ll INF=1e18;
const int mx=200005;

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int n;
    cin>>n;
    string s;
    cin>>s;
    /*stack<char> st;
    int ans=0;
    rep(i,n){
        if(s[i]=='W')st.push(s[i]);
        else{
            if(!st.empty()){
                if(st.top()=='W'&&s[i]=='R'){
                    ans++;
                    st.pop();
                }else st.push(s[i]);
            }else st.push(s[i]);
        }
    }
    cout<<ans<<endl;*/
    int ans=0;
    int l=0,r=n-1;
    while(r-l>0){
        while(s[l]!='W'&&l<n)l++;
        while(s[r]!='R'&&r>=0)r--;
        if(r<=l)break;
        //swap(s[l],s[r]);
        ans++;
        l++;
        r--;
    }
    cout<<ans<<endl;
}
//ペナルティ出しても焦らない　ACできると信じろ！！！
//どうしてもわからないときはサンプルで実験　何か見えてくるかも
//頭で考えてダメなら紙におこせ！！
/*
V,P(大文字)使用不可
乗算などの際にオーバーフローに注意せよ！
(適切にmodをとれ　にぶたんで途中で切り上げろ)
制約をよく読め！
{
    ・全探索できるなら全探索しろ
    ・異常な制約ならそこに注目
}
stringの計算量(扱い)注意
コーナー注意！(特に数値が小さいものについては要検証)
N行出力のときは'¥n'
グリッド上では行先が範囲内におさまるかif文で確認(RE注意)
if文ではちゃんと比較演算子==を使え('='でもエラー出ない)
配列(vector)の大きさが0か1以上かで場合分けせよ(RE注意)
(vector<int> a(m)でm==0というものはできない)
modはなるべく最後に取れ！
doubleを扱うときには(abs)ではなく'fabs'!!!
*/


Measured memory_bytes: 3740
#include <iostream>

using namespace std;

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

    for (int i = 1; i <= 9; i++) {
        if (n <= 100 * i + 10 * i + i) {
            cout << 100 * i + 10 * i + i << endl;
            break;
        }
    }
}


Measured memory_bytes: 256
function myin(){return require("fs").readFileSync("/dev/stdin", "utf8").trim();}
function myout(t){console.log(t);}//standard output
function myerr(t){console.error(t);}//standard error
//[no]param
//0:何もしない  1:数値へ変換  2:半角SPで分割  3:改行で分割  4:半角SPで分割し、数値配列へ
//5:改行で分割し、数値配列へ  6:1文字に分割  7:1文字に分割し、数値配列へ
function myconv(i,no){switch(no){case 0:return i;case 1:return parseInt(i);case 2:return i.split(" ");case 3:return i.split("\n");case 4:return i.split(" ").map((a)=>Number(a));case 5:return i.split("\n").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));}}
function Main(input) {
  input = myconv(input,3);
  var N = myconv(input[0],1);
  var dlist = myconv(input[1],4);
  var dset = {};
  var M = myconv(input[2],1);
  var tlist = myconv(input[3],4);
  for(var i = 0; i < N; i++){
    if(dset[dlist[i]] == null){
       dset[dlist[i]] = 1;
    }else{
      dset[dlist[i]]++;
    }
  }
  for(var i = 0; i < M; i++){
    if(dset[tlist[i]] != null && dset[tlist[i]] > 0){
       dset[tlist[i]]--;
    }else{
      myout("NO");
      return;
    }
  }
  myout("YES");
}
Main(myin());

Measured memory_bytes: 97912
import java.util.*;
public class Main {
    public static void main(String[] args){
        Double a = 0.0;
        Scanner sc = new Scanner(System.in);
        //人数出力
        int ple = Integer.parseInt(sc.next());
        //人数分回す
        for(int i=0;i<ple;i++){
            //金額
            Double b = Double.parseDouble(sc.next());
            //単位
            String c = sc.next();
            if("BTC".equals(c)){
                b = b * 380000;
            }
            a = a + b;
        }
        sc.close();
        System.out.println(a);
    }
}

Measured memory_bytes: 21716
def main():
    a, b, c, d = map(int, input().split())
    while a > 0 or b > 0:
        c -= b
        if c <= 0:
            print('Yes')
            exit()

        a -= d
        if a <= 0:
            print('No')
            exit()


if __name__ == '__main__':
    main()


Measured memory_bytes: 9172
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  ll i;
  ll num;
  static ll odd,even;
  cin>>num;
  for(i=1;i<=num;i++){
  	if(i%2) odd++;
    else even++;
  }
  cout<<odd*even<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pq priority_queue
using namespace std; typedef pair<int, int> P; typedef pair<int, P> P2; typedef pair<int, P2> P3;
constexpr long long gcd(long long a, long long b){return b ? gcd(b, a % b) : a;}
constexpr long long lcm(long long a, long long b){return a / gcd(a, b) * b;}
constexpr int INF = 1e9, MOD = INF + 7, around[] = {0, 1, 1, -1, -1, 0, -1, 1, 0, 0};
constexpr int mod_pow(long long x, long long n, const int mod){long long ret=1;while(n){if(n&1)(ret*=x)%=mod;(x*=x)%=mod;n>>=1;}return ret;}
template<int n> struct Prime{bool arr[n+1];constexpr bool operator[](int k){return arr[k];}constexpr Prime():arr(){for(int i=2;i<n;i++){arr[i]=true;for(int j=2;j*j<=i;j++){if(!(i%j))arr[i]=false;}}}};
template<int n> struct Factorial{long long arr[n+1],ary[n+1];constexpr Factorial():arr(),ary(){arr[0]=1;ary[0]=1;for(int i=0;i<n;i++){arr[i+1]=arr[i]*(i+1)%MOD;ary[i+1]=mod_pow(arr[i+1],MOD-2,MOD);}}};
constexpr Factorial<1010> fact; constexpr Prime<10> prime;
constexpr long long comb(int a, int b){if(a < b) return 0LL;if(!a or !b) return 1LL; long long pos = fact.arr[a], pot = fact.ary[a - b], por = fact.ary[b]; return pos * pot % MOD * por % MOD;}
template<int n> struct Bernoulli{long long arr[n+1];constexpr Bernoulli():arr(){arr[0]=1;for(int i=1;i<=n;i++){long long sum=0;for(int j=0;j<i;j++){(sum+=comb(i+1,j)*arr[j]%MOD)%=MOD;}arr[i]=(MOD-mod_pow(i+1,MOD-2,MOD))%MOD*sum%MOD;}}};
constexpr int vx[] = {1, 0, -1, 0}, vy[] = {0, 1, 0, -1};
constexpr long double PI = abs(acos(-1));
constexpr int sqrtN = 512, logN = 32;
constexpr long long LINF=1e18;

int main(){
	string s; cin >> s; sort(begin(s), end(s));
	
	if(s == "abc") cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int[] num = new int[3];
		
		for(int i=0;i<n;i++){
			num[i] = sc.nextInt();
		}
		if(num[2]==0)num[2]=num[1];
		Arrays.sort(num);
		
		for(int i=1;i<=num[0];i++){
			if(num[0]%i==0 && num[1]%i==0 && num[2]%i==0)System.out.println(i);
		}
		
	}
}

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

int main(){
    int n,m;
    while(cin>>n>>m,n||m){
        vector<int>v;
        for(int i=0;i<n+m;i++){
            int a;cin>>a;
            v.push_back(a);
        }
        v.push_back(0);

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

        int ma=0;
        for(int i=0;i<v.size()-1;i++)ma=max(ma,v[i+1]-v[i]);

        cout<<ma<<endl;
    }
    return 0;
}

Measured memory_bytes: 1348
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll s[100009];
ll t[100009];

int main(){
  int n,k;
  int a[100009];
  cin>>n>>k;
  for(int i=1;i<=n;i++){
    cin>>a[i];
    s[i]=s[i-1]+a[i];
    t[i]=t[i-1]+max(a[i],0);
  }

  ll ans=s[n];
  for(int i=1;i<=n-k+1;i++){
    ans=max(ans,t[i-1]+(s[i+k-1]-s[i-1])+t[n]-t[i+k-1]);
    ans=max(ans,t[i-1]+t[n]-t[i+k-1]);
  }
  
  cout<<ans<<endl;
  return(0);
}


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

int main()
{
	int A,B,C,K;
	cin >> A >> B >> C;
	int M = max(A,max(B,C));
	cin >> K;
	int ans = A + B + C;
	int temp = M;
	rep(i,K)
	{
		temp *= 2;
	}
	ans += temp;
	ans -= M;
	cout << ans << endl;
	return 0;
}

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

s = input()[:-1]

even = set()
odd = set()

for i in range(0, len(s), 2):
    even.add(s[i])
for i in range(1, len(s), 2):
    odd.add(s[i])
#print(odd, even)
print('Yes' if (len(odd - set(list('LUD'))) == 0) and (
    len(even - set(list('RUD'))) == 0) else 'No')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
using ll=long long;
 
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define a first
#define b second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
const ll MOD = 998244353;

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> as(n);
    rep(i, n) cin >> as[i];
    int md = 1e9;
    rep(l, n-k+1) {
        int r = l+k-1; 
        int d =  abs(as[l]-as[r]);
        md = min(md, abs(as[l]) + d );
        md = min(md, abs(as[r]) + d );
    }
    cout << md << endl;
    return 0;
}

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

int main()
{
    int N, K, x, sum = 0;
    cin >> N >> K;
    for (int i = 0; i < N; ++i)
    {
        cin >> x;
        if (2 * x < K)
        {
            sum += 2 * x;
        }else{
            sum += 2 * (K - x);
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 3612
using System;

namespace ITP1_4_B
{
    class Program
    {
        static void Main()
        {
            while (true)
            {
                string[] str = Console.ReadLine().Split(' ');
                var a = int.Parse(str[0]);
                var op = char.Parse(str[1]);
                var b = int.Parse(str[2]);

                if (op == '+') Console.WriteLine(a + b);

                else if (op == '-') Console.WriteLine(a - b);

                else if (op == '*') Console.WriteLine(a * b);

                else if (op == '/') Console.WriteLine(a / b);

                else break;
            }
        }
    }
}

Measured memory_bytes: 9144
#include<stdio.h>
#include<string.h>
int main()
{
	char s[101];
	int i,n,flg;
	scanf("%s",s);
	n=strlen(s);
	flg=1;
	for(i=0;i<=n;i++){
		if(i%2==0){
			if(s[i]=='L'){
				flg=0;
				break;
			}
		}
		else if(i%2==1){
			if(s[i]=='R'){
				flg=0;
				break;
			}
		}	
	}
	
	if(flg==1)	printf("Yes\n");
	else printf("No\n");
	return 0;
}
		

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


vector<int> V[100000];

int findRoot( vector<int>& B, int N, int M ){
    vector<bool> isAppeared(N, false);  // B に現れてないのが root
    for( int i = 0; i < N-1+M; ++i ) isAppeared[B[i]] = true;
    for( int i = 0; i < N; ++i ){
        if( !isAppeared[i] ) return i;
    }
    return -1;
}


int main()
{
    int N, M;
    cin >> N >> M;
    vector<int> A(N-1+M), B(N-1+M);
    for( int i = 0; i < N-1+M; ++i ){
        cin >> A[i] >> B[i];
        --A[i], --B[i];
        V[A[i]].push_back( B[i] );
    }


    int root = findRoot(B, N, M);

    // 親からの最長経路を辿ればいい！って思って幅優先探索を実装したけど、
    // トポロジカルソートってやつと同義らしい
    vector<int> indegree(N, 0);
    for( int i = 0; i < N-1+M; ++i ) ++indegree[B[i]];

    vector<int> parent(N);
    queue<int> q;
    q.push( root );
    while( !q.empty() )
    {
        int tmp = q.front();
        q.pop();
        for( auto v: V[tmp] ){
            if( indegree[v] == 1 ){
                parent[v] = tmp+1;
                q.push( v );
            }
            --indegree[v];
        }
    }
    for( int i = 0; i < N; ++i ) cout << parent[i] << endl;

    return 0;
}

Measured memory_bytes: 7808
H, W = map(int, input().split())
masu = []
for i in range(H):
    masu.append(list(input()))
black = []
for i in range(H):
    for j in range(W):
        if masu[i][j] == "#":
            black.append([i,j])
ans = -1
while len(black) != 0:
    ans += 1
    blacktemp = black[:]
    black = []
    for k in blacktemp:
        for i, j in [[0, -1], [0, 1], [-1, 0], [1, 0]]:
            if 0 <= k[0] + i <= H-1 and 0 <= k[1] + j <= W-1:
                if masu[k[0]+i][k[1]+j] == ".":
                    masu[k[0]+i][k[1]+j] = "#"
                    black.append([k[0]+i, k[1]+j])
print(ans)


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

using namespace std;

int main(){
    int num; cin >> num;
    vector<int> a;
    while(num/10 != 0){
        a.push_back(num%10);
        num = num/10;
    }
    a.push_back(num%10);

    for(int i = 0; i<8;i++){
        switch (i)
        {
        case 0:
            if(a[3] + a[2] + a[1] + a[0] == 7){
              cout << a[3] << '+' << a[2] << '+' << a[1] << '+' << a[0] << "=7" << endl;
              return 0;
            }
            break;
        case 1:
            if(a[3] + a[2] + a[1] - a[0] == 7){
              cout << a[3] << '+' << a[2] << '+' << a[1] << '-' << a[0] << "=7" << endl;
              return 0;
            }
            break;
        case 2:
            if(a[3] + a[2] - a[1] + a[0] == 7){
              cout << a[3] << '+' << a[2] << '-' << a[1] << '+' << a[0] << "=7" << endl;
              return 0;
            }
            break;
        case 3:
            if(a[3] + a[2] - a[1] - a[0] == 7){
              cout << a[3] << '+' << a[2] << '-' << a[1] << '-' << a[0] << "=7" << endl;
              return 0;
            }
            break;
        case 4:
            if(a[3] - a[2] + a[1] + a[0] == 7){
              cout << a[3] << '-' << a[2] << '+' << a[1] << '+' << a[0] << "=7" << endl;
              return 0;
            }
            break;
        case 5:
            if(a[3] - a[2] + a[1] - a[0] == 7){
              cout << a[3] << '-' << a[2] << '+' << a[1] << '-' << a[0] << "=7" << endl;
              return 0;
            }
            break;
        case 6:
            if(a[3] - a[2] - a[1] + a[0] == 7){
              cout << a[3] << '-' << a[2] << '-' << a[1] << '+' << a[0] << "=7" << endl;
              return 0;
            }
            break;
        case 7:
            if(a[3] - a[2] - a[1] - a[0] == 7){
              cout << a[3] << '-' << a[2] << '-' << a[1] << '-' << a[0] << "=7" << endl;
              return 0;
            }
            break;
        }
    }
    return 0;
}

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

int dp[334][334];

int rec(vector<int> &w, int l, int r){
    if(dp[l][r] != -1) return dp[l][r];
    if(r-2 < l) return dp[l][r] = 0;
    if(l == r-2){
        if(abs(w[l] - w[r-1]) <= 1) return dp[l][r] = 2;
        else return dp[l][r] = 0;
    }
    int tmp = rec(w, l+1, r-1);
    if(abs(w[l] - w[r-1]) <= 1 && tmp == (r-l-2)){
        return dp[l][r] = tmp + 2;
    }
    for(int k=l+1; k<r; k++){
        tmp = max(tmp, rec(w, l, k)+rec(w, k, r));
    }
    return dp[l][r] = tmp;
}

int main(){
    int n;
    cin >> n;
    while(n > 0){
        vector<int> w(n);
        for(int i=0; i<n; i++){
            cin >> w[i];
        }
        memset(dp, -1, sizeof(dp));
        cout << rec(w, 0, n) << endl;
        cin >> n;
    }
}


Measured memory_bytes: 3588
import math
import itertools
n = int(input())
info = []
for i in range(n):
    x, y = map(int, input().split())
    info.append([i, x, y])
num = [i for i in range(n)]
# print(info, num)
ans = 0

def d(x1, x2, y1, y2):
    return math.sqrt((x1 - x2)**2 + (y1 - y2)**2)

for v in itertools.permutations(num):
    # print(v)
    for i in range(n-1):
        ans += d(info[v[i]][1], info[v[i+1]][1], info[v[i]][2], info[v[i+1]][2])

ans /= math.factorial(n)
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
using P = pair<int,int>;
const int MOD = 1000000007;

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

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

int main() {
    int n;
    cin>>n;
    ll temp,ans=1LL;
    rep(i,n) {
        cin>>temp;
        ans=lcm(ans,temp);
    }
    cout<<ans<<endl;
}


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

int main() {
  int H,W;
  cin >> H >> W;
  for(int i=0; i<H*W; i++){
    string S;
    cin >> S;
    if(S == "snuke"){
      cout << char('A'+(i%W)) << i/W+1 << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 3596
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <utility>
#include <algorithm>
#include <string>
#include <set>
#include <random>
using namespace std;
int main() {
  int n, k;
  string s;
  cin >> n >> s >> k;
  k--;
  for (int i = 0; i < n; i++) {
	  if (s[i] != s[k]) {
		  s[i] = '*';
		}
	}
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 256
# C - Skill Up

N, M, X = map(int, input().split())
C, A = [], []
for _ in range(N):
    c, *a = map(int, input().split())
    C.append(c)
    A.append(a)

costs = []
def f(i, cost, points):
    if X <= min(points):
        costs.append(cost)
        return
    if N <= i:
        return
    f(i + 1, cost, points)
    tmp = [p for p in points]
    for j in range(M):
        tmp[j] += A[i][j]
    f(i + 1, cost + C[i], tmp)

f(0, 0, [0] * M)
print(min(costs) if len(costs) != 0 else -1)

Measured memory_bytes: 9236