akhauriyash/Code-Regression huggingface dataset:
from collections import deque
N,M=map(int,input().split())
d=dict()
for i in range(M):
  a,b=map(int,input().split())
  d.setdefault(a,set()).add(b)
  d.setdefault(b,set()).add(a)
s=set()#ラベルを貼った場所に置く
label=dict()
A=deque()
A.append(1)
while A:
  a=A.popleft()
  b=d[a]
  b-=s
  for i in b:
    if i not in label:
      label[i]=a
      A.append(i)
k=deque(sorted(label.keys()))
a=k.popleft()
print("Yes")
for i in k:
  print(label[i])

Measured memory_bytes: 76100
import java.util.*;

public class Main {
    private static final Scanner scn = new Scanner(System.in);
    
    public static void main(String[] args) {
        StringBuilder sb = new StringBuilder();
        while(scn.hasNextLine()) {
            sb.append(scn.nextLine());
        }
        int[] cnt = countChar(sb.toString());
        for(int i = 0; i < 26; i++) {
            System.out.println((char)('a' + i) + " : " + cnt[i]);
        }
    }
    
    private static int[] countChar(String str) {
        int[] cnt = new int[26];
        for(char elm : str.toLowerCase().toCharArray()) {
            if(Character.isAlphabetic(elm)) {
                cnt[elm - 'a']++;
            }
        }
        return cnt;
    }
}

Measured memory_bytes: 26028
#include <iostream> // cout, endl, cin
#include <cmath> //sqrt pow
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // dequef
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower

#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define all(a) (a).begin(), (a).end()
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  int n,W;
  cin >> n >> W;
  vi weight(n), value(n);
  int mx = 100010;
  rep(i, n) cin >> weight[i] >> value[i];
  vector<vector<ll>> dp(n + 1, vector<ll>(mx + 1, 100000001000));
  dp[0][0] = 0;
  rep(i, n){
    rep(v, mx + 1){
      if(v >= value[i]) dp[i + 1][v] = min(dp[i + 1][v], dp[i][v - value[i]] + weight[i]);
      dp[i + 1][v] = min(dp[i][v], dp[i + 1][v]);
    }
  }
  int ans = 0;
  rep(i, mx + 1){
    if(dp[n][i] <= W) ans = i;
  }
  cout << ans << endl;
}

Measured memory_bytes: 80256
from bisect import bisect_right
import sys
def main():
    input = sys.stdin.readline
    N = int(input())
    *L, = map(int, input().split())
    L.sort()
    ans = 0
    for i in range(2, N):
        for j in range(i):
            k = bisect_right(L, L[i] - L[j], j + 1, i)
            ans += i - k
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 42716
n,m=map(int, input().split())

d = [0]*10**5
a = set()
w = 0


ps = []
for i in range(m):
    p,s = input().split()
    ps.append([int(p),s])

for p,s in ps:
    if "AC" == s and p not in a:
        w += d[p]
        a.add(p)
    if "WA" == s:
        d[p] += 1
print(len(a),w)






Measured memory_bytes: 28948
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;


int main(){
    ll n;
    cin >> n;
    ll ans = 0;
    for(int i = 1; i <= n; i++){
        ll k = n / i;
        ans += i * k * (k+1) / 2;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3608
const main = (input) => {
  input = input.split(' ');
  const A = parseInt(input[0], 10);
  const B = parseInt(input[1], 10);
  
  if ((A+B)%3===0 ||A%3===0 ||B%3===0){
    console.log("Possible");
  }else{
    console.log("Impossible");
  }  
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

void solve(){
	
	int n,m ;
	cin>>n>>m ;
	vector<vector<int>> jobs(m+1) ;

	rep(i,n){
		int a,b ;
		cin>>a>>b ;

		if(a>m)
			continue ;

		jobs[m-a].push_back(b) ;

	}

	priority_queue<int> q ;
	ll ans=0 ;

	for(int i=m-1;i>=0;i--){

		for(auto x:jobs[i]){
			q.push(x) ;
		}

		if(!q.empty()){

			int temp=q.top() ;
			ans+=temp ;
			q.pop() ;
		}
	}

	cout<<ans ;

}

int main(){
	
	int y ;

	y=1 ;
	//cin>>y ;

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

}

Measured memory_bytes: 8360
#include <bits/stdc++.h>
#define all(x) x.begin(),x.end()
#define ll long long
#define f first
#define s second
using namespace std;

int main()
{
    ios_base :: sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string a,t;
    cin >> a >> t;
    int a1,t1;
    cin >> a1 >> t1;
    string h;
    cin >> h;
    if(h==a)
    {
        cout << a1-1 << ' ' << t1;
    }
    if(h==t)
    {
        cout << a1 << ' ' << t1-1;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll n, ans;
int main() {
	scanf("%lld", &n);
	for(ll i = sqrt(n); i >= 1; i --) {
		if(n % i == 0) {
			ans = (i - 1) + (n / i - 1);
			break;
		}
	}
	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
typedef pair<int,int> P;
const int MOD = 1000000007;
const ll INF = 1e10;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 
#define int long long
#define double long double



////////////////////////////////////////////////////////////////////

template<typename T>
struct edge {
  int to, from;T cost;
  edge(int to, T cost) : from(-1), to(to), cost(cost) {}
  edge(int from, int to, T cost) : from(from), to(to), cost(cost) {}
};
template<typename T>
using edges = vector<edge<T>>;
template<typename T>
using graph = vector<edges<T>>;
template<typename T>
using matrix = vector<vector<T>>;

template<typename T>
bool compByCost(const edge<T>& left, const edge<T>& right){
  return left.cost < right.cost; 
}

template<typename T>
vector<T> dijkstra(int s, graph<T> &g){
  vector<T> dist(g.size()+10, INF);dist[s] = 0;
  priority_queue<P, vector<P>, greater<P>> que;que.push(P(0,s));
  while(!que.empty()){
    P p = que.top();que.pop();
    int v = p.second;
    if(dist[v] < p.first)continue;
    rep(i, g[v].size()){
      edge<T> e = g[v][i];
      if(dist[e.to] > dist[v] + e.cost){
        dist[e.to] = dist[v] + e.cost;
        que.push(P(dist[e.to], e.to));
      }
    }
  }
  return dist;
}

#define dijkstra dijkstra<int>

ll modpow(ll a,  ll n, const ll &MOD = MOD){
  ll ret = n == 0 ? 1 : modpow(a, n/2, MOD);
  (ret *= ret) %= MOD;
  if(n%2)((ret *= a) %= MOD);
  return ret;
}
////////////////////////////////////////////////////////////////////i

int k;
signed main(){
  cin>>k;
  if(k == 0){
    cout << 4 << endl;
    cout << "3 3 3 3" << endl;
    return 0;
  }
  if(k == 1){

  }
  if(2 <= k && k <= 50){
    cout << k << endl;
    rep(i,k)cout << k << (i == k-1 ? "\n" : " ");
    return 0;
  }
  int a = k/50, r = k%50, cnt = 50;
  cout << 50 << endl;
  rep(i,r){
    cout << 100+a-r << " ";
    cnt--;
  }
  rep(i,cnt){
    cout << 50+a-1-r << (i == cnt-1 ? "\n" : " ");
  }
}





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

int main () {
    int N, K, s = 1;
    cin >> N >> K;

    for (int i = 0; i < N; i++){
        if (s <= K){
            s *= 2;
        }
        else {
            s += K;
        }
    }
    cout << s << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
const int n = (int)1e6 + 77;
const double pi = 3.14159265359;
int main() {
ll n;
cin>>n;
string s[n];
ll a=0,r=0,t=0,w=0;
for(ll i=0;i<n;i++)
{
    cin>>s[i];
    if(s[i]=="AC" )
        a++;
        else
     if(s[i]=="WA")
        w++;
        else
         if(s[i]=="TLE")
        t++;
        else
         if(s[i]=="RE")
        r++;
}
cout<<"AC x "<<a<<endl;

cout<<"WA x "<<w<<endl;

cout<<"TLE x "<<t<<endl;

cout<<"RE x "<<r<<endl;
return 0;
}


Measured memory_bytes: 6752
#include<stdio.h>
#include<iostream>
#include<math.h>
using namespace std;
int main(){
    int a;
    cin >> a;
    while(a--){
        double x1,y1,x2,y2,x3,y3;
        cin >> x1 >>y1 >>x2 >> y2 >> x3 >> y3;
        double a1,a2,b1,b2,c1,c2,x,y,r;
         a1=2*(x2-x1);
         b1=2*(y2-y1);
         c1=x1*x1-x2*x2+y1*y1-y2*y2;
         a2=2*(x3-x1);
         b2=2*(y3-y1);
         c2=x1*x1-x3*x3+y1*y1-y3*y3;
         x=(b1*c2-b2*c1)/(a1*b2-a2*b1);
         y=(c1*a2-c2*a1)/(a1*b2-a2*b1);
         r=hypot(x-x1,y-y1);
        printf("%.3lf %.3lf %.3lf\n",x,y,r);
    }
}



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

using namespace std;
 
#define rep(i, n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define pb push_back


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

    string s;
    cin>>s;

    int tmp=0;

    int r=0;
    int l=0;

    for(int i=0;i<s.size();i++){
        if(s[i]=='('){
            tmp++;
        }else{
            if(tmp==0){
                l++;
            }else{
                tmp--;
            
            }
        } 
    }

    for(int i=0;i<l;i++){
        cout<<'(';
    }
    cout<<s;
    for(int i=0;i<tmp;i++){
        cout<<')';
    }
    cout<<endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <map>
#include <set>
#include <cassert>

#define rep(i,x) for(int i = 0; i < x; i++)
#define rrep(i,x) for(int i = 1; i <= x; i++)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using ll = long long;
using namespace std;
const int INF = 1001001001;
const ll LINF = 1002003004005006007;

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> a(m);
    rep(i, m) cin >> a[i];
    rep(i, m) n -= a[i];
    if (n >= 0) cout << n << endl;
    else cout << -1 << endl;
}


Measured memory_bytes: 3232
function Main(input){
	input = input.split("\n");
  var a = ~~input[0];
  var b = input[1].split(" ").map((a)=>~~a);
  var max = b[0];
  var sum = 0;
  for(var i = 0; i < a ; i++){
  	var c = b[i];
  	if(max < c){max = c}
    sum += c;
  }
  if(max * 2 < sum){return "Yes"}
  return "No"
}

// If you are interested in the algorithms I used, 
// there is no need to read down from this line.

((b,c,d)=>"undefined"!=typeof require?console.log(Main(require("fs").readFileSync("/dev/stdin","utf8"))):[b=b.split("\n").slice(1,-1).join("\n"),c=function(){try{return Main(b)}catch(f){return f.stack||f.message}}(),d=typeof c,"string"==d||(c=JSON.stringify(c)),$("<form>").append([[10,b],0,[1,d],0,[10,c]].map(f=>$(f?"<textarea>":"<br>",f&&{rows:f[0],cols:40,text:f[1]}))).appendTo("body")])(`
4
3 8 4 1
`);

Measured memory_bytes: 7372
#include<iostream>
#include<complex>
#include<vector>
#include<cmath>
#include<algorithm>
#include<cstdio>

using namespace std;

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

#define X real()
#define Y imag()

typedef long double D;
typedef complex<D> P;
typedef pair<P, P> L;
typedef vector<P> Pol;

const D INF = 1e40;
const D EPS = 1e-8;
const D PI = acos(-1);

int sig(D r) {return (r < -EPS) ? -1 : (r > EPS) ? 1 : 0;}
bool eq(D a, D b) {return abs(a - b) < EPS;}
bool near(P a, P b) {return abs(a - b) < EPS;}

// テ・ツ??ァツゥツ?
D dot(P a, P b) {return a.X * b.X + a.Y * b.Y;}
// テ・ツ、ツ姪ァツゥツ?
D det(P a, P b) {return a.X * b.Y - a.Y * b.X;}

// テァツキツ堙・ツ按?」ツ?ョテ」ツδ凖」ツつッテ」ツδ暗」ツδォ
P vec(L a) {return a.second - a.first;}

// テァツキツ堙・ツ按?bテ」ツ?ォテ・ツッツセテ」ツ?凖」ツつ凝ァツつケxテ」ツ?ョテ、ツスツ催ァツスツョ
enum CCW{FRONT = 1, RIGHT = 2, BACK = 4, LEFT = 8, ON = 16};
int ccw(L s, P p) {
  P a = vec(s);
  p -= s.first;
  D cr = det(a, p);
  if (eq(cr, 0)) {
    if (sig(dot(a, p)) < 0) return BACK;
    if (sig(norm(a) - norm(p)) < 0) return FRONT;
    return ON;
  }
  return (cr > 0) ? LEFT : RIGHT;
}

struct Par{
  P p, v, a;
  Par() {}
  Par(P p, P v, P a) : p(p), v(v), a(a) {}
};

bool iParL(Par par, L l) {
  par.p = (par.p - l.first) / vec(l);
  par.v /= vec(l);
  par.a /= vec(l);
  if (eq(par.a.Y, 0)) return !eq(par.v.Y, 0);
  D t = par.v.Y / par.a.Y;
  return sig((par.p + par.v * t + par.a * t * t / (D)2).Y) * sig(par.a.Y) <= 0;
}

pair<D, D> tParL(Par par, L l) {
  par.p = (par.p - l.first) / vec(l);
  par.v /= vec(l);
  par.a /= vec(l);
  D t1 = (-par.v.Y + sqrt(pow(par.v.Y, 2) - 2 * par.p.Y * par.a.Y)) / par.a.Y;
  D t2 = (-par.v.Y - sqrt(pow(par.v.Y, 2) - 2 * par.p.Y * par.a.Y)) / par.a.Y;
  return make_pair(t1, t2);
}

pair<P, P> pParL(Par par, L l) {
  pair<D, D> t = tParL(par, l);
  P p1 = par.p + par.v * t.first + par.a * t.first * t.first / (D)2;
  P p2 = par.p + par.v * t.second + par.a * t.second * t.second / (D)2;
  return make_pair(p1, p2);
}

int main() {
  int n;
  D v;
  cin >> n >> v;
  Pol pol;
  rep (i, n) {
    P p;
    cin >> p.X >> p.Y;
    pol.push_back(p);
  }
  P now = pol[0];
  D res = 0;
  rep (i, n - 1) {
    res += abs(now - pol[i + 1]);
    if (i < n - 2 && ccw(L(pol[i], pol[i + 1]), pol[i + 2]) == RIGHT) {
      Par par;
      par.p = pol[i + 1];
      par.v = polar(v, arg(pol[i + 1] - pol[i]));
      par.a = P(0, -9.8);
      for (; i < n - 2; ++i) {
	pair<P, P> pp = pParL(par, L(pol[i + 1], pol[i + 2]));
	if (pp.first.X > pp.second.X) swap(pp.first, pp.second);
	if (sig(pol[i + 1].X - pp.first.X) < 0 && sig(pp.first.X - pol[i + 2].X) < 0) {
	  now = pp.first;
	  break;
	}
	if (sig(pol[i + 1].X - pp.second.X) < 0 && sig(pp.second.X - pol[i + 2].X) < 0) {
	  now = pp.second;
	  break;
	}
      }
    } else {
      now = pol[i + 1];
    }
  }
  printf("%.12Lf\n", res);
  return 0;
}

Measured memory_bytes: 1696
#include<stdio.h>
int main(void)
{
	int n;
	int x,x1,y,z,a,b,c;
	scanf("%d",&n);
	x=n/100;
	x1=n%100;
	y=x1/10;
	z=x%10;
	a=z*100;
	b=y*10;
	c=x;
	if((a+b+c)==n){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
}


Measured memory_bytes: 128
import java.util.*;

class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] a = new int[3*N];
        for(int i = 0; i < 3*N; i++){
            a[i] = sc.nextInt();
        }

        Arrays.sort(a);
        long ans = 0;
        for(int i = N; i < 3 * N - 1; i += 2){
            ans += a[i];
        }

        System.out.println(ans);
    }
}


Measured memory_bytes: 92600
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
typedef long long ll;

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; }
const int INF = 1001001001;
const long long INFL = (1LL<<60);
const double eps = (1e-9);

int count(char c) {
  if (c == 'a') return 0;
  else return 'z' + 1 - c;
}

int main(int argc, char* argv[])
{
  string s;
  cin >> s;
  ll k;
  cin >> k;
  int n = s.size();
/*
  for(int i = 0; i < n; i++){
    if(s[i] == 'a') continue;
    if('z' - s[i] + 1 <= k){
      k -= 'z' - s[i] + 1;
      s[i] = 'a';
    }
  }
*/
  rep(i, n) {
    if (s[i] == 'a') continue;
    int num = 'z' - s[i] + 1;
    if (num <= k) {
      s[i] = 'a';
      k -= num;
    }
    if (k == 0) break;
  }

  // 最後に残った K を処分
  if (k > 0) {
    k %= 26;
    s[n - 1] += k;

    if (s[n - 1] > 'z') s[n - 1] -= 26;
  }

  cout << s << endl;

  return 0;
}


Measured memory_bytes: 512
#include<stdio.h>
int main()
{
    int i;
    char a[6];
    gets(a);
    for(i=0;a[i]!='/0';i++)
    {
        if(a[2]==a[3]&&a[4]==a[5])
        {
           printf("Yes");
           break;
        }
           else
                printf("No");
           break;
    }
    return 0;
}


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

typedef long long ll;

using namespace std;

template<typename TwoDimensionalVector>
void sort_by_column(TwoDimensionalVector &vector, int column) {
    sort(vector.begin(), vector.end(), [&](auto x, auto y) { return x[column] < y[column]; });
}

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

    int N, M;
    cin >> N >> M;

    ll x, y, z;
    vector<vector<ll>> source;
    for (int _ = 0; _ < N; _++) {
        cin >> x >> y >> z;
        vector<ll> tmp = {x + y + z,
                          x + y - z,
                          x - y + z,
                          x - y - z,
                          -x + y + z,
                          -x + y - z,
                          -x - y + z,
                          -x - y - z};
        source.push_back(tmp);
    }

    ll absolute_maximum = 0;
    ll initial_value = 0;

    for (int column = 0; column < 8; column++) {
        sort_by_column(source, column);
        ll maximum = accumulate(prev(source.end(), M), source.end(), initial_value, [&](ll sum, auto x) { return sum + x[column]; });
        if (maximum > absolute_maximum) {
            absolute_maximum = maximum;
        }
    }

    cout << absolute_maximum << endl;
}

Measured memory_bytes: 384
using System;
using System.Linq;

namespace abc129
{
    class C2
    {

        const int MOD = 1000000007;
        static public bool[] isHolls;

        static void Main(string[] args)
        {
            var input = Input.IntArray();
            var N = input[0];
            var M = input[1];

            isHolls = new bool[N + 1];

            for (int i = 0; i < M; i++)
            {
                isHolls[Input.Int()] = true;
            }

            var dp = new long[N + 1];
            dp[0] = 1;

            for (int now = 0; now < N; now++)
            {
                for (int next = now + 1; next <= Math.Min(N, now + 2); next++)
                {
                    if (!isHolls[next]){
                        dp[next] += dp[now];
                        dp[next] %= MOD;
                    }
                }
            }

            Console.WriteLine(dp[N]);

        }


        /** Input Class */
        internal static class Input
        {
            /** input int */
            public static int Int() => int.Parse(Console.ReadLine());

            /** input str */
            public static string Str() => Console.ReadLine();

            /** input array of int */
            public static int[] IntArray() => Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            /** input array of string */
            public static string[] StrArray() => Input.Str().Split(' ');

            /** input array of char */
            public static char[] charArray() => Input.Str().ToCharArray();
        }

    }
}


Measured memory_bytes: 14292
#include<bits/stdc++.h>
/* #define int long long */
/* #define double long double */
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define repa(i, s, n) for(int i = s; i < (int)n; i++)
#define MOD 1000000007
using namespace std;
using ll = long long;
typedef vector<int> vi;
typedef pair<int, int> P;
#define rrep(i,a,b) for(int i=a;i>=b;i--)
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; }

signed main(){
    int n, m;
    cin >> n >> m;

    int ans = (n*(n-1)/2) + (m*(m-1)/2);
    cout << ans << endl;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N;
LL r;
LL D;
LL x;
int main(){
	cin>>r>>D>>x;
	LL now=x;
	REP(i,10){
		now=r*now-D;
		cout<<now<<endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
typedef long long ll;
#define MOD (int)(1e9+7)

ll DP[1000001];
ll DPSum[1000001];
bool used[1000001];
ll N;

int main()
{
	cin >> N;

	for (int i = 1; i <= N; i++) {
		if (i - 1 > 0)DP[i] += DP[i - 1];
		DP[i] %= MOD;
		if (i - 3 > 0)DP[i] += DPSum[i - 3] + N-1-(i-3);
		else if(i>1)DP[i] += N - 1;
		DP[i] %= MOD;
		if(i>1)DP[i] += (N - 1)*(N - 1);
		else DP[i] += N;
		DP[i] %= MOD;

		DP[i] %= MOD;
		DPSum[i] = DPSum[i - 1] + DP[i];
		DPSum[i] %= MOD;

		//cout << DP[i] << endl;
	}

	cout << DP[N] << endl;

    return 0;
}



Measured memory_bytes: 15872
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n - r] % p


p = 10 ** 9 + 7
N = 10 ** 5 + 1  # N は必要分だけ用意する
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]

for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)


N, K = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
ans = 0
for ri in range(2):
    for i in range(N):
        now = cmb(i, K - 1, p)
        if ri == 1:
            now = - now
        ans += A[i] * now
        ans %= p
    A.sort(reverse=True)
print(ans)

Measured memory_bytes: 26740
import sys
from collections import deque
import copy

sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(inputs):
    S = inputs[0]
    T = inputs[1]

    string_queue = deque(S)
    T_queue = deque(T)

    for i in range(len(S)):
        if string_queue == T_queue:
            return 'Yes'
        p = string_queue.pop()
        string_queue.appendleft(p)
    return 'No'


def string_to_int(string):
    return list(map(int, string.split()))


if __name__ == "__main__":
    ret = solve(inputs(2))
    print(ret)


Measured memory_bytes: 3436
import sys
WEIGHT=[91.0, 81.0, 75.0, 69.0, 64.0, 60.0, 57.0, 54.0, 51.0, 48.0,-1]
GRADE=['heavy', 'light heavy', 'middle', 'light middle', 'welter', 'light welter', 'light', 'feather', 'bantam', 'fly', 'light fly']
for line in sys.stdin.readlines():
    weight=float(line.strip())
    for i in xrange(len(GRADE)):
        if weight>WEIGHT[i]:
            print GRADE[i]
            break

Measured memory_bytes: 4244
#include <iostream>
#include <cmath>
#include <algorithm>
#include <bitset>
#include <iomanip>
#include <cstdio>
#include <new>
#include <vector>
#include <cstdlib>
#include <string>
#include <set>
#include <tuple>
#include<map>

using namespace std;
int main() {
	int A, B;
	cin >> A >> B;

	if (A + B < 10)cout << A + B << endl;
	else cout << "error" << endl;

}

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

#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for (int i = (n); i >= 0; i--)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

    ll mod = 1e9 + 7;

    set<int> st;
    ll dp[n + 1];
    rep(i, m)
    {
        int a;
        cin >> a;
        st.insert(a);
    }

    rep(i, n + 1) dp[i] = 0;
    dp[0] = 1;

    for (int i = 1; i < n + 1; i++)
    {
        if (st.find(i) != st.end())
        {
            dp[i] = 0;
            continue;
        }
        if (i >= 1 && st.find(i - 1) == st.end())
            dp[i] = (dp[i] + dp[i - 1]) % mod;
        if (i >= 2 && st.find(i - 2) == st.end())
            dp[i] = (dp[i] + dp[i - 2]) % mod;
    }
    OP(dp[n]);
    return 0;
}

Measured memory_bytes: 5760
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<queue>
#include<stack>
#include<algorithm>
#include<string>
using namespace std;

int main()
{
	long long int i,j,k,n,ans=0;cin>>n;
	for(i=1;i<=n;i=i+1)
	{
	    for(j=1;j<=n;j=j+1)
	    {
	        for(k=1;k<=n;k=k+1)
	        {
	            ans=ans+__gcd(i,__gcd(j,k));
	        }
	    }
	}
	cout<<ans<<endl;
	
	
}

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

#define ld			long double
#define int         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 all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define MOD         1000000007
#define sd(t) 		scanf("%d",&(t))
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define hii 		cout << "hii" << endl
#define okay 		cout << "okay" << endl
#define hey 		cout << "hey" << endl
#define M_PIl       3.141592653589793238462643383279502884L
template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; } 
 
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#endif // ifndef ONLINE_JUDGE

void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);	
}

clock_t time_p=clock();
void starboy1299()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}

const int N = 2e5+5;
int arr[N], h[N], bit[N];
int n, k;

void solve()
{
	int r;
	cin >> r;
	ld ans = 2*(M_PIl)*r;

	cout << fixed << setprecision(15) << ans << endl;
}			 	

int32_t main(){
	fast();
    int t = 1;
    // cin>> t;
    while(t--){
    	solve();
    }
	starboy1299();
}




Measured memory_bytes: 3808
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <string>

typedef long long int ll;

using namespace std;
ll a,b,c,n,m,q,aa[100000],bb[100000];
bool ra,rb,rc;
vector<ll> va,vb;
string st;

#define CE cout<<endl
#define C cout<<
#define E <<endl

int main(){
    cin>>st;
    cout <<(st == "ABC" ? "ARC":"ABC")<<endl;
}


Measured memory_bytes: 3600
#include<stdio.h>

int main(){
	int a[10];
	int b;
	int i;
	int j;
	for(i = 0; i < 10; i++){
		scanf("%d", &a[i]);
	}
	for(i = 0; i < 3; i++){
		for(j = i + 1; j < 10; j++){
			if(a[i] < a[j]){
				b = a[i];
				a[i] = a[j];
				a[j] = b;
			}
		}
		printf("%d\n", a[i]);
	}
	return 0;
}

Measured memory_bytes: 600
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;

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

void chmax(int &l, int r){if(l<r)l=r;}

int main(){

  int n, d, x; cin>> n>> d>> x;
  int p[d][n];
  rep(i, d)rep(j, n) cin>> p[i][j];

  const int M=100005;
  rep(i, d-1){
    // dp[j][k]:=i日目、種類jまで見て、k円持ってるときの、翌日の所持金の最大
    int dp[n+1][M];
    rep(j, n+1)rep(k, M) dp[j][k]=0;    
    for(int k=0; k<=x; k++) dp[0][k]=k; // ?
    rep(j, n){
      for(int k=0; k<=x; k++){
        chmax(dp[j+1][k], dp[j][k]);
        if(k-p[i][j]>=0){
          chmax(dp[j+1][k], dp[j+1][k-p[i][j]]+p[i+1][j]);
        }
      }
    }
    int y=0;
    for(int k=0; k<=x; k++) chmax(y, dp[n][k]);
    x=y;
  }

  cout<< x<< endl;

  return 0;
}


Measured memory_bytes: 7392
#include<stdio.h>
#include<string.h>
   char a[5];
   int main()
   {
   scanf("%s",&a);
   int t=0;
   for(int i=1 ;i<4;i++)	
      {
      if(a[i]==a[i-1])
	  t++;
      }
   if(t==0)
   printf("Good\n");
   else
   printf("Bad\n");
   }

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	int a [] = {0 , 1 , 3 , 1 , 2 , 1 , 2 , 1 , 1 , 2 , 1 , 2 , 1};
// 配列の添字は 0 から始まるので，a [0] は 0 にしている．
int x , y ; cin >> x >> y ;
cout << ( a [ x ] == a [ y ] ? " Yes " : " No ") << endl ;
 
 
 
	return 0;
}


Measured memory_bytes: 256
using System;

class main
{
    static void Main(string[] args)
    {
        string s1, s2, s7, a4;
        s7 = Console.ReadLine();
        int c = int.Parse(s7);
        for (int m = 0; m < c; m++)
        {
            s1 = Console.ReadLine();
            s2 = Console.ReadLine();
            a4 = string.Empty;
            int a1 = 0, a2 = 0;
            string[] s3 = new string[10];
            string[] s4 = new string[10];
            string[] s5 = new string[10];
            int[] a3 = new int[10];
            if (s1.Length > 80 || s2.Length > 80)
            {
                Console.WriteLine("overflow");
                goto end;
            }
            s1 = s1.PadLeft(80, '0');
            s2 = s2.PadLeft(80, '0');
            for (int i = 0; i < 10; i++)
            {
                s3[i] = s1.Substring(8 * i, 8);
                s4[i] = s2.Substring(8 * i, 8);
            }
            for (int j = 9; j >= 0; j--)
            {
                a1 = int.Parse(s3[j]);
                a2 = int.Parse(s4[j]);
                a3[j] += a1 + a2;
                if (a3[j].ToString().Length == 9)
                {
                    if (j == 0)
                    {
                        Console.WriteLine("overflow");
                        goto end;
                    }
                    a3[j] -= 100000000;
                    a3[j - 1] += 1;
                }
                s5[j] = a3[j].ToString().PadLeft(8, '0');
            }
            a4 = string.Join("", s5);
            while (a4.StartsWith("0"))
            {
                a4 = a4.TrimStart('0');
            }
            if (a4 == "")
            {
                Console.WriteLine(0);
                goto end;
            }
            Console.WriteLine(a4);
        end: ;
        }
    }
}

Measured memory_bytes: 6332
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1LL << 60;
constexpr int INF = 3000000007;
const double INFD = 1e100;
const ll mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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;
}
// ----------------------------------------------------------------------------

int main(){
  string S,T;
  cin >> S  >> T;
  cout << T+S << endl;

  return 0;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

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

    ll N;
    cin >> N;
    vector<ll> H(N);
    REP(i, N) cin >> H[i];
    ll res = 0;
    REP(i, N){
    	bool flag = true;
    	REP(j, N){
    		if(j>=i) continue;
    		if(H[j]>H[i]) flag = false;
    	}
    	if(flag) res++;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
H, W = map(int, input().split())

grid = []

for i in range(H):
    s = input()
    r = []
    for j, x in enumerate(s):
        r.append(x)

    grid.append(r)


H_cnt = [[0] * W for _ in range(H)]
W_cnt = [[0] * W for _ in range(H)]

for r in range(H):
    idx = 0

    while idx < W:
        if grid[r][idx] == '.' and (idx == 0 or grid[r][idx - 1] == '#'):
            cnt = 1
            st = idx
            if idx == W - 1 or grid[r][idx + 1] == '#':
                W_cnt[r][idx] = 1
        elif grid[r][idx] == '.' and (idx == W - 1 or grid[r][idx + 1] == '#'):
            cnt += 1
            for i in range(st, idx + 1):
                W_cnt[r][i] = cnt
        elif grid[r][idx] == '.':
            cnt += 1
        elif grid[r][idx] == '#':
            pass

        idx += 1

for c in range(W):
    idx = 0

    while idx < H:
        if grid[idx][c] == '.' and (idx == 0 or grid[idx - 1][c] == '#'):
            cnt = 1
            st = idx
            if idx == H - 1 or grid[idx + 1][c] == '#':
                H_cnt[idx][c] = 1
        elif grid[idx][c] == '.' and (idx == H - 1 or grid[idx + 1][c] == '#'):
            cnt += 1
            for i in range(st, idx + 1):
                H_cnt[i][c] = cnt
        elif grid[idx][c] == '.':
            cnt += 1
        elif grid[idx][c] == '#':
            pass

        idx += 1

max_ = 0
for r in range(H):
    for c in range(W):
        max_ = max(max_, W_cnt[r][c] + H_cnt[r][c] - 1)

print(max_)


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

int main(int argc, char *argv[])
{
    int N;
    int vec[10];
    std::cin >> N;
    for (int i = 0; i < N; i++) {
        std::cin >> vec[i];
    }

    int max = 0;
    int num = 0;
    for (int i = 0; i < N; i++) {
        if (max < vec[i]) {
            max = vec[i];
            num = i;
        }
    }

    vec[num] = vec[num] / 2;

    int ans = 0;

    for (int i = 0; i < N; i++) {
        ans += vec[i];
    }

    std::cout << ans << std::endl;

    return 0;
}

Measured memory_bytes: 256
N = gets.to_i
leaves = gets.split.map(&:to_i)
prev = 1
cnt = 1
remain = leaves.sum
1.upto(N) do |n|
    if 2*prev < leaves[n]
        puts -1
        exit
    end
    if n == N
        cnt += leaves[n]
        break
    end
    remain = remain - leaves[n]
    cur_node = [2*prev-leaves[n], remain].min
    cnt += cur_node + leaves[n]
    prev = cur_node
end
if N == 0 && leaves[0] != 1 || N > 0 && leaves[0] > 0
    puts -1
else
    puts cnt
end

Measured memory_bytes: 20596
N = int(input())
A = [int(input()) for i in range(N)]
B = list(set(A))
B.sort()
B.reverse()
if len(B) == 1 or A.count(B[0])>= 2:
  for i in range(N):
    print(B[0])
else:
  for i in range(N):
    if A[i] == B[0]:
      print(B[1])
    else:
      print(B[0])

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

using namespace std;
int main(int argc, const char * argv[]) {
    
    
    long a, b, c, d;
    cin >> a >> b >> c >> d;
    a--;
    long be = (b)/c; // cout << e << " ";
    long bf = (b)/d; // cout << f << " ";
    long ae = (a)/c; // cout << e << " ";
    long af = (a)/d; // cout << f << " ";

    long gcd = __gcd(d, c); // cout << gcd << " ";
    long lcm = c * d / gcd; // cout << lcm << " ";
    long bg = (b)/lcm; // cout << g << " ";
    long ag = (a)/lcm; // cout << g << " ";

    cout << (b- (be+bf-bg)) - (a  -(ae+af-ag)) << endl;

    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/python3
# -*- coding: utf-8 -*-



N,K = map(int, input().split())
Sn = str(input())
Rn = [0]
for i in range(1,N):
  if Sn[i] == Sn[i-1]:
    Rn[-1] += 1
  else:
    Rn.append(0)
Rn.sort(reverse=True)

print(min(sum(Rn)+2*K,N-1))

Measured memory_bytes: 45296
#include<bits/stdc++.h>
#define rep(i, n) for(int (i)=0 ;i <(n); ++(i))
#define REP(i,m,n) for(int (i) = (m); (i) <= (n); ++(i))
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)? "YES":"NO")
typedef long long ll;
using namespace std;

int main() {
  int n;
  cin >> n;
  if(n%2 == 0) {
    cout << n << endl;
    return 0;
  }
  cout << n * 2 << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(pow(10, 6))
from collections import deque

edges = []
col = []

def is_bipartite():
    global col
    col = [-1 for _ in range(len(edges))]
    col[0] = 0
    que = deque([0])
    while len(que) != 0:
        q = que.popleft()
        for to in edges[q]:
            if col[to] == -1:
                col[to] = col[q] ^ 1
                que.append(to)
            else:
                if col[q] ^ 1 != col[to]:
                    return False
    return True


def main():
    global edges
    n, m = map(int, input().split())
    edges = [[] for _ in range(n)]
    for _ in range(m):
        a, b = map(int, input().split())
        edges[a-1].append(b-1)
        edges[b-1].append(a-1)
    
    if is_bipartite():
        b = sum(col)
        print(b * (n - b) - m)
    else:
        # そうじゃない
        print(n * (n-1) // 2 - m)


if __name__ == '__main__':
    main()


Measured memory_bytes: 22516
import Control.Monad
import Control.Applicative
import Control.Monad.State

type Weight = Int
type Counters = [Weight]
type WeightState = (Weight, Counters)

solve :: State WeightState Weight
solve = do
  (weight, counters) <- get
  if weight == 0
    then return weight
    else do
      case weight of
        weight | weight >= 2^9 -> put (weight - 2^9, 2^9 : counters)
               | weight >= 2^8 -> put (weight - 2^8, 2^8 : counters)
               | weight >= 2^7 -> put (weight - 2^7, 2^7 : counters)
               | weight >= 2^6 -> put (weight - 2^6, 2^6 : counters)
               | weight >= 2^5 -> put (weight - 2^5, 2^5 : counters)
               | weight >= 2^4 -> put (weight - 2^4, 2^4 : counters)
               | weight >= 2^3 -> put (weight - 2^3, 2^3 : counters)
               | weight >= 2^2 -> put (weight - 2^2, 2^2 : counters)
               | weight >= 2^1 -> put (weight - 2^1, 2^1 : counters)
               | weight >= 2^0 -> put (weight - 2^0, 2^0 : counters)
      solve

main = do
  contents <- (map (snd . (\x -> execState solve (x, [])) . (read :: String -> Int))) . lines <$> getContents
  putStr $ unlines $ map (unwords . (map show)) contents

Measured memory_bytes: 4180
#include<bits/stdc++.h>
using namespace std;
#define res register int
#define ll long long
//#define cccgift
//#define getchar()(p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
//char buf[1<<21],*p1=buf,*p2=buf;
template<typename T>
inline void read(T &x)
{
    static char ch;bool f=1;
    for(x=0,ch=getchar();!isdigit(ch);ch=getchar()) if(ch=='-') f=0;
    for(;isdigit(ch);x=(x<<1)+(x<<3)+(ch^48),ch=getchar());x=f?x:-x;
}
template<typename T>
void print(T x)
{
    if (x<0) x=-x,putchar('-');
    if (x>9) print(x/10);
    putchar(x%10+48);
}
template<typename T>
inline void print(T x,char ap) {print(x);if (ap) putchar(ap);}
template<typename T>
inline void chkmax(T &x,const T &y) {x=x<y?y:x;}
template<typename T>
inline void chkmin(T &x,const T &y) {x=x<y?x:y;}
const int mod=1e9+7;
int n,a[100001],tot,fac[100001];
#define inc(x,y) x+=y,x>=mod?x-=mod:0
inline int kuai(int p,int q,int mod) {int tot=1;for(;q;p=(ll)p*p%mod,q>>=1) if(q&1) tot=(ll)tot*p%mod;return tot;}
int main()
{
	ios::sync_with_stdio(false);
	cin>>n;
	for(res i=1;i<=n;++i) cin>>a[i];
	fac[0]=1;
	for(res i=1;i<=n;++i) fac[i]=(ll)fac[i-1]*i%mod;
	for(res i=1;i<n;++i) inc(tot,(ll)(a[n]-a[i])*kuai(i,mod-2,mod)%mod);
	cout<<(ll)tot*fac[n-1]%mod<<'\n';
	cout<<flush;	
	return 0;
}
/* stuff you should look for
    * int overflow, array bounds
    * special cases (n=1?), set tle
    * do something instead of nothing and stay organized
*/ 

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

struct UF{
  vector<int>par,rank;
  UF(int n){
    par.resize(n);
    rank.resize(n,0);
    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){
    x=root(x);
    y=root(y);
    if(rank[x]<rank[y]){
      par[y]=x;
    }
    else{
      par[x]=y;
      if(rank[x]==rank[y]){
        rank[x]++;
      }
    }
  }
  bool isSame(int x,int y){
    return root(x)==root(y);
  }
};

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

  int N,M;
  cin>>N>>M;
  vector<int>X(M),Y(M),Z(M);
  for(int i=0;i<M;i++)cin>>X[i]>>Y[i]>>Z[i];
  UF uf(N+1);
  for(int i=0;i<M;i++){
    uf.unite(X[i],Y[i]);
  }
  int ans=0;
  for(int i=1;i<=N;i++){
    if(uf.par[i]==i)ans++;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 2176
// acdart
#include <iostream>
#include <cstring>
#include <algorithm>
#include <stdio.h>
#include <cstring>
#include <cmath>
#include <cctype>
#include <string>
#include <numeric>
#include <utility>
#include <queue>
#include <memory>
#include <vector>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <cstdlib>
#include <list>
#include <limits.h>
#include <utility>
#include <functional>
#include <iterator>
#include <deque>
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define X first
#define Y second
#define F first
#define S second
#define MOD9 1000000009ll
#define MOD7 1000000007ll
#define MOD
#define INF  1023456789ll
#define INF16 10000000000000000ll
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define SZ(x) ((int)(x).size())
#define MAXN 10010
#define MAXM
#define ALL(x) ((x).begin()),((x).end())
#define RESET(a,b) memset(a,b, sizeof a)
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define LEN(X) strlen(X)
#define FI(a,b,c) for(int a=b; a<c; a++)
#define FD(a,b,c) for(int a=b; a>c; a--)
using namespace std;
typedef long long ll;
typedef long long LL;
typedef double db;
typedef double D;
typedef long double ld;
typedef long double LD;
/*********default*********/
// #define ONLINE_JUDGE

int main()
{/*
	#ifdef ONLINE_JUDGE
    	freopen("aplusb.in", "r", stdin);
    	freopen("aplusb.out", "w", stdout);
	#endif*/
	int a, b, c;
	
	scanf("%d%d%d", &a, &b, &c);
	puts(c >= a && c <= b ? "Yes" : "No");
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
typedef int64_t int64;
typedef uint32_t uint;
typedef uint64_t uint64;
using namespace std;

//---

template <typename T>
inline void print(const T& rhs){ std::cout<<" = "<<rhs<<std::endl; }
template <typename T>
inline void print(const std::vector<T>& rhs){
    std::cout<<" = [ ";
    for(uint i=0; i<rhs.size(); ++i){ std::cout<<rhs[i]<<' '; }
    std::cout<<"]"<<std::endl;
}
template <typename T>
inline void print(const std::vector<std::vector<T>>& rhs){
    std::cout<<" = "<<std::endl;
    std::cout<<"[[ ";
    for(uint p=0; p<rhs.size(); ++p){
        if(p!=0){ std::cout<<" [ "; }
        for(uint q=0; q<rhs[p].size(); ++q){
            std::cout<<rhs[p][q]<<' ';
        }
        if(p!=rhs.size()-1){ std::cout<<"]"<<std::endl; }
    }
    std::cout<<"]]"<<std::endl;
}
template <typename TL, typename TR>
inline void print(const std::vector<std::pair<TR,TL>>& rhs){
    std::cout<<" = [";
    uint i=0;
    for(; i<rhs.size()-1; ++i){ std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"], "; }
    std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"]]" << endl;
}
#define printn(var) {printf("%s", #var);print(var);}
#define printn_all(var) {printf("%s(%d): ", __func__, __LINE__);printf("%s", #var);print(var);}

//---

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int N, A; cin >> N >> A;
    cout << (N%500<=A?"Yes":"No") << endl;
    
    return 0;
}

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

using namespace std;

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



int main(){
    long long a;
    cin>>a;
    long long happy;
    happy = (a/500)*1000;
    a = a % 500;
    happy = happy + (a/5)*5;
    cout<<happy<<endl;
}


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

int64_t gcd(int64_t a, int64_t b){
  int64_t buf;
  while(b > 0){
    buf= a;
    a= b;
    b= buf%b;
  }
  return a;
}

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

  vector<int> data(N);
  for(int i=0; i<N; i++){
    cin >> data.at(i);
  }

  int Amax= *max_element(data.begin(), data.end());
  int g= data.at(0);
  for(int i=1; i<N; i++){
    g= gcd(g, data.at(i));
  }

  string ans= (Amax >= target && (Amax- target) % g==0) ? "POSSIBLE"
                                                        : "IMPOSSIBLE";
  cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
const int maxn = 333;
long long g[maxn][maxn];
int main(){
  for(int i = 0; i < maxn; i++) for(int j = 0; j < maxn; j++) g[i][j] = 1ll<<60;
  for(int i = 0; i < maxn; i++) g[i][i] = 0;
  int n, m, r; cin >> n >> m >> r;
  vector<int> to(r);
  for(int i = 0; i < r; i++) cin >> to[i];
  for(int i = 0; i < m; i++){
    int a, b, c; cin >> a >> b >> c;
    g[a][b] = min(g[a][b], 1ll * c);
    g[b][a] = min(g[b][a], 1ll * c);
  }
  for(int k = 1; k <= n; k++) for(int i = 1; i <= n; i++) for(int j = 1; j <= n; j++)
    g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
  sort(to.begin(), to.end());
  long long ans = 1ll<<60;
  do {
    long long now = 0;
    for(int i = 1; i < r; i++) now += g[to[i - 1]][to[i]];
    ans = min(ans, now);
  } while(next_permutation(to.begin(), to.end()));
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1152
n=int(input())
a=list(map(int,input().split()))
four=0
two=0
one=0
for i in a:
    if i%4==0:
        four+=1
    if i%2==0:
        two+=1
    else:
        one+=1
if int(n/2)==four:
    print('Yes')
elif n==two:
    print('Yes')
elif four == one + 1 or four == one:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 14252