akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
using namespace std;
int main(){
    int N; cin >> N;
    int L[N]; for(int i = 0; i < N; i++){ cin >> L[i]; }
    int max = L[0];
    int sum = 0;
    int flag = 0;
    for(int i = 1; i < N; i++){
        if( max < L[i]){
            max = L[i];
            sum += L[flag];
            flag = i;
        }else{
            sum += L[i];
        }
    }
    if(max < sum){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
#define ll long long
#define ld long double
//vector<pair>のソート、firstが昇順、secondが降順
bool mycomp(pair<string,ll> a, pair<string,ll> b){if(a.first != b.first){return a.first < b.first;} if(a.second != b.second){return a.second > b.second;}else{return true;}}

int main(){
  ll n; cin >> n;
  vector<pair<string,ll>> p(n);
  rep(i,n){
    string s; ll nt;
    cin >> s >> nt;
    p.at(i) = make_pair(s,nt);
  }
  vector<pair<string,ll>> tmp; //ソート前のインデックスを保持する必要があるため、tmpにコピーする
  tmp = p;
  
  sort(begin(tmp),end(tmp),mycomp);
  
  ll i = 0;
  for(auto v : tmp){
    auto itr = find(p.begin(),p.end(),tmp[i]);
    cout << distance(p.begin(),itr) + 1 << endl;
    i++;
  }
}

Measured memory_bytes: 3628
#include<iostream>
#include<algorithm>
#include<string>

using namespace std;

int main(){
	string s;
	cin >> s;
	for(int i=0;i<s.size();++i){
		for(int j=i+1;j<s.size();++j){
			if(s[i] == 'C' && s[j] == 'F'){
				cout << "Yes\n";
				return 0;
			}
		}
	}
	cout << "No\n";


	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
ll dx[4] = { 0, 1, 0, -1 };
ll dy[4] = { 1, 0, -1, 0 };
const ll INF = LLONG_MAX;
const ll MOD = 1e9 + 7;
const ll H_MAX = 2000000;

ll H, A[H_MAX + 2];

void maxHeapify(ll i)
{
    ll largest = i;
    ll l = 2 * i;
    ll r = 2 * i + 1;
    if (l <= H && A[l] > A[largest]) {
        largest = l;
    }
    if (r <= H && A[r] > A[largest]) {
        largest = r;
    }
    if (largest != i) {
        swap(A[i], A[largest]);
        maxHeapify(largest);
    }
}

void buildMaxHeap()
{
    for (ll i = H / 2; i >= 1; --i) {
        maxHeapify(i);
    }
}

ll extract()
{
    if (H < 1) {
        return -1;
    }
    ll maxv = A[1];
    A[1] = A[H--];
    maxHeapify(1);
    return maxv;
}

void insert(ll n)
{
    A[++H] = -1;
    if (n < A[H]) {
        return;
    } else {
        A[H] = n;
        ll i = H;
        while( i > 1 && A[i/2] < A[i]){
            swap(A[i / 2], A[i]);
            i /= 2;
        }
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    string com;
    H = 0;
    while (1) {
        cin >> com;
        if (com == "insert") {
            ll n;
            cin >> n;
            insert(n);
        } else if (com == "extract") {
            cout << extract() << endl;
        } else {
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 10804
if __name__ == '__main__':
    a, b, c, x, y = map(int, input().split())
    cost = 10 ** 10
    for z in range(0, max(x, y) + 1):
        rx = max(0, x - z)
        ry = max(0, y - z)
        cost = min(cost, rx * a + ry * b + z * 2 * c)
    print(cost)

Measured memory_bytes: 40176
#include <iostream>
#include <cstdlib>
#include <string>
using namespace std;

int main(){
  
  int N;
  cin >> N;
  string s;
  cin >> s;
  
  int rc = 0; int bc = 0;
  for(int i = 0; i < N; i++){
  
    if(s[i] == 'R'){
      rc++;
    }else{ 
      bc++;
    }
}
  if(rc > bc){
    cout << "Yes" <<endl;
  }else{
    cout << "No" << endl;
  }
 }


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

int main(){
    int n;
    cin >> n;
    int ans = 1000 - (n%1000);
    if(ans == 1000)ans =0;
    
    cout << ans <<endl;
    
}



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

int main()
{
  long long n, a, sum = 0;
  vector<int> v;

  cin >> n;

  for(int i = 0; i < n; i++){
    cin >> a;
    v.push_back(a);
    sum += v[i];
  }

  sort(v.begin(), v.end());

  cout << v[0] << " " << v[n - 1] << " " << sum << endl;

  return 0;

}

Measured memory_bytes: 3256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {
	
	public static void initSieve(int n, byte[] sieve) {
		for (int i = 2; i <= n; i++) {
	    	if (sieve[i] == 0) {
	    		sieve[i] = 1;
	    		for (int j = 2 * i; j < sieve.length; j += i) {
	    			sieve[j] = -1;
	    		}
	    	}
		}
	}
	
	public static boolean isPrime(int n, byte[] sieve) {
		if (n < 2) return false;
	    return sieve[n] == 1;
	}
	
	public static int solve(int n) {
		if (n < 1) return 0;
		
		byte[] sieve = new byte[2 * n + 1];
		initSieve(2 * n, sieve);
		int count = 0;
		for (int i = n + 1; i <= 2 * n; i++) {
	        if (isPrime(i, sieve)) {
	        	count++;
	        }
		}
		return count;
	}

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);
		String output = "";
		String line;
		while ((line = r.readLine()) != null) {
			int n = Integer.parseInt(line);
			if (n == 0) {
				break;
			} else {
				if (!output.equals("")) {
					output += "\n";
				}
				output += solve(n);
			}
		}
		System.out.println(output);
	}
	
}

Measured memory_bytes: 34904
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var input_array =input.trim().split("\n");
var numbers = input_array[1].split(' ').map((n) => Number(n));

var exchange_count = 0;



for (var i = 0; i < numbers.length; i++) {
  var min_index = i;
  for (var j = i; j < numbers.length; j++) {
    min_index = numbers[j] < numbers[min_index] ? j : min_index; 
  }
  if (min_index !== i) {
    var tmp = numbers[min_index];
    numbers[min_index] = numbers[i];
    numbers[i] = tmp;
    exchange_count++;
  }
}

console.log(numbers.join(' '));
console.log(exchange_count);


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

using namespace std;
using ll = long long;

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

int main() {
  string s;
  cin >> s;

  map<string, int> mp;
  mp["SUN"] = 7;
  mp["MON"] = 6;
  mp["TUE"] = 5;
  mp["WED"] = 4;
  mp["THU"] = 3;
  mp["FRI"] = 2;
  mp["SAT"] = 1;

  cout << mp[s] << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int ans = 0;
		for(int i = 1; i <= n; i++){
			int tmp = i;
			int cnt = 0;
			for(;tmp != 0;){
				tmp/=10;
				cnt++;
			}
			if(cnt%2==1){
				ans++;
			}
		}
		System.out.print(ans);
	}
}


Measured memory_bytes: 21844
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline

def gcd(x,y):
    r = x % y
    if r == 0:
        return y
    else:
        while r != 0:
            tmp = y % r
            y = r
            r = tmp
        return y

def main():
    a,b=map(int,input().split())
    print(gcd(a,b))

if __name__=="__main__":
    main()


Measured memory_bytes: 5608
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
/////////

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
//////////////

void solve() {
	int N;
	cin >> N;
	int NN = N;
	int ter = 0;
	
	while (N) {
		ter += (N % 10);
		N /= 10;
	}
	if (NN % ter == 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String args[]){
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        String S = scanner.next();
        
        int count = 1;
        char current = S.charAt(0);
        for(int i= 1; i<N; i++){
            if(current != S.charAt(i)){
                count++;
            }
            current = S.charAt(i);
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 24112
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    string str;
    while(cin>>str){
        if(str=="#")break;
        char pos='A';
        for(int i=0;i<str.size();i++){
            if(pos=='A'&&str[i]=='0')pos='X';
            else if(pos=='A'&&str[i]=='1')pos='Y';
            else if(pos=='X'&&str[i]=='0')break;
            else if(pos=='X'&&str[i]=='1')pos='Z';
            else if(pos=='Y'&&str[i]=='1')break;
            else if(pos=='Y'&&str[i]=='0')pos='X';
            else if(pos=='Z'&&str[i]=='1')pos='B';
            else if(pos=='Z'&&str[i]=='0')pos='W';
            else if(pos=='W'&&str[i]=='0')pos='B';
            else if(pos=='W'&&str[i]=='1')pos='Y';
            else if(pos=='B'&&str[i]=='0')pos='Y';
            else if(pos=='B'&&str[i]=='1')pos='X';
        }
        if(pos=='B')puts("Yes");
        else puts("No");
    }
    return 0;
}

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

int main(){
	int m;
	cin >> m;
	
	
	ll sum = 0;
	ll csum = 0;
	rep(i,m){
		ll d,c;
      cin >> d >> c;
		sum += d*c;
		csum += c;
	}
	
	cout << csum-1 + (sum-1)/9 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <string>
#include <iomanip>

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

using namespace std;

int main() {
  int N;
  string S;
  cin >> N >> S;

  set<char> X, Y;
  int result;

  for(int i=1; i<N-1; i++) {  //区切りにの位置
    int tmp = 0;
    X.clear();
    Y.clear();
    for(int j=0; j<i; j++) X.insert(S[j]);
    for(int k=i; k<N; k++) Y.insert(S[k]);
    for(auto x : X) if(Y.count(x)==1) tmp++;
    result = max(result, tmp);
  }

  cout << result << endl;

  return 0;
}

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

int main(){
    ll n,m; cin >> n >> m;
    ll ans;
    ans=(1900*m+100*(n-m))*pow(2,m);
    cout << ans << endl;
}

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

using namespace std;

#define rep(i , l , r) for(int i = (l) , ___ = (r) ; i <= ___ ; ++i )
#define per(i , r , l) for(int i = (r) , ___ = (l) ; i >= ___ ; --i )

typedef long long LL;

template<typename Type>
inline bool chkmin(Type &x , const Type &y) { return x > y ? (x = y , 1) : 0; }
template<typename Type>
inline bool chkmax(Type &x , const Type &y) { return x < y ? (x = y , 1) : 0; }

template<typename Type>
inline Type read(Type &f)
{
    f = 0; int x = 1 ; char c = getchar();
    while(!isdigit(c))
        x = (c == '-' ? -1 : 1) , c = getchar();
    while(isdigit(c))
        (f *= 10) += c & 15 , c = getchar();
    return f = x * f;
}

const int N = 4000 + 5 , KCZ = 924844033;

int n , k , S , vis[N];

LL Ans , f[N][N] , fac[N];

void add(LL &x , const LL &y) { x += y ; if(x >= KCZ) x -= KCZ; }
void sub(LL &x , const LL &y) { x -= y ; if(x < 0) x += KCZ; }

void init()
{
	fac[0] = 1;
	rep(i , 1 , 2000)
		fac[i] = fac[i - 1] * i % KCZ;
}

int main()
{
    read(n) , read(k) , init();
    rep(i , 1 , k)
    {
    	S += (n - i) / k + 1 , vis[S] = 1;
    	S += (n - i) / k + 1 , vis[S] = 1;
    }
    rep(i , 0 , S) f[i][0] = 1;
    rep(i , 2 , S) rep(j , 1 , n)
    {
    	add(f[i][j] , f[i - 1][j]);
    	if(!vis[i - 1]) add(f[i][j] , f[i - 2][j - 1]);
    }
    rep(i , 0 , n)
    {
    	LL v = f[S][i] * fac[n - i] % KCZ;
    	i & 1 ? sub(Ans , v) : add(Ans , v);
    }
    cout << Ans << endl;
    return 0;
}


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

int main() {
    double l;
    cin>>l;
    double v;
    v=l*l*l/(double)27;
    printf("%.10f\n",v);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mod 1000000007
#define f(i,a,b) for(ll i=a;i<b;i++)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ii pair<ll,ll>
#define vii vector<ii>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define MAX 1e9
 
ll modpow(ll base, ll exp, ll modulus) {base %= modulus;ll result = 1;while (exp > 0) {if (exp & 1) result = (result * base) % modulus;base = (base * base) % modulus;exp >>= 1;}return result;}
const ld pi=acos(-1);

int main(){
    IOS;
    ll n;cin>>n;
    map<ll,ll>m;
    ll a[n];
    f(i,0,n){cin>>a[i];m[a[i]]++;}
    ll tsum=0;
    for(auto x:m){
        if(x.S>1){
            tsum+=(x.S*(x.S-1))/2;
        }
    }
    f(i,0,n){
        ll x=m[a[i]];
        ll sum=tsum;
        sum-=(x*(x-1))/2;
        x--;
        sum+=(x*(x-1))/2;
        cout<<sum<<endl;
    }
    
    return 0;  
} 





Measured memory_bytes: 11136
//include
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath> 
#include <iomanip>
#include <math.h>
#include <utility>
#include <functional>
#include <cstdlib>
#include <map>
#include <utility>
//using
using namespace std;
using vl = vector <long long>;
using vs = vector <string>;
using vc = vector <char>;
using ll= long long;
using vvl = vector<vector<ll> >;
using vvc = vector<vector<char> >;
//vector<vector<char> > hyou(N, vector<char>(N));
using vd = vector <double>;
//define
//#define int long long
#define rep(i,n) for(int i=0; i<n; i++)
#define print(n) cout<<n<<endl;
#define sortp(d) sort(d.begin(),d.end()) //1234
#define sortm(d) sort(d.rbegin(),d.rend()) //4321
//素数判定　O(√A) 
bool is_prime(int x){
 if(x<=1) return false;
 for(int i=2;i*i<=x;i++)
 if(x%i==0) return false;
 return true;
 }
 //各位の和　
int wa(ll x)
{
ll sum = 0;
while(x!=0){
  sum += x% 10;
  x /= 10;
}
return sum;
}
/*順列生成
do {
  // 順列に対する処理
} while (next_permutation(配列変数.begin(), 配列変数.end()));*/

//絶対値　abs()
//文字→数字　'0' アルファベット→数字　'a'　'A'が65番,'a'が97番だわ
//型キャスト　char('a'+1)
//reverse 回文
//if(isupper('A'))->大なら真


//グローバル変数宣言
ll p=0,q=0,r=0;

int main()
{
  ll l,n;
  cin>>n>>l;
  vs s(n);
  string v;
  rep(i,n)cin>>s[i];
  sortp(s);
  rep(i,n)v+=s[i];
  print(v)
  
}

Measured memory_bytes: 3636
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String[] input = sc.nextLine().split("[\\s]+");
    int N = Integer.parseInt(input[0]);
    int K = Integer.parseInt(input[1]);
    String[] inputX = sc.nextLine().split("[\\s]+");
    int[] x = new int[N];
    for(int i = 0; i < N; i++) {
      x[i] = Integer.parseInt(inputX[i]);
    }
    int min = 0;
    for(int i = 0; i < N - K + 1; i++) {
      int sum1 = Math.abs(x[i]) + Math.abs(x[i] - x[i+K-1]);
      int sum2 = Math.abs(x[i+K-1]) + Math.abs(x[i+K-1] - x[i]);
      int sum = Math.min(sum1,sum2);
      if(i == 0 || sum < min) {
        min = sum;
      }
    }
    System.out.println(min);
  }
}

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

#define fr(i,n) _back
#define pb	push_back
#define eb	emplace_back
#define mk	make_pair
#define fi	first
#define se	second
#define endl	'\n'

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<ii> vii;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1.0);

int main() {
    ios_base::sync_with_stdio(false);
    int r; cin >> r;
    cout << fixed << setprecision(2) << (double)r*2*PI << endl;
    return 0;
}



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

using namespace std;

int main() {
    string s;
    cin >> s;
    bool flag = false;
    for (int i = 1; i < 4; ++i) {
        if (s[i - 1] == s[i]) flag = true;
    }
    if (!flag) cout << "Good" << endl;
    else cout << "Bad" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <iomanip>
#include <iostream>
using namespace std;
long n, a[210000], b[210000], c[210000], sum;
int main()
{
  cin >> n;
  for (int i = 0; i < n; i++)
  {
    cin >> a[i];
    b[a[i]]++;
  }
  for (int i = 1; i <= n; i++)
  {
    c[i] = b[i] * (b[i] - 1) / 2;
    sum += c[i];
  }
  for (int i = 1; i <= n; i++)
  {
    cout << sum - c[a[i - 1]] + ((b[a[i - 1]] - 1) * (b[a[i - 1]] - 2) / 2) << endl;
  }

  return 0;
}

Measured memory_bytes: 7040
#include <bits/stdc++.h>
using namespace std;
#pragma region WUF
struct WUF {			   // 重み付きUnion_Find木
	vector<int> par;	   // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
	vector<int> sz;		   // iを根とする木のサイズ
	vector<int> dist_par;  // 親までの距離

	WUF(int N) : par(N), sz(N), dist_par(N) {
		//最初は全てが根であるとして初期化
		for(int i = 0; i < N; i++) {
			par[i] = i;
			sz[i] = 1;
			dist_par[i] = 0;
		}
	}

	int root(int x) {  // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if(par[x] == x) return x;
		int rt = root(par[x]);	//ここではまだparを更新しない
		dist_par[x] += dist_par[par[x]];
		return par[x] = rt;
	}

	// 2つのデータx, yが属する木が同じならtrueを返す
	bool same(int x, int y) { return root(x) == root(y); }

	int distance(int x, int y) {  // xから見たyまでの距離
		assert(same(x, y));
		// errorの確認をしつつここでdist_par[x],dist_par[y]を根までの距離に変換している
		return dist_par[x] - dist_par[y];
	}

	bool unite(int x, int y, int dis) {	   // xとyの木を併合
		int rx = root(x);				   // xの根をrx
		int ry = root(y);				   // yの根をry
		if(rx == ry)					   // xとyの根が同じ(=同じ木にある)時はそのまま
			return distance(x, y) == dis;  //入力が矛盾しているならfalse
		par[rx] = ry;					   // xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
		sz[ry] += sz[rx];				   //サイズも併合
		sz[rx] = 0;						   //根じゃなくなったらサイズは0になる
		dist_par[rx] = dist_par[y] - dist_par[x] + dis;
		return true;
	}

	int size(int x) { return sz[root(x)]; }
};
#pragma endregion

int main() {
	// https://onlinejudge.u-aizu.ac.jp/courses/library/3/DSL/all/DSL_1_B
	int n, q;
	cin >> n >> q;
	WUF w(n);
	vector<int> ans;
	for(int i = 0; i < q; i++) {
		int c;
		cin >> c;
		if(c) {
			int x, y;
			cin >> x >> y;
			if(w.same(x, y)) {
				cout << (w.distance(x, y)) << "\n";
			} else {
				cout << "?\n";
			}
		} else {
			int x, y, z;
			cin >> x >> y >> z;
			if(!w.unite(x, y, z)) {
				cout << "error" << endl;
				return 0;
			}
		}
	}
}



Measured memory_bytes: 4356
r,c = map(int,input().split())
t = 0
A = [[]for i in range(r+1)]
for i in range(r):
	A[i]=list(map(int,input().split()))
for i in range(r):
	A[i].append(sum(A[i]))
for i in range(c+1):
	t=0
	for j in range(r):
		t += A[j][i]
	A[r].append(t)
for i in range(r+1):
	print(' '.join(map(str,A[i])))


Measured memory_bytes: 5708
while True:
    h,w=map(int,input().split())
    
    if h==0 and w==0:
        break
    
    for x in range(h):
        for y in range(w):
            if (x+y)%2==0:
                print("#",end="")
            else:
                print(".",end="")
        print()
    print()


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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;

const ll mod = 1e9+7;
const int maxn = 1e6 + 5;

ll divceil(ll x, ll y) {
    assert(y);
    return (x+y-1)/y;
}



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

    ll a,b,n;
    cin>>a>>b>>n;


    auto brute = [&]() {
	ll res = 0;
	for (ll x=0; x<=n; x++) {
	    ll cur = (a*x)/b - a*(x/b);
	    //cout<<x<<": "<<cur<<endl;
	    res=max(res,cur);
	}
	return res;
    };

    ll x = divceil(n,b)*b-1;
    while (x>n) x-=b;
    if (x<0) x=n;
    //watch(x);
    ll res = ((a*x)/b)-(a*(x/b));
    // watch(brute());
    // assert(res==brute());
    cout<<res<<endl;    
    return 0;
}


Measured memory_bytes: 3596
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n,d;

        n = sc.nextInt();
        d = sc.nextInt();

        int[][] x = new int[n][d];

        double ans = 0;
        int count = 0;

        for(int i=0;i<n;i++){
            for(int j=0;j<d;j++){
                x[i][j] = sc.nextInt();
            }
        }

        for(int i=0;i<n;i++){
            for(int k=i+1;k<n;k++){
                for(int j=0;j<d;j++){
                    if(i!=(n-1)) {
                        ans += Math.pow(Math.abs(x[i][j] - x[k][j]), 2);
                    }else {
                        ans += Math.pow(Math.abs(x[i][j] - x[0][j]), 2);
                    }
                }
                ans = Math.sqrt(ans);
            if(ans == (int)ans){
                count++;
            }
            ans = 0;
            }
        }

        System.out.println(count);
    }
}

Measured memory_bytes: 21844
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <stdio.h>
using namespace std;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;

vector<bool> eratosthenes(int n) {
	vector<bool> prime(n + 1);
	for (int i = 2; i <= n; i++) {
		prime[i] = true; // 初期化
	}
	prime[0] = prime[1] = false;
	for (int i = 2; i*i <= n;i++) {
		if (prime[i]) {
			for (int j = i * 2; j <= n; j += i) {
				prime[j] = false;
			}
		}
	}
	return prime;
}
int n, m,p[10], ans = 0,a[29], b[29];
const int nmax = 8;
bool graph[nmax][nmax];
/**
 * pos個は決定済み
 * mask 残に置く数の集合を表すビット配列
 */
void dfs(int pos, int mask) {
//	cout << "pos=" << pos << ",mask=" << mask << endl;
	if (pos == n) { // posが最後までいった
//		cout << p[0] << p[1] << p[2] << endl;
		return;
	}
	REP(i, n) {
		if (mask  & (1 << i)) { // 残の中にiが残っている場合
//			cout << "mask=" << mask << ",1<<" << i << "="  << (1 << i) << "=true" << endl;
			p[pos] = i; // 配列のPOS位置を0～nまでループ
			if (p[0] != 0)continue;
			if (pos > 0 && graph[p[pos - 1]][p[pos]] == false) {
				//				cout << "pos=" << pos << "," << p[0] << p[1] << p[2] << ",graph[" << p[pos - 1] << "][" << p[pos] << "]=false" << endl;
				continue;
			}
			dfs(pos + 1, (mask ^ (1 << i))); // 配列のPOS位置を進める,排他的論理和でフラグを下ろす
		}
		else {
//			cout << "mask=" << mask << ",1<<" << i << "=" << (1 << i) << "=false" << endl;
		}
	}
}
/*int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

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

	REP(i, m) {
		scanf("%d %d",&a[i], &b[i]);
		p[i] = i;
		graph[a[i] - 1][b[i] - 1] = graph[b[i] - 1][a[i] - 1] = true;
	}

	dfs(0, (1 << n) - 1);
	cout << ans << endl;
	return 0;
}*/
/**
 * v 現在の頂点
 */
int dfs(int v, int n, bool visited[]) {
	bool all_visited = true; // 全頂点を訪問済
	REP(i, n) {
		if(!visited[i])all_visited = false;
	}
	if (all_visited)return 1; //答を1増やす
	int ret = 0;
	REP(i, n) { //頂点i:頂点vに隣接、且つ、未訪問
		if (!graph[v][i])continue;
		if(visited[i])continue;

		visited[i] = true;
		ret += dfs(i, n, visited);
		visited[i] = false;
	}
	return ret;
}
int main() {
	scanf("%d %d", &n, &m);

	int A, B;
	for (int i = 0; i < m; ++i) {
		scanf("%d %d", &A, &B);
		graph[A - 1][B - 1] = graph[B - 1][A - 1] = true;
	}
	
	bool visited[nmax];
	for (int i = 0; i < n; ++i) {
		visited[i] = false;
	}
	
	visited[0] = true;
	cout << dfs(0, n, visited) << endl;
	return 0;

}


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

using namespace std;

typedef long long ll;

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

int main(void){
    string S;
    ll K;
    ll ans = 0;
    ll tans = 0;
    cin >> S;
    cin >> K;

    ll size = S.size();
  
    if (size == 1){
        cout << size * K/2 << endl;
        return 0;
    }
  
    ll ren = 0;
    vector<char> vec;
    rep(i,size) vec.emplace_back(S[i]);
    vec.emplace_back('0');
    bool rcan = false;
    ll fstren = 0,endren = 0;
    rep(i,size){
        if(vec[i] == vec[i+1]){
            fstren++;
        }else{
            fstren++;
            break;
        }
    }
    for(int i = size - 1;i > 1;i--){
        if(vec[i] == vec[i-1]){
            endren++;
        }else{
            endren++;
            break;
        }
    }
    rep(i,size){
        if(vec[i] == vec[i+1]){
            ren++;
            rcan = true;
        }else if(rcan){
            ren++;
            ans += ren / 2;
            if (ren == size || size == 1){
                 cout << size * K/2 << endl;
                 return 0;
                }
            if (i != size - 1)ren = 0;
            rcan = false;
        }
    }
    tans = ans;
    if (vec[0] == vec[size-1]){
        cout << tans + ans * (K - 1) - ( fstren/2 + endren/2 - (fstren+endren)/2  ) * (K-1)  << endl;
        return 0;
    }
    //cout << tans << endl;
    //rep(i,K-1) tans += ans;
    cout << tans + ans * (K - 1) << endl;
    return 0;
}


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

int main(){
  int n,x;
  cin >> n >> x;
  vector<int> L(n);
  for(int i=0;i<n;i++){
    cin >> L[i];
  }
  int sum=0,count=1;
  for(int i=0;i<n;i++){
    sum+=L[i];
    if(x>=sum){
      count++;
    }else{
      break;
    }
  }
  cout << count << endl;
}
    
  


Measured memory_bytes: 256
#include <bits/stdc++.h>  // ver1.9.4
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define pb push_back
#define mp make_pair
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define Vout(a) rep(i,0,a.size()-1)cout<<a[i]<<' ';cout<<a[a.size()-1]<<endl;
#define INF 9000000000000000000  //  9.0 * 10^18
#define MOD 1000000007  //  10^9 + 7
using namespace std;

int f(int n){int s=0;while(n!=0){s+=n%10;n/=10;}return s;}

signed main() {
  cout << fixed << setprecision(15);
  int a,b,c;
  cin >> a >>b>>c;
  if(c==0) {cout<<b<<endl;return 0;}
  int ans = 1;
  c--;
  if(b>=c){cout << ans+b+c<<endl; return 0;}
  ans += 2*b;
  c -= b;
  b = 0;
  ans += min(a,c);
  cout << ans << endl;
  return 0;
}


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

string s;
char c;

int main(){
	cin>>s;
	c=s[0]-32;
	cout<<c;
	
	cin>>s;
	c=s[0]-32;
	cout<<c;
	
	cin>>s;
	c=s[0]-32;
	cout<<c<<endl;
}


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

int N;
int A[100010];
long long ans = 1,mem = 1;

int main()
{
    scanf("%d",&N);
    for(int i = 0; i < N; i++)scanf("%d",A + i);

    for(int i = 0; i < N; i++)
    {
        ans *= 3;
        if(A[i] % 2 == 0)mem *= 2;
    }
    printf("%lld\n",ans - mem);
    return 0;
}


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

#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define lb(v,n) lower_bound(v.begin(),v.end(),n)
#define ub(v,n) upper_bound(v.begin(),v.end(),n)
#define mae(v) max_element(v.begin(),v.end())
#define mie(v) min_element(v.begin(),v.end())
#define INF 0x7FFFFFFF
#define mod 1000000007
#define fir first
#define sec second
typedef long long ll;
////////////////////////////////////////////////////////////

int main(){
	ll a,b,k;
	cin >> a >> b >> k;
	rep(i,0,k){
		if( i % 2 == 0 ){
			if( a%2 ) a--;
			b += a/2;
			a /= 2;
		}
		else{
			if( b%2 ) b--;
			a += b/2;
			b /= 2;
		}
	}
	cout << a << " " << b << endl;
	ret 0;
}

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


int main() {
  string s;
  cin>>s;
  reverse(s.begin(),s.end());
  int N=s.size();
  string s1="maerd";
  string s2="remaerd";
  string s3="esare";
  string s4="resare";
  int idx=0;
  bool flg=true;

  while(idx<N){
    if(idx+5>N){
      flg=false;
      break;
    }
    if(idx==N){
      flg=true;
      break;
    }
    string t1= s.substr(idx,5);
    string t2= s.substr(idx,7);
    string t3= s.substr(idx,5);
    string t4= s.substr(idx,6);

    if(t1==s1) idx+=5;
    else if(t2==s2) idx+=7;
    else if(t3==s3) idx+=5;
    else if(t4==s4) idx+=6;
    else{
      flg=false;
      break;
    }

  }

  if(flg) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;

}


Measured memory_bytes: 512
cnt=0
def merge(A,left,mid,right):
    global cnt
    n1=mid-left
    n2=right-mid
    L=A[left:mid]+[1000000000]
    R=A[mid:right]+[1000000000]

    i=0
    j=0
    for k in range(left,right):
        if L[i]<=R[j]:
            A[k]=L[i]
            cnt=cnt+1
            i+=1
        else:     
            A[k]=R[j]
            j+=1
            cnt=cnt+1

def mergeSort(A,left,right):
    if left+1< right:
        mid = int((left + right)/2)
        mergeSort(A, left, mid)
        mergeSort(A, mid, right)
        merge(A, left, mid, right)

n=int(input())
S=list(map(int,input().split()))
mergeSort(S,0,n)
print(' '.join(map(str,S)))

print(cnt)



Measured memory_bytes: 66760
#include<stdio.h>
#include<cctype>

int main(){
    char ch;
    int sum=0;
    while(true){
        while((ch = getchar()) != '\n'){
            sum += ch - '0';
        }
        if(sum == 0){
            break;
        } else {
            printf("%d\n",sum);
            sum = 0;
        }
    }
    return 0;
}


Measured memory_bytes: 2704
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<vector>
#define mp make_pair
#define pb push_back
using namespace std;

template<class T>inline void read(T &x) {
  x = 0;
  T tmp = 1;
  char c = getchar();
  while ((c < '0' || c > '9') && c != '-') c = getchar();
  if (c == '-') tmp = -1, c = getchar();
  while (c >= '0' && c <= '9')
    x = (x << 1) + (x << 3) + c - '0', c = getchar();
  x *= tmp;
}

long long n, m, d;

int main(void) {
  read(n), read(m), read(d);
  long long A = (n - d) * (m - 1);
  if (d) A <<= 1;
  long long B = n * n;
  double ans = (double)A / B;
  printf("%.10f\n", ans);

  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int dx[4] = { 0, -1, 1, 0 };
const int dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}

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

template<class T1, class T2> void chmax(T1 &a, T2 b) { if (a<b)a = b; }
template<class T>
void Add(T &a, const T &b, const T &mod = 1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}
////////////////////////////////////////
int main() {
	int H, W;
	cin >> H >> W;
	int a[510][510];
	vector<piii>ans;
	int key = 0;
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			int x; cin >> x;
			if (x % 2 == 0)a[i][j] = 0;
			else a[i][j] = 1;
		}
	}
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W-1; ++j) {
			if (a[i][j] > 0) {
				ans.push_back(piii(pii(i+1,j+1),pii(i+1,j+2)));
				if (a[i][j + 1] == 0)a[i][j + 1] = 1;
				else a[i][j + 1] = 0;
			}
		}
	}
	for (int i = 0; i < H - 1; ++i) {
		if (a[i][W - 1] % 2 == 1) {
			ans.push_back(piii(pii(i + 1, W), pii(i + 2, W)));
			if (a[i + 1][W - 1] == 1)a[i + 1][W - 1] = 0;
			else a[i + 1][W - 1] = 1;
		}
	}
	key = ans.size();
	cout << key << endl;
	for (int i = 0; i < ans.size(); ++i) {
		cout << ans[i].first.first << " " << ans[i].first.second << " " << ans[i].second.first << " " << ans[i].second.second << endl;
	}
	return 0;
}



Measured memory_bytes: 5232
def prime_factor(n):
    ass = []
    for i in range(2,int(n**0.5)+1):
        while n%i == 0:
            ass.append(i)
            n = n//i
    if n != 1:
        ass.append(n)
    return ass


n = int(input())

prime = []
for i in range(2, n+1):
    prime = prime + prime_factor(i)

from collections import Counter

primec = Counter(prime)

ans = 1

primec_list = primec.most_common()

mod = 10**9+7

for p in primec_list:
    ans = ans * (p[1]+1) % mod

print(ans)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define floop(i,a,n) for (int i=a;i<n;i++)
#define rfloop(i,a,n) for (int i=n-1;i>=a;i--)
#define mloop(it,x) for(it=x.begin();it!=x.end();it++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((ll)(x).size())
#define cases ll t; cin>>t; while(t--)
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long ll;
typedef unsigned long long int ull;
typedef vector<ll> vec;
typedef pair<ll,ll> pll;
typedef double db;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const ll mod=1000000007;
ll pm(ll x,ll n) {ll result=1; while(n>0){if(n%2==1) result=((result%mod)*(x%mod))%mod; x=((x%mod)*(x%mod))%mod; n/=2;} return result;}
ll p(ll x,ll n) {ll result=1; while(n>0){if(n%2==1) result=result*x; x=x*x; n/=2;} return result;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll ncr(ll n,ll r) { ll p=1,k=1; if(n-r<r) r=n-r; if(r!=0) {while(r!=0) {p*=n; k*=r; ll temp=gcd(p,k); p/=temp; k/=temp; n--; r--;} } else p=1; return p;}
ll factorial[300000+1];
void fact(ll n) { factorial[0]=1; factorial[1]=1; floop(i,2,n+1) factorial[i] = (i * factorial[i-1]%mod) % mod; }
ll d,coeff1,coeff2; 
void euclid(ll a, ll b) { if(b==0) { d=a; coeff1=1; coeff2=0; } else { euclid(b,a%b); ll temp=coeff1; coeff1=coeff2; coeff2=temp-(a/b)*(coeff2); } }
ll modinv(ll a) { euclid(a,mod); return (coeff1%mod+mod)%mod; }
int prime[1000001]={};
int spf[1000001]={};
void sieve(ll n)
{
	prime[0]=1;
	prime[1]=1;
	for(ll i=2;i*i<=n;i++)
	{
		if(prime[i]==0)
		{
			for(ll j=i*i;j<=n;j+=i)
			{
				prime[j]=1;	
				if(spf[j]==j)
				spf[j]=i;	
			}		
		}
	}
}
/*
vec s(300000,0);
vec si(300000,1);
ll root(ll a)
{
	while(s[a]!=a)
	a=s[a];
	return a;
}
void uni(ll a,ll b)
{
	ll r1=root(a);
	ll r2=root(b);
	if(si[r1]<si[r2])
	{
		s[r1]=s[r2];
		si[r2]+=si[r1];
	}
	else
	{
		s[r2]=s[r1];
		si[r1]+=si[r2];
	}
}
vector<vec > adj(300000);
vec vis(300000,0);
vec dist(300000,0);
void dfs(ll t,ll n)
{
	vis[t]=1;
	floop(i,0,sz(adj[t]))
	{
		if(vis[adj[t][i]]==0)
		{
			dist[adj[t][i]]=dist[t]+1;
			vis[adj[t][i]]=1;
		//	sum[adj[t][i]]=sum[t]+c[t][adj[t][i]];
			dfs(adj[t][i],n);
		}
	}
}*/
struct my_comp
{
	bool operator()(pair<ll,pll> p1, pair<ll,pll> p2)
	{
		if(p1.fi!=p2.fi)
		return p1.fi>p2.fi;
		return p1.se.fi<p2.se.fi;
	}
};
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);	
int main()
{
	ll n;
	cin>>n;
	vec d(n),e(n);
	floop(i,0,n)
	cin>>d[i]>>e[i];
	ll ans=0;
	floop(i,0,n-2)
	{
		if(d[i]==e[i] && d[i+1]==e[i+1] && d[i+2]==e[i+2])
		{
			ans=1;
			break;
		}
	}
	if(ans)
	cout<<"Yes\n";
	else
	cout<<"No\n";
	return 0;
}

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

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;
#define u_b upper_bound
#define l_b lower_bound

int V[55];

signed main() {
    int N;
    cin >> N;
    rep(i, N) {
        cin >> V[i];
    }
    sort(V, V + N);
    double prev = 1. * (V[0] + V[1]) / 2;
    for (int i = 2; i < N; ++i) {
        prev = (prev + V[i]) / 2;
    }
    cout << prev << endl;
    return 0;
}


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

typedef long long ll;
typedef pair<ll,ll> P;

const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;

#define rep(i, a, b) for(ll (i) = (a); (i) < (b);++i)

int main()
{
  ll A, B;
  cin >> A >> B;
  cout << (A-1) * (B-1) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int a,b,c,d,e,f,r;
	scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f);
	r=a+b*5+c*10+d*50+e*100+f*500;
	if(r>=1000){
		printf("1\n");
	}else{
		printf("0\n");
	}
	return 0;
}

Measured memory_bytes: 1816
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define str to_string
#define endl "\n"
#define PI 3.141592653589
using namespace std;
using lint = long long;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

int main(){
    int n,ans=1;cin>>n;
    int rem,check=-1,x;
    for(int i=0;i<n;i++){
        cin>>x;
        if(check==-1){rem=x;check=0;}
        else if(check==0){
            if(rem==x)continue;
            else if(rem>x){rem=x;check=-2;}
            else {rem=x;check=1;}
        }
        else if(check==-2){
            if(rem==x)continue;
            else if(rem>x){
                rem=x;
            }
            else {
                ans++;
                rem=x;
                check=0;
            }
        }
        else{
            if(rem==x)continue;
            else if(rem<x){
                rem=x;
            }
            else{
                ans++;
                rem=x;
                check=0;
            }
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int l,i,j,a[1000],t,n,A;
    double d=20000000,h,k;
    cin>>n>>t>>A;
   for(i=0;i<n;i++){
     cin>>a[i];
  }
   for(j=0;j<n;j++){
      h= t-a[j]*0.006;
       k =abs(A-h);
    if(d>k){d=k;l=j;}
    }
    cout<<l+1<<endl;
    

}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
long long sum;
int main()
{
	int n;
	scanf("%d",&n);
	sum=1;
	for(int i=1;i<=n;i++){
		sum=(sum%(1000000007))*i;
	}
	printf("%lld\n",sum%1000000007);
	return 0;
}

Measured memory_bytes: 128
N,M = gets.chomp.split(" ").map(&:to_i)
arr = readlines.map{|n| n.chomp.to_i}
# p arr

class Integer
    def combination(k)
      return 1 if k.zero?
  
      (self - k + 1..self).inject(:*) / k.factorial
    end
  
    def permutation(k)
      return 1 if k.zero?
  
      (self - k + 1..self).inject(:*)
    end
  
    def factorial
      return 1 if self.zero?
  
      (1..self).inject(:*)
    end
end

=begin
def step_sum(step)
    sum = 0
    return 1 if step == 0
    step.times do |i|
        one = i
        two = step - i
        break if step/2 > two
        sum += two.combination one
    end
    return sum
end
=end
def step_sum(step)
    # sum = 0
    # return 1 if step == 0
    pprev = 1
    prev = 2
    cur = 0
    return 1 if step == 0
    return 1 if step == 1
    return 2 if step == 2
    (step-2).times do |i|
        cur = pprev + prev
        pprev = prev
        prev = cur
    end
    return cur
end

prev = 0
ans = 1
arr << N+1
arr.each do |cur|
    if prev == cur
        ans = 0
        break
    end
    step = cur-1-prev
    
    ans*=step_sum(step)
    # p [step, ans]
    prev = cur+1
end

puts ans % 1000000007

Measured memory_bytes: 37556
#pragma region
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define all(x) x.begin(),x.end()
#pragma endregion

string s;
string can;
char sw(int pos, char answer)
{
	if (can[pos] == 'S')
	{
		if (answer == 'o')return can[pos - 1];
		else
		{
			if (can[pos - 1] == 'S')return 'W';
			else return 'S';
		}
	}
	else
	{
		if (answer == 'o')
		{
			if (can[pos - 1] == 'S')return 'W';
			else return 'S';
		}
		else return can[pos - 1];
	}
}

int main()
{
	int n; cin >> n;
	cin >> s;
	s = "v" + s + "v";
	can = "SS";
	for (int i = 1; i <= n; ++i)
	{
		can += sw(i, s[i]);
	}
	if (can[0] == can[n] && can[1] == can[n + 1])
	{
		cout << can.substr(1, n) << endl;
		return 0;
	}
	can = "WS";
	for (int i = 1; i <= n; ++i)
	{
		can += sw(i, s[i]);
	}
	if (can[0] == can[n] && can[1] == can[n + 1])
	{
		cout << can.substr(1, n) << endl;
		return 0;
	}
	can = "SW";
	for (int i = 1; i <= n; ++i)
	{
		can += sw(i, s[i]);
	}
	if (can[0] == can[n] && can[1] == can[n + 1])
	{
		cout << can.substr(1, n) << endl;
		return 0;
	}
	can = "WW";
	for (int i = 1; i <= n; ++i)
	{
		can += sw(i, s[i]);
	}
	if (can[0] == can[n] && can[1] == can[n + 1])
	{
		cout << can.substr(1, n) << endl;
		return 0;
	}
	cout << -1 << endl;
}

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

const int N = 8010;
const int M = 210;
const int mod = 998244353;

typedef long long LL;

inline int Pow(int x, int y) {
    int res = 1;
    for (; y; y >>= 1, x = (LL)x * x % mod) if (y & 1) res = (LL)res * x % mod;
    return res;
}

int frac[N], inv[N];

inline int C(int n, int r) {
    return (LL)frac[n] * inv[r] % mod * inv[n - r] % mod;
}

int dp[M][N];

int r[N << 2], A[N << 2], B[N << 2];

inline void NTT(int a[], int len, int type) {
    for (int i = 1; i < len; i++) if (i < r[i]) swap(a[i], a[r[i]]);
    for (int mid = 2; mid <= len; mid <<= 1) {
        int Wn = Pow(3, type ? (mod - 1) / mid : mod - 1 - (mod - 1) / mid);
        for (int i = 0; i < len; i += mid)
            for (int j = i, w = 1, t; j < i + (mid >> 1); j++, w = (LL)w * Wn % mod)
                t = (LL)a[j + (mid >> 1)] * w % mod, a[j + (mid >> 1)] = (a[j] - t + mod) % mod, a[j] = (a[j] + t) % mod;
    }
    if (!type) for (int i = 0, inv = Pow(len, mod - 2); i < len; i++)
        a[i] = (LL)a[i] * inv % mod;
}

int main() {
    int n, m; cin >> n >> m;
    frac[0] = inv[0] = 1;
    for (int i = 1; i <= n + 2; i++) 
        frac[i] = (LL)frac[i - 1] * i % mod, inv[i] = Pow(frac[i], mod - 2);
    int len = 1, l = 0;
    while (len <= n * 2) len <<= 1, l++;
    for (int i = 1; i < len; i++) r[i] = (r[i >> 1] >> 1) | ((i & 1) << l - 1);
    dp[0][0] = 1;
    for (int i = 1; i <= n; i++) B[i] = inv[i + 2];
    NTT(B, len, 1);
    for (int i = 1; i <= m; i++) {
        for (int j = 0; j < len; j++) A[j] = 0;
        for (int j = 0; j <= n; j++) A[j] = (LL)dp[i - 1][j] * inv[j] % mod;
        NTT(A, len, 1);
        for (int j = 0; j < len; j++) A[j] = (LL)A[j] * B[j] % mod;
        NTT(A, len, 0);
        for (int j = 0; j <= n; j++) 
            dp[i][j] = ((LL)frac[j + 2] * A[j] + (LL)dp[i - 1][j] * (1 + C(j + 1, 2))) % mod;
    }
    int res = 0;
    for (int i = 0; i <= n; i++) res = (res + (LL)dp[m][i] * C(n, i)) % mod;
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 6784
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
#define mod 1000000007
#define pi 3.141592653589793
typedef vector<int> vi;
typedef vector<ll> vl;
ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll g=gcd(a,b);
    return a/g*b;
}
ll rep_jijo(ll n,ll x){
    if(x==0) return 1;
    if(x%2==0){
        ll t=rep_jijo(n,x/2);
        return t*t%mod;
    }
    return n*rep_jijo(n,x-1)%mod;
}
ll com(ll n,ll r){
    ll x=1,y=1;
    ll tmp=n;
    while(tmp>=n-r+1){
        x=x*tmp%mod;
        tmp--;
    }
    while(r>0){
        y=y*r%mod;
        r--;
    }
    return x*rep_jijo(y,mod-2)%mod;
}


int main (){
    int a[5];
    int b[5];
    int r=inf;
    int ans=0;
    int num;
    rep(i,5){
        int x;
        cin >> x;
        a[i]=x;
        int y=x%10;
        b[i]=y;
        if(y==0) continue;
        if(y<=r){
            r=y;
            num=i;
        }
    }
    if(r==inf){
        rep(i,5) ans+=a[i];
        cout << ans << endl;
        return 0;
    }
    rep(i,5){
        if(i==num) ans+=a[i];
        else{
            if(b[i]!=0)ans+=a[i]+10-b[i];
            else ans+=a[i];
        }
    }
    cout << ans <<endl;
    return 0;
}


Measured memory_bytes: 256
///
// File:  1285.cpp
// Author: ymiyamoto
//
// Created on Tue Nov 21 21:45:11 2017
//

#include <algorithm>
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <vector>

using namespace std;

int32_t main()
{
  while (true) {
    uint32_t n, w;
    cin >> n >> w;
    if (n == 0 && w == 0) break;
    uint32_t num = 100 / w;
    vector<uint32_t> counts(num + 1, 0);

    uint32_t max_count = 0;
    uint32_t max_index = 0;
    for (uint32_t i = 0; i < n; i++) {
      uint32_t val;
      cin >> val;
      for (uint32_t j = 0; j < counts.size(); j++) {
        if (j * w <= val && val < j * w + w) {
          counts[j]++;
          max_count = max(max_count, counts[j]);
          max_index = max(max_index, j);
          break;
        }
      }
    }

    double ink = 0.01;
    for (uint32_t i = 0; i < counts.size(); i++) {
      ink += (double)counts[i] / (double)max_count * (double)(max_index - i) / (double)max_index;
    }
    cout << fixed << setprecision(8) << ink << endl;
  }

  return 0;
}

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

#define debug(x) cout << #x << " = " << x << endl
#define fori(i, ini, lim) for(int i = int(ini); i < int(lim); i++)
#define ford(i, ini, lim) for(int i = int(ini); i >= int(lim); i--)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;

const int MAX = 2e3 + 5;
int arr[MAX];
int n, k, q;

int main() {
	scanf("%d %d %d", &n, &k, &q);
	
	fori(i, 1, n + 1) {
		scanf("%d", arr + i);
	}

	int ans = (int) 2e9;
	fori(i, 1, n + 1) {
		int now = arr[i];

		vector<int> all, cur;
		fori(j, 1, n + 2) {
			if(j == n + 1 || arr[j] < now) {
				sort(cur.begin(), cur.end());
				int sz = cur.size();
				fori(f, 0, sz - k + 1) {
					all.push_back(cur[f]);
				}
				cur.clear();
			}
			else {
				cur.push_back(arr[j]);
			}
		}

		sort(all.begin(), all.end());

		if((int) all.size() >= q) {
			ans = min(ans, all[q - 1] - now);
		}
	}

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

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <unordered_map>
#include <algorithm>
using namespace std;
int main()
{
  int N, M;
  cin >> N;
  unordered_map <string, int> cards;
  for (int i = 0; i < N; i++) {
    string s;
    cin >> s;
    cards[s]++;
  }
  cin >> M;
  for (int i = 0; i < M; i++) {
    string t;
    cin >> t;
    cards[t]--;
  }
  int ans = 0;
	for (unordered_map <string, int>::iterator it = cards.begin(); it != cards.end(); it++) {
		ans = max(ans, it->second);
	}
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3640