akhauriyash/Code-Regression huggingface dataset:
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

// デバッグ(出典不明)
#[allow(unused_imports)]
use std::io::Write;
#[allow(unused_macros)]
macro_rules! eprint {
    ($fmt:expr) => {
        #[cfg(debug_assertions)]
        write!(std::io::stderr(), $fmt).unwrap()
    };
    ($fmt:expr, $($arg:tt)*) => {
        #[cfg(debug_assertions)]
        write!(std::io::stderr(), $fmt, $($arg)*).unwrap()
    };
}

#[allow(unused_macros)]
macro_rules! eprintln {
    ($fmt:expr) => {
        #[cfg(debug_assertions)]
        writeln!(std::io::stderr(), $fmt).unwrap()
    };
    ($fmt:expr, $($arg:tt)*) => {
        #[cfg(debug_assertions)]
        writeln!(std::io::stderr(), $fmt, $($arg)*).unwrap()
    };
}

#[allow(unused_macros)]
macro_rules! dbg {
    ($val:expr) => {
        match $val {
            tmp => {
                eprintln!("[{}:{}] {} = {:#?}",
                    file!(), line!(), stringify!($val), &tmp);
                tmp
            }
        }
    };
}

fn solver(n: i64, x: i64) -> i64 {
    if n >= 0 {
        n / x + 1
    } else {
        0
    }
}

fn main() {
    input!(
        a: i64,
        b: i64,
        x: i64
    );
    
    println!("{}", solver(b, x) - solver(a-1, x));

}

Measured memory_bytes: 4352
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const double PI = acos(-1);
const ll MOD = 1000000007;
// const ll MOD = 998244353;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
///////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N,K; cin >> N >> K;
    int ans = K;
    rep(i,N-1) ans *= (K-1);
    cout << ans << endl; 
}

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

#include <ext/pb_ds/priority_queue.hpp>
typedef __gnu_pbds::priority_queue<int> pq;


int main(void) {
    int n, m; scanf("%d %d", &n, &m);
    int k; scanf("%d", &k);
    vector<int> x(k), y(k);
    vector<int> c(m, 0);
    vector<vector<int>> g(n);
    pq q;
    for (int i = 0; i < k; ++i) {
        scanf("%d %d", &x[i], &y[i]);
        x[i]--; y[i]--;
        g[x[i]].push_back(y[i]);
        c[y[i]]++;
    }
    vector<pq::point_iterator> v;
    for (int i = 0; i < m; ++i)
        v.push_back(q.push(c[i]));
    int ans = 1;
    for (int i = 0; i < n; ++i) {
        for (int j : g[i]) q.modify(v[j], c[j] - 1);
        ans = max(ans, (int)g[i].size() + q.top());
        for (int j : g[i]) q.modify(v[j], c[j]);
    }
    printf("%d\n", ans);

    return 0;
}

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

using namespace std;
typedef long long ll;


int main(void)
{
   int n;
   cin>>n;
   map<ll,ll>m;
   ll sum=0;
   for(int i=0;i<n;i++)
   {
       ll x;
       cin>>x;
       sum+=x;
       m[x]++;
   }
   int q;
   cin>>q;
   for(int i=1;i<=q;i++)
   {
       ll b,c;
       cin>>b>>c;

       sum-= m[b]*b;
       sum+=m[b]*c;
       m[c]+=m[b];
       m[b]=0;
       cout<<sum<<endl;



   }
}






Measured memory_bytes: 9376
#include <iostream>

using namespace std;

typedef long long ll;

int MOD = 1;

struct Modint {
  ll val;
  
  Modint (ll _val = 0)
    : val(_val % MOD) {}

  Modint operator+ (Modint other) const {
    return Modint(val + other.val);
  }

  void operator+= (Modint other) {
    val += other.val;
    val %= MOD;
  }

  Modint operator- () const {
    return Modint(MOD - val);
  }

  Modint operator- (Modint other) const {
    return Modint(val + MOD - other.val);
  }

  void operator-= (Modint other) {
    val += MOD - other.val;
    val %= MOD;
  }

  Modint operator* (Modint other) const {
    return Modint(val * other.val);
  }

  void operator*= (Modint other) {
    val *= other.val;
    val %= MOD;
  }

  bool operator== (Modint other) const {
    return val == other.val;
  }

  bool operator!= (Modint other) const {
    return val != other.val;
  }
};

Modint exp (Modint a, int k) {
  if (k == 0) {
    return Modint(1);
  } else if (k % 2 == 0) {
    Modint half = exp(a, k / 2);
    return half * half;
  } else {
    return a * exp(a, k - 1);
  }
}

Modint inv (Modint a) {
  return exp(a, MOD - 2);
}

ostream& operator<< (ostream& out, Modint p) {
  out << p.val;
  return out;
}

const int MAX_N = 305;

Modint prods [MAX_N][MAX_N];
// prods[i][k] is the sum of all products of
// nondecreasing sequences length i, with the
// last value being = k
// later we prefixize and get last value being <= k

Modint dp [MAX_N][MAX_N];
// dp[i][k] -- i things have been placed, the biggest thing is k

int main () {
  int n, K;
  cin >> n >> K >> MOD;

  prods[0][0] = Modint(1);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= n; j++) {
      for (int k = j; k <= n; k++) {
        prods[i + 1][k] += prods[i][j] * Modint(k);
      }
    }
  }

  // prefixize prods
  for (int i = 0; i <= n; i++) {
    for (int k = 1; k <= n; k++) {
      prods[i][k] += prods[i][k - 1];
    }
  }

  /*
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= K; j++) {
      cout << prods[i][j] << " ";
    }
    cout << endl;
  }
  cout << endl;
  */
  
  dp[0][0] = Modint(1);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < K; j++) {
      for (int k = 0; i + k <= n; k++) { // # of things we add
        dp[i + k][j + 1] += dp[i][j] * prods[k][i + 1];
      }
    }
  }

  /*
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= K; j++) {
      cout << dp[i][j] << " ";
    }
    cout << endl;
  }
  */  

  Modint ans (0);
  for (int k = 0; k <= K; k++) {
    ans += dp[n][k];
  }
  cout << ans << endl;
}


Measured memory_bytes: 5132
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
#define int long long int
typedef complex<long double> cd;
const long double pi=acos(-1);
typedef double db;
typedef long double ldb;
typedef pair <int,int> pii;
typedef pair <db,db> pdd;
typedef vector<int> vi;
typedef vector<vector<int> > matrix;

#define m1 make_pair
#define pb push_back
#define flush fflush(stdout)
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define reset(x,v) memset(x,v,sizeof(x))

#define fi first
#define se second
#define endl "\n"
#define debug(x) (cerr << #x << ": " << x << "\n")
#define setbits(x) __builtin_popcount(x)
#define setbitsll(x) __builtin_popcountll(x)
#define all(x) x.begin(),x.end()
#define pii pair<int,int>

inline int gcd(int a,int b){if(a==0) return b;return gcd(b%a,a);}
inline int power(ll a,ll n,ll m){if(n==0)return 1;ll p=power(a,n/2,m);p=(p%m*p%m)%m;if(n%2) return (p%m*a%m)%m;else return p;}
const double EPS = 1e-9;
const ll MOD=998244353;
const ll hell=1000000007;
const int INF = 1e18;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
template<typename T>
using ordered_set=tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

auto seed = chrono::high_resolution_clock::now().time_since_epoch().count();
std::mt19937 rng(seed);

double startTime;
double getCurrentTime() {
    return ((double)clock() - startTime) / CLOCKS_PER_SEC;
}
const int dx[] = { -1, 0, 1, 0 };
const int dy[] = { 0, 1, 0, -1 };

const int N=100005;

ldb dp[3005][3005];

void solve()
{
int n;
cin>>n;
ldb p[n+1];
for(int i=1;i<=n;i++)
cin>>p[i];
dp[0][0]=1;
for(int i=1;i<=n;i++)
{
    for(int j=0;j<=n;j++)
    {
        dp[i][j]=(1-p[i])*dp[i-1][j];
        if(j)
        dp[i][j]+=p[i]*dp[i-1][j-1];
    }
}
ldb ans=0;
for(int i=(n/2)+1;i<=n;i++)
ans=ans+dp[n][i];
cout<<setprecision(15);
cout<<ans<<endl;


}




int32_t main()
{
    IOS;
    int t;
    t=1;
    //cin>>t;
    while(t--)
    {
        
        solve();
    }
    return 0;
}

Measured memory_bytes: 144668
from collections import defaultdict
import sys
input = sys.stdin.readline
N = int(input())

d = defaultdict(int)
for _ in range(N):
    s = input().strip()
    d[s] += 1

print("AC x", d["AC"])
print("WA x", d["WA"])
print("TLE x", d["TLE"])
print("RE x", d["RE"])


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

using namespace std;

typedef long long ll;
typedef long double ld;

const ld PI = (acos(-1));

int main() {
  ld a, b, x;
  cin >> a >> b >> x;

  ld ans;
  if (a * a * b / 2.0 <= x) {
    ans = atan(2 * (a * a * b - x) / (a * a * a));
  } else {
    ans = PI / 2 - atan(2 * x / (a * b * b));
  }

  cout << fixed << setprecision(6) << ans * 180.0 / PI << endl;

  return 0;
}


Measured memory_bytes: 256
D = int(input()) #365
c = list(map(int, input().split()))
s_matrix = [list(map(int, input().split())) for _ in range(D)]
last = [0] * 26
satis = 0

for i in range(D):
    satis2 = satis
    last2 = last.copy()
    for k in range(26):
        satis3 = satis2
        last3 = last.copy()

        satis2 += s_matrix[i][k]
        last2[k] = i + 1
        for j in range(26):
            satis2 -= c[j] * (i+1 - last2[j])
        
        if satis2 > satis:
            satis = satis2
            ans = k + 1
            last = last2.copy()
        satis2 = satis3
        last2 = last3.copy()
    
    print(ans)


Measured memory_bytes: 69112
#include <bits/stdc++.h>
using namespace std;
int main(){
  int H,N;
  cin>>H>>N;
  vector<int>A(N);
  for(int i=0;i<N;i++){
    cin>>A.at(i);}

  int sum=0;
  for(int i=0;i<N;i++){
    sum+=A.at(i);}

  if(H<=sum){cout<<"Yes"<<endl;}
  else{cout<<"No"<<endl;}
  return 0;}

Measured memory_bytes: 768
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

public class Prime
{
    BitArray Sieve;
    // Sieve of Eratosthenes
    public void Init(int max)
    {
        Sieve = new BitArray(max + 1);
        var end = (int)(Math.Sqrt(max) + 0.1);
        Sieve.Set(1, true);
        for (int i = 2; i <= end; i++)
        {
            if (!Sieve.Get(i))
            {
                for (int j = i * 2; j <= max; j += i)
                {
                    Sieve.Set(j, true);
                }
            }
        }
    }

    public bool IsPrime(int n)
    {
        return !Sieve.Get(n);
    }

    public int[] GetPrimes(int n)
    {
        return Enumerable.Range(2, n - 1).Where(i => !Sieve.Get(i)).ToArray();
    }
}

public class Solution
{
    public static void Main()
    {
        var x = int.Parse(Console.ReadLine());
        var prime = new Prime();
        prime.Init(1000000);
        while(true)
        {
            if(prime.IsPrime(x))
            {
                Console.WriteLine(x);
                return;
            }
            x++;
        }
    }
}

Measured memory_bytes: 13136
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Pine1999
 */

#include <bits/stdc++.h>

using namespace std;

class DForest {
public:
    void solve(std::istream& in, std::ostream& out) {
        int n, m;
        in >> n >> m;
        vector<int> a(n);
        for (int i = 0; i < n; ++i) {
            in >> a[i];
        }
        vector<vector<int>> g(n);
        for (int i = 0; i < m; ++i) {
            int x, y;
            in >> x >> y;
            g[x].push_back(y);
            g[y].push_back(x);
        }
        int forest_size = 0;
        vector<int> visited(n), c;
        vector<int> b;
        function<void(int)> Dfs = [&](int v) {
            c.push_back(a[v]);
            visited[v] = 1;
            for (int to : g[v]) {
                if (visited[to]) continue;
                Dfs(to);
            }
        };
        long long ans = 0;
        for (int i = 0; i < n; ++i) {
            if (visited[i]) continue;
            c.clear();
            Dfs(i);
            sort(c.begin(), c.end());
            ans += c[0];
            ++forest_size;
            for (int j = 1; j < (int) c.size(); ++j) b.push_back(c[j]);
        }
        if (2 * (forest_size - 1) > n) out << "Impossible" << '\n';
        else if (forest_size == 1) out << 0 << '\n';
        else {
            sort(b.begin(), b.end());
            for (int i = 0; i < forest_size - 2; ++i) {
                ans += b[i];
            }
            out << ans << '\n';
        }
    }
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    DForest solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}

Measured memory_bytes: 10608
n = int(input())
a = list(map(int, input().split(' ')))
b = list(map(int, input().split(' ')))
c = list(map(int, input().split(' ')))
ans2 = 0

for j in range (0,n-1):
  if a[j]+1 == a[j+1]:
    ans2 = ans2 + c[a[j]-1]
    
print(sum(b)+ans2)

Measured memory_bytes: 3064
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

namespace MyProgram
{
    public class Program
    {	
        public static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int A = int.Parse(input[0]);
            int B = int.Parse(input[1]);
            int K = int.Parse(input[2]);
            
            List<int> list = new List<int>(); 
            
            for(int i = A ; i < A+K ; i++)
            {
                if(i <= B) list.Add(i);
            }
            for(int i = B ; i > B - K; i--)
            {
                if(i >= A){
                    if(!list.Contains(i))
                    {
                        list.Add(i);
                    }
                }
            }
            list.Sort();
            foreach(int i in list) Console.WriteLine(i);
        }
    }
}

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

using namespace std;

#define REP(i,n)	for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPS(i,s,n)	for(int i=(s), i##_len=(n); i<i##_len; ++i)

#define INF 		2000000007
#define MOD			10e9+7
#define MAX 		100005

typedef unsigned int 			uint;
typedef unsigned long long int	ull;
typedef long long int 			ll;

int main(){
	int W,H,x,y;cin>>W>>H>>x>>y;

	double m = (double)W/2*H;

	printf("%.12f ",m);
	if( (x*2 == W) && (y*2==H) )cout << '1' << endl;
	else cout << '0' << endl;



	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <string>
#include <cmath>
#include <sstream>
#include <istream>
#include <iomanip>
#include <typeinfo>
#include <stack>
#include <map>

using namespace std;
typedef long long int ll;

int main(){

    ll N = 0;
    cin >> N;
    vector<ll > a(N);
    for(ll i = 0; i < N; i++){
        cin >> a[i];
    }

    ll cost = 0;
    ll ans = 1145141919;
    for(ll i = -100; i <= 100; i++){
        for(ll j = 0; j < N; j++){
            cost += pow(a[j] - i, 2);
        }
        //cout << cost << endl;
        ans = min(cost, ans);
        cost = 0;
    }

    cout << ans << endl;

} 

Measured memory_bytes: 256
object Main {
  def main(args: Array[String]) {
    var count = 0
    var max_x = -101
    var min_y = 101


    for(line <- io.Source.stdin.getLines()){
      val factors = line.split(' ').map{_.toInt}
      if(count == 0) {
        max_x = factors(2)
        min_y = factors(3)
      }
      else if(count == 1) {
        factors.foreach { c =>
          if (max_x < c) {
            max_x = c
          } 
        }
      }
      else {
        factors.foreach { c =>
          if (c < min_y) {
            min_y = c
          } 
        }
      }
      count += 1
    }
    if (min_y <= max_x) {
      println("War")
    }
    else {
      println("No War")
    }
  }
}


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

int H[101];
int ans = 0;
int main() {
	int N;
  cin >> N;
  for ( int i = 0; i < N; i++ )
  {
    cin >> H[i+1];
  }
  int max = H[1];
  for ( int i = 1; i <= N; i++ )
  {
    //cout << max << ":" << H[i] << endl;
    if ( max <= H[i] )
    {
      ans++;
      max = H[i];
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cmath>
#include <climits>
#include <map>
#include <queue>
#include <functional>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)
#define rep1(i, n) for(int i = 1; i <= (int) n; i++)
#define all(v) v.begin(),v.end()
const ll mod = 1e9+7;

int main() {
    int n;
    cin >> n;
    int m = n-n%1000+(n%1000!=0)*1000;
    cout << m-n << endl;    
    return 0;
}

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

using namespace std;

int const maxn = 2e5 + 5;
int a[maxn];

main() {
#ifdef HOME
    freopen("input.txt", "r", stdin);
#endif // HOME
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, k;
    cin >> n >> k;
    for (int i = 1; i <= n; ++i) cin >> a[i];
    for (int i = k + 1; i <= n; ++i) {
        if (a[i] > a[i - k]) cout << "Yes" << '\n';
        else cout << "No" << '\n';
    }
    return 0;
}



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

int main (){
  int N, x=0, i;
  cin >> N;
  
  for(i=0 ; i<N ; i++){
    int y;
    cin >> y;
    x|=y;
  }
  
  for(i=0 ; ; i++, x=x>>1)
    if(x%2==1)
      break;
  
  cout << i << endl;
}

Measured memory_bytes: 256
N,M=map(int,input().split())
mod=10**9+7
dp=[0 for i in range(N+1)]
dp[0]=1
a=[int(input()) for i in range(M)]
isbroken=[1 for i in range(N+1)]
for i in range(M):
    isbroken[a[i]]=0
for i in range(N):
    if i-1>=0:
        dp[i+1]=dp[i]*isbroken[i]+dp[i-1]*isbroken[i-1]
    else:
        dp[i+1]=dp[i]*isbroken[i]
    dp[i+1]%=mod
print(dp[N])


Measured memory_bytes: 9592
#include<stdio.h>
#include<string>
#include<utility>
#include<iostream>
#include<queue>
#include<math.h>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<bitset>
#include <cmath>
#include <limits>
#include <numeric>

using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<(int)(n);i++)

int main(){
    int n;
    scanf("%d",&n);
    char s[11];
    vector<string> v;
    REP(i,n){
        scanf("%s",s);
        sort(s,s+10);
        string str(s);
        v.push_back(str);
    }
    sort(v.begin(),v.end());
    //for(auto i:v)cout << i << endl;
    ll num=1;
    ll ans=0;
    int len=v.size();
    for(int i=1;i<len;i++){
        if(v[i-1]==v[i]){
            num++;
        }
        else{
            ans+=num*(num-1)/2;
            num=1;
        }
    }
    ans+=num*(num-1)/2;
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 5748
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
#define pvec(vec) {for (auto v: vec) cout << v << ' '; cout << endl;}
#define pivec(vec) {rep(i, 0, vec.size()) cout << i << ':' << vec[i] << ' '; cout << endl;}

using namespace std;
using ll = long long;

int N, M;
vector<vector<int>> graph;
vector<bool> visited;
vector<int> depth;
int dfs(int par, int now)
{
    if (visited[now]) return depth[now];

    visited[now] = true;

    // go next
    int dep = 0;
    for (auto next: graph[now])
    {
        if (next == par) continue;
        dep = max(dep, dfs(now, next)+1);
    }

    depth[now] = dep ;
    return depth[now];
}

int main()
{
    // read input
    cin >> N >> M;
    graph.assign(N, vector<int>());
    rep(i, 0, M)
    {
        int x, y;
        cin >> x >> y;
        --x, --y;
        graph[x].emplace_back(y);
    }

    // bfs
    visited.assign(N, false);
    depth.assign(N, 0);
    rep(start, 0, N)
        dfs(-1, start);

    // pvec(depth);

    int res = *max_element(depth.begin(), depth.end());
    cout << res << endl;
    return 0;
}


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

int  main()
{
	string s;
	cin >> s;
	map<string, int> mp;
	mp["SUN"] = 7;
	mp["SAT"] = 1;
	mp["FRI"] = 2;
	mp["THU"] = 3;
	mp["WED"] = 4;
	mp["TUE"] = 5;
	mp["MON"] = 6;
	cout << mp[s] << endl;
	return (0);
}

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

  

Measured memory_bytes: 1024
N, Y = list(map(int, input().split()))

result = (-1, -1, -1)
for x in range(N + 1):
    for y in range(N + 1):
        if x + y > N:
            break
        if 10000 * x + 5000 * y + 1000 * (N - x - y) == Y:
            result = (x, y, N - x - y)
print("{} {} {}".format(result[0], result[1], result[2]))


Measured memory_bytes: 3060
import java.util.*;

public class Main {

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

        int max = 0;
        int ans = 0;
        for(int i = 0;i < n;i++){
            int m = sc.nextInt();
            if(max <= m){
                ans++;
                max = m;
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,x;
    while(~scanf("%d",&n))
    {
        int cnt=0;
        for(i=0;i<n;i++)
        {
            scanf("%d",&x);
            if(x%2) cnt++;
        }
        if(cnt%2==1) printf("NO\n");
        else printf("YES\n");
    }
    return 0;
}


Measured memory_bytes: 384
class UnionFind:
    def __init__(self, n):
        self.n = n
        self.parent = [i for i in range(n)]  # 親
        self.rank = [1] * n  # 木の高さ
        self.size = [1] * n  # size[i] は i を根とするグループのサイズ
 
    def find(self, x):  # x の根を返す
        if self.parent[x] == x:
            return x
        else:
            self.parent[x] = self.find(self.parent[x])  # 経路圧縮
            return self.parent[x]
 
    def unite(self, x, y):  # x, y の属する集合を併合する
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                self.parent[x] = y
                self.size[y] += self.size[x]
            else:
                self.parent[y] = x
                self.size[x] += self.size[y]
                if self.rank[x] == self.rank[y]:
                    self.rank[x] += 1
 
    def is_same(self, x, y):  # x, y が同じ集合に属するか判定する
        return self.find(x) == self.find(y)
 
    def group_size(self, x):  # x が属する集合の大きさを返す
        return self.size[self.find(x)]




def bridge(edges,v,e):#与えられるグラフが連結の場合
    hashi=[]#橋
    for i in range(e):
        uf=UnionFind(v)
        for j in range(e):
            if i==j:
                continue
            a,b=edges[j]
            uf.unite(a,b)
        if uf.group_size(0)!=v:#非連結でないなら頂点数と一致する
            hashi.append(i)
    return hashi

def is_bridge(edges,v,e,i):#0-indexのi番目の辺が橋か判定する
    uf=UnionFind(v)
    for j in range(e):
        if i==j:
            continue
        a,b=edges[j]
        uf.unite(a,b)
    if uf.group_size(0)!=v:
        return True
    else:
        return False

n,m=map(int,input().split())
edges=[]
for i in range(m):
    a,b=map(int,input().split())
    a,b=a-1,b-1
    edges.append((a,b))

ans=0
for i in range(m):
    if is_bridge(edges,n,m,i):
        ans+=1
print(ans)

Measured memory_bytes: 9236
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_set>
#include <bitset>
#include <time.h>
#include <limits.h>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define szz(x) (int)x.size()
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
typedef tuple<int, int, int> t3;

namespace Matching{
	//matching [1...n] <-> [1...m]
	const int MX = 40040, MY = 40040;
	vector <int> E[MX];
	int xy[MX], yx[MY];
	int n, m;
	
	void addE(int x, int y) { E[x].pb(y); }
	void setnm(int sn, int sm) { n = sn; m = sm; }
	
	int tdis[MX], que[MX], *dis = tdis + 1;
	int bfs() {
		int *fr = que, *re = que;
		for(int i=1;i<=n;i++) {
			if(xy[i] == -1) *fr++ = i, dis[i] = 0;
			else dis[i] = -1;
		}
		dis[-1] = -1;
		while(fr != re) {
			int t = *re++;
			if(t == -1) return 1;
			for(int e : E[t]) {
				if(dis[yx[e]] == -1) dis[yx[e]] = dis[t] + 1, *fr++ = yx[e];
			}
		}
		return 0;
	}
	
	int dfs(int x) {
		for(int e : E[x]) {
			if(yx[e] == -1 || (dis[yx[e]] == dis[x] + 1 && dfs(yx[e]))) {
				xy[x] = e;
				yx[e] = x;
				return 1;
			}
		}
		dis[x] = -1;
		return 0;
	}
	
	int Do() {
		memset(xy, -1, sizeof xy);
		memset(yx, -1, sizeof yx);
		
		int ans = 0;
		while(bfs()) {
			for(int i=1;i<=n;i++) if(xy[i] == -1 && dfs(i)) ++ans;
		}
		return ans;
	}
}

int main() {
	int n; scanf("%d", &n);
	int a[120], b[120], c[120], d[120];
	for(int i=1;i<=n;i++) scanf("%d%d", a+i, b+i);
	for(int i=1;i<=n;i++) scanf("%d%d", c+i, d+i);
	Matching::setnm(n, n);
	for(int i=1;i<=n;i++) for(int j=1;j<=n;j++) if(a[i] < c[j] && b[i] < d[j]) Matching::addE(i, j);
	printf("%d\n", Matching::Do());
	return 0;
}


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

using namespace std;

#define int long long

template<class T>
struct Segtree {
	int n;
	vector<T> node;
	Segtree(int sz) {
		n = 1;
		while (n < sz) n *= 2;
		node.resize(2 * n - 1, INT_MAX); // UNITY
	}
	T merge(T a, T b) { // NEED TO EDIT
		return min(a, b);
	}
	void set(int p, T v) {
		p += n - 1;
		node[p] = v;
		while (p) {
			p = (p - 1) / 2;
			node[p] = merge(node[p * 2 + 1], node[p * 2 + 2]);
		}
	}
	T get(int a, int b, int k = 0, int l = 0, int r = -1) {
		if (r < 0) r = n;
		if (b <= l || r <= a) {
			return INT_MAX; // UNITY
		}
		if (a <= l && r <= b) {
			return node[k];
		}
		return merge(get(a, b, k * 2 + 1, l, (l + r) / 2),
					 get(a, b, k * 2 + 2, (l + r) / 2, r));
	}
};

signed main()
{
	int n, q;
	cin >> n >> q;
	Segtree<int> seg(n);
	while (q--) {
		int c, a, b;
		cin >> c >> a >> b;
		if (c == 0) seg.set(a, b);
		else cout << seg.get(a, b + 1) << endl;
	}
}



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

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

	int ma = 0;
	for( int i = 0; i < N - 1; i++ ) {
		 ma = max(ma,  A[i + 1] - A[i] );
	}
	ma = max( ma, K - A[N - 1] + A[0] );
	int ans = K - ma;

	cout << ans << endl;
}


Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using static System.Console;

class Program {
	static void Main() {
		var N = NextInt();
		var K = NextInt();
		var l = new int[N];
		for (var i = 0; i < N; i++) {
			l[i] = NextInt();
		}
		Array.Sort(l);
		Array.Reverse(l);
		var ans = 0;
		for (var i = 0; i < K; i++) {
			ans += l[i];
		}
		WriteLine(ans);
	}

	static int NextInt() {
		return int.Parse(NextString());
	}

	static string NextString() {
		var result = new List<char>();
		while (true) {
			int next = Read();
			if (next < 0)
				break;
			var nextChar = (char)next;
			if (!char.IsWhiteSpace(nextChar))
				result.Add(nextChar);
			else if (nextChar != '\r')
				break;
		}
		return string.Join("", result);
	}
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
#include <string>
  
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)
typedef long long ll;

const ll MOD=1000000007ll;
const int MAX=5100000;

using namespace std;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    rep(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}

ll fact[MAX], fact_inv[MAX];

ll power(ll a, ll b){
	ll res=1;
	while(b>0){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		b>>=1;
	}
	return res;
}

// nCr
ll comb(ll n, ll r){
	ll t=1000000;
	fact[0]=1;
	REP(i, t) fact[i+1]=fact[i]*(i+1)%MOD;
	fact_inv[t]=power(fact[t], MOD-2);
	FORR(i, 0, t) fact_inv[i]=fact_inv[i+1]*(i+1)%MOD;
	return (fact[n]*fact_inv[r])%MOD*fact_inv[n-r]%MOD;
}
  
int main()
{
  int N,K,i,ans=0; cin >> N >> K;
  vector <int>X(N,0); rep(i,N){cin >> X[i];}

  rep(i,N){
      ans += min(X[i], K - X[i]) * 2;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3636
class UnionFind(object):
    def __init__(self, n):
        self.par = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]
        self._size = n

    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x != y:
            self._size -= 1
            if self.rank[x] < self.rank[y]:
                x, y = y, x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self.par[y] = x

    def is_same(self, x, y):
        return self.find(x) == self.find(y)

    def size(self):
        return self._size

N, M = map(int, input().split())
a, b = [0] * M, [0] * M
for i in range(M):
    a[i], b[i] = map(int, input().split())

ans = 0
for i in range(M):
    uf = UnionFind(n=N)
    for j in range(M):
        if j == i:
            continue
        uf.union(a[j]-1, b[j]-1)
    if uf.size() != 1:
        ans += 1
print(ans)

Measured memory_bytes: 3064
import java.util.*;

public class Main{
  public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    
    String A = sc.next();
    int start = Integer.parseInt(A);
    String B = sc.next();
    int end = Integer.parseInt(B);
    int count = 0;
    
    for(int i = start; i <= end; i++){
      String judge = Integer.toString(i);
      if(judge.charAt(0) == judge.charAt(4) && judge.charAt(1) == judge.charAt(3)){
        count++;
      }
    }
    
    System.out.println(count);
  }
}

      

Measured memory_bytes: 26324
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
void init(){
  cin.tie(0);
  ios::sync_with_stdio(false);
}


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

  cout<<n*(n-1)/2-n/2<<endl;

  FOR(i,1,n+1){
    FOR(j,i+1,n+1){
      if(i+j==n+!(n%2)) continue;
      cout<<i<<' '<<j<<endl;
    }
  }


}


Measured memory_bytes: 384
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<bitset>
#include<queue>
#include<set>
#include<map>
using namespace std;
 
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define ROF(i,b,a) for (int i=(b);i>(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,n-1,-1)
 
typedef int i32;
typedef long long int i64;
typedef unsigned long long int ui64;
typedef float f32;
typedef double f64;
typedef long double f128;
typedef pair<int,int> Pi;
 
constexpr int INF = 1e9 + 7;
constexpr int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};
 
int main() {
    int a,b,c; cin>>a>>b>>c;
    cout<<a*b/2<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <climits>
#include <cmath>
#include <math.h>
#include <unordered_map>
#include <unordered_set>
//#define local
#ifdef local
#include "dbg-macro/dbg.h"
#endif
//#define hacks
#ifdef hacks
#include <boost/multiprecision/cpp_int.hpp>
#endif
#define p std::pair
#define ll long long
#define ull unsigned long long
#define pi (acos(-1))
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (unsigned long long i = 0; i < (unsigned long long)(n); ++i)
#define vec std::vector
#define oreq |=
using namespace std;
std::vector<unsigned ll> genprimevec(const unsigned ll N);
ll extgcd(ll a, ll b, ll &x, ll &y);
ll nCr(ll n, ll r);
void stat();
constexpr ll mod = 1000000000 + 7;
int main()
{
    stat();
    unordered_set<int> s;
    rep(i,3){
int x;cin>>x;s.insert(x);
    }
    cout<<s.size()<<endl;
    return 0;
}
ll extgcd(ll a, ll b, ll &x, ll &y)
{
    if (b == 0)
    {
        x = 1, y = 0;
        return a;
    }
    ll d = extgcd(b, a % b, y, x);
    y -= a / b * x;
    return d;
}


std::vector<unsigned ll> genprimevec(const unsigned ll N)
{
    std::vector<bool> is_prime(N + 1);
    for (unsigned ll i = 0; i <= N; i++) { is_prime[i] = true; }
    std::vector<unsigned ll> P;
    for (unsigned ll i = 2; i <= N; i++)
    {
        if (is_prime[i])
        {
            for (unsigned ll j = 2 * i; j <= N; j += i) { is_prime[j] = false; }
            P.emplace_back(i);
        }
    }
    return P;
}

void stat() {
#ifdef local
    rep(i, 2) {std::cout << "local enable" << std::endl;
}
#endif
#ifdef hacks
rep(i, 2) { std::cout << "boost enable" << std::endl; }
#endif
}

ll nCr(ll n, ll r)
{
    ll num = 1;
    for (ll i = 1; i <= r; i++) { num = num * (n - i + 1) / i; }
    return num;
}


Measured memory_bytes: 3504
N = int(input())
A = list(map(int, input().split()))

cnt = 0
for i in range(N):
	if A[i]<0:
		A[i] = -A[i]
		cnt = (cnt+1)%2

if 0 in A:
	print(sum(A))
elif cnt==0:
	print(sum(A))
else:
	print(sum(A)-min(A)*2)


Measured memory_bytes: 14284
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef double db;
typedef vector <ll> vll;
typedef pair <ll, ll> pll;
#define pb push_back
#define mp make_pair
#define MAX 1000000
#define mod 1000000007
#define all(_) _.begin(), _.end()
#define F first
#define S second
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

int main()
{
	ios_base :: sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);
	ll n, i, k;
	cin >> n;
	vector <vll> a(n), dp(n);
	for(i = 0; i < n; i++)
	{
		a[i].resize(3);
		dp[i].resize(3);
		for(ll j = 0; j < 3; j++)
			cin >> a[i][j];
	}
	for(i = 0; i < 3; i++)
		dp[0][i] = a[0][i];
	for(i = 1; i < n; i++)
	{
		for(ll j = 0; j < 3; j++)
			for(ll k = 0; k < 3; k++)
				if(j != k)
					dp[i][j] = max(dp[i][j], dp[i - 1][k] + a[i][j]);
	}
	cout << max({dp[n - 1][0], dp[n - 1][1], dp[n - 1][2]}) << endl;
	return 0;
}

Measured memory_bytes: 11264
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define MAXN 8
char M[MAXN+5][MAXN+5];
int cnt,x=1,y=1;
int main(){
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=n;i++){
        getchar();
        for(int j=1;j<=m;j++){
            cin>>M[i][j];
            if(M[i][j]=='#') cnt++;
        }
    }
    for(int i=1;i<cnt;i++){
        if(M[x+1][y]=='#') x++;
        else if(M[x][y+1]=='#') y++;
        else {
            cout<<"Impossible"<<endl;
            return 0;
        }
    }
    cout<<"Possible"<<endl;
    return 0;
}

Measured memory_bytes: 256
N, K, Q = map(int, input().split())

point = [K - Q] * N
for _ in range(0, Q, 1):
	A = int(input()) - 1
	point[A] += 1

for i in point:
	if i <= 0 :
		print("No\n")
	else :
		print("Yes\n")

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

int main(void) {
	int A, B, C, K;
	scanf("%d %d %d %d", &A, &B, &C, &K);
	int ans = 0;
	ans = min(A, K) - max(K - A - B, 0);
	printf("%d", ans);

	return 0;
}


Measured memory_bytes: 3760
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
const int N=1e5+5;
int a[N],n,k,q,x;
int main(){
	scanf("%d%d%d",&n,&k,&q);
	fp(i,1,q)scanf("%d",&x),++a[x];
	fp(i,1,n)puts(k-(q-a[i])>0?"Yes":"No");
	return 0;
}

Measured memory_bytes: 1024
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#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 rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define uni(e) e.erase(unique(e.begin(),e.end()),e.end())
#define double long double
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; }
int INF=1e10;
int MOD=1e9+7;
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
}
int gcd(int a,int b){
  if(a%b==0)
    return b;
  return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool sosuu(int a){
  bool b=1;
  if(a<=1)
    return 0;
  else{
  rep1(i,sqrt(a)-1){
  if(a%(i+1)==0)
  b=0;
  }
  return b;
  }
}
int modpow(int a,int b,int m=MOD){
	if(!b)return 1;	if(b&1)return modpow(a,b-1,m)*a%m;
	int memo = modpow(a,b>>1,m);
	return memo*memo%m;
}
int fact_mod(int n) {
    int f=1; 
for(int i=2;i<n+1;i++) f=f*(i%MOD)% MOD;
    return f;
}
int mod_pow(int x,int n) {
    int res=1;
    while(n>0){
        if(n&1) res=(res*x)%MOD; 
        x=(x*x)%MOD;        
n>>=1; 
    }
    return res;
}
int c_mod(int n, int r) {
    if(r>n-r) r=n-r;
    if(r==0) return 1;
    int a=1;
    rep(i,r) 
a=a*((n-i)%MOD)%MOD;
    int b=mod_pow(fact_mod(r), MOD-2);
    return (a%MOD)*(b%MOD)%MOD;
}
signed main(){
  int a;
  cin>>a;
  vector<int> b(a);
  rep(i,a)
    cin>>b[i];
  sort(all(b));
  int c=0;
  rep(i,a-1)
    c+=b[i];
  YesNo(b[a-1]<c);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define int long long
#define sz(x) (int)x.size()
#define mp make_pair
#define fi first
#define se second
#define io ios_base::sync_with_stdio(false),cin.tie(NULL)
using namespace std;



signed main()
{
	int n;
	cin >> n;
	int a[n];
	rep(i,0,n) cin >> a[i];

	int dp[n];
	dp[n-1] = 0;

	for(int i=n-2;i>=0;i--)
	{
		dp[i] = (a[i+1] + dp[i+1])%hell;
	}
	int ans = 0;
	rep(i,0,n)
	{
		ans = (ans%hell+(a[i]%hell*dp[i]%hell)%hell)%hell;

	}
	cout << ans <<endl;


}
 
	
		



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

using namespace std;

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

	if (n == 1) {
		cout << "Yes" << endl;

		return 0;
	}

	int max = v[0];
	for (int i = 1; i < n; i++) {
		if (max - v[i] >= 2) {
			cout << "No" << endl;

			return 0;
		}
		if (max < v[i]) {
			max = v[i];
		}
	}
	cout << "Yes" << endl;

	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define MEM(x,v) memset(x,v,sizeof(x))
#define MEC(x,y) memcpy(x,y,sizeof(x))
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
const int M=1e5+5;
template <class T>
inline void Rd(T &p){
	p=0;char c;
	while(c=getchar(),c<48);
	do p=p*10+(c&15);
	while(c=getchar(),c>47);
}
template <class T>
inline void pfn(T p,bool f=true){
	if(p<0)putchar('-'),p=-p;
	else if(p==0)putchar('0');
	static int num[100],tot;
	while(p){num[++tot]=p%10;p/=10;}
	while(tot)putchar(num[tot--]^'0');
	putchar(f?'\n':' ');
}
template <class T>
inline void Max(T &a,T b){if(a<b)a=b;}
template <class T>
inline void Chk(T &a,T b){if(!~b&&(!~a||a>b))a=b;}
deque<int>deq;
int n,w; 
int main(){
	Rd(n);
	int op=1;
	for(int i=1;i<=n;++i){
		Rd(w);
		if(op){deq.push_back(w),op^=1;}
		else deq.push_front(w),op^=1;
	}
	if(op){
		while(!deq.empty()){
			pfn(deq.front(),0);
			deq.pop_front();
		}
		puts("");
	}else{
		while(!deq.empty()){
			pfn(deq.back(),0);
			deq.pop_back();
		}
		puts("");
	}
}


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

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main()
{
  int A, B;
  cin >> A >> B;
  if (A <= 5)
    cout << 0 << endl;
  else if (A <= 12)
    cout << B / 2 << endl;
  else
    cout << B << endl;
  return 0;
}

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

#define inf 0x3f3f3f3f
#define mod 1000000007
#define endl '\n'
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define all(cc) (cc).begin(),(cc).end()
using pii = pair<int, int> ;
using vi = vector<int> ;
using vb = vector<bool> ;
using vvi = vector<vector<int>> ;
using vlli = vector<long long int> ;
using vpii = vector<pair<int, int>> ;

int main()
  {
    ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
    long long int l, r, n, a, b ;
    cin>> n >> a >> b ;
    if(b<a || (n==1 && b>a))
      {
        cout<< 0 ;
        return 0 ;
      }
    l=(n-1)*a + b ;
    r=(n-1)*b + a ;
    cout<< r-l+1 ;
  }


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#define ll long long
#define INF 1e+18
#define MOD 1000000007
using namespace std;



int main(){
    int N,K;
    cin >> N >> K;
    
    if(N >= 2*K-1){
        cout<<"YES"<<endl;
        
    }else{
        cout << "NO"<<endl;
    }
    return 0;
}


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

int main()
{
	int h,k,w;
	cin>>h>>w>>k;
	char inp[h+10][w+10];
	set<int> row[h+10],col[w+10];
	int x1,x2,y1,y2;
	cin>>x1>>y1>>x2>>y2;
	for(int i=1;i<=h;i++)
		for(int j=1;j<=w;j++)
		{
			cin>>inp[i][j];
			row[i].insert(j);
			col[j].insert(i);
		}
	int dis[h+10][w+10]={0},vis[h+10][w+10]={0};
	memset(dis,-1,sizeof(dis));
	queue<pair<int,int>>q;
	//if(inp[x1][y1]=='.')
	{
		q.push(make_pair(x1,y1));
		dis[x1][y1]=0;
		row[x1].erase(y1);
		col[y1].erase(x1);
	}
	while(!q.empty())
	{
		auto it=q.front();
		q.pop();
		int i=it.first,j=it.second;
		//cout<<i<<" "<<j<<"\n";
		auto jt=row[i].lower_bound(j);
		vector<int> te;
		while(jt!=row[i].end())
		{
			if(*jt-j>k||inp[i][*jt]!='.')
				break;
			dis[i][*jt]=dis[i][j]+1;
			q.push(make_pair(i,*jt));
			te.push_back(*jt);
			jt++;
		}
		jt=row[i].lower_bound(j);
		if(jt!=row[i].begin())
		{
			jt--;
			while(1)
			{
				if(j-*jt>k||inp[i][*jt]!='.')
					break;
				dis[i][*jt]=dis[i][j]+1;
				q.push(make_pair(i,*jt));
				te.push_back(*jt);
				if(jt==row[i].begin())
					break;
				jt--;
			}
		}
		for(auto x:te)
		{
			row[i].erase(x);
			if(col[x].find(i)!=col[x].end())
				col[x].erase(i);
		}
		auto kt=col[j].lower_bound(i);
		te.clear();
		while(kt!=col[j].end())
		{
			if(*kt-i>k||inp[*kt][j]!='.')
				break;
			dis[*kt][j]=dis[i][j]+1;
			q.push(make_pair(*kt,j));
			te.push_back(*kt);
			kt++;
		}
		kt=col[j].lower_bound(i);
		if(kt!=col[j].begin())
		{
			kt--;
			while(col[j].size()>1)
			{
				if(i-*kt>k||inp[*kt][j]!='.')
					break;
				dis[*kt][j]=dis[i][j]+1;
				q.push(make_pair(*kt,j));
				te.push_back(*kt);
				if(kt==col[j].begin())
					break;
				kt--;
			}
		}
		for(auto x:te)
		{ 
			col[j].erase(x);
			if(row[x].find(j)!=row[x].end())
				row[x].erase(j);
		}		
	}
	//cout<<row[3].size()<<" ";
	cout<<dis[x2][y2];
}



Measured memory_bytes: 227280
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define M 1000005



int main(){
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    
    int n, k;
    cin >> n >> k;
    cout << n - k + 1;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstdio>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include <set>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> P;
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
const int MAXN = 100000;
const int MAXE = 100000;
const int MAXV = 10000;
const int inf = 1e9;
const ll INF = 2e18;
const ll MOD = 1e9 + 7;

struct UnionFind{
    vector<int> par,rank;
    UnionFind(int n):par(n),rank(n){
        for(int i=0;i<n;++i) par[i]=i;
    }
    int root(int x){
        if(par[x]==x) return x;
        return par[x]=root(par[x]);
    }
    void unite(int x,int y){
        int rx=root(x),ry=root(y);
        if(rx==ry) return ;
        if(rank[ry]>rank[rx]) par[rx]=ry;
        else par[ry]=rx;
        if(rank[rx]==rank[ry]) rank[rx]++;
    }
    bool same(int x,int y){
        return root(x)==root(y);
    }
};

vector<ll> fac,inv,finv;

void initcom(){
    fac=inv=finv=vector<ll>(1e6);
    fac[0]=fac[1]=1;
    inv[1]=1;
    finv[0]=finv[1]=1;
    for(ll i=2;i<1e6;++i){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}

ll com(int n,int k){
    if(n<0||k<0) return 0;
    if(n<k) return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
ll gcd(ll x,ll y){
    if(y==0) return x;
    return gcd(y,x%y);
}
ll mopow(ll a,ll x,ll mod){
    ll res=1;
    while(x>0){
        if(x&1) res=res*a%mod;
        a=a*a%mod;
        x>>=1;
    }
    return res;
}
int main(){
    int n;cin>>n;
    vector<int> a(n);
    for(int i=0;i<n;++i) cin>>a[i];
    string ans="second";
    for(int i=0;i<n;++i)if(a[i]%2==1) ans="first";
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3760