akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
double p=3.1415926535;
int main(){
  double a;
  while(cin>>a,a){
    for(int i=1;;i++){
      int b=p*i;
      if(abs(p-(double)b/(double)i)<=a){
        cout<<b<<'/'<<i<<endl;
        break;
      }
      if(abs(p-(double)(b+1)/(double)i)<=a){
        cout<<b+1<<'/'<<i<<endl;
        break;
      }
    }
  }
}

Measured memory_bytes: 3044
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<iostream>
#include<numeric>
#include<string>
#include<vector>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const ll mod = 1e9+7;
const double PI = acos(-1);  // PI = 3.141593...

void dfs(int start, int n, int x, int y, vector<int>& cnt) {
    vector<int> map(n, 0);
    int p1=start;
    int p2=start;
    int p3=n;
    int p4=0;
    for(int i=1; i<n-start; ++i) {
        if(p3<n-1) {++p3;}
        if(p4>=0) {--p4;}
        if(p1==x||p2==x) {p3=y; p4=y;}
        if(p1<n-1) {++p1;}
        if(p2>=0) {--p2;}
        if(p1<n&&p1>start&&map[p1]==0) {map[p1]=1;++cnt[i];}
        if(p2>start&&map[p2]==0) {map[p2]=1;++cnt[i];}
        if(p3<n&&p3>start&&map[p3]==0) {map[p3]=1;++cnt[i];}
        if(p4>start&&map[p4]==0) {map[p4]=1;++cnt[i];}
    }
}

int main() {
    int n,x,y;
    cin>>n>>x>>y;
    --x;--y;
    vector<int> cnt(n, 0);

    for(int i=0; i<n; ++i) {
        dfs(i,n,x,y,cnt);
    }
    for(int i=1; i<n; ++i) cout << cnt[i] << endl;

    return 0;
}

Measured memory_bytes: 256
mask = [[i for i in range(6)], (1, 5, 2, 3, 0, 4), (2, 1, 5, 0, 4,3),(3, 1, 0, 5, 4, 2), (4, 0, 2, 3, 5, 1)]
mask += [[mask[1][i] for i in mask[1]]]

TOP, FRONT, RIGHT, LEFT, BACK, BOTTOM = mask[0]

def set_top(dice, top):
    return [dice[i] for i in mask[top]]

def set_front(dice, front):
    twist = (0, 3, 1, 4, 2, 5)
    while dice[FRONT] != front:
        dice = [dice[i] for i in twist]
    return dice
        
label = input().split()
q = int(input())
for _ in range(q):
    top, front = map(label.index, input().split())
    dice = set_top(mask[0], top)
    dice = set_front(dice, front)
    print(label[dice[RIGHT]])

Measured memory_bytes: 6752
import java.io.*;
 
public class Main {
    public static void main(String[] args) {
        InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(isr);
        try {
            String[] str = br.readLine().split(" ");
            int a = Integer.parseInt(str[0]);
            int b = Integer.parseInt(str[1]);
            System.out.println(a * b + " " + (a + b) * 2);
        } catch(IOException e) {
            e.printStackTrace();
        }
    }
}

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

#if ((_WIN32 || __WIN32__) && __cplusplus < 201103L)
#define lld I64d
#else
#define lld lld
#endif

//{{{
using namespace std;
typedef long long LL;
typedef vector<int> VI;
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define clr(a, b) memset(a, b, sizeof(a))
// clang-format off
#define debug(args...) {vector<string> _v = split(#args, ','); err(_v.begin(), args); cerr<<endl;}
vector<string> split(const string& s, char c) {vector<string> v; stringstream ss(s); string x; while
(getline(ss, x, c)) v.push_back(x); return v;} void err(vector<string>::iterator) {}
template<typename T, typename... Args> void err(vector<string>::iterator it, T a, Args... args)
{cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << ", "; err(++it, args...);}
// clang-format on
//}}}

const int N = 1e5 + 10;
;
int n;
int h[N], dp[N];
int main()
{
#ifdef LOCAL
    freopen("in", "r", stdin);
// freopen("out", "w", stdout);
#endif

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

    dp[1] = 0;
    if (n > 1)
    {
        dp[2] = abs(h[2] - h[1]);
    }

    for (int i = 3; i <= n; i++)
    {
        dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]));
    }
    cout << dp[n] << endl;

    return 0;
}

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

long long gcd(long long a, long long b) {
	if (a < b)
		swap(a, b);
	if (a % b == 0) {
		return b;
	} else {
		return gcd(b, a % b);
	}
}

int main() {
	int N, X;
	cin >> N >> X;
	priority_queue<int> Q;
	Q.push(X);
	for (int i = 0; i < N; i++) {
		int a;
		cin >> a;
		Q.push(a);
	}
	int a = Q.top();
	Q.pop();
	int ans = a - Q.top();
	while (true) {
		a = Q.top();
		Q.pop();
		if (Q.empty())
			break;
		ans = gcd(ans, a - Q.top());
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 892
function Main(input) {
  const lines = input.split(' ').map(e => parseInt(e));
  let sh = lines[0];
  let wol = lines[1];
  if ( sh > wol ) {
    console.log("safe");
  } else {
    console.log("unsafe");
  }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29624
s = input()
n = len(s)
k = int(input())

lis = []
b = None
cont = -1
for c in s:
    if c != b:
        if b is not None:
            lis.append(cont)
        b = c
        cont = 1
    else:
        cont += 1
if b is not None:
    lis.append(cont)

# print(lis)

if k == 1 or s[-1] != s[0]:
    print(sum(map(lambda x: x // 2, lis)) * k)
else:
    if len(lis) == 1:
        odd = lis[0] // 2
        even = ((lis[0] % 2) + lis[0]) // 2
        # print(odd, even, k // 2)
        print(even * (k // 2) + odd * (k - k // 2))
    else:
        top = lis[0] // 2
        mid = sum(map(lambda x: x // 2, lis[1:-1]))
        bottom = lis[-1] // 2
        joint = (lis[0] + lis[-1]) // 2
        print(top + bottom + joint * (k - 1) + mid * k)


Measured memory_bytes: 38384
#include <iostream>
#include <vector>
#include <iomanip>
#include <string>
#include <sstream>
#include <algorithm>
#include <map>
#include <bits/stdc++.h>

using namespace std;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(long long i=(a),i##Len_=(b);i<i##Len_;i++)
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;

int main()
{
    int W,H,x,y,r;

    string res = "Yes";

    cin >> W >> H >> x >> y >> r;

    int minW,maxW,minH,maxH;

    minW = min(0, W);
    maxW = max(0, W);
    minH = min(0, H);
    maxH = max(0, H);
    //(0,0) と (W,H)
    //()
    if(minW > x - r)res = "No";
    if(maxW < x + r)res = "No";
    if(minH > y - r)res = "No";
    if(maxH < y + r)res = "No";

    cout << res << endl;
    
    return 0;
}


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

namespace TOPSIC2
{
    class Program
    {
        static void Main(string[] args)
        {
            double X = double.Parse(Console.ReadLine());
            double count = 0;
            double ans = 100;

            while (true)
            {
                count++;
                ans = Math.Floor(ans * 1.01);

                if (ans >= X)
                {
                    Console.WriteLine(count);
                    break;
                }
            }
        }
    }
}


Measured memory_bytes: 18464
MOD = 10**9 + 7

N = int(input())
S1 = input()
S2 = input()

l = []
res = 1
while res < N:
    if S1[res-1] == S1[res]:
        l.append(2)
        res += 2
    else:
        l.append(1)
        res += 1
if res == N:
    l.append(1)

n = len(l)
if l[0] == 1:
    ans = 3
else:
    ans = 6

for i in range(1, n):
    if l[i] == 1 and l[i-1] == 1:
        ans = ans * 2 % MOD
    elif l[i] == 2 and l[i-1] == 1:
        ans = ans * 2 % MOD
    elif l[i] == 2 and l[i-1] == 2:
        ans = ans * 3 % MOD

print(ans)

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

int main(void){
  long long a[3];
  cin >> a[0] >> a[1] >> a[2];
  for(int i = 0; i < 3; i++){
    for(int j = i + 1; j < 3; j++){
      if(a[i] < a[j]) swap(a[i], a[j]);
    }
  }
  
  long long num;
  if(a[0] % 2 == 0 || a[1] % 2 == 0 || a[2] % 2 == 0){
    num = 0;
  }else{
    num = a[1] * a[2];
  }
  cout << num << endl;
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace D
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var n = long.Parse(Console.ReadLine());
            // (n - 1) % n, n % 1
            Console.WriteLine((n - 1) * n / 2);
        }
    }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
#pragma gcc optimize("ofast")
using namespace std;
typedef long long int lli;
#define mod 1000000007
#define fLoop for(lli i = 0; i < N; i++)
main() {
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    lli N;
    cin >> N;
    lli *input = new lli[N];
    for(int i = 0; i < N; i++) {
    	cin >> input[i];
	}
	lli *DP = new lli[N];
	DP[0] = 0;
	DP[1] = abs(input[1] - input[0]);
	for(int i = 2; i < N; i++) {
		DP[i] = min((abs(input[i] - input[i - 1]) + DP[i - 1]), abs(input[i] - input[i - 2]) + DP[i - 2]);
	}
	cout << DP[N - 1] << '\n';
	delete[] DP;
}


Measured memory_bytes: 4764
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <deque>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <bitset>

using namespace std;
using ll = long long;

const char LEFT = 'W';

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int res = 1e9;
    int cur = 0;
    for (int i = 1; i < n; ++i) {
        cur += s[i] != LEFT;
    }
    res = min(res, cur);
    for (int i = 1; i < n; ++i) {
        if (s[i - 1] == LEFT) {
            ++cur;
        }
        if (s[i] != LEFT) {
            --cur;
        }
        res = min(res, cur);
    }
    cout << res << "\n";
    return 0;
}


Measured memory_bytes: 900
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>
#include<limits>
#include<iterator>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rep(i,n) for(ll i=0; i<n; i++)
#define FOR(i,a,n) for(ll i=a; i<n; i++)

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, char> plc;

int main()
{
	int x, t;
	cin >> x >> t;
	
	if (x - t > 0)
		cout << x - t << endl;
	else
		cout << 0 << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int n;
  cin >> n;
  long long p[n];
  rep(i,n){
    cin >> p[i];
  }
  long long ans=0;
  int w=0;
  int ww=0;
  rep(i,n){
    int a=i;
    int b=p[i];
    if(ww==a-1&&w==1&&b!=0){
      w=0;
      b--;
      ans++;
        
    }
    if(b%2==1){
      ww=a;
      w=1;
      ans+=b/2;
    }
    else ans+=b/2;
    //cout << ans << endl;
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
(let* ((n (read-line))
       (s (read-line))
       (a nil))
  (defun f-equal (a b)
    (reduce (lambda (x y) (and x y))
            (map 'list (lambda (x y) (if (char= #\? x)
                                               t (char= x y))) a b)))
  (setf a (position t (loop :for k :from 0 :to (- (length n) (length s)) :collect (f-equal (subseq n k (+ k (length s))) s)) :from-end t))
  (if a
      (princ (map 'string (lambda (k) (if (char= #\? k) #\a k)) (concatenate 'string (subseq n 0 a) s (subseq n (+ a (length s)))) ))
      (princ "UNRESTORABLE")))

Measured memory_bytes: 17380
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;

int w, h, n;

int main(void){
	
	scanf("%d %d %d", &w, &h, &n);
	vector<vector<bool>> v(h + 1, vector<bool>(w + 1, true));
	for(int i = 0; i < n; ++i){
	    int x, y, a; scanf("%d %d %d", &x, &y, &a);
	    if(a == 1){
	        for(int i = 0; i < h; ++i) for(int j = 0; j < x; ++j) v[i][j] = false;
	    }
	    else if(a == 2){
	        for(int i = 0; i < h; ++i) for(int j = x; j < w; ++j) v[i][j] = false;
	    }
	    else if(a == 3){
	        for(int i = 0; i < y; ++i) for(int j = 0; j < w; ++j) v[i][j] = false;
	    }
	    else{
	        for(int i = y; i < h; ++i) for(int j = 0; j < w; ++j) v[i][j] = false;
	    }
	}
	
	int ans = 0;
	for(int i = 0; i < h; ++i) for(int j = 0; j < w; ++j) if(v[i][j]) ++ans;
	printf("%d\n", ans);
	
    return 0;
}

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

bool isPrime(int x){
    if(x==2)return true;
    else if(x%2==0)return false;
    int i=3;
    while(i*i<=x){
        if(x%i==0)return false;
        i+=2;
    }
    return true;
}

int main(){
    int n,a,cnt=0;
    cin>>n;
    for(int i=0; i<n; i++){
        cin>>a;
        if(isPrime(a))cnt++;
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 3080
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int  main()
{    
    ll n;
    cin>>n;
    int d=n%10;
    if(d==2||d==4||d==5||d==7||d==9)
      cout<<"hon"<<endl;
      else if(d==0||d==1||d==6||d==8)
          cout<<"pon"<<endl;
          else if(d==3)
            cout<<"bon"<<endl;
	
	return 0;
}

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

using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;

#define REPS(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (int i = (a); i >= n; --i)
#define DEP(i, n) DEPS(i, n, 0)

#define vint(v, n) vector<int> v(n); REP(i,n) cin >> v[i];
#define vvint(v, w, n) vector<int> v(n); vector<int> w(n); REP(i,n) cin >> v[i] >> w[i];
#define vlint(v, n) vector<ll int> v(n); REP(i,n) cin >> v[i];
#define vdouble(v, n) vector<double> v(n); REP(i,n) cin >> v[i];
#define vvdoube(v, n1, n2) vector<vector<double> > v(n1, vector<double>(n2, 0)); REP(i,n1) REP(j,n1) cin >> v[i][j];
#define string(x) string x; cin >> x;
#define vstring(v, n) vector<string> v(n); REP(i,n){string a; std::cin >> a; v.push_back(a); }

#define all(v) (v).begin(), (v).end()
#define rall(v) (v).begin(), (v).end(), std::greater<int>()
#define len(v) (v).length()
#define FIND(s, n) (s.find(n) != s.end())
#define SORT(a) sort(all(a))

static const string abet("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");
static const long long MOD = 1000000007;
static const double PI=3.1415926535897932;
static const int INF = 0x3f3f3f3f;
static const int INFTY = (1 << 29);
static const long long LINFTY = (1LL << 32);

static const int dy4[]={0, 0, 1, -1};
static const int dx4[]={1, -1, 0, 0};
static const int dx8[] = {1, 1, 1, 0, 0, -1, -1, -1};
static const int dy8[] = {-1, 0, 1, -1, 1, -1, 0, 1};

int N, M, res;
int G[100][100];
int c[100], m[100];

int dfs(int b, int n) {
	c[n] = 1;
	for (int i = 0; i < N; i++) {
		if (b == i || n == i) continue;
		if (G[n][i]) {
			if (c[i] == 1) return 0;
			if (!dfs(n, i)) return 0;
		}
	}
	return 1;
}

int isPrime(int x){
  int i;
  if(x < 2) return 0;
  else if(x == 2) return 1;
  if( x%2 == 0) return 0;
  for(i = 3; i*i <= x; i += 2){
    if(x%i == 0) return 0;
  }
  return 1;
}

const int pmax = 1000000;
bool isPrime_table[pmax];
//const is necessary;
void eratos(void){
  int i, j;
  double sqrtmax=sqrt(pmax);

  REP(k, pmax) isPrime_table[k] = true; /* Initialization */

  /* Sieve process  */
  isPrime_table[0] = false;
  isPrime_table[1] = false;
          /* 0 and 1 are not prime. */
  for (i=2; i <= sqrtmax; i++){
    if (isPrime_table[i]==true){   /* i is prime. */
      for (j=i; i*j<pmax; j++){
        isPrime_table[i*j] = false; /* multiples of i are not prime. */
      }
    }
  }
}

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

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

	cout << max(a*b, c*d) << endl;
	return 0;
}



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

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

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

	sort(b.begin(), b.end());
	for (int i = 0; i < n; i++) {
		if (a[i] != b[n - 1])
			cout << b[n - 1] << "\n";
		else 
			cout << b[n - 2] << "\n";

	}

	return 0;
}

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

int main(){
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    
    if(a < b && b < c){
        printf("Yes\n");
    } else {
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 3160
#include <bits/stdc++.h>
using namespace std;
using I64 = long long;

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

I64 lcm( I64 a, I64 b ) {
	return b / gcd( a, b ) * a;
}

int main() {
	I64 A, B, C, D;
	cin >> A >> B >> C >> D;

	A -= 1;

	I64 count;
	count  = B - B/C - B/D + B/lcm( C, D );
	count -= A - A/C - A/D + A/lcm( C, D );

	cout << count << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

void _main() {
    string S;
    cin >> S;
    if (S == "Sunny") cout << "Cloudy" << endl;
    if (S == "Cloudy") cout << "Rainy" << endl;
    if (S == "Rainy") cout << "Sunny" << endl;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1000000007;

int main() {
  int a, b;
  cin >> a >> b;
  cout << a * b << endl;
}

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

int main()
{
  int N ;
  int ans=0 ;
  cin>>N ;
  vector<int>A(N,0) ;
  for(int i=0;i<N;i++){
    int temp ;
    cin>>temp ;
    if(temp>N){
      ans++ ;
      continue ;
    }
    A.at(temp-1)++ ;
  }

  for(int i=0;i<N;i++){
    if(A.at(i)<i+1) ans+=A.at(i) ;
    else ans+=A.at(i)-(i+1) ;
  }
  cout<<ans<<endl ;
  
  return 0 ;
}


Measured memory_bytes: 640
import collections
n=int(input())
A=list(map(int,input().split()))
B = [ i-A[i]    for i in range(n)]
C = [ i+A[i]    for i in range(n)]
b = collections.Counter(B)
c = collections.Counter(C)
ans =0
cnt = 0
 
for i in b.keys():
  ans +=c[i]*b[i]
     
print(ans) 

Measured memory_bytes: 63448
#include <iostream>
#include <string>

using namespace std;

int main(void) {
	string str;
	cin >> str;
	int num, max = 0;
	for (int i = 0; i < str.size(); i++) {
		num = 0;
		while (str[i] == 'A' || str[i] == 'T' || str[i] == 'C' || str[i] == 'G') {
			num++;
			i++;
		}
		if (num > max)
			max = num;
	}
	cout << max << "\n";
	return 0;
}

Measured memory_bytes: 256
import itertools


n = int(input())
info = [list(map(int, input().split())) for i in range(n)]


def solve(i, j):
    x, y = info[i]
    xx, yy = info[j]
    return ((x-xx)**2 + (y-yy)**2)**0.5
  
seq = [i for i in range(n)]
m = len(list(itertools.permutations(seq)))
ans = 0
for ptn in list(itertools.permutations(seq)):
    for i in range(n-1):
        ans += solve(ptn[i], ptn[i+1])

print(ans / m)

Measured memory_bytes: 54508
N, A, B = map(int, input().split())
ans = 0


def sumDigits(n):
    sum = 0
    while n != 0:
        sum += n % 10
        n = n // 10
    return sum


for i in range(N+1):
    x = sumDigits(i)
    if A <= x <= B:
        ans += i

print(ans)

Measured memory_bytes: 3060
#pragma GCC optimize ("Ofast")
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"
using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;
#define int long long int
#define pb push_back
#define fi first
#define se second
#define deb cerr << "Line no." << __LINE__
#define fr(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()
#define IO ios :: sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define pii pair<int,int>
#define sz(x) (int)x.size()
const int mod = 1e9 + 7;
const int mod1 = 998244353;
typedef long double f80;
#ifndef LOCAL
#define endl '\n'
#endif

template<typename T>
using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rand(int l, int r){
	uniform_int_distribution<int> uid(l, r);
	return uid(rng);
}
int pwr(int a,int b){
	int ans = 1;
	while(b){
		if(b & 1) ans = (ans * a) % mod;
		a = (a * a) % mod;
		b >>= 1;
	}
	return ans;
}
const int N = 1e5 + 5;
int dp[N], h[N];
void solve(){
	int n;
	cin >> n;
	fr(i, 1, n){
		cin >> h[i];
	}
	dp[n] = 0;
	dp[n - 1] = abs(h[n - 1] - h[n]);
	for(int i = n - 2; i >= 1; i--){
		dp[i] = min(dp[i + 1] + abs(h[i] - h[i + 1]), dp[i + 2] + abs(h[i] - h[i + 2]));
	}
	cout << dp[1];
}
signed main(){
  	IO;
  	#ifdef LOCAL
		freopen("inp.txt","r", stdin);
		// freopen("out.txt", "w", stdout);
	#endif
 	clock_t clk = clock();
  	int t = 1;
  	// cin >> t;
  	fr(tt, 1, t){
    	solve();
  	}
  	cerr << endl << (double)(clock() - clk) / CLOCKS_PER_SEC;
  	return 0;
}

Measured memory_bytes: 1792
S = list(input())
count = 0
current = 0
for i in range(len(S)):
    if S[i] == "A" or S[i] == "C" or S[i] == "G" or S[i] == "T":
        current += 1
    else:
        if current > count:
            count = current
        current = 0
if current > count:
    count = current
print(count)


Measured memory_bytes: 3060
#include <stdio.h>
#include <string.h>
#define LEN 100005
 
typedef struct pp {
  char name[100];
  int t;
} P;
 
P Q[LEN];
int head, tail, n;
 
void enqueue(P x) {
  Q[tail] = x;
  tail = (tail + 1) % LEN;
}
 
P dequeue() {
  P x = Q[head];
  head = (head + 1) % LEN;
  return x;
}
 
int min(int a,int b) {
  return a < b ? a : b; 
}
 
int main() {
  int elaps = 0, c;
  int i, q;
  P u;
  char str[64];
  
  scanf("%d %d",&n ,&q);
  for(i=1; i<=n; i++) {
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
  head = 1; tail = n + 1;
 
  while(head != tail) {
    u = dequeue();
    c = min(q, u.t);
    u.t -= c;
    elaps += c;
    if(u.t > 0) enqueue(u);
    else {
      printf("%s %d\n",u.name,elaps);
    }
  }
  return 0;
}


Measured memory_bytes: 11848
#Contest with Drinks Easy
N = int(input())
T = list(map(int, input().split()))
M = int(input())
P = [0 for i in range(M)]
X = [0 for i in range(M)]
for i in range(M):
    P[i], X[i] = map(int, input().split())
for i in range(M):
    t = 0
    for j in range(N):
        if j+1 == P[i]:
            t = t + X[i]
        else:
            t = t + T[j]
    print(t)

Measured memory_bytes: 3064
import numpy as np
h, w = map(int, input().split())
A = [input() for _ in range(h)]
B = np.empty((h+1, w+1), dtype=str)
for i in range(h):
  for j in range(w):
    B[i, j] = A[i][j]

x = y = 0
B[y, x] = '.'
while x != w-1 or y != h-1:
  if B[y, x+1] == B[y+1, x] == '#':
    print('Impossible')
    exit()
  elif B[y, x+1] == '#':
    x += 1
  else:
    y += 1
  B[y, x] = '.'

if np.any(B == '#'):
  print('Impossible')
else:
  print('Possible')

Measured memory_bytes: 27216
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;

int main()
{
    char a;
    cin >> a;
    
    if(a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
    {
        cout << "vowel" << endl;
        return 0;
    }
    else
    {
        cout << "consonant" << endl;
        return 0;
    }
    return 0;
}

Measured memory_bytes: 256
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { -1,0,1,0 }, dy[4] = { 0,-1,0,1 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        (wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)
# pragma warning(disable:4996)

string s;

int main() {
	cin >> s;
	REP(i, s.size()) {
		if (s[i] == '1')cout << 9;
		else if (s[i] == '9')cout << 1;
		else cout << s[i];
	}
	cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
const int mod = 1e9+7, A = 1e3+5;

int main()
{
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	int n, m, x;
	cin >> n >> m >> x;
	int a[x], ptr = 0;
	for (int i = 0; i < x; i++)
		cin >> a[i];
	int ans[n][m];
	for (int i = 0; i < n; i++)
	{
		if (i % 2 == 0)
		{
			for (int j = 0; j < m; j++)
			{
				ans[i][j] = ptr + 1;
				a[ptr]--;
				if (a[ptr] == 0) ptr++;
			}
		}
		else
		{
			for (int j = m - 1; j >= 0; j--)
			{
				ans[i][j] = ptr + 1;
				a[ptr]--;
				if (a[ptr] == 0) ptr++;
			}
		}
	}
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < m; j++)
			cout << ans[i][j] << ' ';
		cout << '\n';
	}
	return 0;
}

Measured memory_bytes: 384
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define INF 0x6fffffff
#define INFL 0x6fffffffffffffffLL

int main() {
	ll		a,b,c,h,i,j,k,l,m,n,p,x,y;
	ll		ans = 0;
	string	s;
	cin >> n;

	map<string , map<int , int>> pp;

	for(i=1;i<=n;i++) {
		cin >> s >> p;
		pp[s][-1*p] = i;
	}
	for(auto d:pp) {
		map<int , int> qq = d.second;
		for(auto dd:qq) cout << dd.second << endl;
	}
	return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <cstdio>
#define MN 5010
#define mod 1000000007

int f[MN][MN], mi[MN];

int main()
{
	int n, m; scanf("%d%d", &n, &m);
	mi[0] = 1; for(int i = 1; i <= m; i++) mi[i] = mi[i - 1] * 2 % mod;
	for(int j = 1; j <= m; j++) f[0][j] = 1;
	for(int i = 1; i <= n; i++)
	{
		for(int j = 1; j <= m; j++)
			f[i][j] = (f[i][j - 1] * 2 + 1ll * f[i - 1][j - 1] * (j - 1)) % mod;
		for(int j = 1; j <= m; j++)
			f[i][j] = (f[i][j] + 1ll * f[i - 1][j] * (j + 1)) % mod;
	}
		
	printf("%d\n", f[n][m]);
}

Measured memory_bytes: 101684
#include <bits/stdc++.h>
using namespace std;
bool vis[26];

int main()
{
    string ss,s;
    cin >> s;
    if(s.size()<26)
    {
        for(int i=0;i<s.size();i++)
            if(!vis[s[i]-'a'])
                vis[s[i]-'a']=true;
        cout << s;
        for(int i=0;i<26;i++)
        {
            if(!vis[i])
            {
                printf("%c\n",i+'a');
                break;
            }
        }
        return 0;
    }
    bool flag=false;
    for(int i=s.size()-2;i>=0;i--)
    {
        if(s[i]<s[i+1])
        {
            flag=true;
            break;
        }
    }
    if(!flag)
    {
        cout << -1 << endl;
        return 0;
    }
    for(int i=s.size()-1;i>=0;i--)
    {
        for(int j=int(s[i]);j<='z';j++)
        {
            bool f=false;
            for(int k=i+1;k<s.size();k++)
            {
                if(j==s[k])
                {
                    f=true;
                    break;
                }
            }
            if(f)
            {
                s[i]=char(j);
                for(int k=0;k<=i;k++)
                {
                    cout << s[k];
                }
                puts("");
                return 0;
            }
        }
    }
    puts("");
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
using namespace std ;
static const int INF = 1e9;
static const int MAX_N = 1e+6 +10;
typedef pair<int,int> pii;

struct edge{
    int to,cost;
    edge(){}
    edge(int p1,int p2){
        to=p1;
        cost=p2;
    }
};

int N,K;
vector<int> V[5010];
pii G[6010];
vector<int> D[5010];
int d[6010];
int A[6010];

void bfs(int s){
    for(int i=0;i<6000;++i)d[i]=INF;
    queue<pii> que;
    que.push(pii(s,0));
    while(!que.empty()){
        pii p=que.front();
        que.pop();
        int v = p.FI;
        if(d[v]==1)continue;
        d[v]=1;
        if(p.SE<=G[s].SE&&p.FI!=s){
             D[s].PB(v);
        }
        for(int i=0;i<V[v].size();++i){
             que.push(pii(V[v][i],p.SE+1));
        }
     }
}

void dijkstra(int s){
    priority_queue<pii,vector<pii>,greater<pii> > que;
    for(int i=0;i<6000;++i)A[i]=INF;
    A[s]=0;
    que.push(pii(0,s));
    while(!que.empty()){
        pii p = que.top();
        que.pop();
        int v=p.SE;
        if(A[v]<p.FI)continue;
        for(int i=0;i<V[v].size();i++){
            int e = V[v][i];
            if(A[e]>A[v]+G[v].FI){
                A[e] = A[v]+G[v].FI;
                que.push(pii(A[e],e));
            }
        }
    }
}

int main(){
    cin>>N>>K;
    for(int i=0;i<N;++i){
        cin>>G[i].FI>>G[i].SE;
    }
    for(int i=0;i<K;++i){
        int a,b;
        cin>>a>>b;
        a--;b--;
        V[a].PB(b);
        V[b].PB(a);
    }
    for(int i=0;i<N-1;++i)bfs(i);
    for(int i=0;i<N-1;++i){
        V[i].clear();
    }
    for(int i=0;i<N-1;++i){
        for(int j=0;j<D[i].size();++j){
            int a=i;
            int b=D[i][j];
            V[a].PB(b);
        }
    }
    dijkstra(0);
    cout<<A[N-1]<<endl;
}

Measured memory_bytes: 137876
#include <bits/stdc++.h>
#define ll long long
// #define FAST cin.tie(0)->sync_with_stdio(0);cout.tie(0)->sync_with_stdio(0);
#define pb push_back
using namespace std;
int x[4]={0,0,1,-1};
int y[4]={1,-1,0,0};
int main() {
    // FAST
    ll h,w,k;cin>>h>>w>>k;
    ll x1,x2,y1,y2;cin>>x1>>y1>>x2>>y2;
    char grid[h][w];
    for(int i=0;i<h;i++) for(int j=0;j<w;j++) cin>>grid[i][j];
    ll dist[h][w];
    ll INF=(ll)1e10;
    memset(dist,INF,sizeof(dist));
    for(int i=0;i<h;i++) for(int j=0;j<w;j++) dist[i][j]=INF;
    queue<pair<ll,ll>> q;
    --x1;--x2;--y1;--y2;
    dist[x1][y1]=0;
    q.push({x1,y1});
    while(!q.empty())
    {
        pair<ll,ll> t = q.front();
        q.pop();
        ll curx=t.first, cury=t.second;
        // cout<<curx<<" "<<cury<<endl;
        if(curx==x2 && cury==y2)
        {
            cout<<dist[x2][y2];
            return 0;
        }
        for(int i=0;i<4;i++)
        {
            for(int j=1;j<=k;j++)
            {
                
                ll xt=curx+x[i]*j,yt=cury+y[i]*j;
                // cout<<xt<<"-"<<yt<<endl;
                if(xt>=h || xt<0 || yt>=w || yt<0) break;
                if(grid[xt][yt]=='@') break;
                // cout<<"$"<<dist[xt][yt]<<endl;
                if(dist[xt][yt]!=INF && dist[xt][yt]<=dist[curx][cury])
                {
                    break;
                }
                // cout<<"$"<<dist[xt][yt]<<endl;
                if(dist[xt][yt]==dist[curx][cury]+1) continue;
                dist[xt][yt]=dist[curx][cury]+1;
                // cout<<"$"<<dist[xt][yt]<<endl;
                q.push({xt,yt});
            }
        }
    }
    cout<<-1;
    return 0;

}


Measured memory_bytes: 13848
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
  int n,k;
  cin >> n >> k;
  int arr[n];
  for(int i=0; i<n; i++)
  {cin >> arr[i];}
  sort(arr,arr+n);
  int res=0;
  for(int i=0; i<k; i++)
  {res+=arr[i];}
  cout << res << endl;
  return 0;}


Measured memory_bytes: 3132
/*package whatever //do not write package name here */

import java.io.*;
import java.util.*;
class Main {
    
    static int[] h;
    static int[] dp;
    static int n, k;
    
    static int solve(int start, int end)
    {
        //base cases
        if(end-start<=0)
			return 0;
		if(end-start==1)
		    return Math.abs(h[end]-h[start]);
		
        
        if(dp[start]==-1)
        {
            int temp = Integer.MAX_VALUE;
            for(int i = 1; i<=k; i++)
            {   
                if(start + i<=n - 1)
                    temp = Math.min(temp, solve(start + i, end) + Math.abs(h[start] - h[start + i]));
            }
            dp[start] = temp;
            return temp;
        }
        else
            return dp[start];
    }
    
	public static void main (String[] args) {
		Scanner scn = new Scanner(System.in);
		
		n = scn.nextInt();
		k = scn.nextInt();
		
		h = new int[n];
		dp = new int[n];
		
		for(int i=0; i<n; i++)
			h[i] = scn.nextInt();
		
		Arrays.fill(dp, -1); 
		
		System.out.println(solve(0, n-1));
	}
}

Measured memory_bytes: 71424
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 2e5 + 10;
#define fi first
#define se second
#define pb push_back
int main() {
  ios::sync_with_stdio(false);
  int x,y;
  cin>>x>>y;
  if(x>=10)cout<<y<<'\n';
  else cout<<(10-x)*100+y<<'\n';
  return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	N := nextInt()

	ac := 0
	wa := 0
	tle := 0
	re := 0

	for i := 0; i < N; i++ {
		s := nextString()

		if s == "AC" {
			ac++
		}
		if s == "WA" {
			wa++
		}
		if s == "TLE" {
			tle++
		}
		if s == "RE" {
			re++
		}
	}
	fmt.Printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d\n", ac, wa, tle, re)
}

var stdin = initStdin()

func initStdin() *bufio.Scanner {
	bufsize := 1 * 1024 * 1024 // 1 MB
	var stdin = bufio.NewScanner(os.Stdin)
	stdin.Buffer(make([]byte, bufsize), bufsize)
	stdin.Split(bufio.ScanWords)
	return stdin
}

func nextString() string {
	stdin.Scan()
	return stdin.Text()
}

func nextBytes() []byte {
	stdin.Scan()
	return stdin.Bytes()
}

func nextInt() int {
	i, _ := strconv.Atoi(nextString())
	return i
}

func nextInt64() int64 {
	i, _ := strconv.ParseInt(nextString(), 10, 64)
	return i
}

func debug(args ...interface{}) {
	fmt.Fprintln(os.Stderr, args)
}


Measured memory_bytes: 2180
#include<stdio.h>
int main(void){
	int n,p[1000][3],i,o=0,r,f,e,j;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d%d%d",&p[i][0],&p[i][1],&p[i][2]);
		for(r=0;r<3;r++){
			for(e=r+1;e<3;e++){
				if(p[i][r]>p[i][e]){
					f=p[i][r];
					p[i][r]=p[i][e];
					p[i][e]=f;
				}
			}
		}
	}
	for(i=0;i<n;i++){
		for(j=0;j<n;j++){
			if(j==i){
				j++;
			}
			if(p[i][0]==p[j][0]&&p[i][1]==p[j][1]&&p[i][2]==p[j][2]&&p[j][0]!=0){
				o++;
				p[j][0]=0;
			}
		}
	}
	printf("%d\n",o);
	return 0;
}

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

int main() {
  int N, A, B;
  cin >> N >> A >> B;
  int n = 0;
  for(int i = 1; i <= N; i++) {
    int m = 0;
    m += i/10000;
    m += i/1000 - i/10000 * 10;
    m += i/100 - i/1000 * 10;
    m += i/10 - i/100 * 10;
    m += i % 10;
    if(m >= A && m <= B) {
      n += i;
    }
  }
  cout << n << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mod 1000000007
const int N=200005;
 
int state[N];
int dp[5000][1005];
 
 
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
   /* #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif*/
    
    int n,m;
    cin>>n>>m;

    int cost[m+1];

    for(int i=0;i<5000;i++) for(int j=0;j<1005;j++) dp[i][j]=mod;

    for(int i=1;i<=m;i++) {
        int q;
        cin>>cost[i]>>q;
        for(int j=0;j<q;j++) {
            int x;
            cin>>x;
            state[i]|=(1<<(x-1));
        }

    }

    dp[0][0]=0;

    for(int i=0;i<(1<<n);i++) {
        for(int j=1;j<=m;j++) {
            dp[i][j] = min(dp[i][j], dp[i][j - 1]);
            dp[i|state[j]][j] = min(dp[i|state[j]][j], dp[i][j-1]+cost[j]);
        }
    }
    int ans=dp[(1<<n)-1][m];
    
    cout<<(ans==mod?-1:ans);
 
    return 0;
}


Measured memory_bytes: 19968
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, ans = 0;
    cin >> n;
    vector<int> a(n), b(n);
    rep(i, 0, n){
        cin >> a[i] >> b[i];
    }
    int sum = 0;
    repb(i, n - 1, 0){
        int tmp = (b[i] - (a[i] + sum) % b[i]) % b[i];
        ans += tmp;
        sum += tmp;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e9;
const ll MOD = 1e9 + 7;


int main(){
    int n, k;
    cin >> n >> k;
    vector<double> p(n), e(n);
    rep(i, n) cin >> p[i];

    rep(i, n) e[i] = (p[i] + 1) / 2;


    double sum = 0;
    rep(i, k) sum += e[i];
    double ans = sum;
    for(int i=k; i<n; i++){
        sum -= e[i-k];
        sum += e[i];
        chmax(ans, sum);
    }

    cout << setprecision(10) << ans << endl;
}

Measured memory_bytes: 3328
using static System.Math;
using static System.Console;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System;

namespace AtCoder
{
    class Program
    {
        private static long mod = 1000000007;
        static void Main(string[] args)
        {
            var n = long.Parse(ReadLine());
            var line = ReadLine().Split(' ').Select(value => long.Parse(value)).ToArray();

            var count = 0;
            for(var i = 0; i < n; i++)
            {
                if((i + 1) % 2 == 1 && line[i] % 2 == 1)
                {
                    count++;
                }
            }

            WriteLine(count);
        }
    }
}


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

#define ll long long
#define ull unsigned long long

using namespace std;

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

	int cnt = 0;
	bool prevFlag = false;
	for (int ii = 0; ii < N; ++ii){
		int p;
		cin >> p;
		if (p == ii + 1){
			if (prevFlag){
				prevFlag = false;
			} else {
				prevFlag = true;
				cnt++;
			}
		} else {
			prevFlag = false;			
		}
	}

	cout << cnt << "\n";

	return 0;
}


Measured memory_bytes: 3628
#include<iostream>
#include<string>
#include<set>
using namespace std;
string rev(string in)
{
	int l=0,r=in.size()-1;
	string out=in;
	while(l<r) 
	{
		out[l]=in[r];
		out[r]=in[l];
		l++; r--;
	}
	return out;
}

int main()
{
	int m; cin>>m;
	while(m--) 
	{
		string in; cin>>in;
		set<string> ans;
		for(int i = 1; i < in.size(); ++i)
		{
			string left=in.substr(0,i);
			string right=in.substr(i);

			ans.insert(left+right);
			ans.insert(right+left);
			ans.insert(rev(left)+right);
			ans.insert(right+rev(left));
			ans.insert(left+rev(right));
			ans.insert(rev(right)+left);
			ans.insert(rev(left)+rev(right));
			ans.insert(rev(right)+rev(left));
		}
		cout<<ans.size()<<endl;
	}
  return 0;
}

Measured memory_bytes: 1296
from operator import itemgetter
from itertools import accumulate
import numpy as np
N = int(input())
work = []
for i in range(N):
  a, b = map(int, input().split())
  work.append([a, b])

work = sorted(work, key=itemgetter(1,0))
work = np.array(work)

ans = "Yes"
for idx, time in enumerate(list(accumulate(work[:,0]))):
  if time > work[idx,1]:
    ans = "No"
    break

print(ans)

Measured memory_bytes: 62012
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
#define acc(v) accumulate(v.begin(), v.end(), 0)
#define cinv(n,v) rep(i,n) cin >> v[i]
using namespace std;
const int INF = 1e9;
typedef long long ll;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
// const lint MOD = 998244353;
int x_pos[4] = {1,0,-1,0}, y_pos[4] = {0,1,0,-1};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
char upper(char c){
	return c-0x20;
}
char lower(char c){
	return c+0x20;
}

ll gcd(ll x, ll y) {
  if (y == 0) return x;
  return gcd(y, x%y);
}

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

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll MOD = 1e9+7;

int main(){
  string s;
  cin>>s;
  int f=1;
  if(s[s.size()-1]=='1'||s[0]=='0')f=0;
  for(int i=0;i<s.size()-1;i++){
	if(s[i]!=s[s.size()-2-i])f=0;
  }
  if(f==0){
	cout<<-1<<endl;
	return 0;
  }
  cout<<"1 2"<<endl;
  int k=2;
  for(int i=1;i<s.size()-1;i++){
	cout<<k<<" "<<2+i<<endl;
	if(s[i]=='1')k=2+i;
  }
  return 0;
}


Measured memory_bytes: 1664
import math
from fractions import Fraction

N = int(input())
a, b = map(int, input().split())
ret_a = a
ret_b = b
for _ in range(1, N):
    a, b = map(int, input().split())
    x = math.ceil(max(Fraction(ret_a, a), Fraction(ret_b, b)))
    ret_a = a * x
    ret_b = b * x
print(ret_a + ret_b)

Measured memory_bytes: 5088
def main
  fh=STDIN
  #fh=File.new("x.txt", "r")
  w=fh.gets.chomp.downcase
  t=fh.read.downcase
  t.sub!(/END_OF_TEXT.*/,"")

  puts t.split.count{|x|x==w}
end

if $0 == __FILE__ then
  main
end



Measured memory_bytes: 6856
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
#define mod 200003
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//(a+b-1)/b
//priority_queue<ll, vector<ll>, greater<ll>> q;
using pl = pair<ll,ll>;
using vvb=vector<vector<bool>>;
using vb= vector<bool>;
ll f(ll a,ll b,ll p){
	if(b==0) return 1;
	if(b%2==0){
		ll t=f(a,b/2,p);
		return t*t%p;
	}
	return a*(f(a,b-1,p))%p;
} 

//__builtin_popcount()
signed main(){
	ll n,m; cin>>n>>m;
	vl g[n];
	rep(i,0,m){
		ll a,b; cin>>a>>b;
		--a; --b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	vl ans(n+10);
	queue<ll> q;
	q.push(0);
	vector<bool> seen(n);
	seen[0]=1;
	while(!q.empty()){
		ll k=q.front(); q.pop();
		for(auto c:g[k]){
			if(seen[c])continue;
			seen[c]=1;
			ans[c]=k;
			q.push(c);
		}
	}
	cout<<"Yes"<<endl;
	rep(i,1,n)cout<<ans[i]+1<<endl;


	


	return 0;
}

Measured memory_bytes: 12952
//
// Created on 2019-02-09.
//
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
template<class T> bool INRANGE(T x,T a,T b) { return a<=x&&x<=b; }

#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

#define PB push_back
#define INF 1e9
#define MOD 1e9+7
#define EPS 1e-9

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

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


    int N, K;
    string s;
    cin >> N >> K >> s;

    vector<ll> v;
    ll num__continuous = 0;
    char count_ch = '1';

    REP(i, s.length()){
        if (s[i] == count_ch) {
            num__continuous++;
        } else {
            v.emplace_back(num__continuous);
            num__continuous = 1;
            count_ch = s[i];
        }
    }

    if (num__continuous != 0) v.push_back(num__continuous);
    if (v.size() % 2 == 0) v.push_back(0);

    ll ans = 0;
    int num_cnt = 2*K+1;

    for (int i = 0; i < v.size(); i+=2) {
        ll cnt = 0;

        int left = i;
        int right = min(i + num_cnt, (int)v.size());
        for (int j = left; j < right; j++)
        {
            cnt += v[j];
        }
        ans = max(ans, cnt);
    }

    cout << ans << endl;


    return 0;

}

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

int main() {
    int A, B, C, K;
    cin >> A >> B >> C >> K;
    int ans = 0;
    if (A <= K) {
        ans += A;
        if (K - A >= B) {
            ans += -1 * (K - A - B);
            cout << ans << endl;
            return 0;
        } else {
            cout << ans << endl;
            return 0;
        }
    } else {
        cout << K << endl;
        return 0;
    }
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define REP1(i,n) for(int i=1; i<=(int)(n); i++)
#define SORT(v) sort(v.begin(), v.end())
#define REVERSE(v)  reverse(v.begin(), v.end())
using namespace std;

int main() {
  int a,b; cin>>a>>b;
  string ans = "No";
  REP1(c,3) if(a*b*c % 2 == 1) ans = "Yes";
  cout<<ans<<endl;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace C
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var n = int.Parse(Console.ReadLine());
            var list = new List<string>();
            for (var i = 0; i < n; i++)
            {
                var s = Console.ReadLine();
                list.Add(s);
            }
            Console.WriteLine(list.Distinct().Count());
        }
    }
}


Measured memory_bytes: 48020