akhauriyash/Code-Regression huggingface dataset:
import java.util.HashMap;
import java.util.List;
import java.util.Scanner;


public class Main {

    static void solve() {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int f = n/500;
        int rem = n%500;
        int s = rem/5;
        int res = f*1000 + s*5;
        System.out.println(res);
    }


    public static void main(String[] args) {

        solve();

        //        Main m = new Main();
        //        Scanner scan = new Scanner(System.in);

        //        long n = scan.nextLong();
        //        long r = scan.nextLong();
        //        List<Long> list = new ArrayList<>();
        ////        int[] arr = new int[n];
        //        for (long i=0;i<n;i++){
        //            list.add(scan.nextLong());
        //        }
//            System.out.println(ch);
        //        solve(n, arr);
        //        scan.close();
    }


    class Counter extends HashMap<Integer, Integer> {
        public int get(int k) {
            return containsKey(k) ? super.get(k) : 0;
        }

        public void add(int k, int v) {
            put(k, get(k) + v);
        }
    }



    static class Node {
        int val;
        Node next;
        Node random;

        public Node(int val) {
            this.val = val;
            this.next = null;
            this.random = null;
        }
    }

//    static class Node {
//        int key;
//        int data;
//        Node next;
//        Node prev;
//
//        Node(int key, int data) {
//            this.key = key;
//            this.data = data;
//        }
//    }

    static class TreeNode {
        int val;
        TreeNode left;
        TreeNode right;

        TreeNode(int x) {
            val = x;
        }
    }

    static class Trie {
        void add(String word) {

        }

        boolean search(String w) {
            return false;
        }
    }

    static class Node1 {
        public int val;
        public List<Node1> children;

        public Node1() {
        }

        public Node1(int _val, List<Node1> _children) {
            val = _val;
            children = _children;
        }
    }

    ;

    static class TrieNode {

    }

    static class KvNode implements Comparable<KvNode> {
        String key;
        int freq;

        public KvNode(String key, int freq) {
            this.key = key;
            this.freq = freq;
        }

        @Override
        public int compareTo(KvNode o) {
            if (this.key.equals(o.key)) {
                return 0;
            }
            return Integer.compare(o.freq, this.freq);
        }
    }

    static class ListNode {
        int val;
        ListNode next;

        ListNode(int x) {
            val = x;
        }
    }
}


Measured memory_bytes: 21844
/*
    ☁ ☁         ☀     ☁☁
            ☁ ✈    ☁☁

🌳🌲_________🌳___🌳____🌲___🌳
     /    |    \
    /       🚔\
    /     |      \ С ДОРОГИ МЕНТЫ ЕДУТ ПАЦАНЫ
   /        🚘  \
   /             \ 
*/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define mt make_tuple
#define ppb pop_back
#define re return
#define forn(i, n) for (int i = 1; i <= (int)(n); i++)
#define fore(i, n) for (int i = 0; i < (int)(n); i++)
#define ford(i, n) for (int i = (int)(n); i >= 1; i--)
#define forde(i, n) for (int i = (int)(n) - 1; i >= 0; i--)
#define forr(i, l, r) for (int i = (int)(l); i <= (int)(r); i++)
#define fz(a) memset((a), 0, sizeof((a)))
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define SZ(x) (int)((x).size())
#define zhfs main

typedef long long ll;
typedef double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

void gn(int &x) { scanf("%d", &x); }
void gn(long long &x) { scanf("%lld", &x); }
void pi(int x) { printf("%d ", x); }
void pi(long long x) { printf("%lld ", x); }

int zhfs() {
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
#endif
	string s;
  cin >> s;
  if (s.substr(0, 4) == "YAKI") {
    puts("Yes");
  } else {
    puts("No");
  }

}




Measured memory_bytes: 764
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <random>

using namespace std;

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);

	int a;
	string s;
	cin >> a >> s;
	if (a < 3200) cout << "red" << endl;
	else cout << s << endl;
} 


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
//辗转相除 
int gcd(int a, int b) {
	if(b == 0) {
		return a;
	}
	return gcd(b, a % b);
}

int main()
{
	int a, b;
	while(cin >> a >> b) {
		
		int a1 = max(a, b);
		int b1 = min(a, b);
		int res1 = gcd(a, b);					//最大公约数 
		long long t = (long long)a * b;		//t可能会超int范围(没有尝试) 
		long long res2 = t / res1;			//最小公倍数 
		cout << res1 << " " << res2 << endl;
		
	}
	return 0;
}


Measured memory_bytes: 3092
#include <iostream>
#include <vector>
#include <unordered_map>
#include <map>
#include <unordered_set>
#include <set>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <climits>
#include <queue>
using namespace std;


#define ll long long

ll kMod = 1000000007;

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

  vector<vector<int>> g(N);
  for (int i = 0; i < N - 1; i++) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }

  ll ans = K;
  unordered_set<int> seen;
  seen.insert(0);
  queue<int> q;
  q.push(0);

  while (q.size()) {
    int v = q.front(); q.pop();

    ll k = K - 1;
    for (int u : g[v]) {
      if (seen.count(u)) {
        k --;
        break;
      }
    }

    int i = 0;
    for (int u : g[v]) {
      if (seen.count(u)) continue;
      ans = ans * (k - i) % kMod;
      i ++;
      q.push(u);
      seen.insert(u);
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 10640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const ll INF = 1LL << 60;

int main(){
    ll h;
    cin >> h;
    //hを超えない2の累乗で一番大きい数を探す
    ll near2 = 1;
    while(true){
        if(near2 > h){
            near2 /= 2;
            break;
        }
        else near2 *= 2;
    }

    ll sum=0;
    while(near2 > 0){
        sum += near2;
        near2 /= 2;
    }
    cout << sum << endl;




}

Measured memory_bytes: 3592
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include <time.h>
typedef long long ll;
typedef long double ld;
#define INF (1LL<<60)
#define MOD1 1000000007
/*swap 交換*/
void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a=c;}
/*2つのうち大きい数を返す*/
ll max2(ll a,ll b){return a>=b?a:b;}
/*2つのうち小さい数を返す*/
ll min2(ll a,ll b){return a>=b?b:a;}
/*絶対値*/
ll ABS(ll a){return a>=0?a:(-a);}
typedef struct{
    ll aa;
    ll bb;
}frequent;
// 小大
int compare(const void *a, const void *b){
    return *(ll *)a>*(ll *)b?1:*(ll *)a<*(ll *)b?-1:0;}

int main(void){
    ll n,i,ans=0;
    scanf("%lld",&n);
    ll a[n],b[n];
    for(i=0;i<n;i++){
        scanf("%lld%lld",&a[i],&b[i]);
    }
    for(i=n-1;i>=0;i--){
        a[i]+=ans;
        if(a[i]%b[i]!=0){
            ans+=b[i]-a[i]%b[i];
        }
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 1664
#include <iostream>

#include <fstream>

#include <vector>
#include <set>
#include <string>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>

#include <algorithm>
#include <iomanip>
#include <cmath>
#include <random>
#include <cstdlib>
#include <ctime>
#include <utility>

using namespace std;

ifstream in("input.txt");
ofstream out("output.txt");

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

#define F first
#define S second
#define forcin(n, a) for(int i = 0; i < n; ++i) {cin >> a[i];}
#define forcout(n, a) for(int i = 0; i < n; ++i) {cout << a[i] << " ";}
#define PI acos(-1)
#define forup(st, fin) for(int i = st; i < fin; ++i)
#define fordown(st, fin) for(int i = st; i >= fin; --i)
#define reverse_all(v) reverse(v.begin(), v.end())
#define sort_all(v) sort(v.begin(), v.end())
#define sort_allr(v) sort(v.rbegin(), v.rend())

///#define cin in
///#define cout out
///#define int long long

const ll MAXL = 1e18;
const int N = 10005000;
const int MAXN = 1e9 + 7;

int n, c;
vector<vector<int> > D, C;
vector<map<int, int> > mod(3);

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    srand(time(NULL));
    cin >> n >> c;
    C.resize(n, vector<int> (n));
    D.resize(c, vector<int> (c));
    for (int i = 0; i < c; ++i) {
        for (int j = 0; j < c; ++j) {
            cin >> D[i][j];
        }
    }
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            cin >> C[i][j];
            C[i][j]--;
            mod[(i + j + 2) % 3][C[i][j]]++;
        }
    }
    ll ans = MAXL;
    for (int a0 = 0; a0 < c; ++a0) {
        for (int a1 = 0; a1 < c; ++a1) {
            for (int a2 = 0; a2 < c; ++a2) {
                if (a0 == a1 || a0 == a2 || a1 == a2) {
                    continue;
                }
                ll temp = 0;
                for (int col = 0; col < c; ++col) {
                    temp += (mod[0][col] * D[col][a0]);
                    temp += (mod[1][col] * D[col][a1]);
                    temp += (mod[2][col] * D[col][a2]);
                }
                //cout << a0 << " " << a1 << " " << a2 << " : " << temp << "\n";
                ans = min(ans, temp);
            }
        }
    }
    cout << ans << "\n";
    return 0;
}

/*
2 3
0 1 1
1 0 1
1 4 0
1 2
3 3
 */

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

map<char, string> C1;
map<string, char> C2;

void init(){
    string c = "ABCDEFGHIJKLMNOPQRSTUVWXYZ .,-\'?";
    string s[32] = {"00000",
		    "00001",
		    "00010",
		    "00011",
		    "00100",
		    "00101",
		    "00110",
		    "00111",
		    "01000",
		    "01001",
		    "01010",
		    "01011",
		    "01100",
		    "01101",
		    "01110",
		    "01111",
		    "10000",
		    "10001",
		    "10010",
		    "10011",
		    "10100",
		    "10101",
		    "10110",
		    "10111",
		    "11000",
		    "11001",
		    "11010",
		    "11011",
		    "11100",
		    "11101",
		    "11110",
		    "11111"};

    for ( int i = 0; i < c.size(); i++ ){
	C1[c[i]] = s[i];
    }

    C2["101"] = ' ';
    C2["000000"] = '\'';
    C2["000011"] = ',';
    C2["10010001"] = '-';
    C2["010001"] = '.';
    C2["000001"] = '?';
    C2["100101"] = 'A';
    C2["10011010"] = 'B';
    C2["0101"] = 'C';
    C2["0001"] = 'D';
    C2["110"] = 'E';
    C2["01001"] = 'F';
    C2["10011011"] = 'G';
    C2["010000"] = 'H';
    C2["0111"] = 'I';
    C2["10011000"] = 'J';
    C2["0110"] = 'K';
    C2["00100"] = 'L';
    C2["10011001"] = 'M';
    C2["10011110"] = 'N';
    C2["00101"] = 'O';
    C2["111"] = 'P';
    C2["10011111"] = 'Q';
    C2["1000"] = 'R';
    C2["00110"] = 'S';
    C2["00111"] = 'T';
    C2["10011100"] = 'U';
    C2["10011101"] = 'V';
    C2["000010"] = 'W';
    C2["10010010"] = 'X';
    C2["10010011"] = 'Y';
    C2["10010000"] = 'Z';
}

string getCode(string str){
    string s = "";
    for ( int i = 0; i < str.size(); i++ ){
	s += C1[str[i]];
    }
    return s;
}

void convert(string code){
    string str = "";
    for ( int i = 0; i < code.size(); i++ ){
	str += code[i];
	if ( C2[str] != '\0' ){
	    cout << C2[str];
	    str = "";
	} 
    }
    if ( C2[str] != '\0' ){
	cout << C2[str];
    }
    cout << endl;

}

main(){
    init();
    string line;
    while(1){
	getline(cin, line);
	if ( cin.eof() ) break;
	string code = getCode(line);
	convert(code);
    }
}

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

void solve(std::istream &in, std::ostream &out);

int main() {
#ifdef LOCAL
  freopen("../IO/a.in", "r", stdin);
//  freopen("../IO/a.out", "w", stdout);
#else
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
  std::cout.tie(nullptr);
#endif
  solve(std::cin, std::cout);
  return 0;
}


void solve(std::istream &in, std::ostream &out) {
  int n;
  in >> n;
  vector<int> a(n);
  for (int &i : a) in >> i;

  vector<int> fenwick(2 * n + 1, 0);
  function<int(int)> get = [&](int r) {
    int ans = 0;
    for (; r >= 0; r = (r & (r + 1)) - 1) {
      ans += fenwick[r];
    }
    return ans;
  };
  function<void(int)> inc = [&](int pos) {
    for (; pos < 2 * n + 1; pos |= pos + 1) {
      ++fenwick[pos];
    }
  };

  function<int64_t(int)> check = [&](int x) {
    fill(fenwick.begin(), fenwick.end(), 0);
    vector<int> b = a;
    for (int &i : b) {
      i = i >= x ? 1 : -1;
    }
    for (int i = 1; i < n; ++i) {
      b[i] += b[i - 1];
    }
    int64_t count = 0;
    inc(n);
    for (int i = 0; i < n; ++i) {
      count += get(n + b[i]);
      inc(n + b[i]);
    }
    return count;
  };
  int64_t count = ((int64_t) n * (n + 1) / 2 + 1) / 2;
  int lo = 0, hi = 1'000'000'001;
  while (hi - lo > 1) {
    int mid = lo + hi >> 1;
    if (check(mid) >= count) {
      lo = mid;
    } else {
      hi = mid;
    }
  }
  out << lo << '\n';
}

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

int main()
{
    int d[200000];
    int d1[200000];
    int d2[200000];
    int d3[200000];
    int d4[200000];
    int d5[200000];
    int alphabet_max = 26;
    long long N;
    const long long MOD = 1000000007;
    cin >> N;
    string S;
    cin >> S;
    long long kosuu[26];
    for (int i = 0; i < alphabet_max; i++)
    {
        kosuu[i] = 0;
        for (int j = 0; j < N; j++)
        {
            if (S.at(j) == 'a' + i)
            {
                kosuu[i]++;
            }
        }
        kosuu[i]++;
    }
    long long ans = 1;
    for (int i = 0; i < alphabet_max; i++)
    {
        ans *= kosuu[i];
        ans %= MOD;
    }
    if (ans == 0)
    {
        cout << MOD - 1 << endl;
        return 0;
    }
    cout << ans - 1 << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define cyes cout<<"YES"<<endl
#define cno cout<<"NO"<<endl
#define sp <<" "<<
#define cst(x) cout<<fixed<<setprecision(x)
#define pi 3.14159265359
#define mod 1000000007
using namespace std;
using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;
using que_a = priority_queue<int, vector<int>, greater<int> >;
using que_d = priority_queue<int>;
using pint = pair<int,int>;

int main(){

    int n,Y; cin >> n >> Y;
    Y /= 1000;
    int k = Y- n;
    bool ok = false;
    for(int xy = 0; xy <= n; xy++){
        for(int x = 0; x <= xy; x++){
            int y = xy- x;
            if(9*x + 4*y == k){
                ok = true;
                cout << x sp y sp n-x-y << endl;
                return 0;
            }
        }
    }
    cout << -1 sp -1 sp -1 << endl;
    return 0;   
}


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

using namespace std;

int main(void) {
	int n;
	cin >> n;
	int temp;
	long long sum = 0;
	int nmax = -(1 << 28);
	int nmin = (1 << 28);
	for (int i = 0; i < n; ++i) {
		cin >> temp;
		sum += temp;
		nmax = max(temp,nmax);
		nmin = min(temp,nmin);
	}
	cout << nmin << " ";
	cout << nmax << " ";
	cout << sum << endl;
	return 0;
}



Measured memory_bytes: 3104
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<queue>
#include<cstring>

using namespace std;

int main(){

  int h,w;
  cin >> h >> w;

  int dp[10][10];
  memset(dp,100000,sizeof(dp));

  for(int i=0;i<10;i++){
    for(int j=0;j<10;j++){
      cin >> dp[i][j];
    }
  }

  for(int k=0;k<10;k++){
    for(int i=0;i<10;i++){
      for(int j=0;j<10;j++)dp[i][j]=min(dp[i][j],dp[i][k]+dp[k][j]);
    }
  }


  int s=0;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      int a;
      cin >> a;
      if(a!=-1){
        s+=dp[a][1];
      }
    }
  }

  cout << s << endl;

}

Measured memory_bytes: 256
from itertools import product
n=int(input())
a=[]
for i in range(3,10):
  a+=(list(product('357',repeat=i)))
cnt=0
for i in a:
  if len(set(i))!=3:
    continue
  if int(''.join(list(i)))<=n:
    cnt+=1
  else:break
print(cnt)

Measured memory_bytes: 77708
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int x, a, b;
  cin >> x;
  a = (x / 11) * 2;
  b = x % 11;
  if (b == 0) {
    cout << a << endl;
  } else if (b <= 6) {
    cout << a + 1 << endl;
  } else {
    cout << a + 2 << endl;
  }
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

n = int(input())
a = list(map(int, input().split()))
s = [0]*(n+1)
a.append(0)
a.insert(0, 0)
for i in range(n+1):
    s[i] = abs(a[i]-a[i+1])
sum_s = sum(s)
for i in range(n):
    ans = sum_s+abs(a[i]-a[i+2])-(s[i]+s[i+1])
    print(ans)

Measured memory_bytes: 13924
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"

using namespace std;

typedef long int li;
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pt;

#define fi first
#define se second
#define dump(x) cout << #x << " = " << x << endl
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

const ll M = (ll)1e9+7;

ll dp[100007][13];
string s;

int main () {
    fastIO;
    cin >> s;
    dp[0][0]=1;
    for(li h = 0; h < s.size(); h ++) {
        if(s[h] == '?') {
            for(li i = 0; i < 10; i ++) {
                for(li j = 0; j < 13; j ++) {
                    dp[h+1][(j * 10 + i) % 13] += dp[h][j];
                    dp[h+1][(j * 10 + i) % 13] %= M;
                }
            }
        } else {
            ll tNum = s[h] - '0';
            for(li i = 0; i < 13; i ++) {
                dp[h+1][(i * 10 + tNum) % 13] += dp[h][i];
                dp[h+1][(i * 10 + tNum) % 13] %= M;
            }
        }
    }
    cout << dp[s.size()][5];
}


Measured memory_bytes: 10604
#include<stdio.h>

int main(void){
int i,j,h,w;
while(1){
scanf("%d %d",&h,&w);
if(h==0&&w==0)break;
else for(i=0;i<h;i++){
for(j=0;j<w;j++){
if(i==0||i==h-1||j==0||j==w-1)printf("#");
else printf(".");
}
printf("\n");
}
printf("\n");
}
return 0;
}


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

#define rep(i, a, b) for(int i = (a); i < int(b); ++i)
#define rrep(i, a, b) for(int i = (a) - 1; i >= int(b); --i)
#define trav(it, v) for(auto &it : (v))
#define all(v) (v).begin(), (v).end()
#define what_is(x) cerr << #x << " is " << x << endl;
#define sz(x) (int)(x).size()

typedef double fl;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;

int main(){
	ios::sync_with_stdio(0);
	string s;
	cin >> s;
	int ans = 1000;
	for(char c='a'; c <= 'z'; ++c){
		int d = 0;
		int worst = 0;
		for(int i=s.size()-1; i >= 0; --i){
			++d;
			if(s[i] == c)
				d = 0;
			worst = max(worst, d);
		}
		ans = min(ans, worst);
	}
	cout << ans << endl;
}

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

ary = []
for i in range(m):
	x = list(map(int, input().split()))
	x.pop(0)
	ary.append(x)

p = list(map(int, input().split()))

cnt = 0
for i in range(2**n):
	den = [0 for ii in range(n)]
	for j in range(n):
		if (i>>j) & 1:
			den[j] += 1
	flg = False
	for j in range(m):
		c = 0
		d = [0 for i in range(n)]
		for k in ary[j]:
			if den[k-1] == 1:
				d[k-1] = 1
		for kk in d:
			if kk == 1:
				c += 1
		'''
		for k in ary[j]:
			if den[k-1] ==1:
				c += 1
		'''
		if c%2 == p[j]%2:
			continue
		else:
			flg = True
			break
	if flg == False:
		cnt += 1
print (cnt)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
int GCD(int a,int b){
    if(b == 0)return a;
    return GCD(b,a%b);
}
int main(void){
    int N,X;
    cin >> N >>X;
    int x[N];
    for(int i=0;i<N;i++){
        cin >> x[i];
        x[i] = abs(X-x[i]);
    }
    int ans = 0;
    for(int i=0;i<N;i++){
        ans = GCD(ans,x[i]);
    }
    cout << ans;
}


Measured memory_bytes: 3584
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(int,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
a, b, c = M()
x = b-a
y = c-b
if x == y:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 68416
//  Mayank Agarwal
//  IIIT Hyderabad



#include<bits/stdc++.h>
using namespace std;
const long long int M = 1000000007; 
#define ll long long int
#define ld double
#define pb push_back
#define mp make_pair
ll power(ll x, ll y,  ll p) 
{ 
    ll res = 1;      
    x = x % p;   
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1;x = (x*x) % p; 
    } return res%p; 
} 
ll modinver(ll a,ll b)
{
    return (power(a,1,M)*power(b,M-2,M))%M;
}
void SieveOfEratosthenes(int n) 
{   
    bool prime[10005]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
} 
double dp[301][301][302];
ll n;
double sushians(ll o,ll t,ll th)
{
	if(dp[o][t][th]!=-1)
	{
		return dp[o][t][th];
	}
	double ans=0.0;
	// cout<<ans<<'\n';
	if(o!=0)
	{
		ans+=sushians(o-1,t,th)*o;
	}
	if(t!=0)
	{
		ans+=sushians(o+1,t-1,th)*t;
	}
	if(th!=0)
	{
		ans+=sushians(o,t+1,th-1)*th;
	}
	ans+=n;
	ans*=1.0/((double)(o+t+th));
	dp[o][t][th]=ans;
	return dp[o][t][th];
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    cin>>n;
    ll a[1000];
    ll one=0,two=0,three=0;
    for (int i = 0; i <=300; ++i)
    {
    	for (int j = 0; j <=300 ; ++j)
    	{
    		for (int k = 0; k <=300 ; ++k)
    		{
    			dp[i][j][k]=-1;
    		}
    	}
    }
    dp[0][0][0]=0;
    for (int i = 0; i < n; ++i)
    {
    	cin>>a[i];
    	if(a[i]==1)
    	{
    		one++;
    	}
    	else if(a[i]==2)
    	{
    		two++;
    	}
    	else
    	{
    		three++;
    	}
    }
    cout<<fixed<<setprecision(10)<<sushians(one,two,three)<<'\n';
}


Measured memory_bytes: 214144
#include <iostream>
#include <bits/stdc++.h>
#include <stdio.h>
#include <algorithm>
using namespace std;
int main()
{    long long int n,i,k,s,flag=0,count=0;
   scanf("%lld %lld %lld",&n,&k,&s);
   for(i=0;i<n;i++)
   {  if(count!=k)
      {   if(flag==0)
           printf("%lld",s),flag=1;
         else printf(" %lld",s);
         count++;
      }
      else
      {  if(flag==0)
          {   if(s==1000000000)
              printf("%lld",s-1),flag=1;
              else
              {  printf("%lld",s+1),flag=1;
              }
          }
         else
         {  if(s==1000000000)printf(" %lld",s-1);
           else printf(" %lld",s+1);
         }
      }
   }
    return 0;
}


Measured memory_bytes: 1280
# -*- coding: utf-8 -*-
"""
Created on Mon May  4 20:38:08 2020
"""

import sys
#import numpy as np

sys.setrecursionlimit(10 ** 9)
#def input():
#    return sys.stdin.readline()[:-1]
mod = 10**9+7

#N = int(input())
N, M = map(int,input().split())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

divisors = make_divisors(M)

for d in divisors:
    if d >= N:
        ans = M // d
        break
print(ans)
    



Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
template<typename T>
void cmax(T &a, const T &b) {
    if (a < b)
        a = b;
}
template<typename T>
void cmin(T &a, const T &b) {
    if (b < a)
        a = b;
}
using LL = long long;
constexpr int MAX_N = 50, MAX_V = MAX_N * MAX_N * MAX_N;
constexpr LL INF = 1E18;
int n, x, d;
LL m[MAX_N];
int p[MAX_N], v[MAX_N], a[MAX_N];
LL f[MAX_V + 1];
void work(LL m, int v) {
    for (int i = n * n * n; i >= v; --i)
        cmin(f[i], f[i - v] + m);
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n >> x >> d;
    cin >> m[0];
    for (int i = 1; i < n; ++i) {
        cin >> m[i] >> p[i];
        --p[i];
    }
    for (int i = n - 1; i >= 1; --i)
        m[p[i]] += m[i];
    for (int i = 0; i < n; ++i)
        v[i] = 1;
    for (int i = n - 1; i >= 1; --i)
        v[p[i]] += v[i];
    for (int i = 0; i < n; ++i)
        a[i] = i;
    sort(a, a + n, [&](int i, int j) {return v[i] * m[j] > v[j] * m[i];});
    fill(f + 1, f + MAX_V + 1, INF);
    for (int i = 0; i < n; ++i) {
        int lim = i == 0 ? n : min(n, d);
        int c = 1;
        while (c <= lim) {
            lim -= c;
            work(c * m[i], c * v[i]);
            c *= 2;
        }
        work(lim * m[i], lim * v[i]);
    }
    int ans = 0;
    for (int i = 0; i <= n * n * n; ++i) {
        if (f[i] > x)
            continue;
        int res = x - f[i];
        int sum = i;
        for (int j = 0; j < n; ++j) {
            int t = a[j] == 0 ? res / m[0] : min(int(res / m[a[j]]), max(0, d - n));
            res -= t * m[a[j]];
            sum += t * v[a[j]];
        }
        cmax(ans, sum);
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 1280
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;



class Myon
{
    public Myon() { }
    public static int Main()
    {
        cin = new Scanner();
        new Myon().calc();
        return 0;
    }

    static Scanner cin;

    void calc()
    {
        int A = cin.nextInt();
        int B = cin.nextInt();

        int K = (A + B) / 2;

        if (Math.Abs(A - K) == Math.Abs(B - K)) Console.WriteLine(K);
        else Console.WriteLine("IMPOSSIBLE");
    }
}



class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
constexpr double eps=1e-8;
const double pi=acos(-1);
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int Random(int mi,int ma){
    random_device rnd;
    mt19937 mt(rnd());//32bit
    //[mi,ma]
    uniform_int_distribution<int>engine(mi,ma);
    return engine(mt);
}
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
vector<int>kaijo,invkaijo;
void init_fact(int n){
    kaijo.resize(n+1);
    invkaijo.resize(n+1);
    kaijo[0]=1;
    for(int i=1;i<=n;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
    rep(i,n+1)invkaijo[i]=modpow(kaijo[i],mod-2);
}
int comb(int a,int b){
    if(a<b)return 0;
    if(a<0||b<0)return 0;
    return kaijo[a]*invkaijo[a-b]%mod*invkaijo[b]%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}

signed main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    vector<int>x={a,b},y={c,d};
    if(a<=0&&0<=b)x.pb(0);
    if(c<=0&&0<=d)y.pb(0);
    int ans=-INF;
    for(int i:x){
        for(int j:y){
            chmax(ans,i*j);
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3656
x, y = map(int, input().split())

if x > 0 and y > 0:
    if x < y:
        print(y-x)
    else:
        print(x-y+2)
elif x < 0 and y < 0:
    if x < y:
        print(y-x)
    else:
        print(x - y + 2)
elif x == 0:
    if y > 0:
        print(y)
    else:
        print(-y+1)
elif y == 0:
    if x > 0:
        print(x+1)
    else:
        print(-x)
else:
    print(abs(abs(y) - abs(x)) + 1)


Measured memory_bytes: 38372
import bisect, copy, heapq, math
from math import inf
import sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
def celi(a,b):
    return -(-a//b)
sys.setrecursionlimit(5000000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n,m=map(int,input().split())
a=[int(input()) for i in range(m)]

dic={}
for i in range(m):
    dic[a[i]]=1
dp=[0]*(n+2)

dp[0]=1
for i in range(n):
    if i in dic:
        continue
    dp[i+1]+=dp[i]
    dp[i+2]+=dp[i]
    dp[i+1]%=mod
    dp[i+2]%=mod
print(dp[-2])

Measured memory_bytes: 21124
k=int(input())

if k%7==0:
    l=9*k//7
else:
    l=9*k

rem=1
if k%2==0 or k%5==0:
    print(-1)
else:
    for i in range(1,10**7):
        rem*=10
        rem%=l
        if rem==1:
            print(i)
            break

Measured memory_bytes: 9100
import numpy as np
import sys

def main():
    n = int(input())
    _list = list(input().split())
    _max = 0
    for i in range(1, n):
        tr = int(_list[i])
        if _max < tr:
            _max = tr
        
        if _max -1 > tr:
            print('No')
            sys.exit()

        

    print('Yes')




if __name__ == '__main__':
    main()
    

Measured memory_bytes: 20248
#include <stdio.h>

int main(void)
{
	int a,b,c[10000],i,n,total=0;
	scanf("%d %d",&a,&b);

	for(i=0;i<a*b;i++)
	{
		scanf("%d",&c[i]);
	}
	
	for(n=0;n<a;n++)
	{
	
	for(i=0;i<b;i++)
	{
	total+=c[i+n*b];
	printf("%d ",c[i+n*b]);
	}
	printf("%d\n",total);
	total=0;
	}

	
	//???????????????
	for(i=0;i<b;i++)
	{

	for(n=0;n<a;n++)
	{
		total+=c[n*b+i];
	}
	printf("%d ",total);
	total=0;
	}
	
	
	
	//????????????
	for(n=0;n<a*b;n++)
	{
		total+=c[n];
	}
	printf("%d\n",total);
	return 0;


}

Measured memory_bytes: 636
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
using namespace std;
using ll = long long;
 
int main() {
	int x,t;
	cin >> x >> t;
	x -= t;
	if(x >0) {
		cout << x << endl;
	}else {
		cout << 0 << endl;
	}
	return 0;
}


Measured memory_bytes: 256
import sys
from fractions import gcd

INPUT = lambda: sys.stdin.readline().rstrip()
MAP = lambda: map(int, INPUT().split())

sys.setrecursionlimit(10 ** 9)


def main():
    A, B = MAP()
    
    lcm = lambda x, y: (x * y) // gcd(x, y)
    print(lcm(A, B))


if __name__ == '__main__':
    main()

Measured memory_bytes: 63980
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <assert.h>

using namespace std;

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

// const ll INF = 1LL << 60;

int main()
{
  ll N;
  cin >> N;
  vector<ll> A(N);
  for (ll i = 0; i < N; i++)
  {
    cin >> A[i];
    A[i]--;
  }
  vector<ll> B(N, 0);
  for (ll i = 0; i < N; i++)
  {
    B[A[i]]++;
  }
  ll ans_ = 0;
  for (ll i = 0; i < N; i++)
  {
    ans_ += B[i] * (B[i] - 1) / 2;
  }
  for (ll i = 0; i < N; i++)
  {
    cout << ans_ - (B[A[i]] - 1) << endl;
  }
}


Measured memory_bytes: 5760
n = int(input())
a_l = list(map(int,input().split()))

a_dict = {}
for num in a_l:
    if num in a_dict:
        a_dict[num] += 1
    else:
        a_dict[num] = 1

comb_dict = {}
comb_tot = 0
for num in a_dict:
    comb_dict[num] = a_dict[num]*(a_dict[num]-1)//2
    comb_tot += comb_dict[num]

for num in a_l:
    ans = comb_tot - (a_dict[num]-1)
    print(ans)



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

using ll = long long;

int main(){

	int n;
	cin >> n;
	vector<ll> l(n);
	for(int i=0;i<n;i++) cin >> l[i];
	int ans=0;
	sort(l.begin(),l.end());

	for(int i=0;i<n-2;i++){
		for(int j=i+1;j<n-1;j++){
			if(l[i]==l[j]) continue;
			for(int k=j+1;k<n;k++){
				if(l[i]!=l[k] && l[j]!=l[k]){
					if(l[i]+l[j]>l[k]) ans++;
				}
			}
		}
	}

	cout << ans << endl;


}


Measured memory_bytes: 3596
//2020.1.20
//s1270188 xxxmk2
//alds1_10c

#include<stdio.h>
#include<string.h>
#define N 1001

//global
int d[N][N];
char x[N+1], y[N+1];

//prototype
int longest(void);

int main(){
  int num, i;

  //input
  scanf("%d",&num);
  for(i=0;i<num;i++){
    scanf(" %s %s",x,y);

    //output
    printf("%d\n",longest());
  }
  
  return 0;
}

int longest(void){
  int xl=strlen(x), yl=strlen(y);
  int i, j;

  //reset d
  for(i=0;i<=xl;i++) d[i][0]=0;
  for(i=0;i<=yl;i++) d[0][i]=0;
  
  for(j=1;j<=yl;j++){
    for(i=1;i<=xl;i++){

      if(x[i-1]!=y[j-1]){
	if(d[i][j-1]>=d[i-1][j]) d[i][j]=d[i][j-1];
	else d[i][j]=d[i-1][j];
      }
      else d[i][j]=d[i-1][j-1]+1;
    }
  }

  return d[xl][yl];
}



Measured memory_bytes: 5720
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>
#include <queue>
#include <set>
#include <bitset>
#include <map>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<long long> vll;
typedef queue<int, int> qii;
typedef pair<int, int> pii;

#define PI 3.14159265359
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repz(i,n) rep(i,0,n)

//int型を受け取ってその桁数を返す
int check_digits(int n) {
	int digits = 0;
	while (n != 0) {
		n /= 10;
		digits++;
	}
	return digits;
}

//int型を受け取ってその各桁の和を返す
int sum_digits(int n) {
	int sum=0;
	int N = n;
	while (N) {
		sum += N % 10;
		N /= 10;
	}
	return sum;
}


//最大公約数を返す関数
int gcd(int n, int m) {
	while (n != 0) {
		if (n < m) swap(n, m);
		n = n % m;
	}
	return m;
}


//2点間の距離を返す
float dis(int x1, int y1, int x2, int y2) {
	return sqrt(pow(abs(x1 - x2), 2) + pow(abs(y1 - y2), 2));
}


int main() {
	int n,temp, top = 0, ans = 0;
	cin >> n;
	repz(i, n) {
		cin >> temp;
		if (temp >= top) {
			top = temp;
			ans++;
		}
	}
	
	cout << ans << endl;

	system("pause");
	return 0;
}


Measured memory_bytes: 504
package main
import (
    "fmt"
    )

func main() {
    var N, A, B int
    fmt.Scan(&N, &A, &B)
    
    var sum int
    if N - (A+B) < 0 {
       if N <= A {
           sum += N
       } else {
           sum += A
       }
    } else {
        sum += A * (N/(A+B))
    
        m := N % (A+B)
        if m > A {
            sum += A
        } else {
            sum += m
        }
        
    }
    fmt.Println(sum)
}

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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
int main()
{
  int d;
  cin >> d;
  vector<int> c(26);
  int i,j;
  rep(i,26) cin >> c[i];
  vector<vector<int>> s(d,vector<int>(26));
  rep(i,d)rep(j,26) cin >> s[i][j]; 
  vector<int> t(d);
  rep(i,d)
  {
    cin >> t[i];
    t[i]--;
  }
  vector<int> las(26,0);
  int kans = 0;
  rep(i,d)
  {
    las[t[i]] = i+1;
    kans += s[i][t[i]];
    rep(j,26)
    {
      kans -= c[j]*(i+1-las[j]);
    }
    cout << kans << "\n";
  }
}


Measured memory_bytes: 3676
#include<iostream>
#include<vector>
#include<string>
#include<ctime>
#include<climits>
using namespace std;

int main()
{
	int min=INT_MAX;
	string s;
	cin >> s;
	for (int i = 0; i < s.length() - 2; i++)
		if (abs(stoi(s.substr(i, 3)) - 753) < min)
			min = abs(stoi(s.substr(i, 3)) - 753);

	cout << min;
	
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstdio>
#include<stdlib.h>
#include<algorithm>
#include<cstring>
#include<vector>
#define MAXN 100005
using namespace std;
int a[2*MAXN],n;
bool check(int mid)
{
	for(int i=0;i<n-1;i++)
	{
		if((a[n-i]>mid&&a[n-i-1]>mid)||(a[n+i]>mid&&a[n+i+1]>mid))
			return false;
		if((a[n-i]<=mid&&a[n-i-1]<=mid)||(a[n+i]<=mid&&a[n+i+1]<=mid))
			return true;
	}
	return a[1]<=mid;
}
int ef(int l,int r)
{
	int mid;
	while(l<r)
	{
		mid=(l+r)>>1;
		if(check(mid))
			r=mid;
		else
			l=mid+1;
	}
	return l;
}
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	scanf("%d",&n);
	for(int i=1;i<=2*n-1;i++)
		scanf("%d",&a[i]);
	printf("%d",ef(1,2*n-1));
    return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define ll long long
#define mod 1e9+7
#define decimalupto(no,y)     fixed<<setprecision(y)<<no

using namespace std;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
   
    ll n;
    cin>>n;
    vector<ll> a(n),b(n);
    for(ll i=0; i<n; ++i){
        cin>>a[i]>>b[i];
    }
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    ll ans;
    if(n%2==1){
        ans = b[n/2]-a[n/2]+1;
    }
    else {
        ans = b[n/2-1]+b[n/2]-(a[n/2-1]+a[n/2])+1;
    }
    cout<<ans<<"\n";
}






Measured memory_bytes: 6336
#include <stdio.h>

int sumdigits(int x)
{
  int sum = 0;
  while (x) {
    sum += x % 10;
    x /= 10;
  }
  return sum;
}

int main(void) 
{
  int a, b, n;
  int min = 10000;
  scanf("%d", &n);
  
  for (a = 1; a < n; a++) {
    b = n - a;
    if (min > sumdigits(a) + sumdigits(b))
      min = sumdigits(a) + sumdigits(b);
  }
  printf("%d", min);
  return 0;
}
  

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define eps 1e-8
#define pr pair<int,int>
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const int maxx = 1e5;

int main()
{
	int n;
	ll sum = 0;
	cin >> n;
	for(int i = 1; i <= n; i ++)
	{
		for(int j = 1; j <= n; j ++)
		{
			for(int k = 1; k <= n; k ++)
			{
				sum += __gcd(__gcd(i, j), k);
			}
		}
	}
	printf("%lld\n", sum);
	return 0;
}



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

const long long MOD=1e9+7;

long long dp[110][100010];

int main()
{
	int n,k;
	cin>>n>>k;
	vector<int>a;
	for(int i=1;i<=n;)
	{
		a.emplace_back(n/i);
		i=n/(n/i)+1;
	}
	int m=a.size();
	sort(a.begin(),a.end());
	for(int i=0;i<=m;i++)
		dp[1][i]=a[i];
	long long ans=0;
	for(int i=2;i<=k;i++)
	{
		for(int j=0;j<=m;j++)
		{
			int oj=m-j-1;
			int t=a[j]-(j==0?0:a[j-1]);
			dp[i][j]=1ll*t*dp[i-1][oj]%MOD;
			if(i==k)
				ans=(ans+dp[i][j])%MOD;
		}
		for(int j=1;j<=m;++ j)
			dp[i][j]=(dp[i][j]+dp[i][j-1])%MOD;
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 79356
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
#define all(v) v.begin(), v.end()
#define bigger (char)toupper
#define smaller (char)tolower
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;
typedef unsigned long long ull;

int main() {
    int N;
    cin>>N;
    vi v(N);
    rep(i,N) {
        cin>>v.at(i);
    }
    sort(all(v));
    int sum=0;
    rep(i,N-1) {
        sum+=(v.at(i+1)-v.at(i));
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 256
def solve():
    strN = input()
    N = int(strN)

    maxD = len(strN)

    numss = [[0]*(10) for _ in range(10)]
    for x in range(1, 10):
        for y in range(1, 10):
            num = 0
            for d in range(1, maxD-2):
                num += 10**d
            if maxD-2 > 0:
                if x < int(strN[0]):
                    num += 10**(maxD-2)
                elif x == int(strN[0]):
                    num += int(strN[1:-1]) + 1
                    if y > int(strN[-1]):
                        num -= 1
            j = x*10 + y
            if 1 <= j <= N:
                num += 1
            if x == y:
                j = x
                if 1 <= j <= N:
                    num += 1
            numss[x][y] = num

    ans = 0
    for i in range(1, 10):
        for j in range(1, 10):
            ans += numss[i][j]*numss[j][i]

    print(ans)


solve()


Measured memory_bytes: 3064
//
// Created by 李青坪 on 2018/10/31.
//

#include <cstdio>
#include <algorithm>

#define MAXN 101
using namespace std;

int graph[MAXN][MAXN];

void init(){
    for (auto &i : graph) {
        fill(i, i +MAXN, 0);
    }
}

int main(){
    int n;
    scanf("%d", &n);
    init();
    int v, dgr;
    for (int i = 0; i < n; ++i) {
        scanf("%d %d", &v, &dgr);
        int node;
        for (int j = 0; j < dgr; ++j) {
            scanf("%d", &node);
            graph[v][node] = 1;
        }
    }
    for (int k = 1; k <= n; ++k) {
        for (int i = 1; i <= n; ++i) {
            if (i-1) printf(" ");
            printf("%d", graph[k][i]);
        }
        printf("\n");
    }
}
/*
4
1 2 2 4
2 1 4
3 0
4 1 3

 */


Measured memory_bytes: 2776
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val N = sc.nextInt()
    val M = sc.nextInt()
    val X = sc.nextInt()
    val Y = sc.nextInt()
    val x = (1..N).map { sc.nextInt() }
    val y = (1..M).map { sc.nextInt() }
    val xRight = Math.max(x.max()!!, X)
    val yLeft = Math.min(y.min()!!, Y)
    println(if (xRight < yLeft) "No War" else "War")
}

Measured memory_bytes: 31512
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pii pair<long long int,long long int>
#define vi vector<long long int >
#define vvi vector<vector< long long int>>
#define MP make_pair
#define PB push_back 
#define pb pop_back
#define PF push_front
#define pf pop_front
#define MOD 1000000007
#define MT make_tuple
ll exp(ll x,ll y)
{
	ll h=1;
	x%=MOD;
	while(y)
	{
		if(y%2==1)
		{
			h=(h*x)%MOD;
		}
		y/=2;
		x = (x*x)%MOD;
	}
	return h;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n;
	cin>>n;
	ll ans=0;
	ans=exp(10,n);
	ll exc=(2*exp(9,n))%MOD;
	ans = (ans+exp(8,n))%MOD;
	if(ans<exc)
		cout<<MOD-(exc-ans)<<endl;
	else
		cout<<ans-exc<<endl;

	//cout<<exp(10,2);

    return 0;
}
			

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for (ll i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define mod (1000000007)
void solve() 
{
    ll n,k;cin>>n>>k;
    ll mn[n+1],mx[n+1];mn[0]=0;mx[0]=n;
    rep(i,1,n+1){
        mn[i]=mn[i-1]+i;
        mx[i]=mx[i-1]+(n-i);
    }
    ll ans=0;
    for(int i=k-1;i<=n;i++){
        // cout<<mx[i]-mn[i]+1<<endl;
        ans+=mx[i]-mn[i]+1;
        ans%=mod;
    }
    cout<<ans<<endl;
    
}

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

Measured memory_bytes: 6732
N = int(input())
A = []
B = []
for _ in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)
A = sorted(A)
B = sorted(B)

K = N//2
if N%2==0:
    a = A[K-1]+A[K]
    b = B[K-1]+B[K]
    print(b-a+1)
else:
    print(B[K]-A[K]+1)

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

using namespace std;

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

	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
		a[i] -= (i + 1);
	}
	sort(a.begin(), a.end());
	int med = a[n / 2];
	for (int i = 0; i < n; ++i) {
		a[i] -= med;
	}
	long long ans = 0;
	for (int i = 0; i < n; ++i) {
		ans += (abs(a[i]));
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 1024
/* ~ CoderMehraJ ~ */
#include <bits/stdc++.h>
using namespace std;

#define show(x) cout << #x << " = " << x << '\n';

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int l;
    double volume;
    cin>>l;
    volume=(l*1.00)/3.00;
    volume=volume*volume*volume;
    cout<<fixed<<setprecision(12)<<volume<<endl;
    return 0;
}
//fixed<<setprecision(1)


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#define FOR(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
const int N=200200;
int n,S,x,w,d,D,A,B;
int a[N],b[N];
long long ans,f[N],g[N];
int main(){
	//freopen("1.in","r",stdin);
	scanf("%d%d",&n,&S);
	FOR(i,1,n){
		scanf("%d%d",&x,&w);
		x<S?(a[++A]=x,f[A]=w):(b[++B]=x,g[B]=w);
	}
	reverse(a+1,a+A+1);
	reverse(f+1,f+A+1);
	while(A && B){
		d=f[A]>=g[B]?-1:1;
		if(d!=D) ans+=b[B]-a[A],D=d;
		~d?g[B]+=f[A--]:f[A]+=g[B--];
	}
	ans+=A?S-a[A]:b[B]-S;
	cout<<ans<<'\n';
}

Measured memory_bytes: 3072
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <math.h>
#include <vector>
using namespace std;

int main() {
    double r;
    cin >> r;

    cout << fixed << setprecision(6) << (r * r * M_PI) << endl;
    cout << fixed << setprecision(6) << (2 * r * M_PI) << endl;

    return 0;
}


Measured memory_bytes: 3236
package main
 
import(
  "fmt"
  "bufio"
  "os"
  "strings"
  "strconv"
  "log"
)
 

func main(){
    a := 0
    fmt.Scan(&a)
    fmt.Println(a*a*a)
}


var sc = bufio.NewScanner(os.Stdin)

func Rr() []string {
  sc.Scan()
  slice := strings.Split(sc.Text(), " ")
  return slice
}



//入力関係ライブラリ(Atcoder:yamanobori_oldさんのもの)
func make_liner(maxByte int) *bufio.Scanner {
  liner := bufio.NewScanner(os.Stdin)
  liner.Buffer(make([]uint8, 0, 8192), maxByte)
  return liner
}
func word_spliter() *bufio.Scanner {
  words := make_liner(8192) 
  words.Split(bufio.ScanWords)
  return words
}

func eGetLine(r *bufio.Scanner) string {
  if r.Scan() {
    return r.Text()
  }
  err := r.Err()
  if err != nil {
    log.Fatal(err)
  }
  // EOF
  return ""
}

func eGetInt(r *bufio.Scanner) int {
  line := eGetLine(r)
  return eAtoi(line)
}

func eAtoi(s string) int {
  n, err := strconv.Atoi(s)
  if err != nil {
    log.Fatal(err)
  }
  return n
}


Measured memory_bytes: 1120
s = input()
n = len(s)+1
num = 0
ans = 0
con = 0


for i in range(n-1):
    if s[i] == '>':
        if con == 0:
            con = 1
        else:
            con += 1

        num -= 1
        if num < 0:
            num = 0
            ans += con
    else:
        if not con == 0:
            ans = ans - num*(con)
            num = 0
        num += 1
        con = 0
    ans += num
print(ans)


Measured memory_bytes: 4212
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<int, int>
#define PP pair<P,int>
#define T tuple<int,int,int> 
using namespace std;

int main(){
    int n,k; cin >> n >> k;
    vector<int> h(n);
    rep(i,n) cin >> h[i];
    int ans=INF;
    sort(all(h));
    rep(i,n-k+1){
        ans=min(ans,h[i+k-1]-h[i]);
    }
    cout << ans << endl;
return 0;
}


Measured memory_bytes: 3760