akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <array>
#include <algorithm>
#include <iostream>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <math.h>
#include <assert.h>
#include <queue>
#include <deque>
#include <iomanip>
#include <numeric>
#include <fstream>

using namespace std;

typedef long long ll;
typedef long double ld;

#define fi first
#define se second

#define mp make_pair
#define pb push_back
#define sz(x) ((int)(x).size())

typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ld> vld;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<ld>> vvd;
typedef vector<string> vs;
typedef vector<bool> vb;

typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

bool ok(ll x) {
    ll d = 0;
    while (x > 0) {
        ++d;
        x /= 10;
    }
    return d % 2 == 1;
}

int main() {
    cout << setprecision(30);
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

    string s;
    cin >> s;
    ll n = sz(s);
    vl ans(n);


    ll curr_kek = 0;
    for (int i = 0; i < n; ++i) {
        if (s[i] == 'L') {
            ans[i] += curr_kek / 2;
            ans[i - 1] += curr_kek - curr_kek / 2;
            curr_kek = 0;
            continue;
        }
        ++curr_kek;
    }

    curr_kek = 0;
    for (int i = n - 1; i >= 0; --i) {
        if (s[i] == 'R') {
            ans[i] += curr_kek / 2;
            ans[i + 1] += curr_kek - curr_kek / 2;
            curr_kek = 0;
            continue;
        }
        ++curr_kek;
    }

    for (int i = 0; i < n; ++i) {
        cout << ans[i] << (i + 1 < n ? " " : "");
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 1488
hlist = []
for i in range(10):
    h = int(input())
    hlist.append(h)

for i in range(10):
    for j in range(9,0,-1):
        if hlist[j-1]<hlist[j]:
            hlist[j-1],hlist[j] = hlist[j],hlist[j-1]

print(hlist[0])
print(hlist[1])
print(hlist[2])


Measured memory_bytes: 5596
def main():
  H,W,D=map(int,input().split())

  A=[[0,0] for i in range(H*W)]
  for h in range(H):
    for w,a in enumerate(map(int,input().split())):
      A[~-a][0],A[~-a][1]=h,w

  B=[0]*(H*W)
  for i in range(H*W-D):
    B[i+D]=B[i]+abs(A[i][0]-A[i+D][0])+abs(A[i][1]-A[i+D][1])

  for q in range(int(input())):
    l,r=map(int,input().split())
    print(B[~-r]-B[~-l])

main()


Measured memory_bytes: 20588
while 1:
    n = int(input())
    if n == 0:
        break

    for _ in range(n):
        m, e, j = map(int, input().split())
        total = m + e + j
        if 100 in [m, e, j]:
            print("A")
        elif m + e >= 180:
            print("A")
        elif total >= 240:
            print("A")
        elif total >= 210:
            print("B")
        elif total >= 150 and (m >= 80 or e >= 80):
            print("B")
        else:
            print("C")



Measured memory_bytes: 5616
#include <iostream>

using namespace std;

const int N = 100;
int A[N][N] = {{0}};
int n;
int t = 0;
int d[N] = {0};
int f[N] = {0};

void dfs(int id) {
    if (d[id] != 0) {
        return;
    }
    ++t;
    d[id] = t;

    for (int i = 0; i < n; ++i) {
        if (A[id][i] != 0) {
            dfs(i);
        }
    }

    ++t;
    f[id] = t;
}

int main() {
    cin >> n;
    for (int i = 0; i < n; ++i) {
        int u;
        cin >> u;

        int k;
        cin >> k;
        for (int j = 0; j < k; ++j) {
            int x;
            cin >> x;
            A[u-1][x-1] = 1;
        }
    }

    for (int i = 0; i < n; ++i) {
        if (d[i] == 0)
            dfs(i);
    }

    for (int i = 0; i < n; ++i) {
        cout << i + 1 << " ";
        cout << d[i] << " " << f[i];
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 3128
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
#include <set>
#include <map>
#include <tuple>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rep(i,N) for (int i=0;i<N;i++)
#define loop(i,N,M) for(int i=N;i<M;i++)
#define MAX(v) *max_element(v.begin(),v.end())
#define MIN(v) *min_element(v.begin(),v.end())
#define SORTL2S(type,v) sort(v.begin(),v.end(),greater<type>())
#define SORTS2L(type,v) sort(v.begin(),v.end())
#define SORTMF(v,func) sort(v.begin(),v.end(),func)

//変数
ll N;
vector<ll> vec;

//解法
void solve() {

	vector<ll> hi(N,0);
	ll ans = 0;
	bool flag = false;

	int maxhi = MAX(vec);

	for (int nowLevel = 1; nowLevel <= maxhi; nowLevel++) {

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

			if (vec[nowPos] > hi[nowPos]) {
				hi[nowPos]++;
				flag = true;
			}
			else {
				if (flag == true) ans++;
				flag = false;
			}

		}

		if (flag == true) ans++;
		flag = false;

	}

	cout << ans;

	return;
}

int main() {
	//入力

	cin >> N;
	vec.resize(N);
	rep(i, N) cin >> vec[i];

	solve();
	//cout << endl;
	return 0;
}

Measured memory_bytes: 256
N,M,X = map(int,input().split())
CA = [list(map(int,input().split())) for _ in range(N)]
ans = 10**9

for i in range(2**N):
  cost = 0
  skill = [0]*M
  cnt = 0
  for j in range(N):
    if (i>>j)&1 == 1:
      for k in range(M):
        skill[k] += CA[j][k+1]
      cost += CA[j][0]
  for l in range(M):
    if skill[l] >= X:
      cnt += 1
    if cnt == M:
      ans = min(ans,cost)
if ans == 10**9:
  print(-1)
else:
  print(ans)

Measured memory_bytes: 9216
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<string>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<iostream>
#include<algorithm>
#include<unordered_map>
#include<unordered_set>
#define PI acos(-1)
#define pb push_back
#define all(x) x.begin(),x.end()
#define INF 0x3f3f3f3f
#define dd(x) cout<<#x<<" = "<<x<<","
#define de(x) cout<<#x<<" = "<<x<<"\n"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int N=1e6+5;
int a[N];
int main()
{
	int n,k;
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
	}
	sort(a+1,a+n+1);
	int ans=0;
	for(int i=1;i<=k;i++){
		ans+=a[i];
	}
	printf("%d",ans);
}


Measured memory_bytes: 3724
K = int(input())
N = 50
A = [i for i in range(N)]

q = K // N
r = K % N

A = [a+q for a in A]
for i in range(r):
  A[i] += N
  for j in range(N):
    if i != j:
      A[j] -= 1

print(N)
for i in range(N):
  if i != 0:
    print(" ", end="")
  print(A[i], end="")
print("")

Measured memory_bytes: 3064
import math

def makelist(n, m):
    return [[0 for _ in range(m)] for _ in range(n)]

# 
# a, b = list(map(int, input().split()))
# s = input()

ans = "No"

n = int(input())
for i in range(1, 10):
    for j in range(1, 10):
        if i * j == n:
            ans = "Yes"

print(ans)


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

int main(void){
  string S;
  string T;
  cin >> S >> T;

  int lens = S.size();
  int lent = T.size();
  int can = true;
  for(int i = 0; i < lens; i++){
    if(S[i] != T[i]){
      can = false;
      break;
    }
  }

  if(lens == lent - 1 && can){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}



Measured memory_bytes: 3628
#include<iostream>
#include<string>
#include<typeinfo>
#include<vector>
#include<algorithm>
#include<map>
using namespace std;
int main()
{
	int N, x;
	cin >> N >> x;
	vector<int> a(N);

	for(int i=0; i<N; i++){
		cin >> a.at(i);
	}
	sort(a.begin(), a.end());

	int cnt=0;
	int i;
	for(i=0; i<N; i++){
		if(x>=a.at(i)){
			cnt++;
			x-=a.at(i);
		}else{
			break;
		}
	}
	if(x>0 && i==N){
		if(cnt){
			cnt--;
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}

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

    double ans = 2.0 * R * M_PI;
    cout<<std::fixed<<std::setprecision(10);
    cout << ans << endl;
}


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

using namespace std;
typedef long long ll;

int main(){
    ll n, k;
    cin >> n >> k;
    vector<ll> v(n);
    for (int i = 0; i < n; i++)
    {
        cin >> v[i];
    }
    sort(v.begin(), v.end());
    ll sum = 0;
    for (int i = 0; i < n-k; i++)
    {
        sum += v[i];
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<string>
using namespace std;
#define int long long
#define rep(i,n) for(int i = 0; i < n; i++)
#define INF (long long)(1e17)
#define MOD (int)(1e9+7)
#define MAX_N 103
#define MAX_V 10
#define MAX_M 101
#define yn(f) (f?"Yes":"No")
#define YN(f) (f?"YES":"NO")
#define pro "はいプロ　世界一○○が上手　○○界のtourist　○○時代の終焉を告げる者　実質○○　○○するために生まれてきた男"


signed main(){
	int w, h, ans = 0;
	int temp[20][20] = {}, mi[20] = {}, a[250][250];
	cin>>h>>w;
	rep(i,10){
		rep(j,10){
			cin>>temp[i][j];
			mi[j] = INF;
		}
	}
	rep(i,h){
		rep(j,w){
			cin>>a[i][j];
		}
	}
	mi[1] = 0;
	rep(k,10){
		for(int i = 0; i < 10; i++){
		// mi[i] = temp[i][1];
			for(int j = 0; j < 10; j++){
			
				//cout<<i<<" "<<j<<" "<<mi[j]<<" "<<temp[j][1]<<" "<<mi[i]<<endl;
				mi[i] = min(mi[j]+temp[i][j],mi[i]);
			
			}//cout<<mi[i]<<endl;
		}
	}
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			if(a[i][j] != -1) ans += mi[a[i][j]];
		}
	}
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    int sum1=0,sum2=0;
    if(a==5) sum1++;
    else if(a==7) sum2++;
    if(b==5) sum1++;
    else if(b==7) sum2++;
    if(c==5) sum1++;
    else if(c==7) sum2++;
    if(sum1==2&&sum2==1) printf("YES\n");
    else printf("NO\n");
    return 0;
}


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

int main(){
    int n,k;
    
  int num1=0;
 int num2=0;

  long long int num_end;
    
    
    cin>>n>>k;

    for(int i=1;i<=n;i++){
        if(i%k==0){
            num1++;
        }
        else if((2*i)%k==0){
            num2++;
        }
        
    }

    num_end=pow(num1,3)+pow(num2,3);

    cout<<num_end<<endl;
    return 0;

    

    
}

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

using namespace std;

using ll = long long;
using ull = unsigned long long;

int main(int argc, char const *argv[]) {
	ll a,b,c,k;
	std::cin >> a >> b >> c >> k;
	if (k % 2 == 0) {
		std::cout << a - b << '\n';
	}
	else {
		std::cout << b - a << '\n';
	}
	return 0;
}


Measured memory_bytes: 256
//48
#include<iostream>

using namespace std;

int main(){
  for(int b,r,g,c,s,t;cin>>b>>r>>g>>c>>s>>t,b|r|g|c|s|t;){
    cout<<(15+16*5)*b+(15+16*3)*r+7*g+2*c+3*s-t*3+100<<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <iomanip>
#include <limits>
#include <thread>
#include <utility>
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <cmath>
#include <numeric>
#include <cassert>
#include <random>
#include <chrono>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <list>
#include <functional>
#include <bitset>
#include <complex>
#include <tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long double D;
typedef complex<D> P;
const ll E = 1e18 + 7;
const ll MOD = 1000000007;
#define REP(i, a, b) for (int i = a; i < b; i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define fill(x, y) memset(x, y, sizeof(x))
#define pcnt __builtin_popcount
#define buli(x) __builtin_popcountll(x)
#define pb push_back
#define mp make_pair
#define F first
#define S second
template <class... A>
void prints() { cout << endl; }
template <class... A>
void prints_rest() { cout << endl; }
template <class T, class... A>
void prints_rest(const T &first, const A &... rest) { cout << " " << first; prints_rest(rest...); }
template <class T, class... A>
void prints(const T &first, const A &... rest) { cout << first; prints_rest(rest...); }

template <class T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

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

    int N;
    cin >> N;
    int P[N];
    rep (i, N) cin >> P[i];

    int ans = 0;
    REP(i, 1, N-1) {
        if ( P[i-1] < P[i] && P[i] < P[i+1] ) {
            ans++;
        }
        else if (P[i-1] > P[i] && P[i] > P[i+1])
        {
            ans++;   
        }
    }

    prints(ans);

    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
int main(void) {
  int a, b, i;
  scanf("%d%d", &a, &b);
    if (a <= b){
        for(i = 0; i < b; i++){
            printf("%d", a);
        }
    }else {
        for(i = 0; i < a; i++){
            printf("%d", b);
        }
    }
    printf("\n");
  
}


Measured memory_bytes: 1708
c1 = list(map(int,input().split()))
c2 = list(map(int,input().split()))
c3 = list(map(int,input().split()))
print ("Yes") if c1[0]-c1[1] == c2[0]-c2[1] == c3[0]-c3[1] and c1[1]-c1[2] == c2[1]-c2[2] == c3[1]-c3[2] else print ("No")


Measured memory_bytes: 9176
#include<bits/stdc++.h>
using namespace std;
vector<int>par;
vector<int>W;
int root(int v) {
  if (v == par[v]) return v;
  int r = root(par[v]);
  W[v] += W[par[v]];
  return par[v] = r;
}
int wei(int v) {
  int k = root(v);
  return W[v];
}
//W[a] - W[b] = w 
int unit(int a, int b, int w) {
  w += wei(b);
  w -= wei(a);
  b = root(b);
  a = root(a);
  par[a] = b;
  W[a] = w;
}
bool same(int a, int b) {
  return root(a) == root(b);
}
int dif_w(int a, int b) {
  return wei(a) - wei(b);
}
int main () {
  int N, M;
  cin >> N >> M;
  par.resize(N);
  W.resize(N);
  for (int i = 0; i < N; i ++) {
    par[i] = i;
    W[i] = 0;
  }
  for (int i = 0; i < M; i ++) {
    int l, r, d;
    cin >> l >> r >> d;
    l --;
    r --;
    if (same(l, r)) {
      //cout << dif_w(r, l) << endl;
      if (dif_w(r, l) != d){
        cout << "No" << endl;
        return 0;
      }
    }
    else unit(r, l, d);
    //cout << i << endl;
  }
  cout << "Yes" << endl;
}



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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n;
  
  vector<int> a(n);
  map<int, int> mp;
  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
    mp[a.at(i)]++;
  }
  
  sort(a.begin(), a.end());
  
  if (mp.size() >= 3 || a.back() - a.front() >= 2) {
    cout << "No\n";
  }
  else if (mp.size() == 1) {
    int x = a.front();
    if (x == n - 1 || n / 2 >= x) {
      cout << "Yes\n";
    }
    else {
      cout << "No\n";
    }
  }
  else {
    int x = a.front(), y = a.back();
    if (mp[x] < y && (y - mp[x]) <= mp[y] / 2) {
      cout << "Yes\n";
    }
    else {
      cout << "No\n";
    }
  }
}

Measured memory_bytes: 5376
use std::io::Read;

fn run() {
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    let n: usize = it.next().unwrap().parse().unwrap();
    let w: usize = it.next().unwrap().parse().unwrap();
    let mut dp = vec![0u64; w + 1];
    for _ in 0..n {
        let a: usize = it.next().unwrap().parse().unwrap();
        let b: u64 = it.next().unwrap().parse().unwrap();
        for i in (a..(w + 1)).rev() {
            dp[i] = std::cmp::max(dp[i], dp[i - a] + b);
        }
    }
    let ans = dp[w];
    println!("{}", ans);
}

fn main() {
    run();
}

Measured memory_bytes: 4352
a, b, c, d = map(int, input().split())

if b < 0 and d < 0:
    print(a * c)
elif a < 0 and c < 0:
    if a < 0 and c < 0:
        if a * c < b * d:
            print(b * d)
        else:
            print(a * c)
    else:
        print(b * d)
elif b < 0:
    print(b * c)
elif d < 0:
    print(a * d)
else:
    print(b * d)

Measured memory_bytes: 61656
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl
int gcd(int a,int b){
    if(a<=0||b<=0){
        return 0;
    }
    if(a<b)swap(a,b);
    int r=a%b;
    while(r){
        a=b;
        b=r;
        r=a%b;
    }
    return b;
}


signed main(void){
    int a,b;
    cin >> a >> b;
    cout << a*b/gcd(a,b) << endl;
    return 0;
}



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

using ll =  long long;
using pint =  pair<int,int>;

#define INF 99999999
#define rep(i,n) for(int (i)=0,temp=(int)(n);(i)<temp;++(i)) 
#define repi(i,start,end) for(int (i)=(start),temp=(int)(end);i<(end);++(i))
#define rfor(v,x) for(const auto& (x) : (v)) //xは値を表す
#define all(x) (x).begin(),(x).end()
#define SORT(v, n) sort((v), (v)+(n))
#define vsort(v) sort((v).begin(), (v).end())
#define vfsort(v,lambda) sort(all((v)),(lambda))
#define vint vector<int>
#define vvint vector<vector<int>> //vvint v(n,vint(n))のように宣言できる
#define vin(v) rep(i,(v).size()) {cin >> (v)[i];}
//最終奥義
//#define int long long
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 ctoi(char c) {return c-'0';}
//lambda式 -> [&](int x, int y){return x<y;}
//vector内の重複を削除-> v.erase(unique(all(v)),v.end());

signed main(void){
  int n;cin>>n;
  string s;cin>>s;
  int ans=0;
  char prev=s[0];
  repi(i,1,n){
    if(prev!=s[i]){
      ans++;
    }
    prev=s[i];
  }
  ans++;
  cout << ans << endl;

}


Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main()
{
	int r, c;
	int A[101][101] = {};
	int i, j;

	cin >> r >> c;

	for (i = 0; i < r; i++)
	{
		for (j = 0; j < c; j++)
		{
			cin >> A[i][j];
			A[i][c] += A[i][j];
			A[r][j] += A[i][j];
			A[r][c] += A[i][j];
		}
	}

	for (i = 0; i <= r; i++)
	{
		for (j = 0; j <= c; j++)
		{			
			cout << A[i][j];
			if (j != c)
				cout << " ";
		}
		cout << endl;
	}
}

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

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

	cin >> a;
	cin >> b;
	cin >> c;

	if ((a<b) && (b<c)) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}



Measured memory_bytes: 3108
N = int(input())
T,A = map(int,input().split())
H = list(map(int,input().split()))

a =0
h = len(H)
b =[]

for i in range(h):
    a = A - (T - H[i]*(0.006))
    if a >= 0:
        b.append(a)
    else:
        b.append(-a)

c = min(b)

print(b.index(c)+1)


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (sc.hasNext()) {
			String input = sc.nextLine();
			String[] array = input.split(" ");
			int h = Integer.parseInt(array[0]);
			int w = Integer.parseInt(array[1]);
			if (h == 0 && w == 0) {
				System.exit(0);
			}
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					if (i == 0 || i == h - 1 || j == 0 || j == w - 1) {
						System.out.print("#");
					} else {
						System.out.print(".");
					}
				}
				System.out.print("\n");
			}
			System.out.print("\n");

		}
	}
}

Measured memory_bytes: 35876
n = int(input())
s = list(input())[::-1]
result = 0
for i in range(1000):
    x = format(i, "03")
    j = 0
    p = 0
    while p < n:
        if s[p]==x[j]:
            j += 1
            if j == 3:
                result += 1
                break
        p += 1

print(result)

Measured memory_bytes: 42608
#define int long long

time[3000], umami[3000], n, t, dp1[3000][3000], dp2[3000][3000], max;

main ()
{
    scanf("%lld %lld", &n, &t);

    for(int i = 0; i < n; i++) scanf("%lld %lld", &time[i], &umami[i]);

    /* dp */
    for(int tt = 0; tt < t; tt++)
    {
        for (int nn = 0; nn < n; nn++)
        {
            int taberu = 0, tabenai = 0;

            if (tt >= time[nn])
            {
                taberu += umami[nn];
                if (nn > 0) taberu += dp1[tt - time[nn]][nn - 1];
            }

            if (nn > 0)
            {
                tabenai += dp1[tt][nn - 1];
            }

            dp1[tt][nn] = taberu > tabenai ? taberu : tabenai;
        }

        for (int nn = n - 1; nn >= 0; nn--)
        {
            int taberu = 0, tabenai = 0;

            if (tt >= time[nn])
            {
                taberu += umami[nn];
                if (nn < n - 1) taberu += dp2[tt - time[nn]][nn + 1];
            }

            if (nn < n - 1)
            {
                tabenai += dp2[tt][nn + 1];
            }

            dp2[tt][nn] = taberu > tabenai ? taberu : tabenai;
        }
    }

    for (int tt = 0; tt < t; tt++)
    {
        for (int nn = 0; nn < n; nn++)
        {
            int score = umami[nn];
            if (nn > 0) score += dp1[tt][nn - 1];
            if (nn < n - 1) score += dp2[t - 1 - tt][nn + 1];
            if (score > max) max = score;
        }
    }

    printf("%lld\n", max);
}


Measured memory_bytes: 70528
N, K = map(int, input().split())
H = [int(input()) for i in range(N)]

H.sort()
ans = 10**9
for i in range(N-K+1):
    if (H[i+K-1]-H[i] < ans):
        ans = H[i+K-1]-H[i]

print(ans)

Measured memory_bytes: 7508
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <unordered_map>

using namespace std;

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

int sum[100000];

int main(){
    int H, W, D;
    cin >> H >> W >> D;
    vector<vector<int>> A(H, vector<int>(W));
    for(int i = 0; i < H; ++i){
        for(int j = 0; j < W; ++j){
            cin >> A[i][j];
        }
    }
    int Q;
    cin >> Q;
    vector<int> L(Q), R(Q);
    for(int i = 0; i < Q; ++i){
        cin >> L[i] >> R[i];
    }
    
    // キーに対応する座標を格納するコンテナ
    vector<P> coord(H * W + 1);
    for(int i = 0; i < H; ++i){
        for(int j = 0; j < W; ++j){
            coord[A[i][j]] = P(i + 1, j + 1);
        }
    }
    
    for(int i = H * W - D + 1; i <= H * W; ++i){
        int now = i;
        while(now > D){
            int temp = sum[now];
            P p1 = coord[now];
            now -= D;
            P p2 = coord[now];
            
            sum[now] = temp + abs(p2.first - p1.first) + abs(p2.second - p1.second);
        }
    }
    
    for(int i = 0; i < Q; ++i){
        cout << sum[L[i]] - sum[R[i]] << endl;
    }
}

Measured memory_bytes: 3328
// Undone
#include <bits/stdc++.h>
using namespace std;
int H, W; 
char grid[2000][2000];
int main() {
  cin >> H >> W;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> grid[i][j];
    }
  }

  int ans = 0, found = 0;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (grid[i][j] != 'B') continue;
      for (int k = H-1; k >= 0; k--) {
        for (int l = W-1; l >= 0; l--) {
          if (grid[k][l] != 'B') continue;
          ans = max(ans, abs(i-k)+abs(j-l));
        }
      }
    }
  }
  cout << ans << endl;
}




Measured memory_bytes: 3144
N, M = map(int, input().split())
L, R = [], []
low = -float('INF')
high = float('INF')
for i in range(M):
    l, r = map(int, input().split())
    L.append(l)
    R.append(r)
    if l > low:
        low = l
    if r < high:
        high = r
print(max(0, high - low + 1))


Measured memory_bytes: 10996
#include <bits/stdc++.h>
using namespace std;
int main() {
	int a, b, c;
	for (a=0; a<10000; a++ ){
		cin >> b >> c;
		if ( b == 0&&c == 0) break;
		else {
			if ( b<=c ){cout<< b << " " << c << endl;}
			else {
				cout<< c << " " << b << endl;
				}
			}
	}
	return 0;
}



Measured memory_bytes: 3088
using System;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
using Debug = System.Diagnostics.Debug;
using LayoutKind = System.Runtime.InteropServices.LayoutKind;
using StructLayoutAttribute = System.Runtime.InteropServices.StructLayoutAttribute;
using FieldOffsetAttribute = System.Runtime.InteropServices.FieldOffsetAttribute;


static class P
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        var a = Console.ReadLine().Split().Select(long.Parse).OrderBy(x => x).ToArray();
        long current = a.Sum();
        long max = current;
        for (int i = 1; i < a.Length; i += 2)
        {
            a[i - 1] *= -1;
            a[i] *= -1;
            current += (a[i - 1] + a[i]) * 2;
            max = Max(max, current);
        }
        Console.WriteLine(max);
    }
}


Measured memory_bytes: 34140
n, d = map(int, input().split())
x = [list(map(int, input().split())) for i in range(n)]

ans = 0
for i in range(n):
    for j in range(n-i-1):
        j += 1+i
        dis = 0

        for rep in range(d):
            dis += abs(x[i][rep] - x[j][rep])**2

        dis **= 0.5

        if dis == dis//1:
            ans += 1

print(ans)


Measured memory_bytes: 38608
#include <cstdio>

int main(int argc, const char * argv[]) {
    
    int n,a,b,ans=0;
    
    scanf("%d %d %d",&n,&a,&b);
    
    for(int i=1;i<=n;i++){
        
        int tmp = i;
        int sum = 0;
        while(tmp){
            sum += tmp%10;
            tmp/=10;
        }
        if(a<=sum && sum<=b) ans+= i;
    }
    printf("%d\n",ans);
    return 0;
}

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

int main() {
  string s; cin >> s;
  int first_number = stoi(s.substr(0, 2));
  int second_number = stoi(s.substr(2, 2));
  bool is_month_first = 0 < first_number && first_number < 13;
  bool is_month_second = 0 < second_number && second_number < 13;
  cout << (is_month_first && is_month_second ? "AMBIGUOUS" :
          (is_month_first ? "MMYY" :
          (is_month_second ? "YYMM" :
          "NA"))) << endl;
}

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

using namespace std;
mt19937 rng;

int cost(vector<int> heights, int k)
{
    int n = heights.size();
    if (n < 2) return 0;

    vector<int> cost(n + k, numeric_limits<int>::max());
    cost[0] = 0;

    for (int i = 0; i < n; ++i)
    {
        for (int j = 1; j <= k; ++j)
        {
            cost[i+j] = min(cost[i+j], cost[i] + abs(heights[i+j] - heights[i]));
        }
    }
    
    return cost[n-1];
}

int main(void)
{
	int n, k; cin >> n >> k;
	vector<int> h(n);
	for (int i = 0; i < n; ++i) cin >> h[i];
    cout << cost(h, k) << endl;
  	return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::cerr;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int n; scanf("%d", &n);
	std::vector<int> d(n);
	std::vector<i64> c(n);
	for(int i = 0; i < n; i++) scanf("%d%lld", &d[i], &c[i]);
	
	// solve
	std::vector<i64> T(10, 0), S(10, 0);
	for(int D = 1; D < 10; D++) {
		int now = D;
		while(true) {
			if(now > 9) now = now % 10 + now / 10;
			else {
				now = now + D;

				T[D]++;
			}

			S[D]++;
			if(now == D) break;
		}
	}

	//~ for(auto v: T) cout << v << " "; cout << endl;
	//~ for(auto v: S) cout << v << " "; cout << endl;
	
	i64 ans = -1, now = 0;
	for(int i = 0; i < n; i++) {
		if(d[i] == 0) {
			ans += c[i];
		} else if(d[i] == 9) {
			ans += (c[i] - 1) * 2LL;

			int tan = 1;
			while(tan) {
				if(now > 9) now = now % 10 + now / 10;
				else {
					now = now + d[i];

					tan--;
				}
				ans++;
			}
		} else {
			int tan = 0;
			if(c[i] % T[d[i]]) {
				ans += c[i] / T[d[i]] * S[d[i]];
				tan = c[i] % T[d[i]];
			} else {
				ans += (c[i] / T[d[i]] - 1) * S[d[i]];
				tan = T[d[i]];
			}

			while(tan) {
				if(now > 9) now = now % 10 + now / 10;
				else {
					now = now + d[i];

					tan--;
				}
				ans++;
			}
		}
//		cout << i << ": " << ans << " " << now << endl;
	}
	if(now > 9) ans++;
	
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 2560
// ITP1_2_A Small, Large or Equal

#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  // 初期値
  int a, b; 
  cin >> a >> b;
  
  // Main loop
  if (a < b){
    cout << "a < b" << endl;
  } else if (a > b){
    cout << "a > b" << endl;
  } else if (a == b){
    cout << "a == b" << endl;
  }
   
  return 0;
}


Measured memory_bytes: 3024
while(1):
 num = 100009
 time = [0]*num

 n = int(input())
 if(n == 0): break

 for i in range(n):
  t = list(input().split())
  a_,b_ = t[0].split(':'),t[1].split(':')
  a = int(a_[0])*3600+int(a_[1])*60+int(a_[2])
  b = int(b_[0])*3600+int(b_[1])*60+int(b_[2]) -1
  #print(a)
  #print(b)

  time[a] += 1
  time[b+1] -= 1

 ans = 1
 for i in range(num):
  if(i != 0): time[i] += time[i-1]
  ans = max(ans,time[i])
 print(ans)


Measured memory_bytes: 9800
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;

/*

*/

template<typename T_n>
struct segment_tree{
	typedef struct node_{
		T_n value;
		int left,right; //[left,right)
		struct node_ *left_child,*right_child;
	}* node;
	node parent_node = new node_;
	T_n default_value=1e18;//範囲外の場合の評価値
	T_n eval(T_n a, T_n b){//segment_treeの評価関数
		return min(a,b);
	}
	T_n back_propagation(T_n before, T_n after){//伝播する値を計算
		return min(before,after);
	}
	segment_tree(int left,int right){//どんな範囲でも作れる
		make_segtree_(parent_node,left,right);
	};
	void make_segtree_(node p,int left,int right){
		p->left=left;
		p->right=right;
		p->value=default_value;
		if(left+1!=right){
			node q=new node_, r=new node_;
			p->left_child=q;
			p->right_child=r;
			make_segtree_(q,left,(left+right)/2);
			make_segtree_(r,(left+right)/2,right);
		}else{//要素数が1個
			p->left_child=NULL;
			p->right_child=NULL;
		}
	}
	T_n query(int left,int right){//[left,right)
		return query_(parent_node,left,right);
	}
	T_n query_(node p,int left,int right){
		if(p->right<=left || right<=p->left)return default_value;
		if(left<=p->left && p->right<=right)return p->value;
		return eval( query_(p->left_child,left,right), query_(p->right_child,left,right) );
	}
	void change(int pos,T_n value){
		change_(parent_node,pos,value);
	}
	T_n change_(node p,int pos,T_n value){
		//上に差分を伝播
		T_n diff;
		if(p->left<=pos && pos<p->right){//入っているなら
			if(p->left==pos && pos+1==p->right){//justなら
				diff = back_propagation(p->value,value);
			}else{
				diff = eval(change_(p->left_child,pos,value), change_(p->right_child,pos,value));
			}
			p->value = eval(p->value,diff);
		}else{
			diff=default_value;
		}
		return diff;//差分が上に伝播する
	}
};

int main(void){
	ll n,x,a[2010],ok=0,ng=1e9+7,ans=1e18;
	segment_tree<ll> f(0,2010);
	cin>>n>>x;
	rep(i,n){
		cin>>a[i];
		f.change(i,a[i]);
	}
	reg(k,0,n){//魔法を使う回数
		ll sum=0;
		rep(i,n){
			if(i-k>=0){
				sum+=f.query(i-k,i+1);
			}else{
				sum+=min(f.query(0,i+1),f.query(n-(k-i),n+1));
			}
		}
		ans=min(ans,x*k+sum);
	}
	cout<<ans<<endl;
	return 0;
}

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

signed main(void)
{
	string s;
	cin >> s;
	if ("YAKI" == s.substr(0, 4))
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}


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

int max(int a, int b){
	if(a > b){
		return a;
	}
	else{
		return b;
	}
}

int main(){
	int N, i, m = 0, d = 0, ans = 0;
	scanf("%d", &N);
	int *a = (int *)malloc(sizeof(int) * N);
	for(i = 0; i < N; i++){
		scanf("%d", &a[i]);
	}
	for(i = 1; i < N; i++){
		if(m == 1){
			if(a[i] > a[i - 1]){
				d++;
			}
			else if(a[i] < a[i - 1]){
				ans = max(ans, d);
				m = -1;
				d = 1;
			}
		}
		else if(m == -1){
			if(a[i] < a[i - 1]){
				d++;
			}
			else if(a[i] > a[i - 1]){
				ans = max(ans, d);
				m = 1;
				d = 1;
			}
		}
		else{
			if(a[i] > a[i - 1]){
				m = 1;
				d = 1;
			}
			else if(a[i] < a[i - 1]){
				m = -1;
				d = 1;
			}
		}
	}
	ans = max(ans, d);
	printf("%d\n", ans + 1);
	return 0;
}

Measured memory_bytes: 2228
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>

#define INF 1000000021
#define MOD 1000000007
#define pb push_back
#define sqr(a) (a)*(a)
#define M(a, b) make_pair(a,b)
#define T(a, b, c) make_pair(a, make_pair(b, c))
#define F first
#define S second
#define all(x) (x.begin(), x.end())
#define deb(x) cerr << #x << " = " << x << '\n'
#define N 222222

using namespace std;
//using namespace __gnu_pbds;

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

const ld pi = 2 * acos(0.0);
template<class T> bool umin(T& a, T b){if(a>b){a=b;return 1;}return 0;}
template<class T> bool umax(T& a, T b){if(a<b){a=b;return 1;}return 0;}
template<class T, class TT> bool pal(T a, TT n){int k=0;for(int i=0;i<=n/2;i++){if(a[i]!=a[n-i-1]){k=1;break;}}return k?0:1;}

//int month[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};
ll a[N];
int main()
{
	int n;
	cin >> n;
	map<ll, ll> mp;
	for(int i = 1; i <= n; i ++)
	{
		cin >> a[i];
		mp[a[i]] ++;
	}
	ll s = 0;
	for(auto it : mp)
		s += (it.S*(it.S-1)) / 2;
	for(int i = 1; i <= n; i ++)
	{
		ll q = mp[a[i]];
		ll r = (q*(q - 1)) / 2;
		s -= r;
		q --;
		cout << s + (q*(q - 1)) / 2 << '\n';
		s += r;
	}





	





	getchar();
	getchar();
	return 0;
	//ios::sync_with_stdio(false);
	//cin.tie(0);
}

Measured memory_bytes: 11008
n,k=map(int,input().split())
s=input()
from itertools import groupby as gb
var=[len(list(b)) for a,b in gb(s)]
ans=n-len(var)
G=len(var)
if s[0]==s[-1]:
    t=G//2
    h=G-G//2+2
else:
    t,h=G-G//2,G//2+2
#print(f"{t=},{h=},{k=},{ans=},")
if k>min(t,h):
    print(n-1)
elif k==min(t,h):
    print(n-1)
else:
    print(ans+2*k)

Measured memory_bytes: 3976
#include<stdio.h>
#include<string.h>
#include<stdlib.h>

int main(void){
  int N, K;
  char *S;
  scanf("%d %d", &N, &K);
  S = (char*)malloc(N * sizeof(char));  /* メモリ領域の確保 */
  scanf("%s", S);
  
  S[K-1] += 32;
  printf("%s\n", S);
  free(S);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h> 
#define FOR(i,a,b) for(int i=(a);i<=(b);++i) 
#define RFOR(i,a,b) for(int i=(a);i>=(b);--i) 
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n);i>0;--i)
#define CI cin>> 
#define CO cout<<
#define EN <<endl 
#define all(x) (x).begin(),(x).end() 
#define asn ans
using namespace std;
template <typename T> istream& operator >> (istream& is, vector<T>& vec) { for (T& x : vec) is >> x; 	return is; }
using ll = long long;

int main() {
	string s; CI s;
	if (s[0] != s[1] && s[1] != s[2] && s[2] != s[0])CO "Yes" EN;
	else CO "No" EN;

	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <random>
#include <cfloat>
#define norm(X) ((X) * (X))
using namespace std;
template<class T, class Compare = less<T> >
using MaxHeap = priority_queue<T, vector<T>, Compare>;
template<class T, class Compare = greater<T> >
using MinHeap = priority_queue<T, vector<T>, Compare>;
using llong = long long;

const llong s = 1000000;
const double R = 1e11;
llong n;
double px[105];
double py[105];
llong cnt[105];
double x, y;
double r;
double sx, sy;
llong indx;

int main() {
    
    cin >> n;
    for (llong i = 0; i < n; i++) {
        cin >> px[i];
        cin >> py[i];

        sx += px[i];
        sy += py[i];
    }
    sx /= n;
    sy /= n;

    for (llong i = 1; i <= s; i++) {
        x = R * cos(i * 2.0 * M_PI / s) + sx;
        y = R * sin(i * 2.0 * M_PI / s) + sy;
        indx = 0;

        r = 1e32;

        //cout << x << ' ' << y << endl;
        for (llong j = 0; j < n; j++) {
            double d = norm(x - px[j]) + norm(y - py[j]);

            if (d < r) {
                indx = j;
                r = d;
            }
        }

        cnt[indx]++;
    }

    for (llong i = 0; i < n; i++) {
        printf("%.*lf\n", DBL_DIG, (double)cnt[i] / (double)s);
    }

    return 0;
}


Measured memory_bytes: 256
def main():
    import heapq
    n,m = map(int,input().split())
    a = list(map(int,input().split()))
    a = sorted([-i for i in a])
    for i in range(m):
        x = heapq.heappop(a)
        if x%2 == 0:
            x = int(x//2)
        else:
            x = int(x//2)+1
        heapq.heappush(a,x)
    print(sum(a)*(-1))
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 14180
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class D { public static void Main() => (new Solver()).Solve(); }

public class Solver
{
	public void Solve()
	{
		long A = GetLong();
		long B = GetLong();
		long E = GetLong();

		long G = A + B - E;
		long F = A + G - E;
		long C = A + E - F;
		long D = B + C - G;
		long H = A + E - G;
		long I = B + E - G;

		WriteLine($"{A} {B} {C}\n{D} {E} {F}\n{G} {H} {I}");
	}
}

public static class MyIO
{
	private static string[] args = new string[0];
	private static int cnt = 0;
	private static IEnumerable<string> getArgs(long N) => Range(0, N).Select(_ => getArg());
	private static string getArg()
	{
		if(cnt == args.Length) { args = Console.ReadLine().Split(); cnt = 0; }
		return args[cnt++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static decimal GetDecimal() => decimal.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(long N) => getArgs(N).Select(int.Parse).ToArray();
	public static long[] GetLongs(long N) => getArgs(N).Select(long.Parse).ToArray();
	public static double[] GetDoubles(long N) => getArgs(N).Select(double.Parse).ToArray();
	public static decimal[] GetDecimals(long N) => getArgs(N).Select(decimal.Parse).ToArray();
	public static string[] GetStrings(long N) => getArgs(N).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) < 0) x = y; }
	public static void chmin<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) > 0)	x = y; }
	public static void swap<T>(ref T x, ref T y) { T tmp = x; x = y; y = tmp; }
	public static long rightShift(long x, long y) => (x >> (int)y);
	public static long leftShift(long x, long y) => (x << (int)y);
	public static bool contains(long s, long x) => (rightShift(s, x) & 1L) == 1L;
	public static long gcd(long x, long y) => (y == 0) ? x : gcd(y, x % y);
	public static long lcm(long x, long y) => (x / gcd(x,y)) * y;	
	public static IEnumerable<int> Range(long start, long count) => Enumerable.Range((int)start, (int)count);
	public static void Sort(this List<string> source) => source.Sort(StringComparer.Ordinal);
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define cans cout << ans << endl
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
typedef long long ll;


int main(){
    int n;
    cin >> n;
    int now = 0;
    rep(i,n){
        int a;
        cin >> a;
        now = __gcd(a,now);
    }
    cout << now << endl;
    return 0;
}

Measured memory_bytes: 3408
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {

        Scanner sc = new Scanner(System.in);
        
        int X = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();
        int ans = X - A;
        
        while(ans - B >= 0) ans -= B;
        
        System.out.println(ans);
    }
}
 

Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
//typedef tree <int,null_type,less <int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
// #include <ext/rope>
// using namespace __gnu_cxx;
typedef long long int ll;
typedef long double ld;
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define rep(g, i, n) for (ll g = i; g < n; g++)
#define rev(g, n, i) for (ll g = n - 1; g >= i; g--)
#define all(v) v.begin(), v.end()
#define pb push_back
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define ve vector
#define lb lower_bound
#define ub upper_bound
#define bb break
#define cc continue
#define rem 1000000007
#define PI 3.141592653589793238462643383279502
ll power(ll x, ll y, ll p) 
{ 
    ll res = 1;      // Initialize result 
    x = x % p;  // Update x if it is more than or 
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1; // y = y/2 
        x = (x*x) % p; 
    } 
    return res; 
} 
ll modInverse(ll n, ll p) 
{ 
    return power(n, p-2, p); 
} 
struct point
{
    ll x,y;
};
int main()
{
    FAST
    // freopen("input1.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    /*ll tests;
    cin>>tests;
    rep (gg,0,tests)
    {}*/
    ll n;
    cin>>n;
    set<string> s1;
    rep (i,0,n)
    {
        string s;
        cin>>s;
        s1.insert(s);
    }
    cout<<s1.size()<<"\n";
}


Measured memory_bytes: 19232
class Ntt:
    def __init__(self, mod=10**9+7, root=3):
        self.mod = mod
        self.roots = [pow(root, (mod - 1) >> i, mod) for i in range(24)]
        self.iroots = [pow(x, mod - 2, mod) for x in self.roots]
        
    def untt(self, a, n):
        for i in range(n):
            m = 1 << (n - i - 1)
            for s in range(1 << i):
                wn = 1
                s *= m * 2
                for p in range(m):
                    a[s + p], a[s + p + m] = (a[s + p] + a[s + p + m]) % self.mod,\
                                             (a[s + p] - a[s + p + m]) * wn % self.mod
                    wn = wn * self.roots[n - i] % self.mod
    
    def iuntt(self, a, n):
        for i in range(n):
            m = 1 << i
            for s in range(1 << (n - i - 1)):
                wn = 1
                s *= m * 2
                for p in range(m):
                    a[s + p], a[s + p + m] = (a[s + p] + a[s + p + m] * wn) % self.mod,\
                                             (a[s + p] - a[s + p + m] * wn) % self.mod
                    wn = wn * self.iroots[i + 1] % self.mod
    
        inv = pow((self.mod + 1) // 2, n, self.mod)
        for i in range(1 << n):
            a[i] = a[i] * inv % self.mod
    
    def convolution(self, a, b):
        deg = len(a) + len(b) - 2
        n = deg.bit_length()
        N = 1 << n
        a += [0] * (N - len(a))
        b += [0] * (N - len(b))
        self.untt(a, n)
        self.untt(b, n)
        for i in range(N):
            a[i] = a[i] * b[i] % self.mod
        self.iuntt(a, n)
        return a[:deg + 1]


N, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
mod = 998244353

ntt = Ntt(mod=mod)
print(*ntt.convolution(a, b))


Measured memory_bytes: 183972
#include <stdio.h>
void output(int data[100], int n) {
	int i;
	const char *fmt = "%d";

	for (i = 0; i < n; i++) {
		printf(fmt, data[i]);
		fmt = " %d";
	}
	putchar('\n');
}

int main(void) {
	int n, i, j, data[100], key;

	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d", data+i);
	}
	output(data, n);
	for (j = 1; j < n; j++) {
		key = data[j];
		i = j - 1;
		while (i >= 0 && data[i] > key) {
			data[i+1] = data[i];
			i -= 1;
		}
		data[i+1] = key;
		output(data, n);
	}
	return 0;
}

Measured memory_bytes: 604
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define  fo(i,a,b) for(ll i=a;i<b;i++)
#define rfo(i,a,b) for(ll i=a;i>=b;i--)
#define fori(it, x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)

#define err() cout<<"----------"<<endl;
#define errA(A) for(auto i:A)   cout<<i<<" ";cout<<endl;
#define pb push_back
#define deb(x) cout<< #x << " = "<<x<<endl;
#define F first
#define S second
#define MP make_pair
#define all(x) (x).begin(), (x).end()
#define pi 3.141592653589
bool comp(ll a, ll b)
{
    return a>b;
}
void solve()
{
  ll n;
  cin>>n;
  ll a[n];
  fo(i,0,n)
  {
    cin>>a[i];
  }
  sort(a,a+n,comp);
  ll comfort=a[0],count=0,j=1;
  for(ll i=2;i<n;i++)
  {
    comfort+=a[j];
    count+=1;
    if(count==2)
    {
        count=0;
        j+=1;
    }
  }
  cout<<comfort<<endl;
}
int main()
{

    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
//  clock_t time_req;
//  time_req = clock();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }

// time_req = clock()-time_req;
//  cout<<"Time taken: "<<(float)time_req/CLOCKS_PER_SEC<<"s"<<endl;

    return 0;
}

Measured memory_bytes: 5168
/* ---------- STL Libraries ---------- */

// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

/* ---------- Namespace ---------- */

using namespace std;

/* ---------- Type Abbreviation ---------- */

using ll = long long;

template <typename T>
using PQ = priority_queue<T>;
template <typename T>
using GPQ = priority_queue<T, vector<T>, greater<T>>;

#define mp make_pair
#define mt make_tuple

/* ---------- conversion ---------- */

#define INT(c) static_cast<int>(c)
#define CHAR(n) static_cast<char>(n)
#define LL(n) static_cast<ll>(n)
#define DOUBLE(n) static_cast<double>(n)

/* ---------- container ---------- */

#define gsort(b, e) sort(b, e, greater<decltype(*b)>())

/* ----------- debug ---------- */

template <class T>
ostream& operator<<(ostream& os, vector<T> v) {
    os << "[";
    for (auto vv : v)
        os << vv << ",";
    return os << "]";
}

template <class T>
ostream& operator<<(ostream& os, set<T> v) {
    os << "[";
    for (auto vv : v)
        os << vv << ",";
    return os << "]";
}

template <class L, class R>
ostream& operator<<(ostream& os, pair<L, R> p) {
    return os << "(" << p.first << "," << p.second << ")";
}

/* ---------- Constants ---------- */

// const ll MOD = 1e9 + 7;
// const int INF = 1 << 25;
// const ll INF = 1LL << 50;
// const double PI = acos(-1);
// const double EPS = 1e-10;
// mt19937 mert(LL(time(0)));

/* ---------- Short Functions ---------- */

template <typename T>
inline T sq(T a) { return a * a; }

template <typename T>
T gcd(T a, T b) {
    if (a > b) return gcd(b, a);
    return a == 0 ? b : gcd(b % a, a);
}

template <typename T, typename U>
T mypow(T b, U n) {
    if (n == 0) return 1;
    if (n == 1) return b /* % MOD */;
    if (n % 2 == 0) {
        return mypow(b * b /* % MOD */, n / 2);
    } else {
        return mypow(b, n - 1) * b /* % MOD */;
    }
}

ll pcnt(ll b) {
    return __builtin_popcountll(b);
}

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */

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

    cout << "Christmas";
    while (D < 25) {
        cout << " Eve";
        ++D;
    }

    cout << endl;
    return 0;
}


Measured memory_bytes: 256