akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) \
  SORT(var);       \
  REVERSE(var)
#define OPTIMIZE_STDIO         \
  ios::sync_with_stdio(false); \
  cin.tie(0);                  \
  cout.precision(10);          \
  cout << fixed
#define endl '\n'

const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
struct mint {
  ll x;
  mint() : x(0) {
  }
  mint(ll x) : x((x % MOD + MOD) % MOD) {
  }
  mint& operator+=(const mint& r) {
    if ((x += r.x) >= MOD) {
      x -= MOD;
    }
    return *this;
  }
  mint& operator-=(const mint& r) {
    if ((x -= r.x) < 0) {
      x += MOD;
    }
    return *this;
  }
  mint& operator*=(const mint& r) {
    if ((x *= r.x) > MOD) {
      x %= MOD;
    }
    return *this;
  }
  mint& operator++() {
    if ((++x) >= MOD) {
      x -= MOD;
    }
    return *this;
  }
  mint operator++(int) {
    mint ret = x;
    if ((++x) >= MOD) {
      x -= MOD;
    }
    return ret;
  }
  mint& operator--() {
    if ((--x) < 0) {
      x += MOD;
    }
    return *this;
  }
  mint operator--(int) {
    mint ret = x;
    if ((--x) < 0) {
      x += MOD;
    }
    return ret;
  }
  mint operator+(const mint& r) {
    mint ret;
    return ret = x + r.x;
  }
  mint operator-(const mint& r) {
    mint ret;
    return ret = x - r.x;
  }
  mint operator*(const mint& r) {
    mint ret;
    return ret = x * r.x;
  }
  mint operator-() {
    return mint() - *this;
  }
  bool operator<(const mint& a) {
    return x < a.x;
  }
  bool operator>(const mint& a) {
    return x > a.x;
  }
  bool operator<=(const mint& a) {
    return x <= a.x;
  }
  bool operator>=(const mint& a) {
    return x >= a.x;
  }
  bool operator==(const mint& a) {
    return x == a.x;
  }
  bool operator!=(const mint& a) {
    return x != a.x;
  }
};
ostream& operator<<(ostream& os, const mint& r) {
  os << r.x;
  return os;
}
ostream& operator>>(ostream& os, const mint& r) {
  os >> r.x;
  return os;
}

int d;

void solve(istream& cin, ostream& cout) {
  int n, k;
  cin >> n >> k;
  map<int, bool> m;
  FOR(i, 1, n) {
    m[i] = false;
  }
  REP(i, k) {
    cin >> d;
    int a;
    REP(i, d) {
      cin >> a;
      m[a] = true;
    }
  }
  int ans = 0;
  FOR(i, 1, n) {
    if (!m[i]) ans++;
  }
  cout << ans << endl;
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
  return 0;
}
#endif


Measured memory_bytes: 3624
using static System.Math;
using System;

public class hello
{
    public static void Main()
    {
        while (true)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            var d = int.Parse(line[0]);
            var e = int.Parse(line[1]);
            if (d == 0 && e == 0) break;
            Console.WriteLine(getAns(d, e));
        }
    }
    static double getAns(int d, int e)
    {
        var ans = (double)Abs(d - e);
        for (int i = 1; i <= d / 2; i++)
        {
            var t = Abs(e - Sqrt(i * i + (d - i) * (d - i)));
            ans = Min(ans, t);
        }
        return ans;
    }
}



Measured memory_bytes: 15896
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << "\n\n"
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;

template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << ' ';
  }
  return s;
}

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      cout << '\n';
  }
  return s;
}

template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

signed main() {
  int N;
  cin >> N;

  int k = -1;
  repp(i, 1, 1000) {
    if (i * (i - 1) / 2 == N) {
      k = i;
      break;
    }
  }
  if (k == -1) {
    cout << "No\n";
    return 0;
  }

  vector<vector<int>> S(k);
  int n = 1;
  rep(i, k) {
    repp(j, i + 1, k - 1) {
      S[i].pb(n);
      S[j].pb(n);
      n++;
    }
  }

  cout << "Yes\n";
  cout << k << "\n";
  rep(i, k) {
    cout << len(S[i]) << " ";
    cout << S[i] << "\n";
  }
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
#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 MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
using P = pair<int,int>;

int main()
{
  int N,K,R,S,P;
  cin >> N >> K >> R >> S >>P;
  string T;
  cin >> T;

  int ans = 0;
  REP(i,N){
    if(i<K){
      if(T.at(i)=='r'){
        ans+=P;
      }else if(T.at(i)=='s'){
        ans+=R;
      }else{
        ans+=S;
      }
    }else{
      if(T.at(i)=='r'&&T.at(i-K)!='r'){
        ans+=P;
      }else if(T.at(i)=='s'&&T.at(i-K)!='s'){
        ans+=R;
      }else if(T.at(i)=='p'&&T.at(i-K)!='p'){
        ans+=S;
      }else if(T.at(i)=='r'&&T.at(i-K)=='r'){
        T.at(i)='a';
      }else if(T.at(i)=='s'&&T.at(i-K)=='s'){
        T.at(i)='a';
      }else if(T.at(i)=='p'&&T.at(i-K)=='p'){
        T.at(i)='a';
      }
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define S second
#define F first
#define ll long long

using namespace std;

const int N = 2e5 + 5;

int arr[N], grid[200][200];

int main()
{
    map<int, int> mop;
    int n, xx, k;
    scanf("%d%d", &n, &k);
    for(int i = 0 ; i < n ; i++)
    {
        scanf("%d", &xx);
        mop[xx]++;
    }
    vector<pair<int, int> > v;
    for(auto i:mop) v.emplace_back(i.S, i.F);
    sort(v.rbegin(), v.rend());
    int ans = 0;
    for(int i = k ; i < v.size() ; i++) ans += v[i].F;
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 11768
import java.util.Scanner;

public class Main {
    public static void main(String args[]){
        Scanner stdIn = new Scanner(System.in);

        long a = stdIn.nextLong();
        long b = stdIn.nextLong();
        long c = stdIn.nextLong();
        //int e = stdIn.nextInt();
        //int x = stdIn.nextInt();
        //int num[] = new int[];
        //String s = stdIn.next();
        //String t = stdIn.next();
        //char c[] = s.toCharArray();
        //int sum = 0;
        //boolean flag = true;
        //for(int i = 0; i < s.length(); i++){
        //}

        System.out.println(Math.min(a, Math.min(b, c)) + " " + Math.max(a, Math.max(b, c)));

        //System.out.println();
        //System.out.print();

        stdIn.close();
    }
}



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

#define INF 1000000

int main(void){
    while(true){
        int n, m;
        cin >> n >> m;
        if(n == 0 && m == 0){ break; }

        double input, tarotal = 0, hanakotal = 0;
        set<double> taro, hanako;
        for(int i = 0; i < n; i++){
            cin >> input;
            taro.insert(input);
            tarotal += input;
        }
        for(int i = 0; i < m; i++){
            cin >> input;
            hanako.insert(input);
            hanakotal += input;
        }

        double now, dif, ans_taro = INF, ans_hanako = INF;
        for(set<double>::iterator it = taro.begin(); it != taro.end(); it++){
            now = tarotal - *it;
            dif = (hanakotal + *it - now) / 2;

            if(hanako.count(dif) != 0 && *it + dif < ans_taro + ans_hanako){
                ans_taro = *it;
                ans_hanako = dif;
            }
        }

        if(ans_taro == INF && ans_hanako == INF){ cout << -1 << endl; }
        else{ cout << ans_taro << " " << ans_hanako << endl; }
    }
    return 0;
}

Measured memory_bytes: 3128
#include <iostream>

using namespace std;

int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int w = 0, r = 0;
  for (auto x : s) {
    if (x == 'W') w++;
    else r++;
  }
  int ans = 0;
  for (int i = 0; i < r; i++) {
	if (s[i] == 'W') ans++;
  }
  cout << ans;
}

Measured memory_bytes: 3420
#include <bits/stdc++.h>
using namespace std;
#define MAX_N 100001
#define INF 1000000000
int N, X, x[MAX_N];
int gcd(int a, int b){
	if(b==0) return a;
	return gcd(b, a % b);
}

int main(void){
	cin >> N >> X;
	for(int i=0; i<N; i++) cin >> x[i];
	for(int i=0; i<N; i++) x[i] = abs(X - x[i]);
	int min_x = INF;
	for(int i=0; i<N; i++) min_x = min(min_x, x[i]);
	int min_gcd = INF;
	for(int i=0; i<N; i++) min_gcd = min(min_gcd, gcd(min_x, x[i]));
	cout << min_gcd << endl;
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<vector>
#include<utility>
#include<cstdlib>
#include<queue>
using namespace std;

int main() {

    int N;
    cin >> N;
    int ans = 0;
    while( N > 0 ) {
        ans += N %10;
        N /= 10;
    }
    if(ans == 1) {
        ans = 10;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5 + 50;
int a[N];
int main()
{
    int n, m;
    ll ans = 0;
    scanf("%d%d", &n, &m);
    for (int i = 0; i < m; i++)
        scanf("%d", a + i);
    sort(a, a + m);
    for (int i = 1; i < m; i++)
        a[i - 1] = a[i] - a[i - 1];
    sort(a, a + m - 1, greater<int>());
    for (int i = n - 1; i < m - 1; i++)
        ans += a[i];
    printf("%lld", ans);
    return 0;
}

Measured memory_bytes: 640
SEPARATE = "####################"

tower = [
		[[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],
		[[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],
		[[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],
		[[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]
		]

n = int(input())
i = 0
while i < n:
	b, f, r, v = map(int, input().split())
	tower[b - 1][f - 1][r - 1] += v
	i += 1

i = 0
j = 0
k =  0
while k < 4:	
	while j < 3:
		while i < 10:
			print(" " + str(tower[k][j][i]), end = "")
			i += 1
		print()
		j += 1
		i = 0
	if k != 3:
		print(SEPARATE)
	j = 0
	k += 1


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

int main()
{
  string s;
  cin >> s;
  
  bool result = false;

  for(int i = 0; i < s.size(); i++){
    if(s.at(i) == '7'){
      result = true;
      break;
    }
  }
  if(result){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  return 0;

}

Measured memory_bytes: 3624
#include <stdlib.h>
#include <cmath>
#include <cstdio>
#include <cstdint>
#include <string>
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
using namespace std;
using ll = long long;

int main(){
  int N,M;
  cin >> N >> M;
  vector<pair<bool,int>> prob(N,make_pair(false,0));
  int p;
  string s;
  int ac=0,pena=0;
  for(int i=0;i<M;++i){
    cin >> p >> s;
    --p;
    if(s=="WA") prob.at(p).second++;
    else{
      if(prob.at(p).first==true) continue;
      else{
	prob.at(p).first=true;
	++ac;
	pena+=prob.at(p).second;
      }
    }
  }

  cout << ac << " " << pena << endl;

  return 0;
}


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

int n,innerRating,displayedRating;

int main(){
	cin>>n>>displayedRating;
	if(n >= 10){
		innerRating = displayedRating;
	}else{
		innerRating = displayedRating + 100 * (10 - n);
	}
	cout<<innerRating<<endl;
}


Measured memory_bytes: 256
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include<bits/stdc++.h>
using namespace std;
#define rint register int
#define rep(i,l,r) for(rint i=l;i<=r;i++)
#define per(i,l,r) for(rint i=l;i>=r;i--)
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define fir first
#define sec second
#define mset(s,t) memset(s,t,sizeof(s))
template<typename T1,typename T2>void ckmin(T1 &a,T2 b){if(a>b)a=b;}
template<typename T1,typename T2>void ckmax(T1 &a,T2 b){if(a<b)a=b;}
template<typename T>T gcd(T a,T b){return b?gcd(b,a%b):a;}
int read(){
  int x=0,f=0;
  char ch=getchar();
  while(!isdigit(ch))f|=ch=='-',ch=getchar();
  while(isdigit(ch))x=10*x+ch-'0',ch=getchar();
  return f?-x:x;
}
const int N=100005;
int main(){
  int A,B,C;
  long long ans =0;
  int n;
  cin>>n;
  n--;
  for(int i=1;i<=n;i++)ans+=n/i;
  cout<<ans;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
const int mod = 2019;
int cnt[mod + 1] = {1};
int main() {
    string str;
    cin >> str;
    int val = 0, pow = 1, ans = 0;
    int len = str.size();
    for (int i = len - 1; i >= 0; i--) {
        val += (str[i] - '0') * pow % mod;
        pow = pow * 10 % mod;
        val %= mod;
        ans += cnt[val];
        cnt[val]++;
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3728
#include <iostream>

using namespace std;

const int MAX_N = 100;

int main(int argc, char const *argv[]) {
  int n, ans=0, x=0;
  char s[MAX_N];
  cin >> n;
  for (size_t i = 0; i < n; i++) {
    cin >> s[i];
    if (s[i]=='I') x++;
    else x--;
    ans = max(ans,x);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i< (n); i++)
using namespace std;

int main() {
 string s,t;
 cin >> s >> t;
 char v = t.back();
 if(t == s + t.back()){
   cout << "Yes" << endl;
 }
 else{
   cout << "No" << endl;
 }

}


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

namespace AtCoder
{
    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        class Node
        {
            public static int K;
            public static int[] count = new int[100001];
            private bool visited = false;
            public List<Node> children = new List<Node>();
            public long Count(int n)
            {
                visited = true;
                int n0 = count[n]++;
                int n1 = (n >= 1) ? 1 : 0;
                int n2 = (n >= 2) ? 1 : 0;
                long ans = K - n0 - n1 - n2;
                foreach (var child in children)
                {
                    if (ans <= 0) { break; }
                    if (!child.visited)
                    {
                        ans *= child.Count(n + 1);
                        ans %= 1000000007;
                    }
                }
                visited = false;
                count[n + 1] = 0;
                return Math.Max(ans, 0);
            }
        }

        static void Main(string[] args)
        {
            var V1 = ReadInts();
            int N = V1[0], K = V1[1];
            var nodes = new Node[N];
            for (int i = 0; i < N; ++i) { nodes[i] = new Node(); }
            for (int i = 0; i < N - 1; ++i)
            {
                var V2 = ReadInts();
                var a = nodes[V2[0] - 1];
                var b = nodes[V2[1] - 1];
                a.children.Add(b);
                b.children.Add(a);
            }
            Node.K = K;
            Console.WriteLine(nodes[0].Count(0));
        }
    }
}


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

int main() {
    int n, m;
    long long ans = 0;
    priority_queue<int> q;
    cin >> n >> m;
    for(int i=0;i<n;i++){
        int a;
        cin >> a;
        q.push(a);
    }
    while(!q.empty()){
        int v = q.top(); q.pop();
        if(m > 0){
            m--;
            q.push(v / 2);
        }else{
            ans += v;
        }
    }
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 892
/*
No matter how long a night, dawn will always break.

Simular saying ... The darkest hour is just before the dawn.
 ***************************************   ************************8   **********************************
*/
#include <bits/stdc++.h>
using namespace std;

 
#define int         long long
#define double      long double
#define pb          push_back
#define pf          push_front
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define x           first
#define y           second
#define endl        '\n'
#define sz(x)	    (int)(x).size()
#define fo(i,l,u)   for(i=l;i<u;i++)
#define rfo(i,l,u)  for(i=l;i>=u;i--)
#define allfo(s)    for(auto it=(s).begin();it!=(s).end();it++)
#define _init(b)     memset(b,-1,sizeof(b))
#define _init0(b)     memset(b,0,sizeof(b))
#define MOD         1000000007
#define hell        998244353
#define output(x) cout << (x ? "YES" : "NO")<<endl;
 
 
 
 
 
int gcd(int a, int b) {if(a>b)swap(a,b) ;  if (a == 0)  return b; return gcd(b % a, a); }  
bool mod(double a,double b) {return a/b - floor(a/b);}
 

 int f(int a,int b,int l,int r){
 	if(l>r)return 0;
 	if(l/b==r/b){
 		return (a*r)/b-a*(r/b);
 	}
 	int mid=l+(r-l)/2;
 	return max(f(a,b,l,mid),f(a,b,mid+1,r));
 }
 
 
signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   int i,j,x,k,a,b,n,m;
   cin>>n>>m;
   if(n%2==1){
	   fo(i,0,m){
	   	cout<<i+1<<" "<<n-i<<endl;
	   }
	}
	else{
		b=(m-1)/2+1;
		fo(i,0,b){
			cout<<n/2-i<<" "<<n/2+i+1<<endl;
		}
		a=m-b;
		fo(i,0,a){
			cout<<i+1<<" "<<n-i-1<<endl;
		}
	}


   
   
   
    return 0;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define rep(i, a, b) for (auto i = (a); i < (b); ++i)
typedef long long ll;

int n, m, p;
vector<pair<int, int> > v[2501];
ll cost[2501];

int main() {
  cin >> n >> m >> p;
  rep(i, 0, m) {
    int a, b, c; cin >> a >> b >> c;
    a--; b--;
    v[a].pb(mp(b, -(c - p)));
  }
  fill(cost, cost + n, LLONG_MAX);
  cost[0] = 0;
  rep(loop, 0, 3 * n) {
    bool update = false;
    rep(i, 0, n) {
      if (cost[i] == LLONG_MAX) continue;
      rep(j, 0, (int)v[i].size()) {
        int next = v[i][j].fi;
        ll nextc = cost[i] + v[i][j].se;
        if (cost[next] > nextc) {
          cost[next] = nextc;
          if (loop >= n) {
            cost[next] = -999999999;
          }
          update = true;
        }
      }
    }
    if (update && loop == 3 * n - 1 && cost[n - 1] == -999999999) {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << (-cost[n - 1] < 0 ? 0 : -cost[n - 1]) << endl;
}

///////////////////////////////////////////////////////////////////////////////////
// NOTE
///////////////////////////////////////////////////////////////////////////////////
/*
http://sigma1113.hatenablog.com/entry/2019/08/12/130042
嘘解法だったなんて今まで思いもしなかった.
でも、結構綺麗に対処できるからコード量はあんまり変わらないかも.
*/

Measured memory_bytes: 512
import numpy as np
def matrix_power(Mat, n):
    if n == 0:
        return I#(単位元）
    x = matrix_power(Mat, n>>1)#半分を考える
    x = np.dot(x, x)#n//2を二回行う
    if not n&1:
        return x%M
    x = np.dot(x, Mat)#あまりの分
    return x%M
I = np.identity(3, dtype = 'object') 
L, A, B, M = map(int,  input().split())
ans = np.array([[0],
                          [A],
                          [1]], dtype = 'object')
s_L = A+B*(L-1)
for digit in range(len(str(A)), len(str(s_L))+1):
    cnt = (min(s_L, 10**digit-1)-A)//B-max(-1, (10**(digit-1)-1-A)//B)
    Mat = np.array([[10**digit, 1, 0],
                            [0, 1, B],
                            [0, 0, 1]])
    ans = np.dot(matrix_power(Mat, cnt), ans)%M
print(ans[0, 0])

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

using namespace std;

#define lli long long int
#define pb  push_back
#define mp  make_pair

vector <lli> vv;

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

    n = n%k;

    if(n-k > -n){
        n = n-k;
        cout << abs(n);
    }
    else cout << n;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ld long double
#define pb push_back
// #define mp make_pair
#define nt _int128 
#define fir first
#define sec second
#define fast_as_levi ios_base::sync_with_stdio(false) , cin.tie(NULL);
#define debug(x) cout<<x<<"\n";
#define debug cout<<"debugged\n";
#define inf 0x3f3f3f3f
 
const ll mod = 1e9 + 7;
const ll mx = 2e6 + 5;
const ll mxi = 2e3 + 5;

int main()
{
    fast_as_levi;
    ll i,n;
    cin>>n;
    ll ar[n],br[n],cr[n];
    for(i=0;i<n;i++)
    {
        cin>>ar[i]>>br[i]>>cr[i];
    }
    ll dp[n+1][3];
    for(i=0;i<=n;i++)
    {
        for(ll j=0;j<3;j++)
        dp[i][j]=0;
    }
    for(i=1;i<=n;i++)
    {
        dp[i][0] = ar[i-1] + max(dp[i-1][1],dp[i-1][2]);
        dp[i][1] = br[i-1] + max(dp[i-1][0],dp[i-1][2]);
        dp[i][2] = cr[i-1] + max(dp[i-1][0],dp[i-1][1]);
    }
    // for(i=0;i<=n;i++)
    // {
    //     for(ll j=0;j<n;j++)
    //     {
    //         cout<<dp[i][j]<<" ";
    //     }
    //     cout<<"\n";
    // }
    cout<<max(dp[n][0],max(dp[n][1],dp[n][2]));
}

Measured memory_bytes: 4992
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

// #define DEBUG
#ifdef DEBUG
#define debug_printf printf
#else
#define debug_printf 1 ? 0 : printf
#endif

typedef long long int ll;
typedef vector<ll> Vl;
typedef vector<int> Vi;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pl;

#define MOD(x, y) ((((x) % (y)) + (y)) % (y))
#define DIV(x, y) (((x) < 0) ? ((x) + 1) / (y) - 1: (x) / (y))
#define FST first
#define SND second

const int MAX_H = 500;                  // 10^5
// const int MAX_N = 100000;                  // 10^5
// const int MAX_N = 1000000000;              // 10^9
// const ll  MAX_N = 1000000000000000000;     // 10^18
// const int BASE  = 1000000000 + 7;          // 10^9 + 7
// const int INFI  = 1000000000 + 7;          // 10^9 + 7
// const ll INFL  = 1000000000000000000 + 7; // 10^18 + 7

string COLOR = "RGBY";

int H, W, D;
char MAP[MAX_H][MAX_H + 1];

void solve() {
  for (int i = 0; i < H; i++)
    for (int j = 0; j <= W; j++) MAP[i][j] = '\0';

  for (int r = 0; r < H; r++) {
    for (int c = 0; c < W; c++) {
      int x = r + c, y = r - c;
      int z = DIV((2 * x + D - 1), (2 * D));
      int w = DIV((2 * y + D - 1), (2 * D));
      z = MOD(z, 2);
      w = MOD(w, 2);
      #ifdef DEBUG
      cout << r << " " << c << endl;
      cout << x << " " << y << endl;
      cout << z << " " << w << endl;
      cout << endl;
      #endif
      int k = 2 * z + w;
      MAP[r][c] = COLOR[k];
    }
  }

  for (int i = 0; i < H; i++)
    cout << MAP[i] << endl;
}

int main() {
  cin >> H >> W >> D;

  solve();

  return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
#define fast                                                                   \
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
#define ll long long
#define f(i, n) for (int i = 0; i < n; i++)
#define fo(i,a,n) for (i = a; i <= n; i++)
#define F first
#define S second
#define pii pair<int,int>
#define sz size()
#define all(v) v.begin(),v.end()
#define pb push_back
#define pf push_front    
#define PB pop_back
#define pll pair<long long, long long>
#define vi vector<int>
#define vl vector<int>
#define mp make_pair
#define mod 1000000007
typedef unsigned long long ull;
const int N = 200005;
const int MOD = 998244353 ;


void solve(){
    double n, k, p, ans;
    cin>>n;
    k = (n/3);
    k *= k;
    k *= (n/3);
    cout<<fixed<<setprecision(12)<<k;
    /*if(n%3 == 0){
        int k = (n / 3);
        cout<<(k*k*k);
        return ;
    }
    else if(n%3 == 1){
        int k = (n/3);
        n -= (2*k);
        k *= k;
        k *= n;
        cout<<k;
        return ;
    }
    else{
        int k = (n/3);
        n -= (2 * (k + 1));
        k++;
        k *= k;
        k *= n;
        cout<<k;
        return ;
    }*/
}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define vec(k) vector<k>
#define vecvec(k) vector<vector<k> >
#define pai(k) pair<k,k>
#define mod 1000000007
#define mpai make_pair
#define p1 first
#define p2 second
#define umap(x,y) unordered_map<x,y>

ll dp[22][(ll)(1<<22)];
int solve(vector<ll>arr, int n, int i, int mask)
{
	if(i==n )
		return dp[i][mask]=1;
	if(mask==0)
		return dp[i][mask]=1;
	if(dp[i][mask]!=-1)
		return dp[i][mask];
	ll val=arr[i];
	val&=mask;
	int ans=0;
	for(int j=0;j<n;j++)
	{
		if((val>>j)&1)
		{
			ans= (ans+ solve(arr,n,i+1,mask^(1<<j)))%mod;
		}
	}
	return dp[i][mask] =ans%mod;
	
}

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


ll n,x,a;
cin>>n;
memset(dp,-1,sizeof(dp));
vector<ll>arr;
// bitset<32>bit;
for(int i=0;i<n;i++)
{
	x=0;
	for(int j=0;j<n;j++)
	{
	cin>>a;
	if(a)
		x|=(ll)pow(2,j);
	}
	arr.push_back(x);
}
ll mask=pow(2,n)-1;
int ans=solve(arr, n, 0, mask);
cout<<ans<<"\n";

return 0;
}


Measured memory_bytes: 721152
#line 1 "/workspaces/compro/lib/template.hpp"


#line 1 "/workspaces/compro/lib/io/vector.hpp"
#include <iostream>
#include <vector>

#ifndef IO_VECTOR
#define IO_VECTOR

template <class T> std::ostream &operator<<(std::ostream &out, const std::vector<T> &v) {
  int size = v.size();
  for (int i = 0; i < size; i++) {
    std::cout << v[i];
    if (i != size - 1)
      std::cout << " ";
  }
  return out;
}

template <class T> std::istream &operator>>(std::istream &in, std::vector<T> &v) {
  for (auto &el : v) {
    std::cin >> el;
  }
  return in;
}

#endif
#line 4 "/workspaces/compro/lib/template.hpp"
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
#define MM << " " <<

using namespace std;

template <class T> void say(bool val, T yes, T no) { cout << (val ? yes : no) << "\n"; }

void say(bool val, string yes = "Yes", string no = "No") { say<string>(val, yes, no); }

template <class T> void chmin(T &a, T b) {
  if (a > b)
    a = b;
}

template <class T> void chmax(T &a, T b) {
  if (a < b)
    a = b;
}

// C++ 17に完全移行したら消す
// 最大公約数を求める
template <class T> T gcd(T n, T m) { return n ? gcd(m % n, n) : m; }

// 最小公倍数を求める
template <class T> T lcm(T n, T m) {
  int g = gcd(n, m);
  return n * m / g;
}

// 重複を消す。計算量はO(NlogN)
template <class T> void unique(std::vector<T> &v) {
  std::sort(v.begin(), v.end());
  v.erase(std::unique(v.begin(), v.end()), v.end());
}


#line 2 "main.cpp"

void solve(long long K) {
  string s = "ACL";
  REP(i, K) { cout << s; }
  cout << endl;
}

// generated by online-judge-template-generator v4.7.1 (https://github.com/online-judge-tools/template-generator)
int main() {
  long long K;
  std::cin >> K;
  solve(K);
  return 0;
}


Measured memory_bytes: 3552
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n,k = inpl()
s = set()
for i in range(k):
    a = inp()
    b = inpl()
    for i in b:
        s.add(i)
print(n-len(s))

Measured memory_bytes: 10500
s = input()
n = len(s)
mod = 10**9+7
dp = [[0]*13 for _ in range(n+1)]
dp[0][0] = 1
d = {(j, k):(10*j+k)%13 for k in range(10) for j in range(13)}
for i in range(n):
  if s[i] != "?":
    t = int(s[i])
    for j in range(13):
      dp[i+1][(10*j+t)%13] += dp[i][j]
      dp[i+1][(10*j+t)%13] %= mod
  else:
    for k in range(10):
      for j in range(13):
        dp[i+1][(10*j+k)%13] += dp[i][j]
        dp[i+1][(10*j+k)%13] %= mod
print(dp[n][5]%mod)

Measured memory_bytes: 61916
from sys import exit, stderr, stdin, setrecursionlimit
input = stdin.readline
# setrecursionlimit(10**7)

def debug(var, name="hoge"):
    print(name +":" + str(type(var)) + " = " + repr(var), file=stderr)
    return



def main():
    # まず可能かどうか
    S = str(input().rstrip())*2
    T = str(input().rstrip())
    LS = len(S)//2
    LT = len(T)
    S *= 3
    # はじめて出る位置
    char_p = dict()
    for i in range(LS):
        if not S[i] in char_p:
            char_p[S[i]] = i

    # char_pの文字が２つめのはじめて出る位置までに
    char_d = dict(zip(char_p.keys(),[[0 for __ in range(LS+char_p[c])] for c in char_p]))
    for c in char_p:
        dis = 1
        for i in range(LS+char_p[c]-1,-1,-1):
            if S[i] == c:
                char_d[c][i] = dis
                dis = 1
            else:
                char_d[c][i] = dis
                dis += 1
    # 答えの計算
    debug(char_d)
    init = True
    for t in T:
        if t not in char_p:
            print(-1)
            exit()
        else:
            debug(t,'string')
            if init:
                cur = char_p[t]
                init = False
            #それ以外なら区切りで相対的な位置を出して足す
            else:
                rel_cur = cur%LS
                debug(rel_cur,"relative_cursol")
                cur += char_d[t][rel_cur]
        debug(cur,"cur")
        # print()
    print(cur+1)






if __name__ == "__main__":
    main()


Measured memory_bytes: 800560
# -*- coding: utf-8 -*-
n = int(input())
hi = list(map(int, input().split()))
flag = False
cnt = 0
while sum(hi)>0:
    flag = False
    for hidx in range(len(hi)):
        if hi[hidx] > 0:
            if not flag:
                cnt += 1
                flag = True
            hi[hidx] -= 1
        else:
            flag = False
print(cnt)


Measured memory_bytes: 2940
import sys
s = str(input())

if s[0] != 'A':
    print('WA')
    sys.exit()
    
test_st = s[2:-1]
#print(test_st)
test_stx =''
for i in range(len(test_st)):
    if test_st[i] == 'C':
        test_stx = s[1]+test_st[:i] + test_st[i+1:]+s[-1]
        #print(test_stx)
    
if test_stx.islower() and len(test_stx) >0:
    print('AC')
else:
    print('WA')
    

Measured memory_bytes: 8744
#include <stdio.h>
int main(){
    int S,h,m,s;    
    scanf("%d",&S);
    h=S/3600;
    m=(S-h*3600)/60;
    s=S-h*3600-m*60;
    printf("%d:%d:%d\n",h,m,s);
    return 0;
}


Measured memory_bytes: 2148
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll maxn=1e5+9;
ll arr[maxn];
ll sum[maxn];
ll sz[maxn];
ll n,k;
int main(){
        ll a,b,c,d,e,f,g,h;
        ios::sync_with_stdio(0);
        string s;
        while(cin>>s){
                for(int i=0;i<19;i++){
                        if(s[i]==',')cout<<' ';
                        else cout<<s[i];
                }
                cout<<endl;
        }
        return 0;
}


Measured memory_bytes: 256
def examA():
    W = {'Sunny':'Cloudy','Cloudy':'Rainy','Rainy':'Sunny'}
    S = SI()
    ans = W[S]
    print(ans)
    return

def examB():
    ans = 0
    print(ans)
    return

def examC():
    ans = 0
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    # https://tjkendev.github.io/procon-library/python/string/z-algorithm.html
    def z_algo(S):
        N = len(S)
        A = [0] * N
        i = 1; j = 0
        A[0] = l = len(S)
        while i < l:
            while i + j < l and S[j] == S[i + j]:
                j += 1
            if not j:
                i += 1
                continue
            A[i] = j
            k = 1
            while l - i > k < j - A[k]:
                A[i + k] = A[k]
                k += 1
            i += k; j -= k
        return A
    N = I()
    S = SI()
    ans = 0
    for i in range(N):
        Z = z_algo(S[i:])
        for k,n in enumerate(Z[1:]):
            cur = min(k+1,n)
            ans = max(ans,cur)
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,copy,bisect,itertools,heapq,math,random
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

if __name__ == '__main__':
    examA()

"""

"""

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

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

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

int main(void){

    string a, b;
    cin >> a >> b;

    b.pop_back();

    if(a == b) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 3624
import java.util.Scanner;

public class Main {
    public static void main(String args[]){
        Scanner scan = new Scanner(System.in);

        int d[]=new int[6];
        for(int i=0;i<6;i++){
            d[i]=scan.nextInt();
        }
        Dice dice =new Dice(d[0],d[1],d[2],d[3],d[4],d[5]);

        String inst =scan.next();

        for(int i=0;i<inst.length();i++){
            char c=inst.charAt(i);
            switch (c){
                case 'N':
                    dice.turnN();
                    break;
                case 'S':
                    dice.turnS();
                    break;
                case 'W':
                    dice.turnW();
                    break;
                case 'E':
                    dice.turnE();
                    break;
            }
        }

        System.out.println(dice.top);
    }
}

class Dice{
    int top,bottom,left,right,front,back;

    Dice(int a, int b,int c,int d,int e,int f){
        top=a;
        front=b;
        right=c;
        left=d;
        back=e;
        bottom=f;
    }

    void turnN(){
        int tmp=top;
        top=front;
        front=bottom;
        bottom=back;
        back=tmp;
    }
    void turnS(){
        int tmp=top;
        top=back;
        back=bottom;
        bottom=front;
        front=tmp;
    }
    void turnW(){
        int tmp=top;
        top=right;
        right=bottom;
        bottom=left;
        left=tmp;
    }
    void turnE(){
        int tmp=top;
        top=left;
        left=bottom;
        bottom=right;
        right=tmp;
    }
}



Measured memory_bytes: 26432
fun next() = readLine()!!
fun nextInt(offset: Int = 0) = Integer.parseInt(next()) + offset
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map(String::toInt)
fun listOfInt(offset: Int = 0) = listOfString().map { Integer.parseInt(it) + offset }

fun main(arg: Array<String>) {
    val (N, M) = listOfInt() 
	val graph = Array(N) { BooleanArray(N) }
    repeat (M) {
        val (A,B) = listOfInt(-1)
		graph[A][B] = true
        graph[B][A] = true
    }
    val visited = BooleanArray(N)
	fun dfs(v: Int): Int {
		if (visited.all {it}) return 1
    	var ret = 0
    	for (i in 0 until N) {
	        if (!graph[v][i]) continue
	        if (visited[i]) continue
	        visited[i] = true
	        ret += dfs(i)
	        visited[i] = false
		}
		return ret
    }
    visited[0] = true
    val ans = dfs(0)
    println(ans)
}


Measured memory_bytes: 37676
#include<stdio.h>
#include<stdlib.h>

void run(void){
  int n;
  scanf("%d",&n);
  double *dp=(double *)calloc(n+1,sizeof(double));
  dp[0]=1;
  for(int i=0;i<n;i++){
    double p;
    scanf("%lf",&p);
    for(int j=i+1;j>0;j--) dp[j]=(1-p)*dp[j]+p*dp[j-1];
    dp[0]*=1-p;
  }
  double ans=0;
  for(int i=n;i>n-i;i--) ans+=dp[i];
  printf("%.9f\n",ans);
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define int long long
typedef long long ll;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
using namespace std;
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

signed main() {
  string s;cin>>s;int n = s.length();
  bool c = false;
  rep(i,n){
    if(!c && s[i] == 'C')c = true;
    else if(c && s[i] == 'F'){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 508
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int MOD = 1000000007;

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n) {
    if (n&1) (res *= a) %= mod;
    (a *= a) %= mod;
    n >>= 1;
  }
  return res;
}

template< int mod >
struct ModInt {
  int x;
  ModInt() : x(0) {}
  ModInt(long long y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
  ModInt &operator+=(const ModInt &p) {
    if((x += p.x) >= mod) x -= mod;
    return *this;
  }
  ModInt &operator-=(const ModInt &p) {
    if((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }
  ModInt &operator*=(const ModInt &p) {
    x = (int) (1LL * x * p.x % mod);
    return *this;
  }
  ModInt &operator/=(const ModInt &p) {
    *this *= p.inverse();
    return *this;
  }
  ModInt operator-() const { return ModInt(-x); }
  ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
  ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
  ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
  ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
  bool operator==(const ModInt &p) const { return x == p.x; }
  bool operator!=(const ModInt &p) const { return x != p.x; }
  ModInt inverse() const {
    int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0) {
      t = a / b;
      swap(a -= t * b, b);
      swap(u -= t * v, v);
    }
    return ModInt(u);
  }
  ModInt pow(long long n) const {
    ModInt ret(1), mul(x);
    while(n > 0) {
      if(n & 1) ret *= mul;
      mul *= mul;
      n >>= 1;
    }
    return ret;
  }
  friend ostream &operator<<(ostream &os, const ModInt &p) {
    return os << p.x;
  }
  friend istream &operator>>(istream &is, ModInt &a) {
    long long t;
    is >> t;
    a = ModInt< mod >(t);
    return (is);
  }
  static int get_mod() { return mod; }
};
using mint = ModInt< MOD >;

mint comb(mint n, int k) {
  mint res = 1;
  for (int i = 1; i <= k; i++)
    res *= (n-i+1)/i;
  return res;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, a, b;
  cin >> n >> a >> b;
  mint ans = modpow(2, n, MOD);
  ans -= 1;
  ans -= comb(n, a);
  ans -= comb(n, b);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
let cnt = ref 0

let insertion_sort (a : int array) n g =
  for i = g to n - 1 do
    let v = a.(i) in
    let j = ref (i - g) in
    while !j >= 0 && a.(!j) > v do
      a.(!j+g) <- a.(!j);
      j := !j - g;
      incr cnt;
    done;
    a.(!j+g) <- v;
  done

let generate_g n =
  let rec doit i g acc =
    if g > n then acc
    else doit (i + 1) (int_of_float (4.**(float_of_int i) +. 3.*.2.**(float_of_int (i - 1)) +. 1.)) (g :: acc) in
  doit 1 1 []

let shell_sort (a : int array) n =
  cnt := 0;
  let g = generate_g n in
  List.iter (fun g -> insertion_sort a n g) g;
  g

let () =
  let n = read_int () in
  let a = Array.init n (fun _ -> read_int ()) in
  let g = shell_sort a n in
  Printf.printf "%d\n" (List.length g);
  List.iteri (fun i n -> if i <> 0 then print_string " "; print_int n) g;
  print_newline ();
  Printf.printf "%d\n" !cnt;
  Array.iter (fun n -> Printf.printf "%d\n" n) a

Measured memory_bytes: 12652
#!/usr/bin/env python3
import bisect
import heapq
import itertools
import math
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from math import gcd
from operator import add, itemgetter, mul, xor
def cmb(n,r,mod):
  bunshi=1
  bunbo=1
  for i in range(r):
    bunbo = bunbo*(i+1)%mod
    bunshi = bunshi*(n-i)%mod
  return (bunshi*pow(bunbo,mod-2,mod))%mod
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def I(): return int(input())
def LI(): return list(map(int,input().split()))
def MI(): return map(int,input().split())
def LLI(n): return [list(map(int, input().split())) for _ in range(n)]
a,b,n = MI()
if n >= b:
  n = b-1
  print(math.floor(a*n/b)-a*math.floor(n/b))
else:
  print(math.floor(a*n/b)-a*math.floor(n/b))

Measured memory_bytes: 10064
#include<stdio.h>

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


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

int k, n, a, b, c;
ll t[1 << 17], d[1 << 17];

int main()
{
    cin >> n >> a >> b >> c;
    vector<int> v(n);
    int ans = a / c;
    for (int i = 0; i < n; i++)
    {
        cin >> v[i];
    }
    sort(v.rbegin(), v.rend());
    int sum = c;
    for (int i = 0; i < n; i++)
    {
        int m = a + b * (i + 1);
        sum += v[i];
        ans = max(ans, sum / m);
    }
    cout << ans << endl;
}



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

#include <fstream>

#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstdlib>
#include <tuple>
#include <queue>
#include <functional>
#include <stack>
#include <cassert>

using namespace std;

class atA {
public:
    void solve(istream& in, ostream& out) {
        int N;
        in >> N;
        vector<int> A(N);
        int oddcount = 0;
        for (int i = 0; i < N; ++i) {
            in >> A[i];
            oddcount += (A[i] % 2);
        }
        
        if (oddcount % 2 == 0) {
            out << "YES\n";
        } else {
            out << "NO\n";
        }
    }
};


int main() {
	std::ios::sync_with_stdio(false);

	atA solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
 
using namespace std;
#define int long long
const int MAX = 2001;
const int MOD = 1000000007;
 
 
 
  queue<pair<int,int>> que;
signed main(){
    int n,m;
    cin>>n>>m;
    vector<int> t[n];
    int u,v;
    for(int i=0;i<m;i++){
        cin>>u>>v;
        t[u-1].push_back(v-1);
    }
    int s0,t0;
    cin>>s0>>t0;s0--;t0--;
   
    que.push(make_pair(s0,0));
    int c[3][n];
    for(int j=0;j<3;j++)for(int i=0;i<n;i++)c[j][i]=-1;
    c[0][s0]=0;
    pair<int,int> s;
    while(!que.empty()){
        s=que.front();
        que.pop();
       
            for(int j=0;j<t[s.first].size();j++){
                if(c[(s.second+1)%3][t[s.first][j]]==-1){
                    c[(s.second+1)%3][t[s.first][j]]=(s.second+1)/3;
                    que.push(make_pair(t[s.first][j],s.second+1));
                }
            }
            if(c[0][t0]!=-1)break;
        
    }
  
    cout<<c[0][t0];
    return 0;
}

Measured memory_bytes: 8064
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using System.Runtime.CompilerServices;
using static MyUtil;

class MyUtil
{
    public static int[] ReadIntArray()
    {
	return ReadLine().Split().Select(x => int.Parse(x)).ToArray();
    }
}

class Program
{
    static int n;
    static int[] a;

    static int[,] dp;

    static int rec(int x, int turn)
    {
	if (dp[x, turn] > 0) return dp[x, turn];

	// 先手は先手勝ち、後手は後手勝ちをめざす
	int win = (turn == 0) ? 1 : 2;
	int lose = (turn == 0) ? 2 : 1;
	int nextTurn = (turn  + 1) & 1;
	
	int i = 0;
	while (i < n && a[i] <= x)
	{
	    if (rec(x - a[i], nextTurn) == win)
		return dp[x, turn] = win;
	    i++;
	}
	
	return dp[x, turn] = lose;
    }
    
    public static void Main()
    {
	var tmp = ReadIntArray();
	n = tmp[0]; int k = tmp[1];
	a = ReadIntArray();
	Array.Sort(a);

	// dp [残りの個数, 0: 先手番 / 1: 後手番]
	//    値: 0 未計算, 1: 先手の勝ち, 2: 後手の勝ち
	dp = new int[k+1, 2];

	WriteLine(rec(k, 0) == 1 ? "First" : "Second");
    }
}


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

int main(){ 
int A,B,C,D,K;
cin >> A>>B >> C >> D >> K ;
int X = (C * 60 + D) - (A * 60 + B) - K ;
if(X > 0){
  cout << X << endl;
}
else{
  cout << 0 << endl;
}

}


Measured memory_bytes: 3588
import java.util.Scanner;
public class Main
{
	public static void main(String arg[])
	{
		Scanner in=new Scanner(System.in);
		for(;;)
		{
			char ch[]=in.next().toCharArray();
			String ans="";
			String st=in.next();
			if(st.equals("X"))
				return;
			else if(st.equals("U"))
				for(int i=0;i<ch.length;i++)
				{
					if(ch[i]=='_')
					{
						ans+=(ch[i+1]+"").toUpperCase();
						i++;
					}
					else
					{
						String tmp=ch[i]+"";
						if(i==0)
							ans+=tmp.toUpperCase();
						else 
							ans+=tmp;
					}
				}
			else if(st.equals("L"))
				for(int i=0;i<ch.length;i++)
				{
					if(ch[i]=='_')
					{
						ans+=(ch[i+1]+"").toUpperCase();
						i++;
					}
					else
					{
						String tmp=ch[i]+"";
						if(i==0)
							ans+=tmp.toLowerCase();
						else 
							ans+=tmp;
					}
				}
			else if(st.equals("D"))
				for(int i=0;i<ch.length;i++)
				{
					if(i!=0&&Character.isUpperCase(ch[i]))
					{
						ans+="_";
						ans+=(ch[i]+"").toLowerCase();
					}
					else
						ans+=(ch[i]+"").toLowerCase();
				}
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 17404
#define _CRT_SECURE_NO_WARNINGS
using namespace std;
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <functional>
#include <set>
#include <queue>
#include <string>
#include <map>
#include <iomanip>
#include <sstream>
#include <cassert>


using namespace std;

int arr[100000];
long long MOD = 1000000007;

int main()
{
	long long N, K;
	cin >> N >> K;
	for (int i = 0; i < N; i++)
	{
		cin >> arr[i];
	}
	long long ans = 0;
	for (int i = 0; i < N; i++)
	{
		long long less_inv = 0, gre_inv = 0;
		for (int j = 0; j < N; j++)
		{
			if (j < i && arr[i] > arr[j])
				less_inv++;
			if (j > i && arr[i] > arr[j])
				gre_inv++;
		}
		ans += (less_inv * ((K * (K - 1) / 2) % MOD)) % MOD;
		ans %= MOD;
		ans += (gre_inv * ((K * (K + 1) / 2) % MOD)) % MOD;
		ans %= MOD;
	}
	cout << ans;
}

Measured memory_bytes: 256