akhauriyash/Code-Regression huggingface dataset:
N = int(input())
B = list(map(int,input().split()))
cnt=0
cnt+=B[0]
for i in range(len(B)-1):
    if B[i]<= B[i+1]:
        cnt+=B[i]
    elif B[i]> B[i+1]:
        cnt+=B[i+1]
cnt += B[-1]
print(cnt)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long
#define all(v) v.begin(),v.end()
#define PI 3.1415926535897932384626433832795
#define what(x) cout<<#x<<" is "<<x<<endl;
using namespace std;


template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}

template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

// ll powmod(ll a,ll b,ll mod) {
//     ll res=1;a%=mod;
//     //assert(b>=0);
//     for(;b;b>>=1){
//         if(b&1)res=res*a%mod;a=a*a%mod;
//     }
//     return res;
// }

void solve(){
  int n;
  cin>>n;
  map<string,int> mp;
  for(int i=0;i<n;i++){
    string t;
    cin>>t;
    mp[t]++;
  }
  cout<<"AC x "<<mp["AC"]<<endl;
  cout<<"WA x "<<mp["WA"]<<endl;
  cout<<"TLE x "<<mp["TLE"]<<endl;
  cout<<"RE x "<<mp["RE"]<<endl;
}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    #endif
    int tc=1;
    // cin>>tc;
    while(tc--)solve();
}


Measured memory_bytes: 3668
#include <iostream>
#include <array>
#include <vector>

using namespace std;

template<int mod>
struct Ring_mod {
    int val;
    Ring_mod(): val(0) {}
    Ring_mod(int x)
    {
        if (x < 0) x += mod;
        if (x >= mod) x -= mod;
        val = x;
    }
    explicit operator int() { return val; }
    Ring_mod operator+(const Ring_mod& b) { return Ring_mod(val + b.val); }
    Ring_mod operator-(const Ring_mod& b) { return Ring_mod(val - b.val); }
    void operator+=(const Ring_mod& b) { val = Ring_mod(val + b.val).val; }
    void operator-=(const Ring_mod& b) { val = Ring_mod(val - b.val).val; }
};
typedef Ring_mod<(int) 1e9 + 7> int_mod;

int main()
{
    int n;
    cin >> n;
    vector<vector<char> > compat(n, vector<char>(n));
    for (auto& r : compat)
        for (auto& c : r)
            cin >> c;

    vector<int_mod> dp(1 << n);
    dp[0] = 1;
    for (int mask = 1; mask < 1 << n; ++mask) {
        int i = __builtin_popcount(mask) - 1;
        for (int j = 0; j < n; ++j)
            if (((mask >> j) & 1) && compat[i][j] == '1')
                dp[mask] += dp[mask ^ (1 << j)];
    }
    cout << (int) dp[(1 << n) - 1];
    return 0;
}


Measured memory_bytes: 8448
H,W=map(int, input().split())
a=[[int(x) for x in input().split()] for _ in range(H)]

show=False
prev=(-1,-1)
ans=[]

for h in range(H):
	for w in range(W) if h % 2 else range(W-1, -1, -1):
		if show:
			ph,pw=prev
			ans.append((ph+1, pw+1, h+1, w+1))
		if a[h][w] % 2 == 1:
			show = not show
		prev=(h,w)

print(len(ans))
for a,b,c,d in ans:
	print(a,b,c,d)


Measured memory_bytes: 26136
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  int a = 0, b = 0, c = 0, d = 0;
  
  cin >> N;
  a = N / 1000;
  b = N / 100 - a * 10;
  c = N / 10 - a * 100 - b * 10;
  d = N % 10;
  if ((a == b)&&(b == c) || (b == c)&&(c == d)) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
    

}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
int n,m;
ll a[8]={1,1,1,1,-1,-1,-1,-1},b[8]={1,-1,1,-1,1,-1,1,-1},c[8]={1,1,-1,-1,1,1,-1,-1};
ll ans,x[1005],y[1005],z[1005];
ll s[1005];
int main(void){
    cin>>n>>m;
    for(int i=0;i<n;i++){
        cin>>x[i]>>y[i]>>z[i];
    }
    for(int i=0;i<8;i++){
        for(int j=0;j<n;j++){
            s[j]=a[i]*z[j]+b[i]*y[j]+c[i]*x[j];
        }
        sort(s,s+n,greater<ll>());
    ll r=0;
    for(int i=0;i<m;i++)r+=s[i];
    ans=max(ans,r);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main(void)
{
  int n,y;
 
  cin>>n>>y;
 
  for(int i=0;i<=n;i++)
  {
    for(int j=0;j<=n-i;j++)
    {
      for(int k=0;k<=n-i-j;k++)
      {
        if((y - i*10000 - j*5000 - k*1000) == 0)
        {
          if(n == i+j+k)
          {
            cout<<i <<" "<< j <<" "<< k<<endl;
            return 0;
          }
        }
      }
    }
  }
 
  cout<<"-1 -1 -1"<<endl;
  return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define cs const 
#define int long long
#define low(i) (i&(-i))
#define mid ((l+r)>>1)
#define ls (now<<1)
#define rs (now<<1|1)
#define par pair<int,int>
#define mp make_pair
#define fr first 
#define se second
#define rep(i, x, y) for(int i=x; i<=y; ++i)
#define drep(i, x, y) for(int i=x; i>=y; --i)
#define fore(i, x) for(int i=fir[x]; i; i=nex[i])
cs int base = 233;
cs int ff = 3e6+1;
cs int mod = 998244353;
cs int inf = 1e9+1;
int n, m; 
char s[ff];
void init()
{
	cin >> s+1; int len = strlen(s+1);
	int tag = 1;
	int head = 1, tail = (len-1) / 2;
	while(head <= tail)
	{
		if( s[head] != s[tail] ) tag = 0;
		head++; tail--;
	}
	tail = len, head = (len+3) / 2;
	while(head <= tail)
	{
		if( s[head] != s[tail] ) tag = 0;
		head++; tail--;
	}
	tail = len, head = 1;
	while(head <= tail)
	{
		if( s[head] != s[tail] ) tag = 0;
		head++; tail--;
	}
	puts( tag ? "Yes" : "No" );
}
signed main()
{
	int T = 1;
	while(T--) 
		init();
} 


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define flash ios_base::sync_with_stdio(false);     cin.tie(NULL);
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define all(v) v.begin(),v.end()
#define f first
#define s second



using namespace std;




// int count1[1000000];

// adjacency list representation of tree
vector<int> adj[1000000];

// function to calculate no. of nodes in subtree
// void numberOfNodes(int s, int e)
// {
//   vector<int>::iterator u;
//   count1[s] = 1;
//   for (u = adj[s].begin(); u != adj[s].end(); u++) {
//
//       // condition to omit reverse path
//       // path from children to parent
//       if (*u == e)
//           continue;
//
//       // recursive call for DFS
//       numberOfNodes(*u, s);
//
//       // update count[] value of parent using
//       // its children
//       count1[s] += count1[*u];
//   }
// }
//
//
// void printNumberOfNodes(int n)
// {
//   for (int i = 1; i < n; i++) {
//       cout << "\nNodes in subtree of " << i;
//       cout << ": " << count1[i];
//   }
// }


int main()
{
  flash
  ll n;
  cin>>n;
  std::vector<int> v(n-1);
  for(int i=0;i<n-1;i++){
    cin>>v[i];
    //adj[i].push_back(v[i]);
    adj[v[i]].push_back(i+2);

  }

    // numberOfNodes(1, 0);
    //
    //   printNumberOfNodes(n);
  for(int i=1;i<=n;i++){
    cout<<adj[i].size()<<"\n";
  }

}


Measured memory_bytes: 33736
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations
    #from itertools import accumulate, product
    from bisect import bisect_left,bisect_right
    from math import floor, ceil
    #from operator import itemgetter

    #mod = 1000000007

    n,m = map(int, input().split())
    x,y = [], []
    for _ in range(m):
        a,b = map(int, input().split())
        if a==1:
            x.append(b)
        if b==n:
            y.append(a)
    if not len(x)+len(y)==len(set(x+y)):
            print('POSSIBLE')
            exit()
    print('IMPOSSIBLE')


if __name__ == '__main__':
    main()

Measured memory_bytes: 69852
#include <stdio.h>
int main(){

    int a,b,c;

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

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

struct card {
    char mark;
    int num;
    int order;
};

int partition(vector<card> &A, int p, int r) {
    int x = A.at(r).num;
    int i = p - 1;
    for (int j = p; j < r; ++j) {
        if (A.at(j).num <= x) {
            ++i;
            swap(A.at(i), A.at(j));
        }
    }
    swap(A.at(i + 1), A.at(r));
    return i + 1;
}

void quickSort(vector<card> &A, int p, int r) {
    if (p < r) {
        int q = partition(A, p, r);
        quickSort(A, p, q - 1);
        quickSort(A, q + 1, r);
    }
    return;
}

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

    int n;
    cin >> n;
    vector<card> A(n);
    for (int i = 0; i < n; ++i) {
        char a;
        int b;
        cin >> a >> b;
        A.at(i) = card{a, b, i};
    }
    quickSort(A, 0, n - 1);
    bool stable = true;
    for (int i = 1; i < n; ++i) {
        if (A.at(i).num == A.at(i - 1).num && A.at(i).order < A.at(i - 1).order) {
            stable = false;
            break;
        }
    }
    cout << ((stable) ? "Stable" : "Not stable") << endl;
    for (int i = 0; i < n; ++i) {
        cout << A.at(i).mark << ' ' << A.at(i).num << endl;
    }

    return 0;
}


Measured memory_bytes: 4108
import java.util.Arrays;
import java.util.Scanner;
import java.util.regex.Pattern;


public class Main {

	public static void main(String[] args) {

		String regex = ".*1(0+)$";
		Pattern p = Pattern.compile(regex);

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		String[] b = new String[n];
		String[] nb = new String[n];

		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}

		for (int i = 0; i < a.length; i++) {
			b[i] = Integer.toBinaryString(a[i]);
			if ("1".equals(b[i].substring(b[i].length()-2, b[i].length()-1))) {
				System.out.println("0");
				return;
			}
			nb[i] = p.matcher(b[i]).replaceAll("$1");
		}

		Arrays.sort(nb);

		System.out.println(nb[0].length());
	}

}

Measured memory_bytes: 23764
using System;

namespace rensyuu1
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                string[] str = Console.ReadLine().Trim().Split(' ');
                int m = int.Parse(str[0]);
                int f = int.Parse(str[1]);
                int r = int.Parse(str[2]);
                if (m == -1 && f == -1)
                {
                    break;
                }
                else
                {
                    if (m == -1 || f == -1)
                    {
                        Console.WriteLine("F");
                    }
                    else
                    {
                        if (m + f >= 80)
                        {
                            Console.WriteLine("A");
                        }
                        else if (80 > m + f && m + f >= 65)
                        {
                            Console.WriteLine("B");
                        }
                        else if (65 > m + f && m + f >= 50)
                        {
                            Console.WriteLine("C");
                        }
                        else if (50 > m + f && m + f >= 30)
                        {
                            if (r >= 50)
                            {
                                Console.WriteLine("C");
                            }
                            else
                            {
                                Console.WriteLine("D");
                            }
                        }
                        else if (30 > m + f)
                        {
                            Console.WriteLine("F");
                        }
                    }
                }
            }
        }
    }
}


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

int main() {
  int N;
  cin >> N;
  vector<int> H(N);
  for (int i = 0; i < N; i++) cin >> H[i];
  vector<int> move;
  int tmp = 0;
  for (int i = 0; i < N-1; i++) {
    if (H[i] < H[i+1]) {
      move.push_back(tmp);
      tmp = 0;
    }
    else tmp++;
  }
  move.push_back(tmp);
  sort(move.begin(), move.end());
  reverse(move.begin(), move.end());
  cout << move[0] << endl;
}


Measured memory_bytes: 1276
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

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

#define GET_MACRO(_1,_2,_3,_4,NAME,...) NAME
#define REP2(i,n) for(int i=0;i<(int)(n);i++)
#define REP3(i,m,n) for(int i=m;i<(int)(n);i++)
#define REP4(i,m,n,s) for(int i=m;(s>0 and i<(int)(n)) or (s<0 and i>(int)(n));i+=s)
#define REP(...) GET_MACRO(__VA_ARGS__, REP4, REP3, REP2)(__VA_ARGS__)
#define REPIT(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define PIS(x) printf("%d ",x)
#define PN() putchar('\n')
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define MT make_tuple

using PII = pair<int, int>;
using TI3 = tuple<int, int, int>;
using LL = long long;
using ULL =  unsigned long long;
using MAT = array<array<LL, 2>, 2>;

template<class T> void _read( T &x ) { cin>>x; }
void _read(int &x) { scanf("%d", &x); }
void _read(LL &x) { scanf("%lld", &x); }
void _read(ULL &x) { scanf("%llu", &x); }
void _read(double &x) { scanf("%lf", &x); }
void _read(char &x) { scanf(" %c", &x); }
void _read(char *x) { scanf("%s", x); }
void read() {}
template<class T, class... U>
void read( T& head, U&... tail ) {
    _read(head);
    read(tail...);
}

template<class T> void _print( const T &x ) { cout << x; }
void _print( const int &x ) { printf("%d", x); }
void _print( const LL &x ) { printf("%lld", x); }
void _print( const double &x ) { printf("%.16lf",x); }
void _print( const char &x ) { putchar(x); }
void _print( const char *x ) { printf("%s",x); }
template<class T> void _print( const vector<T> &x ) { for (auto i = x.begin(); i != x.end(); _print(*i++)) if (i != x.cbegin()) putchar(' '); }
void print() {}
template<class T, class... U> void print( const T& head, const U&... tail ) {
    _print(head);
    putchar(sizeof...(tail) ? ' ' : '\n');
    print(tail...);
}

#define LLINF 0x3f3f3f3f3f3f3f3f
#define INF 0x3f3f3f3f

const int MOD = 1000000007;
#define MAX_N 300005

int main()
{
    char _s[100];
    read(_s);
    if(strcmp(_s, "zyxwvutsrqponmlkjihgfedcba") == 0) {
        print("-1");
        return 0;
    }
    string s(_s);
    int n = s.size();
    vector<int> a(26, 0);
    REP(i, n) {
        a[(int)s[i] - 'a'] = 1;
    }
    int m = -1;
    REP(i, 26) {
        if(a[i] == 0) {
            m = i;
            break;
        }
    }
    if(m >= 0) {
        printf("%s%c\n", _s, 'a' + m);
        return 0;
    }
    next_permutation(s.begin(), s.end());
    REP(i, n) {
        putchar(s[i]);
        if(s[i] != _s[i]) {
            break;
        }
    }
    PN();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;

ll d1[111111],d2[111111];
vector<PP> v[111111];
void Main() {
  ll n,m,s,t,w=1000000000000000LL;
  cin >> n >> m >> s >> t;
  s--,t--;
  fill(d1,d1+n,MAXL);
  fill(d2,d2+n,MAXL);
  rep(i,m) {
    ll x,y,z1,z2;
    cin >> x >> y >> z1 >> z2;
    x--,y--;
    v[x].pb(PP(y,P(z1,z2)));
    v[y].pb(PP(x,P(z1,z2)));
  }
  priority_queue<P,vector<P>,greater<P> > que;
  que.push(P(0,s));
  d1[s]=0;
  while(!que.empty()) {
    P p=que.top();que.pop();
    ll x=p.S,c=p.F;
    if(d1[x]<c) continue;
    rep(i,v[x].size()) {
      PP q=v[x][i];
      ll y=q.F,z1=q.S.F,z2=q.S.S;
      if(d1[y]>d1[x]+z1) {
        d1[y]=d1[x]+z1;
        que.push(P(d1[y],y));
      }
    }
  }
  que.push(P(0,t));
  d2[t]=0;
  while(!que.empty()) {
    P p=que.top();que.pop();
    ll x=p.S,c=p.F;
    if(d2[x]<c) continue;
    rep(i,v[x].size()) {
      PP q=v[x][i];
      ll y=q.F,z1=q.S.F,z2=q.S.S;
      if(d2[y]>d2[x]+z2) {
        d2[y]=d2[x]+z2;
        que.push(P(d2[y],y));
      }
    }
  }
  vector<ll> ans(n);
  ans[n-1]=w-(d1[n-1]+d2[n-1]);
  rrep(i,n-1) ans[i]=max(ans[i+1],w-(d1[i]+d2[i]));
  rep(i,n) pr(ans[i]);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 14072
N = gets.to_i
H = gets.split.map(&:to_i)

0.upto(N - 2) do |idx|
  if H[idx] < H[idx + 1]
    H[idx + 1] -= 1
  elsif H[idx] > H[idx + 1]
    puts 'No'
    exit
  end
end

puts 'Yes'


Measured memory_bytes: 8580
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)

using namespace std;
using ll = long long;
using P = pair<int,int>;
using ull= unsigned long long;
const ll K_MAX=1e5+5;

int main(){
  double l;
  cin >>l;
  
 // cout<<pow(l/3,3)<<endl;
  printf("%.20f",pow(l/3,3));
  
  
}

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


// セグメントツリー
template<class Monoid> struct SegTree {
    using Func = function<Monoid(Monoid, Monoid)>;
    const Func F;
    const Monoid UNITY;
    int SIZE_R;
    vector<Monoid> dat;
    
    SegTree(int n, const Func f, const Monoid &unity): F(f), UNITY(unity) { init(n); }
    void init(int n) {
        SIZE_R = 1;
        while (SIZE_R < n) SIZE_R *= 2;
        dat.assign(SIZE_R * 2, UNITY);
    }
    
    /* set, a is 0-indexed */
    void set(int a, const Monoid &v) { dat[a + SIZE_R] = v; }
    void build() {
        for (int k = SIZE_R - 1; k > 0; --k)
            dat[k] = F(dat[k*2], dat[k*2+1]);
    }
    
    /* update a, a is 0-indexed */
    void update(int a, const Monoid &v) {
        int k = a + SIZE_R;
        dat[k] = v;
        while (k >>= 1) dat[k] = F(dat[k*2], dat[k*2+1]);
    }
    
    /* get [a, b), a and b are 0-indexed */
    Monoid get(int a, int b) {
        Monoid vleft = UNITY, vright = UNITY;
        for (int left = a + SIZE_R, right = b + SIZE_R; left < right; left >>= 1, right >>= 1) {
            if (left & 1) vleft = F(vleft, dat[left++]);
            if (right & 1) vright = F(dat[--right], vright);
        }                                                                                                              
        return F(vleft, vright);
    }
    inline Monoid operator [] (int a) { return dat[a + SIZE_R]; }
    
    /* debug */
    void print() {
        for (int i = 0; i < SIZE_R; ++i) {
            cout << (*this)[i];
            if (i != SIZE_R-1) cout << ",";
        }
        cout << endl;
    }
};


long long GCD(long long a, long long b) {
    return b ? GCD(b, a%b) : a;
}


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

    // セグツリーの構築
    SegTree<long long> seg(N, [](long long a, long long b) {
            return GCD(a, b);
        },
        0);
    vector<long long> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
        seg.set(i, A[i]);
    }
    seg.build();

    // 求める
    long long res = 0;
    for (int i = 0; i < N; ++i) {
        long long left = seg.get(0, i);
        long long right = seg.get(i+1, N);
        res = max(res, GCD(left, right));
    }
    cout << res << endl;
}

Measured memory_bytes: 3072
#include <bits/stdc++.h>
typedef long long lint;
using namespace std;

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

string s;

int main() {
    cin >> s;
    s = '0' + s;
    lint n = s.length();
    // dp[0][i]:[0,i)までの会計の仕方で、次に繰り下がれないような方法での最小
    // dp[1][i]:[0,i)までの会計の仕方で、次に繰り下がれるような方法での最小
    vector<vector<int>> dp(2, vector<int>(n + 1, INT_MAX / 2));
    dp[0][0] = 0;
    for (int i = 0; i < n; i++) {
        int k = s[i] - '0';
        chmin(dp[0][i + 1], dp[0][i] + k);
        if (k != 9) chmin(dp[1][i + 1], dp[0][i] + k + 1);
        chmin(dp[0][i + 1], dp[1][i] + 10 - k);
        chmin(dp[1][i + 1], dp[1][i] + 9 - k);
    }
    cout << dp[0][n] << endl;
}

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

int main(){
	string a,b;
	cin >> a >> b;
	sort(a.begin(),a.end());
	sort(b.begin(),b.end(),greater<char>());
	if(a < b) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
typedef pair<ll, int> p;
 
int main() {
	cin.tie(0);
    ios::sync_with_stdio(false);

    int N;
    ll k;
    cin >> N >> k;

    vector<ll> A(N);

    vector<int> T;
    vector<int> D;
    vector<ll> H;

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

    ll t = A[0];
    ll d = A[0];
    
    int tc = 1;
    int dc = 1;
    int dk = 0;

    for(int i = 1; i < N; i++) {
        if(A[i] > t) {
            t = A[i];
            tc = 1;
            dc += dk;
            dk = 0;
            //cerr << "a" << i << endl;
        } else if(A[i] == t) {
            tc++;
            dc += dk;
            dk = 0;
            //cerr << "b" << i << endl;
        }
        
        if(A[i] < d) {
            T.push_back(tc);
            D.push_back(dc);
            H.push_back(t - d);
            t = A[i];
            d = A[i];
            tc = 1;
            dc = 1;
            //cerr << "c" << i << endl;
        } else if(A[i] == d) {
            dk++;
            //cerr << "d" << i << endl;
        }
    }

    T.push_back(tc);
    D.push_back(dc);
    H.push_back(t - d);
/*
    for(int i = 0; i < T.size(); i++) {
        cerr << T[i] << " " << D[i] << " " << H[i] << endl;
    }*/

    ll x = *max_element(H.begin(), H.end());

    int ans = 0;

    for(int i = 0; i < T.size(); i++) {
        if(H[i] != x) continue;
        ans += min(T[i], D[i]);
    }

    cout << ans << endl;
}

Measured memory_bytes: 2040
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define tll tuple<ll, ll, ll>
#define all(c) c.begin(),c.end()

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
 
const ll inf = 1000000001;
const ll INF = 1e18;
const ll MOD = 1000000007;

char albt[26] = {'a','b','c','d','e','f','g','h','i','j','k','l',
                 'm','n','o','p','q','r','s','t','u','v','w','x',
                 'y','z'};

//vector<ll> g[202020];
//fill(score, score+202020, 0);
//vector<ll> v;

int main(){
  ll n;
  cin >> n;
  
  if (n%2 == 0) cout << 0.5 << endl;
  else{
    ll n2 = n/2 + 1;
    double n3 = n2;
    cout << fixed;
    cout << setprecision(8) << n3/n << endl;
    //cout << n2/n << endl;
  }
    
  
  
  //cout << happy << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int N,M,X,Y;
	cin>>N>>M>>X>>Y;
	int x[N];
	for(int i=0;i<N;i++){
		cin>>x[i];
	}
	int y[M];
	for(int i=0;i<M;i++){
		cin>>y[i];
	}
	int cnt1=0,cnt2=0;
	for(int i=X+1;i<=Y;i++){
		cnt1=0;
		for(int j=0;j<N;j++){
			if(i>x[j]){
				cnt1++;
			}
		}
		if(cnt1==N){
			cnt2=0;
			for(int j=0;j<M;j++){
				if(i<=y[j]){
					cnt2++;
				}
			}
			if(cnt2==M){
				cout<<"No War";
				return 0;
			}
		}
	}
	cout<<"War";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 9999999999;
const int INFI=2147483647;
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
  T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }


int main() {
  int i = 0;
  int x; cin >>x;
  while (x > 0){
    i++;
    cout <<"Case " <<i <<": " <<x <<endl;
    cin >>x;
  }
}



Measured memory_bytes: 3112
#include <bits/stdc++.h>
#define FOR(i, l, r) for(ll i = l; i < r; i++)
#define rep(i, N) FOR(i, 0, N)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;

int main() {
    int T; cin >> T;
    queue<ll> ans;
    while(T--) {
        int N; cin >> N;
        vector<P> lKD, rKD;
        ll mx = 0;  
        int K,L,R;
        rep(i,N) {
            cin >> K >> L >> R;

            //Lの方が高いラクダとRの方が高いラクダに分ける
            if(L-R >= 0) lKD.emplace_back(P(K, L-R));
            else rKD.emplace_back(P(N-K, R-L));
            mx += max(L,R);
        }
        //K（左端，右端からK番目以内に置きたい），LとRの差（希望通りでないときの減少量の小さい順）でソート
        sort(lKD.begin(), lKD.end());
        sort(rKD.begin(), rKD.end());

        //すでに並んでいるラクダの集合(LとRの差の小さい順)
        priority_queue<int, vector<int>, greater<int>> llaw;
        priority_queue<int, vector<int>, greater<int>> rlaw;
        int lidx = 0, ridx = 0;
        //左に並べたいラクダを順に並べていく
        rep(j,lKD.size()) {
            while(lidx < lKD.size() && j+1 == lKD[lidx].first) {
                llaw.push(lKD[lidx].second);
                lidx++;
            }
            //並んでいるラクダの内，LとRの差が小さいラクダを追い出す
            while(llaw.size() > j+1) {
                mx -= llaw.top();
                llaw.pop();
            }
        }
        //右に並べたいラクダを順に並べていく
        //N=Kのとき，右には並べられないことに注意
        rep(j,rKD.size()+1) {
            while(ridx < rKD.size() && j == rKD[ridx].first) {
                rlaw.push(rKD[ridx].second);
                ridx++;
            }
            while(rlaw.size() > j) {
                mx -= rlaw.top();
                rlaw.pop();
            }
        }
        ans.push(mx);
    }

    while(!ans.empty()) {
        cout << ans.front() << "\n";
        ans.pop();
    }
    return 0;
}


Measured memory_bytes: 5644
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
using namespace std;


int main()
{
	string str;
	getline(cin, str);
	istringstream iss(str);
	iss >> str;
	long A = stoi(str);
	iss >> str;
	long B = stoi(str);
	iss >> str;
	int K = stoi(str);

	for (int i = 0; i < K; i++) {
		if (i % 2 == 0) {
			if (A % 2 == 1) A = A - 1;
			A = A / 2;
			B = A + B;
		}
		else {
			if (B % 2 == 1) B = B - 1;
			B = B / 2;
			A = A + B;
		}
	}
	cout << A << " " << B << endl;


	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(){
    int n, t, ans=0;
    cin >> n >> t;
    vector<int>a(n);
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    for(int i=0; i<n-1; i++){
        if(a[i]+t>a[i+1]){
            ans += a[i+1]-a[i];
        }else{
            ans += t;
        }
    }
    cout << ans+t << endl;
    return 0;
}

Measured memory_bytes: 4032
#include <iostream>
#include <set>

using namespace std;

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

    set<char> s;
    for(int i = 0; i < N; ++i)
    {
        char si;
        cin >> si;
        s.insert(si);
    }

    cout << (3 == s.size() ? "Three" : "Four") << endl;

    return 0;
}

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

int main() {
  int n, r;
  while (cin >> n >> r, n) {
    auto v = vector<int>(n);
    iota(begin(v), end(v), 1);
    reverse(begin(v), end(v));

    auto tmp = v;
    for (int i = 0; i < r; ++i) {
      int p, c; cin >> p >> c;
      for (int i = 0; i < c; ++i) tmp[i] = v[i + p - 1];
      for (int i = 0; i < p - 1; ++i) tmp[i + c] = v[i];
      v = tmp;
    }
    cout << v[0] << endl;
  }
  return 0;
}



Measured memory_bytes: 3084
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . ___
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         ·ð×æ±£ÓÓ       ÓÀÎÞBUG
*/
//use readint!
#pragma GCC optimize(1)
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize(4)
#pragma GCC optimize(5)
#pragma GCC optimize(6)
#pragma GCC optimize(7)
#pragma GCC optimize(8)
#pragma GCC optimize(9)
#include<map>
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<set>
#include<cmath>
#include<stdio.h>
#include<fstream>
#include<assert.h>
#include<time.h>
#include<queue>
#include<deque>
#include<stack>
#include<list>
#include<string.h>
#define mp make_pair
#define ll long long
#define all(v) v.begin(),v.end()
#define memset(a,b) memset(a,b,sizeof(a))
using namespace std;
const int INF=1e9;
inline int pt(int a[],int l,int r){
	int p,i,j;
	p=a[l];
	i=l;
	j=r+1;
	for(;;){
		while(a[++i]<p) if(i>=r) break;
		while(a[--j]>p) if(j<=l) break;
		if(i>=j) break;
		else swap(a[i],a[j]);
	}
	if(j==l) return j;
	swap(a[l],a[j]);
	return j;
}
inline void q_sort(int a[],int l,int r){
	int q;
	if(r>l){
		q=pt(a,l,r);
		q_sort(a,l,q-1);
		q_sort(a,q+1,r);
	}
}
inline int readint(){
    int x=0;
    int f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9') ch=getchar();
	if(ch=='-'){
		f=-1;
		ch=getchar();
	}
    while(ch>='0'&&ch<='9'){
        x=x*10+ch-'0';
        ch=getchar();
    }
    return x*f;
}
int main(){
	long long i,j,a,b;
	cin>>a>>b;
	cout<<max(a+b,max(a*b,a-b))<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int n; scanf("%d", &n);
  int x = 0;
  int l, r;
  for (int i=0;i<n;i++){
    scanf("%d %d", &l, &r);
    x += r-l+1;
  }
  printf("%d", x);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

using vi = vector<int>;

#define ALL(a) (a).begin(),(a).end()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ITER(it,v) for(auto it=v.begin();it!=v.end();++it)
#define IN(v) int v;cin>>v;
#define OUT(v) cout<<v<<endl

int main() {
  IN(N);

  map<int, int> m;
  vi A;
  REP(i, N) {
    IN(a);
    ++m[a];
  }
  ITER(it, m) {
    A.push_back(it->second);
  }
  sort(ALL(A));

  int ans = 0;
  ITER(it, A) {
    int n = *it;
    if (n == 1) {
      ++ans;
      continue;
    }
    if (it+1 != A.end()) {
      *(it+1) -= n-1;
      *it = 1;
      ++ans;
    } else {
      if (n % 2 == 1)
        ++ans;
    }
  }
  OUT(ans);

  return 0;
}
// -1 0 -1
// -1 -1
// -2
//
// 後ろから見ていく


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

int n, sum=0;

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


Measured memory_bytes: 256
#include<cstdio>
#include<cctype>
#include<cstring>
#include<algorithm>
#define LL long long
#define OP "then"
const int MAXN(1e5+5);
inline int read()
{
	int x(0);
	int flag(1);
	char ch(getchar()); 
	while(!isdigit(ch))
	{
		if(ch=='-')
		{
			flag=-1;
		}
		ch=getchar();
	}
	while(isdigit(ch))
	{
		x=(x<<1)+(x<<3)+(ch^48);
		ch=getchar();
	}
	return flag*x;
}
int fx[MAXN];
int fy[MAXN];
LL wx[MAXN];
LL wy[MAXN];
int findx(int x)
{
	if(fx[x]==x) 
	{
		return x;
	}
	int y=findx(fx[x]); 
	wx[x]+=wx[fx[x]];
	return fx[x]=y;
}
int findy(int x)
{
	if(fy[x]==x)
	{
		return x;
	}
	int y(findy(fy[x]));
	wy[x]+=wy[fy[x]];
	return fy[x]=y;
}
bool unionnx(int x,int y,LL val1,LL val2)
{
	int a(findx(x));
	int b(findx(y));
	if(a==b)
	{
		return wx[x]-wx[y]==val2-val1;//1 x  2 y
	}
	fx[a]=b; 
	wx[a]=val2-val1+wx[y]-wx[x];
	return 1;
}
bool unionny(int x,int y,LL val1,LL val2)
{
	int a(findy(x));
	int b(findy(y));
	if(a==b)
	{
		return wy[x]-wy[y]==val2-val1;//1 x  2 y
	}
	fy[a]=b; 
	wy[a]=val2-val1+wy[y]-wy[x];
	return 1;
}
class Node
{
	public:
		int x;
		int y;
		LL val;
}node[MAXN];
bool cmpx(const Node &a,const Node &b )
{
	return a.x<b.x;
}
bool cmpy(const Node &a,const Node &b)
{
	return a.y<b.y;
}
LL h1[MAXN];
LL h2[MAXN];
int main()
{
	//std::freopen(OP".in","r",stdin);
	//std::freopen(OP".out","w",stdout);
	std::memset(h1,63,sizeof h1); 
	std::memset(h2,63,sizeof h2);
	std::memset(wx,0,sizeof wx);
	std::memset(wy,0,sizeof wy);
	int r(read()),c(read()),n(read());
	for(int i=1;i<=r;i++)
	{
		fx[i]=i;
	}
	for(int i=1;i<=c;i++)
	{
		fy[i]=i;
	}
	bool flag=1;
	for(int i=1;i<=n;i++)
	{
		int x(read()),y(read()),val(1ll*read());
		node[i]=(Node){x,y,val};
		if(val<0)
		{
			flag=0;
		}
	}
	if(!flag)
	{
		std::printf("No\n");
		return 0;
	}
	std::sort(node+1,node+1+n,cmpx);
	for(int i=1;i<n;i++)
	{
		if(node[i].x==node[i+1].x)
		{
			flag&=unionny(node[i].y,node[i+1].y,node[i].val,node[i+1].val);
		}
	}
	std::sort(node+1,node+1+n,cmpy);
	for(int i=1;i<n;i++)
	{
		if(node[i].y==node[i+1].y)
		{
			flag&=unionnx(node[i].x,node[i+1].x,node[i].val,node[i+1].val);
		}
	}
    for(int i=1;i<=n;i++)
    {
       	int x=findx(node[i].x);
       	h1[x]=std::min(1ll*h1[x],node[i].val+wx[node[i].x]);
    }
    for(int i=1;i<=r;i++)
    {
       	int x=findx(i);
       	h2[x]=std::min(1ll*h2[x],-wx[i]);
    }
    for(int i=1;i<=r;i++)
    {
        if(fx[i]==i&&h1[i]+h2[i]<0)
		{
        	flag=0;
        }    		
    }
	(!flag)?std::printf("No\n"):std::printf("Yes\n");
	return 0;
}
/*
6
2 2
3
1 1 0
1 2 10
2 1 20
2 3
5
1 1 0
1 2 10
1 3 20
2 1 30
2 3 40
2 2
3
1 1 20
1 2 10
2 1 0
3 3
4
1 1 0
1 3 10
3 1 10
3 3 20
2 2
4
1 1 0
1 2 10
2 1 30
2 2 20
1 1 
1
1 1 -1
*/

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

using namespace std;
typedef long long int ll;
ll a[300000];
ll rot[300000];
int main() 
{
ll n;
cin>>n;
ll i = 1 ; //RAM-RAM!!!!
while(i<=n)
{
    
cin>>a[i];

//i.......>a[i]
    if(i>=a[i])
    {
        
        ll ram = i - a[i];
        if(ram+1<=n)
        {
        rot[ram+1]=rot[ram+1] + 1;
        }
        
    }
    
    i++;
}
    /*
    i=1;
    while(i<=n)
    {
        
    cout<<rot[i]<<" ";    
        
        i++;
    }
    cout<<"\n";*/
    
    ll sum = 0 ;
    i=1;
    while(i<=n)
    {ll xhm = a[i] ; 
        ll expect = i + a[i] + 1 ; 
        if(expect<=n)
        {
        
        sum=sum + rot[expect];
        }
        
        i++;
        
    }
    cout<<sum;
    return 0;
}

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

int main() {
  
  string yoso, real;
  cin >> yoso >> real;
  
  int counter = 0;
  if (yoso.at(0) == real.at(0)) counter++;
  if (yoso.at(1) == real.at(1)) counter++;
  if (yoso.at(2) == real.at(2)) counter++;
  
  cout << counter << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i <= (n); i++)
#define repi(i,a,b) for (int i = (a); i < (b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;

int main() {
  string A, B, C;
  cin >> A >> B >> C;
  
 if (A.at(A.size()-1)==B.at(0) && B.at(B.size()-1)==C.at(0)) 
   cout << "YES" << endl;
  else
    cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back
#define mp make_pair
std::vector<int> v[100002];
int dp[100002];
bool vis[100002] = {false};
int dfs(int i) {
    vis[i] = true;
    int val = 0;
    for(auto it:v[i]) {
        if(!vis[it]) {
            dp[it] = dfs(it);
        }
        dp[i] = max(dp[i], dp[it] + 1);

    }
    if(v[i].empty()) {
        dp[i] = 0;
    }
    return dp[i];
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    int n, m, i, j, k;
    cin >> n >> m;
    for(i = 0; i < m; i++) {
        cin >> j >> k;
        v[j].pb(k);
    }
    memset(dp, -1, sizeof(dp));
    i = 1;
    while(v[i].empty()) {
        i++;
    }
    int mx = -1;
    for(i = 1; i <= n; i++) {
        if(!vis[i]) {
            dfs(i);
        }
    }
    for(i = 0; i <= n; i++) {
        mx = max(dp[i], mx);
    }
    cout << mx << endl;

    return 0;
}

Measured memory_bytes: 8960
#include <bits/stdc++.h>
//#include <mylib.h>
using namespace std;
//cin.sync_with_stdio(false);

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define FOR_EQ(i,a,b) for(int i = (a); i <= (b); ++i)
#define FOR_RE(i,a,b) for(int i = (a); i > (b); --i)
#define rep(i,n) FOR(i,0,n)
#define rep_eq(i,n) FOR_EQ(i,0,n)
#define rep_re(i,n) FOR_RE(i,n,0)

#define WHITE 1//（未訪問）
#define GRAY 2//（訪問）未だに訪問していない頂点への辺を持っている。スタックに退避。
#define BLACK 3//（訪問完了）未訪問への頂点への辺を持たない
#define N 100
#define INFTY (1 << 21) //10^21
int M[N][N];//隣接行列
int color[N];

//1個上から時計周り
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
//上右下左
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {-1, 0, 1, 0};
static const int NIL = -1;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> Vector;
typedef vector<Vector>	DVector;
int n;

//配列の表示
void printArray(int array[], int n){
    rep(i, n){
        if(i)   cout << " ";
        cout << array[i];
    }
    cout << endl;
}

//偶数ならtrue, 奇数ならfalseを返す．
bool odd_even_judge(int num){
    if(num % 2){
        return false;
    }else{
        return true;
    }
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int s;
    cin >> s;
    int a[1000000];
    int ite = 1;
    a[0] = s;
    int now = s;
    int next;
    
    while(1){
        if (odd_even_judge(now))
        {
            next = now / 2;
        }else{
            next = 3 * now + 1;
        }
        
        rep(i, ite){
            if(a[i] == next){
                cout << ite+1 << endl;
                return 0;
            }
        }
        
        a[ite] = next;
        now = a[ite];
        ite++;
    }
}

Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
int n;//計算する行列の数
const int MAX_N =110;
int dp[MAX_N][MAX_N];//dp[i][j]:=Ai...Ajの計算に必要な最小のコスト
pii A[MAX_N];//行列firstを行secondを列とする。
int B[MAX_N+1][MAX_N+1]; //B[i][j]:=Ai...Ajに最適な括弧を挿入する場所
void init(){
	for(int i =0; i < n;i++){
		for(int j = 0;j < n;j++){
			dp[i][j]=INF;
			B[i][j]=0;
		}
	}
	for(int i =0;i < n;i++){
		dp[i][i]=0;
	}
}
//計算
int solve(){
	for(int k =1;k <n;k++){//個数
		for(int i =0;i <n-k;i++){//何処から始めるか
			for(int j =i;j <i+k;j++){//何処で終わるか
				int sz =A[i].first*A[j].second*A[i+k].second;
				int cost=dp[i][j]+dp[j+1][i+k]+sz;
				if(dp[i][i+k] >cost){
					dp[i][i+k]=cost;
					B[i][i+k]= j+1;//括弧を挿入する場所
				}

			}
		}
	}
	return dp[0][n-1];
}
//復元
void order(int i,int j){
	if(i==j){
		cout <<'A'<<i;
	}else{
		cout <<"(";
		order(i, B[i][j]-1);
		order(B[i][j], j);
		cout <<")";
	}
}

int main(){
	cin>>n;
	init();
	for(int i =0;i < n;i++){
		cin>>A[i].first>>A[i].second;
	}
	cout <<solve()<<endl;
	//order(0, n-1);
	return 0;
}

Measured memory_bytes: 1256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<queue>
#define Vmaxn 100010
#define Emaxn 500010
#define inf 2147483646

using namespace std;

struct Node
{
    int x,y,val,pre;
};
int g_[Vmaxn];
Node g[Emaxn];//动态数组存储

int n,m,r;
int dis[Vmaxn];
bool h[Vmaxn];
queue<int> q;
void read(int &x){
	char ch = getchar();x = 0;
	for (; ch < '0' || ch > '9'; ch = getchar());
	for (; ch >='0' && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';
}

int main()
{
    int i,j,k,t,ans;
    int p,p_;
    read(n),read(m),read(r);
    memset(g_,-1,sizeof g_);
    for(i=0;i<m;i++)
    {
        read(g[i].x),read(g[i].y),read(g[i].val);
        g[i].pre=g_[g[i].x];
        g_[g[i].x]=i;
    }

    for(i=0;i<n;i++)
        dis[i]=inf,h[i]=true;
    dis[r]=0,h[r]=false;
    q.push(r);

    while(!q.empty())
    {
        p=q.front();q.pop();h[p]=true;
        j=g_[p];
        while(j!=-1)
        {
            p_=g[j].y;
            if(dis[p]+g[j].val<dis[p_])
            {
                dis[p_]=dis[p]+g[j].val;
                if(h[p_])
                {
                    q.push(p_);
                    h[p_]=false;
                }
            }
            j=g[j].pre;
        }
    }
    for(i=0;i<n;i++)
        if(dis[i]==inf)
            printf("INF\n");
        else
            printf("%d\n",dis[i]);
    return 0;
}



Measured memory_bytes: 11888
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int r = sc.nextInt();
        int g = sc.nextInt();
        int b = sc.nextInt();
        int n = sc.nextInt();
        int ans = 0;

        for (int i = 0; i <= n / r; i++) {
            for (int j = 0; j <= (n - r * i) / g; j++) {
               if((n - r * i - g * j) % b == 0) ans++;
            }
        }

        System.out.println(ans);
        sc.close();
    }
}

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

int main() {
	int n,a=0,b=0;
	cin>>n;
	vector<int>v(n);
	for(int i=0;i<n;i++)cin>>v.at(i);
	sort(v.begin(),v.end(),greater<int>());
	for(int i=0;i<n;i++){
		if(i%2==0){
			a+=v.at(i);
		}else{
			b+=v.at(i);
		}
	}
	cout<<a-b<<endl;
	return 0;
}



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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
void tostr(ll x,string& res){while(x)res+=('0'+(x%10)),x/=10; reverse(ALL(res)); return;}
template<class T> inline bool chmax(T& a,T b){ if(a<b){a=b;return 1;}return 0; }
template<class T> inline bool chmin(T& a,T b){ if(a>b){a=b;return 1;}return 0; }
//template end



int main(){
   string s,t; cin>>s>>t;
   int a,b; scanf("%d%d",&a,&b);
   string r; cin>>r;
   if(s==r)a--; else b--;
   printf("%d %d\n",a,b);
   return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std;
long long n,k,ans;
int main()
{
	cin>>n>>k;
	for(long long i=k+1;i<=n;i++)
	{
		if(!(n%i))ans+=(i-k)*(n/i);
		else{if(k==0)ans--;ans+=(i-k)*(n/i)+max(0ll,n%i-k+1);}
	}
	cout<<ans; 
}

Measured memory_bytes: 3636
import sys
from sys import exit
from collections import deque
from bisect import bisect_left, bisect_right, insort_left, insort_right #func(リスト,値)
from heapq import heapify, heappop, heappush
from itertools import product, permutations, combinations, combinations_with_replacement
from functools import reduce
from math import sin, cos, tan, asin, acos, atan

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def lcm(x,y):
    return x*y//gcd(x,y)
def lgcd(l):
    return reduce(gcd,l)
def llcm(l):
    return reduce(lcm,l)
def powmod(n,i,mod):
    return pow(n,mod-1+i,mod) if i<0 else pow(n,i,mod)
def div2(x):
    return x.bit_length()
def div10(x):
    return len(str(x))-(x==0)
def perm(n,mod=None):
    ans = 1
    for i in range(1,n+1):
        ans *= i
        if mod!=None:
            ans %= mod
    return ans
def intput():
    return int(input())
def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)
def ston(c, c0='a'):
    return ord(c)-ord(c0)
def ntos(x, c0='a'):
    return chr(x+ord(c0))
class counter(dict):
    def __init__(self, *args):
        super().__init__(args)
    def add(self,x):
        self.setdefault(x,0)
        self[x] += 1
class comb():
    def __init__(self, n, mod=None):
        self.l = [1]
        self.n = n
        self.mod = mod
    def get(self,k):
        l,n,mod = self.l, self.n, self.mod
        k = n-k if k>n//2 else k
        while len(l)<=k:
            i = len(l)
            l.append(l[i-1]*(n+1-i)//i if mod==None else (l[i-1]*(n+1-i)*powmod(i,-1,mod))%mod)
        return l[k]

x = intput()
print(2*(x//11)+((x%11)!=0)+((x%11)>6))

Measured memory_bytes: 69144