akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

using namespace std;

int main() {
  string s;
  cin >> s;
  int n = s.size();

  long long total = 0;
  // 文字の間に+が入る全パターンをbitを使って列挙
  // cout << "-------------" << endl;
  for (int bit = 0; bit < (1<<(n-1)); bit++) {
    // +の場合を挿入していく
    // とりあえず文字列で
    string t;
    for (int i = 0; i < n; i++) {
      t += s[i];
      if (bit & (1<<i)) {
        t += "+";
      }
    }
    // cout << t << "=?" << endl;

    // あとは足し算してくだけ
    long long sum = 0;
    long long tmp = 0;
    for (int i = 0; i < t.size(); i++) {
      // cout << t[i] << endl;
      if (t[i] == '+') {
        sum += tmp;
        tmp = 0;
      } else {
        tmp = tmp * 10 + (t[i] - '0');
      }
    }
    sum += tmp;
    total += sum;
  }
  cout << total << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll a7=1000000007;
ll inf=1000000000000000;
typedef pair<ll,ll> l_l;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back


ll min(ll a,ll b){
    if(a<b)return a;
    return b;
}
ll max(ll a,ll b){
    if(a>b)return a;
    return b;
}

ll hpow(ll x,ll y){
    ll ans=1;
    ll i=x;
    if(y==0)return 1;
    while(y>0){
        if(y%2==1){
            ans=(ans*i)%a7;
        }
        i=(i*i)%a7;
        y=y/2;
        
    }
    return ans;
}

ll memop[2000000];
ll mkai(ll i){
    if(i==0){
        return 1;
    }
    if(memop[i]!=0){
        return memop[i];
    }else{
        ll ans=(mkai(i-1)*hpow(i,a7-2))%a7;
        memop[i]=ans;
        return ans;
    }
}

ll memok[2000000];
ll kai(ll i){
    if(i==0){
        return 1;
    }
    if(memok[i]!=0){
        return memok[i];
    }else{
        ll ans=(kai(i-1)*i)%a7;
        memok[i]=ans;
        return ans;
    }
}

ll comb(ll n,ll k){
    ll ans=(kai(n)*mkai(k))%a7;
    ans=(ans*mkai(n-k))%a7;
    return ans;
}

int main(){
    ll n;
    ll x,y;cin>>x>>y;
    if((x+y)%3!=0){
        cout<<0<<endl;
    }else{
        n=(x+y)/3;
        if(x-n<0 || y-n<0){
            cout<<0<<endl;
        }else{
            cout<<comb(n,x-n)%a7<<endl;
        }
    }
    
    
    
    return 0;
}







Measured memory_bytes: 21248
def main():
    n = int(input())
    A1 = list(map(int,input().split()))
    A2 = list(map(int,input().split()))

    ans = 0
    for i in range(n):
        ans = max(ans,sum(A1[:i+1]+A2[i:]))
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
n = int(input())
a = list(map(int, input().split()))#n
b = list(map(int, input().split()))#n
c = list(map(int, input().split()))#n-1

score=b[a[0]-1]

for i in range(1,n):
    if a[i]==a[i-1]+1:
        score+=b[a[i]-1]+c[a[i]-2]
    else:
        score+=b[a[i]-1]
print(score)

Measured memory_bytes: 38384
#include<iostream>
#include<string>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<math.h>

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)

typedef long long i64;
typedef pair<i64,i64> P;


int n;
vector<int> a(1010,INF);

int main(){
	cin >> n;
	for(int i = 1; i < n; i++){
		cin >> a[i];
	}
	
	int ans = 0;
	for(int i = 1; i <= n; i++){
		ans += min(a[i], a[i-1]);
	}
	
	cout << ans << endl;
	
	return 0;
}

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

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define RFOR(i, a, b) for (ll i = (b)-1; i >= (a); i--)
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rep1(i, n) for (ll i = 1; i <= (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define pii pair<int, int>
#define vi vector<int>

using namespace std;
template <class S, class T>
ostream& operator<<(ostream& o, const pair<S, T>& p)
{
    return o << "(" << p.first << "," << p.second << ")";
}
template <class T>
ostream& operator<<(ostream& o, const vector<T>& vc)
{
    o << "sz = " << vc.size() << endl
      << "[";
    for (const T& v : vc)
        o << v << ",";
    o << "]";
    return o;
}
using ll = long long;
constexpr ll MOD = 1000000007;

int main()
{
    string s;
    cin >> s;
    int mini = numeric_limits<int>::max() / 100;
    for (int i = 0; i < 26; i++) {
        const char c = 'a' + (char)(i);
        vector<int> interval;
        int pos = -1;
        for (int j = 0; j < s.size(); j++) {
            if (s[j] == c) {
                interval.pb(j - pos - 1);
                pos = j;
            }
        }
        interval.pb(s.size() - pos - 1);
        int maxi = 0;
        for (const int inte : interval) {
            maxi = max(maxi, inte);
        }
        mini = min(maxi, mini);
    }
    cout << mini << endl;


    return 0;
}


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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);

  int n; std::cin >> n;
  int tot = 0;
  rep(i, n) {
    int a; std::cin >> a;
    while ((a & 1) == 0) a /= 2, tot++;
  }
  std::cout << tot << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 using namespace std;
int main() {
int N, X; cin >> N >> X;
 vector<int> D(N + 1);
 D[0] = 0;
 for (int i = 0; i < N; ++i) {
 int x; cin >> x;
 D[i + 1] = D[i] + x;
 }
 int ans = 0;
 for (int i = 0; i <= N; ++i) {
 if (D[i] <= X) {
 ans++;
 }
 }
 cout << ans << endl;
 return 0;
 }


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

using namespace std;


int main() {
	int N;
	cin >> N;
	vector<int> a(N);
	for(auto &x: a) cin >> x;

	vector<bool> b(N);

	int M = 0;
	for(int i = N; i >= 1; i--) {
		bool t = (a[i-1] == 1);
		for(int j = i * 2; j <= N; j += i) {
			if(b[j-1]) t = !t;
		}
		b[i-1] = t;
		if(t) M++;
	}

	cout << M << endl;
	for(int i = 0; i < N; i++) {
		if(b[i]) cout << i+1 << endl;
	}
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll int knapSack(ll int W, ll int wt[], ll int val[], ll int n)
{
   ll int i, w;
   ll int K[n+1][W+1];
   for (i = 0; i <= n; i++)
   {
       for (w = 0; w <= W; w++)
       {
           if (i==0 || w==0)
               K[i][w] = 0;
           else if (wt[i-1] <= w)
                 K[i][w] = max(val[i-1] + K[i-1][w-wt[i-1]],  K[i-1][w]);
           else
                 K[i][w] = K[i-1][w];
       }
   }

   return K[n][W];
}

int main()
{
    ll int n,w;
    cin>>n>>w;
    ll int val[n],wt[n];
    for(ll int i=0;i<n;i++){
        cin>>wt[i]>>val[i];
    }
    ll int ans = knapSack(w,wt,val,n);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 79104
#include <bits/stdc++.h>
using namespace std;
int main(){long n,m=1e9+7,i=26;vector<int>a(26,0);cin>>n;string s;cin>>s;while(n--)a[s[n]-'a']++;n=1;while(i--)n=n*(a[i]+1)%m;cout<<n-1;}

Measured memory_bytes: 512
using System;
using System.Linq;
using System.Diagnostics;
using System.Collections.Generic;
using static System.Math;

class P
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        int[] dx = Console.ReadLine().Split().Select(int.Parse).ToArray();
        Console.WriteLine(Enumerable.Repeat(0, n).Select(_ => int.Parse(Console.ReadLine())).Sum(x => (dx[0] - 1) / x) + dx[1] + n);
    }
}

Measured memory_bytes: 13396
import Control.Monad
import Data.Array
import qualified Data.ByteString.Char8 as C
import Data.List

main = sol <$> get >>= mapM_ print

get = fmap (unfoldr (C.readInt . C.dropWhile (==' '))) . C.lines <$> C.getContents 

sol ([n,_]:es) = elems . accumArray (+) 0 (1,n) $ zip (concat es) (repeat 1)

Measured memory_bytes: 508
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
// memo  fixed  setprecision(20);
using vvll = vector<vector<ll>>;
ll mod =1e9+7;
/*"itob" int to "N"base */           template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits<TypeInt> t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;}
/*"chmin" a = MAX*/                  template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
/*"chmax" a = MIN*/                  template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*"ctoi"  char to int*/              int ctoi(char c) {return c-'0';}
/*"gcd"   MAX Euclidean */           ll gcd(ll a,ll b){if(b==0)return a; return gcd(b,a%b);}
    /*"lcm"   MIN*/                      ll lcm(ll a,ll b){ll g = gcd(a,b);return a/g*b;}
/*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
ll modpow(ll a,ll n, ll mod){ll res = 1;while(n>0){if (n%2==1){res = res * a % mod;}a = a * a % mod;n/=2;}return res;}
int main() {
    string s;
    cin >> s;
    ll ans = 0;
    for(int i=0;i<s.size();i++){
        ans+=ctoi(s.at(i));
    }
    if(ans%9==0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}
    



Measured memory_bytes: 3700
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    get!($($t),*)
        ).collect::<Vec<_>>()
    };
    ($t:ty |) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty | $n:expr) => {
        (0..$n).map(|_| get!($t |)).collect::<Vec<_>>()
    };
}

fn main() {
    let (N, A, B) = get!(u8, u8, u8);
    println!("{}", if N*A < B {
        N*A 
    } else {
        B
    });
}


Measured memory_bytes: 4352
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef set<int> S;
#define rep(i, n) for(int i=0; i<n; i++)
const ll MOD=1e9+7;

int main(){

  int k ,x;
  cin >> k >> x;
  if(500*k>=x){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <chrono>
using namespace std;
typedef long long ll;
#define tr(container, it) \
        for (auto it = container.begin(); it != container.end(); it++)
#define scontains(c, x) ((c).find(x) != (c).end())   //O(log n)
#define contains(c, x) (find((c).begin(),(c).end(),x) != (c).end()) //O(n)
#define ill(_x)  ll _x;scanf("%lld",&_x);
#define idb(_x)  double _x;scanf("%lf",&_x);
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define mll map<ll,ll>
#define vll vector<ll>
#define sll set<ll>
#define vs vector<string>
#define in0(x, a, b)((x)>=a && (x)<=b    )
#define in1(x, a, b)((x)>a && (x)<b)
#define  rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const double pi = 3.14159265358979323846;
const int INF = 0x3f3f3f3f;
const int X10=1024,X11=2048,X12=4096,X13=8196,X14=16392,X15=32786,X16=65536,X17=131072,X18=262144,X19=524288,X20=1048576;

int T[10001];
void _(){
    int n;
    cin >> n;
    int t= -1;
    int cnt = 1;
    int sum=0;
    for (int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        if(a==t)cnt++;
        else {
            sum += cnt/2;
            cnt = 1;
        }
        t=a;

    }
    sum +=cnt/2;
    cout << sum;
}






int main() {
#ifdef Debug
    freopen("/home/joduskame/Desktop/cpp/IO/Input.txt", "r", stdin);
    freopen("/home/joduskame/Desktop/cpp/IO/Output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    _();
    return 0;

}








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

int N;
string S;

void solve(){
    cin >> N;
    cin >> S;
    for(int i=0; i<S.length(); i++){
        if(S[i] + N > 90){
            S[i] = S[i] + N - 26;
        }else{
            S[i] = S[i] + N;
        }
        
    }

    cout << S << endl;
    
}

int main(){
    solve();
}

Measured memory_bytes: 256
use std::io::prelude::*;

fn input<T: std::str::FromStr>() -> T {
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let n: usize = input();
    let m: usize = input();
    let s: Vec<Vec<usize>> = (0..m)
        .map(|_| {
            let k: usize = input();
            (0..k).map(|_| input()).collect()
        })
        .collect();
    let p: Vec<i32> = (0..m).map(|_| input()).collect();

    let mut ans = 0i64;
    for i in 0..1 << n {
        let mut ok = true;
        for j in 0..m {
            let mut cnt = 0;
            for k in &s[j] {
                if ((i >> (k - 1)) & 1) > 0 {
                    cnt += 1;
                    cnt %= 2;
                }
            }
            if cnt != p[j] {
                ok = false;
                break;
            }
        }
        if ok {
            ans += 1;
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 4352
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;
using System.Threading.Tasks;



class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }
    

    Scanner cin;

    void calc()
    {
        cin = new Scanner();
        int N = cin.nextInt();
        int H = cin.nextInt();
        int[] a = new int[N];
        int[] b = new int[N];
        for (int i = 0; i < N; i++)
        {
            a[i] = cin.nextInt();
            b[i] = cin.nextInt();
        }

        Array.Sort(b);
        Array.Reverse(b);

        int MaxA = a.Max();

        int ans = 0;

        for (int i = 0; i < N; i++)
        {
            if(MaxA < b[i] && H > 0)
            {
                H -= b[i];
                ans++;
            }
        }

        ans += Math.Max(0, (H + MaxA - 1) / MaxA);

        Console.WriteLine(ans);
    }
    
}




class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}



Measured memory_bytes: 15952
#include <iostream>
#include <cassert>
//#define NDEBUG

/* 横線 #出力 */
void OutW(int w){
	using namespace std;
	for (int j = 0; j < w; j++){			/* 横幅分の# */
		cout << "#";
	}
		cout << "\n";						/* 改行 */
}

/* 縦線 #出力 (内部の.含む) */
void OutH(int h, int w){
	using namespace std;
	for (int i = 0; i < h-2; i++){			/* 高さ-2(上辺と下辺を除く) */
		cout << "#";						/* 左端の# */
		for (int j = 0; j < w-2; j++){		/* 横幅-2(左辺と右辺を除く) */
				cout << ".";
		}
		cout << "#";						/* 右端の# */
		cout << "\n";						/* 改行 */
	}
}

int main(void){
	using namespace std;
	static const int INPUT_H_MIN = 3;	/* 前提は3以上だが、入力終了時は0 */
	static const int INPUT_H_MAX = 300;
	static const int INPUT_W_MIN = 3;	/* 前提は3以上だが、入力終了時は0 */
	static const int INPUT_W_MAX = 300;
	int input_h = 0;
	int input_w = 0;
	
	do{
		/* 高さHと横幅Wを入力 */
		cin >> input_h >> input_w;
		
		/* 入力値が、  両方0(入力終了時) or 前提条件 最大・最小の制限内の入力 */
		assert ((input_h == 0 && input_w == 0 ) || (INPUT_H_MIN <= input_h && input_h <= INPUT_H_MAX));
		assert ((input_h == 0 && input_w == 0 ) || (INPUT_W_MIN <= input_w && input_w <= INPUT_W_MAX));

		if(input_h != 0 && input_w != 0 ){
			/* 出力 */
			OutW(input_w);				/* 横線 ##### */
			OutH(input_h, input_w);		/* 縦線 #...# (高さ-2行分繰り返す)*/
			OutW(input_w);				/* 横線 ##### */
			cout << "\n";					/* データセット間の空行 */
		}
		else{
			break;
		}
	}while(input_h != 0 && input_w != 0);
	
	return 0;
}



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

int main() {
    int n, m, k;
    cin >> n >> m >> k;
    vector<ll> psa(n + 1, 0), psb(m + 1, 0);
    rep(i, n) {
        ll a;
        cin >> a;
        psa[i + 1] = psa[i] + a;
    }
    rep(i, m) {
        ll b;
        cin >> b;
        psb[i + 1] = psb[i] + b;
    }

    int ans = 0;
    for (int i = 0; i <= n && psa[i] <= k; i++) {
        int num = upper_bound(psb.begin(), psb.end(), k - psa[i]) - psb.begin();
        num += i;
        num--;
        ans = max(ans, num);
    }
    cout << ans << endl;
}


Measured memory_bytes: 6424
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define endl "\n"
#define fastio ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define all(x) x.begin(),x.end()
#define y1 omg
#define INF 1000000010
#define FOR(x, n) for(int x=0; x<n; x++)
#define ini(x, n) memset(x, n, sizeof(x));
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<ll> vl;

int dx[] = { 1, -1, 0, 0, 1, 1, -1, -1 };
int dy[] = { 0, 0, 1, -1, 1, -1, 1, -1 };

ll x;

ll f(ll n) { return n * n * n * n * n; }
ll can(ll n) {
	for (ll i = 0; ; i++) {
		if (abs(n) == f(i)) return true;
		else if (abs(n) < f(i)) return false;
	}
}
ll give(ll n) {
	for (ll i = 0; ; i++) {
		if (abs(n) == f(i)) {
			if (n >= 0) return i;
			else return -i;
		}
	}
}
int main() {
	cin >> x;
	for (ll i = 0; ; i++) {
		ll a = f(i);
		ll target = a - x;
		if (can(target)) {
			cout << i << " " << give(target);
			return 0;
		}
	}
}

Measured memory_bytes: 3624
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        A solver = new A();
        solver.solve(1, in, out);
        out.close();
    }

    static class A {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            int n = in.ni();
            String s = in.ns();
            long mod = (int) 1e9 + 7;
            int[] cnt = new int[26];
            long ans = 0;
            for (int i = 0; i < n; i++) {
                int d = s.charAt(i) - 'a';
                long res = 1;
                for (int j = 0; j < 26; j++) {
                    if (j == d) continue;
                    res = res * (cnt[j] + 1) % mod;
                }
                ans = (ans + res) % mod;
                cnt[d]++;
            }
            out.println(ans);
        }

    }

    static class FastScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public FastScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String ns() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public int ni() {
            return Integer.parseInt(ns());
        }

    }
}



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

int main(void) {
    int n;
    scanf("%d", &n);
    char s[n], t[n], ans[2*n+1];
    scanf("%s %s", s, t);
    for (int i = 0; i < n; i++) {
        ans[i*2] = s[i];
        ans[i*2+1] = t[i];
    }
    ans[2*n] = '\0';
    printf("%s\n", ans);
    return 0;
}


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

using ll = long long;
using namespace std;

int n, m;
ll ans;

int main(){
	vector< pair<int, int> > t;
	cin >> n >> m;
	for(int i = 0; i < n; ++i){
		int a, b; cin >> a >> b;
		t.push_back(make_pair(a, b));
	}
	sort(t.begin(), t.end());
	
	for(int i = 0; i < n; ++i){
		int honsu = min(m, t[i].second);
		if(honsu > 0){
			m -= honsu;
			ans += 1LL * honsu * t[i].first;
		}else break;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1400
#include<iostream>
#include<vector>
#include<iomanip>

using namespace std;

int main(){
int N; cin >> N ; vector<double> p(N);
  for(int i = 0; i < N; i++){
    cin >> p[i];}
  
  double dp[3000][3000];
  
  for(int i = 0; i < 3000; i++){
    for(int j = 0; j < 3000; j++){
      dp[i][j] = 0;}}
  
  dp[0][0] = 1.0;
  
  for(int i = 0; i < N; i++){
    for(int j = 0; j <= i; j++){
      dp[i+1][j+1] += dp[i][j] * p[i];
      dp[i+1][j] += dp[i][j] * ( 1.0 - p[i]);}}

  
   double sum = 0;
  for(int j = (N + 1) / 2; j <= N; j++){
    sum += dp[N][j];}
  cout << setprecision(10) << sum << endl; return 0;}
                       
  
 


Measured memory_bytes: 70528
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long
#define mkp make_pair
#define pb push_back
#define ff first
#define ss second
#define debug1(a) cout<<a<<endl;
#define debug2(a,b) cout<<a<<' '<<b<<endl;
#define debug3(a,b,c) cout<<a<' '<<b<<' '<<c<<endl;
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,a,b)for(int i=a;i<b;i++)
#define repre(i,a,b)for(int i=a;i<=b;i++)
#define pi pair<int,int>
#define pii pair<int,pi>
//#define mp map<int,int>
//#define ump unordered_map<int,int>
#define st set<int>
#define mst multiset<int>
#define pq priority_queue
#define mpq priority_queue<int,vector<int>,greater<int> >
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace __gnu_pbds;
using namespace std;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> orderedSet;
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> orderedMSet;
//*p.find_by_order(index) return value at index
//p.order_of_key(key) return index
int32_t main()
{
   fastio
   int n;
   cin>>n;
   int arr[n];
   int ans=0;
   rep(i,n)
   {
     cin>>arr[i];
     ans=ans^arr[i];
   }
   if(ans==0)cout<<"Yes\n";
   else cout<<"No\n";

   return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
#define ll long long
#define vi vector <int>
#define vii vector <pair<int,int> >
#define rep(i,a,b) for (int i=a;i<b;i++)
#define repD(i,a,b) for (int i=a;i>b;i--)
#define pb push_back
#define pii pair <int,int>
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define MOD 1000000007
#define PI 3.14159265359
/*
 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>
 
using namespace __gnu_pbds;
typedef tree<pii,null_type,less <pii>,rb_tree_tag,tree_order_statistics_node_update>ind_set;
*/
///*X.find_by_order("index")
///X.order_of_key("key")
 
 
 
#define deb(x) cerr<<#x<< " : " <<x<<"\n";
#ifndef local
	#define deb(x) ;
#endif
///----------------------------------------------------------------------------------


void solve()
{
	int n,a,b;cin>>n>>a>>b;cout<<min(b,a*n)<<"\n";
}

signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);
 
    #ifdef local
    ///freopen("input.txt","r",stdin);
    ///freopen("output.txt","w",stdout);
    clock_t qwertyuiop = clock();
    #endif
 
 
    int t=1;
    ///cin>>t;
    
    rep(a,0,t)
    {
        ///cout<<"Case #"<<a+1<<": ";
        solve();
    }
    #ifdef local
	{qwertyuiop = clock() - qwertyuiop;double time_taken = ((double)qwertyuiop)/CLOCKS_PER_SEC;cerr<<fixed<<setprecision(5)<<"\n\nTime Taken : "<<time_taken<<" seconds\n";}
	#endif
}

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

const ll MOD = 1e9 + 7;

void sumToN(vector<ll> &v) {
    v.at(0) = 0;
    for (int i = 1; i < v.size(); ++i) {
        v.at(i) = (i + v.at(i - 1)) % MOD;
    }
}

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

    int N, K;
    cin >> N >> K;
    vector<ll> V(N + 1, 0);
    sumToN(V);
    ll ans = 0;
    for (int i = K; i <= N; ++i) {
        ans = (ans + ((V.at(N) + MOD - V.at(N - i)) % MOD + MOD - V.at(i - 1) + 1)) % MOD;
    }
    ans = (ans + 1) % MOD;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4784
import sys

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


def main():
    N = int(input())
    S = input()

    # 0番目と1番目を決めれば他が全部決まる
    for s0, s1 in [("S", "W"), ("W", "S"), ("S", "S"), ("W", "W")]:
        ans = [None] * N
        ans[0] = s0
        ans[1] = s1
        for i in range(1, N - 1):
            if ans[i] == "S":
                s = S[i]
            else:
                if S[i] == "o":
                    s = "x"
                else:
                    s = "o"

            if s == "o":
                ans[i + 1] = ans[i - 1]
            else:
                if ans[i - 1] == "S":
                    ans[i + 1] = "W"
                else:
                    ans[i + 1] = "S"

        if ans[-1] == "S":
            if S[-1] == "o":
                if ans[-2] == ans[0]:
                    pass
                else:
                    continue
            else:
                if ans[-2] != ans[0]:
                    pass
                else:
                    continue
        else:
            if S[-1] == "o":
                if ans[-2] != ans[0]:
                    pass
                else:
                    continue
            else:
                if ans[-2] == ans[0]:
                    pass
                else:
                    continue

        if ans[0] == "S":
            if S[0] == "o":
                if ans[-1] == ans[1]:
                    print(*ans, sep="")
                    return
                else:
                    continue
            else:
                if ans[-1] != ans[1]:
                    print(*ans, sep="")
                    return
                else:
                    continue
        else:
            if S[0] == "o":
                if ans[-1] != ans[1]:
                    print(*ans, sep="")
                    return
                else:
                    continue
            else:
                if ans[-1] == ans[1]:
                    print(*ans, sep="")
                    return
                else:
                    continue

    else:
        print(-1)


if __name__ == "__main__":
    main()


Measured memory_bytes: 7760
//by Top1
#include <bits/stdc++.h>
          
#define f first
#define s second
#define int long long
#define ld long double
#define ull unsigned long long
#define pii pair <int, int>
#define pll pair <long, long>
#define mp make_pair
#define pb push_back
#define pf push_front
#define pp pop_back
#define cerr cout
#define rev reverse
#define all(s) s.begin(), s.end()
#define sz(s) (int)s.size()
#define forn(i, a, b) for (int i = a; i <= b; i++)
#define boost ios_base::sync_with_stdio(false); cin.tie(0),cout.tie(0);
#define nxtp next_permutation
#define pvtp prev_permutation
#define KZ return 
#define x1 x21212121
#define y1 y21212121
#define sqr(x) x * x 
      
const int inf = (1e18) + 1;
const int mod = 479001599;
const int maxn = 2e5 + 1;
        
using namespace std;          

int n, u, v, dist1[maxn], dist2[maxn];
queue <int> q, t;
vector <int> g[maxn];
bool was[maxn], used[maxn];

void solve(){
	cin >> n >> u >> v;

	for (int i = 1; i < n; i++){
		int x, y;
		cin >> x >> y;
		g[x].pb(y);
		g[y].pb(x);
	}

	q.push(u);
	t.push(v);
	was[u] = true;
	used[v] = true;

	while (!q.empty()){
		int x = q.front();
		q.pop();
		for (int i = 0; i < sz(g[x]); i++){
			int to = g[x][i];
			if (!was[to]){
				was[to] = true;
				dist1[to] = dist1[x] + 1;
				q.push(to);
			}
		}	
	}

	while (!t.empty()){
		int x = t.front();
		t.pop();
		for (int i = 0; i < sz(g[x]); i++){
			int to = g[x][i];
			if (!used[to]){
				used[to] = true;
				dist2[to] = dist2[x] + 1;
				t.push(to);
			}
		}	
	}

	int mx = 0;

	for (int i = 1; i <= n; i++)
		if (dist1[i] <= dist2[i])
			mx = max(dist2[i], mx);

	cout << mx - 1;
}   
      
main(){
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);

    boost;
    
    int q = 1;

    //cin >> q;

    while (q--){
        solve();
    }
}

Measured memory_bytes: 12160
num=STDIN.gets.to_i
lines=STDIN.gets.chomp.split.map{|v|v.to_i}
maxval=lines.slice(0..num-1).max
sum=0
minval=lines.slice(0..num-1).min
lines.slice(0..num-1).each do | elm |
        sum = sum + elm
end
puts '%d %d %d'%([minval,maxval,sum])

Measured memory_bytes: 6508
#include <iostream>
using namespace std;
 
    
    
int main(){
  int k,n,x;
  cin>>k>>n;
  int a[n],b[n];

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

  for (int i = 0; i < n-1; i++)
  {
    b[i]=a[i+1]-a[i];
  }
  b[n-1]=k-a[n-1]+a[0];

  x=b[0];  
  for (int i = 1; i < n; i++)
  {
    if (x<b[i])
    {
      x=b[i];
    }
  }
  
  cout<<k-x<<endl;
  
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  double A, total_inv = 0;
  cin >> N;
  for(int i = 0; i < N; i++){
    cin >> A;
    total_inv += 1 / A;
  }
  cout << setprecision(15) << 1 / total_inv << endl;
  return 0;
}

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

#define all(A) begin(A), end(A)
#define rall(A) rbegin(A), rend(A)
#define sz(A) int(A.size())
#define pb push_back
#define mp make_pair

using namespace std;

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

int main () {
  ios::sync_with_stdio(false); cin.tie(0);
  int n;
  cin >> n;
  vector <int> p(n);
  for (int i = 0; i < n; i++) cin >> p[i];
  int ans = 0;
  for (int i = 1; i + 1 < n; i++) if ((p[i - 1] < p[i] and p[i] < p[i + 1]) or
                                      (p[i + 1] < p[i] and p[i] < p[i - 1])) ans++;
  cout << ans << '\n';
  return (0);
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    int n = in.nextInt();
    int[] h = new int[n];
    for (int i = 0; i < n; i++) h[i] = in.nextInt();
    int[] dp = new int[n];
    dp[0] = 0;
    dp[1] = Math.abs(h[0] - h[1]);
    for (int i = 2; i < n; i++) {
      int x = Math.abs(h[i] - h[i - 2]);
      int y = Math.abs(h[i] - h[i - 1]);
      dp[i] = Math.min(dp[i-2] + x,dp[i-1] + y);
    }
    System.out.println(dp[n-1]);
  }
}

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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

int main()
{
  int N, M; scanf("%d %d", &N, &M);
  vector<int> freqs(N + 5, 0);
  int a, b;
  for (int i = 0; i < M; ++i) {
    scanf("%d %d", &a, &b);
    ++freqs[a];
    ++freqs[b];
  }
  for (int i = 1; i <= N; ++i) {
    printf("%d\n", freqs[i]);
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stdio.h>

using namespace std;

int main() {
	char ch;
	int num, cou[26];
	for (int i = 0; i < 26; i++) {
		cou[i] = 0;
	}
	while (cin >> ch) {
		if (ch >= 'A' && ch <= 'Z') {
			num = ch - 'A';
			cou[num]++;
		}
		else if (ch >= 'a' && ch <= 'z') {
			num = ch - 'a';
			cou[num]++;
		}
	}
	for (int j = 0; j < 26; j++) {
		printf("%c : %d\n", j + 'a', cou[j]);
	}
	return 0;
}


Measured memory_bytes: 3224
import heapq

n, c = map(int, input().split())
d = [list(map(int, input().split())) for _ in range(c)]
grid = [list(map(int, input().split())) for _ in range(n)]

MAXN = 500
MAXC = 30

s = [[0 for _ in range(MAXC)] for _ in range(3)]
for i in range(3):
    for co in range(c):
        for x in range(n):
            for y in range(n):
                if (x+y)%3 == i:
                    s[i][co] += d[grid[x][y]-1][co]

ans = 10**10
for c0 in range(c):
    for c1 in range(c):
        if c0 == c1:
            continue
        for c2 in range(c):
            if c0 == c2 or c1 == c2:
                continue
            ans = min(ans, s[0][c0]+s[1][c1]+s[2][c2])
print(ans)


Measured memory_bytes: 47108
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const ll mod = 100000000000000003;
int ne[200001], he[10001];
char C[1200100];

ll num[524300];
int kazu[524300];
const int ma = (1 << 19) - 1;
int query(ll n) {
	int n2 = (n & ma) + 1;
	while (num[n2]) {
		if (num[n2] == n + 1) return kazu[n2];
		n2 = n2 * 61 + 1 & ma;
	}
	return 0;
}
void add(ll n, int b) {
	int n2 = (n & ma) + 1;
	while (num[n2]) {
		if (num[n2] == n + 1) {
			kazu[n2] |= b;
			return;
		}
		n2 = n2 * 61 + 1 & ma;
	}
	num[n2] = n + 1;
	kazu[n2] = b;
}

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


	fread(C, 1, 1200100, stdin);
	char* ci = C, c;
	int N = 0;
	while ((c = *ci++) >= '0') N = N * 10 + c - '0';

	ll dekai[100];
	int d = 0;
	char* s[200001];
	rep1(i, N) {
		s[i] = ci;
		while (*ci++ >= '0');
		int n = ci - s[i] - 1;	
		if (n <= 100000) {
			ne[i] = he[n];
			he[n] = i;
		}
		else {
			dekai[d++] = (ll(n) << 30) + s[i] - C;
		}
	}

	ll kotae = 0;

	for (int M = 1; M <= 10000; M++) {
		for (int p = he[M]; p; p = ne[p]) {
			auto S = s[p];
			int k[26] = {};
			ll are = 0;
			for (int i = M - 1; i >= 1; i--) {
				int tmp = query(are);
				if (tmp) {
					rep(j, 26) if ((tmp >> j & 1)) {
						k[j]++;
					}
				}
				kotae += k[S[i] - 'a'];
				k[S[i] - 'a'] = 0;
				are = (are * 30 + S[i] - 'a' + 1) % mod;
			}

			kotae += k[S[0] - 'a'];
			k[S[0] - 'a'] = 0;

			add(are, 1 << (S[0] - 'a'));
		}
	}
	sort(dekai, dekai + d);
	rep(p, d) {
		auto S = C + (dekai[p] & (1 << 21) - 1);
		int k[26] = {};
		ll are = 0;
		for (int i = (dekai[p] >> 30) - 1; i >= 1; i--) {
			int tmp = query(are);
			if (tmp) {
				rep(j, 26) if ((tmp >> j & 1)) {
					k[j]++;
				}
			}
			kotae += k[S[i] - 'a'];
			k[S[i] - 'a'] = 0;
			are = (are * 30 + S[i] - 'a' + 1) % mod;
		}

		kotae += k[S[0] - 'a'];
		k[S[0] - 'a'] = 0;

		add(are, 1 << (S[0] - 'a'));
	}
	printf("%lld\n", kotae);


	Would you please return 0;
}

Measured memory_bytes: 12700
/// 25-01-2018
/// MD:NUR ALAM
/// Eastern University of Bangladesh

#include "bits/stdc++.h"

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = (a); i < (b); ++i)
#define fo(i, a, b) for (int i = (a); i <(b); ++i)
#define fors(i, s) for (int i = 0; s[i]; ++i)
#define rs(x) scanf("%s", (x))
#define mp make_pair
#define pb push_back
#define mso(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define len(X) strlen(x)

using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef long double lu;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vpll;
typedef pair<int,int> Pll;
typedef map<string,int>msi;
typedef set<int>se;

template<class t> void _r(t &x) { cin >> x; }
void _r(int &x) { scanf("%d", &x); }
void _r(int64_t &x) { scanf("%lld", &x); }
void _r(double &x) { scanf("%lf", &x); }
void _r(char &x) { scanf(" %c", &x); }
void _r(char *x) { scanf("%s", x); }
void r() {}
template<class t, class... u> void r(t &head, u &... tail) { _r(head); r(tail...); }
template<class t> void _w(const t &x) { cout << x; }
void _w(const int &x) { printf("%d", x); }
void _w(const int64_t &x) { printf("%lld", x); }
void _w(const double &x) { printf("%.16f", x); }
void _w(const char &x) { putchar(x); }
void _w(const char *x) { printf("%s", x); }
template<class t,class u> void _w(const pair<t,u> &x) {_w(x.f); putchar(' '); _w(x.s);}
void w() {}
template<class t, class... u> void w(const t &head, const u &... tail) { _w(head); putchar(sizeof...(tail) ? ' ' : '\n'); w(tail...); }
template<class t, class... u> void debug(const t &head, const u &... tail) {
#ifdef HOME
#endif
}

///------------------------------------------------------------------------------------------------------------------------------------



int main(){

    ll a,n,s=0;
    r(a);
    n=a;
    while(n!=0)
    {
        s=s+n%10;
        n/=10;
    }
    if(a%s==0) w("Yes");
    else w("No");
}


Measured memory_bytes: 256
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.array;
import std.range;
import std.math;

void main(){
  auto z=readln.split.to!(int[]),a=z[0],b=z[1];
  if(a<=b)writeln(a);
  else writeln(a-1);
}  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std; // スペル注意
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)

vector<string> split(string s, char sp){
    vector<string> vs;
    string t = "";
    for(char c : s){
        if(c == sp){
            vs.emplace_back(t);
            t = "";
        }
        else{
            t += c;
        }
    }
    vs.emplace_back(t);
    return vs;
}
string calc(string S, string T){
        if(S == T){
            return "IDENTICAL";
        }
        vector<string> P = split(S, '\"');
        vector<string> Q = split(T, '\"');
        if(P.size() != Q.size())return "DIFFERENT";
        int cnt = 0;
        rep(i, P.size()){
            //cout << P[i] << " " << Q[i] << endl;
            if(i % 2 == 0){
                if(P[i] != Q[i])return "DIFFERENT";
            }
            else{
                if(P[i] != Q[i])cnt++;
            }
        }
        if(cnt > 1)return "DIFFERENT";
        return "CLOSE";
}

int main(){
    string S, T;
    while(cin >> S, S != "."){
        cin >> T;
        cout << calc(S,T) << endl;
    }
    return 0;
}


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

int main() {
	// your code goes here

    int n; cin>>n;
    int a[n];
    
    for(int i=0;i<n;i++) cin>>a[i];
    if(n==2)
    {
        cout<<abs(a[1]-a[0])<<endl;
       
    }
    else {
    int dp[n+1];
    dp[0]=0;
   // dp[n]=min(abs(a[n-1]-a[n-2]),abs(a[n-1],a[n-3]));
    for(int i=1;i<n;i++)
    {
       if(i==1) dp[i]=abs(a[i]-a[i-1]);
       else dp[i]=min(abs(a[i]-a[i-1])+dp[i-1],abs(a[i]-a[i-2])+dp[i-2]);
       
    //   cout<<dp[i]<<" ";
       
    }
    cout<<dp[n-1]<<endl; 
    }
	return 0;
}


Measured memory_bytes: 4396
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pl;
#define all(a) (a).begin(),(a).end()
#define overload4(_1, _2, _3, _4, name, ...) name
#define rep1(n) for(ll i = 0;i < (n);i++)
#define rep2(i,n) for(ll i = 0;i < (n);i++)
#define rep3(i,a,b) for(ll i = (a);i < (b);i++)
#define rep4(i,a,b,c) for(ll i = (a);i < (b);i += (c))
#define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep1(n) for(ll i = (n)-1;i >= 0;i--)
#define rrep2(i,n) for(ll i = (n)-1;i >= 0;i--)
#define rrep3(i,a,b) for(ll i = (a)-1;i >= (b);i--)
#define rrep4(i,a,b,c) for(ll i = (a)-1;i >= (b);i -= (c))
#define rrep(...) overload4(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define SHOW(x) cout << #x << ": " << x << endl;
template<class T> ll sumArr(const T& a){ return accumulate(all(a), 0LL);}
template<class T> auto minArr(const T& a){ return *min_element(all(a));}
template<class T> auto maxArr(const T& a){ return *max_element(all(a));}
template<class T> void DEBUG_PRINT(T tmp){cout<<tmp<<endl;}
template<class T1,class... T2> void DEBUG_PRINT(T1 tmp,T2... tmp2){cout<<tmp<<" ";DEBUG_PRINT(tmp2...);}
ll gcd(ll a, ll b){ while(b){ ll c = b; b = a % b; a = c; } return a; }
const ll INF=1e18,MOD = 1e9+7;
const int iINF = 1e9;


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

    string s;
    cin>>s;
    bool flag = false;

    rep(i,s.size())if(s[i] == '7')flag = true;

    if(flag)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    

    return 0;

}

Measured memory_bytes: 3616
import sys
import itertools

def one_step(lo,lis):
    nu = [ e for e in lis ]
    for j in xrange(len(nu)):
        if lo[0][j] == 1:
            nu[j],nu[j+1] = nu[j+1],nu[j]
    return lo[1:],nu

def solve(lo,lis):
    if len(lo) == 0:
        return lis
    nu = [ e for e in lis]
    lo2,nu2 = one_step(lo,nu)
    return solve(lo2,nu2)

def func(lots,lis,n,m,star,d):
    for i in xrange(d):
        for j in xrange(1,n):
            if lots[0][j-1] + lots[0][j] + lots[0][j+1] == 0:
                lots[0][j] = 1
                if solve(lots,lis)[star] == m: print i+1,j;return True
                lots[0][j] = 0
        lots,lis = one_step(lots,lis)
    return False

while True:
    n = input()
    if n == 0: exit()
    m = input()
    star = input()
    d = input()
    lis = range(n+1)
    lots = []
    for i in xrange(d):
        lots.append( [0] + map(int,raw_input()) + [0])
    if solve(lots,lis)[star] == m: print 0;continue
    elif func(lots,lis,n,m,star,d): continue
    else: print 1

Measured memory_bytes: 4464
A, B, C = gets.chomp.split.map(&:to_i)
aa = (A * 10 + B) + C
bb = (A * 10 + C) + B
cc = (B * 10 + A) + C
dd = (B * 10 + C) + A
ee = (C * 10 + A) + B
ff = (C * 10 + B) + A
puts [aa, bb, cc, dd, ee, ff].max

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

int main(){
  int a,b,c;
  
  cin>>a>>b>>c;
  
  if((a==5&&b==5&&c==7)||(a==5&&b==7&&c==5)||(a==7&&b==5&&c==5))cout << " YES " << endl;
  else cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 256
double d[3],e[3],s[99][3];main(T,n,i,j,k,l){for(scanf("%d",&T);T;T--){
for(scanf("%lf%lf%lf%d",d,d+1,d+2,&n),i=0;i<n;i++)scanf("%lf%lf%lf",s[i],s[i]+1,s[i]+2);
for(i=0;i<n;i++)for(j=0;j<n;j++)for(k=0;k<n;k++)if(i!=j&&j!=k&&k!=i){
	*e=sqrt(pow(*s[j]-*s[i],2)+pow(s[j][1]-s[i][1],2)+pow(s[j][2]-s[i][2],2));
	e[1]=sqrt(pow(*s[k]-*s[j],2)+pow(s[k][1]-s[j][1],2)+pow(s[k][2]-s[j][2],2));
	e[2]=sqrt(pow(*s[i]-*s[k],2)+pow(s[i][1]-s[k][1],2)+pow(s[i][2]-s[k][2],2));
	for(l=0;l<3;l++)if(d[l]/d[(l+1)%3]-e[l]/e[(l+1)%3]>1e-3)break;
	if(l==3)printf("%d %d %d\n",k+1,i+1,j+1);
}
}exit(0);}

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

int main() {
  int x;
  cin >> x;
  if (x < 2) {
    cout << 1;
  }else if (x < 4) {
    cout << 2;
  }else if (x < 8) {
    cout << 4;
  }else if (x < 16) {
    cout << 8;
  }else if (x < 32) {
    cout << 16;
  }else if (x < 64) {
      cout << 32;
  }else {
      cout << 64;
  }
}

Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

#define rep(i, N) for (int i = 0; i < N; ++i)

int main() {
    int fans = 1012345678;
    vector<int> menus(5);
    vector<int> order = {0, 1, 2, 3, 4};
    rep(i, 5) cin >> menus[i];

    while (next_permutation(order.begin(), order.end())) {
        int ans = 0;
        rep(i, menus.size()) {
            while (ans % 10 != 0) ans++;
            ans += menus[order[i]];
        }
        fans = min(fans, ans);
    }

    cout << fans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)(b); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n;
    cin >> n;
    ll a[n];
    rep(i, 0, n) {
        cin >> a[i];
    }
    ll sum[n + 1] = {};
    rep(i, 0, n) {
        sum[i + 1] = sum[i] + a[i];
    }
    ll ans = 0;
    rep(i, 0, n - 1) {
        ans += (a[i] * ((sum[n] - sum[i + 1]) % MOD)) % MOD;
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6744
#include <bits/stdc++.h>
using namespace std;
int main()
{   int n,x=0,m=0;cin>>n;
    char a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(a[i]=='I'){
            x+=1;
            if(x>m)
                m=x;
        }
        else {
             x-=1;
            if(x>m)
                m=x;
        }
    }
    
    cout<<m<<endl;
return 0;
}






Measured memory_bytes: 3520
s = input()
n = int(input())
t = ''
for i in range(n):
    q = input().split()
    if len(q) == 1:
        t, s = s, t
    elif len(q) == 3:
        if q[1] == '1':
            t += q[2]
        elif q[1] == '2':
            s += q[2]

t = t[::-1]
print(t + s)

Measured memory_bytes: 4316
N = int(input())
H = list(map(int, input().split()))

cnt = cnt_tmp = 0
for i in range(1, N):
    if H[i] <= H[i - 1]:
        cnt_tmp += 1
    else:
        cnt = max(cnt, cnt_tmp)
        cnt_tmp = 0
else:
    cnt = max(cnt, cnt_tmp)

print(cnt)

Measured memory_bytes: 14252