akhauriyash/Code-Regression huggingface dataset:
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

import fractions
n,k = inm()
a = inl()
#g = reduce(fractions.gcd,a)
g = a[0]
for i in range(1,n):
    g = fractions.gcd(g,a[i])
print('POSSIBLE' if k%g==0 and k<=max(a) else 'IMPOSSIBLE')


Measured memory_bytes: 88172
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#pragma warning( disable:4996 )
using namespace std;

#define SWAP(a,b) (a += b,b = a - b,a -= b)
#define MIN(a, b) ((a) < (b) ? (a) : (b))

#define MOD 1000000007

int dp_right[1000001];
int dp_middle[1000001];
int dp_left[1000001];
typedef long long ll;
map<int,int> list_right, list_middle, list_left;

struct p {
	long long a;
	long long b;
};

struct p f(ll a, ll b) {
	if (b == 0) {
		struct p hoge;
		hoge.a = 1;
		hoge.b = 0;
		return hoge;
	}
	ll s, t;
	struct p temp = f(b, a % b);
	s = temp.a;
	t = temp.b;
	struct p ret;
	ret.a = t;
	ret.b = s - a / b * ret.a;
	return ret;
}

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

int main(void) {

	
	int x, y;
	scanf("%d %d", &x, &y);

	if ((x%y==0 && x/y==2) || (y % x == 0 && y / x == 2)) {
		printf("1\n");
		return 0;
	}
	if ((2 * x - y) % 3 == 0) {
		long long m = (2LL * x - y)/3;
		if (m > 0) {
			long long n = x - 2LL * m;
			if (n > 0) {
				long long up = 1;
				for (long long i = 1; i <= n + m; i++) {
					up *= i;
					up %= 1000000007LL;
				}
				long long left = 1;
				for (long long i = 1; i <= n; i++) {
					left *= i;
					left %= 1000000007LL;
				}
				ll right = 1;
				for (long long i = 1; i <= m; i++) {
					right *= i;
					right %= 1000000007LL;
				}
				//long long ans = up / down;
				/*struct p ret_left = f(left, 1000000007);
				struct p ret_right = f(right, 1000000007);
				ll ans = up* (ret_left.a%1000000007);
				ans %= 1000000007;
				ans *= ret_right.a % 1000000007;
				ans %= 1000000007;*/
				ll leftorg = left;
				ll rightorg = right;
				/*for (int i = 0; i < 1000000007-3; i++) {
					left *= leftorg;
					left %= 1000000007;
					right *= rightorg;
					right %= 1000000007;
				}*/
				left = fastpow(left, MOD-2);
				right = fastpow(right, MOD - 2);
				ll ans = up * left;
				ans %= 1000000007;
				ans *= right;
				ans %= 1000000007;

				printf("%lld\n", ans);
			}
			else {
				printf("0\n");
			}
		}
		else {
			printf("0\n");
		}
	}
	else {
		printf("0\n");
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
#include <complex>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <iomanip>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)),(v).end())
#define bitcnt(x) __builtin_popcount(x)
#define fst first
#define snd second
#define Pqaz(T) priority_queue<T,vector<T>,greater<T>>
#define Pqza(T) priority_queue<T>
#define put(x) cout << x;
#define putsp(x) cout << x << ' ';
#define putbd cout << "---------------------------------------------" << endl;
#define putln(x) cout << x << endl;
#define debug(x) cerr << #x << "=" << x << endl;
#define ENJYU std::ios::sync_with_stdio(false);std::cin.tie(0);
#define yuiyui 0

typedef long long ll;
typedef unsigned long long ul;
typedef pair<int, int> intP;
typedef pair<ll, ll> llP;
typedef pair<ul, ul> ulP;
typedef complex<double> comp;
typedef vector <int> vec;
typedef vector <ll> vecll;
typedef vector <ul> vecul;
typedef vector <double> vecd;
typedef vector <vec> mat;
typedef vector <vecll> matll;
typedef vector <vecul> matul;
typedef vector <vecd> matd;

//vector の中身を出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

const int MAX = 200020;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const ll INFL = 1e18;
const ll MOD = 1e9+7;

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

//********************************template END****************************************//

void solve(void){

	long double a,b,c,d,e,f;

	while(~scanf("%Lf%Lf%Lf%Lf%Lf%Lf\n", &a,&b,&c,&d,&e,&f))
	{
		long double x = (c*e-b*f)/(a*e-b*d);
		long double y = (c*d-a*f)/(b*d-a*e);

		if (abs(x)<1e-4) x = abs(x);
		if (abs(y)<1e-4) y = abs(y);

		printf("%.3Lf %.3Lf\n", x, y);

	}

}

int main(void)
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return yuiyui;
}



Measured memory_bytes: 3148
# 解説放送の方針
# 平面走査をし、各点について、左上、左下、右上、右下にある点を数え、計算する。
# 解説放送ではBITを2本使っていたが、座標圧縮の結果を利用してBIT１本で済むようにした

N = int(input())
xy = [tuple(map(int,input().split())) for _ in range(N)]

mod = 998244353

class BIT:
    '''https://tjkendev.github.io/procon-library/python/range_query/bit.html'''
    def __init__(self, n):
        self.n = n
        self.data = [0]*(n+1)
        self.el = [0]*(n+1)
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.data[i]
            i -= i & -i
        return s
    def add(self, i, x):
        self.el[i] += x
        while i <= self.n:
            self.data[i] += x
            i += i & -i
    def query(self, i, j=None):
        if j is None:
            return self.el[i]
        return self.sum(j) - self.sum(i)

# 平面走査のためのソート（高速化のため１次元にしてソート）
xy2 = []
for i in range(N):
  x,y = xy[i]
  x += 10**9
  y += 10**9
  xy2.append(y<<80 | x << 40 | i)

# ソート後の復元+座標圧縮用の辞書作成
# 座標圧縮: 小さいyから順に1,2,3...と値を割り振る。
xy2 = sorted(xy2)
mask = (1<<40)-1
y_order=[0]*N
y_compress={}
for j,y in enumerate(xy2):
  i = y & mask
  y >>= 40
  x = y & mask
  x -= 10**9
  y >>= 40
  y -= 10**9
  y_order[i] = j
  y_compress[y] = j+1

xy2 = []
for i in range(N):
  x,y = xy[i]
  x += 10**9
  y += 10**9
  xy2.append(x<<80 | y << 40 | i)
  
xy2 = sorted(xy2)
mask = (1<<40)-1
bit=BIT(N)
ans = 0
memo=[0]*N

# いちいち2^nを計算していると遅いのでメモ化
def pow2(x):
  if memo[x-1]:return memo[x-1]
  out = pow(2,x,mod)
  memo[x-1] = out
  return out

for x in xy2:
  i = x & mask
  x >>= 40
  y = x & mask
  y -= 10**9
  x >>= 40
  x -= 10**9
  
  y = y_compress[y]
  bit.add(y,1)
  '''
  今現在みている点より左上と左下にある点の個数（今の点は含まない。以下同じ）。
  BITを使って求める。
  '''
  n1 = bit.query(y-1,N)-1
  n2 = bit.query(0,y)-1 
  '''
  右上と右下。座標圧縮の結果を利用。(N-y(座標圧縮済))はある点より上にある点の総数。
  そこからn1（走査済みの点の個数)を引くことで、まだ走査していない点の個数を求めることができる。
  '''
  n3 = N-y-n1 
  n4 = y-n2-1
  
  prod14 = (pow2(n1)-1)*(pow2(n4)-1)*pow2(n2+n3) %mod
  prod23 = (pow2(n2)-1)*(pow2(n3)-1)*pow2(n1+n4) %mod
  prod1234 = (pow2(n1)-1)*(pow2(n4)-1)*(pow2(n2)-1)*(pow2(n3)-1) %mod
  ans += pow2(N-1)+prod14+prod23-prod1234
  ans %= mod
  
print(ans)

Measured memory_bytes: 214256
#include<bits/stdc++.h>
using namespace std; 
#define int long long 
#define mod (int)(1e9)
#define endl '\n'
#define MAXI (int)(3e18+10)
#define N 200005



// Driver code to test above functions
int32_t main()
{
   
     
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);

    int m, n;
    cin >> m >> n;

    int sum = 0;
    for(int i=0;i<n;i++)
    {
        int x;
        cin >> x;
        sum += x;
    }

    if(m<sum)
        cout << -1;
    else
        cout << m-sum; 



    return 0;
}  

Measured memory_bytes: 3656
from collections import Counter
mod = 1000000007


def inverse(a):
    return pow(a, mod - 2, mod)


def usearch(x, a):
    lft = 0
    rgt = len(a) + 1
    while rgt - lft > 1:
        mid = (rgt + lft) // 2
        if a[mid] <= x:
            lft = mid
        else:
            rgt = mid
    return lft


def update(x, y, new_value, dp):
    if 0 <= x < len(dp) and 0 <= y < len(dp):
        dp[x][y] = min(dp[x][y], new_value)

def main():
    n,k=map(int, input().split())
    print(len([i for i in input().split() if int(i) >= k]))
main()


Measured memory_bytes: 10372
#include <vector>
#include <algorithm>
#include <iostream>
#include <queue>
#include <limits>
#include <math.h>
#include <string>
#include <map>

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  int ans = 0;
  for (int i = 0; i < n - 1; ++i) {
    if (a[i] == a[i + 1]) {
      a[i + 1] = 100000000;
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


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

// #define ANS  //for answer
#define CMP  //for compe

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
#define nv(x) #x,(x)
#define ncv(x) #x,":",(x)
#define ncvc(x) #x,":",(x),","
using ll = long long;
void pPRINT(std::ostream& ost) {}
template <class T, class... U>void pPRINT(std::ostream& ost,const T t,const U... u) {ost<<t<<" ";pPRINT(ost, u...);}
template <class... T>void PRINT(const T... t) {pPRINT(std::cout, t...);}
template <class... T>void PRINTl(const T... t){pPRINT(std::cout,t...);std::cout<<"\n";}
template <class T>void PRINTa(const T* const t,const ll size){REP(i,size)PRINT(t[i]);PRINTl();}
template <class T>void PRINTal(const T* const t,const ll size){REP(i,size)PRINTl(i,":",t[i]);}
#ifdef CMP
using namespace std;
#else
#endif
#ifndef DBG
#define DEBUG(...)
void init(){}
#else
#define DEBUG(...) PRINT("##DEBUG##","file :",__FILE__,", line :",__LINE__,"[");PRINT(__VA_ARGS__);PRINTl("]");
void init(){
  cin.tie(0);
  ios::sync_with_stdio(false);
}
#endif
#ifdef ANS
#else
#endif

void solve();

int main(int argc, char *argv[]) {

  init();
  DEBUG();
  solve();

  return 0;
}

#define sss(i) (int)(s[i]-'0')

void solve(){

  DEBUG("SOLVE START");
  string s;cin>>s;
  DEBUG(s,s[2],sss(2),s[1],sss(1),s[0],sss(0));
  if(sss(0)>sss(1)){
    cout<<sss(0)*111;
  }
  else if(sss(0)==sss(1)){
    if(sss(1)>=sss(2)){
    cout<<sss(0)*111;
    }
    else{
      cout<<(sss(0)+1)*111;
    }
  }else{
    cout<<(sss(0)+1)*111;
  }
}

Measured memory_bytes: 256
s = gets.to_i
dp = []
dp.push(1,0,0)
(3..s).each do |i|
  (0..i-3).each do |j|
    dp[i] ||= 0
    dp[i] += dp[j]
    dp[i] %= 10**9+7
  end
end
puts dp[s]


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

using namespace std;
#define int long long
#define INF 10e9
#define pb push_back
int N;
int call(int idx, vector<int> &dp,vector<vector<int> >& GRAPH,int parent)
{
    int i=idx;
    if(dp[idx]!=-1)
    {
        return dp[i];
    }
    dp[i]=0;
    int m=0;
    for(int j=0;j<GRAPH[idx].size();j++)
    {
        if(GRAPH[idx][j]==parent)
        continue;
        m=max(m,call(GRAPH[idx][j],dp,GRAPH,idx));
    }
    return dp[i]=m+1;
}
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int M;
    cin>>N>>M;
    vector<vector<int> >GRAPH(N+1);
    
    for(int i=0;i<M;i++)
    {
        int x,y;
        cin>>x>>y;
        GRAPH[x].pb(y);
    }
    
    vector<int> dp(N+1,-1);
    int ans=0;
    for(int i=1;i<=N;i++)
    {
        if(dp[i]==-1)
        {
           // cout<<i<<"  jh";
            call(i,dp,GRAPH,-1);
        }
       // cout<<dp[i]<<" ";
        ans=max(ans,dp[i]);
    }
    cout<<ans-1;
    
    return 0;
    
}

Measured memory_bytes: 9984
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  string s;
  cin >> s;
  string pt = "keyence";
  if (s == pt) {
    cout << "YES" << endl;
    return 0;
  }
  int n = s.size();
  for (int i = 0; i < n; ++i) {
    string s1 = s.substr(0, i);
    for (int j = i; j < n; ++j) {
      string s2 = s.substr(j, n);
      if (s1 + s2 == pt) {
        cout << "YES" << endl;
        return 0;
      }
    }
  }
  cout << "NO" << endl;
  return 0;
}

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

// 計算量
//   N-1 * N-2 * ... * 2 * 1
// = (N-1 + 1) * (N-1 / 2)
// = (N) * (N-1 / 2)
// = (N**2 - N) / 2
// = O(N**2)
vector<int> bubble_sort(vector<int> &A, int N, int &num_of_exchanges) {
  // # while ループ1回目
  // * 5 3 2 4 1
  //   * 1 < 4 のため、4 1 をひっくり返す
  // * 5 3 2 1 4
  //   * 1 < 2 のため、2 1 をひっくり返す
  // * 5 3 1 2 4
  //   * 1 < 3 のため、3 1 をひっくり返す
  // * 5 1 3 2 4
  //   * 1 < 5 のため、5 1 をひっくり返す
  // * 1 5 3 2 4
  //
  // # while ループ2回目
  // * 1 5 2 3 4
  //   * 4 > 3 のため、3 4 はひっくり返さない
  // * 1 5 2 3 4
  //   * 3 > 2 のため、2 3 はひっくり返さない
  // * 1 5 2 3 4
  //   * 2 < 5 のため、5 2 はひっくり返す
  // * 1 2 5 3 4
  //   * 2 > 1 のため、1 2 はひっくり返さない
  //
  // # while ループ3回目 (省略)
  // * 1 2 3 5 4
  //
  // # while ループ4回目 (省略)
  // * 1 2 3 4 5
  //
  // 最終的に5個の要素に「逆の隣接要素」が存在しなくなる。
  // その結果、for ループで existing = true が代入されなくなる。
  // existing = false のため while ループが終了する。
  //
  bool existing = true;
  int i = 0; // 未ソートの部分の先頭を指すループ変数
  int loop_counter = 0;
  while (existing) {
    existing = false;
    for (int j = N-1; j >= i+1; j--) {
      if (A.at(j) < A.at(j-1)) {
        swap(A.at(j), A.at(j-1));
        num_of_exchanges++;
        existing = true;
      }
      loop_counter++;
    }
    i++;
  }

  return A;
}

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

  int num_of_exchanges = 0;
  bubble_sort(v, n, num_of_exchanges);

  for (int i = 0; i < n; i++) {
    cout << v.at(i);
    if (i < n - 1) {
      cout << " ";
    }
  }
  cout << endl;
  cout << num_of_exchanges << endl;

  return 0;
}



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

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; }

using ll = long long;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007LL;

ll pow(ll a, ll n, ll m) {
	ll ret = 1LL;
	for (; n > 0LL; n >>= 1LL, a = a * a % m) {
		if (n % 2LL == 1LL) {
			ret = ret * a % m;
		}
	}
	return ret;
}

ll combination(ll x, ll y){
  if(y>x) return 0LL;
  ll c = 1LL;
  for(ll i = 0LL; i < y; i++){
    c *= (x-i)%mod;
    c %= mod;
    c*= pow(i+1,mod-2,mod);
    c%=mod;
  }
  return c;
}

int main() {
  ll N, K;
  cin >> N >> K;
  for(ll i = 1LL; i <= K; i++) {
    cout<<((combination(K-1,i-1)*combination(N-K+1,i))%mod) << endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<math.h>
using namespace std;

int main(void){
    int i,n;
    double ans;
    cin >> n;
    ans=100.000;
    for(i=0;i<n;i++){
        ans*=1.05;
        ans=(int)(ans+0.999);
        ans=(double)ans;
    }
    ans*=1000;
    printf("%d\n",(int)ans);
    return 0;
}

Measured memory_bytes: 3152
#include<stdio.h>

int main(){
  int a,b;
  scanf("%d%d", &a, &b);
  if ( a < b ){
  printf("a < b\n",a,b);
    }
  else if ( a > b ){
  printf("a > b\n",a,b);
    }
 else if( a == b ){
 printf("a == b\n",a,b);
    }
  return 0;
}

Measured memory_bytes: 580
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>

using namespace std;

#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk
#define prev asdasfsadjkjsdfjs

const int MAXN = 105000;

int n, total;
long long dp[MAXN];
int w[MAXN], v[MAXN];

int main() { 

  scanf("%d %d", &n, &total);

  for (int i = 0; i < n; i++) {
    scanf("%d %d", &w[i], &v[i]);
  }

  for (int i = 0; i < n; i++) {
    for (int j = total; j >= w[i]; j--) {
      dp[j] = max(dp[j], dp[j - w[i]] + v[i]);
    }
  }

  cout << dp[total] << endl;

  return 0;
}


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

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

ll lcm(ll a, ll b){
	return (a*b) / gcd(a, b);
}

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

	ll n,i,j,xo;
	cin >> n;

	ll a[n];

	cin >> a[0];
	xo = a[0];

	for(i=1;i<n;i++)
	{
		cin >> a[i];
		xo = xo^a[i];
	}

	for(i=0;i<n-1;i++)
	{
		ll z = a[i]^xo;
		cout << z << " ";
	}

	ll z = a[n-1]^xo;
	cout << z << endl;


}

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

using namespace std;

#define vit vector<int>::iterator
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define forn(i, n) for(int i = 0; i < int(n); i++)
#define fr first
#define sc second
#define skip continue
#define PI 3.14159265

typedef unsigned long long ull;
typedef long long ll;
typedef unsigned int ui;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<bool> vb;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const ll MAXN = 3e5 + 3;
const int  M   =   1e9+7;

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

bool cmp(const string& a, const string& b) {
    return (a + b) < (b + a);
}

void solve(){
    int a;
    cin >> a;
    if(a >= 1200) cout << "ARC";
    else cout << "ABC";
}


int main(){
    //freopen("slalom.in","r",stdin);
    //freopen("slalom.out","w",stdout);
    //faster();
    int n = 1;
    //cin >> n;
    while(n--){
        solve();
        cout << endl;
    }
    //fclose(stdout);
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define VV vector
#define pb push_back
#define bitc  __builtin_popcountl
#define m_p make_pair
#define inf 1000000000000000000
#define MAXN 1000001
#define eps 0.0000000001
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<class T>//usage rand<long long>()
T rand() {
    return uniform_int_distribution<T>()(rng);
}

// string to integer stuuu()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();

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

#define S second
#define F first
#define int long long  

//////////

signed main()
{
	fastio;
	// #ifndef ONLINE_JUDGE
	// 	freopen("inputf.in","r",stdin);
	// 	freopen("outputf.in","w",stdout);
	// #endif
	int n;
	cin>>n;
	string s;
	cin>>s;
	int mo=1000000007;
	int f[26]={};
	for(int i=0;i<n;++i)
	{
		f[s[i]-'a']++;
	}
	int ans=1;
	for(int i=0;i<26;++i)
	{
		ans*=f[i]+1;
		ans%=mo;
	}
	ans--;
	ans+=mo;
	ans%=mo;
	cout<<ans;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <ext/rope>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define ll long long
#define int long long
#define pb push_back
#define x first
#define ld long double
#define y second
#define mk(a,b) make_pair(a,b)
#define rr return 0
#define sqr(a) ((a)*(a))
#define all(a) a.begin(),a.end()

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;
template<class value, class cmp = less<value> >
using ordered_set = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class value, class cmp = less_equal<value> >
using ordered_multiset = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class key, class value, class cmp = less<key> >
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;

/// find_by_order()
/// order_of_key()
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
inline int randll(int l = INT_MIN, int r = INT_MAX) {
    return uniform_int_distribution<int>(l, r)(rng);
}
main()
{
    ios::sync_with_stdio(0);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, a, b, x, y;
    cin >> n;
    cin >> a >> b;
    for (int i = 1; i < n; i++) {
        cin >> x >> y;
        int g = max((a + x - 1) / x, (b + y - 1) / y);
        a = g * x;
        b = g * y;
    }
    cout << a + b << '\n';
}


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

#include <algorithm>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;

long long mod = 1000000007;

long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t * t;
    } else {
        return modpow(m, n - 1) * m;
    }
}
typedef long long ll;
typedef pair<ll, ll> P;

void yes() {
    cout << "Yes" << endl;
    exit(0);
}
void no() {
    cout << "No" << endl;
    exit(0);
}
#define REP(i, n) for (long long i = 0; i < (n); i++)
vector<long long> dijkstra(vector<vector<pair<long long, long long>>> graph, long long s) {
    vector<long long> ans(graph.size(), -1);
    priority_queue<pair<long long, long long>, vector<pair<long long, long long>>, greater<pair<long long, long long>>>
        pq;
    pq.push({0, s});
    while (pq.size() > 0) {
        ll cur1 = 0;
        ll cur2 = 0;
        if (ans[pq.top().second] != -1) {
            pq.pop();
        } else {
            cur1 = pq.top().first;
            cur2 = pq.top().second;
            pq.pop();
            ans[cur2] = cur1;
            for (long long i = 0; i < graph[cur2].size(); i++) {
                pq.push({cur1 + graph[cur2][i].second, graph[cur2][i].first});
            }
        }
    }
    return ans;
}
vector<vector<P>> yen_graph;
signed main() {
    int n, m, s, t;
    cin >> n >> m >> s >> t;
    s--;
    t--;
    vector<vector<P>> yen_graph(n), snuuk_graph(n);
    for (int i = 0; i < m; i++) {
        int u, v, a, b;
        cin >> u >> v >> a >> b;
        u--;
        v--;
        yen_graph[u].push_back({v, a});
        yen_graph[v].push_back({u, a});
        snuuk_graph[u].push_back({v, b});
        snuuk_graph[v].push_back({u, b});
    }
    vector<long long> yen_costs = dijkstra(yen_graph, s);
    vector<long long> snuuk_costs = dijkstra(snuuk_graph, t);
    // cout << "hogrider" << endl;
    long long min_cost = 1e18;
    vector<ll> as(n);
    for (int j = n - 1; j >= 0; j--) {
        long long total_cost = yen_costs[j] + snuuk_costs[j];
        min_cost = min(min_cost, total_cost);
        as[j] = min_cost;
    }
    for (int i = 0; i < n; i++) {
        cout << 1000000000000000 - as[i] << endl;
    }
}

Measured memory_bytes: 26856
#include <stdio.h>
#include <string.h>
int n, a[20], y, x;
int main(){
    scanf("%d", &n);
    int x = 1; 
    int y = 1;
    for (int i = 1; i <= n; ++i){
        scanf("%d", a + i);
        if (!(a[i] & 1)){
            x *= 2;
        }
        y *= 3;
    }
    printf("%d\n", y - x);
}

Measured memory_bytes: 128
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000)
INF = 1<<32


def solve(N: int, S: "List[str]", P: "List[int]"):
    sp = [[i, S[i], P[i]] for i in range(N)]

    sp = sorted(sp, key=lambda x:(x[1],-x[2]))

    for i in range(N):
        print(sp[i][0]+1)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = [str()] * (N)  # type: "List[str]"
    P = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        S[i] = next(tokens)
        P[i] = int(next(tokens))
    solve(N, S, P)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807
#define INF I64_MAX/2
#define MOD 1000000007
#define MEM_SIZE 10000

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){std::cout << e << std::endl;}
template<class T> void DEBUG(string str, T e){std::cout <<str << ">>" << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ DEBUG(v); } }
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }




void update(vector<int> & Segtree, int k, int a,int N)
{
  k += N -1;
  Segtree[k] = a;
  while(k > 0)
  {
    k = (k-1)/2;
    Segtree[k] = min(Segtree[2*k+1],Segtree[2*k + 2]);
  }
}

int query(vector<int> & Segtree,int a, int b, int k, int l,int r)
{
  // DEBUG(k);
  if(r <= a || b <= l) return 2147483647;
  if(a <= l && r <= b) return Segtree[k];
  else
  {
    int vl = query(Segtree,a,b,k*2+1,l,(r+l)/2);
    int vr = query(Segtree,a,b,k*2+2,(l+r)/2,r);
    return min (vr,vl);
  }

  

}

void solve(void)
{
  int N,Q;
  cin>>N>>Q;
  int _N = 1;
  while(_N < N) _N *= 2;
  N = _N;
  vector<int> Segtree(2*N - 1,2147483647);
  // DEBUG(N);
  for (int i = 0; i < Q; i++)
  {
    int A,B,C;
    cin>>A>>B>>C;
    if(A == 0)
    {
      update(Segtree,B,C,N);
    }
    else
    {
      cout<<query(Segtree,B,C+1,0,0,N)<<endl;;
    }
    

  }
  


  return; 
}


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

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

 
  return 0;
}


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

using namespace std;

#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define INF (1 << 29)
#define LLINF (1LL << 60)
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

using Pi = pair<int, int>;
using ll = long long;

string to_string(string s) { return s; }
template <class S>
string to_string(unordered_set<S> s);
template <class S>
string to_string(set<S> s);
template <class S, class T>
string to_string(map<S, T> m);
template <class T>
string to_string(vector<T> v);

template <class S, class T>
string to_string(pair<S, T> p) {
  return "{" + to_string(p.first) + "," + to_string(p.second) + "}";
}

template <class S>
string to_string(unordered_set<S> s) {
  string ret = "{";
  for (S x : s) ret += to_string(x) + ",";
  return ret + "}";
}

template <class S>
string to_string(set<S> s) {
  string ret = "{";
  for (S x : s) ret += to_string(x) + ",";
  return ret + "}";
}

template <class S, class T>
string to_string(map<S, T> m) {
  string ret = "{";
  for (pair<S, T> x : m) ret += to_string(x) + ",";
  return ret + "}";
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  for (int i = 0; i < (int)v.size() - 1; ++i) {
    ret += to_string(v[i]) + ",";
  }
  if (v.size() > 0) {
    ret += to_string(v.back());
  }
  ret += "}";
  return ret;
}

void debug() { cerr << endl; }

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() { cout << endl; }

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

int main() {
  cin.tie(0);
  int N, C;
  cin >> N >> C;
  constexpr int MAX = 100002 * 2;
  vector<int> acc(MAX);
  vector<set<int>> start(C), end(C);
  FOR(i, N) {
    int s, t, c;
    cin >> s >> t >> c;
    s *= 2;
    t *= 2;
    acc[s - !end[c - 1].count(s)]++;
    acc[t - start[c - 1].count(t)]--;
    start[c - 1].insert(s);
    end[c - 1].insert(t);
  }
  FORIN(i, 1, MAX) acc[i] += acc[i - 1];
  print(*max_element(ALL(acc)));
  return 0;
}

Measured memory_bytes: 10496
import java.util.*;
class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		long w=sc.nextInt();
		long h=sc.nextInt();
		long x=sc.nextInt();
		long y=sc.nextInt();

		System.out.println(w*h*0.5+" "+(x*2==w&&y*2==h?1:0));

	}
		
}

Measured memory_bytes: 23380
/*
Author: Racer5x
 ***************************************   UNAUTHORISED COPYING OF CODE PROHIBITED   **********************************
*/
 
// #pragma GCC optimize("O3")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#include<bits/stdc++.h>
#define int         long long
#define double      long double
#define pb          emplace_back
#define pf          emplace_front
#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 rall(a)     (a).rbegin(),(a).rend()
#define x           first
#define y           second
#define endl        '\n'
#define hell        998244353 
#define PI          3.141592653589
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MAX         2000000000000000000
#define M           1000000007
using namespace std;
 
signed main()
{
    tezz
    
    int a, b, c;
    cin>>a>>b>>c;

    if((a+b+c) >= 22) cout<<"bust";
    else cout<<"win";
} 

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

// typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

// rep
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
#define DEBUG(x) cerr << #x << ": " << x << '\n'

const int INF = 1LL << 62;

int n, k;
VI v(100010);

signed main()
{
    cin >> n >> k;
    REP(i, n){
        cin >> v[i];
    }
    v.resize(n);

    int res = INF;
    if (n - k == 0){
        int r = abs(v[0]) + abs(v[k-1] - v[0]);
        int l = abs(v[k-1]) + abs(v[k-1] - v[0]);
        res = min(res, min(r, l));
    } else {
    FOR(i, 0, n - k+1){
        int left = v[i];
        int right = v[i+k-1];
        int r = abs(left) + abs(left - right);
        int l = abs(right) + abs(left - right);
        res = min(res, min(r, l));
    }
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1LL << 60;

int main() {
    string s; cin >> s;
    int cnt = 0;
    for (int i = 0; i < 3; i++) {
        if (s[i] == '1') cnt++;
    }

    cout << cnt << endl;
    return 0;
}

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

using namespace std;

#define N 300000

int n,T,p[N];

bool cyc(int x,int y,int z){
	return (p[x]<p[y]&&p[y]<p[z])||(p[y]<p[z]&&p[z]<p[x])||(p[z]<p[x]&&p[x]<p[y]);
}

int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;++i){
		int x; scanf("%d",&x);
		p[x]=i;
	}
	p[n+1]=n+1;
	T=0;
	for (int i=n,f=0;i;--i){
		if (T==0){
			if (p[i]>p[i+1]){++T; f=i+1;}
		}
		else{
			if (!cyc(f,i,i+1)){++T; f=i+1;}
		}
	}
	printf("%d\n",T);
	
	return 0;
}
			

Measured memory_bytes: 1024
//abc178_a.cpp
//Sun Sep 13 20:42:00 2020

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007
#define rep(i,n) for (int i=0;i<(n);++i)

using namespace std;
using ll=long long;
typedef pair<int,int> P;

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


	if (n==0){
		cout << 1 << endl;
	}else {
		cout << 0 << endl;
	}
//	printf("%.4f\n",ans);
}

Measured memory_bytes: 3632
#include<stdio.h>
#include<string.h>
int N,M,i,j,P[105][105],Q[4][55][55];

void rot(int A[55][55],int B[55][55])
{
	int i,j;
	for(i=0;i<M;i++)
		for(j=0;j<M;j++)
			B[i][j]=A[j][M-i-1];
}

int ch(int y,int x)
{
	int i,j,k,r=15;
	for(i=0;i<M;i++)
		for(j=0;j<M;j++)
		{
			for(k=0;k<4;k++)
				if((r&(1<<k))&&Q[k][i][j]!=-1&&P[y+i][x+j]!=Q[k][i][j])
					r&=(~(1<<k));
			if(r==0)return r;
		}
	return r;
}

void f()
{
	int i,j,k,t,r=999999999,y,x,q;
	for(i=0;i<=N-M;i++)
		for(j=0;j<=N-M;j++)
		{
			if((t=ch(i,j))!=0)
			{
				for(k=0;k<4;k++)
				{
					for(y=0;y<M;y++)
						for(x=0;x<M;x++)
							if((1<<k)&t&&Q[k][y][x]!=-1)
							{
								r=r<y*1000+x?r:y*1000+x;
								goto e;
							}
					e:;
				}
				printf("%d %d\n",j+r%1000+1,i+r/1000+1);
				return;
			}
		}
	puts("NA");
	return;
}

int main()
{
	for(;scanf("%d%d",&N,&M),N;)
	{
		for(i=0;i<N;i++)for(j=0;j<N;j++)scanf("%d",&P[i][j]);
		for(i=0;i<M;i++)for(j=0;j<M;j++)scanf("%d",&Q[0][i][j]);
		for(i=1;i<4;i++)rot(Q[i-1],Q[i]);
		f();
	}
	return 0;
}

Measured memory_bytes: 696
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし


N = I()
print(sum((i*(N//i)*(N//i+1)//2) for i in range(1,N+1)))


Measured memory_bytes: 73168
N,K=map(int,input().split())
P=list(map(int,input().split()))
X=0
for k in range(K):
	X+=P[k]
Y=X
for n in range(1,N-K+1):
	Y=Y+P[n+K-1]-P[n-1]
	X=max(X,Y)
print((X+K)/2)

Measured memory_bytes: 25060
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <math.h>
#include <vector>
using namespace std;
int main(){
    int n; cin>>n;
    int a[3];
    a[0]=n/100;
    a[1]=(n-100*a[0])/10;
    a[2]=n-a[0]*100-a[1]*10;
    for(int i=0;i<3;i++){
        if(a[i]==1) a[i]=9;
        else if(a[i]==9) a[i]=1;
    }
    for(int i=0;i<3;i++){
        cout<<a[i];
    }
    return 0;
}


Measured memory_bytes: 256
n, m = list(map(int, input().split()))
a = []
for _ in range(m):
    a.append(int(input()))
a = set(a)
cur = 0
dp = [0 for _ in range(n + 1)]
dp[0], dp[1] = 1, 1
if 1 in a:
    dp[1] = 0
for i in range(2, n + 1):
    if i in a:
        continue
    dp[i] = (dp[i - 1] + dp[i - 2]) % (10 ** 9 + 7)
print(dp[n])


Measured memory_bytes: 95792
def main():
    h, w, n = map(int, input().split())
    xy = [tuple(map(lambda x:int(x)-1, input().split())) for _ in [0]*n]
    ans = h
    d = set(xy)
    block = [[h] for _ in [0]*w]
    for x, y in xy:
        block[y].append(x)
    block = [sorted(i)[::-1] for i in block]
    nowx, nowy = 0, 0
    for i in range(h):
        if nowy >= w:
            break
        while block[nowy]:
            j = block[nowy][-1]
            if j > nowx:
                ans = min(ans, j)
                break
            else:
                block[nowy].pop()
        if (nowx+1, nowy) in d:
            break
        else:
            nowx += 1
        if (nowx, nowy+1) not in d:
            nowy += 1
    print(ans)


main()

Measured memory_bytes: 82916
#include <bits/stdc++.h>
using namespace std;
//#define che
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define MK make_pair
#define PB push_back
#define fi first
#define se second

typedef unsigned long long LL;
typedef pair<int, int> PII;
const int N=2e5 +10 ;

LL pre[N];int a[N], n, m, x;
int main(){
	#ifdef che
	freopen("input.txt","rt",stdin);
	freopen("output.txt","wt",stdout);
	#endif
	scanf("%d%d", &n, &x);
	for (int i=1; i<=n; ++i) scanf("%d", &a[i]);
	reverse(a+1, a+n+1);
	pre[0] =0 ;
	for (int i=1; i<=n; ++i) pre[i] = pre[i-1] + 1ll*a[i];
	LL ans= -1; 
	for (int k=1 ; k<=n; ++k){
		LL res= 0 ;
		for (int i=1,j=0; j<n; j+=k, ++i)
			res += 1ll*(2*i+1+2*(i==1))*(pre[ min(j+k,n)] -pre[j]);
		
		res += 1ll*(n+k)*x;
		if (ans==-1) ans=res;
		ans= min(ans, res);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 2560
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>
#define vi vector<int>
#define vii vector<vi>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;

int main(){
	 //cin.tie(0);
	//ios::sync_with_stdio(false);
	//std::cout << std::fixed;
	//std::cout << std::setprecision(12);
	//std::cout << std::defaultfloat;
int q,w;
cin>>q>>w;
cout<<max(max(q*w,q+w),q-w)<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;

int main(){
    int n,m;
    cin>>n>>m;
    int x[m];
    for(int i=0;i<m;i++){
        cin>>x[i];
    }
    sort(x,x+m);
    long long int ans=0;
    if(n>=m){
        ans=0;
    }else{
        int y[m-1];
        for(int i=0;i<m-1;i++){
            y[i]=x[i+1]-x[i];
        }
        sort(y,y+m-1);
        for(int i=0;i<m-n;i++){
            ans=ans+y[i];
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<string.h>

int main(){
    
    int n;
    scanf("%d", &n);
    
    int max = 0;
    int count = 0;
    
    char arr[105];
    scanf("%s", arr);
    
    int arrlen = strlen(arr);
    
    for(int i = 0; i < arrlen; i++){
        if(arr[i] == 'I'){
            count++;
        }
        else if(arr[i] == 'D'){
            count--;
        }
        if(max < count){
            max = count;
        }
    }
    
    printf("%d\n", max);
    
    return 0;
}

Measured memory_bytes: 1692
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {

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

    int n = sc.nextInt();
    int m = sc.nextInt();
    int l = sc.nextInt();

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

    int[][] b = new int[m][l];
    for (int i = 0; i < m; i++) {
      for (int j = 0; j < l; j++) {
        b[i][j] = sc.nextInt();
      }
    }

    long[][] ans = new long[n][l];
    for (int i = 0; i < n; i++) {      
      for (int j = 0; j < l; j++) {
        for (int k = 0; k < m; k++) {
          ans[i][j] += a[i][k] * b[k][j];
        }
      }
    }

    for (int i = 0; i < n; i++) { 
      StringBuilder sb = new StringBuilder();
      for (int j = 0; j < l; j++) {
        sb.append(ans[i][j] + " ");
      }
      pw.println(sb.toString().trim());
    }

    pw.flush();
    sc.close();
  }
}


Measured memory_bytes: 54496
#include <stdio.h>
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <bitset>
#include <map>
#include <set>
#include <tuple>
#include <string.h>
#include <math.h>
#include <random>
#include <functional>
#include <assert.h>
#include <math.h>

using namespace std;

using i64 = long long int;
using ii = pair<int, int>;
using ii64 = pair<i64, i64>;

vector<ii> edge[100005];
i64 pos[100005];
bool visit[100005];

bool dfs(int v)
{
	for (auto& e : edge[v])
	{
		if (visit[e.first])
		{
			if (pos[e.first] != pos[v] + e.second)
				return false;

			continue;
		}

		visit[e.first] = true;
		pos[e.first] = pos[v] + e.second;

		if (!dfs(e.first))
			return false;
	}

	return true;
}

int main()
{
	int n, m;
	scanf("%d %d", &n, &m);

	for (int i = 0; i < m; i++)
	{
		int l, r, d;
		scanf("%d %d %d", &l, &r, &d);

		edge[l].emplace_back(r, -d);
		edge[r].emplace_back(l, d);
	}

	for (int i = 1; i <= n; i++)
	{
		if (visit[i])
			continue;

		visit[i] = true;

		if (!dfs(i))
		{
			printf("No\n");
			return 0;
		}
	}

	printf("Yes\n");

	return 0;
}

Measured memory_bytes: 11520
#include <stdio.h>

int main(){
  int n,i,j,min,x,count=0,befor;

  scanf("%d",&n);

  int A[n];

  for(i=0;i<n;i++)scanf("%d",&A[i]);

  for(i=0;i<n;i++){
    
    befor=A[i];
    min=i;

      for(j=i;j<n;j++){
	if(A[j]<A[min]){
	  min=j;
	}
      }

    x=A[i];
    
    A[i]=A[min];
    
    A[min]=x;

    if(befor!=A[i])count++;

  }

  for(i=0;i<n;i++){
    printf("%d",A[i]);
    if(i<n-1)printf(" ");

  }

  printf("\n%d\n",count);

  return 0;

}
  



Measured memory_bytes: 2104
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<vector>
using namespace std;
using ll = long long;
using lli = long long int;
typedef pair<ll, ll> pii;
const ll MM = 1000000000;
const ll mod = MM + 7;
int main(){
    int d; cin >> d;
    if(d == 25) cout << "Christmas" << endl;
    if(d == 24) cout << "Christmas Eve" << endl;
    if(d == 23) cout << "Christmas Eve Eve" << endl;
    if(d == 22) cout << "Christmas Eve Eve Eve" << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
 
int main() {
  int N, ans=0;
  cin >> N;
  for(int i=1;i<10;i++){
    if((N % i == 0) && (N / i < 10)){
      ans = 1;
      break;
    }
  }
  if(ans == 1){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
      
  return 0;
}

Measured memory_bytes: 256
import sys
from collections import defaultdict as dd
import heapq
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 6)
N = int(input())
e = dd(list)
inc = [0] * (N + 1)
for _ in range(N - 1):
  u, v = map(int, input().split())
  e[u].append(v)
  e[v].append(u)
  inc[u] += 1
  inc[v] += 1
x = 0
for i in range(1, N + 1):
  if inc[x] < inc[i]: x = i

c = list(map(int, input().split()))
c.sort()
ressum = sum(c[: -1])
vis = set()
res = [0] * (N + 1)
res[x] = c[-1]
def dfs(y):
  global vis
  global res
  global c
  res[y] = c.pop()
  for z in e[y]:
    if z in vis: continue
    vis.add(z)
    dfs(z)
vis.add(x)
dfs(x)
print(ressum)
print(*res[1: ])

Measured memory_bytes: 221444
N, M, K = map(int, input().split())

friends = [set() for _ in range(N)]
for _ in range(M):
    a,b = map(lambda x: int(x)-1, input().split())
    friends[a].add(b)
    friends[b].add(a)

blocks = [set() for _ in range(N)]
for _ in range(K):
    c,d = map(lambda x: int(x)-1, input().split())
    blocks[c].add(d)
    blocks[d].add(c)

ans = [0]*N
visited = [False]*N
for i in range(N):
    if visited[i]:
        continue
    visited[i] = True
    d = [i]
    check = {i} 
    while len(d):
        tmp = d.pop()
        for k in friends[tmp]:
            if visited[k]:
                continue
            d.append(k)
            visited[k] = True
            check.add(k)
    for j in check:
        ans[j] += len(check) - len(friends[j]&check) - len(blocks[j]&check) - 1
print(*ans)


Measured memory_bytes: 99732
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
using namespace std;

typedef long long ll;

int main(){
	ll N, K;
	cin >> N >> K;

	ll ans = 0;
	for (int b = K + 1; b <= N; b++) {
		ll n = (N - b + 1) / b;
		ans += (b - K) * (n + 1);
		if (K == 0) ans -= 1;
		if (N >= (n + 1)*b + K) {
			ans += N - ((n + 1)*b + K) + 1;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,v) for (int i = 0; i < v.size(); i++)
#define RREPALL(i,v) for (int i = v.size()-1; i >= 0; i--)
#define SORT(v) sort(v.begin(), v.end())
#define MIN_ELEMENT(v) min_element(v.begin(), v.end())
#define MAX_ELEMENT(v) max_element(v.begin(), v.end())
#define COUNT(v,n) count(v.begin(), v.end(), n);
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
typedef long long ll;
typedef unsigned long long ull;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

int n;
vector<string> ans;

void solve()
{
    vector<string> s(n);
    vector<int> last(1111, -1);

    REP(i,n) {
        cin>>s[i];
        int cnt = COUNT(s[i], '.');
        if (cnt != 0) {
            s[i][cnt-1] = '+';
        }
        if (last[cnt] != -1) {
            FOR(j,last[cnt]+1,i) {
                s[j][cnt-1] = '|';
            }
            //last[cnt+1] = -1;
            memset(&last[cnt+1], -1, 1111-cnt-1);
        }
        last[cnt] = i;
        REP(j,cnt-1) {
            if (s[i][j] == '.')
                s[i][j] = ' ';
        }
    }
    REP(i,n) ans.push_back(s[i]);
}

int main()
{
    while (cin>>n, n != 0) {
        solve();
    }
    REPALL(i,ans) cout<<ans[i]<<endl;

    return 0;
}



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

#define MAX_N 1000000

using namespace std;

long long cnt;
int l;
int A[MAX_N];
int n;
vector<int> G;

void InsertionSort(int A[], int n, int g)
{
    for(int i=g; i<n; i++)
    {
        int v=A[i];
        int j=i-g;
        while(j>=0 && A[j]>v)
        {
            A[j+g]=A[j];
            j-=g;
            cnt++;
        }
        A[j+g]=v;
    }
}

void ShellSort(int A[], int n)
{
    for(int h=1; ;)
    {
        if(h>n)
            break;
        G.push_back(h);
        h=3*h+1;
    }
    reverse(G.begin(), G.end());
    for(int i=0; i<G.size(); i++)
        InsertionSort(A, n, G[i]);
}

int main()
{
    cin>>n;
    for(int i=0; i<n; i++)
        scanf("%d", A+i);
    cnt=0;
    ShellSort(A,n);
    cout<<G.size()<<endl;
    for(int i=0; i<G.size(); i++)
    {
        if(i>0)
            printf(" ");
        printf("%d",G[i]);
    }
    printf("\n");
    printf("%d\n", cnt);
    for(int i=0; i<n; i++)
        printf("%d\n", A[i]);
    return 0;
}



Measured memory_bytes: 7172
#include <stdio.h>

int main(void) 
{
  long n,sum=0,i;
  scanf("%ld",&n);
  for(i=1;i<n+1;i++)
  {
    if(i%3!=0&&i%5!=0)
    {
      sum=sum+i;
    }
  }
  printf("%ld",sum);
  return 0;
}


Measured memory_bytes: 1736
l,r=map(int,input().split())
q=l//2019
l-=q*2019
r-=q*2019
ans=2018
if r>=2019:
  exit(print(0))
for i in range(l,r):
  for j in range(i+1,r+1):
    ans=min(ans,(i*j)%2019)
print(ans)


Measured memory_bytes: 9192