akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<numeric>
#include<cmath>
using namespace std;
typedef long long int ll;
#define rep(i,n) for(int i=0;i<(int)n;i++)
int main(void) {
	int n; cin >> n; int k; cin >> k;
	set<int> se;
	int x;
	rep(i, k) {
		cin >> x;
		se.insert(x);
	}
	bool f = 0;
	for (int i = n;; i++) {
		for (int s = i; s > 0; s /= 10) {
			if (se.count(s % 10)) {
				f = 1;
				break;
			}
		}
		if(!f) {
			cout << i << endl;
			return 0;
		}
		f = 0;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define M 1000000007
#define all(a) (a).begin(),(a).end()
#define rep(i,n) reps(i,0,n)
#define reps(i,m,n) for(int i=(m);i<(n);i++)
int main(){
  ll n,a,b;cin>>n>>a>>b;
  cout<<n/(a+b)*a+min((n-(n/(a+b))*(a+b)),a);
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;
ll A[100005];
ll X[100005];

int main()
{
	int N;
	cin >> N;
	ll sum = 0;
	ll sumE = 0;
	for (int i = 0; i < N; ++i)
	{
		cin >> A[i];
		sum += A[i];
		if (i % 2 == 1)
		{
			sumE += A[i];
		}
	}
	//cout << sum << " " << sumE << endl;

	X[0] = sum - (2 * sumE);
	for (int i = 1; i < N-1; ++i)
	{
		X[i] = 2 * A[i-1] -X[i-1];
	}
	X[N-1] = 2 * A[N-1] - X[0];

	for (int i = 0; i < N; ++i)
	{
		if (i != 0)
		{
			cout << " ";
		}
		cout << X[i];
	}
	cout << endl;
	return 0;
}

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

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)

typedef long long ll;

const ll inf = 1e18+7;
const ll mod = 1e9+7;


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

    vector<int>dp(n+1),bkn(n+1,1);

    rep(i,m){
        int a;
        cin>>a;
        bkn[a]=0;
    }

    dp[0]=1;
    dp[1]=bkn[1];

    rep2(i,2,n+1){
        if(bkn[i]){
            dp[i]=(dp[i-1]+dp[i-2])%mod;
        }
    }

    cout<<dp[n]<<endl;
}


Measured memory_bytes: 1024
w_a = input()
w_b = input()

w_a = sorted(w_a)
w_b = sorted(w_b,reverse = True)

ord_a = list(map(lambda x: ord(x),w_a))
ord_b = list(map(lambda x: ord(x),w_b))

tmp = 0
for i in range(min(len(ord_a),len(ord_b))):
    if ord_a[i] < ord_b[i]:
        tmp -= 1
        break
    elif ord_a[i] > ord_b[i]:
        tmp += 1
        break

if w_a == w_b:
    print('No')
elif tmp == 1:
    print('No')
elif tmp == 0 and len(w_a) > len(w_b):
    print('No')
else:
    print('Yes')

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

int main()
{
	int T, N, D;
	cin >> T;
	while (T--) {
		cin >> N >> D;
		if (N & 1)
			cout << 127 * (N - 1) + D << endl;
		else
			cout << 127 * (N - 1) + (D ^ 127) << endl;
	}
	return 0;
}


Measured memory_bytes: 256
N,K=map(int,input().split())
A = list(map(int,input().split()))
MOD = 1000000007
cnt = 0
for i in range(N-1):
  for j in range(i+1,N):
    if ( A[i] > A[j] ):
      cnt += 1

AS = sorted(A, reverse=True)
sumn = 0
tmp = 0
for i in range(1,N):
  if AS[i] != AS[i-1]:
    tmp = i
  sumn += tmp


if K%2==0:
  mulk = K * ((K-1)//2) + (K//2)
else:
  mulk = K * ((K-1)//2)
mulk %= MOD 
#print( cnt, sumn , mulk, (N-1)//2 );
print ( ((cnt * K)%MOD  + (sumn * mulk) % MOD) %MOD)
  


Measured memory_bytes: 3188
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int x = s.nextInt();
        int a = s.nextInt();
        if(x<a){
            System.out.println(0);
        }else{
            System.out.println(10);
        }
    }
}


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

#define ALL(a) (a).begin(), (a).end()
#define llong long long

using namespace std;

signed main(){
	while(true){
		int n,m; cin >> n >> m;
		if(n == 0)break;
		vector<int> s(m), k(m);
		vector<vector<int>> c(m);
		for(int i = 0; i < m; i++){
			cin >> s[i] >> k[i];
			for(int j = 0; j < k[i]; j++){
				int tmp; cin >> tmp;
				c[i].push_back(tmp-1);
			}
		}

		vector<pair<int,int>> mmin(n), mmax(n);
		for(int i = 0; i < n; i++){
			mmin[i] = {0,i};
			mmax[i] = {0,i};
		}
		for(int i = 0; i < m; i++){
			if(k[i] == 1) mmin[c[i][0]].first += s[i];
			for(int j = 0; j < k[i]; j++){
				mmax[c[i][j]].first += s[i];
			}
		}
		int ans = 0;
		//for(auto e : mmin)cerr << e.first; cerr << endl;
		//for(auto e : mmax)cerr << e.first; cerr << endl;
		sort(ALL(mmin));
		sort(ALL(mmax), greater<pair<int,int>>());
		if(mmin[0].second == mmax[0].second){
			ans = max(mmax[0].first - mmin[1].first, mmax[1].first - mmin[0].first);
		}
		else{
			ans = mmax[0].first - mmin[0].first;
		}
		ans++;

		
		cout << ans << endl;
	}

	return 0;
}




Measured memory_bytes: 3692
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
using namespace std;
typedef pair<int, int> P;

signed main(){
    int a;
    stack<int> st;
    while(cin >> a){
        if(a == 0){
            int t = st.top(); st.pop();
            cout << t << endl;
        }else{
            st.push(a);
        }
    }
}

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

#define REP(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define eb emplace_back

using ll = int64_t;

using namespace std;

int n;
vector<pair<int,int>> to[100010];

int dist[100010];

void dfs(int x,int p = -1,int d = 0){
    dist[x] = d;
    for(auto i : to[x]){
       int v = i.first;
       int di = i.second;

       if(v == p)continue;
       dfs(v,x,(d + di) % 2);
    }
}

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

    cin >> n;
    REP(i,n-1){
        int a,b,c;cin >> a >> b >> c;
        a--,b--;
        to[a].emplace_back(b,c % 2);
        to[b].emplace_back(a,c % 2);
    }
    dfs(0);
    REP(i,n)cout << dist[i] << '\n';
}



Measured memory_bytes: 11600
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;

int main() {
	while (1) {
		int i, j, n, m, begin, cnt = 0, add;
		string s;
		cin >> n;
		if (!n)break;
		cin >> m;
		cin >> s;
		begin = -1;
		if (s[0] == 'I')begin = 0;
		for (i = 1; i < m; i++) {
			if (s[i] == s[i - 1] && begin != -1) {
				if (s[i] == 'O') {
					add = (i - begin - 2) / 2 - n + 1;
				} else {
					add = (i - begin - 1) / 2 - n + 1;
				}
				if (add > 0)cnt += add;
				begin = -1;
			}
			if (s[i] == 'I' && begin == -1) {
				begin = i;
			}
		}

		cout << cnt << endl;



	}
	return 0;
}

Measured memory_bytes: 3780
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

// union by size + path having
class UnionFind {
public:
    vector <ll> par; // 各元の親を表す配列
    vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)

    // Constructor
    UnionFind(ll sz_): par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }

    // Member Function
    // Find
    ll root(ll x) { // 根の検索
        while (par[x] != x) {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }

    // Union(Unite, Merge)
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) { // 連結判定
        return root(x) == root(y);
    }

    ll size(ll x) { // 素集合のサイズ
        return siz[root(x)];
    }
};

int main()
{
  int N, M, A, B;

  cin >> N >> M;

  UnionFind uf(N);

  for(int i=0; i<M; ++i){
    cin >> A >> B;

    uf.merge(A-1, B-1);
  }

  int ret = 0;

  for(int i=0; i<N; ++i){
    if(i == uf.par[i]) ++ret;
  }

  cout << ret - 1 << endl;

  return 0;
}

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

void doRoutine() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
#ifdef LOCAL
    freopen("C:\\Users\\M\\alg\\practice\\clion_main\\input.txt", "r", stdin);
    freopen("C:\\Users\\M\\alg\\practice\\clion_main\\output.txt", "w", stdout);
#endif
}


#define DBG(VAR) cerr << #VAR << ": " << VAR << endl

#define all(x) x.begin(), x.end()
#define vb vector<bool>
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define fi first
#define se second
#define pb push_back
#define vc vector
#define $ make_pair

#ifndef LOCAL
#define cerr if(0) cerr
#define DBG(...) (true)
#endif

#define D double
#define int long long

// ----------------------------- CODE NOW ------------------------

signed main() {
    doRoutine();

    int n, p;
    cin >> n >> p;

    if (n == 1) {
        cout << p << endl;
        return 0;
    }

    int ans = 1;
    for (int d = 2; d * d <= p; ++d) {
        if (p % d == 0) {
            int cnt = 0;
            while (p % d == 0) {
                p /= d;
                ++cnt;
            }
            while (cnt >= n) {
                ans *= d;
                cnt -= n;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
using System;

class Program
{
    static void Main(string[] args) {
        string s = Console.ReadLine();
        int ans = 0;
        for(int i = 0; i < s.Length; i ++) {
            if(s[i] == '+') ans ++;
            else ans --;
        }
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 13140
# encoding:utf-8
import copy
import numpy as np
import random
import bisect #bisect_left　これで二部探索の大小検索が行える

N,Q = map(int, input().split())
s = input()
td = [input().split() for i in range(Q)]

td.reverse()

nl = 0
nr = N-1
L = []
R = []
for i in td:#全ての指示
    # print(L,R)
    if i[1]=="L":
        if nl < N:
            if s[nl] == i[0]:
                L.append(i[0])
                nl += 1
            if len(R) != 0:
                if R[-1]==i[0]:
                    R.pop()
                    nr += 1
    else:
        if nr >= 0:
          if s[nr] == i[0]:
            R.append(i[0])
            nr -= 1
        if len(L) != 0:
          if L[-1] == i[0]:
            L.pop()
            nl -= 1

print(N-len(L)-len(R))


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

#define mod 1000000007

using namespace std;
typedef long long ll; 
 
int main(void){
	
	string s;
	
	cin >> s;
	
	int A = s[0] - '0', B = s[1] - '0', C = s[2] - '0', D = s[3] - '0';
	
	if(A+B+C+D == 7)
		cout << A << '+' << B << '+' << C << '+' << D << '=' << 7;
	else if(A+B+C-D == 7)
		cout << A << '+' << B << '+' << C << '-' << D << '=' << 7;
	else if(A+B-C+D == 7)
		cout << A << '+' << B << '-' << C << '+' << D << '=' << 7;
	else if(A-B+C+D == 7)
		cout << A << '-' << B << '+' << C << '+' << D << '=' << 7;
	else if(A-B-C+D == 7)
		cout << A << '-' << B << '-' << C << '+' << D << '=' << 7;
	else if(A-B+C-D == 7)
		cout << A << '-' << B << '+' << C << '-' << D << '=' << 7;
	else if(A+B-C-D == 7)
		cout << A << '+' << B << '-' << C << '-' << D << '=' << 7;
	else if(A-B-C-D == 7)
		cout << A << '-' << B << '-' << C << '-' << D << '=' << 7;
	
	return 0;
}

Measured memory_bytes: 256
let () =
  Scanf.scanf "%d" @@ fun n ->
  let a = Array.init n (fun _ -> Scanf.scanf " %d" ((+) 0)) in
  Array.sort (-) a;
  let m = a.(n-1) in
  let r = Array.fold_left (fun r e ->
    if abs (m-2*e) < abs (m-2*r) then e else r) a.(0) a in
  Printf.printf "%d %d\n" m r

Measured memory_bytes: 7040
#include<stdio.h>
int main(void)
{
        int s1,s2,m,h;
        scanf("%d",&s1);
        h = s1 / 3600;
        m = (s1 % 3600) / 60;
        s2 = (s1 % 3600 % 60) % 60;
        printf("%d:%d:%d\n",h,m,s2);
        return 0;
}




Measured memory_bytes: 2100
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int ans = 0;
        for (int i = 1 ; i <= k ; i++) {
            for (int j = 1 ; j <= k ; j++) {
                for (int m = 1 ; m <= k ; m++) {
                    int d = gcd(i, gcd(j, m));
                    ans += d;
                }
            }
        }
        System.out.println(ans);
    }


    private static int gcd(int m, int n) {
        if(m < n) return gcd(n, m);
        if(n == 0) return m;
        return gcd(n, m % n);
    }

}

Measured memory_bytes: 27196
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i <= (n); i++)
#define repf(i,a,b) for (int i = (a); i < (b); i++)
#define repi(i,a,b) for (int i = (a); i <= (b); i++)
#define repr(i,a,b) for (int i = (a); i >= (b); i--)
#define all(x) (x).begin(),(x).end()
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vd = vector<double>;
using pii = pair<int, int>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;
using tiii = tuple<int, int, int>;
 
int main() {
  string S, T; cin >> S >> T;
  
  string S_rot;
  S_rot = S + S;
  
  if ((int)S_rot.find(T) == -1)
    cout << "No" << endl;
  else
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
N, M, L = map(int, input().split())
dist = [[10**12] * N for _ in range(N)]
for i in range(N):
    dist[i][i] = 0
    
for _ in range(M):
    a, b, c = map(int, input().split())
    if c <= L:
    	dist[a-1][b-1] = dist[b-1][a-1] = c

for k in range(N):
    for i in range(N):
        for j in range(N):
            dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j])

old_dist = [row[:] for row in dist]
for i in range(N):
    for j in range(N):
        if old_dist[i][j] <= L:
            dist[i][j] = 1
            
for k in range(N):
    for i in range(N):
        for j in range(N):
            dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j])

Q = int(input())
for _ in range(Q):
    start, end= map(int, input().split())
    if dist[start-1][end-1] < 10**12:
    	print(dist[start-1][end-1] - 1)
    else:
        print(-1)

Measured memory_bytes: 60280
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define between(a,x,b) ((a)<=(x)&&(x)<=(b))
using namespace std;
typedef pair<string, double> sd;
bool cmp(const sd &a, const sd &b){
  //  if(a.second == b.second) return a.first < b.first;
  if(a.second != b.second) return a.second > b.second;
  else return a.first < b.first;
}

int main(){
  int N;
  while(scanf("%d", &N) && N){
    int P, A, B, C, D, E, F, S, M;
    char L[32];
    vector<sd >ef(N);
    rep(i, N){
      scanf("%s%d%d%d%d%d%d%d%d%d",  L, &P, &A, &B, &C, &D, &E, &F, &S, &M);
      ef[i] = make_pair(string(L),(double)(S * F * M - P) / (double)(A + B + C + (D + E) * M));
      //      printf("%d %d\n", N, i);
    }

    sort(ef.begin(), ef.end(), cmp);
    rep(i, N) puts(ef[i].first.c_str());
    puts("#");
  }
  return 0;
}

Measured memory_bytes: 1224
(n, a, b) = map(int, input().split())

grand_total = 0
for i in range(1, n + 1):
    str_num = str(i)
    total = 0
    for num in str_num:
        total += int(num)
    if a <= total and total <= b:
        grand_total += i
print(grand_total)
    

Measured memory_bytes: 2940
#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;
int n, m, cnt, s, u[55], v[55], x[55];
vector<int> g[55];

void dfs(int p) {
	if(x[p]) return;
	x[p] = 1;
	s++;
	for(int i=0; i<g[p].size(); i++) {
		dfs(g[p][i]);
	}
}

int main() {
	int i, j;
	cin>>n>>m;
	for(i=0; i<m; i++) cin>>u[i]>>v[i];
	for(i=0; i<m; i++) {
		for(j=1; j<=n; j++) g[j].clear(), x[j] = 0;
		for(j=0; j<m; j++) {
			if(j==i) continue;
			g[u[j]].push_back(v[j]);
			g[v[j]].push_back(u[j]);
		}
		s = 0;
		dfs(1);
		cnt += (s!=n);
	}
	cout<<cnt;
	return 0;
}

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

int main(){
	while(1){
		int n[4];
		int L=0;
		int S=0;
		int N=0;
		cin>>N;
		if(N==0){
			break;
		}
		if(N%1111==0){
			cout<<"NA"<<endl;
			continue;
		}
		int cun=0;
		int B=1;
		while(B){
			if(N==6174){
				B=0;
				break;
			}
			cun++;
			n[0]=N/1000;
			n[1]=N/100%10;
			n[2]=N/10%10;
			n[3]=N%10;
			
			sort(n,n+4);
			
			S=n[0]*1000+n[1]*100+n[2]*10+n[3];
			L=n[3]*1000+n[2]*100+n[1]*10+n[0];

			N=L-S;
			
			
		}
		cout<<cun<<endl;
	}
	return 0;
}

Measured memory_bytes: 1180
n = int(input())

cnt = 0
flag = True
for i in range(1, n + 1):
    if i == 10 or i ==100 or i==1000 or i==10000 or i ==100000or i==1000000:
        if flag:
            flag = False
        else:
            flag = True

    if flag:
        # print(i)
        cnt += 1

print(cnt)


Measured memory_bytes: 2940
N, M = map(int, input().split())
overall = []
for i in range(N):
    tmp_a, tmp_b = map(int, input().split())
    overall.append((tmp_a, tmp_b))

juice = sorted(overall)
count = 0
price = 0
for i in range(len(juice)):
    if count + juice[i][1] <= M:
        price += juice[i][0] * juice[i][1]
        count += juice[i][1]
    else:
        diff = M - count
        price += juice[i][0] * diff
        break
        
print(price)

Measured memory_bytes: 17804
n = input()
if n[-1:] == "0":
    print("pon")
if n[-1:] == "1":
    print("pon")
if n[-1:] == "2":
    print("hon")
if n[-1:] == "3":
    print("bon")
if n[-1:] == "4":
    print("hon")
if n[-1:] == "5":
    print("hon")
if n[-1:] == "6":
    print("pon")
if n[-1:] == "7":
    print("hon")
if n[-1:] == "8":
    print("pon")
if n[-1:] == "9":
    print('hon')

Measured memory_bytes: 9088
#include <stdio.h>
#include <string.h>
#include <ctype.h>

int main() {
    char W[10], T[3];
    int count = 0, i;
    scanf("%s", W);
    while (scanf("%s", T) && strcmp(T, "END_OF_TEXT")) {
        for (i = 0; T[i]; i++) {
            T[i] = tolower(T[i]);
        }
        if (!strcmp(W, T)) {
            count++;
        }
    }
    printf("%d\n", count);
    return 0;
}

Measured memory_bytes: 552
raw_data = gets
raw_data = raw_data.split("/").map{|n|n.to_i}
year = raw_data[0]
month = raw_data[1]
day = raw_data[2]
answer = "Heisei"
answer = "TBD" if year > 2019
answer = "TBD" if (year == 2019 && month > 4)
answer = "TBD" if (year == 2019 && month == 4 && day > 30)
puts answer

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

#define ll long long
#define ull unsigned long long

int a;

void solve() {
    cin >> a;
    cout << a+a*a+a*a*a << "\n";
}

int main() {
    ios::sync_with_stdio(0);
    solve();
    return 0;
}

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



int main(){
  int a,b;
  cin >> a  >> b;
  if(2*a-1 >= 2*b-1){
    cout << max(2*a-1, a+b) <<endl;
  }
  else{
    cout << max(2*b-1,a+b)<< endl;
  }
}
  
     
    
    


Measured memory_bytes: 256
import sys

line = sys.stdin.readline().replace('\n', '').split(' ')
cnt = 0

height = int(line[1])
width = int(line[2])

for i in range(int(line[0])):

  board = sys.stdin.readline().replace('\n', '').split(' ')
  if int(board[0]) - height >= 0 and int(board[1]) - width >= 0:
    cnt += 1 

  #print (board[0])
print (cnt)

Measured memory_bytes: 3064
#include <iostream>
#include <numeric>
#include <bits/stdc++.h>
using namespace std;
// long long -> lint
using lint = long long;
// fast cin and cout from hitonanode-san's code
// w/o 71 ms -> w/ 18 ms (tested on ABC148-D with C++14(GCC 5.4.1))
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;


int main(){
    // input
    int a, b;
    cin >> a >> b;

    // out
    int mi = min(a, b);
    int ma = max(a, b);
    for( int i=0; i<ma; i++ ){
        cout << mi;
    }
    cout << endl;
} 

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

typedef long long ll;

int main()
{
    ll N;
    cin >> N;
    vector<ll> A;
    for (ll i = 0; i < N; ++i)
    {
        ll temp;
        cin >> temp;
        A.push_back(temp);
    }
    double sum = 0;
    for (ll l : A)
    {
        sum += l;
    }
    double avr = sum / N;
    double mini = 1000000;
    ll ans = 0;
    for (ll i = 0; i < N; ++i)
    {
        if (mini > abs(A[i] - avr))
        {
            ans = i;
            mini = abs(A[i] - avr);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <cassert>
#include <stdio.h>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <stack>

using namespace std;

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

#define debug(args...) {vector<string> _v = split(#args, ','); err(_v.begin(), args); puts("");}
vector<string> split(const string& s, char c) {vector<string> v; stringstream ss(s); string x; while (getline(ss, x, c)) v.push_back(x); return v;}
void err(vector<string>::iterator it) {}
template<typename T, typename... Args> void err(vector<string>::iterator it, T a, Args... args) {cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << ", "; err(++it, args...);}

#define all(x)  (x).begin(),(x).end()
#define tr(c, it)   for(auto it=c.begin(); it!=c.end(); it++)
#define clr(a, b)   memset(a, b, sizeof(a))
#define forn(i, n)   for(int i=0; i<n; i++)

const double eps = 1e-6;
LL n, m;
LL mod = 1000000007;

int main()
{
#ifdef LOCAL
    freopen("in", "r", stdin);
    //freopen("out", "w", stdout);
#endif

    //scanf("%d",&T);


    while(cin >> n >> m)
    {
        if(abs(n - m) > 1)
        {
            cout << 0 << endl;
            continue;
        }

        LL res = 1;

        for(int i=1; i<=n; ++i)
        {
            res  = res * i % mod;
        }
        for(int i=1; i<=m; ++i)
        {
            res  = res * i % mod;
        }

        if(n == m)
            res = res * 2 % mod;

        cout << res << endl;



    }
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
char a[10010];
int main()
{
	scanf("%s",a);
	int len=strlen(a)-1;
	for(int i=0;i<=len;++i)
	{
		if(a[i]=='A'&&a[i+1]=='C'){printf("Yes\n");return 0;}
	}printf("No\n");return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
#define ll long long
#define INF LLONG_MAX/3
#define eps LDBL_EPSILON
#define moder 1000000007
#define pie 3.141592653589793238462643383279
#define P std::pair<int,int>
#define prique priority_queue
using namespace std;
signed main(){
	int a[4];
	cin>>a[0]>>a[1]>>a[2]>>a[3];
	sort(a,a+4);
	if(a[0]==1&&a[1]==4&&a[2]==7&&a[3]==9)puts("YES");
	else puts("NO");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>

using namespace std;
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()
// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return;std::cout << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class X> void DEBUG(X d, T e){if(DEBUG_OUT == false)return;std::cout <<d<<" ";DEBUG(e);};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

  // vector<vector<vector<int> > > DP =  vector<vector<vector<int> > >(100001,vector<vector<int> >(2,vector<int>(2,0)));
void solve(void)
{
  int N;
  cin>>N;
  string str;
  cin>>str;
  vector<int> W(N,0),B(N,0);
  int NW = 0;
  int NB = 0;
  for (int i = 0; i < N; i++)
  {
    if(str[i]=='#')
    {
      B[i]++;
      NB++;
    }
    else
    {
      W[i]++;
      NW++;
    }
    
  }
  for (int i = 0; i < N-1; i++)
  {
    W[i+1] += W[i];
  }
  for (int i = 0; i < N-1; i++)
  {
    B[N-2-i] += B[N-1-i];
  }
  //   for (int i = 0; i < N-1; i++)
  // {
  //   B[i+1] += B[i];
  // }
  // for (int i = 0; i < N-1; i++)
  // {
  //   W[N-2-i] += W[N-1-i];
  // }
  for (int i = 0; i < N; i++)
  {
    W[i] = NW - W[i];
    B[i] = NB - B[i];
  }
  
  // DEBUG(W);DEBUG(B);
  
  int ANS = INF;
  for (int i = 0; i < N; i++)
  {
    chmin(ANS,W[i]+B[i]);
  }
  cout<<ANS<<endl;
  
  
  return;
}

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

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


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

#define rep(i,a,n) for(int i=a;i<n;++i)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
const int N=2e5+5;
const int inf=2e9;
#define ll long long

ll gcd(ll a,ll b){
    ll r=a%b;
    while(r){
        a=b;
        b=r;
        r=a%b;
    }
    return b;
}
int main(){
    ios::sync_with_stdio(0);
    int n;
    ll a,ans=1;
    cin>>n;
    rep(i,0,n){
        cin>>a;
        ans=ans/gcd(ans,a)*a;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ri register int
#define csi const int&
#define fi first
#define se second
#define pb push_back
using namespace std;
const int rlen=1<<18|1;
char buf[rlen],*ib=buf,*ob=buf;
#define gc() (((ib==ob)&&(ob=(ib=buf)+fread(buf,1,rlen,stdin)),ib==ob)?-1:*ib++)
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
inline int read(){
	int ans=0;
	char ch=gc();
	while(!isdigit(ch))ch=gc();
	while(isdigit(ch))ans=((ans<<2)+ans<<1)+(ch^48),ch=gc();
	return ans;
}
inline ll readl(){
	ll ans=0;
	char ch=gc();
	while(!isdigit(ch))ch=gc();
	while(isdigit(ch))ans=((ans<<2)+ans<<1)+(ch^48),ch=gc();
	return ans;
}
inline int Read(char*s){
	int top=0;
	char ch=gc();
	while(!isalpha(ch))ch=gc();
	while(isalpha(ch))s[++top]=ch,ch=gc();
	return top;
}
namespace modular{
	const int mod=1e9+7;
	inline int add(int a,int b){return (a+=b)<mod?a:a-mod;}
	inline int dec(int a,int b){return (a-=b)<0?a+mod:a;}
	inline int mul(int a,int b){return (ll)a*b%mod;}
	inline void Add(int&a,int b){a=add(a,b);}
	inline void Dec(int&a,int b){a=dec(a,b);}
	inline void Mul(int&a,int b){a=(ll)a*b%mod;}
	inline int ksm(int a,int p){int ret=1;for(;p;p>>=1,Mul(a,a))(p&1)&&(Mul(ret,a),1);return ret;}
	inline int Inv(int x){return ksm(x,mod-2);}
	inline void fix(int&x){x=(x%mod+mod)%mod;}
}
using namespace modular;
template<typename T>inline void ckmin(T&a,const T&b){a>b?a=b:0;}
template<typename T>inline void ckmax(T&a,const T&b){a<b?a=b:0;}
struct Mat{
	int a[4][4];
	Mat(int v=0){for(ri i=0;i<=3;++i)for(ri j=0;j<=3;++j)a[i][j]=i==j?v:0;}
	inline int*operator[](const int&k){return a[k];}
	inline const int*operator[](const int&k)const{return a[k];}
	friend inline Mat operator*(Mat a,Mat b){
		Mat c;
		for(ri i=0;i<=3;++i)for(ri k=0;k<=3;++k)if(a[i][k])
		for(ri j=0;j<=3;++j)if(b[k][j])Add(c[i][j],mul(a[i][k],b[k][j]));
		return c;
	}
	friend inline Mat operator^(Mat a,int p){
		Mat ret(1);
		for(;p;p>>=1,a=a*a)if(p&1)ret=ret*a;
		return ret;
	}
}trans1,trans2,res(1);
int n,m;
int main(){
	#ifdef ldxcaicai
	freopen("lx.in","r",stdin);
	#endif
	trans1[0][0]=2,trans1[0][1]=1,trans1[0][2]=1,trans1[0][3]=1;
	trans1[1][0]=1,trans1[1][1]=1,trans1[1][2]=0,trans1[1][3]=1;
	trans1[2][0]=1,trans1[2][1]=0,trans1[2][2]=1,trans1[2][3]=1;
	trans1[3][0]=1,trans1[3][1]=0,trans1[3][2]=0,trans1[3][3]=1;

	trans2[0][0]=1,trans2[0][1]=1,trans2[0][2]=1,trans2[0][3]=1;
	trans2[1][0]=0,trans2[1][1]=1,trans2[1][2]=0,trans2[1][3]=1;
	trans2[2][0]=0,trans2[2][1]=0,trans2[2][2]=1,trans2[2][3]=1;
	trans2[3][0]=0,trans2[3][1]=0,trans2[3][2]=0,trans2[3][3]=1;

	n=read(),m=read();
	int las=1;
	for(ri i=1,x;i<=m;++i){
		x=read();
		if(i>1){
			res=(trans1^(x-las-1))*trans2*res;
		}
		else res=(trans1^(x-las))*res;
		las=x;
	}
	if(m)res=(trans1^(n-las-1))*trans2*res;
	else res=trans1^(n-1);
	cout<<add(add(res[0][0],res[0][1]),add(res[0][2],res[0][3]));
	return 0;
}

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

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

    int n;
    cin >> n;
    vector<int> x(n), y(n);
    rep(i, n) cin >> x[i] >> y[i];

    map<pair<int, int>, int> mp;
    rep(i, n) rep(j, n){
        if(i == j) continue;
        ++mp[make_pair(x[j]-x[i], y[j]-y[i])];
    }

    int sub = 0;
    for(auto itr = mp.begin(); itr != mp.end(); ++itr){
        sub = max(sub, itr->second);
    }

    cout << n-sub << endl;

    return 0;
}

Measured memory_bytes: 3788
/** 
 * THIS IS MOOONI'S CODE !
 * HACK IT IF YOU CAN !
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<string> s(n);
  for (int i = 0; i < n; i++) {
    cin >> s[i];
  }
  vector<vector<int>> dp(n, vector<int>(m));
  dp[0][0] = (s[0][0] == '#');
  for (int i = 1; i < m; i++) {
    dp[0][i] = dp[0][i - 1];
    if (s[0][i] == '#' && s[0][i - 1] == '.') {
      ++dp[0][i];
    }
  }
  for (int i = 1; i < n; i++) {
    dp[i][0] = dp[i - 1][0] + (s[i][0] == '#' && s[i - 1][0] == '.');
    for (int j = 1; j < m; j++) {
      dp[i][j] = min(dp[i - 1][j] + (s[i][j] == '#' && s[i - 1][j] == '.'), dp[i][j - 1] + (s[i][j] == '#' && s[i][j - 1] == '.'));
    }
  }
  cout << dp[n - 1][m - 1] << '\n';
  return 0;
}

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

int main() {
    int n, l;
    cin >> n >> l;
    int a[n];
    cin >> a[0];
    for (int i = 1; i < n; i++) {
        cin >> a[i];
        if (a[i] + a[i - 1] >= l) {
            cout << "Possible\n";
            for (int j = 1; j < i; j++) {
                cout << j << '\n';
            }
            for (int j = n - 1; j >= i; j--) {
                cout << j << '\n';
            }
            return 0;
        }
    }
    cout << "Impossible";
    return 0;
}


Measured memory_bytes: 1152
def get_input_data():
    input_data = int(input())
    return input_data

def make_calendar():
    calendar_dict = dict()
    duration = 0
    y, m, d = 1000, 1, 1
    while y > 1 or m > 1 or d > 1:
        duration += 1
        if d > 1:
            d -= 1
        elif m > 1:
            m -= 1
            d = calculate_month_having_date(y, m)
        else:
            y -= 1
            m = 10
            d = calculate_month_having_date(y, m)
        calendar_dict[(y, m, d)] = duration
    return calendar_dict

def calculate_month_having_date(y, m):
    if y % 3 == 0 or m % 2 == 1:
        d = 20
    else:
        d = 19
    return d

def show_the_duration(calendar_dict):
    birthday = input().split()
    for i, v in enumerate(birthday):
        birthday[i] = int(v)
    duration = calendar_dict[tuple(birthday)]
    return duration

if __name__ == "__main__":
    calendar_dict = make_calendar()
    # print("calendar_dict", calendar_dict) # debug
    people_num = get_input_data()
    for i in range(people_num):
        duration = show_the_duration(calendar_dict)
        print(duration)



Measured memory_bytes: 39028
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i = 0; i < N; i++) cin >> A[i];
    bool flag = true;
    for(int i = 0; i < N; i++){
        if(A[i] % 2 == 0){
            if(A[i] % 3 == 0 || A[i] % 5 == 0)  continue;
            else flag = false; 
        }
    }
    if(flag == true) cout << "APPROVED" << endl;
    else cout << "DENIED" << endl;
}


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

int main(){
  int n,z,w;
  cin>>n>>z>>w;
  int a[n];
  rep(i,0,n) cin>>a[i];
  if(n>1) cout<<max(abs(a[n-1]-w),abs(a[n-1]-a[n-2]));
  else cout<<abs(a[0]-w)<<endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) throws Exception{
		Scanner scn = new Scanner(System.in);
		int A = scn.nextInt();
      int B = scn.nextInt();
      int m = scn.nextInt();
      //冷蔵庫の価格
		int[] a = new int[A];
		for(int i=0; i<a.length; ++i){
			a[i] = scn.nextInt();
		}
      //レンジの価格
      int[] b = new int[B];
		for(int i=0; i<b.length; ++i){
			b[i] = scn.nextInt();
		}
      //クーポン格納
      int[] c = new int[m*3];
		for(int i=0; i<c.length; ++i){
			c[i] = scn.nextInt();
		}
      //冷蔵庫の最安値
      int aa = a[0] +1;
      int bb = b[0] +1;
      for(int i=0; i<a.length; ++i){
			if(aa>a[i]){
              aa = a[i];
            }
      }
      //レンジの最安値
      for(int i=0; i<b.length; ++i){
			if(bb>b[i]){
              bb = b[i];
            }
      }
      //合計の最安値
      int ans = aa + bb;
      int sum = 0;
      //クーポン込みの最安値
      for(int i=0; i<c.length; i+=3){
			sum = a[c[i]-1] + b[c[i+1]-1] - c[i+2];
        	if(sum < ans){
              ans = sum;
            }
      }
      System.out.println(ans);
	}
}


Measured memory_bytes: 62432
/************
< 주소 >      :
*************
< 해결방안 >   :


*************
< 오답노트 >   :

*************/

#include <bits/stdc++.h>
using namespace std;

#ifdef LOCAL_BOOKNU
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

// ........................macro.......................... //
#define FOR(i, f, n) for(int (i) = (f); (i) < (int)(n); ++(i))
#define RFOR(i, f, n) for(int (i) = (f); (i) >= (int)(n); --(i))
#define pb push_back
#define emb emplace_back
#define fi first
#define se second
#define ENDL '\n'
#define sz(A) (int)(A).size()
#define ALL(A) A.begin(), A.end()
#define UNIQUE(c) (c).resize(unique(ALL(c)) - (c).begin())
#define next next9876
#define prev prev1234
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<vii> vvii;
typedef long long i64;
typedef unsigned long long ui64;
// inline i64 GCD(i64 a, i64 b) { if(b == 0) return a; return GCD(b, a % b); }
inline int getidx(const vi& ar, int x) { return lower_bound(ALL(ar), x) - ar.begin(); } // 좌표 압축에 사용: 정렬된 ar에서 x의 idx를 찾음
inline i64 GCD(i64 a, i64 b) { i64 n; if(a < b) swap(a, b); while(b != 0) { n = a % b; a = b; b = n; } return a; }
inline i64 LCM(i64 a, i64 b) { if(a == 0 || b == 0) return GCD(a, b); return a / GCD(a, b) * b; }
inline i64 CEIL(i64 n, i64 d) { return n / d + (i64)(n % d != 0); } // 음수일 때 이상하게 작동할 수 있음.
inline i64 ROUND(i64 n, i64 d) { return n / d + (i64)((n % d) * 2 >= d); }
inline i64 POW(i64 a, i64 n) {
	assert(0 <= n);
	i64 ret;
	for(ret = 1; n; a = a*a, n /= 2) { if(n%2) ret *= a; }
	return ret;
}
template <class T> ostream& operator<<(ostream& os, vector<T> v) {
	os << "[";
	int cnt = 0;
	for(auto vv : v) { os << vv; if(++cnt < v.size()) os << ","; }
	return os << "]";
}
template <class T> ostream& operator<<(ostream& os, set<T> v) {
	os << "[";
	int cnt = 0;
	for(auto vv : v) { os << vv; if(++cnt < v.size()) os << ","; }
	return os << "]";
}
template <class L, class R> ostream& operator<<(ostream& os, pair<L, R> p) { return os << "(" << p.fi << "," << p.se << ")"; }
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << H, debug_out(T...); }
// ....................................................... //

const int MAXN = 1e5;
int n, m, ar[MAXN];
vi res;
void input() {
	cin >> n >> m;
	FOR(i, 0, m) cin >> ar[i];
}

int solve() {
	sort(ar, ar + m);
	RFOR(i, m-1, 1) res.pb(ar[i]-ar[i-1]);
	sort(ALL(res));
	i64 ans = 0;
	FOR(i, 0, max(0, m-n)) ans += res[i];
	cout << ans << ENDL;
	return 0;
}

// ................. main .................. //
void execute() {
	input(), solve();
}

int main(void) {
#ifdef LOCAL_BOOKNU
	freopen("input.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);
#endif
	cin.tie(0), ios_base::sync_with_stdio(false);
	execute();
	return 0;
}
// ......................................... //

Measured memory_bytes: 1276
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<iomanip>


#define MOD 1000000007
#define INF 1001001001
#define MIN -1001001001
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back
#define PF push_front
#define all(x) (x).begin(),(x).end()


using namespace std;
typedef long long ll;
typedef vector<ll> v;
typedef vector<vector<ll>> vv;

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

int main(){
    ll H,W;
    cin>>H>>W;
    vector<string> A(H);
    rep(i,0,H)cin>>A[i];
    map<ll,ll> a,b;
    rep(i,0,H){
        bool ok = true;
        rep(j,0,W)if(A[i][j] == '#') ok = false;
        if(ok) a[i]++;
    }
    rep(i,0,W){
        bool ok = true;
        rep(j,0,H)if(A[j][i] =='#') ok = false;
        if(ok) b[i]++;
    }
    rep(i,0,H){rep(j,0,W){
        if(a[i] == 0&& b[j] == 0)cout<<A[i][j];
    }cout<<endl;}

    return 0;
}

Measured memory_bytes: 256
from fractions import gcd
from datetime import date, timedelta
from heapq import*
import math
from collections import defaultdict, Counter, deque
import sys
from bisect import *
import itertools
import copy
sys.setrecursionlimit(10 ** 7)
MOD = 10 ** 9 + 7


def main():
    n, m = map(int, input().split())
    a = [list(input()) for i in range(n)]
    b = [list(input()) for i in range(m)]

    for i in range(n-m+1):
        for j in range(n - m + 1):
            f = True
            for p in range(m):
                for q in range(m):
                    if a[i + p][j + q] != b[p][q]:
                        f= False
            
            if f:
                print("Yes")
                exit()

    print("No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 5472
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPP(i, n) for(int i = 1; i <= n; ++i)
#define REPR(i, n) for(int i = n-1; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define ALL(v) v.begin(), v.end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1000000007;
const ll INF = 1000000000;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m; cin >> n >> m;
    vector<ll> x(n), y(n), z(n);
    REP(i,n) cin >> x[i] >> y[i] >> z[i];
    ll ans=0, tmp;
    REP(bit, (1<<3)) {
        vector<ll> v(n);
        REP(i,n) {
            tmp = 0;
            if(bit & 1<<0) tmp += x[i]; else tmp -= x[i];
            if(bit & 1<<1) tmp += y[i]; else tmp -= y[i];
            if(bit & 1<<2) tmp += z[i]; else tmp -= z[i];
            v[i] = tmp;
        }
        sort(ALL(v), greater<ll>());
        ll sum = 0;
        REP(i,m) sum += v[i];
        ans = max(ans, sum);
    }
    cout << ans << endl;
    return 0;
}

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


int isPalindrome(int n)
{
	int rev = 0;
	for (int i = n; i > 0; i /= 10)
		rev = rev*10 + i%10;
	return (n==rev);
}


int countPal(int mn, int mx)
{
	int cnt=0;
	for (int i = mn; i <= mx; i++)
		if (isPalindrome(i)) cnt++;
    return cnt;

}


int main()
{
    int a, b;
    cin>>a>>b;
    int ans;
    ans=countPal(a, b);
    cout<<ans<<endl;
	return 0;
}


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

#define FOR(i,l,r) for(int i = (int) (l);i < (int) (r);i++)
#define ALL(x) x.begin(),x.end()
template<typename T> bool chmax(T& a,const T& b){ return a < b ? (a = b,true) : false; }
template<typename T> bool chmin(T& a,const T& b){ return b < a ? (a = b,true) : false; }
typedef long long ll;

ll N,W;
ll dp [101] [101] [301];
const ll INF = 1e18;

int main()
{
	scanf("%lld%lld",&N,&W);
	vector<ll> C(N),V(N);
	FOR(i,0,N){
		scanf("%lld%lld",&C [i],&V [i]);
	}
	ll ans = 0;
	for(int i = 0;i <= N;i++) if(i * C.front() <= W){
		ll lim = W - i * C.front();
		chmin(lim,300ll);
		fill(dp [0] [0],dp [101] [0],-INF);
		dp [0] [0] [0] = 0;
		FOR(j,0,N) FOR(k,0,i + 1) FOR(l,0,lim + 1) if(dp [j] [k] [l] >= 0){
			chmax(dp [j + 1] [k] [l],dp [j] [k] [l]);
			if(k + 1 <= i && l + C [j] - C.front() <= lim){
				chmax(dp [j + 1] [k + 1] [l + C [j] - C.front()],dp [j] [k] [l] + V [j]);
			}
		}
		chmax(ans,*max_element(dp [N] [0],dp [N + 1] [0]));
	}

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

	return 0;
}


Measured memory_bytes: 24192
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<stack>
#include<iostream>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define MOD 1000000007
#define vec(a) vector<int>a
using namespace std;


int main()
{
#ifndef ONLINE_JUDGE
	freopen("output.txt", "w", stdout);
	freopen("input.txt", "r", stdin);
#endif
	double w,h,x,y;
	cin>>w>>h>>x>>y;
	cout<<fixed<<setprecision(6)<<w*h/2<<" ";
	if(2*x-w==0 && 2*y-h==0)
		cout<<1<<"\n";
	else
		cout<<0<<"\n";
	return 0;
}
	

Measured memory_bytes: 3756
m=10**9+7
k=13
t=input()[::-1]
dp=[0]*k
dp[0]=1
for d in range(len(t)):
  p=[0]*k
  if t[d]=='?':
    for x in range(10):
      r=int(x)*pow(10,d,k)
      for i in range(k):
        p[(i+r)%k]+=dp[i]
  else:
    r=int(t[d])*pow(10,d,k)
    for i in range(k):
      p[(i+r)%k]=dp[i]
  dp=[j%m for j in p]
print(dp[5]%m)


Measured memory_bytes: 43884
#include "bits/stdc++.h"
using namespace std;

int main() {
	int N, M;
	cin >> N >> M;
	int c_min, c_max;
	c_min = 1;
	c_max = N;
	for (int m = 0; m < M; m++) {
		int L, R;
		cin >> L >> R;
		c_min = max(c_min, L);
		c_max = min(c_max, R);
	}

	cout << max(c_max - c_min + 1, 0);

	return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long unsigned int ll;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD 1000000007

#define REP(i,n) for(int i=0;i<n;i++)
#define REPS(i,f,n) for(int i=(f);i<(n);i++)
#define EACH(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)

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

typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

// https://beta.atcoder.jp/contests/abc060/tasks/abc060_b

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

    for (int i = 1; i <= A*B; i++) if (A*i%B==C){
            cout << "YES" << "\n";
            return 0;
    }


    cout << "NO" << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <math.h>
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
#define INF 99999999999
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

using llong = long long;
using namespace std;

int main(){
    llong n,a;
    cin >> n;
    map<llong, llong> mp;
    for(llong i=1;i<=n;i++){
        cin >> a;
        mp[a] = i;
    }
    for(llong i=1;i<n;i++) cout << mp[i] << " ";
    cout << mp[n] << endl;
}

Measured memory_bytes: 7040
#include "bits/stdc++.h"
using namespace std;

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < (n); i++)
#define Rep(i, n) for(int i = 1; i < n; i++)

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vii = vector<pair<int, int>>;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return (a * b) / GCD(a, b); }
int round_int(int a, int b) { return (a + (b - 1)) / b; }

// 素因数分解; 返り値は(素数, 乗数)のvector配列
vector<pair<ll, int>> factorize(ll n) {
	vector<pair<ll, int>> res;
	for (ll i = 2; i * i <= n; ++i) {
		if (n % i) continue;
		res.emplace_back(i, 0);
		while (n % i == 0) {
			n /= i;
			res.back().second++;
		}
	}
	if (n != 1) res.emplace_back(n, 1);
	return res;
}

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };
constexpr auto MAX = 100010;

// ──────────────────────────────────────────────────────────────────

int main() {
	int n; cin >> n;
	vi a(n), b(n), c(n);
	rep(i, n) cin >> a[i];
	rep(i, n) cin >> b[i];
	rep(i, n) cin >> c[i];

	sort(ASC(a));
	sort(ASC(b));
	sort(ASC(c));

	ll ans = 0;
	rep(i, n) {
		ans += (lower_bound(ASC(a), b[i]) - a.begin())
			* (c.end() - upper_bound(ASC(c), b[i]));
	}
	cout << ans << endl;
}

Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <chrono>
#include <random>

std::mt19937 rng((int) std::chrono::steady_clock::now().time_since_epoch().count());

const int MOD = 1e9 + 7;
const int ms = 200200;

long long fexp(long long x, long long e = MOD - 2) {
	long long ans = 1;
	for(; e > 0; e /= 2) {
		if(e & 1) ans = ans * x % MOD;
		x = x * x % MOD;
	}
	return ans;
}

long long fat[ms], ifat[ms];

long long comb(int n, int a) {
	if(a < 0 || a > n) return 0;
	else return fat[n] * ifat[a] % MOD * ifat[n-a] % MOD;
}

int main() {
	std::ios_base::sync_with_stdio(false); std::cin.tie(NULL);
	int n;
	int a, b, c;
	std::cin >> n >> a >> b >> c;
	int r = fexp((100 - c) * fexp(100) % MOD);
	a = a * fexp(100 - c) % MOD;
	b = b * fexp(100 - c) % MOD;
	long long ans = 0;
	fat[0] = ifat[0] = 1;
	for(int i = 1; i < ms; i++) {
		fat[i] = fat[i-1] * i % MOD;
		ifat[i] = fexp(fat[i]);
	}
	for(int i = 0; i < n; i++) {
		//std::cout << "(" << comb(n + i - 1, i) << " * " << fexp(a, i) << " * " << fexp(b, n) << " * " << r << ")\n";
		ans = (ans + comb(n + i - 1, i) * fexp(a, i) % MOD * fexp(b, n) % MOD * r % MOD * (i + n) % MOD) % MOD;
		ans = (ans + comb(n + i - 1, i) * fexp(b, i) % MOD * fexp(a, n) % MOD * r % MOD * (i + n) % MOD) % MOD;
	}
	std::cout << ans << '\n';
}

Measured memory_bytes: 3456