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

const int N = 2e5;

typedef pair<int,int> pii;

struct road{
	int s,t,x;
	int da,db;
};

int n,q;
road li[N+5];

bool cmp(road a, road b){
	return a.da < b.da;
}

priority_queue<pii> pend;
priority_queue<int> jar, delp;

int main(){
	scanf("%d%d",&n,&q);
	for(int i=1;i<=n;i++){
		scanf("%d %d %d",&li[i].s,&li[i].t,&li[i].x);
		li[i].da = li[i].s - li[i].x;
		li[i].db = li[i].t - li[i].x - 1;
	}
	sort(li+1,li+n+1,cmp);
	int idx = 1;
	for(int i=1;i<=q;i++){
		int D;
		scanf("%d",&D);
		while(idx <= n && D >= li[idx].da){
			jar.push(-li[idx].x);
			pend.push(make_pair(-li[idx].db,li[idx].x));
			idx++;
		}
		while(!pend.empty() && D > -pend.top().first){
			delp.push(-pend.top().second);
			pend.pop();
		}
		while(!delp.empty() && delp.top() == jar.top()){
			delp.pop();
			jar.pop();
		}
		if(jar.empty()) printf("-1\n");
		else printf("%d\n",-jar.top());
	}
	return 0;
}


Measured memory_bytes: 9320
#include <bits/stdc++.h>
//#include <mylib.h>
using namespace std;
//cin.sync_with_stdio(false);

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define FOR_EQ(i,a,b) for(int i = (a); i <= (b); ++i)
#define FOR_RE(i,a,b) for(int i = (a); i > (b); --i)
#define rep(i,n) FOR(i,0,n)
#define rep_eq(i,n) FOR_EQ(i,0,n)
#define rep_re(i,n) FOR_RE(i,n,0)
//1個上から時計周り
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
//上右下左
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {1, 0, -1, 0};

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> Vector;
typedef vector<Vector>	DVector;
int n;

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    string s, t, ss, tt;
    cin >> s >> t;
    
    sort(s.begin(), s.end());
    
    sort(t.begin(), t.end());
    reverse(t.begin(), t.end());
    int judge;
    //cout << s << " " << t << endl;
    judge = s.compare(t);
    if(judge < 0)   cout << "Yes" << endl;
    else    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define db(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<'\n'
const int N = 1e6;

int main() {
    ios_base::sync_with_stdio(0);
    int a,b,n,p,T,cas=0;
    string s;
    cin>>n>>p>>s;
    ll res=0;
    if(p==2||p==5) {
        for(int i=0;i<n;++i) {
            if((s[i]-'0')%p==0) res+=i+1;
        }
    }
    else {
        map<int, int> mp;
        mp[0]=1;
        int pow10=1, r=0;
        for(int i=n-1;i>=0;--i) {
            r = (r + (s[i]-'0')*pow10)%p;
            res += mp[r];
            mp[r]++;
            pow10 = (pow10*10)%p;
        }
    }
    cout<<res<<endl;
    return 0;
}

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

template<typename T>
inline T pow(T a, long long n) {
    T ret = 1; while (n) { if (n & 1) ret *= a; n >>= 1; a *= a; }
    return ret;
}

int main() {
    int d, n; cin >> d >> n;
    cout << (n + (n - 1) / 99) * pow(100, d) << endl;
    return 0;
}


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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

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

  string s; cin >> s;
  int ans = 700;
  ans += 100 * (s[0] == 'o');
  ans += 100 * (s[1] == 'o');
  ans += 100 * (s[2] == 'o');
  cout << ans << endl;
}


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

struct test
{
	int tyukan;
	int kimatsu;
	int Tsuishi;
	char seiseki;
};

int main()
{
	test in[1000];
	int m, f, r;
	int count = 0;
	while (1)
	{
		cin >> m >> f >> r;
		if (m == -1 && f == -1 && r == -1)
		{
			break;
		}
		in[count].tyukan = m;
		in[count].kimatsu = f;
		in[count].Tsuishi = r;
		count++;
	}

	for (int i = 0; i < count; i++)
	{
		if (in[i].tyukan == -1 || in[i].kimatsu == -1)
		{
			in[i].seiseki = 'F';
		}
		else if (80 <= in[i].tyukan + in[i].kimatsu)
		{
			in[i].seiseki = 'A';
		}
		else if (65 <= in[i].tyukan + in[i].kimatsu && in[i].tyukan + in[i].kimatsu < 80)
		{
			in[i].seiseki = 'B';
		}
		else if (50 <= in[i].tyukan + in[i].kimatsu && in[i].tyukan + in[i].kimatsu < 65)
		{
			in[i].seiseki = 'C';
		}
		else if (30 <= in[i].tyukan + in[i].kimatsu && in[i].tyukan + in[i].kimatsu < 50)
		{
			if (50 <= in[i].Tsuishi)
			{
				in[i].seiseki = 'C';
			}
			else
			{
				in[i].seiseki = 'D';
			}
		}
		else if (in[i].tyukan + in[i].kimatsu < 30)
		{
			in[i].seiseki = 'F';
		}
	}
	for (int i = 0; i < count; i++)
	{
		cout << in[i].seiseki << endl;
	}
	return 0;
}

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

#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,b,a) for(int i = (b) - 1; i>= (a); i--)
#define ITER(it,a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a,value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define MP make_pair
#define PB push_back

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

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL) INF;

LL get(string s, int pref)
{
	LL res = 0;
	FOR (i, 0, pref)
	{
		res += s[i] - '0';
	}
	
	if (pref == SZ(s)) return res;
	if (s[pref] == '0') return -1;
	
	res += s[pref] - '0' - 1;
	FOR (i, pref + 1, SZ(s))
	{
		res += 9;
	}
	return res;
}

int main()
{
	//freopen("in.txt", "r", stdin);
	//ios::sync_with_stdio(false); cin.tie(0);
	
	string s;
	cin>>s;
	LL res = 0;
	
	FOR (i, 0, SZ(s) + 1)
	{
		res = max(res, get(s, i));
	}
	
	cout<<res<<endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
      	int n = sc.nextInt();
        int r = n % 1000;
		if (r == 0) {
			System.out.println(r);
		} else {
          	System.out.println(1000 - r);
        }
	}
}








Measured memory_bytes: 35896
def calc_time_to_next_station(t, c, s, i):
  if t <= s:
    return s + c
  else:
    f = lambda x, y: (x + y - 1) // y
    return f(t-s, i) * i + s + c  


def calc_needed_time(i, cost, start, interval):
  """
  calculate the needed time to reach n-th station when we are at i-th station 
  Args:
    i (int): 0-indexed number
    cost (list)
    start (list)
    interval (list)
  """
  if i == n - 1:
    return 0
  m = len(start)
  t = 0
  for j in range(i, m):
    t = calc_time_to_next_station(t, cost[j], start[j], interval[j])
  return t
 



n = int(input())
cost, start, interval = [], [], []
for _ in range(n-1):
  c, s, i = map(int, input().split())
  cost.append(c)
  start.append(s)
  interval.append(i)


for i in range(n):
  print(calc_needed_time(i, cost, start, interval))


Measured memory_bytes: 39920
import java.lang.Math.*

fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val happiness = Array(n) { IntArray(3) }
    for (i in 0 until n) {
        val tmp = readLine()!!.split(" ").map { it.toInt() }.toIntArray()
        happiness[i] = tmp
    }

    val dp = Array(n) { IntArray(3) }
    dp[0][0] = happiness[0][0]
    dp[0][1] = happiness[0][1]
    dp[0][2] = happiness[0][2]

    for (i in 1 until n) {
        dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + happiness[i][0]
        dp[i][1] = max(dp[i - 1][2], dp[i - 1][0]) + happiness[i][1]
        dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + happiness[i][2]
    }

    println(dp.last().max())
}

Measured memory_bytes: 80584
N, M = list(map(int, input().split()))
R = sorted([tuple(map(int, input().split())) for _ in range(M)])

ir = 0
d = N+1
ans = 0
for i in range(1, N):
    while ir<len(R) and R[ir][0]<=i:
       	d = min(d, R[ir][1])
        ir+=1

    if d==i+1:
        d = N+1
        ans += 1

print(ans)

Measured memory_bytes: 17796
x =int(input())

if 400 <= x <= 599:
    print(8)
elif 600 <= x <= 799:
    print(7)
elif 800 <= x <= 999:
    print(6)
elif 1000 <= x <= 1199:
    print(5)
elif 1200 <= x <= 1399:
    print(4)
elif 1400 <= x <= 1599:
    print(3)
elif 1600 <= x <= 1799:
    print(2)
elif 1800 <= x <= 1999:
    print(1)


Measured memory_bytes: 9180
n, m = map(int, input().split())
x = list(map(int, input().split()))
cnt = 0
if n > m:
    print(0)
    exit()
x.sort()
L = []
for i in range(m - 1):
    L.append(x[i + 1] - x[i])
L.sort()
L.reverse()
for i in range(n-1):
    L.pop(0)
print(sum(L))


Measured memory_bytes: 13968
n = int(input())
count = 0
times_count = 0
for i in range(n):
    d1, d2 = map(int, input().split())
    if d1 == d2:
        count += 1
    else:
        count = 0
    if count == 3:
        times_count += 1

if times_count == 0:
    print('No')
else:
    print('Yes')

Measured memory_bytes: 9152
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)

int main(){
	ll N;
	cin >> N;
	ll ans = N * (N - 1) / 2;
	cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

    int N = scanner.nextInt();
    int Ma = scanner.nextInt();
    int Mb = scanner.nextInt();
    int[] a = new int[N + 1];
    int[] b = new int[N + 1];
    int[] c = new int[N + 1];

    for (int i = 1; i <= N; i++) {
      a[i] = scanner.nextInt();
      b[i] = scanner.nextInt();
      c[i] = scanner.nextInt();
    }

    int INF = 1_000_000;
    int M = 400;
    int[][][] dp = new int[N + 1][M + 1][M + 1];
    for (int i = 0; i <= N; i++)
      for (int j = 0; j <= M; j++)
        for (int k = 0; k <= M; k++) dp[i][j][k] = INF;
    for (int i = 0; i <= N; i++) dp[i][0][0] = 0;

    for (int i = 1; i <= N; i++) {
      for (int j = 1; j <= M; j++) {
        for (int k = 1; k <= M; k++) {
          dp[i][j][k] = dp[i - 1][j][k];
          if(j >= a[i] && k >= b[i]) {
            dp[i][j][k] = Math.min(dp[i][j][k], dp[i - 1][j - a[i]][k - b[i]] + c[i]);
          }
        }
      }
    }

    //for (int i = 1; i <= N; i++) {
    //  System.out.printf("N = %d\n", i);
    //  for (int j = 1; j <= M; j++) {
    //    for (int k = 1; k <= M; k++) {
    //      if (dp[i][j][k] >= INF) System.out.print("∞ ");
    //      else System.out.printf("%d ", dp[i][j][k]);
    //    }
    //    System.out.println();
    //  }
    //}

    int min = INF;
    for (int i = 1; i <= M; i++)
      for (int j = 1; j <= M; j++)
        if (Ma * j == Mb * i) min = Math.min(min, dp[N][i][j]);

    if (min >= INF) {
      System.out.println(-1);
    } else {
      System.out.println(min);
    }
  }
}


Measured memory_bytes: 53240
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
#define FOR(i, m, n) for(ll i = m; i < (n); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vii = vector<vi>;
using pii = pair<int, int>; 
using vl = vector<ll>;
using vll = vector<vl>;
using pll = pair<ll, ll>;

int main() {
    string s;
    cin >> s;
    cout << s[0] << s[1] << s[2];
}

Measured memory_bytes: 3568
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <math.h>
#include <set>
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define P pair<int, int>

#define MOD 1000000007
#define INF 2147483647
#define NINF (-2147483647-1)
#define LLINF 9223372036854775807
using ll = long long;
using namespace std;

int main() {
    int N;
    string S;
    cin >> N >> S;
    vector<int> white(N + 1, 0), black(N + 1, 0);
    for (int i = 0; i < N; i++)
    {
        white[i + 1] = white[i];
        black[i + 1] = black[i];
        if (S[i] == '#') {
            black[i + 1]++;
        }
        else {
            white[i + 1]++;
        }
    }
    int ans = INF;
    for (int i = 0; i <= N; i++)
    {
        ans = min(ans, black[i] + white[N] - white[i]);
    }
    cout << ans << endl;
    getchar(); getchar();
    return 0;
}

Measured memory_bytes: 2180
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <complex>
#include <set>
#include <list>
#include <iomanip>
#include <map>
#include <memory.h>
 
 
 
using namespace std;
static const double EPS = 1e-9;
typedef long long ll;
typedef unsigned long long ull;
#define rep(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a,0,sizeof(a))
#define minus(a) memset(a,0xff,sizeof(a))
#define chmax(a,b) a=min((a),(b))
#define chmin(a,b) a=max((a),(b))
 
 
#define MOD 1000000007
 
typedef pair<int,int>P;
#define INF (1<<29)
 
struct edge { 
	int from, to; 
	edge (int from, int to){
		this->from=from; this->to=to;
	}
};
 
int V,E;
typedef vector<edge> edges;
vector<edges> G;

ll n,m;
ll x[100005],y[100005];

ll go(ll *x, ll n){
	ll xsum=0;
	for(ll i=0;i<n;i++){
		xsum=(xsum+x[i]*i-x[i]*(n-i-1))%MOD;
	}
	return xsum;
}

int main() {

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

	rep(i,n){
		scanf("%lld ",&x[i]);
	}
	rep(i,m){
		scanf("%lld ",&y[i]);
	}	

	ll xsum=go(x,n);
	ll ysum=go(y,m);


	cout << xsum*ysum%MOD << endl;
	return 0;
}




Measured memory_bytes: 1792
N = int(input())
S = input()

cum_b = [0]
for c in S:
    cum_b.append(cum_b[-1] + int(c=='#'))

ans = N
for i in range(N+1):
    tmp = cum_b[i] + N-i - (cum_b[-1] - cum_b[i])
    ans = min(ans, tmp)
print(ans)

Measured memory_bytes: 11136
#include <iostream>

using namespace std;

int calc_gcd(int a, int b) {
        int bigger = a > b ? a : b;
        int lower = a > b ? b : a;

        int r = a % b;
        while (r != 0) {
                a = b;
                b = r;
                r = a % b;
        }

        return b;
}

int calc_lcm(int a, int b) {
        int bigger = a > b ? a : b;
        int lower = a > b ? b : a;

        int ans = bigger;
        while((ans % lower) != 0) {
                ans = ans + bigger;
        }

        return ans;
}

int main(void) {
        int a,b;

        while(cin >> a >> b) {
                cout << calc_gcd(a,b);
                cout << " ";
                cout << calc_lcm(a,b);
                cout << endl;
        }

        return 0;
}

Measured memory_bytes: 2988
#include<algorithm>
#include <iostream>
#include<cstdio>
#include<cmath>
#include<iomanip>
#include<string>
#include<cstdlib>
#include<ctime>
#include<vector>
#include<map>
using namespace std;

int main(){
//srandom((unsigned long)time(NULL));

int n,m,c;
cin>>n>>m>>c;
int a[n][m];
int b[m];
int cnt=0;

for(int i=0;i<m;i++){
    cin>>b[i];
}
for(int i=0;i<n;i++){
    int x=c;
    for(int j=0;j<m;j++){
        cin>>a[i][j];
        x+=a[i][j]*b[j];

    }
    if(x>0)cnt+=1;
}


cout<<cnt<<endl;


return 0;
}

Measured memory_bytes: 256
#include <cassert>
#include <cstdio>
#include <vector>
#include <set>

#include <map>
#include <unordered_map>
#include <deque>
#include <string>
#include <utility>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <climits>

using namespace std;

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; }

const int INF = 1e9;
const long long LINF = 1e18;

int main() {
	long long N, K;
	cin >> N >> K;

    vector<long long> H(N);
    for (int i = 0; i < N; i++) {
        cin >> H[i];
    }

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

    long long sum = 0;
    for (int i = 0; i < N - K; i++) {
        sum += H[i];
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 1792
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
using namespace std;

#define ll         long long
#define PI         acos(-1.0)
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)

int main(void){
    string s;
    cin>>s;
    int a=999999, z=0;
    FOR(i, 0, s.length()){
        if(s[i]=='A') a = min(a, i);
        if(s[i]=='Z') z = max(z, i);
    }
    cout << z-a+1 << endl;
}

Measured memory_bytes: 640
// tzl ak IOI! 
 
#include<bits/stdc++.h>
 
#define HEAP priority_queue
#define rep(i, n) for(int i = 0, _end_ = (n); i < _end_; ++i)
#define per(i, n) for(int i = (n) - 1; i >= 0 ; --i)
#define forn(i, l, r) for(int i = (l), _end_ = (r); i <= _end_; ++i)
#define nrof(i, r, l) for(int i = (r), _end_ = (l); i >= _end_; --i)
#define FOR(a, b) for(auto (a): (b))
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define X first
#define Y second
#define eps 1e-6
#define pi 3.1415926535897932384626433832795
#define SZ(x) (int)x.size()
#define ALL(x) x.begin(), x.end()
#define FILL(a, b) memset((a), (b), sizeof((a)))
#define MCPY(a, b) memcpy((a), (b), sizeof((b)))
 
using namespace std;
 
typedef long long LL;
typedef double flt;
typedef vector<int> vi;
typedef vector<LL> vl;
typedef pair<int,int> pii;
typedef pair<int,LL> pil;
typedef pair<LL,int> pli;
typedef pair<LL,LL> pll;
typedef vector<pil> vil;
typedef vector<pii> vii;
typedef vector<pli> vli;
typedef vector<pll> vll;
 
const int iinf = 1e9 + 7;
const LL linf = 1ll << 60;
const flt dinf = 1e60;
 
template <typename T>
inline void scf(T &x)
{
	bool f = 0; x = 0; char c = getchar();
	while((c < '0' || c > '9') && c != '-') c = getchar();
	if(c == '-') { f = 1; c = getchar(); }
	while(c >= '0' && c <= '9') { x = x * 10 + c - '0'; c = getchar(); }
	if(f) x = -x; return;
}
 
template <typename T1, typename T2>
void scf(T1 &x, T2 &y) { scf(x); return scf(y); }
 
template <typename T1, typename T2, typename T3>
void scf(T1 &x, T2 &y, T3 &z) { scf(x); scf(y); return scf(z); }
 
template <typename T1, typename T2, typename T3, typename T4>
void scf(T1 &x, T2 &y, T3 &z, T4 &w) { scf(x); scf(y); scf(z); return scf(w); }
 
inline char mygetchar(){ char c = getchar(); while(c == ' ' || c == '\n') c = getchar(); return c; }
 
template <typename T>
void chkmax(T &x, const T &y){ if(y > x) x = y; return; }
 
template <typename T>
void chkmin(T &x, const T &y){ if(y < x) x = y; return; }
 
#ifdef ONLINE_JUDGE
#define debug(x,c) ;
#else
#define DEBUG
#define debug(x,c) cerr<<#x<<"="<<x<<c;
#endif
 
void TZL();
 
void RANK1();
 
#define tzl int
#define ak main
#define IOI ()
tzl ak IOI
{
#undef tzl
#undef ak
#undef IOI
 
	TZL();
	RANK1();
 
#define tzl return
#define caisi 0
#define myy ;
	tzl caisi myy
#undef tzl
#undef caisi
#undef myy
}
 
//---------------------------head----------------------------
 
const int N = 1e5 + 100;
 
int n, m;
vi g[N];
deque<int> ans;
bool vis[N];
 
void TZL()
{
	scf(n, m);
	rep(i, m)
	{
		int u, v;
		scf(u, v);
		g[u].pb(v);
		g[v].pb(u);
	}
	return;
}
 
void dfs(int u)
{
	ans.pb(u);
	vis[u] = 1;
	for(int v: g[u]) if(!vis[v])
	{
		return dfs(v);
	}
	return;
}
 
void RANK1()
{
	dfs(1);
	reverse(ALL(ans));
	ans.pop_back();
	dfs(1);
	printf("%d\n", SZ(ans));
	for(int x: ans) printf("%d ", x);
}

Measured memory_bytes: 6784
#coding:utf-8
import sys,os
from collections import defaultdict, deque
from fractions import gcd
from math import ceil, floor
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in os.environ else lambda *x: 0
def main(given=sys.stdin.readline):
    input = lambda: given().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    XLMIIS = lambda x: [LMIIS() for _ in range(x)]
    YN = lambda c : print('Yes') if c else print('No')
    MOD = 10**9+7

    N = II()

    def f(s,v):
        if len(s) == N:
            print(s)
            return
        for i in range(v):
            f(s+chr(ord('a')+i),v)
        f(s+chr(ord('a')+v),v+1)
    f('a',1)



        


if __name__ == '__main__':
    main()

Measured memory_bytes: 89228
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    A, B = map(int, readline().split())
    if (A + B) % 2:
        print('IMPOSSIBLE')
    else:
        print((A + B) // 2)

    return


if __name__ == '__main__':
    main()


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

typedef string::const_iterator State;

int number(State& begin);
int term(State& begin);
int expr(State& begin);
int factor(State& begin);

int number(State& begin){
    int res = 0;
    while( isdigit(*begin) ){
        res *= 10;
        res += *begin - '0';
        begin++;
    }
    return res;
}

int term(State& begin){
    int res = factor(begin);
    for(;;){
        if( *begin == '*' ){
            begin++;
            res *= factor(begin);
        }else if( *begin == '/' ){
            begin++;
            res /= factor(begin);
        }else{
            break;
        }
    }
    return res;
}

int expr(State& begin){
    int res = term(begin);
    for(;;){
        if( *begin == '+' ){
            begin++;
            res += term(begin);
        }else if( *begin == '-' ){
            begin++;
            res -= term(begin);
        }else{
            break;
        }
    }
    return res;
}

int factor(State& begin){
    if(*begin == '('){
        begin++;
        int res = expr(begin);
        begin++;
        return res;
    }else{
        return number(begin);
    }
}

int main(void){
    int N;
    cin >> N;
    cin.ignore();
    for(string s;N--;){
        getline(cin, s);
        State begin = s.begin();
        cout << expr(begin) << endl;
    }
    return 0;
}

Measured memory_bytes: 1204
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    int x, y;
    cin >> x >> y;
    int n = s.size();
    int j = 0;
    while(j != n and s[j] == 'F') {
        x--;
        ++j;
    }
    vi gx, gy;
    bool xx = true;
    bool ren = true;
    for(; j < n; ++j) {
        if(s[j] == 'T') {
            xx ^= 1;
            ren = false;
        }
        else {
            if(xx) {
                if(ren) {
                    gx[gx.size()-1]++;
                } else {
                    gx.push_back(1);
                    ren = true;
                }
            } else {
                if(ren) {
                    gy[gy.size()-1]++;
                } else {
                    gy.push_back(1);
                    ren = true;
                }
            }
        }
    }

    unordered_set<int> se;
    se.insert(0);
    rep(i, gx.size()) {
        vi xx;
        for(int ne:se) {
            xx.push_back(ne+gx[i]);
            xx.push_back(ne-gx[i]);
        }
        se.clear();
        rep(i, xx.size()) {
            se.insert(xx[i]);
        }
    }
    if(se.find(x) == se.end())  {
        cout << "No" << endl;
        return 0;
    }
    se.clear();
    se.insert(0);
    rep(i, gy.size()) {
        vi xx;
        for(int ne:se) {
            xx.push_back(ne+gy[i]);
            xx.push_back(ne-gy[i]);
        }
        se.clear();
        rep(i, xx.size()) {
            se.insert(xx[i]);
        }
    }
    if(se.find(y) == se.end())  {
        cout << "No" << endl;
        return 0;
    }

    cout << "Yes" << endl;
}

Measured memory_bytes: 640
#include<iostream>
#include<stack>
#include<algorithm>
#include<cstring>
#include<cmath>

using namespace std;
typedef long long ll;

#define MAXN 100003
int d[MAXN][3],a[MAXN][3];

int main()
{
    int i,N;
    scanf("%d",&N);
    for(i=0;i<N;i++)
    {
        scanf("%d%d%d",&a[i][0],&a[i][1],&a[i][2]);
    }
    d[0][0]=a[0][0];
    d[0][1]=a[0][1];
    d[0][2]=a[0][2];
    for(i=1;i<N;i++)
    {
        d[i][0]=a[i][0]+max(d[i-1][1],d[i-1][2]);
        d[i][1]=a[i][1]+max(d[i-1][0],d[i-1][2]);
        d[i][2]=a[i][2]+max(d[i-1][1],d[i-1][0]);
    }
    printf("%d\n",max(d[N-1][0],max(d[N-1][1],d[N-1][2])));

    return 0;
}



Measured memory_bytes: 2560
import sys
input = sys.stdin.readline
mod = 2019

s = input().strip()[::-1]
l = [0] * mod

n10 = [1]
for _ in range(len(s)):
    n10.append(n10[-1] * 10 % mod)

n = 0
for i, c in enumerate(s):
    n += n10[i] * int(c)
    n %= mod
    l[n] += 1

ans = 0
for i, v in enumerate(l):
    if v > 1:
        ans += v * (v - 1) // 2
    if i == 0:
        ans += v
print(ans)


Measured memory_bytes: 87516
#include<stdio.h>
int main()
{
  int h,n,i,sum=0;
  
  scanf("%d%d",&h,&n);
  int c[n];
  for(i=0;i<n;i++)
  {
  scanf("%d",&c[i]);
  sum=sum+c[i];
        }
        if(sum>=h)
  printf("Yes");
  else
        printf("No");
        return 0;
        }

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

using namespace std;

int main(void) {
    string N;
    cin >> N;
    if((N[0] == N[1] && N[1] == N[2]) || (N[1] == N[2] && N[2] == N[3])) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
	int N; cin >> N;
	int H[N];
	for(int i = 0; i < N; i++) cin >> H[i];
	bool can = true;
	int pre = H[0]-1;
	for (int i = 1; i < N; i++)
	{
		if(H[i] > pre) {
			pre = H[i] - 1;
		}
		else if(H[i] < pre){
			can = false;
		}
	}
	
	if(can) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


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

template <class T> using V = vector<T>;
template <class S, class T> using P = pair<S, T>;
template <class... T> using TP = tuple<T...>;

using ll = long long;
using db = double;
using ldb = long db;
using str = string;
using vll = V<ll>;
using vvll = V<V<ll>>;
using pll = P<ll,ll>;
using tpll = TP<ll,ll,ll>;
using vpll =V<pll>;
using vst = V<str>;
using vch = V<char>;

#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(b);i>(ll)(a);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) __lcm(a,b)
#define co(a) cout<<a<<endl
#define ci(a) cin>>a
#define pb(a) push_back(a)
#define pob pop_back()
#define mp make_pair
#define mt make_tuple
#define pbmp(a,b) push_back(mp(a,b))
#define subs(a,b) substr(a,b)
#define cfs(a) cout<<fixed<<setprecision(a)
#define INF 1e16
#define mod 1e9+7
//vvll v(n,vll(m)) n行m列
//A.erase(A.begin()+i) 配列Aのi番目を消せる
//std::binary_search(v.bgn,v.en,a);
//abs(a,b)   pow(a,n)  to_string  stoll
//auto Iter=lower_bound(v.bgn,v.en,a);
//lower//upper  co(*Iter)co(Iter-v.bgn);

const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
void Comuse() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
#define comuse Comuse()
ll combi(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
  ll a,b,c;
  cin>>a>>b>>c;
  if(c-a+b<0){
    co(0);
  }
  else{
    co(c-a+b);
  }
}
  

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define endl '\n'
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
int main()
{
   fastio;
   int n;
   cin>>n;
   ll ans=0;
   for(ll i=1;i<=n;i++)
   {
       for(ll j=1;j<=n;j++)
       {
           if(i*j>=n)
           {
               break;
           }
           ans++;
       }
   }
   cout<<ans<<endl;
   return 0;
}

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

int main(){
  ll n,k;
  cin >> n >> k;
  vector<ll> v(n,0);
  for(int i=0;i<n;i++){
    cin >> v[i];
  }
  vector<ll> dp(n,INT_MAX);
  dp[0]=0;
  k = min(k,n);
  for(int i=1;i<k;i++){
    dp[i] = abs(v[i] - v[0]);
  }
  for(int i=k;i<n;i++){
    for(int j=1;j<=k;j++){
      dp[i] = min(dp[i],dp[i-j] + abs(v[i]-v[i-j]));
    }
  }
  cout << dp[n-1] << endl;
}


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

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

using namespace std;

class mint{
	static const int MOD=998244353;
	int x;
public:
	mint():x(0){}
	mint(long long y){ x=y%MOD; if(x<0) x+=MOD; }

	mint& operator+=(const mint& m){ x+=m.x; if(x>=MOD) x-=MOD; return *this; }
	mint& operator-=(const mint& m){ x-=m.x; if(x<   0) x+=MOD; return *this; }
	mint& operator*=(const mint& m){ x=1LL*x*m.x%MOD; return *this; }
	mint& operator/=(const mint& m){ return *this*=inverse(m); }
	mint operator+(const mint& m)const{ return mint(*this)+=m; }
	mint operator-(const mint& m)const{ return mint(*this)-=m; }
	mint operator*(const mint& m)const{ return mint(*this)*=m; }
	mint operator/(const mint& m)const{ return mint(*this)/=m; }

	friend mint inverse(const mint& m){
		int a=m.x,b=MOD,u=1,v=0;
		while(b>0){ int t=a/b; a-=t*b; swap(a,b); u-=t*v; swap(u,v); }
		return u;
	}

	friend istream& operator>>(istream& is,mint& m){ long long t; is>>t; m=mint(t); return is; }
	friend ostream& operator<<(ostream& os,const mint& m){ return os<<m.x; }
	int to_int()const{ return x; }
};

mint pow(mint m,long long k){
	mint res=1;
	for(;k>0;k>>=1,m*=m) if(k&1) res*=m;
	return res;
}

class linear_sieve{
	vector<int> lpf,p;
public:
	linear_sieve(int n):lpf(n+1){
		for(int i=2;i<=n;i++){
			if(lpf[i]==0){
				lpf[i]=i;
				p.emplace_back(i);
			}
			for(int j=0;j<p.size()&&p[j]<=lpf[i]&&i*p[j]<=n;j++) lpf[i*p[j]]=p[j];
		}
	}

	const vector<int>& primes()const{ return p; }

	bool is_prime(int a)const{
		assert(a<=(int)lpf.size()-1);
		return a>0 && lpf[a]==a;
	}

	map<int,int> prime_factorize(int a)const{
		assert(a<=(int)lpf.size()-1);
		map<int,int> pf;
		for(;a>1;a/=lpf[a]) ++pf[lpf[a]];
		return pf;
	}
};

template<class T>
vector<T> divisors(const map<T,int>& pf){
	vector<T> res={T(1)};
	for(const auto& q:pf){
		int m=res.size();
		T pp=1;
		rep(i,q.second){
			pp*=q.first;
			rep(i,m) res.emplace_back(res[i]*pp);
		}
	}
	sort(res.begin(),res.end());
	return res;
}

int main(){
	linear_sieve LS(1e6);

	int n; scanf("%d",&n);
	vector<int> a(n);
	rep(i,n) scanf("%d",&a[i]);

	static vector<int> J[1000001];
	rep(i,n) for(int d:divisors(LS.prime_factorize(a[i]))) J[d].emplace_back(i);

	static mint coef[1000001];

	mint ans=0;
	for(int d=1;d<=1e6;d++) if(!J[d].empty()) {
		mint sum=0,sqsum=0;
		for(int i:J[d]){
			sum+=a[i];
			sqsum+=mint(a[i])*a[i];
		}
		mint prodsum=(sum*sum-sqsum)/2;

		coef[d]=mint(1)/d;
		for(int h:divisors(LS.prime_factorize(d))) if(h<d) coef[d]-=coef[h];

		ans+=coef[d]*prodsum;
	}
	printf("%d\n",ans.to_int());

	return 0;
}


Measured memory_bytes: 74588
#include <bits//stdc++.h>
using namespace std;
int main(void){
    int a,b,c,d,e;
    cin>>a>>b>>c>>d>>e;
    int ans;
    if(a<b&&a<c)
    ans=a;
    else if(b<c)
    ans=b;
    else
    ans=c;
    if(d<e)
    ans=ans+d;
    else
    ans=ans+e;
    cout<<ans-50<<endl;
}



Measured memory_bytes: 3112
#include<bits/stdc++.h>
using namespace std;
template<class T> inline bool chkmax(T& a,T b){return a<b?a=b,1:0;}
template<class T> inline bool chkmin(T& a,T b){return a>b?a=b,1:0;}
template<typename T> inline T& read(T& x){
    static char c; bool flag=0;
    while(!isdigit(c=getchar())) if(c=='-') flag=1;
    for(x=c-'0';isdigit(c=getchar());(x*=10)+=c-'0');
    if(flag) x=-x;
    return x;
}
const int maxn=110;
char s[maxn];
int n,m,sum[30];
int main(){
#ifdef xffyjq
	freopen("exec.in","r",stdin);
	freopen("exec.out","w",stdout);
#endif
	read(n); read(m);
	for(int i=1;i<=n;i++){
		scanf("%s",s);
		for(int j=0;j<m;j++) ++sum[s[j]-'a'];
	}
	if((n&1)&&(m&1)){
		bool flag=0;
		for(int i=0;i<26;i++) if(sum[i]&1){
			--sum[i]; flag=1; break;
		}
		if(!flag) puts("No"),exit(0);
	}
	int need=((n&1)?m/2:0)+((m&1)?n/2:0),tot=0;
	for(int i=0;i<26;i++) if(sum[i]%4==2) ++tot,sum[i]-=2;
	if(need<tot) puts("No"),exit(0);
	for(int i=0;i<26;i++) if(sum[i]%4!=0) puts("No"),exit(0);
	puts("Yes");
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cassert>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repd(i, n) for (int i = n; i >= 1; i--)
#define mod 1000000007
#define MOD 998244353
#define inf 1e20
typedef long long int ll;
typedef pair<ll, ll> p;


int main() {
	int a, b, c;
	cin >> a >> b >> c;
	int i=a;
	while (i <= b) {
		if (i<a + c || i>b - c) {
			cout << i <<endl;
		}
		i++;
	}
	return 0;
}

//Ctrl+Aを使わない

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

using namespace std;

int main(){
  string S,T; cin >>  S >> T;
  string G = S + T;
  int g = stoi(G);
  int c = (int) sqrt((double) g );
  if( c * c == g){ cout << "Yes" << endl;}
  else{cout << "No" << endl;}
  return 0;}

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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };




void solve() {
    int n; cin >> n;
    cout << n*(n+1)/2 << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 7740
#include<bits/stdc++.h> 
using namespace std;
#define se second
#define fr first
#define int long long int
#define pb push_back
#define inf 1e18
#define all(v) v.begin(),v.end()
#define CHAL_BAAP_KO_MT_SIKHA ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mod 1000000007
/*
    Damn Fast:TheFuckinMastermind
    while(How to solve the Question?){
                Read the Question Again!!
           }
        do
            Practise
    #Motivation::::0/0  
*/
const int N=2e5;
int h[N+1];
int n;
int dp[N+1];
int solve(int pos){
    if(pos>n){
        return inf;
    }
    if(pos==n)
        return 0;
    if(dp[pos]!=-1)
        return dp[pos];
    int ans=inf;
    if(pos+1<=n){
        ans=min(ans,solve(pos+1)+abs(h[pos+1]-h[pos]));
    }
    if(pos+2<=n){
        ans=min(ans,solve(pos+2)+abs(h[pos+2]-h[pos]));
    }
    return dp[pos]=ans;
}
signed main()
{
   
    CHAL_BAAP_KO_MT_SIKHA
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>h[i];
    }
    memset(dp,-1,sizeof(dp));
    cout<<solve(1);
}

Measured memory_bytes: 5760
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;
public class Main {
	public static void main(String[] args){
      	
		Scanner sc = new Scanner(System.in);

    long N = sc.nextLong();
    long K = sc.nextLong();
    if (N/K>10000000) {
      N =N%K;
      if (Math.abs(N-K)<N) {
        N = Math.abs(N-K);
      }
    }else{
     while (Math.abs(N-K)<N) {
        N =Math.abs(N-K);
      }
    }  
      System.out.println(N);
      sc.close();
    }
		

}

Measured memory_bytes: 21844
#include<cstdio>
//#include<cstring>
#include<iostream>
#define N 1000


void ini(void);
using namespace std;
char before[N];
char after[N];
char sth/*[N]*/;
int main(){
  ini();
  int n;
  
  int i;
  while(cin >> n){
    if(n==0)break;
    for(i=0;i<n;i++){
      
      cin >>  before[i] >> after[i];
      
    }
    
    int m;
    
    cin >> m;
    
    for(i=0;i<m;i++){
      
      cin >> sth/*[i]*/ ;
      for(int j=0;j<n;j++){
	if(sth/*[i]*/ == before[j]){
	  sth/*[i]*/=after[j];
	  break;
	}
      }
      printf("%c", sth/*[i]*/);
    }
    cout << endl;
    
  }
    return 0;
    
  
}
  
void  ini(void){

  int i;

  for(i=0;i<N;i++){
    // sth[i]=-1;
    before[i]=-1;
    after[i]=-1;
  }

}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define int long long
using namespace std;

int n,k,mod=1e9+7,ans=0;
int a[100005];

int quick_power(int a,int b)
{
	int res=1;
	for (;b;b=b>>1,a=(a*a)%mod)
	{
		if (b&1)  res=(res*a)%mod;
	}
	return res;
}

signed main()
{
	cin>>n>>k;
	for (int i=k;i>=1;i--)
	{
		a[i]=quick_power(k/i,n)%mod;
		for (int j=2*i;j<=k;j+=i)  a[i]=((a[i]-a[j])%mod+mod)%mod;
	}
	for (int i=1;i<=k;i++)  ans=(ans+a[i]*i)%mod;
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 4376
import itertools

N, M, Q = [int(i) for i in input().split()]
#print(N, M, Q)

l = [i for i in range(1, M+1)]
#print(l)
C = itertools.combinations_with_replacement(l, N)

O = []
for i in range(Q):
    a, b, c, d = [int(j) for j in input().split()]
    O.append([a, b, c, d])
    
maxl = []  
for v in C:
    #print(v)
    A = sorted(list(v))
    #print(A)    
    mans = 0 
    for a, b, c, d in O:
        #print(a, b, c, d)
        if A[b-1] - A[a-1] == c:
            mans += d
    maxl.append(mans)

print(max(maxl))

Measured memory_bytes: 12628
n=int(input())
A=[]
B=[]
a=[list(map(int,input().split())) for i in range(n)]
a.sort(key=lambda x: x[1])
time=0
for i in range(len(a)):
  time+=a[i][0]
  if time>a[i][1]:
    print("No")
    break
else:
  print("Yes")

Measured memory_bytes: 53720
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String[] nm = br.readLine().split(" ");
		int n = Integer.parseInt(nm[0]);
		int m = Integer.parseInt(nm[1]);

		ArrayList<String> demands = new ArrayList<String>(m);

		for (int i = 0; i < m; i++) {
			String[] miline = br.readLine().split(" ");
			demands.add(String.format("%05d", Integer.parseInt(miline[0])) + "-"
					+ String.format("%05d", Integer.parseInt(miline[1])));
		}

		Collections.sort(demands);

		int ans = 0;
		int min = -1;
		int max = 999999999;

		for (int i = 0; i < m; i++) {
			String[] ab = demands.get(i).split("-");
			int a = Integer.parseInt(ab[0]);
			int b = Integer.parseInt(ab[1]);
			if (a < max) {
				min = Math.max(a, min);
				max = Math.min(b, max);
			} else {
				ans++;
				min = a;
				max = b;
			}
		}

		ans++;

		System.out.println(ans);

	}

}


Measured memory_bytes: 122628
/*
* Welcome to my code!
*---------------------------------------------*
* author : lynmisakura(twitter : @andoreiji11)
*/

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <cassert>

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define repn for(int i = 0;i < n;i++)
#define ain(a) for(auto& i : a)cin >> i;
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x.size()) 
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define cont continue

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using pi = pair<int,int>;
using vpi = vector<pi>;
using pl = pair<ll,ll>;
using vpl = vector<pl>;

template<class T> bool chmin(T& a,T b){if(a > b){a = b;return true;}else return false;}
template<class T> bool chmax(T& a,T b){if(a < b){a = b;return true;}else return false;}
template<class T> void print(std::vector<T> a){ int sz = a.size();
for(int i=0;i<a.size();i++)cout << a[i] << (i < sz-1 ? ' ' : '\n'); }
void ioboost(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}
///////////////////////////////////////////////////////////

int main(int argc, char const *argv[])
{
	ioboost();
	ll x;cin >> x;
	ll ans = 0;
	ll cur = 100;
	while(cur < x){
		cur *= 1.01;
		ans++;
	}	
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 3652
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::str::FromStr;
use std::io::*;
use std::collections::*;
use std::cmp::*;

struct Scanner<I: Iterator<Item = char>> {
    iter: std::iter::Peekable<I>,
}

macro_rules! exit {
    () => {{
        exit!(0)
    }};
    ($code:expr) => {{
        if cfg!(local) {
            writeln!(std::io::stderr(), "===== Terminated =====")
                .expect("failed printing to stderr");
        }
        std::process::exit($code);
    }}
}

impl<I: Iterator<Item = char>> Scanner<I> {
    pub fn new(iter: I) -> Scanner<I> {
        Scanner {
            iter: iter.peekable(),
        }
    }

    pub fn safe_get_token(&mut self) -> Option<String> {
        let token = self.iter
            .by_ref()
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            Some(token)
        }
    }

    pub fn token(&mut self) -> String {
        self.safe_get_token().unwrap_or_else(|| exit!())
    }

    pub fn get<T: FromStr>(&mut self) -> T {
        self.token().parse::<T>().unwrap_or_else(|_| exit!())
    }

    pub fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.get()).collect()
    }

    pub fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }

    pub fn char(&mut self) -> char {
        self.iter.next().unwrap_or_else(|| exit!())
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.get::<String>().chars().collect()
    }

    pub fn mat_chars(&mut self, row: usize) -> Vec<Vec<char>> {
        (0..row).map(|_| self.chars()).collect()
    }

    pub fn line(&mut self) -> String {
        if self.peek().is_some() {
            self.iter
                .by_ref()
                .take_while(|&c| !(c == '\n' || c == '\r'))
                .collect::<String>()
        } else {
            exit!();
        }
    }

    pub fn peek(&mut self) -> Option<&char> {
        self.iter.peek()
    }
}

const INF: usize = 1 << 60;

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin.bytes().map(|c| c.unwrap() as char));
    let n: usize = sc.get();
    let mut cnt = vec![INF; 26];
    for _ in 0..n {
        let S: Vec<char> = sc.chars();
        let mut S_cnt = vec![0; 26];
        for &c in &S {
            S_cnt[(c as u8 - b'a') as usize] += 1;
        }
        for c in 0..26 {
            cnt[c] = min(cnt[c], S_cnt[c]);
        }
    }
    for c in 0..26 {
        if cnt[c] == INF {
            continue;
        }
        for _ in 0..cnt[c] {
            print!("{}", char::from(b'a' + c as u8));
        }
    }
    println!();
}


Measured memory_bytes: 4352
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define show(x) cerr << #x << " = " << (x) << endl;
using namespace std;
using ll = long long;
using pii = pair<int,int>;
int a,b,c;
int solve(int num, const vector<int> &d){
//    show(num);
    int res = 1<<30;
    if(num == 0){
        int n = (int)d.size();
        for(int i = 0; i < n; i++){
            for(int j = 0; j < n; j++){
                if(i==j)continue;
                for(int k = 0; k < n; k++){
                    if(i==k or j ==k)continue;
                    if(i!=j and j != k and k != i)res = min(res,abs(a-d[i])+abs(b-d[j])+abs(c-d[k]));
                }
            }
        }
    }else{
        int n = (int)d.size();
        for(int i = 0; i < n-1; i++){
            vector<int>dd;
//            show(i);
            for(int j = 0; j < n; j++)if(j != i)dd.push_back(d[j]);
            for(int j = 0; j < n-1; j++){
                dd[j]+=d[i];
                res = min(res, solve(num-1,dd)+10);
                dd[j]-=d[i];
            }
//            dd[i] += d[i];
//            for(auto x:d){
//                cout << x << " ";
//            }
//            cout << endl;
//            for(auto x:dd){
//                cout << x << " ";
//            }
//            cout << endl;
            res = min(res, solve(num-1,dd)+10);
        }
    }
    return res;
}
//333-100=233
int main(){
    int n;
    cin >> n >> a >> b >> c;
    vector<int>d(n);
    rep(i,n)cin >> d[i];
    int ans = 1<<30;
//    solve(2,d);
    for(int i = 0; i <= n-3; i++){
        ans = min(ans, solve(i,d));
//        show(solve(i,d));
    }
    cout << ans << endl;
}

Measured memory_bytes: 256