akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
using namespace std;
//桁
int kt(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }
signed main(){
  string a;
  cin>>a;
  bool c=true;
  rep(i,a.size()){
    if(i%2==0){
      if(a.at(i)=='L'){
    c=false;
        break;
      }
    }
    else{
      if(a.at(i)=='R'){
c=false;
        break;
      }
    }
  }
    if(c)
         cout<<"Yes";
         else
         cout<<"No";
}


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

const int MAX_N = 100100100;

int main() {
    ll x;
    cin >> x;
    ll money = 100;
    int ans = 0;
    for(int i = 1; i < MAX_N; i++) {
        money *= 1.01;
        if(x <= money) {
            ans = i;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3592
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
using namespace std;
typedef pair<int,int> P;
double dat[100][100];
//int dp[6][1010];//動的計画法
int prime[10000001];
char str[1010][1010];
vector<pair<int,int> > pc[100001];
int ABS(int a){return max(a,-a);}
int main(){
	int x,tmp;
	cin>>x;
	for(int i=1;i<=x;i++){
		tmp+=i;
		if(tmp>=x){
			cout<<i;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 4352
#include <stdio.h>

int main(){
	long long a, b, c, d;
	scanf("%lld %lld %lld %lld", &a, &b, &c, &d);
	long long x = a*c, y = b*c, z = a*d, p = b*d;
	if(x>y) y = x;
	if(z>p) p = z;
	if(y>p) p = y;
	printf("%lld", p);
	return 0;
}

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

int main(void) {
  long long X;
  cin >> X;
  for (long long A = -300; A < 300; A++)
    for (long long B = -300; B < 300; B++)
      if (A * A * A * A * A - B * B * B * B * B == X) {
        cout << A << " " << B << endl;
        return 0;
      }
  return 0;
}

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

#define debug(x) cout<<#x<<": "<<x<<endl
#define rep(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<=(b);i++)
#define all(a) (a).begin(),(a).end()
using namespace std;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef long long ll;

void solve() {
#ifdef _WIN32
	istream &cin = ifstream("input.txt");
#endif

	int k, t, m = 0, sum = 0;
	cin >> k >> t;
	VI v(t);

	rep(i, t) {
		cin >> v[i];
	}
	sort(all(v));
	sum = accumulate(all(v), 0) - v[t - 1];

	cout << max(0, v[t - 1] - sum - 1) << endl;
}




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


	solve();
	system("PAUSE");
	return 0;
}

Measured memory_bytes: 504
#include<bits/stdc++.h>
#define ll  long long int
#define ull unsigned long long 
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back 
#define mp make_pair
#define inf 1000000000000000
#define mod 1000000007
#define ld long double
#define pll pair<ll,ll>
using namespace std;
const ll use =1e18;
int main()
{ 
	

fast;
ld a,b;
cin>>a>>b;
ll ans=a*b;
cout<<ans;
}


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

int main(){
string s;
cin >> s;
if (s=="Sunny") cout << "Cloudy" << endl;
else if (s=="Cloudy") cout << "Rainy" << endl;
else if (s=="Rainy") cout << "Sunny" << endl;
   }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,N) for(i=0;i<N;i++)
typedef long long ll;
typedef pair<ll, ll> P;
typedef struct{
  int first;
  int second;
  int third;
}T;

//昇順
bool comp_Se(T& l, T& r){
  return l.second < r.second;
}

int N;
vector<P> v;

int main(void){
  bool sat=true;
  cin >> N;
  int i,j,mode;
  vector<ll> d;
  v.resize(N);
  ll x,y,max=0,length=0,L;
  REP(i,N){
    cin >> x >> y;
    if(!i) mode = abs(x+y)%2;
    else if(abs(x+y)%2 != mode) sat = false;
    if(max < abs(x) + abs(y)) max = abs(x) + abs(y);
    v[i].first = x;
    v[i].second = y;
  }
  if(!sat){
    cout << -1 << endl;
    return 0;
  }
  if(!mode){
    d.push_back(1);
    length++;
  }
  while(max>length){
    if(d.size() + mode==1)d.push_back(1);
    else d.push_back(2*d[d.size()-1]);
    length += d[d.size()-1];
  }
  sort(d.begin(),d.end(),greater<ll>());

  cout << d.size() << endl;
  REP(i,d.size()) cout << d[i] << " ";
  cout << endl;
  REP(i,N){
    x = v[i].first;
    y = v[i].second;
    L = length;
    REP(j,d.size()){
      if(abs(x+d[j])+abs(y)<=L-d[j]){
        cout << "L";
        x += d[j];
        L -= d[j];
      }else if(abs(x-d[j])+abs(y)<=L-d[j]){
        cout << "R";
        x -= d[j];
        L -= d[j];
      }else if(abs(x)+abs(y+d[j])<=L-d[j]){
        cout << "D";
        y += d[j];
        L -= d[j];
      }else if(abs(x)+abs(y-d[j])<=L-d[j]){
        cout << "U";
        y -= d[j];
        L -= d[j];
      }else{
      }
    }
    cout << endl;
  }


  return 0;
}

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

int main() {
  int N, A = 0, B = 0;
  cin >> N;
  vector<int> vec(N);
  for (auto i = 0; i < N; i++)
    cin >> vec[i];
  sort(vec.begin(), vec.end());
  for (auto i = 0; i < N; i += 2) {
    A += vec.back();
    vec.pop_back();
    if (! vec.empty()) {
      B += vec.back();
      vec.pop_back();
    }
  }
  cout << A - B << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(sc.hasNext()) {
            String[] a_b = sc.nextLine().split(" ");
            int a = Integer.parseInt(a_b[0]);
            int b = Integer.parseInt(a_b[1]);
            if (a == 0 && b == 0) {
                break;
            }
            if (a > b) {
                System.out.println(b + " " + a);
            } else {
                System.out.println(a + " " + b);
            }
        }
    }
}




Measured memory_bytes: 37616
n, k = map(int, input().split())
v = list(map(int, input().split()))

ans = 0
for left in range(min(n, k+1)):
    for right in range(min(n-left+1, k-left+1)):
        l = v[:left]
        l+=v[::-1][:right]
        l.sort()
        temp = sum(l)
        for t in range(max(0, min(len(l), k-left-right))):
            if l[t]<0:
                temp-=l[t]
        ans = max(ans, temp)
print(ans)


Measured memory_bytes: 3064
#include <cstdio>
#include <cstdlib>
#include <cstring>

// 双方向連結リストのノード
struct Node
{
    int key;        // キー
    Node *next;     // 次のノード
    Node *prev;     // 前のノード
};

Node *nil;  // 番兵

Node* listSearch(int key)
{
    Node* cur = nil->next;  // 番兵の次の要素から辿る

    /* 指定された値が見つかるまで */
    while (cur != nil && cur->key != key) {
        cur = cur->next;        
    }
    return (cur);   // 指定された値と一致するノードのアドレス or 番兵のアドレス(※見つからなかった場合)
}

// 番兵ノード作成
void init()
{
    nil = (Node*)malloc(sizeof(Node));
    nil->next = nil;
    nil->prev = nil;
}

void printList()
{
    Node* cur = nil->next;  // 先頭ノード
    int isf = 0;
    while (1)
    {
        if ( cur == nil ) break;
        if ( isf++ > 0 ) printf(" ");
        printf("%d", cur->key);
        cur = cur->next;
    }
    printf("\n");
}
// キー x を持つ最初の要素を連結リストから削除する。
// そのような要素が存在しない場合(t == nil)は何もしない。
void deleteNode(Node* t)
{
    if ( t == nil ) return;
    t->prev->next = t->next;    // 前のノードのnextを次のノードへのポインタにする
    t->next->prev = t->prev;    // 次のノードのprevを前のノードへのポインタにする    
    free(t);
}
// リストの先頭の要素を削除する
void deleteFirst()
{
    // 番兵の次のノード == 先頭ノード
    deleteNode(nil->next);
}
// リストの末尾の要素を削除する
void deleteLast()
{
    // 番兵の前のノード == 末尾ノード
    deleteNode(nil->prev);
}

// keyを指定して削除する
void deleteKey(int key)
{
    deleteNode(listSearch(key));
}
// 連結リストの先頭にキー x を持つ要素を継ぎ足す
void insert(int key)
{
    Node* x;    // 挿入されるノード

    x = (Node*)malloc(sizeof(Node));

    x->key = key;
    x->next = nil->next; 
    x->prev = nil;

    nil->next->prev = x;
    nil->next = x;
}

int main()
{
    int key, n;
    int size = 0;

    char com[20];

    int np = 0, nd = 0;

    scanf("%d", &n);

    init();

    for (int i = 0; i < n; i++) {
        scanf("%s%d", com, &key);
        if (com[0] == 'i') {
            insert(key);
            np++;
            size++;
        }
        else if (strncmp(com, "delete", 6) == 0) {
            if (strcmp(&com[6], "First") == 0) {
                deleteFirst();
            }
            else if (strcmp(&com[6], "Last") == 0) {
                deleteLast();
            }
            else {
                deleteKey(key);
                nd++;
            }
            size--;
        }
    }
    printList();

    return (0);
}



Measured memory_bytes: 33992
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <complex>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
#include <assert.h>
#include <array>
#include <cstdio>
#include <cstring>
#include <random>
#include <functional>
#include <numeric>
#include <bitset>
#include <fstream>

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

typedef long long ll;
int const inf = 1<<29;

int main() {

  int N; scanf("%d", &N);
  map<pair<int, int>, ll> mp;
  vector<pair<int, int>> vs;
  rep(i, N) {
    int x, y, w; scanf("%d%d%d",&x,&y,&w);
    vs.emplace_back(x, y);
    mp[{x, y}] += w;
  }

  ll ans = 0;

  rep(i, vs.size()) {
    int x = vs[i].first, y = vs[i].second;
    REP(dx, -1, 2) REP(dy, -1, 2) {
      if(!dx || !dy) continue;
      maximize(ans, mp[{x, y}] + mp[{x + dx, y}] + mp[{x, y + dy}] + mp[{x + dx, y + dy}]);
    }
  }

  cout << ans << " / 1" << endl;

  return 0;
}

Measured memory_bytes: 59788
#include <stdio.h>

int main(void) {
    int digits, count;
    scanf("%d %d", &digits, &count);

    int nums[digits];
    for (int i = 0; i < digits; i++) {
        nums[i] = -1;
    }
    for (int i = 0; i < count; i++) {
        int digit, num;
        scanf(" %d %d", &digit, &num);
        if (nums[digit - 1] < 0) {
            nums[digit - 1] = num;
        } else {
            if (nums[digit - 1] != num) {
                printf("-1\n");
                return 0;
            }
        }
    }

    int result = 0, times = 1, flag = 1;
    // printf("%d %d %d\n", nums[0], nums[1], nums[2]);
    if (nums[0] < 0 && digits > 1) {
        nums[0] = 1;
    }
    for (int j = 0; j < digits - 1; j++) {
        times *= 10;
    }
    for (int i = 0; i < digits; i++) {
        if (flag && !nums[i]) {
            break;
        } else if (nums[i] > 0) {
            result += nums[i] * times;
            flag = 0;
        }
        times /= 10;
        // printf("%d\n", result);
    }
    if (!flag) {
        printf("%d\n", result);
    } else if (digits == 1) {
        printf("0\n");
    } else {
        printf("-1\n");
    }
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll  long long
#define mod 1000000007
class flow
{public:
ll int he;
ll int be;
    
};
ll int solve(flow* a,ll int n)
{ll int dp[n]={0};
ll int ans=0;
//cout<<a[0].he<<" "<<a[0].be<<" poi\n";
map<ll int,ll int> meaningful;
meaningful[a[0].he]=a[0].be;
dp[0]=a[0].be;
ans=max(ans,dp[0]);
//cout<<dp[0]<<" dp[0]\n";
for(ll int i=1;i<n;i++)
{dp[i]=a[i].be;
auto it=meaningful.lower_bound(a[i].he+1);
if(it!=meaningful.begin())
{it--;

dp[i]=dp[i]+it->second;    
}
meaningful[a[i].he]=dp[i];
it=meaningful.upper_bound(a[i].he);
while(it!=meaningful.end()&&it->second<=dp[i])
{auto temp=it;
temp++;
meaningful.erase(it);
it=temp;
    
}

ans=max(ans,dp[i]) ;   

//cout<<i<<" "<<dp[i]<<endl;    
}
return ans;

}

int main()
{ll int n;
cin>>n;
 flow a[n];
 for(ll int i=0;i<n;i++)
 {cin>>a[i].he;}
  for(ll int i=0;i<n;i++)
 {cin>>a[i].be;}
 
  ll int d=solve(a,n);
cout<<d<<endl;    
}

Measured memory_bytes: 17408
// Author : Mohamed Sameh
#include <bits/stdc++.h>
typedef long long ll ;
#define pb push_back
#define f first
#define s second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define SZ(a) (int)a.size()
#define Flush fflush(stdout);
using namespace std ;
const int N = 1e5, M = 1e9 + 7;
vector<int> adj[N];
int n;
ll dp[N][2];
void solve(int node = 0, int par = 0)
{
  dp[node][0] = dp[node][1] = 1;
  for (int i : adj[node])
  {
    if (i == par)continue;
    solve(i, node);
    dp[node][0] = (dp[node][0] * (dp[i][1] + dp[i][0])%M)%M;
    dp[node][1] = (dp[node][1] * dp[i][0])%M;
  }
}
int main()
{
  scanf("%d", &n);
  for (int i = 0; i < n-1; i++)
  {
    int u, v;
    scanf("%d%d", &u, &v);
    u--;v--;
    adj[u].pb(v);
    adj[v].pb(u);
  }
  solve();
  printf("%d\n", (dp[0][0] + dp[0][1])%M);
}


Measured memory_bytes: 17580
#include <bits/stdc++.h>
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(long long i = 0; i < (long long)(N); i++)
#define repr(i,N) for(long long i = (long long)(N) - 1; i >= 0; i--)
#define rep1(i,N) for(long long i = 1; i <= (long long)(N) ; i++)
#define repr1(i,N) for(long long i = (N) ; (long long)(i) > 0 ; i--)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
using namespace std; void solve();
using ll = long long; template<class T = ll> using V = vector<T>;
using vi = V<int>; using vl = V<>; using vvi = V< V<int> >;
constexpr int inf = 1001001001; constexpr ll infLL = (1LL << 61) - 1;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(7);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cerr << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,N) do { cerr << #v << " = "; array_out(v , N);cout << endl;} while(0)
#else
  #define trc(...)
  #define trca(...)
  int main(){solve();}
#endif

#define inc(...) char __VA_ARGS__; in(__VA_ARGS__)
#define in2(N,s,t) rep(i,N){in(s[i] , t[i]);}
#define in3(N,s,t,u) rep(i,N){in(s[i] , t[i] , u[i]);}
using vd = V<double>; using vs = V<string>; using vvl = V< V<> >;
template<typename T>using heap = priority_queue< T , V<T> , greater<T> >;

using P = pair<ll,ll>; using vp = V<P>;
constexpr int MOD = /**/ 1000000007; //*/ 998244353;
//////////////////

void solve(){
  inl(N , L);
  vl a(N); in(a);

  rep(i , N - 1){
    if(a[i] + a[i + 1] >= L){
      out("Possible");
      for(int j = 0 ; j < i ; j++){
        out(j + 1);
      }
      for(int j = N - 2 ; j > i ; j--){
        out(j + 1);
      }
      out(i + 1);
      return;
    }
  }

  out("Impossible");
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) x.begin(),x.end()
#define pll  pair <long long,long long>
#define ss second
#define ff first
#define inf 9223372036854775807
#define maa 1000000007
#define ld long double
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define bug(x) cout << #x <<": " << x << '\n';
const ll N=200001 ;
int main()
{
   fast ;
   ///Mission-500
   ll x ;
   cin>>x ;
   ll n=x+(x%2) ;
   n/=2 ;
   ll a=0 ;
   while(n>=5)
   {
       a+=n/5 ;
       n=n/5 ;
   }

   if(x%2==0)
   {
       cout<<a ;
   }
   else
   {
       cout<<"0" ;

   }


}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <functional>

template<class T> class segment_tree {
	int N = 1; // the number of leaves
	std::vector<T> value;

public :
	const std::function<T(T, T)> op; // binary operation
	const T id; // identity element

	segment_tree(const std::vector<T>& v, const std::function<T(T, T)>& f, const T& t) : op(f), id(t) {
		int n = v.size();
		while (N < n) N *= 2;
		value.resize(N * 2, id);
		for (int i = 0; i < n; ++i) value[N + i] = v[i];
		for (int i = N - 1; i > 0; --i) value[i] = op(value[i * 2], value[i * 2 + 1]);
	}
	segment_tree(const int& n, const std::function<T(T, T)>& f, const T& t) : op(f), id(t) {
		while (N < n) N *= 2;
		value.resize(N * 2, id);
	}

	void point_update(const int& k, const T& t) {
		value[N + k] = t;
		for (int i = (N + k) / 2; i > 0; i /= 2) value[i] = op(value[i * 2], value[i * 2 + 1]);
	}

	T range_fold(const int& L, const int& R, const int& k = 1, const int& l = 0, int r = -1) const {
		if (r == -1) r = N;
		if (r <= L || R <= l) return id;
		if (L <= l && r <= R) return value[k];
		int mid = (l + r) / 2;
		return op(range_fold(L, R, k * 2, l, mid), range_fold(L, R, k * 2 + 1, mid, r));
	}

	const T& operator[](const int& k) const {return value[N + k];}
};

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

	int N, K;
	std::cin >> N >> K;
	std::vector<int> A(N);
	for (int i = 0; i < N; i++) std::cin >> A[i];

	segment_tree<int> sg(300001, [](int a, int b){return std::max(a, b);}, 0);
	for (int i = 0; i < N; i++) {
		int m = sg.range_fold(A[i] - K, A[i] + K + 1);
		sg.point_update(A[i], m + 1);
	}
	std::cout << sg.range_fold(0, 300001) << '\n';
}

Measured memory_bytes: 8484
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef  unsigned long long int ull;
typedef pair<ll,ll> P;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int main(){
ll n;
cin>>n;
V<ll> a(n);
ll ans=0;
for(int i=0;i<n;i++){
   cin>>a[i];
}
sort(all(a));
int mid=n/2;
V<ll> b(n);
b[mid]=a[0];
int l=1,r=n-1;
for(int i=1;i<=mid;i++){
    if(i%2==1){
        b[mid-i]=a[r--];
        if(mid+i<n)b[mid+i]=a[r--];
    }
    else{
        b[mid-i]=a[l++];
        if(mid+i<n)b[mid+i]=a[l++];
    }
}
ll res=0,res2=0;
for(int i=0;i<n-1;i++){
  res+=abs(b[i+1]-b[i]);
}
b[mid]=a[n-1];
l=0;r=n-2;
for(int i=1;i<=mid;i++){
    if(i%2==0){
        b[mid-i]=a[r--];
        if(mid+i<n)b[mid+i]=a[r--];
    }
    else{
        b[mid-i]=a[l++];
        if(mid+i<n)b[mid+i]=a[l++];
    }
}
for(int i=0;i<n-1;i++){
  res2+=abs(b[i+1]-b[i]);
}
cout<<max(res,res2)<<endl;
}



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

class MainClass : Scanner
{
    static void Main()
    {
        string A = RString();
        int N = A.Length;

        var Counter = new long[26][];
        for (int i = 0; i < 26; i++)
        {
            Counter[i] = new long[N+1];
            for (int j = 0; j < N; j++)
            {
                Counter[i][j + 1] = Counter[i][j] + (A[j] == (char)('a' + i) ? 1 : 0);
            }
        }

        long ans = 0;
        for (int i = 0; i < N-1; i++)
        {
            int index = (A[i] - 'a');
            ans += (N-i) - (Counter[index][N] - Counter[index][i]);
        }
        WriteLine(ans+1);
    }
}



class Scanner
{
    public static string RString() => Console.ReadLine();
    public static int RInt() => ReadTuple<int>();
    public static long RLong() => ReadTuple<long>();
    public static double RDouble() => ReadTuple<double>();

    public static string[] RStrings() => Console.ReadLine().Split();
    public static int[] RInts() => Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
    public static long[] RLongs() => Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
    public static double[] RDoubles() => Array.ConvertAll(Console.ReadLine().Split(), double.Parse);
    public static int[] RInts(Func<string, int> func) => Console.ReadLine().Split().Select(func).ToArray();
    public static long[] RLongs(Func<string, long> func) => Console.ReadLine().Split().Select(func).ToArray();
    public static double[] RDoubles(Func<string, double> func) => Console.ReadLine().Split().Select(func).ToArray();
    //public static string[] RStrings(Func<string, string> func) => Console.ReadLine().Split().Select(func).ToArray();

    public static T1 ReadTuple<T1>()
    {
        var r = RString();
        var r1 = (T1)Convert.ChangeType(r, typeof(T1));
        return r1;
    }
    public static (T1, T2) ReadTuple<T1, T2>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
        return (r1, r2);
    }
    public static (T1, T2, T3) ReadTuple<T1, T2, T3>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
        var r3 = (T3)Convert.ChangeType(r[2], typeof(T3));
        return (r1, r2, r3);
    }
    public static (T1, T2, T3, T4) ReadTuple<T1, T2, T3, T4>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
        var r3 = (T3)Convert.ChangeType(r[2], typeof(T3));
        var r4 = (T4)Convert.ChangeType(r[3], typeof(T4));
        return (r1, r2, r3, r4);
    }
}


Measured memory_bytes: 67588
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()
#define AB 1
#define BC 3
#define INF 1<<29

using namespace std;

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

int toA (int, int, int );
int toC (int, int, int );

int toA(int A, int B, int C )
{
	if (!B && !C ) return 0;

	if (A & 1 ){
		return toA(A>>1, B>>1, C>>1 );
	} // end if
	if (B & 1 ){
		return toC(A>>1, B>>1, C>>1 ) + 1 + toA(0, 0, (A|B|C)>>1 );
	} // end if
	if (C & 1 ){
		return toA(A>>1,B>>1,C>>1) + 1 + toC((A|B|C)>>1, 0, 0 ) + 1 + toA(0, 0, (A|B|C)>>1 );
	} // end if
}

int toC(int A, int B, int C )
{
	if (!A && !B ) return 0;

	if (C & 1 ){
		return toC(A>>1, B>>1, C>>1 );
	} // end if
	if (B & 1 ){
		return toA(A>>1, B>>1, C>>1 ) + 1 + toC((A|B|C)>>1, 0, 0 );
	} // end if
	if (A & 1 ){
		return toC(A>>1, B>>1, C>>1 ) + 1 + toA(0, 0, (A|B|C)>>1 ) + 1 + toC((A|B|C)>>1, 0, 0 );
	} // end if
}

int main()
{
//	cut here before submit 
//	freopen ("testcase.cup", "r", stdin );

	int n, m;
	while (scanf ("%d %d", &n, &m ), n, m ){
		int T[3] = {0};
		rep (i, 3 ){
			int in;
			scanf ("%d", &in );
			while (in--){
				int cup;
				scanf ("%d", &cup );
				T[i] |= 1<<(cup-1);
			} // end rep
		} // end rep

		int res = min (toA(T[0],T[1],T[2] ), toC(T[0],T[1],T[2] ) );
		cout << (res > m ? -1 : res ) << endl;
	} // end loop
		
	return 0;
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
#define int long long
#define double long double
using namespace std;
const int MOD = 1000000007;
const int INF = 1e12;
using Graph = vector<vector<int>>;

signed main(){
  int N, A, B;
  cin >> N >> A >> B;
  vector<int> C(N);
  for( int i = 0; i < N; i++ ) cin >> C[i];

  if( N == 1 ){
    cout << abs(C[0]-B) << endl;
    return 0;
  }
  cout << max(abs(C[N-1]-B), abs(C[N-2]-C[N-1])) << endl;


}

Measured memory_bytes: 3652
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<numeric>

typedef long long LL;

using namespace std;

LL gcd(LL a, LL b) {
	LL r;
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}
LL lcm(LL a, LL b) {
	return (a / gcd(a, b) * b);
}

int main(void) {
	int n, m;
	cin >> n >> m;
	vector<string>a(n), b(m);
	int k;
	for (int i = 0; i < n; i++)cin >> a[i];
	for (int i = 0; i < m; i++)cin >> b[i];
	for (int i = 0; i <= n - m; i++) {
		for (int j = 0; j <= n - m; j++) {
			for (k = 0; k < m; k++) {
				if (a[i + k].substr(j, m) != b[k]) {
					break;
				}
			}
			if (k == m) {
				cout << "Yes";
				return 0;
			}

		}
	}
	cout << "No";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    int K,X;
    cin >> K >> X;
    int max, min;
    max=K+X-1;
    min=X-K+1;
    int p, i;
    if(max==min){
        cout << X;
    }else{
        for(i=0; i<2*K-1; i++){
            p=min+i;
            cout << p << " ";
        }
    }
    cout << 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 a, b, c, k;
  cin >> a >> b >> c >> k;

  if (k > a + b) {
    cout << a - (k - (a + b)) << endl;
  }
  else if (k > a) {
    cout << a << endl;
  }
  else {
    cout << k << endl;
  }

  return 0;
}

Measured memory_bytes: 3560
N = int(input())

P = []

S = 0

for i in range(N):
   P.append(list(map(int,input().split())))


for i in range(N-1):
   for j in range(N-1-i):
       
       S += (((P[i][0] - P[i+j+1][0])**2 + (P[i][1] - P[i+j+1][1])**2)**0.5)*2
       
print(S/N)  


Measured memory_bytes: 2940
#include <cstdio>
#include <utility>
#include <algorithm>
#include <vector>
#include <queue>
#include <functional>

using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
#define Input(x) scanf("%lld",&x)

const ll INF = 123456789012345678;

ll n, m, c;
ll sum = 0;
vector<pll> edgeset;//first:distance second:edge length

struct edge
{
	ll to, cost;
};
vector<edge>graph[123456];
ll dist[123456];
void dijkstra()
{
	fill(dist,dist + n,INF);
	dist[0] = 0;
	priority_queue<pll, vector<pll>, greater<pll>>que;
	que.push({0,0});
	while (!que.empty())
	{
		pll p = que.top(); que.pop();
		ll fromcos = p.first;
		ll fromvec = p.second;
		if (fromcos > dist[fromvec])continue;
		for (edge ed : graph[fromvec])
		{
			if (dist[ed.to] > fromcos + ed.cost)
			{
				dist[ed.to] = fromcos + ed.cost;
				que.push({ dist[ed.to],ed.to });
			}
		}
	}
}

int main()
{
	Input(n); Input(m); Input(c);
	for (ll i = 0; i < m; ++i)
	{
		ll a, b, d;
		Input(a); Input(b); Input(d);
		--a; --b;
		graph[a].push_back({b,d});
		graph[b].push_back({a,d});
		sum += d;
	}
	dijkstra();
	for (int a = 0; a < n; ++a)
	{
		for (edge e : graph[a])
		{
			if (a < e.to)
			{
				edgeset.push_back({max(dist[a],dist[e.to]),e.cost});
			}
		}
	}
	sort(edgeset.begin(), edgeset.end());
	ll x = 0;
	ll ans = sum;
	for (pll ed : edgeset)
	{
		x = ed.first;
		sum -= ed.second;
		ans = min(ans,c * x + sum);
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 20548
#include<bits/stdc++.h>
using namespace std;
#define ll long long                                    // long long省略
#define pb push_back                                    // push_back省略
#define mp make_pair                                    // make_pair省略
#define fi first                                        // first省略
#define se second                                       // second省略
#define itn int                                         // int誤字保険
#define count cout                                      // cout誤字保険
#define vecotr vector                                   // vector誤字保険
#define ednl endl                                       // endl誤字保険
#define opt() cin.tie(0); ios::sync_with_stdio(false)   // 入出力速度改善

#define rep(i,l,r) for(ll i=(l);i<(r);i++)               // 範囲[l, r)で刻み1のfor文(順方向)
#define repp(i,l,r,k) for(ll i=(l);i<(r);i+=(k))         // 範囲[l, r)で刻みkのfor文(順方向)
#define rrep(i,l,r) for(ll i=(r-1);i>=(l);i--)           // 範囲[l, r)で刻み1のfor文(逆方向)
#define rrepp(i,l,r,k) for(ll i=(r-1);i>=(l);i-=(k))     // 範囲[l, r)で刻みkのfor文(逆方向)
#define all(x) (x).begin(), (x).end()                   // vectorのポインタ位置指定用
#define max(p,q)((p)>(q)?(p):(q))                       // max拡張
#define min(p,q)((p)<(q)?(p):(q))                       // min拡張
#define bit(n,m)(((n)>>(m))&1)                          // 変数nのm番目のbitを取り出す

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int dy[]={0, 1, 0, -1};                                 // 4方向近傍
int dx[]={1, 0, -1, 0};                                 // 4方向近傍

ll gcd(ll a, ll b){
	if(b == 0) return a;
	if(a < b) return gcd(b,a);
	return gcd(b, a%b);
}

int main(){
	ll n,m;cin>>n>>m;
	ll l[m],r[m];rep(i,0,m)cin>>l[i]>>r[i];
	ll lb = 1, ub = n;
	rep(i,0,m){
		lb = max(lb, l[i]);
		ub = min(ub, r[i]);
	}
	cout << (lb<=ub?ub-lb+1:0) << ednl;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		while (true) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			int c = sc.nextInt();
			if (a == -1 && b == -1 && c == -1)
				break;
			judge(a, b, c);
		}
	}

	static void judge(int a, int b, int c){
		int sum = a + b;
		if(a == -1 || b == -1) System.out.println("F");
		else if (sum >= 80) System.out.println("A");
		else if (sum >= 65 && sum < 80) System.out.println("B");
		else if (sum >= 50 && sum < 65) System.out.println("C");
		else if (sum >= 30 && sum < 50) {
			if (c >= 50) System.out.println("C");
			else System.out.println("D");
		} else if (sum < 30) System.out.println("F");
	}
}

Measured memory_bytes: 19240
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, start, end) for(int i = start; i < end; i++)
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << (x) << endl;
typedef long long ll;
const int MAX = 999999999;

int main(){
    int n, m;
    cin >> n >> m;
    cout << pow(2, m) * (n-m) * 100 + pow(2, m) * m * 1900 << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    sort(a, a + 3);
    cout << a[2] - a[0] << endl;
}

Measured memory_bytes: 256
#include<map>
#include<set>
#include<ctime>
#include<cmath>
#include<queue>
#include<bitset>
#include<vector>
#include<cstdio>
#include<cctype>
#include<string>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#define gc getchar()//(p1==p2&&(p2=(p1=buf)+fread(buf,1,size,stdin),p1==p2)?EOF:*p1++)
#define lc (x<<1)
#define rc (x<<1|1)
#define fi first
#define se second
#define mk make_pair
#define pb push_back
#define ll long long
#define pi pair<ll,ll>
using namespace std;
const int N=2e5+10,size=1<<20,mod=1000000007;

//char buf[size],*p1=buf,*p2=buf;
template<class o> void qr(o &x) {
	x=0; int f=1; char c=gc;
	while(!isdigit(c)){if(c=='-')f=-1; c=gc;}
	while(isdigit(c))x=x*10+c-'0',c=gc;
	x*=f;
}
template<class o> void qw(o x) {
	if(x<0) putchar('-'),x=-x;
	if(x>9) qw(x/10);
	putchar(x%10+'0');
}
template<class o> void pr1(o x) {qw(x); putchar(' ');}
template<class o> void pr2(o x) {qw(x); puts("");}

//math
ll gcd(ll x,ll y) {return !x?y:gcd(y%x,x);}
ll lcm(ll x,ll y) {return x/gcd(x,y)*y;}
ll power(ll a,ll b=mod-2) {
	ll c=1;
	while(b) {
		if(b&1) c=c*a%mod;
		b /= 2; a=a*a%mod;
	}
	return c;
}


map<pi,int> s;
int n;
ll ans,a,b,p[N],x,y,z,cnt;

int main() {
	qr(n); p[0]=1; for(int i=1;i<=n;i++) p[i]=p[i-1]*2LL%mod;
	for(int i=1;i<=n;i++) {
		qr(x); qr(y);
		if(!x&&!y) {cnt++; continue;}
		if(!x) a++;
		else if(!y) b++;
		else {
			z=gcd(abs(x),abs(y));
			if((x<0)==(y<0)) x=abs(x)/z,y=abs(y)/z;
			else x=-abs(x)/z,y=abs(y)/z;
			s[mk(x,y)]++;
		}
	}
	ans=(p[a]+p[b]-1)%mod;
	for(auto i:s) {
		pi u=i.fi,t=u;
		swap(t.fi,t.se);
		if(t.se<0) t.se=-t.se;
		else t.fi=-t.fi;
		ll v=i.second;
		if(s.count(t)) {
			if(u.fi<0) ans=ans*(p[v]+p[s[t]]-1)%mod;
		}
		else ans=ans*p[v]%mod;
	}
	pr2((ans-1+mod+cnt)%mod);
	return 0;
}



Measured memory_bytes: 17508
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <string>
 
int main()
{
    int n, flag = 0;
    char s[101];

    std::cin >> n;
    for(int i = 0;i < n;i++){
        std::cin >> s[i];
        if(s[i] == 'Y'){
            flag = 1;
        }
    }

    if(flag == 1){
        std::cout << "Four";

        return 0;
    }

    std::cout << "Three";

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli long long int
#define ulli unsigned long long int
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define pf pop_front()
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define loopl(i,a,b) for(lli i=a;i<b;i++) 
#define loop(i,a,b) for(int i=a;i<b;i++)
#define mod 1000000007
#define inf 1000000000000000
#define lld long double
#define pll pair<long long int,long long int>
#define vll vector<lli>
#define stp setprecision(15)
#define eps 0.000001
#define endl '\n'
#define ll lli
 
using namespace std ;
 
typedef tree<pll,null_type,less<pll>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
#define N 2000000

int main() 
{ 

/////////////////////////////////////
    
    fastio;
 
/////////////////////////////////////    

    lli a;
    string s;
    cin>>a>>s;

    if(a<3200) cout<<"red"<<endl;
    else cout<<s<<endl;

} 

Measured memory_bytes: 256
import java.util.*;

public class Main {
    private static final Scanner scn = new Scanner(System.in);
    private static final String[] TERMS = new String[] {
      "the", "this", "that"
    };
    
    public static void main(String[] args) {
        while(scn.hasNextLine()) {
            String str = scn.nextLine();
            while(judge(str)) {
                str = slide(str);
            }
            System.out.println(str);
        }
    }
    
    public static boolean judge(String str) {
        boolean rslt = true;
        for(String term : TERMS) {
            if(str.indexOf(term) >= 0) {
                rslt = false;
                break;
            }
        }
        return rslt;
    }
    
    public static String slide(String str) {
        StringBuilder sb = new StringBuilder();
        for(char elm : str.toCharArray()) {
            if(Character.isAlphabetic(elm)) {
                sb.append((char)((elm - 'a' + 1) % 26 + 'a'));
            } else {
                sb.append(elm);
            }
        }
        return sb.toString();
    }
}

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

#define trace(...) __f( #__VA_ARGS__ , __VA_ARGS__ )
template <typename Arg1>
void __f( const char* name , Arg1&& arg1 ) {
        cerr << name << " : " << arg1 << "\n";
}
template <typename Arg1, typename... Args>
void __f( const char* na , Arg1&& arg1 , Args&&... args ) {
        const char* c = strchr( na + 1 , ',' );
        cerr.write( na , c - na ) << " : " << arg1 << " , ";
        __f( c + 1 , args... );
}
#define endl "\n"
#define all(V) V.begin(),V.end()
#define Unique(V) sort(all(V)),V.erase(unique(all(V)),V.end())
#define IO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long int LL;
typedef pair <int,int> pii;
const int MOD = 1e9 + 7;
const int inf = 1e9;
const double EPS = 1e-9;
const double PI = acos(-1.0);
const long long INF = 1e18;
const int N = 2e5 + 5;

int n , q;
vector <int> graph[ N ];
int Time , st[ N ] , en[ N ];

void flat_it( int s , int p ) {
        st[s] = ++Time;
        for( auto x : graph[s] ) {
                if( x != p ) flat_it( x , s );
        }
        en[s] = Time;
}
struct binary_indexed_tree {
        static const int N = 2e5 + 5;
        int BIT[ N + 5 ];
        void init( ) { memset( BIT , 0 , sizeof(BIT) ); }
        int r_query ( int l , int r ) {
                return p_query( r ) - p_query( l - 1 );
        }
        void p_update ( int idx , int v ) {
                if( idx <= 0 ) return;
                for(;idx <= N; idx += ( idx & -idx )) BIT[idx] += v;
        }
        int p_query ( int idx ) {
                int ret = 0;
                for(;idx > 0; idx -= ( idx & -idx )) ret += BIT[idx];
                return ret;
        }
        void r_update ( int idx , int idy , int v ) {
                for(;idx <= N; idx += ( idx & -idx )) BIT[idx] += v;
                idy++ , v *= -1;
                for(;idy <= N; idy += ( idy & -idy )) BIT[idy] += v;
        }
} bit;

int main( ) {
        IO;
        #ifdef LOCAL
            //freopen( "input.txt" , "r" , stdin );
        #endif // LOCAL
        cin >> n >> q;
        for( int i = 1; i <= n - 1; i++ ) {
                int u , v;
                cin >> u >> v;
                graph[u].push_back( v );
                graph[v].push_back( u );
        }
        Time = 0 , flat_it( 1 , 0 );
        while( q-- ) {
                int node , val;
                cin >> node >> val;
                bit.r_update( st[node] , en[node] , val );
        }
        for( int i = 1; i <= n; i++ ) cout << bit.p_query(st[i]) << " ";
        return 0;
}










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

int main(){
  int64_t N, M;
  cin >> N >> M;
  vector<int64_t> vec(M+2);
  for(int i=0; i<M; i++){
    cin >> vec.at(i);
  }
  vector<int64_t> ans(N+2);
  int n_exist = 0;
  ans.at(0) = 1;
  ans.at(1) = 2;
  
  if(vec.at(0) == 1){
    ans.at(0) = 0;
    ans.at(1) = 1;
    n_exist++;  
  }
  if(vec.at(0) == 2){
     ans.at(1) = 0;
     n_exist++;
  }
  if(vec.at(1) == 2){
     ans.at(1) = 0;
     n_exist++;
  }
  
  for(int j=2; j<N; j++){
    if(n_exist < vec.size() && vec.at(n_exist)-1 == j){
      n_exist++;
      continue;
    }
    else{
      ans.at(j) = ans.at(j-1) +ans.at(j-2);
      ans.at(j) = ans.at(j) %1000000007;
    }
  }
  cout << ans.at(N-1) << endl;
}

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

int a, b;

int main(){
	cin >> a >> b;
	if (a + b == 15) {
		cout << '+' << endl;
		return 0;
	}
	else if (a*b == 15) {
		cout << '*' << endl;
		return 0;
	}
	else {
		cout << 'x' << endl;
		return 0;
	}
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class Z { static void Main() => new K(); }
class K
{
	int F => int.Parse(Str);
	long FL => long.Parse(Str);
	int[] G => Strs.Select(int.Parse).ToArray();
	long[] GL => Strs.Select(long.Parse).ToArray();
	string Str => ReadLine();
	string[] Strs => Str.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
	const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var I = G;
		int N = I[0], H = I[1];
		int A = -1;
		var b = new int[N];
		for (var i = 0; i < N; i++)
		{
			I = G;
			A = Max(A, I[0]);
			b[i] = I[1];
		}
		var B = b.Where(x => x > A).ToList();
		B.Sort((x, y) => y.CompareTo(x));
		var c = 0;
		foreach (var x in B)
		{
			if (H <= 0) break;
			H -= x;
			c++;
		}
		if (H > 0) c += (H + A - 1) / A;
		WriteLine(c);
	}
}


Measured memory_bytes: 18744
"""
Binary indexed tree
0-indexed, 関数は閉区間
0からの区間加算、1点更新
"""
class BIT: #0-indexed
    def __init__(self, n):
        self.size = n
        self.tree = [0]*(n+1)
        self.depth = n.bit_length()
        self.n0 = 1<<self.depth
#        self.element = [0]*(n+1)
    def get_sum(self, i): #a_0 + ... + a_{i} #閉区間
        s = 0; i += 1
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s
    def query(self,l,r): #a_l + ... + a_r 閉区間
        return self.get_sum(r) - self.get_sum(l-1) 
    def add(self, i, x):
        i += 1
        while i <= self.size:
            self.tree[i] += x
            i += i & -i
        # self.element[i] += x
    #def get(self,i): return element[i]        
    def bisect_left(self,w):
        #和が w 以上になる最小の index
        #w が存在しない場合 self.size を返す
        if w <= 0: return 0
        x,k = 0,self.n0
        for _ in range(self.depth):
            k >>= 1
            if x+k <= self.size and self.tree[x+k] < w:
                w -= self.tree[x+k]
                x += k
        return x

# coding: utf-8
# Your code here!
import sys
readline = sys.stdin.readline
read = sys.stdin.read

n,Q = [int(i) for i in readline().split()]
a = [int(i) for i in readline().split()]
q = [[int(i) for i in readline().split()]+[j] for j in range(Q)]


q.sort(key = lambda x: x[1])
last = [-1]*(n+1)
ans = [0]*Q
idx = 0
B = BIT(n+1)
for i in range(n):
    c = a[i]
    if last[c] != -1:
        B.add(last[c],-1)
    last[c] = i
    B.add(i,1)

    while idx < Q and q[idx][1] <= i+1:
        ans[q[idx][2]] = B.query(q[idx][0]-1,q[idx][1]-1)
        idx += 1
    
print(*ans,sep="\n")




Measured memory_bytes: 190000
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class F
{
	public static void Main() => (new Solver()).Solve();
}

public class Solver
{
	public void Solve()
	{
		int N = GetInt();
		var S = GetInts(1 << N);

		Array.Sort(S, (x, y) => y - x);
		var used = S.Take(1).ToList();
		var rest = S.Skip(1).ToList();

		for(int i = 0; i < N; i++)
		{
			rest.Sort((x, y) => y - x);
			used.Sort((x, y) => y - x);

			var nextRest = new List<int>();
			int head = 0;
			int cntRest = rest.Count;
			for(int j = 0; j < (1 << i); j++)
			{
				while(head < cntRest && rest[head] >= used[j])
					nextRest.Add(rest[head++]);

				if(head == cntRest)
				{
					WriteLine("No");
					return;
				}
				used.Add(rest[head++]);
			}
			nextRest.AddRange(rest.Skip(head));
			rest = nextRest;
		}
		WriteLine("Yes");
	}
}

public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static decimal GetDecimal() => decimal.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(long N) => Enumerable.Range(0, (int)N).Select(_ => GetInt()).ToArray();
	public static long[] GetLongs(long N) => Enumerable.Range(0, (int)N).Select(_ => GetLong()).ToArray();
	public static double[] GetDoubles(long N) => Enumerable.Range(0, (int)N).Select(_ => GetDouble()).ToArray();
	public static decimal[] GetDecimals(long N) => Enumerable.Range(0, (int)N).Select(_ => GetDecimal()).ToArray();
	public static string[] GetStrings(long N) => Enumerable.Range(0, (int)N).Select(_ => GetString()).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) < 0)
			x = y;
	}

	public static void chmin<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) > 0)
			x = y;
	}

	public static void swap<T>(ref T x, ref T y)
	{
		T tmp = x;
		x = y;
		y = tmp;
	}
}

Measured memory_bytes: 51100
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cmath>

using namespace std;

int main() {
    int n;
    cin >> n;
    for (int i = 1; i < 10; i++) {
        for (int j = 1; j < 10; j++) {
            if (i*j == n) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 256