akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#define REP(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long LL;

int main() {
  int N, M, A[300][300];
  cin >> N >> M;
  REP(i, N) {
    REP(j, M) {
      int _A;
      cin >> _A;
      A[i][j] = _A - 1;
    }
  }
  bool hold[300];
  REP(i, M) {
    hold[i] = true;
  }
  
  int ret = 999;
  while(true) {
    int participant[300] = {};
    REP(i, N) {
      int tsp = -1;
      REP(j, M) {
        if(hold[A[i][j]]) {
          tsp = A[i][j];
          break;
        }
      }
      participant[tsp]++;
    };
    int maxp = *max_element(participant, participant + M);
    if(maxp < ret) {
      ret = maxp;
    }
    REP(i, M) {
      if(participant[i] == maxp) {
        hold[i] = false;
      }
    }
    int flag = false;
    REP(i, M) {
      if(hold[i]) {
        flag = true;
        break;
      }
    }
    if(!flag) {
      break;
    }
  }
  cout << ret << endl;
}

Measured memory_bytes: 640
#include<stdio.h>
#define ll long long
int main()
{
	ll n;
	ll x;
	int ans = 0;
	scanf("%lld",&n);
	for(ll i = 1; i * i <= n; i++)
	{
		if(!(n % i))  x = n / i;
	}
	while(x > 0)
	{
		ans ++;
		x /= 10;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
from sys import stdin
n, k = map(int, stdin.readline().rstrip().split())
a = [format(int(x), 'b')[::-1] for x in stdin.readline().rstrip().split()]

d = [0] * 64
maxlen = 0
for c in a:
    len_ = len(c)
    if len_ > maxlen:
        maxlen = len_
    for j in range(len(c)):
        if c[j] == '1':
            d[j] += 1

m = format(k, 'b')[::-1]
if len(m) >= maxlen:
    maxlen = len(m)
else:
    m = m + '0' * (maxlen - len(m))

flag = False
result = 0
for j in range(maxlen - 1, -1, -1):
    if d[j] >= n - d[j]:
        result = result * 2 + d[j]
        if m[j] == '1':
            flag = True
    else:
        if flag or m[j] == '1':
            result = result * 2 + n - d[j]
        else:
            result = result * 2 + d[j]

print(result)

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

using namespace std;
struct qentry {
  int vertex;
  int64_t cost;
  bool operator<(const qentry& r) const { return cost < r.cost; }
  bool operator>(const qentry& r) const { return cost > r.cost; }
};

vector<int64_t> bfs(int n, int start,
                    const vector<vector<pair<int, int64_t>>>& edges) {
  priority_queue<qentry, vector<qentry>, greater<qentry>> q;
  vector<int64_t> costs(n + 1, 1e15);
  q.push(qentry{start, 0});
  costs[0] = 0;  // unused
  costs[start] = 0;
  while (!q.empty()) {
    auto from = q.top();
    q.pop();
    if (costs[from.vertex] < from.cost) continue;
    for (auto& o : edges[from.vertex]) {
      const int& out_v = o.first;
      const int64_t& cost = o.second;
      if (costs[from.vertex] + cost < costs[out_v]) {
        q.push(qentry{out_v, from.cost + cost});
        costs[out_v] = costs[from.vertex] + cost;
      }
    }
  }
  return costs;
}

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

  int n, m, s, t;
  cin >> n >> m >> s >> t;
  vector<int> u(m), v(m), a(m), b(m);
  vector<vector<pair<int, int64_t>>> yen_edge(n + 1);
  vector<vector<pair<int, int64_t>>> snuuk_edge(n + 1);
  for (int i = 0; i < m; ++i) {
    int u, v, a, b;
    cin >> u >> v >> a >> b;
    yen_edge[u].emplace_back(make_pair(v, a));
    yen_edge[v].emplace_back(make_pair(u, a));
    snuuk_edge[u].emplace_back(make_pair(v, b));
    snuuk_edge[v].emplace_back(make_pair(u, b));
  }

  auto yen = bfs(n, s, yen_edge);
  auto snuuk = bfs(n, t, snuuk_edge);
  int64_t money = 1e15;
  vector<int64_t> result(n + 1);

  result[n] = yen[n] + snuuk[n];
  for (int i = n - 1; 0 <= i; i--)
    result[i] = min(result[i + 1], yen[i] + snuuk[i]);
  for (int i = 1; i <= n; ++i) {
    cout << (money - result[i]) << "\n";
  }
}


Measured memory_bytes: 20552
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#define NMAX 100000
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define prin(arg) cout<<arg<<"\n";
#define scan(arg) cin>>arg;
using namespace std;
int a,b;
int main(){
	scan(a);scan(b);
	if(b%a==0){prin(a+b);}
	else prin(b-a);
	return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  
  for (int i = 0; i < N; i ++){
    cin >> vec[i];
  }
  
  sort(vec.begin(), vec.end());
  
  int count=0;
  for(int i = 0; i < vec.size(); i ++ ){
    if(vec[i] != vec[i + 1] ){
      count += 1;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
using ll=long long;
using namespace std;

long long pow(long long a,long long b,long long mod){
    if(b==0){
        return 1;
    }else{
        if(b%2==0){
            return pow(a*a%mod,b/2,mod);
        }else{
            return pow(a*a%mod,b/2,mod)*a%mod;
        }
    }
}

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

    ll mod=1e9+7;

    ll ans=pow(10,N,mod);
    ans-=pow(9,N,mod);
    ans+=mod;
    ans%=mod;
    ans-=pow(9,N,mod);
    ans+=mod;
    ans%=mod;
    ans+=pow(8,N,mod);
    ans%=mod;
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 3632
import math

def calc_omote(x, y):
    score = x
    omo = 0
    while(score < y):
        score *= 2
        omo += 1
    return omo
        

n, k = map(int, input().split())
ans = 0
for i in range(1,n+1):
    omote = calc_omote(i, k)
    p = 1/(2**omote)
    ans += p/n
#sump /= n
print(ans)

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

using namespace std;



int main()
{
    int n;
    cin>>n;
    int ac=0,tle=0,re=0,wa=0;
    for(int i=0;i<n;i++){
        string a;
        cin>>a;
        if(a=="AC")ac++;
        else if(a=="TLE")tle++;
        else if(a=="RE")re++;
        else if(a=="WA")wa++;
    }
    cout<<"AC x "<<ac<<endl<<"WA x "<<wa<<endl<<"TLE x "<<tle<<endl<<"RE x "<<re<<endl;
}


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

#define ll long long

#define fr(i,a,b) for (ll i = (a), _b = (b); i <= _b; i++)
#define frr(i,a,b) for (ll i = (a), _b = (b); i >= _b; i--)
#define rep(i,n) for (ll i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (ll i = n - 1; i >= 0; i--)
#define fill(ar,val) memset(ar, val, sizeof(ar))
#define fill0(ar) fill((ar), 0)
#define debug(x) cout<<#x<<": "<<x<<endl

#define ld long double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef vector<ii> vii;
typedef vector<int> vi;

#define INF 1000000000000000000
#define PI 3.14159265358979323846L

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

    ll n,m;
    cin >> n >> m;

    pair<ll, ll> p[n];

    rep(i,n)
    {
    	ll x,y;
    	cin >> x>> y;
    	p[i] = mp(x,y);
    }

    sort(p,p+n);

    ll ans = 0;
    ll p1 = 0;

    while(m>0)
    {
    	ll cost = p[p1].ff;
    	ll num = p[p1].ss;

    	if(num<=m)
    	{
    		ans = ans + cost*num;
    		m = m-num;
    	}
    	else
    	{
    		ans = ans + cost*m;
    		m = 0;
    	}

    	p1++;
    }

    cout << ans << endl;
}


Measured memory_bytes: 1792
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main(void){
  int a, b, c;
  cin >> a >> b >> c;

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

  return 0;
}

Measured memory_bytes: 1156
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define ff first
#define ss second
#define file_se_input  freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define pp long long int
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define pb push_back
#define mp make_pair
#define pi 3.141592653589793238
#define eb emplace_back
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define zip(i,a,b) for(int i=a;i<b;i++)
#define rzip(i,a,b) for(int i=a;i>=b;i--)
#define ll unsigned long long int
#define test int t;cin>>t; while(t--)
#define um unordered_map
#define en '\n'
#define us unordered_set
typedef pair<int, int>     pii;
typedef pair<char, int>    pci;
typedef pair<char, char>   pcc;
typedef vector<pii>       vii;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define INF (1e18+5)
#define inf (1e9+5)
#define mod 1000000007


bool check_prime(long long n)
{
	int flag = 0;
	for (long long i = 2; i * i <= n; i++)
	{
		if (n % i == 0)
		{
			flag = 1;
			break;
		}
	}
	if (n == 1)
		return false;
	else if (flag == 0 || n == 2 || n == 3)
	{
		return true;
	}
	else
	{
		return false;
	}

}

int BE(int x, int n, int m) //function to calculate x raise to power n modulo m
{
	int result = 1;
	while (n > 0)
	{
		if (n % 2 == 1)
			result = result * x % m;
		x = x * x % m;
		n = n / 2;
	}
	return result;
}

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	if (fopen("input.txt", "r"))
	{
		freopen ("input.txt" , "r" , stdin);
		freopen ("output.txt" , "w" , stdout);
	}
#endif
	//_______________________________-code starts-_______________________________________________


	int r, g, b, n;
	cin >> r >> g >> b >> n;
	int x;
	int cnt = 0;
	rep(i, 0, n)
	{
		rep(j, 0, n)
		{
			x = n - i * r - j * g;
			if (x >= 0 && x % b == 0)
			{
				if (x / b <= n)
				{
					cnt++;
				}
			}

		}
	}
	cout << cnt << en;

	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>

using namespace std;
typedef long long int ll;

int main(int argc, char const *argv[])
{
    ll n, i;
    cin >> n >> i;
    cout << n - i + 1;
}

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

using namespace std;


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

    int n, k, arr[51];
    cin >> n >> k;
    for (int i = 0; i < n; i++)
        cin >> arr[i];

    vector<int> item;
    int ans = 0, now = 0;
    for (int i = 0; i <= min(n, k); i++) // amount of taken items
        for (int j = 0; j <= i; j++) // amount of items taken from the left
        {
            int l = i - j;
            item.clear(), now = 0;
            for (int m = 0; m < j; m++)
                item.push_back(arr[m]), now += arr[m];
            for (int m = 0; m < l; m++)
                item.push_back(arr[n - m - 1]), now += arr[n - m - 1];
            sort(item.begin(), item.end());
            for (int m = 0; m < i && m < k - i && item[m] < 0; m++)
                now -= item[m];
            //cerr << n << ' ' << i << ' ' << j << ' ' << l << ' ' << now << '\n';
            ans = max(ans, now);
        }
    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 256
def main():
    N,M,C = map(int, input().split())
    B = list(map(int, input().split()))
    count = 0
    for i in range(N):
        A = list(map(int, input().split()))
        ans = C
        for a,b in zip(A,B):
            ans += a * b
        if ans > 0:
            count += 1
    print(count)

if __name__ == '__main__':
    main()

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

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

	int n, a, b, c;
	vector<int> t, x, y;
	cin >> n;
	for (int i = 0; i < n; ++i){
		cin >> a >> b >> c;
		t.push_back(a);
		x.push_back(b);
		y.push_back(c);
	}
	int rt = 0, rx = 0, ry = 0;
	for (int i = 0; i < n; ++i){
		if (t[i]-rt < abs(x[i]-rx) + abs(y[i]-ry)){
			cout << "No" << "\n";
			return 0;
		}
		/*
		if (rx == x[i] && ry == y[i]){
			if ((t[i]-rt)%2 == 1){
				cout << "No" << "\n";
				return 0;
			}
		}
		*/
		if ((abs(x[i]-rx) + abs(y[i]-ry))%2 != (t[i]-rt)%2){
			cout << "No" << "\n";
			return 0;
		}
		rt = t[i];
		rx = x[i];
		ry = y[i];
	}
	cout << "Yes" << "\n";
	return 0;
}

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

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))

#define INF 2e9
#define INF_LL 1LL<<60
#define ll long long


int main(){
    int h, w, n;
    cin >> h >> w >> n;

    int sr, sc;
    cin >> sr >> sc;
    sr--, sc--;

    string s, t;
    cin >> s >> t;

    /* 上方向 */
    int tate = sr;
    REP(i, n) {
        /* 高橋 */
        if(s[i] == 'U') {
            tate--;
            if(tate < 0) {
                cout << "NO" << endl;
                return 0;
            }
        }
        /* 青木 */
        if(t[i] == 'D') {
            if(tate < h-1) tate++; 
        }
    }

    /* 下方向 */
    tate = sr;
    REP(i, n) {
        /* 高橋 */
        if(s[i] == 'D') {
            tate++;
            if(tate > h-1) {
                cout << "NO" << endl;
                return 0;
            }
        }
        /* 青木 */
        if(t[i] == 'U') {
            if(tate > 0) tate--; 
        }
    }

    /* 右方向 */
    int yoko = sc;
    REP(i, n) {
        /* 高橋 */
        if(s[i] == 'R') {
            yoko++;
            if(yoko > w-1) {
                cout << "NO" << endl;
                return 0;
            }
        }
        /* 青木 */
        if(t[i] == 'L') {
            if(yoko > 0) yoko--; 
        }
    }

    /* 左方向 */
    yoko = sc;
    REP(i, n) {
        /* 高橋 */
        if(s[i] == 'L') {
            yoko--;
            if(yoko < 0) {
                cout << "NO" << endl;
                return 0;
            }
        }
        /* 青木 */
        if(t[i] == 'R') {
            if(yoko < w-1) yoko++; 
        }
    }


    cout << "YES" << endl;

    return 0;
}


Measured memory_bytes: 900
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

int main(){
    ll N, Z, W;
    cin >> N >> Z >> W;
    vector<ll> a(N+1);
    for(int i=1; i<=N; ++i) cin >> a[i];

    if(N == 1){
        cout << abs(a[N] - W) << endl;
    } else {
        cout << max(abs(a[N]-W), abs(a[N]-a[N-1])) << endl;
    }
}

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

bool greater_second(const pair<int, int>& a, const pair<int, int>& b){
  return a.second > b.second;
}

int main(void){
  int n; map<int, int> x[2];
  cin >> n;
  for(int i = 0; i < n; i++){
    int v; cin >> v;
    x[i%2][v]++;
  }
  vector<pair<int,int>> a, b;
  a.reserve(n/2);
  b.reserve(n/2);
  for(const auto& v: x[0]){
    a.push_back(v);
  }
  for(const auto& v: x[1]){
    b.push_back(v);
  }
  sort(a.begin(), a.end(), greater_second);
  sort(b.begin(), b.end(), greater_second);

  int maxv = 0;
  for(int i = 0; i < 2; i++){
    for(int j = 0; j < 2; j++){
      if(a[i].first == b[j].first) continue;
      maxv = max(maxv, a[i].second + b[j].second);
    }
  }
  cout << n - maxv << endl;
}


Measured memory_bytes: 5760
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;


class Program
{
    static void Main(string[] args)
    {
        // 入力
        //var s = Console.ReadLine();
        var n = decimal.Parse(Console.ReadLine());
        //int[] n = Console.ReadLine().Split().Select(int.Parse).ToArray();

        var list = new List<decimal>();
        var sum = 0;
        for (int i = 1; i <= n; i++)
        {
            sum += i;
            list.Add(i);
            if(sum == n)
            {
                break;
            }
            else if (sum > n)
            {
                var tmp = sum - n;
                list.Remove(tmp);
                break;
            }
        }

        // 出力
        foreach (var item in list)
        {
            Console.WriteLine(item);
        }
    }
}

Measured memory_bytes: 27988
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define DEBUG(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x),0);
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int INF = 1e+9;
const ll mod = 1000000007;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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

int h[100010];
int dp[100010];

int main () {
  int N; cin >> N;
  rep(i,N) cin >> h[i];

  rep(i,100010) {
    dp[i] = INF;
  }

  dp[0] = 0;
  for (int n = 0; n < 100000; n++) {
    dp[n+1] = min(dp[n+1], dp[n]+abs(h[n]-h[n+1]));
    dp[n+2] = min(dp[n+2], dp[n]+abs(h[n]-h[n+2]));
  }

  cout << dp[N-1] << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for(ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for(ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for(ll i = a; i >= (ll)(b); i--)

int main() {
    int N, M;
    cin >> N >> M;

    char AA[N][N];
    char BB[M][M];

    REP(y, N) {
        REP(x, N) { cin >> AA[y][x]; }
    }

    REP(y, M) {
        REP(x, M) { cin >> BB[y][x]; }
    }

    REP(x0, N - M + 1) {
        REP(y0, N - M + 1) {
            bool tmp = true;
            REP(x, M) {
                REP(y, M) {
                    if(AA[y0 + y][x0 + x] != BB[y][x]) {
                        tmp = false;
                    }
                }
            }
            if(tmp) {
                cout << "Yes" << endl;
                return (0);
            }
        }
    }

    cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define LLMAX (1ll << 60) - 1
#define INTMAX (1 << 30) - 1
#define MOD 1000000007 
#define NMAX 1000*100+1

#define numberOfSetBits(S) __builtin_popcount(S) // __builtin_popcountl(S) __builtin_popcountll(S)
#define MSET(x,y) memset(x,y,sizeof(x))
#define gcd(a,b) __gcd(a,b)
#define all(x)  x.begin(),x.end()
#define isOn(S, j) (S & (1 << j))
#define endl '\n'
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
#define print(x)    for(auto it:x) cout<<it<<' '; cout<<endl;
#define printii(x)  for(auto it:x) cout<<it.F<<' '<<it.S<<'\t';  cout<<endl;
#define in(x,n)   for(int e=0;e<n;e++){ll y;cin>>y;x.pb(y);}

#define vi vector<ll>
#define vvi vector<vi>
#define ii pair<ll,ll>
#define pll pair<ll,ll>
#define vii vector<ii>
#define vvii vector<vii>
#define viii vector<pair<ii,ll>>
#define pb push_back
#define F first
#define S second
#define mp make_pair
#define mc(a,b,c) mp(mp(a,b),c)


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,x,t,m,y,z;
    cin>>x;
    y = x%100;
    z = x/100;
    bool ok1=false,ok2=false;
    if((y<=12)&&(y)){
        ok1=true;
    }  
    if((z<=12)&&(z)){
        ok2=true;
    }      
    if(ok1&ok2){
        cout<<"AMBIGUOUS\n";
    }
    else if(ok1){
        cout<<"YYMM";
    }
    else if(ok2){
        cout<<"MMYY";
    }
    else{
        cout<<"NA";
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(ll i=0;i<n;i++)
#define ll long long
using namespace std;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
signed main() {
	int n, k;
	cin >> n >> k;
	if ((n - 1) / 2+1 >=k)puts("YES");
	else puts("NO");
	getchar(); getchar(); return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> PII;

const int MM = 1e9 + 7;
const double eps = 1e-8;
const int MAXN = 2e6 + 10;

int n, m;

void prework(){

}

int a[MAXN];

ll A, B;

void read(){
	scanf("%d%lld%lld", &n, &A, &B);
	for(int i = 1; i <= n; i++)
		scanf("%d", &a[i]);
	ll ans = 0;
	for(int i = 2; i <= n; i++){
		ans += min(B, A * (a[i] - a[i-1]));
	}
	cout<<ans<<endl;
}

void solve(int casi){

}

void printans(){

}


int main(){
	prework();
	int T = 1;
//	cin>>T;
	for(int i = 1; i <= T; i++){
		read();
		solve(i);
		printans();
	}
	return 0;
}




Measured memory_bytes: 640
#region using
using System;
using System.Collections.Generic;
using System.Linq;
using IEnumerable = System.Collections.IEnumerable;
using IEnumerator = System.Collections.IEnumerator;
using BitArray = System.Collections.BitArray;
using BigInteger = System.Numerics.BigInteger;
using TextReader = System.IO.TextReader;
using System.Text;
#endregion

namespace AtCoderProject
{
    public class Program
    {
        public object Calc()
        {
            return consoleReader.String.Replace(',', ' ');
        }

        #region いつもの
#pragma warning disable
        private ConsoleReader consoleReader;
        public Program(ConsoleReader consoleReader) { this.consoleReader = consoleReader; }
        static void Main() => Console.WriteLine(new Program(new ConsoleReader(Console.In)).Calc()); static string AllLines<T>(IEnumerable<T> source) => string.Join("\n", source);
    }
    static class Ext
    {
        public static Dictionary<TKey, int> GroupCount<TSource, TKey>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector) => source.GroupBy(keySelector).ToDictionary(g => g.Key, g => g.Count());
        public static Dictionary<TKey, int> GroupCount<TKey>(this IEnumerable<TKey> source) => source.GroupCount(i => i);
    }
    public class ConsoleReader { private string[] ReadLineSplit() => textReader.ReadLine().Split(Array.Empty<char>(), StringSplitOptions.RemoveEmptyEntries); private string[] line = Array.Empty<string>(); private int linePosition; private TextReader textReader; public ConsoleReader(TextReader tr) { textReader = tr; } public int Int => int.Parse(String); public long Long => long.Parse(String); public double Double => double.Parse(String); public string String { get { if (linePosition >= line.Length) { linePosition = 0; line = ReadLineSplit(); } return line[linePosition++]; } } public class SplitLine { private string[] splited; public SplitLine(ConsoleReader cr) { splited = cr.ReadLineSplit(); cr.line = Array.Empty<string>(); } public int[] Int => String.Select(x => int.Parse(x)).ToArray(); public int[] Int0 => String.Select(x => int.Parse(x) - 1).ToArray(); public long[] Long => String.Select(x => long.Parse(x)).ToArray(); public double[] Double => String.Select(x => double.Parse(x)).ToArray(); public string[] String => splited; } public SplitLine Split => new SplitLine(this); public class RepeatReader : IEnumerable<ConsoleReader> { ConsoleReader cr; int count; public RepeatReader(ConsoleReader cr, int count) { this.cr = cr; this.count = count; } public IEnumerator<ConsoleReader> GetEnumerator() => Enumerable.Repeat(cr, count).GetEnumerator(); System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() => GetEnumerator(); public IEnumerable<string> String => this.Select(cr => cr.String); public IEnumerable<int> Int => this.Select(cr => cr.Int); public IEnumerable<int> Int0 => this.Select(cr => cr.Int - 1); public IEnumerable<long> Long => this.Select(cr => cr.Long); public IEnumerable<double> Double => this.Select(cr => cr.Double); } public RepeatReader Repeat(int count) => new RepeatReader(this, count); }
    #endregion
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define ld long double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
typedef
tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> order_set;
const ll mod=1e9+7;
const int N=2e6+10;
const int M=20;

ll power(ll x, unsigned ll y, ll p)
{
     ll res = 1; 
     x = x % p;
     while (y > 0)
     {
         if (y & 1)
             res = (res*x) % p;
         y = y>>1;
         x = (x*x) % p;  
     }
    return res;
}


int main() 
{
    FAST;
    srand(time(NULL));
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ll n,k;
    cin >> n >> k;
    ll a[n],i;
    for(i=0;i<n;i++)
        cin >> a[i];
    sort(a,a+n);
    ll ans=INT_MAX;
    for(i=0;i<=n-k;i++)
    {
        ll x=a[i+k-1]-a[i];
        ans=min(ans,x);
    }
    cout << ans;
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  vector<int> v(N);
  for(int i = 0; i < N; i++) {
    int a;
    cin >> a;
    v.at(a - 1) = i + 1;
  }
  
  for(int i = 0; i < N; i++) {
   cout << v.at(i) << ' ';
  }
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
#define FOR(i,a,b) for(long long i = (long long)(a); i < (long long)(b); i++)
#define RFOR(i,a,b) for(long long i = (long long)(a); i >= (long long)(b); i--)
#define MIN3(a,b,c) (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c))
#define MAX(a,b) (a)>(b)?(a):(b)
#define MIN2(a,b) (a)<(b)?(a):(b)
using namespace std;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef long long ll;
#define ull unsigned long long
typedef long double ld;
typedef vector<ll> vll;
typedef pair<ll,ll> lll;
#define deb(x )     cerr << #x << " here "<< x << endl;
#define endl    "\n"
#define printCase() "Case #" << caseNum << ": "
inline bool is_palindrome(const string& s){ return std::equal(s.begin(), s.end(), s.rbegin()); }
const ll MOD = 1000000007;
const ll INF = 1e9+5;
const double eps = 1e-7;
const double PI = acos(-1.0);
#define coud(a,d) cout << fixed << showpoint << setprecision(d) << a;
inline void debug_vi(vi a) {FOR(i, 0, a.size()) cout<<a[i]<<" ";}
inline void debug_vll(vll a) {FOR(i, 0, a.size()) cout<<a[i]<<" ";}
#define ff first
#define ss second
/*----------------------------------------------------------------------*/

const int N = 105;
int mat[N][N];
ii cols[N*N];

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

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int h,w,n,ind=0;
    cin>>h>>w>>n;
    FOR(i, 0, n) {
    	cin>>cols[i].ff;
    	cols[i].ss = i;
    }
    sort(cols, cols + n, greater<ii>());
    FOR(i, 0, h) {
    	if(i % 2 == 0) {
    		FOR(j, 0, w) {
				mat[i][j] = cols[ind].ss + 1;
				cols[ind].ff--;
    			if(!cols[ind].ff) ind++;
    		}
    	} else {
    		RFOR(j, w-1, 0) {
    			mat[i][j] = cols[ind].ss + 1;
				cols[ind].ff--;
    			if(!cols[ind].ff) ind++;
    		}
    	}
    }
    FOR(i, 0, h) {
    	FOR(j, 0, w) {
    		cout<<mat[i][j]<<" ";
    	}
    	cout<<endl;
    }

    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
vector<int> solve(int N, int A, int B)
{
    vector<int> L;
    if (B == 1) {
        if (N != A) return {-1};
        L = { N };
    } else {
        L = { A };
        int q = (N - A) / (B - 1);
        int r = (N - A) % (B - 1);
        if (q == 0) return {-1};
        if (q + (r != 0) > A) return {-1};
        for (int i = 0; i < r; i++) L.push_back(q + 1);
        for (int i = r; i < B-1; i++) L.push_back(q);
    }
    vector<int> ans;
    for (int i = 0; i < L.size(); i++) {
        for (int j = 0; j < L[i]; j++) {
            ans.push_back(N - L[i] + 1 + j);
        }
        N -= L[i];
    }
    return ans;
}
int main()
{
    cin.tie(nullptr); ios::sync_with_stdio(false);
    int N, A, B; cin >> N >> A >> B;
    for (auto n : solve(N, A, B)) cout << n << ' ';
    cout << '\n';
    return 0;
}

Measured memory_bytes: 3492
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

N,K = map(int,input().split())
V = [int(i) for i in input().split()]
#
if N == 1:
    print(max(0,V[0]))
    exit()

ans = 0
for i in range(K): # 戻す数
    for j in range(K-i+1):
        if j <= N-(K-i-j):
            ans_list = V[:j]+V[N-(K-i-j):]
            ans_list.sort()
            tmp = sum(ans_list)
            for k in range(min(len(ans_list),i)):
                if ans_list[k] < 0:
                    tmp -= ans_list[k]
            ans = max(ans,tmp)
        else:
            pass

print(max(ans,0))


Measured memory_bytes: 6472
//二分探索木
//参考：https://onlinejudge.u-aizu.ac.jp/solutions/problem/ALDS1_8_A/review/1911655/emine/C%23
//Nodeクラスの中にNodeメンバ関数を作っていてそのやり方が分からなかった
using System;

namespace tst
{
    class Program
    {
        public class Node
        {
            internal int key;
            internal Node left;
            internal Node right;
            public Node(int key)
            {//引数付きコンストラクタ。その都度初期化できる。
                this.key = key;
            }
        }
        static Node root;
        public static void Insert(int k)
        {
            //yはxの親。xはTの根。
            Node x = root;
            Node y = null;
            Node z = new Node(k);//keyにkを入れる
            while (x != null)
            {
                y = x;
                if (z.key < x.key)
                {
                    x = x.left;
                }
                else
                {
                    x = x.right;
                }

            }
            if (y == null)
            {
                root = z;
            }
            else if(z.key<y.key)
            {
                y.left = z;
            }
            else
            {
                y.right = z;
            }
        }
        public static void Inorder(Node u)
        {
            if (u == null) return;
            Inorder(u.left);
            Console.Write(" " + u.key);
            Inorder(u.right);
        }
        public static void Preorder(Node u)
        {
            if (u == null) return;
            Console.Write(" " + u.key);
            Preorder(u.left);
            Preorder(u.right);
        }
        public static void Main()
        {
            int n = int.Parse(Console.ReadLine());
            for (int i=0; i<n; i++)
            {
                String[] In = Console.ReadLine().Split(' ');
                if (In[0] == "insert")
                {;
                    Insert(int.Parse(In[1]));
                }
                else if(In[0] == "print")
                {
                    Inorder(root);
                    Console.WriteLine(); 
                    Preorder(root);
                    Console.WriteLine();
                }
            }
        }
    }
}


Measured memory_bytes: 38004
#include <bits/stdc++.h>
#define rep(i, x, N) for (int i = x; i < (N); i++)
using namespace std;
int main()
{
    int N;
    string S;
    cin >> N >> S;
    vector<char> alfa(91);
    char j = 'A';
    rep(i, 65, 91)
    {
        alfa[i] = j;
        (int)j++;
    }
    rep(i, 0, N)
    {
        char temp = alfa[65];
        for (int j = 65; j <= 90; j++)
        {
            alfa[j] = alfa[j + 1];
        }
        alfa[90] = temp;
    }
    rep(i, 0, S.size())
    {
        S[i] = alfa[(int)S[i]];
    }
    cout << S << endl;
}


Measured memory_bytes: 256
def f(n):
    ans = 0
    while n > 0:
        ans += n % 10
        n //= 10
    return ans


N = int(input())

ans = float('inf')
for A in range(1, N // 2 + 1):
    B = N - A
    ans = min(ans, f(A) + f(B))
print(ans)


Measured memory_bytes: 2940
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
typedef unsigned int ui;
int main() {
	int n;
	cin >> n;
	int a[20000];
	if (n == 3) {
		a[0] = 2; a[1] = 5; a[2] = 63;
	}
	else if (n <= 15002) {
		a[0] = 3; a[1] = 9;
		if ((n - 2) % 3 != 1) {
			for (int i = 1; i <= n - 2; i++) {
				a[i + 1] = 2 * i;
			}
		}
		else {
			for (int i = 1; i <= n - 2; i++) {
				a[i + 1] = 2 * i + 4;
			}
		}
	}
	else {
		for (int i = 1; i <= 15000; i++) {
			a[i - 1] = 2 * i;
		}
		if ((n - 15000) % 2 == 1) {
			for (int i = 0; i < n - 14999; i++) {
				a[i + 14999] = 3 + 6 * i;
			}
		}
		else {
			for (int i = 0; i < n - 15000; i++) {
				a[i + 15000] = 3 + 6 * i;
			}
		}
	}
	for (int i = 0; i < n; i++) {
		cout << a[i] << " ";
	}
	cout << endl;
	char nyaa;
	cin >> nyaa;
	return 0;
}


Measured memory_bytes: 384
#include<cstdio>
#include<algorithm>
using namespace std;

char cam[51][51];
int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};
int main()
{
  int H,W,i,j,f=1,s,x,y,bb=0;
  scanf("%d %d",&H,&W);
  for(j=0;j<H;j++)
    fscanf(stdin,"%s",cam[j]);
  for(j=0;j<H;j++)
    for(i=0;i<W;i++){
      if(cam[j][i] == '#'){
        for(s = 0;s<4;s++){
          x = i + dx[s];
          y = j + dy[s];
          if(x < 0 || x>= W || y < 0 || y >= H)
            continue;
          if(cam[y][x] == '#')
            bb = 1;
        }
        if(bb == 0){
          printf("No\n");
          return 0;
        }
      }
      bb = 0;
    }
  printf("Yes\n");
}


Measured memory_bytes: 256
#include <cmath>
#include <cstdlib>

#include <iostream>
#include <vector>
#include <algorithm>

int main() {

  long N;
  long length[3];


  std::cin >> N;

  for(int i = 0; i < N; ++i) {

    std::cin >> length[0] >> length[1] >> length[2];
    std::sort(length, length+3);

    if(length[0]*length[0] + length[1]*length[1] == length[2]*length[2]) {
      std::cout << "YES" << std::endl;
    }
    else {
      std::cout << "NO" << std::endl;
    }

  }

  return 0;

}

Measured memory_bytes: 1160
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;

class Program{
  static void Main(){
	var s = ReadLine();
    var n = s.Length;
    var one = false;
    var two = false;
    var three = false;
    var x = "";
    
    for(var j = n-1;j >= 0;j--){
    	x = x + s[j];
    }
    if(s.Equals(x)){
        one = true;
    }

    var s2d = "";
    var s2 = "";
    
    for(var i = (n+3)/2-1;i < n;i++){
      s2 = s2 + s[i];
    }
    
    for(var i = n-1;i >= (n+3)/2-1;i--){
      s2d = s2d + s[i];
    }
    
    if(s2.Equals(s2d)){
        two = true;
    }
    
    var s3 ="";
    var s3d = "";

    for(var i = 0;i <= (n-1)/2-1;i++){
      s3 = s3 + s[i];
    }
    
    for(var i = (n-1)/2-1;i >= 0;i--){
      s3d = s3d + s[i];
    }
    

    
    if(s3.Equals(s3d)){
        three = true;
    }
    
    if(one == true && two == true && three == true){
    	Write("Yes");
    }else{
    	Write("No");
    }
    
    
  }
}

Measured memory_bytes: 17228
uses math; 
var
    n, i, j, k, ans : longint;
    a, dp : array[1..100005, 1..5] of longint;

begin
    readln(n);
    for i := 1 to n do
    for j := 1 to 3 do read(a[i, j]);
    fillchar(dp, sizeof(dp), 255);
    for i := 1 to 3 do dp[1, i] := a[1, i];
    for i := 2 to n do
    for j := 1 to 3 do
    for k := 1 to 3 do
    if (j <> k) then dp[i, j] := max(dp[i, j], dp[i - 1, k] + a[i, j]);
    ans := -1;
    for i := 1 to 3 do ans := max(ans, dp[n, i]);
    writeln(ans);
end.

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

int main()
{
  int m1, d1;
  int m2, d2;
  cin >> m1 >> d1;
  cin >> m2 >> d2;
  if (m1 != m2 && d2 == 1) {
    cout << 1 << endl;
  } else {
    cout << 0 << endl;
  }
}


Measured memory_bytes: 256
use std::cmp::Ordering;

fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

struct Restaurant {
    i: i32,
    s: String,
    p: i32,
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let n: i32 = read(&mut stdin_lock, &mut buf, b'\n');
    let mut ts: Vec<Restaurant> = Vec::new();
    for i in 0..(n - 1) {
        ts.push(Restaurant {
            i: i + 1,
            s: read(&mut stdin_lock, &mut buf, b' '),
            p: read(&mut stdin_lock, &mut buf, b'\n'),
        });
    }
    ts.push(Restaurant {
        i: n,
        s: read(&mut stdin_lock, &mut buf, b' '),
        p: read(&mut stdin_lock, &mut buf, b'\n'),
    });

    ts.sort_by(|a, b| match a.s.cmp(&b.s) {
        Ordering::Less => Ordering::Less,
        Ordering::Greater => Ordering::Greater,
        Ordering::Equal => b.p.cmp(&a.p),
    });
    for t in ts.iter() {
        println!("{}", t.i);
    }
}


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

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

using namespace std;

int main() {

    long int N; cin >> N;

    long int ans = 0;

    rep(i,N) ans += i;

    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define boost() ios_base :: sync_with_stdio(0); cin.tie(); cout.tie(); cout << fixed; cout << setprecision(15); srand(time(NULL))
#define int long long
using namespace std;

const int N = 60;

signed main () {
  boost();
  int a, b;
  cin >> a >> b;
  string s = "", t = "";
  for (int i = 0; i < b; i++) s.push_back((char)(a + '0'));
  for (int i = 0; i < a; i++) t.push_back((char)(b + '0'));
  if (s < t) cout << s << endl;
  else cout << t << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>
#include <chrono>
using namespace std;

int main(int argc, const char * argv[]) {
    
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    
    cout << max(0, min(b, d) - max(a, c)) << endl;
    
    return 0;
}


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

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

vector<int> argsort(vector<int> v)
{
	int n = v.size();
	vector<int> indices(n);
	REP(i,n){ indices[i] = i; }

	sort(indices.begin(), indices.end(), [&v](size_t i1, size_t i2) {
        return v[i1] < v[i2];
  });

	return indices;
}

int main()
{
  int N; cin >>  N;
  vector<int> array(N);
  REP(i, N){ cin >> array[i]; }

  vector<int> out = argsort( array );
  
  REP(i, N){ cout << out[i]+1 << " "; }
  cout << endl;

  return 0;
}

Measured memory_bytes: 1656
#include <iostream>
using namespace std;
using ll = long long;

int main() {
  ll A, B;
  cin >> A >> B;

  if(A == B) {
    cout << A << endl;
    return 0;
  }

  ll a1 = 0LL;
  ll a2 = 0LL;
  if(A % 2 == 1) {
    a1 = A;
    a2 = A + 1;
  } else {
    a1 = 0;
    a2 = A;
  }
  ll b1 = 0LL;
  ll b2 = 0LL;
  if(B % 2 == 1) {
    b1 = 0;
    b2 = B;
  } else {
    b1 = B;
    b2 = B - 1;
  }
  // cout << a1 << ", " << a2 << ", " << b2 << ", " << b1 << endl;
  ll c = (((b2 - a2 + 1) / 2) % 2 == 1) ? 1 : 0;
  // cout << c << endl;
  ll ans = a1 ^ b1 ^ c;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import math
a, b, n = map(int, input().split())

x = 0
if n < b :
    x = n
    ans = math.floor(a*x/b)-a*math.floor(x/b)
    print(ans)
elif b <= n :
    x = b-1
    ans =  math.floor(a*x/b)-a*math.floor(x/b)
    print(ans)


Measured memory_bytes: 9184
#include <stdio.h>
int main(void){
while(1){
    int h,w;
    scanf("%d%d",&h,&w);
    if(h==0&&w==0)
    break;
    
    int i,j;
    
    for(i=0;i<w;i++)
    printf("#");
    
    printf("\n");
    
    for(i=2;i<h;i++){
        printf("#");
        for(j=2;j<w;j++){
            printf(".");
        }
        printf("#\n");
    }
    for(i=0;i<w;i++)
    printf("#");
    
    printf("\n\n");
}
return 0;
}

Measured memory_bytes: 2592
import java.util.*;

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

    int n = sc.nextInt();
    int d = sc.nextInt();
    String dummy = sc.nextLine();
    
    int[][] x = new int[n][d];

    for (int i = 0; i < n; i++) {
      String[] s = sc.nextLine().split(" ");
      for (int j = 0; j < d; j++) {
        x[i][j] = Integer.parseInt(s[j]);
      }
    }

    
    int ans = 0;
    for (int i = 0; i < n - 1; i++) {
      for (int j = i + 1; j < n; j++) {
        int sum = 0;
        for (int k = 0; k < d; k++) {
          sum += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
        }
        if (Math.sqrt(sum) == (int)Math.sqrt(sum)) ans++;
      }
    }

    System.out.println(ans);
  }
}


Measured memory_bytes: 21716
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

ll cnt[26];
int main()
{
	string S; cin >> S;
	cnt[S[0] - 'a']++;
	ll ans = 1;
	for (int i = 1; i < S.size(); i++) {
		ans += i - cnt[S[i] - 'a'];
		cnt[S[i] - 'a']++;
	}
	cout << ans << endl;
}


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

using namespace std;

int main(){
  long long q,h,s,d,n;
  cin>>q>>h>>s>>d>>n;
  q*=4,h*=2;

  long long x=min(s,min(q,h));

  if(n==1||x*2<d)cout<<x*n<<endl;
  else cout<<n/2*d+(n%2)*x<<endl;
  
  return 0;
}


Measured memory_bytes: 256
s = int(input())
a_li = [s]
i = 0
f = 0
while True:
    if a_li[i] % 2 == 0:
        a_li.append(int(a_li[i] / 2))
    else:
        a_li.append(3 * a_li[i] + 1)
    i += 1
    for j in range(i):
        if a_li[i] == a_li[j]:
            f = 1
    if f == 1:
        break
print(i+1)


Measured memory_bytes: 3060
use proconio::{fastout, input};
#[allow(unused_mut)]
#[fastout]
fn main() {
    input! {
        n: usize,
        x: usize,
        m: [usize; n]
    }
    let m: Vec<usize> = m;
    let sum: usize = m.iter().sum();
    let min = *m.iter().min().unwrap();
    let remain = x - sum;
    println!("{}", n + remain / min);
}


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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};

int main(){
    string s;
    cin>>s;
    int win=0,lose=0;
    for (int i = 0; i < s.size(); i++)
    {
        if(s[i]=='o') win++;
        else lose++;
    }
    if(15-lose>=8) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn=2e5+5;
vector<int>E[maxn];
int d[maxn][3]; // mod 3=j
int vis[maxn][3];
void bfs(int x)
{
    for(int i=0;i<maxn;i++)
    {
        for(int j=0;j<3;j++)
        {
            d[i][j]=1e9;
        }
    }
    queue<pair<int,int>>q;
    d[x][0]=0;
    vis[x][0]=1;
    q.push({x,0});
    while(!q.empty())
    {
        int now=q.front().first;
        int t=q.front().second;//这一步mod3的值
        int y=(t+1)%3;//下一步mod3的值
        q.pop();
        for(auto&v:E[now])
        {
            if(vis[v][y]) continue;
            vis[v][y]=1;
            d[v][y]=d[now][t]+1;
            q.push({v,y});
        }
    }

}
void dijkstra(int x)
{
      for(int i=0;i<maxn;i++)
    {
        for(int j=0;j<3;j++)
        {
            d[i][j]=1e9;
        }
    }
    queue<pair<int,int>>q;
    d[x][0]=0;
    q.push({x,0});
    while(!q.empty())
    {
        int now=q.front().first;
        int t=q.front().second;//这一步mod3的值
        int y=(t+1)%3;//下一步mod3的值
        q.pop();
        for(auto&v:E[now])
        {
            if(d[v][y]>d[now][t]+1)
            {d[v][y]=d[now][t]+1;
            q.push({v,y});}
        }
    }
}
int main()
{
   ios::sync_with_stdio(false);
   cin.tie(0);
   int n,m;
   cin>>n>>m;
   for(int i=1;i<=m;i++)
   {
       int u,v;
       cin>>u>>v;
       E[u].push_back(v);
   }
   int s,t;
   cin>>s>>t;
   dijkstra(s);
   if(d[t][0]==1e9)
   {
       cout<<-1<<'\n';
   }
   else
    cout<<d[t][0]/3<<'\n';



}





Measured memory_bytes: 10752
fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let input: Vec<i32> = s.split_whitespace().map(|x| x.parse::<i32>().unwrap()).collect();
    let mut state = 0;
    let lefta = input[2] - input[0];
    if lefta >= 0 && lefta <= input[1] { state = 1 }

    let ans = vec!["NO", "YES"];
    println!("{}", ans[state]);
}


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

typedef long long ll;

int main(){
	int m1,d1,m2,d2;
	cin>>m1>>d1>>m2>>d2;
	if(m1!=m2){
		cout<<1<<endl;
	}else{
		cout<<0<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
// SPG-B-Teacher.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//
//#include"pch.h"
#include<iostream>
#include<vector>

using namespace std;
int N;
long long ans, K, mod = 1000000000 + 7;
int main()
{
	cin >> N >> K;
	vector<int>A(N);
	for (int i = 0; i < N; i++)cin >> A.at(i);
	for (int i = 0; i < N; i++)
	{
		long cnt = 0, t = 0;
		for (int j = 0; j < N; j++)if (A[j] > A[i])cnt++, t += j < i;
		ans += K * (K - 1) / 2 % mod*cnt%mod + t * K%mod;
		ans %= mod;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
using System;

namespace ForAtcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var x = Console.ReadLine().Split(" ");
            if (long.Parse(x[0]) <= long.Parse(x[1]))
            {
                Console.WriteLine("unsafe");
            }
            else
            {
                Console.WriteLine("safe");
            }
        }
    }
}

Measured memory_bytes: 27520
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

int main(){
    int n,k;
    cin >> n >> k;
    vl h(n);
    rep(i,n) cin >> h[i];
    sort(all(h));
    set<int> g;
    rep(i,n-k+1){
        g.insert(h[i + k - 1] - h[i]);
    }
    cout << *begin(g) << endl;
}

Measured memory_bytes: 4864