akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class Program
{
    void Calc()
    {
        var sc = new Scanner();
        int A = sc.NextInt();
        int a = A;
        int B = sc.NextInt();
        int b = B;
        int C = sc.NextInt();
        int r = 0;
        r = A % B;
        while (r != 0)
        {
            A = B;
            B = r;
            r = A % B;
        }
        int d = (a * b) / B;
        bool check = false;
        for (int i = 0; i < (d / a); i++)
        {
            int nnn = (i * a) % b;
            if (nnn<0)
            {
                nnn += d;
            }
            if (nnn == C)
            {
                check = true;
                break;
            }
        }
        if (a == 1)
        {
            check = true;
        }
        if (check == true)
        {
            Console.WriteLine("YES");
        }
        else
        {
            Console.WriteLine("NO");
        }
    }
    static void Main()
    {
        new Program().Calc();
    }

    class Scanner
    {
        string[] s = new string[0];
        int i = 0;
        char[] cs = new char[] { ' ' };

        public string Next()
        {
            if (i < s.Length) return s[i++];
            s = Console.ReadLine().Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return s[i++];
        }
        public int NextInt() { return int.Parse(Next()); }
        public long NextLong() { return long.Parse(Next()); }
        public double NextDouble() { return double.Parse(Next()); }
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

ll gcd(ll x, ll y) {
    if (x < y) swap(x, y);
    if (y == 0) return x;
    return gcd(x % y, y);
}
ll lcm(ll x, ll y) {
    return x / gcd(x, y) * y;
}

int main() {
    int n;
    ll m;
    cin >> n >> m;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    sort(all(a));
    get_unique(a);
    int two = -1;
    ll l = 1;
    rep(i, n) {
        ll b = a[i];
        int now = 0;
        while (b % 2 == 0) {
            b /= 2;
            now++;
        }
        if (two == -1)
            two = now;
        else if (two != now) {
            cout << 0 << endl;
            return 0;
        }
        l = lcm(l, a[i] / 2);
        if (l > m) {
            cout << 0 << endl;
            return 0;
        }
    }

    m /= l;
    cout << (m + 1) / 2 << endl;
}

Measured memory_bytes: 1024
def resolve():
    N = int(input())
    p = list(map(int, input().split()))
    cnt = 1
    min_v = p[0]
    for i in range(1, len(p)):
        if p[i] < min_v:
            min_v = p[i]
            cnt += 1
    print(cnt)

resolve()

Measured memory_bytes: 75472
// https://atcoder.jp/contests/abc157/tasks/abc157_b
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    vector<vector<int>> A(3, vector<int>(3));
    vector<vector<bool>> C(3, vector<bool>(3));
    REP(i, 3) REP(j, 3) { cin >> A[i][j]; }
    int N;
    cin >> N;
    REP(i, N) {
        int t;
        cin >> t;
        REP(j, 3) REP(k, 3) {
            if (A[j][k] == t) {
                C[j][k] = true;
            }
        }
    }
    // 判定
    bool flag = false;
    REP(i, 3) {
        if (C[i][0] && C[i][1] && C[i][2]) {
            flag = true;
        }
        if (C[0][i] && C[1][i] && C[2][i]) {
            flag = true;
        }
    }
    if (C[0][0] && C[1][1] && C[2][2]) {
        flag = true;
    }
    if (C[0][2] && C[1][1] && C[2][0]) {
        flag = true;
    }
    if (flag) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }

    return 0;
}


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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define show(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define show(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
template<typename T> using vec=std::vector<T>;

const int inf=1<<30;
const long long int infll=1LL<<62;
const double eps=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

void solve(){
    int n;
    cin >> n;
    vector<int> h(n),w(n);
    vector<vector<int>> c(4,vector<int>(4));
    rep(i,0,n) cin >> h[i] >> w[i];
    rep(i,0,4) rep(j,0,4){
        char tmp;
        cin >> tmp;
        if(tmp=='R') c[i][j]=0;
        if(tmp=='G') c[i][j]=1;
        if(tmp=='B') c[i][j]=2;
    }

    bool flag[4][4][5][5][3];
    fill_n((bool*)flag,4*4*5*5*3,false);
    rep(y1,0,4) rep(x1,0,4) rep(y2,y1+1,5) rep(x2,x1+1,5) rep(y,y1,y2) rep(x,x1,x2) flag[y1][x1][y2][x2][c[y][x]]=true;

    auto encode=[](const bitset<16> &bs){
        int res=0;
        rep(i,0,16) if(bs[i]) res|=1<<i;
        return res;
    };

    vector<int> cost(1<<16,inf);
    queue<int> que;
    cost[0]=0;
    que.push(0);
    while(!que.empty()){
        auto state=que.front();
        que.pop();
        if(state==(1<<16)-1){
            cout << cost[state] << endl;
            return;
        }
        rep(i,0,n) rep(y,-h[i]+1,4) rep(x,-w[i]+1,4){
            int y1=max(0,y),x1=max(0,x),y2=min(4,y+h[i]),x2=min(4,x+w[i]);
            rep(j,0,3){
                if(!flag[y1][x1][y2][x2][j]) continue;
                auto next_state=state;
                rep(y_,y1,y2) rep(x_,x1,x2){
                    if(c[y_][x_]==j) next_state|=1<<(4*y_+x_);
                    else next_state&=~(1<<(4*y_+x_));
                }
                if(cost[next_state]!=inf) continue;
                cost[next_state]=cost[state]+1;
                que.push(next_state);
            }
        }
    }
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    solve();
    return 0;
}

Measured memory_bytes: 3428
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def printlist(lst, k='\n'): return k.join(list(map(str, lst)))
INF = float('inf')

def mcomb(n, k, mod):
    def mfac(l, r, mod):
        ans = l
        for i in reversed(range(r, l)):
            ans *= i
            ans %= mod
        return ans

    A = mfac(n,n-k+1,mod)
    B = mfac(k,1,mod)
    # B = mpow(B,mod-2,mod)
    B = pow(B, mod-2, mod)
    return A * B % mod

def solve():
    x, y = MI()
    if (x + y) % 3 != 0:
        print(0)
        return

    n = (x + y) // 3
    x -= n
    y -= n
    if x < 0 or y < 0:
        print(0)
        return

    mod = 1000000007
    ans = mcomb(x+y, max(x, y), mod)
    print(ans % mod)

if __name__ == '__main__':
    solve()


Measured memory_bytes: 3188
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ProconTemplate
{
    class Doing
    {
        public class Jewel
        {
            public int Value { get; set; }
            public int Cost { get; set; }
            public int Profit => Value - Cost;
        }


        public static void Main(string[] args)
        {
            // Drop
            Console.ReadLine();
            var valueList = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var costList = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

            var jewelList = new List<Jewel>();
            for(int index = 0; index < valueList.Length; index++)
            {
                jewelList.Add(new Jewel() { Value = valueList[index], Cost = costList[index] });
            }

            Console.WriteLine(jewelList.Where(x => x.Profit > 0).Sum(x => x.Profit));
        }
    }
}


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

#define Q int t; scanf("%d", &t); for(int q=1; q<=t; q++)
typedef unsigned long long int lli;
typedef pair<int, int> pi;

int main()
{
    int k, n, i;
    cin >> k >> n;
    int a[n+1];
    for(i=0; i<n; i++){
        cin >> a[i];
    }
    a[n] = a[0]+k;
    int mx = 0;
    for(i=1; i<=n; i++){
        mx = max(mx, a[i]-a[i-1]);
    }
    cout << k-mx << "\n";

    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    long long a[201],sum=0;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    bool masatoy=true;
    while(masatoy==true){
        for(int i=0;i<n;i++){
            if(a[i]%2!=0)masatoy=false;
        }
        if(masatoy==true){
            for(int i=0;i<n;i++){
                a[i]/=2;
            }
            sum++;
        }
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const long long MOD = 1e9+7;
#define rep(i,n) for(int i=0;i<n;++i)
typedef long long int ll;
typedef unsigned long long ull;
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;}
typedef pair<ll,ll> P;


int main()
{
    ll n;
    cin>>n;
    ll cnt=0;
    string ans="";
    while(n>0)
    {
        ll a = n/pow(26,cnt);
        a %=26;
        
        if(a==0){
            ans+='z';
            n-=(ll)pow(26,cnt)*26;
        }
        else {
            
            ans += (char)('a'+a-1);
            n-=(ll)pow(26,cnt)*a;
        }
       // cout<<a<<endl;
        cnt++;
    }
    reverse(ans.begin(),ans.end());
    cout<<ans<<endl;
    return 0; 
}


Measured memory_bytes: 4092
// clang-format off
#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()
 
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S &s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
// clang-format on

ll a, b, n;

int main() {
    fastio();

    cin >> n >> a >> b;

    cout << (n / (a + b)) * a + min(a, (n % (a + b))) << endl;

    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")

// #define _GLIBCXX_DEBUG

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

#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
// #define NP next_permutation;
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
// typedef multiset<ll> S;
typedef priority_queue<ll> PQ;
typedef priority_queue<P,vector<P>,greater<P>> SPQ;
using vi=vector<ll>;
using vvi=vector<vi>;
// using vvvi=vector<vvi>;
/*
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double pi=3.14159265358979323846;
*/
template<class T> bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
// template<class T> void decimal(T a){cout<<fixed<<setprecision(a);}
template<class T> void out(T a){cout<<a<<endl;}
/*
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<endl;}
template<class T> void outvp(T v){rep(i,v.size())outp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<endl;}
template<class T> void outvv(T v){rep(i,v.size()){rep(j,v[i].size()){if(j)cout<<' ';cout<<v[i][j];}cout<<endl;}}

void YesNo(bool a){if(a) out("Yes"); else out("No");}
void yesno(bool a){if(a) out("yes"); else out("no");}
void YESNO(bool a){if(a) out("YES"); else out("NO");}
ll GCD(ll a,ll b){ll c; while(b!=0){c=a%b; a=b; b=c;} return a;}
ll LCM(ll a,ll b){return(a/GCD(a,b))*(b/GCD(a,b))*GCD(a,b);}
ll POW(ll a,ll b){ll c=1; while(b>0){if(b&1){c=a * c%mod;} a=a * a%mod; b>>=1;} return c;}
vi calc(ll x){vi res; while(x>0){res.eb(x%10); x/=10;} reverse(all(res)); return res;}
*/
void solve() {
  string S; cin>>S;
  rep(i,(ll)S.size()) cout<<"x";
  cout<<endl;
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<queue>
#include<vector>
#include<string.h>
#include<algorithm>
#include<cmath>
#include<map>

using namespace std;

long long i,j,k,N;
double x,y;

vector<long long>A;

int main()
{
  cin>>N;
  
  for(i=0;i<N;i++)
  {
    cin>>j;
    A.push_back(j);
  }
  
  sort(A.begin(),A.end());
  
  if(A[0]==0)
  {
    cout<<"0";
    return 0;
  }
  

    j=1;
    for(i=0;i<N;i++)
    {
      k=j*A[i];
      
      if(k>1000000000000000000 || k<j)
      {
        cout<<"-1";
        return 0;
      }
      j=k;
      
    }
    
  cout<<j;
  
  
}

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

int gcd(int a,int b){
	if(a==0)
	return b;
	if(b==0)
	return a;
	if(a==b)
	return a;
	if(a>b)
	return gcd(a-b,b);
	return gcd(a,b-a);
}

int GCD(int a,int b){
	if(a==0)
	return b;
	if(b==0)
	return a;
	if(a==b)
	return a;
	return GCD(b,a%b);
}

int main(){
	ll n;
	cin>>n;
	vector<ll>v;
	for(ll i=0;i<n;i++){
		ll x;
		cin>>x;
		v.push_back(x);
	}
	sort(v.begin(),v.end());
	reverse(v.begin(),v.end());
	ll ans=0;
	for(int i=1;i<n;i++){
		ans+=v[i/2];
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 5360
N = int(input())
h = list(map(int,input().split()))
DP = [10**9]*N
DP[0] = 0
DP[1] = abs(h[1]-h[0])
for i in range(2,N):
    DP[i] = min(DP[i],DP[i-2]+abs(h[i]-h[i-2]))    
    DP[i] = min(DP[i],DP[i-1]+abs(h[i]-h[i-1])) 
    
print(DP[-1])

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

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

using namespace std;

int main(){
	int h,w; scanf("%d%d",&h,&w);

	int cnt=0;
	rep(i,h){
		char s[9]; scanf("%s",s);
		cnt+=count(s,s+w,'#');
	}
	puts(cnt==h+w-1?"Possible":"Impossible");

	return 0;
}


Measured memory_bytes: 256
macro_rules! scan_sub {
    ( $itr:ident, $t:ty ) => {
        let mut buf = String::new();
        let $itr = {
            while buf.trim().len() == 0 {
                buf = String::new();
                std::io::stdin().read_line(&mut buf).unwrap();
            }
            buf.split_whitespace().map(|n| n.parse::<$t>().unwrap())
        };
    };
}

macro_rules! scan {
    ( $x:ident; Vec<$t:ty> ) => {
        scan_sub!(itr, $t);
        let $x = itr.collect::<Vec<_>>();
    };
    ( $( $x:ident ),*; $t:ty ) => {
        scan_sub!(itr, $t);
        let mut itr = itr;
        $(
            let $x = itr.next().unwrap();
        )*
    };
}

fn main() {
    scan!(n; usize);

    let res = (1..n+1)
        .filter(|&i| i % 3 != 0 && i % 5 != 0)
        .sum::<usize>();

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


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

#define fast ios::sync_with_stdio(false);cin.tie(0); cout.tie(0)

typedef long long ll;

ll n,m,k;
ll a,b;
ll arr[100001];

int main() {
    fast;
    cin >> n;
    map<ll,ll> s;
    for (int i = 0; i < n; i++) {
        cin >> a;
        s[a]++;
    }
    for(auto v : s){
        if(v.second&1) m++;
    }
    cout << m << endl;
    return 0;
}

Measured memory_bytes: 6528
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-9, pi = acos(-1.0);
namespace std {
    bool operator<(const Point &lhs, const Point &rhs) {
        if (lhs.real() < rhs.real() - eps) return true;
        if (lhs.real() > rhs.real() + eps) return false;
        return lhs.imag() < rhs.imag();
    }
}
ld solve(){
    ld res = LINF;
    ll N; cin >> N;
    vector<Point> ps(N);
    for(int i = 0; i < N;i++){
        ld x,y; cin >> x >> y;
        ps[i] = Point(x,y);
    }
    
    sort(ps.begin(),ps.end());
    
    // ==== Bitonic-TSP === //
    vector<vector<ld> > L(N, vector<ld>(N, 0.0));
    for (int j = 1; j < N; j++) {
        for (int i = 0; i < j; i++) {
            if (i == 0 && j == 1) {
                L[i][j] = abs(ps[i]-ps[j]);
            } else if (i < j - 1) {
                L[i][j] = L[i][j-1] + abs(ps[j-1]-ps[j]);
            } else {
                L[i][j] = LINF;
                for (int k = 0; k < i; k++)
                    L[i][j] = min(L[i][j], L[k][i] + abs(ps[k]-ps[j]));
            }
        }
    }
    
    res = LINF;
    for (int k = 0; k < N-1; k++)
        res = min(res, L[k][N-1] + abs(ps[k]-ps[N-1]));

    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(12) << solve() << endl;
    return 0;
}



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

typedef long long ll;
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    vector<int> graph(N + 1);
    vector<pair<int, int>> e(N - 1);
    map<pair<int, int>, int> m;
    for (int i = 0; i < N - 1; i++) {
        int a, b;
        cin >> a >> b;
        graph[a]++;
        graph[b]++;
        e[i] = { a, b };
        m.insert({ make_pair(a, b), i });
    }
    int colorNum = -1;
    for (int i = 1; i <= N; i++) {
        colorNum = max(colorNum, graph[i]);
    }
    cout << colorNum << endl;
    vector<int> ans(N - 1);
    vector<vector<bool>> colors(N + 1, vector<bool>(colorNum + 1, false));
    for (auto &mm: m) {
        pair<int, int> p = mm.first;
        int v = mm.second;
        for (int k = 1; k <= colorNum; k++) {
            if (!colors[p.first][k] && !colors[p.second][k]) {
                colors[p.first][k] = true;
                colors[p.second][k] = true;
                ans[v] = k;
                break;
            }
        }
    }
    for (auto &v : ans) cout << v << endl;
    return 0;
}


Measured memory_bytes: 316544
#include "bits/stdc++.h"
#define ll long long
#define inf 1000000007 //10^9+7
#define sort(vec) sort((vec).begin(),(vec).end());
#define rever(vec) reverse((vec).begin(),(vec).end());
#define unsort(vec) sort((vec)); rever((vec));
using namespace std;

int main() {
  int a;
  cin>>a;
  if(a==5||a==7||a==3) {
    cout<<"YES"<<endl;
  }
  else {
    cout<<"NO"<<endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int mgcd(int a,int b){
	if(b==0)return a;
  else return mgcd(b,a%b);
}
int main(){
	int n,x;cin>>n>>x;
  vector<int >nos(n,0);
  for(int i=0,a;i<n;i++){cin>>a;nos[i]=abs(x-a);}
  int gcd = nos[0];
  for(int i=1;i<n;i++){
  	gcd = mgcd(gcd,nos[i]);
  }
  cout<<gcd;
}

Measured memory_bytes: 3724
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Main dice = new Main(sc);
		sc.nextLine();
		String[] lines = sc.nextLine().split("");

		for(int i = 0;i < lines.length;i++) {
			if(lines[i].equals("N")) {
				dice.goNorth();
			} else if(lines[i].equals("S")) {
				dice.goSouth();
			} else if(lines[i].equals("E")) {
				dice.goEast();
			} else if(lines[i].equals("W")){
				dice.goWest();
			}
		}

		System.out.println(dice.getTop());


	}

	int top;
	int south;
	int east;
	int west;
	int north;
	int bottom;


	public Main(Scanner sc) {
		this.top = sc.nextInt();
		this.south = sc.nextInt();
		this.east = sc.nextInt();
		this.west = sc.nextInt();
		this.north = sc.nextInt();
		this.bottom = sc.nextInt();
	}

	public void goNorth() {
		int t = this.top;
		int s = this.south;
		int e = this.east;
		int w = this.west;
		int n = this.north;
		int b = this.bottom;

		this.top = s;
		this.south = b;
		this.north = t;
		this.bottom = n;
	}

	public void goSouth() {
		int t = this.top;
		int s = this.south;
		int e = this.east;
		int w = this.west;
		int n = this.north;
		int b = this.bottom;

		this.top = n;
		this.south = t;
		this.north = b;
		this.bottom = s;
	}

	public void goEast() {
		int t = this.top;
		int s = this.south;
		int e = this.east;
		int w = this.west;
		int n = this.north;
		int b = this.bottom;

		this.top = w;
		this.east = t;
		this.west = b;
		this.bottom = e;
	}

	public void goWest() {
		int t = this.top;
		int s = this.south;
		int e = this.east;
		int w = this.west;
		int n = this.north;
		int b = this.bottom;

		this.top = e;
		this.east = b;
		this.west = t;
		this.bottom = w;
	}

	public int getTop() {
		return this.top;
	}
}

Measured memory_bytes: 26212
//https://atcoder.jp/contests/abc127/tasks/abc127_b
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
// clang-format on
int main()
{
    int r, D, x;
    cin >> r >> D >> x;
    vector<int> v(11);
    v[0] = r * x - D;
    for (int i = 1; i < 11; ++i)
    {
        cout << v[i - 1] << endl;
        v[i] += r * v[i - 1] - D;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    string s; cin >> s;
    bool ok = false;
    if (s[0] == s[1] && s[1] == s[2]) ok = true;
    if (s[1] == s[2] && s[2] == s[3]) ok = true;
    printf(ok?"Yes\n":"No\n");
}

Measured memory_bytes: 256
from math import log2


def build():
    dfs()
    pk0 = parent[0]
    for pk1 in parent[1:]:
        for v in range(n):
            pkv = pk0[v]
            pk1[v] = -1 if pkv < 0 else pk0[pkv]
        pk0 = pk1


def dfs():
    stack = [(0, -1, 0)]
    while stack:
        v, p, d = stack.pop()
        parent[0][v] = p
        depth[v] = d
        stack.extend((child, v, d + 1) for child in tree[v])


def get(u, v):
    du, dv = depth[u], depth[v]
    if du > dv:
        u, v = v, u
        du, dv = dv, du
    for k, pk in enumerate(parent):
        if (dv - du) >> k & 1:
            v = pk[v]
    if u == v:
        return u
    for pk in parent[logn - 1:None:-1]:
        pku, pkv = pk[u], pk[v]
        if pku != pkv:
            u, v = pku, pkv
    return parent[0][u]


n = int(input())
tree = [set(map(int, input().split()[1:])) for _ in range(n)]

logn = int(log2(n)) + 1
parent = [[0] * n for _ in range(logn)]
depth = [0] * n
build()

q = int(input())
for _ in range(q):
    print(get(*map(int, input().split())))

Measured memory_bytes: 60312
#include<iostream>
#include<cmath>
#include<vector>
#include<algorithm>
#include<cassert>
#include<iomanip>
#define M 256
#define MAX 257
#define EPS (1e-7)
#define equals(a,b) (fabs((a)-(b)) < EPS)
using namespace std;
int N;
int I[MAX],O[MAX],R[MAX];
int cnt[MAX];
 
void makeR(int S,int A,int C)
{
  R[0] = S;
  for(int i=1;i<=N;i++)
    R[i] = (A*R[i-1]+C)%M;    
}
 
void makeO(int S,int A,int C)
{
  for(int i=0;i<N;i++)
    O[i] = (I[i]+R[i+1])%M;
}
 
double getH()
{
  double ret = 0;
   
  for(int i=0;i<MAX;i++)
    {
      if(cnt[i] == 0)continue;
      if(cnt[i] == N)continue;
      ret += (cnt[i]/(double)N)*log(cnt[i]/(double)N);
    }   
  return -ret;
}
 
int main()
{ 
  while(cin >> N,N)
    {
      for(int i=0;i<N;i++)cin >> I[i];
  
      int aS,aA,aC;
      aS=aA=aC=0;
      double men = (1<<29);
 
      for(int S=0;S<16;S++)
        {
          for(int A=0;A<16;A++)
            {
              for(int C=0;C<16;C++)
                {
                  makeR(S,A,C);
                  makeO(S,A,C);
                  for(int l=0;l<MAX;l++)cnt[l]=0;
                  for(int i=0;i<N;i++)cnt[O[i]]++;
 
                  double H = getH();
 
                  if(men > H && !equals(men,H))
                    {                  
                      men = H;
                      aS = S;
                      aA = A;
                      aC = C;
                    }
                }
            }
        }
 
      cout << aS << " " << aA << " " << aC << endl; 
    }
  return 0;
}

Measured memory_bytes: 1208
from collections import defaultdict
dd = defaultdict(int)

S=input()
N=len(S)
for i in range(N):
    dd[S[i]]+=1
    
if len(dd.keys())==2 and list(dd.values())==[2,2]:
    ans="Yes"
else:
    ans="No"
    
print(ans)

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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 x,a,b;
    cin >> x >> a >> b;
    ANS((x-a)%b);
    return 0;
}

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

int dp[1010][1010];

int LCS(string s1, string s2)
{
	s1 = ' ' + s1;
	s2 = ' ' + s2;
	int maxl = 0;
	for(int i = 1; i <= s1.length(); ++ i)
	{
		for(int j = 1; j <= s2.length(); ++ j)
		{
			if(s1[i] == s2[j])
			{
				dp[i][j] = dp[i-1][j-1] + 1;
			}
			else
			{
				dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
			}
			maxl = max(maxl, dp[i][j]);
		}
	}
	
	return dp[s1.length()-1][s2.length()-1];
}

int main()
{
	string s1, s2;
	int n, sum;
	cin >> n;
	for(int i = 0; i < n; ++ i)
	{
		cin >> s1 >> s2;
		sum = LCS(s1, s2);
		cout << sum << endl;
	}
	
	return 0;
}


Measured memory_bytes: 7076
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef set<int> si;
typedef map<string, int> msi;
typedef greater<int> gt;
typedef priority_queue<int, vector<int>, gt> minq;
typedef long long ll;
const ll INF = 1e18L + 1;

int main()
{
  int n, m;
  cin >> n >> m;
  int ans = 0;
  if (n > 1)
    ans += (n * (n - 1) / 2);
  if (m > 1)
    ans += (m * (m - 1) / 2);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
int main()
{
    int i,s,x=0;
    char h[101]={0};
    scanf("%s",&h);
    for(i=0;h[i]!=0;i++){
        if(h[i]=='C')
        x=1;
        if((h[i]=='F')&&(x==1)){
            printf("Yes");
            return 0;
        }
    }
    printf("No");
    return 0;
}

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

int main() {
	int n;
	bool ok = true;
	map<string,int> words;
	string one_back, now;
	cin >> n;
	cin >> now;
	words[now]++;

	for (int i = 1; i < n; i++) {
		one_back = now;
		cin >> now;
		words[now]++;
		if (words[now] > 1 || now[0] != one_back[(int)one_back.size() - 1]) {
			ok = !ok;
			break;
		}
	}
	if (ok)cout << "Yes" << endl;
	else cout << "No" << endl;
}


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

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

	low = max(A, C);
	up = min(B, D);

	cout << max(0, up - low) << endl;

	return 0;
}

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

int main() {

  bool flag[31] = {};

  for ( long long int i = 0; i < 28; i++ ) {

    long long int in;
    cin >> in;
    flag[in] = true;

  }

  for ( long long int i = 1; i <= 30; i++ ) {
    if ( flag[i] == false ) cout << i << endl;
  }

  return 0;

}

Measured memory_bytes: 1156
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
template <typename Monoid, typename LazyMonoid> class LazySegmentTree {
private:
  using FunctionMonoid = function<Monoid(Monoid, Monoid)>;
  using FunctionAction = function<Monoid(Monoid, LazyMonoid)>;
  using FunctionLazy = function<LazyMonoid(LazyMonoid, LazyMonoid)>;
  FunctionMonoid fm;
  FunctionAction fa;
  FunctionLazy fl;
  int n, height;
  vector<Monoid> data;
  vector<LazyMonoid> lazy;
  Monoid M_UNITY;
  LazyMonoid L_UNITY;
  void build (const int siz) {
    n = 1;
    while (n < siz) n <<= 1, ++height;
    data.assign(2 * n, M_UNITY);
    lazy.assign(2 * n, L_UNITY);
  }
public:
  LazySegmentTree (FunctionMonoid f, FunctionAction g, FunctionLazy h, const Monoid& m_unity, const LazyMonoid& l_unity, int siz = 1) 
  : fm(f), fa(g), fl(h), M_UNITY(m_unity), L_UNITY(l_unity) {
    build(siz);
  }
  inline Monoid reflect (int k) {
    return lazy[k] == L_UNITY ? data[k] : fa(data[k], lazy[k]);
  }
  inline void propagate (int k) {
    if (lazy[k] == L_UNITY) return;
    lazy[(k << 1) | 0] = fl(lazy[(k << 1) | 0], lazy[k]);
    lazy[(k << 1) | 1] = fl(lazy[(k << 1) | 1], lazy[k]);
    data[k] = reflect(k);
    lazy[k] = L_UNITY;
  }
  inline void thrust (int k) {
    for (int i = height; i > 0; --i) propagate(k >> i);
  }
  inline void recalc (int k) {
    while (k >>= 1) data[k] = fm(reflect((k << 1) | 0), reflect((k << 1) | 1));
  }
  void modify (int left, int right, LazyMonoid val) {
    thrust(left += n);
    thrust(right += n - 1);
    for (int l = left, r = right + 1; l < r; l >>= 1, r >>= 1) {
      if (l & 1) lazy[l] = fl(lazy[l], val), l++;
      if (r & 1) --r, lazy[r] = fl(lazy[r], val);
    }
    recalc(left);
    recalc(right);
  }
  void modify (int idx, LazyMonoid val) {
    thrust(idx += n);
    data[idx] = val;
    lazy[idx] = L_UNITY;
  }
  Monoid get (int left, int right) {
    thrust(left += n);
    thrust(right += n - 1);
    Monoid val_l = M_UNITY, val_r = M_UNITY;
    for (int l = left, r = right + 1; l < r; l >>= 1, r >>= 1) {
      if (l & 1) val_l = fm(val_l, reflect(l++));
      if (r & 1) val_r = fm(reflect(--r), val_r);
    }
    return fm(val_l, val_r);
  }
};
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int n, q;
  cin >> n >> q;
  auto fm = [] (int a, int b) -> int {return min(a, b);};
  auto fa = [] (int a, int b) { return b;};
  auto fl = [] (int a, int b) { return b;};
  LazySegmentTree<int, int> sgt(fm, fa, fl, (int) (1e31 - 1), (int) (1e31 - 1), n + 10);
  for (int i = 0; i < q; i++) {
    int c;
    cin >> c;
    if (c == 0) {
      int l, r, x;
      cin >> l >> r >> x;
      sgt.modify(l, r + 1, x);
    } else {
      int l, r;
      cin >> l >> r;
      cout << sgt.get(l, r + 1) << '\n';
    }
  }
  return 0;
}


Measured memory_bytes: 4864
n = int(input())
A = list(map(int, input().split()))

def partition(A, p, r):
    x = A[r]
    i = p - 1
    for j in range(p, r):
        if A[j] <= x:
            i = i + 1
            A[i], A[j] = A[j], A[i]
    A[i+1], A[r] = A[r], A[i+1]
    return i + 1

q = partition(A, 0, n - 1)

result = list(map(str, A))
result[q] = '[' + result[q] + ']'

print(' '.join(result))



Measured memory_bytes: 16588
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
import math
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul, itemgetter
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

#############
# Main Code #
#############

def make_divisors(n):
    divisors = []
    for i in range(1, int(math.sqrt(n)) + 1):
        if n % i == 0:
            divisors.append(i)
            # √nで無い数についてもう一個プラス
            if i != n // i:
                divisors.append(n // i)
    return sorted(divisors)

N = getN()

# 手順としては
# ①　kで出来るだけ割る
# ②　kで引いていく　N = mk + d(d = 1, 2, 3...)とすると,　引いて残る数はm(k - 1) + d
# つまりkで割り切れず、引いても引いても永遠に①に戻ることはない

# N = k ** i * (mk + 1)となるkの数を求める
# i == 0の時
# kがなんであれk ** iは１になるので
# N = mk + 1、つまりN - 1がkの倍数であればそのkは条件を満たす
# N - 1の約数（１以外）が候補

ans = set()
for i in make_divisors(N - 1):
    if i != 1:
        ans.add(i)

# 割れるだけ割る関数
def dividor(x, k):
    if k == 1:
        return 0
    n = x
    while True:
        if n % k == 0:
            n //= k
        else:
            break
    return n

# i >= 1の時
# 候補はNの約数
for prim in make_divisors(N):
    if prim == 1:
        continue
    # Nを割れるだけ割る
    alta = dividor(N, prim)
    if alta == 1:
        ans.add(prim)
        continue
    if alta >= prim and alta % prim == 1:
        ans.add(prim)

print(len(ans))

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

int main(void)
{
	int a, b, k;
	cin >> a >> b >> k;

	if(k * 2 >= b - a + 1) {
		for(int i = a; i <= b; ++ i) {
			cout << i << endl;
		}
	} else {
		for(int i = a; i < a + k; ++i) {
			cout << i << endl;
		}
		for(int i = b - k + 1; i <= b; ++i) {
			cout << i << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;

#define all(a) (a).begin(), (a).end()

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

vector<int> a(200010);
vector<int> ans(200010);
vector<int> dp(200010, inf);

void dfs(int cv, int pv, vector<vector<int>> &G){
    int idx = lower_bound(dp.begin(), dp.end(), a[cv]) - dp.begin();
    int pre = dp[idx];
    dp[idx] = a[cv];

    ans[cv] = lower_bound(dp.begin(), dp.end(), inf) - dp.begin();
    
    for(auto nv : G[cv]){
        if(nv == pv) continue;

        dfs(nv, cv, G);
    }

    dp[idx] = pre;

    return ;
}

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

    int n; cin>>n;
    for(int i=0; i<n; i++) cin>>a[i];
    vector<vector<int>> G(n);
    for(int i=0; i<n-1; i++){
        int u, v; cin>>u>>v;
        u--, v--;
        G[u].emplace_back(v);
        G[v].emplace_back(u);
    }

    dfs(0, -1, G);

    for(int i=0; i<n; i++) cout << ans[i] << endl;

    return 0;
}


Measured memory_bytes: 30688
#include<iostream>
#include <string>
using namespace std;
int main(int argc, char const *argv[]) {
  string c;
  string d;
  cin>>c>>d;
  if(c[0]==d[2]&&c[1]==d[1]&&c[2]==d[0]){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=200001,INF=1<<30;
ll inv[MAX],fac[MAX],finv[MAX];

void make(){
    
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    
    for(int i=2;i<MAX;i++){
        inv[i]=mod-inv[mod%i]*(mod/i)%mod;
        fac[i]=fac[i-1]*(ll)i%mod;
        finv[i]=finv[i-1]*inv[i]%mod;
    }
    
}

ll rui(ll a,ll b){
    if(b==1) return a%mod;
    if(b==0) return 1;
    if(b%2==0) return (rui(a,b/2)*rui(a,b/2))%mod;
    return (rui(a,b-1)*a)%mod;
}

ll comb(ll a,ll b){
    if(a<b) return 0;
    return fac[a]*(finv[b]*finv[a-b]%mod)%mod;
}

int main(){
    
    make();
    
    int N,A,B,C;cin>>N>>A>>B>>C;
    vector<ll> pow100(2*N+1),powA(2*N+1),powB(2*N+1),powAB(2*N+1);
    for(ll i=0;i<=2*N;i++){
        if(i==0) pow100[i]=1;
        else pow100[i]=pow100[i-1]*100%mod;
    }
    
    for(int i=0;i<=2*N;i++){
        if(i==0) powA[i]=1;
        else powA[i]=powA[i-1]*A%mod;
        
        if(i==0) powB[i]=1;
        else powB[i]=powB[i-1]*B%mod;
        
        if(i==0) powAB[i]=1;
        else powAB[i]=powAB[i-1]*(A+B)%mod;
    }
    
    ll P=0;
    for(ll M=N;M<=2*N-1;M++){
        ll sum=comb(M-1,N-1)*M%mod*100%mod*powAB[2*N-1-M]%mod;
        sum=sum*(powA[N]*powB[M-N]%mod+powA[M-N]*powB[N]%mod)%mod;
        P=(P+sum)%mod;
    }
    
    ll Q=powAB[2*N-1]*(100-C)%mod;
    
    cout<<P*rui(Q,mod-2)%mod<<endl;
    
}



Measured memory_bytes: 11136
N=int(input())
A=list(map(int,input().split()))
ans=0
tmp=0
for i in range(N):
    tmp+=A[i]
    
for i in range(N):
    tmp-=A[i]
    ans+=A[i]*tmp%(10**9+7)
    ans%=(10**9+7)
print(ans)


Measured memory_bytes: 31676
#include<stdio.h>
#include<string>
#include<stdlib.h>
#include<math.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<string.h>
#include<map>
#include<queue>

using namespace std;

typedef pair<int,int> pii;

#define rep(i,j) for(int i=0;i<(j);i++)
#define reps(i,j,k) for(int i=j;i<=k;i++)
#define in(i,j,k) ((i)>=(j)&&(i)<=(k))


int main(){
	double a,s;
	while(~scanf("%lf",&a)){
		s=a;
		rep(i,9){
			if(i%2)a/=3;
			else a*=2;
			s+=a;
		}
		printf("%lf\n",s);
	}
	return 0;
}

Measured memory_bytes: 1232
n,m,X,Y = map(int,input().split())
x = sorted(list(map(int,input().split())))
y = sorted(list(map(int,input().split())))
if x[n-1] < y[0] and X < y[0] and x[n-1] < Y:
  print("No War")
else:
  print("War")

Measured memory_bytes: 3060
from math import ceil
N, H = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(N)]
A = [i[0] for i in AB]
A.sort()
B = [i[1] for i in AB]
B.sort()

furudamage = A[-1]
count= 0
while len(B):
    nagedamage = B.pop()
    if nagedamage > furudamage:
        H -= nagedamage
        count += 1
        if H <= 0:
            print(count)
            break
    else:
        break
if H > 0:
    count += ceil(H/furudamage)
    print(count)


Measured memory_bytes: 29216
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define all(x) (x).begin(),(x).end()
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
using Graph = vector<vector<int>>;
double nCk(int n, int k) {
double res=1.0;
for(int i=0; i<n; i++){
res*=0.5;}
for(int i=0; i<k; i++){
res*=(double)(n-i);
res/=(double)(k-i);
}
return res;}
 
int main() {
ll x,y; cin>>x>>y;
map <ll,ll> d;
for (long long a = 2; a * a <= x; ++a) {
        if (x % a != 0) continue;
        long long ex = 0; // 指数

        // 割れる限り割り続ける
        while (x % a == 0) {
            ++ex;
            x /= a;
        }

        d[a]++;
    }
    if (x != 1) d[x]=1;
for (long long a = 2; a * a <= y; ++a) {
        if (y % a != 0) continue;
        long long ex = 0; // 指数

        // 割れる限り割り続ける
        while (y % a == 0) {
            ++ex;
            y /= a;
        }
        d[a]++;
    }
    if (y != 1) d[y]++;
ll ca = 0;
for(auto p : d){
   //cout << p.fi << " " << p.se << endl;
   if(p.se==2){
   ca++;}
}
cout << ca+1 << endl;}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
    using namespace std;
    #define all(vec) vec.begin(),vec.end()
    typedef long long int ll;
    typedef pair<int,int> P;
    typedef pair<P,P> PP;
    const ll MOD=10000;
    const ll INF=1000000010;
    const int MAX=100001;
    int dx[4]={0,1,0,-1};
    int dy[4]={1,0,-1,0};
    
    int main(){
		int n,m;
		while(cin>>n>>m,n+m){
			int s1[110],s2[110];
			int sum1=0;int sum2=0;
			for(int i=0;i<n;i++){
				cin>>s1[i];
				sum1+=s1[i];
			}
			for(int i=0;i<m;i++){
				cin>>s2[i];
				sum2+=s2[i];
			}
			int ans1=INF;int ans2=INF;
			bool f=false;
			for(int i=0;i<n;i++){
				for(int j=0;j<m;j++){
					if(sum1+s2[j]-s1[i]==sum2+s1[i]-s2[j]){
						ans1=s1[i];
						ans2=s2[j];
						f=true;
						break;
					}
				}
				if(f){
					break;
				}
			}
			if(ans1==INF){
				cout<<-1<<endl;
			}else{
				cout<<ans1<<" "<<ans2<<endl;
			}
		}
		
    	return 0;
    }



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

int main() {
  // 入力
  int N, M, K;
  cin >> N >> M >> K;

  string ans = "No";
  if (K % N == 0 || K % M == 0) {
    ans = "Yes";
  } else {
    int sum;
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < M; j++) {
        sum = (i + 1) * j + (N - i - 1) * (M - j);
        //cout << sum << endl;
        if (sum == K) ans = "Yes";
      }
    }
  }

  // 解答
  cout << ans << endl;

  return 0;
}


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

#ifdef TESTING
  #include "dump.hpp"
#else
  #define DUMP(...)
  #define DEBUG(...)
#endif

typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;
#define SZ(a) int((a).size())
#define _REP(_1,_2,_3,_4,name,...) name
#define _REP4(i,b,e,s) for(decltype(e) _b=(b),_e=(e),i=_b+(0<(s)?0:(s));(0<(s)?i<_e:_e<=i);i+=(s))
#define _REP3(i,b,e) for(decltype(e) _b=(b),_e=(e),i=(_b<_e?_b:_b-1);(_b<_e?i<_e:_e<=i);(_b<_e?i++:i--))
#define _REP2(i,n) for(decltype(n) i=0,_n=(n);i<_n;i++)
#define _REP1(n) for(decltype(n) _i=0,_n=(n);_i<_n;_i++)
#define REP(...) _REP(__VA_ARGS__,_REP4,_REP3,_REP2,_REP1)(__VA_ARGS__)
#define FOR(it,c) for(auto&& it=begin(c);it!=end(c);it++)
#define ROF(it,c) for(auto&& it=rbegin(c);it!=rend(c);it++)
#define EB emplace_back
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define INT(n) int n;assert(0<scanf("%d",&n))
#define AI(a,size,n) array<int,size> a;REP(i,n){assert(0<scanf("%d",&a[i]));}
#define CS(s,l) char s[l];assert(0<scanf("%s",s))
#define MSET(arr,val)  memset(arr,val,sizeof(arr))

int main(){
  INT(n); INT(k);
  int ans = 0, wh[k + 1][k + 1], bl[k + 1][k + 1]; MSET(wh, 0); MSET(bl, 0);
  REP(n){
    INT(x); INT(y); CS(c, 2);
    if ((k <= y % (2 * k)) == (k <= x % (2 * k))){
      if (c[0] == 'W'){
        wh[y % k + 1][x % k + 1]++;
      } else {
        bl[y % k + 1][x % k + 1]++;
      }
    } else {
      if (c[0] == 'W'){
        bl[y % k + 1][x % k + 1]++;
      } else {
        wh[y % k + 1][x % k + 1]++;
      }
    }
  }
  REP(y, 1, k + 1){
    REP(x, 1, k + 1){
      wh[y][x] += wh[y][x - 1];
      bl[y][x] += bl[y][x - 1];
   }
  }
  REP(y, 1, k + 1){
    REP(x, 1, k + 1){
      wh[y][x] += wh[y - 1][x];
      bl[y][x] += bl[y - 1][x];
    }
  }
  REP(y, 1, k + 1){
    REP(x, 1, k + 1){
      ans = max(ans, 2 * wh[y][x] + wh[k][k] - wh[y][k] - wh[k][x] + bl[y][k] + bl[k][x] - 2 * bl[y][x]);
      ans = max(ans, 2 * bl[y][x] + bl[k][k] - bl[y][k] - bl[k][x] + wh[y][k] + wh[k][x] - 2 * wh[y][x]);
    }
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 8064
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
  int a,b,st[14]={0,13,1,2,3,4,5,6,7,8,9,10,11,12};
  cin >> a >> b;
  if (st[a]>st[b]) cout << "Alice" << endl;
  else if (st[a]<st[b]) cout << "Bob" << endl;
  else cout << "Draw" << endl;
  return 0;
}

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

using namespace std;

const long long INF = 1e18;

int main(){
    string s, t; cin >> s >> t;
    int ls=s.size(), lt=t.size();
    auto dp = vector< vector<int> >(3010, vector<int>(3010, 0));

    dp[0][0] = (s[0] == t[0]) ? 1 : 0;

    for (int i=1; i<ls; i++){
        if (s[i] == t[0])  dp[i][0] = 1;
        else  dp[i][0] = dp[i-1][0];
    }
    for (int i=1; i<lt; i++){
        if (s[0] == t[i])  dp[0][i] = 1;
        else  dp[0][i] = dp[0][i-1];
    }

    for (int i=1; i<ls; i++){
        for (int j=1; j<lt; j++){
            if (s[i] == t[j])  dp[i][j] = dp[i-1][j-1]+1;
            else  dp[i][j] = max(dp[i][j-1], dp[i-1][j]);
        }
    }

    string ans="";
    int i=ls-1, j=lt-1;
    while (i>=0 && j>=0){
        if (i>0 && dp[i][j] == dp[i-1][j])  i--;
        else if (j>0 && dp[i][j] == dp[i][j-1])  j--;
        else {
            if (s[i] == t[j])  ans = s[i]+ans;
            i--; j--;
        }
    }

    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 35712