akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

ll solve() {
    ll H1, M1, H2, M2, K;
    cin >> H1 >> M1 >> H2 >> M2 >> K;
    ll x = (H2-H1)*60+M2-M1-K;
    if ( x < 0 ) x = 0;
    return x;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define deb(a) cout << a << ": "
using namespace std;
const int inf = 1e18 + 7;
const int N = 1e6 + 7;
const int md = 1e9 + 7;
void sliczny() {
    int ans = 0;
    int l, r, d;
    cin >> l >> r >> d;
    for(int i=l; i<=r; i++) {
        if(i % d == 0) ans++;
    }
    cout << ans;
}

int32_t main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int T = 1;
  //cin >> T; 
    for(int t = 1; t <= T; t++) {
    //cout << "Case #" << t << ": ";
        sliczny();
    }
  return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<ll,ll>P;

P p[200000];
signed main(){
	ll n,h;cin>>n>>h;
	vector<ll>v;
	rep(i,n){
		scanf("%lld%lld",&p[i].first,&p[i].second);
		v.push_back(p[i].first);
		v.push_back(p[i].second);
	}
	sort(v.begin(),v.end(),greater<>());
	sort(p,p+n,[](P a,P b){return a.first>b.first;});
	rep(i,v.size()){
		if(v[i]==p[0].first){
			v.erase(v.begin()+i);
			break;
		}
	}
	ll cnt=0;
	ll Min=(h+p[0].first-1)/p[0].first;
	rep(i,v.size()){
		cnt+=v[i];
		if(cnt>=h)Min=min(Min,(ll)i+1);
		else Min=min(Min,(h-cnt+p[0].first-1)/p[0].first+i+1);
	}
	cout<<Min<<endl;
}

Measured memory_bytes: 3444
#include <iostream>
#include <algorithm>
#include <climits>
using namespace std;

int N, M, X;
int C[20];
int A[20][20];


int cost = INT_MAX;

bool canGoal(int bit){

    //init
    int knowledge[20];
    for (int i = 1; i <= M; i++) {
        knowledge[i] = 0;
    }

    //calc
    for(int i = 0; i < N; i++){
        if (!(bit & (1<<i))) continue;
        for (int j = 1; j <= M ; j++) {
            knowledge[j] +=A[i+1][j];
        }
    }

    //judge
    for (int i = 1; i <= M; i++) {
      	if(knowledge[i]<X) return false;
    }
    return true;
}

int calCost(int bit){
    int tmpCost = 0;
    //calc
    for(int i = 0; i < N; i++){
        if (!(bit & (1<<i))) continue;

        tmpCost += C[i+1];
    } 
    return min(cost, tmpCost);
}



int main() {
    cin >> N >> M >> X;
    for (int i = 1; i <= N ; i++) {
        cin >> C[i];
        for (int j = 1; j <= M; j++) {
            cin >> A[i][j];
        }
    }

    for(int bit = 1; bit < (1<<N); bit++){
        if( canGoal(bit) ){
            cost = calCost(bit);
        }
    }
    if (cost == INT_MAX){
        cout << -1 << endl;
    } else {
        cout << cost << endl;
    }
    return 0;
}


Measured memory_bytes: 3600
#56 ABC136E
n,k=map(int,input().split())
a=list(map(int,input().split()))
s=sum(a)

res=[]
for d in range(1,int(s**0.5)+1):
	if s%d==0:
		res.append(d)
		res.append(s//d)
ans=[]
for d in res:
	r1=[t%d for t in a]
	r1.sort()
	r2=[(d-t)%d for t in r1]
	r2=r2[::-1]
	x=[r1[0]]
	_=[x.append(x[-1]+r1[i]) for i in range(1,n)]
	y=[r2[0]]
	_=[y.append(y[-1]+r2[i]) for i in range(1,n)]
	#print(r1,r2,d,x,y)
	for i in range(n-1):
		#print(x[i],y[-i-2])
		if x[i]==y[-i-2] and x[i]<=k:
			ans.append(d)
			break
print(max(ans))

Measured memory_bytes: 3188
#include <bits/stdc++.h>
  
#define FOR(i,a,b) for( ll i = (a); i < (ll)(b); i++ )
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort( (x).begin(),(x).end() )
#define REVERSE(x) reverse( (x).begin(),(x).end() )
#define UNIQUE(x) (x).erase( unique( ALL( (x) ) ) , (x).end() )
#define PW(x) (1LL<<(x))
#define SZ(x) ((ll)(x).size())
#define SHOW(x) cout << #x << " = " << x << endl
 
#define pb emplace_back
#define fi first
#define se second

using namespace std;
 
typedef long double ld;
typedef long long int ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<vpl> gr;
typedef vector<vl> ml;
typedef vector<vd> md;
typedef vector<vi> mi;
 
const ll INF = (ll)1e9 + 10;
const ll INFLL = (ll)1e18 + 10;
const ld EPS = 1e-8;
const ll MOD = 1e9+7;

template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }
template<class T> inline T sq( T a ){ return a * a; }
ll in(){ ll x; scanf( "%lld" , &x ); return x; }
 
// head

vi v;

int main(){

  v.pb( in() );
  v.pb( in() );
  v.pb( in() );
  SORT( v );
  if( v == vi({5,5,7}) ) puts( "YES" );
  else puts( "NO" );
  
  return 0;
}


Measured memory_bytes: 256
S = int(input())

if S == 1 or S ==2:
  print(0)
  
elif S == 3:
  print(1)
  
else:
  
  #初期化
  dp = [0]*S
  dp[2] = 1
  dp_S = 0
  
  #dp
  for i in range(3,S):
    dp_S += dp[i-3] 
    dp[i] = 1+dp_S

  print(dp[S-1]%1000000007)

Measured memory_bytes: 9192
#include <iostream>
#include <iomanip>

using namespace std;

double dp[3000][3000];


int main(){
    int N;
    cin >> N;
    double p[3000];
    for(int i = 0; i < N; i++){
        cin >> p[i];
    }
    dp[0][0] = 1-p[0];
    dp[0][1] = p[0];
    for(int i = 1; i < N;i++){
        dp[i][0] = dp[i-1][0]*(1-p[i]);
        for(int j = 1; j <= i; j++){
            dp[i][j] = dp[i-1][j]*(1-p[i])+dp[i-1][j-1]*p[i];
        }
        dp[i][i+1] = dp[i-1][i]*p[i];
    }
    double ans = 0;
    for(int i = N; (i+1)*2 > N+1; i--){
        ans += dp[N-1][i];
        //cout << i+1 << endl;
    }
    cout  << std::setprecision(10) << ans << endl;
}

Measured memory_bytes: 68864
#include<bits/stdc++.h>
#define ll long long 
#define hell 1000000007 
#define F first
#define re 15000000
#define S second
#define pb push_back
#define all(a)  (a).begin(),(a).end()
#define rep(i,a,b) for(ll int i = a;i<b;i++)
#define pi 3.1415926536
#define Mod 998244353
using namespace std;
int main()
{
	int n,m;
	cin>>n>>m;
	vector<ll> v(n);
	for(int i=0;i<n;i++)
		cin>>v[i];
	sort(all(v));
	vector<pair<ll,ll> > q(m);
	for(int i = 0;i<m;i++)
	{
		cin>>q[i].S>>q[i].F;
	}
	sort(all(q));
	reverse(all(q));
	int curr = 0;
	for(int i = 0;i<q.size();i++)
	{
		int x = q[i].S;
		while(curr < n && x)
		{
			if(v[curr] < q[i].F)
			{
				v[curr] = q[i].F;
				x--;
			}
			else
				break;
			curr++;
		}
	}
	ll sum = 0;
	for(int i = 0;i<n;i++)
	{
		sum = sum+v[i];
	}
	cout<<sum;
}

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

using namespace std;
#define ll long long int
const int MAXN = 2 * 1e5 + 5;

void solve(){
    string s; cin >> s;
    int q; cin >> q;
    bool rev = false;
    string front = "";
    string back = "";
    while( q-- ){
        int x; cin >> x;
        if( x == 1){
            if( rev ) rev = false;
            else rev = true;
        } else {
            int y;
            char z;
            cin >> y >> z;
            if(!rev){
                if(y == 1) front += z;
                else back += z;
            } else {
                if( y == 1) back += z;
                else front += z;
            }
        }
    }
    
    if( !rev ){
        reverse(front.begin(), front.end());
        cout << front + s + back << '\n';
    } else {
        reverse(s.begin(), s.end());
        reverse(back.begin(), back.end());
        cout << back + s + front << '\n';
    }
}

int main(){
    ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr); 
	//int t; cin >> t;
	//while(t--)
		solve();
}







Measured memory_bytes: 1300
mod io{
    use std::io::*;
    pub fn read<T: ::std::str::FromStr>()->T{
        let stdin=stdin();
        let ret=stdin.lock().bytes().map(|c|c.unwrap()as char)
        .skip_while(|c|c.is_whitespace())
        .take_while(|c|!c.is_whitespace())
        .collect::<String>().parse().ok().unwrap();
        ret
    }
}
use io::read;
fn main(){
    let n=read::<usize>();
    let s=read::<String>().chars().collect::<Vec<char>>();
    let mut a=0;
    let mut t=0;
    for i in 0..n{
        if s[i]=='I'{t+=1}
        else if s[i]=='D'{t-=1}
        if a<t{a=t}
    }
    println!("{}",a)
}


Measured memory_bytes: 4352
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;

// kmp をやるための前計算
vector<int> makeTable(const vector<int>& s) {
    int n = s.size();
    vector<int> ret(n+1);
    ret[0] = -1;
    int j = -1;
    for (int i = 0; i < n; i++) {
        while (j >= 0 && s[i] != s[j]) j = ret[j];
        ret[i+1] = ++j;
    }
    return ret;
}

// str の中に word とマッチする場所のリストを返す
// ret のそれぞれの要素 el は, 「str[el] からの文字列が word と一致する」ことを示す
vector<int> kmp(const vector<int>& str, const vector<int>& word) {
    vector<int> table = makeTable(word), ret;
    int m = 0, i = 0, n = str.size();
    while (m+i < n) {
        if (word[i] == str[m+i]) {
            if (++i == (int)(word.size())) {
                ret.push_back(m);
                m = m+i-table[i];
                i = table[i];
            }
        } else {
            m = m+i-table[i];
            if (i > 0) i = table[i];
        }
    }
    return ret;
}

int n,a[400010],b[200010];
vector<int> A,B;
string t1,t2;

void solve(){
    cin >> n;
    rep(i,n){
        cin >> a[i];
        a[i+n]=a[i];
    }
    rep(i,n){
        cin >> b[i];
    }
    rep(i,2*n-2){
        A.push_back(a[i+1]^a[i]);
        //cout << A[i] << endl;
    }
    rep(i,n-1){
        B.push_back(b[i+1]^b[i]);
        //cout << B[i] << endl;
    }
    vector<int> ks=kmp(A,B);
    for(int k:ks){
        cout << k << " " << (a[k]^b[0]) << endl;
    }
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(50);
    solve();
}

Measured memory_bytes: 10864
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
#define fi0 for(ll i=0;i<n;i++)
void solve()
{
}
void abc(){
 int i, j, k;
    int n,m;
    int x,y;

    cin>>n;

    ll cnt=0;
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=n;j++)
        {
            x=i^j;

            if(x<=n && x>0)
            {
                k=0;
                if(i+j<=x)
                    k++;
                else if(i+x<=j)
                    k++;
                else if(x+j<=i)
                    k++;

                if(k<=0)
                    cnt++;
            }
        }
    }

    cout<<cnt/6;
}
void bcd(){
    string s,ss;
    cin>>s>>ss;
    int sum=0,n=s.size(),nn=ss.size();
    for(int i=0;i<=n-nn;i++){
            int a=0;
        for(int j=i;j<i+nn;j++){
            if(s[j]==ss[j-i]){
                a++;
            }
           /// cout<<s[j]<<ss[j]<<' ';

        }
        sum=max(a,sum);
       /// cout<<sum<<endl;
    }
    cout<<ss.size()-sum<<endl;
}
int main()
{
   ///int t;cin>>t;while(t--){
  ///  solve();}
    bcd();
    return 0;
}


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

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

  for(int i=0; i<s.size(); i++){
    if(k == 0){
      break;
    }else if(i == s.size()-1){
      s[i] = 'a' + (((s[i] - 'a') + k) + 26) % 26;
      k = 0;
      break;
    }else if(s[i] != 'a' && 26 - (s[i] - 'a') <= k){
      k -= (26 - (s[i] - 'a'));
      s[i] = 'a';
    }
  }

  cout << s << endl;

  return 0;
}


Measured memory_bytes: 512
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	static int chocoAmount;

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int N = s.nextInt();
		int X = s.nextInt();

		int[] race = new int[N];
		int donuts = 0;
		int result = 0;

		for (int i = 0; i < N; i++) {
			race[i] = s.nextInt();
			donuts += race[i];
		}
		int rest = X - donuts;
		Arrays.sort(race);

		if (race[0]<rest) {
			result = rest / race[0];
			System.out.println(result + N);
		} else {
			System.out.println(N);
		}
	}
}

Measured memory_bytes: 23636
#include<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= end; --i)
#define iter(i, c) for (auto i = (c).begin(); i != (c).end(); ++i)
#define riter(i, c) for (auto i = (c).rbegin(); i != (c).rend(); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    if (N % 2 == 0) {
        cout << N / 2 - 1 << endl;
    }
    else {
        cout << N / 2 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
using System;

class Program
{
    static void Main(string[] args) {
        int x = int.Parse(Console.ReadLine());
        Console.WriteLine(solve(x));
    }
    static long solve(int x) {
        long ans = 1;
        for(int i = 2; i <= 1000; i ++) {
            long tmp = i;
            for(int j = 2; j <= 1000; j ++) {
                tmp = tmp * i;
                if(tmp > x) break;
                ans = Math.Max(ans, tmp);
            }
        }
        return ans;
    }
}

Measured memory_bytes: 11092
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
    // Your code here!
    int N;
    cin >> N;
    vector<string> S(N);
    for(int i=0;i<N;i++) cin >> S.at(i);
    sort(S.begin(), S.end());
    S.erase(unique(S.begin(), S.end()), S.end());
    cout << S.size() << endl;
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] % 2 == 1) cnt++;
  }
  cout << (cnt % 2 == 0 ? "YES" : "NO") << endl;
  return 0;
}

Measured memory_bytes: 3776
#include <bits/stdc++.h>
#define ALL(A) (A).begin(),(A).end()
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)

const ll mod = 1e9+7;
const ll INF = -1*((1LL<<63)+1) - 1e9*300-1;
const int inf = -1*((1<<31)+1);

using namespace std;

ll A[303][303];
int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	vector<vector<bool>> A_n(N,vector<bool>(N));
	rep(i,N)rep(j,N){
		cin >> A[i][j];
	}
	rep(k,N)rep(i,N)rep(j,N){
		if(A[i][j] > A[i][k] + A[k][j]){
			cout << -1 << endl;
			return 0;
		}
		if(A[i][j] == A[i][k] + A[k][j] && k!=i &&k!=j){
			A_n[i][j] = true;//辺(i,j)と(j,i)は使わなくてok
		}
	}
	ll ans = 0;
	for(int i=0; i<N; i++){
		for(int j=0; j<N; j++){
			if(A_n[i][j] == false){
				ans += A[i][j];
			}
		}
	}
	cout << ans/2LL << endl;
	
}

Measured memory_bytes: 1024
// Sky's the limit :)
#include <bits/stdc++.h>
using namespace std;
#define int long long

const int mod = 998244353;

int power(int x, int y) {
    int res = 1;
    while(y) {
        if(y & 1) 
            res = res * x % mod;
        x = x * x % mod;
        y >>= 1;
    }
    return res;
}

signed main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    int T = 1; 
    // cin >> T; 
    while (T--) {
        int n, s; 
        cin >> n >> s;
        int a[n];
        for(int i = 0; i < n; i++)
            cin >> a[i];

        int dp[n + 5][s + 5];
        memset(dp, 0, sizeof(dp));
        dp[0][0] = power(2, n);
        int inv = power(2, mod - 2);
        for(int i = 0; i < n; i++) {
            for(int j = 0; j <= s; j++) {
                dp[i + 1][j] = (dp[i + 1][j] + dp[i][j]) % mod;
                if (j + a[i] <= s) 
                    dp[i + 1][j + a[i]] = (dp[i + 1][j + a[i]] + dp[i][j] * inv) % mod;
            }
        }
     
        cout << dp[n][s] << '\n';
        
    }
    
    return 0;
}



Measured memory_bytes: 74176
#include <bits/stdc++.h>
using namespace std;
 
const double PI=3.14159265358979323846;

int main(){
  cout << fixed << setprecision(10);
  double a, b, x; cin >> a >> b >> x;
  
  if(x <= a*a*b/2){
    
    double dig = atan2(2*x, (a*b*b)) * 180 / PI;
    cout << 90 - dig << endl;
  
  }else{
    
    double c = a*a*b - x;
    double dig = atan2(a, 2*c/(a*a)) * 180 / PI;
    cout << 90 - dig <<endl;
    
  }
  

}

Measured memory_bytes: 256
# coding: utf-8
from math import ceil
N,A,B,C,D = map(int,input().split())   #N A B C D
if ceil(N/A)*B > ceil(N/C)*D:
    print(ceil(N/C)*D)
elif ceil(N/C)*D > ceil(N/A)*B :
    print(ceil(N/A)*B)
else:
    print(ceil(N/A)*B)


Measured memory_bytes: 5668
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define showmap(is, js, x) {rep(i, is){rep(j, js){cout << x[i][j] << " ";}cout << endl;}}
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> llP;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}


int main()
{
    int n;
    cin >> n;
    int one = n%10;

    if (one == 0 || one == 1 || one == 6 || one == 8){
        cout << "pon" << endl;
    } else if (one == 3){
        cout << "bon" << endl;
    } else {
        cout << "hon" << endl;
    }


}

Measured memory_bytes: 3636
#include <iostream>
#include <iomanip>
/*cout <<setprecision(11)<<ret<<endl;で、数字部分を計11桁表示*/
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
//Shift+Command+bでデバッグ
//その後ターミナルで./a.outを実行
//入力を貼り付ける

//////////////////
//  A
int main(void){
    int a,p;cin >>a >>p;
    cout<<(a*3+p)/2<<endl;
    
    return 0;
}
//////////////////
//  B
/*int main(void){

    return 0;
}*/
//////////////////
//  C
/*int main(void){

    return 0;
}*/
//////////////////
//  D
/*int main(void){

    return 0;
}*/
//////////////////
//  E
/*int main(void){

    return 0;
}*/
//////////////////
//  F
/*int main(void){

    return 0;
}*/


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int main()
{
	ll N, M;
	cin >> N >> M;
	vector<ll> A(N);
	vector<ll> B(M);
	for (auto i = 0; i < N; ++i)
	{
		cin >> A[i];
	}
	for (auto i = 0; i < M; ++i)
	{
		cin >> B[i];
	}

	auto mod = (ll)1e9 + 7;

	sort(A.begin(), A.end());
	sort(B.begin(), B.end());

	bool valid = true;
	for (auto i = 1; i < N; ++i)
	{
		if (A[i] == A[i - 1])
		{
			valid = false;
		}
	}
	for (auto i = 1; i < M; ++i)
	{
		if (B[i] == B[i - 1])
		{
			valid = false;
		}
	}

	auto ans = 1ll;
	auto count = 0ll;
	if (valid)
	{
		auto c = 0ll;
		auto r = 0ll;
		while (r < N && c < M)
		{
			auto flag = false;
			if (A[r] > B[c])
			{
				flag = true;
			}

			auto same = false;
			if (A[r] == B[c])
			{
				same = true;
			}

			if (same)
			{
				auto num = (N - r) + (M - c) - 2;
				for (auto i = 0; i < num; ++i)
				{
					auto temp = A[r] - 1;
					temp = max(0ll, temp - count);
					ans = ans * temp % mod;
					++count;
				}
				++r;
				++c;
				++count;
			}
			else if (flag)
			{
				auto num = N - r;
				for (auto i = 0; i < num - 1; ++i)
				{
					auto temp = B[c] - 1;
					temp = max(0ll, temp - count);
					ans = ans * temp % mod;
					++count;
				}
				ans = ans * num % mod;
				++c;
				++count;
			}
			else
			{
				auto num = M - c;
				for (auto i = 0; i < num - 1; ++i)
				{
					auto temp = A[r] - 1;
					temp = max(0ll, temp - count);
					ans = ans * temp % mod;
					++count;
				}
				ans = ans * num % mod;
				++r;
				++count;
			}
		}
		
	}
	else
	{
		ans = 0;
	}

	cout << ans << endl;

	return 0;
}

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

long long int m = 1000000007;

int main() {
    int r, c;
    cin>>r>>c;
    char grid[r+1][c+1];
    long long int dp[r+1][c+1];
    for(int i = 0; i < r; i++){
        for(int j = 0; j < c; j++){
            cin>>grid[i][j];
        }
    }
    for(int i = 0; i <= r; i++){
        for(int j = 0; j <= c; j++){
            if(i==0 || j==0){
                dp[i][j] = 0;
                continue;
            }
            if(i == 1 && j==1){
                dp[i][j] = 1;
            }
            else{
                if(grid[i-1][j-1] == '#'){
                    dp[i][j] = 0;
                }
                else{
                    dp[i][j] = ((dp[i-1][j] % m) + (dp[i][j-1] % m))%m;
                }
            }
        }
    }
    cout<<dp[r][c]<<endl;
}

Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007

int main() {
	int N;
	string S;
	cin >> N;
	vector<int> C(1000, 0), D(1000, 512411);
	for (int i = 0;i < N;i++) {
		cin >> S;
		for (char c : S) {
			C[c]++;
		}
		for (int j = 0;j < 1000;j++) {
			D[j] = min(D[j], C[j]);
			C[j] = 0;
		}
	}
	for (int i = 0;i < 1000;i++) {
		char c = i;
		for (int j = 0;j < D[i];j++) {
			cout << c;
		}
	}
	cout << endl;
}

Measured memory_bytes: 256
M, D = map(int, input().split())

ans = 0

for m in range(1, M+1):
    for d in range(1, D+1):
        if d <= 21:
            pass
        else:
            d1, d10 = int(list(str(d))[1]), int(list(str(d))[0])
            if m == d1 * d10 and d1 > 1:
                ans += 1
                #print(m, d)
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <algorithm>
#include <cmath>
#include <iterator>
#include <numeric>
#include <iomanip>
#define FI first
#define SE second
#define EB emplace_back
#define MP make_pair
#define REP(i, n) for (ll i = 0; i < n; i++)
#define INF 1100000000
#define LLINF 1100000000000000000LL
#define Decimal fixed << setprecision(20)
#define ALL(c) c.begin(),c.end()
#define SHOWVEC(v, sz) for(int i = 0; i < sz; i++) cerr << v[i] << ' '; cerr << endl;
#define SHOWX(x) cerr << #x << ": " << x << endl;
#define SHOWP(p) cerr << "[" << p.first << ',' << p.second << "]";

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

int main()
{
  int A1, A2, A3;
  cin >> A1 >> A2 >> A3;
  if (A1 + A2 + A3 >= 22) cout << "bust" << endl;
  else cout << "win" << endl;
  return 0;
}


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

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define vecpairll vector<pair<long long,long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)

template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "<" << #__VA_ARGS__ << ">:", debug_out(__VA_ARGS__)
#define INF LLONG_MAX


// Run Length Encoding
vector<ll> countVector(vector<ll>v,ll guard=-1){
  ll size=v.size();
  v.push_back(guard);
  vector<ll>ret;
  ll count=1;
  for(int i=0;i<size;i++){
	if(v[i]==v[i+1]){
	  count++;
	}else{
	  ret.push_back(count);
	  count=1;
	}
  }
  return ret;
}


int main()
{
  string s;
  char b = 'R';
  cin >> s;
  vecll ans(s.size(), 0);
  vecll s_(s.size(), 0);
  vecll count;
  
  forll(i, 0, s.size()){
	if (s[i] == 'R') s_[i] = 0;
	else s_[i] = 1;
  }

  count = countVector(s_);

  ll b_i = 0;
  bool r = true;
  ll cum_i = 0;
  forll(i, 0, count.size()){
	if (r){
	  cum_i += count[i];
	  ans[cum_i - 1] += count[i] / 2 + count[i] % 2;
	  ans[cum_i] += count[i] / 2;
	  b_i = cum_i;
	  r = false;
	}else{
	  r = true;
	  ans[cum_i - 1] += count[i] / 2;
	  ans[cum_i] += count[i] / 2 + count[i] % 2;
	  cum_i += count[i];
	}
  }

  forll(i, 0, s.size())
	cout << ans[i] << ' ';
}


Measured memory_bytes: 4592
import copy

a, b, c = map(int, input().split())
if a == b == c and a%2 == 0 and b%2 == 0 and c%2 == 0:
    print(-1)
else:
    cnt = 0
    while True:
        if a % 2 != 0 or b % 2 != 0 or c % 2 != 0:
            print(cnt)
            break
        else:
            cnt += 1
            tmp_a = (b+c)//2
            tmp_b = (a+c)//2
            tmp_c = (a+b)//2
        a = copy.copy(tmp_a)
        b = copy.copy(tmp_b)
        c = copy.copy(tmp_c)

Measured memory_bytes: 3572
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var AB = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var A = AB[0];
            var B = AB[1];

            var output = Math.Max(A, B) + (A > B ? Math.Max(A - 1, B) : Math.Max(A, B - 1));

            Console.Write(output);
        }
    }
}


Measured memory_bytes: 11348
#include <bits/stdc++.h>
using namespace std;
typedef long long lol;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(lol i=0;i<lol(n);i++)
#define REPD(i,n) for(lol i=n-1;i>=0;i--)
#define FOR(i,a,b) for(lol i=a;i<=lol(b);i++)
#define FORD(i,a,b) for(lol i=a;i>=lol(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) lol(x.size()) //sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//最大値最小値
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int f(int, int, int);

int main()
{
    lol result{0};
    lol n; cin >> n;
    vector<int> a(10000);
    //int k; cin >> k;
    FOR(x, 1, 100)
    {
        FOR(y, 1, 100)
        {
            FOR(z, 1, 100)
            {
                int fn = f(x, y, z);
                if(fn > 10000)
                    break;
                a[fn]++;
            }
        }
    }

    FOR(i, 1, n)
        cout << a[i] << endl;
    return 0;
}

int f(int x, int y, int z)
{
    return x*x + y*y + z*z + x*y + y*z + z*x;
}

Measured memory_bytes: 3624
#include <iostream>

using namespace std;

bool f2(char c) {
    if (c == 'A') {
        return true;
    }
    if (c == 'C') {
        return true;
    }
    if (c == 'G') {
        return true;
    }
    if (c == 'T') {
        return true;
    }
    return false;
}

int f(string s) {
    int count = 0;
    int max = 0;
    for (int i = 0; i < s.size(); i++) {
        if (f2(s[i])) {
            count++;
            if (max < count) {
                max = count;
            }
        } else {
            count = 0;
        }
    }
    return max;
}

int main() {

    string s;
    cin >> s;

    int result = f(s);
    cout << result << endl;

    return 0;
}


Measured memory_bytes: 256
def main():
    a,b = map(int,input().split())
    if a<=0 and 0<=b:
        print("Zero")
    else:
        if 0<a:
            print("Positive")

        else:
            if (b-a)%2==0:
                print("Negative")
            else:
                print("Positive")
if __name__=='__main__':
    main()

Measured memory_bytes: 38256
#include <algorithm>
#include <bitset>
#include <boost/multiprecision/cpp_int.hpp>
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstring>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <set>
#include <numeric>
#include <sstream>
#include <stdio.h>
#include <string>
#include <tuple>
#include <vector>
#include<iomanip>
namespace mp = boost::multiprecision;
using namespace std;
using ull = unsigned long long;
using ld = long double;
using lll = boost::multiprecision::cpp_int;
using ll = long long;
#define FOR(i, N) for(ll i = 0; i < N; ++i)

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
// using int = ll;
ll gcd(ll m, ll n) {
    if(n == 0)
        return abs(m);
    return (gcd(n, m % n));
}
void putYN(bool b) {
    if(b) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}
template<typename T>
void swap(T &a, T &b) {
    T tmp = a;
    a = b;
    b = tmp;
}
ll combi(ll n, ll k) {
    ll r = 1, rr = 1;
    for(ll i = 0; i < k; ++i) {
        r *= (n - i);
        rr *= (i + 1);
        // r %= 1000000007;
        // rr %= 1000000007;
    }
    r /= rr;
    // r %= 1000000007;
    return r;
}

int main() {
  ll T1,T2,A1,A2,B1,B2;
  cin>>T1>>T2>>A1>>A2>>B1>>B2;
  lll l1_1,l1_2;
  lll l2_1,l2_2;
  l1_1=T1*A1;
  l1_2=T2*A2;
  l2_1=T1*B1;
  l2_2=T2*B2;
  if(l1_1<l2_1){
    swap(l1_1,l2_1);
    swap(l1_2,l2_2);
  }
  if(l1_1+l1_2>l2_1+l2_2){
    cout<<0<<endl;
  	return 0;
  }
  if(l1_1+l1_2==l2_1+l2_2){
    cout<<"infinity"<<endl;
  	return 0;
  }
  lll ans =((l1_1-l2_1)/(-(l1_1+l1_2)+(l2_1+l2_2)))*2+1;
  if(((l1_1-l2_1)%(-(l1_1+l1_2)+(l2_1+l2_2)))==0)ans--;
  //cout<<l1_1+l1_2<<endl;
  //cout<<(l2_1+l2_2)<<endl;
  //cout<<l1_1+l1_2-(l2_1+l2_2)<<endl;
  //cout<<l1_1-l2_1<<endl;
  cout<<ans<<endl;
  return 0;
}


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

int main()
{
  int a, b; cin >> a >> b;
  if(a == 1) a = 14;
  if(b == 1) b = 14;
  if(a < b) cout << "Bob";
  else if(a == b) cout << "Draw";
  else cout <<"Alice";
  return 0;
}

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

int main() {
  
  int N, A, x, y;
  cin >> N;
  y = 1000;
  
  for (int i = 0; i < N; i++){
    cin >> A;
    
    while (A % 2 == 0){
      A /= 2;
      x++;
    }
    if(x < y)y = x;
    x = 0;
  }
  cout << y << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 3010
using namespace std;
typedef signed long long ll;

ll p;
ll a[N], c1[N], c2[N], c3[N], ret[N];

ll powmod(ll x) {
    ll y = 1;
    ll n = p - 2;
    while (n) {
        if (n % 2 == 1) {
            y = y * x % p;
        }
        x = x * x % p;
        n >>= 1;
    }
    return y;
}

int main() {
    cin >> p;
    for (auto i = 0; i < p; i++) {
        cin >> a[i];
    }
    
    c1[0] = 1;
    for (auto i = 0; i < p; i++) {        
        c2[0] = (-i*c1[0]%p+p)%p;
        for (auto j = 1; j <= i + 1; j++) {
            c2[j] = (c1[j-1]-i*c1[j]%p+p)%p;
        }
                
        swap(c1, c2);
    }
    
    for (auto i = 0; i < p; i++) {
        if (a[i] == 0) {
            continue;
        }
        
        ll q = 1;
        for (auto j = 0; j < p; j++) {
            if (j != i) {
                q = q*(i-j)%p;
            }
        }
        
        q = powmod((q%p+p)%p)%p;
        memset(c3, 0, sizeof(c3));
        for (auto j = p-1; j >= 0; j--) {
            c3[j] = ((c3[j+1]*i+c1[j+1])%p+p)%p;
            ret[j] = (ret[j]+c3[j]*q)%p;
        }
    }
    
    for (auto i = 0; i < p; i++) {
        cout << ret[i] << " ";
    }
    
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;

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

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

 ll k;
  cin >> k;
  vll a(k);
  rep(i,0,k) cin >> a[i];

 ll l=2,r=2;
  
  rep(i,0,k){
   l=((l-1)/a[k-1-i]+1)*a[k-1-i];
   r=r/a[k-1-i]*a[k-1-i]+a[k-1-i]-1;
    bool flag=false;
     rep(j,0,r-l+1) if((l+j)%a[k-1-i]==0) {
       flag=true;
       break;
     }
    if(!flag) {
      cout << -1 << endl; 
      return 0;
    }
  }
  cout << l << " " << r <<endl;
  
}

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


int main()
{
	std::string c;
	std::cin >> c;
	if (c == "A") { std::cout << "T" << std::endl; }
	else if (c == "T") { std::cout << "A" << std::endl; }
	else if (c == "C") { std::cout << "G" << std::endl; }
	else { std::cout << "C" << std::endl; }

	return 0;
}

Measured memory_bytes: 256
protocol InitFromString {
    init?(_ str: String)
}

extension Int: InitFromString {}
extension Int8: InitFromString {}
extension Int16: InitFromString {}
extension Int32: InitFromString {}
extension Int64: InitFromString {}
extension String: InitFromString {}

func input<T: InitFromString>() -> [T] {
    readLine()!.split(separator: " ").map(String.init).compactMap(T.init)
}

let nk: [Int] = input()
let n = nk[0]
let k = nk[1]

let mod = 1000_000_000 + 7

let result = (k...(n+1)).reduce(0, { res, i in
    let max = sum((n-i+1)...n)
    let min = sum(0...(i - 1))
    return (res + max - min + 1) % mod
})

print(result == 0 ? 1 : result % mod)

func sum(_ arr: ClosedRange<Int>) -> Int {
    return (arr.first! + arr.last!) * arr.count / 2
}


Measured memory_bytes: 7916
#include<iostream>
using namespace std;
int main()
{
    string arr[]={"SUN","MON","TUE","WED","THU","FRI","SAT"};
    string s;
    cin>>s;
    for(int i=0;i<7;i++){
        if(arr[i]==s){
            printf("%d\n",7-i);
        }
    }
    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 ll long long
#define pp pair<ll,ll>
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=998244353;
int inf=1000001000;
ll INF=1e18+5;
ll mod=INF;

int main() {
    ld a,b;
    cin >> a >> b;
    ld e=a*b;
    ll u=e;
    cout << u << endl;
}


Measured memory_bytes: 3756
#include <iostream>

using namespace std;

int main(){
  int N, D, X, count = 0;
  int A[100];
  cin >> N >> D >> X;
  for(int i = 0; i < N; ++i){
    cin >> A[i];
    count += (D-1) / A[i] + 1;
  }
  cout << count + X << endl;
  return 0;
}

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

int main() {
    using namespace std;
    constexpr unsigned long MOD = 1000000007;
    unsigned long N, K;
    cin >> N >> K;
    vector<unsigned long> A;
    A.reserve(N);
    copy_n(istream_iterator<unsigned long>(cin), N, back_inserter(A));
    unsigned long M{*max_element(A.begin(), A.end())};
    vector<unsigned long> cnt(M);
    unsigned long inv{0};
    for(const auto& i : A)++cnt[i - 1];
    for(unsigned long i = 1; i < N; ++i)for(unsigned long j = 0; j < i; ++j)if(A[i] < A[j])++inv;
    vector<unsigned long> acnt(M);
    unsigned long ans{0};
    auto merge_inversion = [&M, &MOD](vector<unsigned long>& tocnt, unsigned long& toinv, vector<unsigned long>& srccnt, unsigned long srcinv){
        vector<unsigned long> retcnt(M);
        unsigned long retinv = toinv + srcinv;
        for(unsigned long i = 0; i < M; ++i)(retcnt[i] = tocnt[i] + srccnt[i]) %= MOD;
        for(unsigned long i = 1; i < M; ++i)for(unsigned long j = 0; j < i; ++j)(retinv += tocnt[i] * srccnt[j]) %= MOD;
        copy(retcnt.begin(), retcnt.end(), tocnt.begin());
        toinv = retinv % MOD;
    };
    while(K){
        if(K & 1)merge_inversion(acnt, ans, cnt, inv);
        merge_inversion(cnt, inv, cnt, inv);
        K >>= 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<string.h>
using namespace std;
#define inf 9000000
int main()
{
    int n;
    cin>>n;
    int res1,res2;
    int ans,sum=0,ans2=0;
    int a[105];
    int minn=inf;
    for(int i=0;i<n;i++)
        {cin>>a[i];}
        for(int i=-100;i<=100;i++)
        {
            ans=0;
            for(int j=0;j<n;j++)
             ans+=(a[j]-i)*(a[j]-i);
             minn=min(minn,ans);
        }
        cout<<minn<<endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
  string str;
  cin >> str;
  for(int i = 0; i < str.size()-1; i++) {
    if(str.at(i) != str.at(i+1)) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
"""
kari1 = '3 3'
in1 = kari1.split()
mylist = []
mylist.append('dxx')
mylist.append('axx')
mylist.append('cxx')
"""
in1 = input().split()
mylist = []
for num in range(int(in1[0])):
    mylist.append(input())

mylist.sort()

print(''.join(mylist))


Measured memory_bytes: 3316
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>

namespace adaptor = boost::adaptors;

void solve()
{
    int64_t M1, M2, D1, D2;
	std::cin >> M1 >> D1;
	std::cin >> M2 >> D2;

	if (M2 == M1) {
		std::cout << "0" << std::endl;
	} else {
		std::cout << "1" << std::endl;
	}
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	solve();
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<string>
#include<cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <utility> 

using namespace std;

int main()
{
	while (1)
 { 
	int n, k;
	k = 0;
	vector<int> A;
	cin >> n;
	if (n==0)
	{
		break;
	}
	for (int i = 0; i < n; i++)
	{
		int a;
		cin >> a;
		A.push_back(a);
	}
	for (int j = 0; j < n;j++)
	{
		for (int i = 0; i < n-1; i++)
		{
			if (A[i]>A[i + 1])
			{
				swap(A[i], A[i + 1]);
				k++;
			}
		}
	}
	cout << k << endl;
 }
	return 0;
}

Measured memory_bytes: 1216
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
using namespace std;

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

    vector<int> x(n);
    vector<int> y(n);
    for(int i = 0; i < n; ++i)
    {
        int tx,ty;
        cin >> tx >> ty;
        x[i] = tx;
        y[i] = ty;
    }

    double sum = 0;
    for(int i = 0; i < n; ++i)
    {
        for(int j = 0; j < n; ++j)
        {
            double x1 = x[i];
            double y1 = y[i];
            double x2 = x[j];
            double y2 = y[j];
            double dist = sqrt(pow(x1-x2,2) + pow(y1-y2,2));
            sum += dist;
        }
    }

    int n1 = 1;
    for(int i = 1; i <= n-1; ++i)
    {
        n1 *= i;
    }
    int n2 = 1;
    for(int i = 1; i <= n; ++i)
    {
        n2 *= i;
    }
    cout << fixed << setprecision(7) << n1 * sum / n2 << endl;
}

Measured memory_bytes: 256
#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 fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
#define pi 3.141592653589793

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    ld a,b,h,m;
    cin>>a>>b>>h>>m;
    ld mx,my,hx,hy;
    if((m>=0)&&(m<15)){
        ld radm=m/30*pi;
        mx=b*sin(radm);
        my=b*cos(radm);
    }
    else if((m>=15)&&(m<30)){
        ld radm=(m-15)/30*pi;
        mx=b*cos(radm);
        my=-b*sin(radm);
    }
    else if((m>=30)&&(m<45)){
        ld radm=(m-30)/30*pi;
        mx=-b*sin(radm);
        my=-b*cos(radm);
    }
    else if((m>=45)&&(m<60)){
        ld radm=(m-45)/30*pi;
        mx=-b*cos(radm);
        my=b*sin(radm);
    }
    ld hm=h*60+m;
    if((h>=0)&&(h<3)){
        ld radh=hm/360*pi;
        hx=a*sin(radh);
        hy=a*cos(radh);
    }
    else if((h>=3)&&(h<6)){
        ld radh=(hm-180)/360*pi;
        hx=a*cos(radh);
        hy=-a*sin(radh);
    }
    else if((h>=6)&&(h<9)){
        ld radh=(hm-360)/360*pi;
        hx=-a*sin(radh);
        hy=-a*cos(radh);
    }
    else if((h>=9)&&(h<12)){
        ld radh=(hm-540)/360*pi;
        hx=-a*cos(radh);
        hy=a*sin(radh);
    }
    ld d=sqrt((hx-mx)*(hx-mx)+(hy-my)*(hy-my));
    cout << setprecision(12) << d<< endl;
    
}


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

#define mp make_pair
#define pb push_back
#define f first
#define s second 
#define sz(s) (int)s.size()
#define all(s) s.begin(), s.end()
#define forn(i, x, y) for(int i = x; i <= y; i++)
#define forev(i, y, x) for(int i = y; i >= x; i--)

using namespace std;

const int maxn = (int)3e5 + 100;
const int mod = (int)1e9 + 7;
const int P = (int)1e6 + 7;
const int inf = (int)1e9 + 7;

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef long double ld;

int n, a[maxn];
main () {
  cin >> n;
  forn(i, 1, n) cin >> a[i];
  do{
    int bad = 0;
    a[n + 1] = a[1];
    a[0] = a[n];
    forn(i, 1, n){
      bad ^= a[i];
    }
    if(!bad){
      cout << "Yes";
      return 0;
    }
    break;
  }while(next_permutation(a + 1, a + n + 1));
  cout << "No";
}

Measured memory_bytes: 640
N, C, K = map(int, input().split())
T = [int(input()) for _ in range(N)]

T.sort()

ret = 1
cnt = 1
pre = T[0]
for i in range(1, N) :
  if cnt == C or T[i] > pre + K :
    ret += 1
    cnt = 1
    pre = T[i]
  
  else :
    cnt += 1
  
print(ret)

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

import sys

n, m, p = map(int, sys.stdin.readline().split())
mat_a = list()
mat_b = list()

for i in range(n):
    mat_a.append(list(map(int, sys.stdin.readline().split())))

for i in range(m):
    mat_b.append(list(map(int, sys.stdin.readline().split())))

mat_c = [[0 for i in range(p)] for k in range(n)]

for row in range(n):
    for col in range(p):
        for k in range(m):
            mat_c[row][col] += mat_a[row][k]*mat_b[k][col]
    str_x = list(map(str, mat_c[row]))
    print(' '.join(str_x))



Measured memory_bytes: 6916
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define pb push_back
#define N 200001
#define ll long long
#define int ll 
#define pi pair<int , int>
#define pip pair<pair ,int>
#define mp make_pair 
#define f first
#define s second
#define mod 998244353
ll Mod(ll x, ll y, int p) 
{ll res = 1; x = x % p;
while (y > 0) 
{if(y & 1) res = (res*x) % p; 
y = y>>1;x = (x*x) % p; 
}return res; 
}
int* getlps(string pattern){
 int len = pattern.length();
 int * lps = new int[len];
 lps[0] = 0;
 int i = 1 , j = 0;
 while(i < len){
  if(pattern[i] == pattern[j]){
	  lps[i] = j+1;
   i++;
   j++;
  }
  else{
		if(j != 0){
		 j = lps[j-1];
		}
		else{
		 lps[i] = 0;
		 i++;
		}
  }
 }
 return lps;
}
class Triplet{
 public:
 int x ;
 int y ;
 int gcd;
};
Triplet extendedEuclid(int a , int b){
 if(b == 0){Triplet ans; ans.gcd = a;ans.x = 1;ans.y = 0;return ans;}
 Triplet smallAns = extendedEuclid(b , a%b);
 Triplet ans;
 ans.gcd = smallAns.gcd;
 ans.x = smallAns.y;
 ans.y = smallAns.x - (a/b)*smallAns.y;
 return ans;
}
int mmInverse(int a , int m){
 Triplet ans = extendedEuclid(a , m);
 return ans.x;
}
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin>>n;
cout<<(n+1)/2<<endl;
}



Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static int MOD = 1000000007;
	static int[] mh4 = { 0, -1, 1, 0 };
	static int[] mw4 = { -1, 0, 0, 1 };

	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int n = in.nextInt();
			int[] a = new int[n], b = new int[n];
			for (int i = 0; i < n; i++) {
				int ai = in.nextInt(), bi = in.nextInt();
				a[i] = ai; b[i] = bi;
			}

			long sum = 0;
			for (int i = n-1; i >= 0; i--) {
				if ((a[i]+sum) % b[i] != 0) {
					sum += b[i] - ((a[i]+sum) % b[i]);
				}
			}

			out.println(sum);
		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}

}


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

#define MAX_N 110
char s[MAX_N];

int main(){
	//freopen("in.txt", "r", stdin);
	while(~scanf("%s", &s)){
		for(int i = 0; s[i]; ++i) {
			if(s[i] == '1') putchar('9');
			else if(s[i] == '9') putchar('1');
			else putchar(s[i]);
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstring> //memset
using namespace std;


int main()
{
	long N;

	cin >> N;

	double sum = 0.0;

	for (long long iN = 0; iN < N; iN++) {
		double value;

		cin >> value;

		sum += 1.0 / value;
	}

	double result = 1.0 / sum;

	cout << result << endl;
}


//int main()
//{
//	long a;
//	string s;
//
//	cin >> a >> s;
//
//	if (a >= 3200) {
//		cout << s << endl;
//	}
//	else {
//		cout << "red" << endl;
//	}
//
//}


Measured memory_bytes: 256