akhauriyash/Code-Regression huggingface dataset:
import copy
n, m = map(int ,input().split())
inf = 10**8
edges = []
graph = [[inf for i in range(n+1)] for j in range(n+1)]
for i in range(m):
    a,b,c = map(int, input().split())
    graph[a][b] = graph[b][a] = c
    edges.append([a,b,c])
ans = 0
for i in range(n+1):
    graph[i][i] = 0
for k in range(1,n+1):
    for i in range(1,n+1):
        for j in range(1,n+1):
            if graph[i][k] + graph[k][j] < graph[i][j]:
                graph[i][j] = graph[i][k] + graph[k][j]
for i in range(m):
    flag = False
    a,b,c = edges[i]
    for j in range(1,n+1):
        for k in range(1,n+1):
            if graph[j][a] + c + graph[b][k] == graph[j][k]:
                flag = True
    if flag:
        ans += 1
print(m-ans)


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

int main( void )
{
    int n, p;
    while ( cin >> n >> p && n && p ) {
        int C = p;
        int P[51];
        memset( P, 0, sizeof(P) );
        int ind = 0;
        int answer;
        for ( int s = 0; s < 1000000; s++ ) {
            if ( C > 0 ) {
                P[ind]++;
                C--;
                if ( P[ind] == p ) {
                    answer = ind;
                    break;
                }
            } else {
                C += P[ind];
                P[ind] = 0;
            }
            ind = ( ind + 1 ) % n;
        }
        cout << answer << endl;
    }
    return 0;
}

Measured memory_bytes: 864
# -*- coding: utf-8 -*-
# D_ans.pyからコメントなど不要部分削除したもの
import sys
sys.setrecursionlimit(10**6) 

class UnionFindbySize:
    def __init__(self, n):
        self.parent = [-1 for i in range(n)]

    def root(self, x):
        if self.parent[x] < 0:
            return x
        else:
            self.parent[x] = self.root(self.parent[x])
            return self.parent[x]

    def issame(self, x, y):
        return self.root(x) == self.root(y)

    def unite(self, x, y):
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return False
        else:
            self.parent[y] += self.parent[x]    # yの要素数を増やす
            self.parent[x] = y
            return True

    def size(self, x):
        return -self.parent[self.root(x)]

N, M = map(int, input().split())
A = [0] * M
B = [0] * M
for i in range(M):
    A[i], B[i] = map(int, input().split())
    A[i] -= 1
    B[i] -= 1

uf = UnionFindbySize(N)
res = [0] * (M)
res[-1] = N*(N-1)//2

i = 1
for a, b in zip(A[::-1], B[::-1]):
    id = M - 1 - i
    if id < 0:
        break
    if uf.issame(a, b):
        res[id] = res[id+1]
    else:
        sa = uf.size(a)
        sb = uf.size(b)
        res[id] = res[id+1] - sa*sb
        uf.unite(a, b)
    i+=1

for r in res:
    print(r)


Measured memory_bytes: 31164
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int n, a;
  
  cin >> n;
  a = n % 1000;
  
  if(a == 0)
    cout << "Yes" << endl;
  else if(a%111 == 0)
    cout << "Yes" << endl;
  else if(n/10%111 == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
/** 
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 */

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

typedef long long ll;
#define endl "\n"
#define fori(n) for(ll i=0; i<(n); i++)

#define cins(s) string s; cin>>s;
#define cini(i) int i; cin>>i;
#define cinll(l) ll l; cin>>l;
#define cinai(a, n) vi a(n); fori(n) { cin>>a[i]; }
#define cinall(a, n) vll a(n); fori(n) { cin>>a[i]; }
#define cinas(s, n) vs s(n); fori(n) { cin>>s[i]; }

typedef pair<int, int> pii;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<string> vs;
typedef vector<ll> vll;

int main() {
cin.tie(nullptr);
std::ios::sync_with_stdio(false);
    cini(n);
    cinai(b, n-1);

    vi a(n);
    a[0]=b[0];
    a[1]=b[0];

    ll ans=a[0];
    for(int i=1; i<n-1; i++) {
        a[i+1]=b[i];
        a[i]=min(a[i], b[i]);
        ans+=a[i];
    }
    ans+=a[n-1];

    cout<<ans<<endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>

using namespace std;

#define F(i , a , b) for(int (i) = (a) ; (i) <= (b) ; (i)++)
#define pb push_back
#define ll long long
#define E(a) cerr << #a << " = " << a << '\n'
#define X first
#define Y second
#define INF 10000000000000
#define int long long
const int MAX_N = 100000 + 10 , mod = 1000000007;


int n,a[MAX_N],A,B,ans;

int32_t main(){
    
    //    freopen("input.txt" , "r" , stdin);
    //    freopen("output.txt" , "w" , stdout);
    //    cout << setprecision(10) << fixed;
    ios::sync_with_stdio(0); cin.tie() ; cout.tie();
    
    
    cin >> n >> A >> B;
    for(int i =0 ; i<n ; i++){
    	cin >> a[i];
    }
    for(int i =1 ;i<n ; i++){
    	int x = (a[i]-a[i-1])*A;
    	ans += min(x,B);
    }
    cout << ans;
    
    
    
    
    
    
    
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,A,B;
  cin >> N >> A >> B;
  int ans=0;
  for (int i=1;i<N+1;i++){
    int sum=0,j=i;
    while (j>=1){
      sum+=j%10;
      j/=10;
    }
    if (A<=sum&&sum<=B){
      ans+=i;
    }
  }
  cout << ans << endl;
}

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

using namespace std;

#define endl '\n'

typedef long long ll;

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

int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a;a=1ll*a*a;}while(b>>=1);return ans;}
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}

#define _rep3(i,p,n) for(int i=(p),i##_counter=(n); i<i##_counter;++i)
#define _rep2(i,n,_) _rep3(i,0,n)
#define _rep_call(a, b, c, name, ...) name(a, b, c)
#define rep(...) _rep_call(__VA_ARGS__, _rep3, _rep2)

#define dump(x)  cerr << #x << " = " << (x) << '\n'
#define debug(x) cerr << #x << " = " << (x) << " (at line " << __LINE__ << ")" << " " << __FILE__ << '\n'

void Main() {
    string s;
    cin >> s;
    int N = s.size();
    rep(i, N - 1) {
        if (s[i] == s[i + 1]) {
            cout << i + 1 << ' ' << i + 2 << endl;
            return;
        }
    }
    rep(i, N - 2) {
        if (s[i] == s[i + 2]) {
            cout << i + 1 << ' ' << i + 3 << endl;
            return;
        }
    }
    cout << "-1 -1" << endl;
}

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

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

using namespace std;

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

	while (n--) {
		int tri[3];
		cin >> tri[0] >> tri[1] >> tri[2];
		sort(tri, tri + 3);
		if (tri[0] * tri[0] + tri[1] * tri[1] == tri[2] * tri[2]) {
			cout << "YES" << endl;
		} else {
			cout << "NO" << endl;
		}
	}
}

Measured memory_bytes: 1168
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        // 入力
        String s = sc.next();
        String t = sc.next();

        if (s.length() <= 10 && s.length() + 1 == t.length() && s.equals(t.substring(0, s.length()))) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


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

int main()
{
	while(1){
		int a, j=0;
		cin >> a;
		if (a == 0)break;
		j = a;
		string s="";
		int b = 0;
		for (b = 1; b * 8 <= a; b *= 8) {}
		for (int c = b; c != 1; c /= 8) {
			int o =a/c;
			switch (a / c) {
			case 0:case 1:case 2:case 3:cout << a / c;  break;
			case 4:cout << 5; break;
			default:cout << a / c + 2; break;
			}
			
			a -= c*o;
		}
			switch (j % 8) {
			case 0:case 1:case 2:case 3:cout << j % 8; break;
			case 4:cout << 5; break;
			default:cout << j % 8 + 2;
			}
		
		cout << endl;
			}
}

Measured memory_bytes: 3104
n,m,x = [int(i) for i in input().split()]
a = []
for i in range(n):
    b = [int(i) for i in input().split()]
    a.append(b)

ans = []
for i in range(1, 2**n):
    c = [0] * m
    tot = 0
    for j in range(n):
        if ((1<<j) & i):
            for k in range(1, len(a[j])):
                c[k-1] += a[j][k]
            tot += a[j][0]
            poss = 0
            for k in c:
                if k < x:
                    poss = 1
                    break
            if poss == 0:
                ans.append(tot)

if (len(ans) == 0):
    print(-1)
else:
    print(min(ans))
            


Measured memory_bytes: 9684
#include <iostream>

using namespace std;

int ans[3][3] =
{
	{1, 2, 3},
	{4, 5, 6},
	{7, 8, 0}
};
int dx[] = { 0, 1, 0, -1 };
int dy[] = { -1, 0, 1, 0 };

bool match(int f[3][3]) {
	for (int i = 0; i < 3; ++i) {
		for (int j = 0; j < 3; ++j) {
			if (f[i][j] != ans[i][j])
				return false;
		}
	}
	return true;
}

int dfs(int f[3][3], int x, int y, int v, int d, int l) {
	if (match(f))
		return d;
	if (d > l)
		return -1;
	for (int i = 0, res; i < 4; ++i) {
		int nx = x + dx[i];
		int ny = y + dy[i];
		if (nx < 0 || nx > 2 || ny < 0 || ny > 2 || (i + 2) % 4 == v)
			continue;
		f[y][x] = f[ny][nx];
		f[ny][nx] = 0;
		if ((res = dfs(f, nx, ny, i, d + 1, l)) > 0)
			return res;
		f[ny][nx] = f[y][x];
		f[y][x] = 0;
	}
	return -1;
}

int main() {
	int f[3][3], x, y;
	for (int i = 0; i < 3; ++i) {
		for (int j = 0; j < 3; ++j) {
			cin >> f[i][j];
			if (f[i][j] == 0) {
				y = i;
				x = j;
			}
		}
	}

	int res;
	for (int i = 1; i < 50; ++i) {
		if ((res = dfs(f, x, y, -1, 0, i)) >= 0) {
			break;
		}
	}
	cout << res << endl;

	return 0;
}


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

using namespace __gnu_pbds;
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

#define mp make_pair
#define pb push_back
#define pf push_front
#define ss second
#define ff first
#define sz(x) (int)x.size()
#define newl "\n"
#define vi vector<int>
#define pii pair<int, int>
#define vii vector<pii>
#define vl vector<ll>
#define pll pair<ll, ll>
#define vll vector<pll>
#define coutp cout << fixed << setprecision(12)
#define mem(x, val) memset(x, val, sizeof(x))
#define fastio                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define all(v) (v).begin(), (v).end()

const ld pi = 3.14159265359;
ll INF = 1e18 + 10;
ll MOD = 998244353;
ll mod = 1e9 + 7;

inline ll add(ll a, ll b, ll m)
{
    if ((a + b) >= m)
        return (a + b) % m;
    return a + b;
}

inline ll mul(ll a, ll b, ll m)
{
    if ((a * b) < m)
        return a * b;
    return (a * b) % m;
}

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

void solve()
{
    int n,m;
    cin>>n>>m;
    vector<vi> a(m);
    for(int i=0;i<m;i++) {
        int k;
        cin>>k;
        for(int j=0;j<k;j++) {
            int x;
            cin>>x;
            a[i].pb(x);
        }
    }
    vi p(m);
    for(int i=0;i<m;i++) {
        cin>>p[i];
    }
    int ans=0;
    for(int j=0;j<1<<n;j++) {
        int res=0;
        set<int> s;
        for(int i=0;i<n;i++) {
            if(j>>i&1) {
                s.insert(i+1);
            }
        }
        for(int i=0;i<m;i++) {
            int cnt=0;
            for(int k=0;k<sz(a[i]);k++) {
                if(s.count(a[i][k])) cnt++;
            }
            if(p[i]%2==cnt%2) {
                res++;
            }
        }
        if(res==m) {
            ans++;
        }
    }
    cout<<ans;

}

int main()
{
    fastio;
    int t;
    t = 1;
    //cin >> t;
    //int test=t;
    
    while (t-- > 0)
    {
        //cout<<"Case #"<<(test-t)<<": ";
        solve();
        cout << newl;
    }

    return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>
#include <climits>
#include <iterator>
#include <iomanip>
#include <stack>
#include <set>
#include <cstdio>
#include <bitset>
#include <functional>
#include <tuple>
#include <list>
#include <deque>
using namespace std;
typedef pair<int, int> P;

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

typedef long long ll;
typedef vector<int> VI;
struct Less {
	bool operator()(const pair<int, int>& x, const pair<int, int>& y) const {
        if(x.first==y.first) return x.second < y.second;
		return x.first < y.first;
	}
};
struct More {
	bool operator()(const pair<int, int>& x, const pair<int, int>& y) const {
		return x.first > y.first;
	}
};


vector<pair<int, int> > v;
int main() {
    cin.tie(0);
   	ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    REP(i, n) {
        int x, y; cin >> x >> y;
        v.push_back({x, y});
    }
    sort(v.begin(), v.end(), Less());
    
    for(int i=0; i<v.size(); ++i){
        cout << v[i].first << " " << v[i].second << endl;
    }
	return 0;
}


Measured memory_bytes: 3896
#include <bits/stdc++.h>
namespace my_std {
using namespace std;
#define reg register
#define Rint register int
#define FOR(i, a, b) for (register int i = (a), ed_##i = (b); i <= ed_##i; ++i)
#define ROF(i, a, b) for (register int i = (a), ed_##i = (b); i >= ed_##i; --i)
typedef long long i64;
#define Templ(T) template <typename T>
inline int read() {
    reg int ans = 0, f = 1;
    reg char c = getchar();
    while (!isdigit(c)) f ^= (c == '-'), c = getchar();
    for (; isdigit(c); c = getchar()) ans = (ans << 1) + (ans << 3) + (c ^ 48);
    return f ? ans : -ans;
}
Templ(_Tp) inline int chkmin(_Tp &x, _Tp y) { return x > y ? x = y, 1 : 0; }
Templ(_Tp) inline int chkmax(_Tp &x, _Tp y) { return x < y ? x = y, 1 : 0; }
#define mod 998244353
inline void inc(int &x, const int &y) { x += y; if (x >= mod) x -= mod; }
inline void dec(int &x, const int &y) { x -= y; if (x < 0) x += mod; }
inline void qmo(int &x){ x += (x >> 31) & mod; }
inline int ksm(int x, i64 y) {
    int res = 1;
    for (; y; y >>= 1, x = (i64)x * x % mod)
        if (y & 1) res = (i64)res * x % mod;
    return res;
}
} // namespace my_std
using namespace my_std;

#define N 410
int fac[N], ifac[N];
int n;
inline void init(int lim){
    *fac = *ifac = 1;
    FOR(i, 1, lim) fac[i] = (i64)i * fac[i - 1] % mod;
    ifac[lim] = ksm(fac[lim], mod - 2);
    ROF(i, lim - 1, 1) ifac[i] = (i64)(i + 1) * ifac[i + 1] % mod;
}

int a[N], b[N], Sa, Sb;
int f[N][N];

int main() {
    n = read();
    FOR(i, 1, n) a[i] = read(), Sb += (b[i] = read()) - 1;
    init(Sb), Sb = 0;
    f[0][0] = mod - 1;
    FOR(i, 1, n){
        Sa += a[i], Sb += b[i] - 1;
        ROF(j, Sa, a[i]) ROF(k, Sb, 0){
            reg i64 t(1);
            FOR(x, 0, min(b[i] - 1, k)){
                qmo(f[j][k] -= t * ifac[x] % mod * f[j - a[i]][k - x] % mod);
                (t *= a[i]) %= mod;
            }
        }
    }
    Rint ans(0);
    FOR(j, 1, Sa){
        reg const int inv(ksm(j, mod - 2));
        reg i64 t(Sa * (i64)inv % mod);
        FOR(k, 0, Sb){
            qmo(ans += (t * fac[k] % mod * f[j][k] % mod) - mod);
            (t *= inv) %= mod;
        }
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 4428
N, K, C = map(int, input().split())
S = list(input())

left = [None] * N
right = [None] * N

cnt = 0
penalty = 0
for idx in range(N):
    if S[idx] == 'o' and penalty == 0:
        left[idx] = cnt
        cnt += 1
        penalty = C + 1
    #
    if cnt >= K: continue
    penalty = max(0, penalty - 1)

cnt = 0
penalty = 0
for idx_inv in range(N):
    idx = N - 1 - idx_inv
    if S[idx] == 'o' and penalty == 0:
        right[idx] = K - 1 - cnt
        cnt += 1
        penalty = C + 1
    #
    if cnt >= K: continue
    penalty = max(0, penalty - 1)



# print("#", left, right)
for idx in range(N):
    if left[idx] != None and right[idx] != None and left[idx] == right[idx]:
        print(idx + 1)

Measured memory_bytes: 21960
#include <iostream>
#include <stdio.h>
using namespace std;
int main()
{

 int total = 0;
 int A, B;
 cin >> A >> B;
 for(int t=0;t<2;t++){
	 if (A > B) {
		 total += A;
		 A -= 1;
	 }
	 else {
		 total += B;
		 B -= 1;
	 }
 }
 cout << total;
}

Measured memory_bytes: 256
X = int(input())
if X >= 1800:
    print(1)
elif X >= 1600:
    print(2)
elif X >= 1400:
    print(3)
elif X >= 1200:
    print(4)
elif X >= 1000:
    print(5)
elif X >= 800:
    print(6)
elif X >= 600:
    print(7)
else:
    print(8)


Measured memory_bytes: 61620
#include <stdio.h>

int main(void) {
    char s[4];
    int i;
    scanf("%s",s);
    for (i = 0;i < 3;i++) {
        if (s[i] == '1') {
            s[i] = '9';
        } else if (s[i] == '9') {
            s[i] = '1';
        }
    }
    printf("%s\n",s);
    return 0;
}


Measured memory_bytes: 128
time = []
for i in range(5):
	time.append(int(input()))
remain = [0]
for i in range(5):
	if time[i] % 10 != 0:
		remain.append(10 - time[i] % 10)
sum = 0
for i in range(5):
	if time[i] % 10 == 0:
		sum += time[i]
	else:
		sum += (time[i] // 10 + 1) * 10

print(sum - max(remain))

Measured memory_bytes: 3064
n = int(input())
a = list(map(int, input().strip().split()))
sum = 0
mod = 1000000000+7
for i in a:
    sum += i
    sum %= mod
ans = 0
for i in a:
    sum -= i
    if(sum < 0):
        sum += mod
    ans += sum*i
    ans %= mod
print(ans)


Measured memory_bytes: 105420
#include <bits/stdc++.h>
using namespace std;
void findIntersection(int intervals[][2], int N)
{
	int l = intervals[0][0];
	int r = intervals[0][1];
	for (int i = 1; i < N; i++) {
		if (intervals[i][0] > r || intervals[i][1] < l) {
			cout << 0;
			return;
		}
		else {
			l = max(l, intervals[i][0]);
			r = min(r, intervals[i][1]);
		}
	}
    cout<<r-l+1<<endl;
}
int main()
{
    int n,m,i;
    cin>>n>>m;
    int intervals[m+5][2];
    for(i=0;i<m;i++)
        cin>>intervals[i][0]>>intervals[i][1];
	findIntersection(intervals,m);
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <cassert>
#include <queue>
#include <map>
using namespace std;
#define range(a) a.begin(),a.end()

int N, K, a;
vector<int> A;
int gcd(int a, int b) { return a ? gcd(b%a, a) : b; }
int main() {
	scanf("%d%d", &N, &K);
	A = vector<int>(N);
	for (register int i = 0; i < N; ++i)
		scanf("%d", &A[i]);
	if (find(range(A), K) != A.end()) {
		printf("POSSIBLE\n");
		return 0;
	}
	sort(range(A));
	if (A[N - 1] < K) {
		printf("IMPOSSIBLE\n");
		return 0;
	}
	int g = A[0];
	for (register int i = 1; i < N; ++i) {
		g = gcd(g, A[i]);
	}
	if (g == 1 || K%g == 0) {
		printf("POSSIBLE\n");
		return 0;
	}
	printf("IMPOSSIBLE\n");
	return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

class Main {
	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);
		
		double x1, y1, x2, y2, xq, yq, ax, ay;
		double m1, m2, l1, l2;
		
		int q;

		x1 = scan.nextDouble();
		y1 = scan.nextDouble();
		x2 = scan.nextDouble();
		y2 = scan.nextDouble();
		
		//Y - y1 =((y2-y1) / (x2-x1)) * (X-x1)
		
		//p1,p2???????????´???????????? m1
		m1 = (y2-y1) / (x2-x1);
		
		//p1,p2??´????????????  l1
		l1 = y1 - (m1 * x1);
		
		//p???????????????????????????m2
		m2 = -1.0 / m1;
		
		q = scan.nextInt();
		
		for(int i = 0; i < q; i++) {
			xq = scan.nextDouble();
			yq = scan.nextDouble();

			if(x1 == x2) { //?????????????????´
				ax = x1;
				ay = yq;
				
			} else if(y1 == y2) { //??????????°´???
				ax = xq;
				ay = y1;
				
			} else {
				//p???????????????????????? l2
				l2 = yq - (m2 * xq);
			
				//??¬????????§?¨????ax, ay)
				ax = (l2 - l1) / (m1 - m2);
				ay = (l2 * m1 - l1 * m2) / (m1 - m2);
			}
			
			System.out.println(ax + " " + ay);
		}
		
		scan.close();
	}
}

Measured memory_bytes: 42228
#include <stdio.h>

int min2(int a, int b){
    return (a<b)?a:b;
}
int main(void){
    int N;
    scanf("%d", &N);
    char s[N+1];
    scanf("%s", s);
    int countw[N];
    int countb[N];
    int min = N;
    countw[0] = (s[0] == '.');
    countb[0] = (s[0] == '#');
    int count = 0;
    for(int i = 1; i<N; i++){
        countw[i] = countw[i-1] + (s[i] == '.');
        countb[i] = countb[i-1] + (s[i] == '#');
    }
    min = min2(countw[N-1], countb[N-1]);
    //iをblack
    for(int i = 1; i<N; i++){
        count = countb[i-1] + (countw[N-1] - countw[i]);
        if(count < min){
            min = count;
        }
    }

    printf("%d\n", min);
    return 0; 
}

Measured memory_bytes: 1920
/*Bismillahir Rahmanir Rahim*///{
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using ull = unsigned long long; using ld = long double;
const ll llinf = (1ll<<61)-1;
const double eps = 1e-6, ldeps = 1e-9;
struct Dbg {
static constexpr auto &os = cout;   // replace by cerr in interactive.
template<class C> static auto dud(C *x)->decltype(os << *x, 0);
template<class C> static char dud(...);
template<class C> typename enable_if<sizeof dud<C>(0)!=1, Dbg&>::type operator<<(const C &x) { os << x; return *this; }
template<class C> Dbg &dump(C b, C e) {
    *this << "\n[";
    int cur = 0;
    for (C i = b; i!=e and cur<26; i++, cur++) *this << ", "+2*(i==b) << *i;
    return *this << ']';
}
template<class C> typename enable_if<sizeof dud<C>(0)==1, Dbg&>::type operator<<(const C &x) {
    return dump(begin(x), end(x));
}
template<class C, size_t X> typename enable_if<sizeof(C)!=1, Dbg&>::type operator <<(C (&x)[X]) {
    return dump(begin(x), end(x));
}
template<class B, class C> Dbg &operator <<(const pair<B, C> &x) {
    return *this << '{' << x.first << ", " << x.second << '}';
}
template<class C, size_t Y> struct TP {
    void operator()(Dbg& os, const C &t) { TP<C, Y-1>()(os, t); os << ", " << get<Y-1>(t); }
};
template<class C> struct TP<C, 1> { void operator()(Dbg& os, const C &t) { os << get<0>(t); } };
template<class... C> Dbg& operator<<(const tuple<C...> &t) {
    os << '{', TP<decltype(t), sizeof...(C)>()(*this, t); return *this << '}';
}
Dbg &operator<<(ostream&(*x)(std::ostream&)) { os << x; return *this; }
} dbg;
void err(istringstream *iss) { delete iss; }
template<class C, class... Args> void err(istringstream *iss, const C &val, const Args &... args) {
    string name; *iss >> name; if (name.back()==',') name.pop_back();
    dbg << name << " = " << val << "; ", err(iss, args ...);
}
#define bug(args...) dbg << __LINE__ << ": ", err(new istringstream(string(#args)), args), dbg << endl
#define sl(a) int(strlen(a))
#define sz(a) int(a.size())
int T, Q, cn;//}
const int inf = 1000000007, mxn = 100005;

int n, a, b, h[mxn];

bool check(int x) {
    ll cnt = 0;
    for (int i = 1; i <= n; i++) {
        ll y = h[i]-x*ll(b);
        if (y>0) cnt += ((y-1)/(a-b)+1);
    }
    return cnt<=x;
}

signed main() { ios::sync_with_stdio(0); cin.tie(NULL); cout.precision(11);
/*
If we fix number of explosions by binary search as x, we can tell that there will be at most x decrement by a and all
others (n*x-x) decrement by b. As a>b, we can convert it to: every element will be decreased by b x times and there will
be at most x decrement by a-b. ==> This can be easily checked by greedy, every element will need ceil(max(h[i]-x*b, 0)/(a-b))
decrements of 2nd type.
*/
    cin >> n >> a >> b;
    for (int i = 1; i <= n; i++) {
        cin >> h[i];
    }
    int lo = 1, hi = inf, ans = -1;
    while (lo<=hi) {
        auto mid = (lo+hi)>>1;
        if (check(mid)) hi = mid-1, ans = mid;
        else lo = mid+1;
    }
    cout << ans << '\n';
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){ 
    int n[3], k;
    cin >> n[0] >> n[1] >> n[2] >> k;
    sort(n,n+3);
    for(int i = 0; i < k; i++){
        n[2] *= 2;
    }
    cout << n[0]+n[1]+n[2] << endl;
}

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

int main(){
  int A,B,C,D,E;
  cin>>A>>B>>C;
  D=0;
  E=0;
  vector<int> V(B);
  for(int i=0;i<B;i++)
    cin>>V.at(i);
  for(int i=0;i<B;i++){
     if(V.at(i)<C)
       D++;
     if(V.at(i)>C)
       E++;
  }
     if(D>E)
       cout<<E<<endl;
  else
    cout<<D<<endl;
}

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

using namespace std;

int main()
{
   int n,a;
   cin>>n;
   int ar[100000];
   for(int i=1;i<=n;i++)
   {
       cin>>a;
       ar[a]=i;
   }
   for(int i=1;i<=n;i++)
   {
       cout<<ar[i]<<" ";
   }

    return 0;
}


Measured memory_bytes: 1152
//#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 P = pair<int, int>;
using vi = vector<ll>;
using vvi = vector<vi>;



int main() {
    int n, k;
    cin >> n >> k;
    vi h(n);
    rep(i, n) {
        cin >> h[i];
    }
    sort(all(h));
    rep(i, min(k, n)) {
        h.pop_back();
    }

    ll sum = 0LL;
    for(int x:h) {
        sum += x;
    }

    cout << sum << endl;
}

Measured memory_bytes: 1792
/*
　　こんにちは。あたしはｶｳｶﾞｰﾙ。
　　redcoderになるためAtCoderを巡る旅をしてます。

　　　 　 ＿_
　　　 ヽ|＿_|ノ　　　　ﾓｫ
　　　　||‘‐‘||ﾚ　　_)_, ―‐ 、
　　　　/(Ｙ (ヽ＿ /・ ヽ　　 ￣ヽ
　　　　∠ ＿ ゝ　 ｀^ヽ ﾉ.::::_(ノヽ
　　　　 _/ヽ　 　　  /ヽ￣￣/ヽ
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define dump(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl

#define rep(i, n) REP(i, 0, n)                              // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++)             // x, x + 1, ..., n-1
#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(v) (v).begin() , (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

#define COUT(x) cout << (x) << endl

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

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

    int n, k; cin >> n >> k;
    ll ans = k * pow(k - 1, n - 1);
    cout << ans << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long int lli;
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define ff first
#define ss second
#define pi pair<lli,lli>
#define pii pair<pi,lli>
#define endl "\n"
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int N = 1e5 + 5;


int main() {
	IOS
	int T = 1;
	// cin >> T;

	while(T--)
	{
		string s, t;
		cin >> s >> t;
		int n = s.size();
		int ans = 0;
		for(int i=0;i<n;i++)
		{
			ans = ans + (s[i]!=t[i]);
		}
		cout << ans << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3796
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <vector>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define ALL(vec) (vec).begin(), (vec).end()
#define SUM(...) accumulate(ALL(__VA_ARGS__),0LL)
#define DSUM(...) accumulate(ALL(__VA_ARGS__),0.0)
using namespace std;
using ll = long long;
using P = 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;}
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
inline ll gcd(ll a,ll b){if(b == 0) return a;return  gcd(b,a%b);}
inline ll lcm(ll a,ll b){ll g = gcd(a,b);return a / g * b;}

// 出力
void print() { std::cout << '\n'; }
template <class T>void print(const T &x) {std::cout << x <<'\n';}
template <class T, class... Args>void print(const T &x, const Args &... args) {std::cout << x << " ";print(args...);}

const int INF = 2002002002;

void solve(long long A, long long B){
    if (A >= 1 && A <= 9 && B >= 1 && B <= 9) print(A * B);
    else print(-1);
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<stack>
#include<functional>
#include<list>
#include<map>
#include<unordered_map>
#define P pair<int,int>//cost to
using namespace std;

int mincost[1500][1500];
vector<P>rinsetu[1500];
list<int>L[1500][1500];
bool s[1500];
signed main() {
	int a, b; cin >> a >> b;
	for (int c = 0; c < b; c++) {
		int d, e, f; scanf("%d%d%d", &d, &e, &f); d--; e--;
		rinsetu[d].push_back(P(f, e)); 
		rinsetu[e].push_back(P(f, d));
	}
	for (int c = 0; c < a; c++) {
		fill(mincost[c], mincost[c] + a, 1 << 29);
		mincost[c][c] = 0;
		priority_queue<P, vector<P>, greater<P>>Q;
		Q.push(P(0,c));
		while (Q.size()) {
			P t = Q.top(); Q.pop();
			if (t.first > mincost[c][t.second])continue;
			for (P u : rinsetu[t.second]) {
				if (mincost[c][u.second] > t.first + u.first) {
					mincost[c][u.second] = t.first + u.first;
					Q.push(P(mincost[c][u.second], u.second));
					L[c][u.second].clear();
					L[c][u.second].push_back(t.second);
				}
				else if (mincost[c][u.second] == t.first + u.first) {
					L[c][u.second].push_back(t.second);
				}
			}
		}
	}
	int MAX = 0;
	for (int i = 0; i < a; i++) {
		for (int j = 0; j < a; j++) {
			MAX = max(MAX, mincost[i][j]);
		}
	}
	for (int i = 0; i < a; i++) {
		for (int j = 0; j < a; j++) {
			if (mincost[i][j] != MAX)continue;
			queue<int>Q;
			Q.push(j);
			while (Q.size()) {
				int o = Q.front(); Q.pop();
				s[o] = true;
				for (int k : L[i][o]) {
					Q.push(k);
				}
			}
		}
	}
	list<int>w;
	for (int i = 0; i < a; i++) {
		if (!s[i])w.push_back(i);
	}
	cout << w.size() << endl;
	for (int u : w)cout << u+1 << endl;
}

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

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

    string key = "keyence";
    int f_index = 0, l_index = key.size() - 1;
    int f_sum = 0, l_sum = 0;

    for (int i = 0; i < S.size(); i++)
    {
        if (S[i] == key[f_index])
        {
            f_sum++;
            f_index++;
            if (f_sum == 7)
            {
                cout << "YES" << endl;
                return 0;
            }
        }
        else
        {
            break;
        }
    }

    for (int i = S.size() - (7 - f_sum); i < S.size(); i++)
    {
        if (S[i] == key[f_index])
        {
            f_sum++;
            f_index++;
            if (f_sum == 7)
            {
                cout << "YES" << endl;
                return 0;
            }
        }
        else
        {
            cout << "NO" << endl;
            return 0;
        }
    }

    // for (int i = S.size() - 1; i >= 0; i--)
    // {
    //     if (S[i] == key[l_index])
    //     {
    //         l_sum++;
    //         l_index--;
    //         if (l_sum == 7)
    //         {
    //             cout << "YES" << endl;
    //             return 0;
    //         }
    //     }
    //     else
    //     {
    //         break;
    //     }
    // }

    // if (f_sum + l_sum == 7)
    // {
    //     cout << "YES" << endl;
    // }
    // else
    // {
    //     cout << "NO" << endl;
    // }

    return 0;
}

Measured memory_bytes: 256
package main
import(
	"bufio"
	"fmt"
	"os"
)
func main(){
	stdin:=bufio.NewReader(os.Stdin)
	var w,h,x,y,r int
	fmt.Fscan(stdin,&w,&h,&x,&y,&r)
	if(x-r<0||y-r<0||x+r>w||y+r>h){
		fmt.Printf("No\n");
	}else{
		fmt.Printf("Yes\n");
	}
}


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

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


bool landfill(int x, int y, int w, int h, vector<vector<int> > &land) {
    if (x < 0 || y < 0 || x >= h || y >= w) return false;
    if (land.at(x).at(y) == 0) return false;
    land.at(x).at(y) = 0;
    return landfill(x, y + 1, w, h, land) || landfill(x, y - 1, w, h, land) ||
           landfill(x + 1, y, w, h, land) || landfill(x - 1, y, w, h, land) ||
           landfill(x - 1, y + 1, w, h, land) || landfill(x - 1, y - 1, w, h, land) ||
           landfill(x + 1, y + 1, w, h, land) || landfill(x + 1, y - 1, w, h, land);
}

int main() {
    vector<int> ans_union;
    do{
        int w, h;
        cin >> w >> h;
        if(w == 0 && h == 0) break;
        vector<vector<int> > land(h, vector<int>(w));

        int ans = 0;
        rep(i, h) rep(j, w) {
                cin >> land.at(i).at(j);
            }

        rep(i, h) rep(j, w) {
                if (land.at(i).at(j) == 1) {
                    ans++;
                    landfill(i, j, w, h, land);
                }
            }
        ans_union.push_back(ans);
    }while(1);
    for(int i = 0; i < ans_union.size(); i++){
        cout << ans_union.at(i) << endl;
    }

    return 0;

}


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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
void tostr(ll x,string& res){while(x)res+=('0'+(x%10)),x/=10; reverse(ALL(res)); return;}
template<class T> inline bool chmax(T& a,T b){ if(a<b){a=b;return 1;}return 0; }
template<class T> inline bool chmin(T& a,T b){ if(a>b){a=b;return 1;}return 0; }
//end



int main(){
   ll n; scanf("%lld",&n);
   rep(i,1,3501)rep(j,1,3501){
      ll a=n*i*j,b=4LL*i*j-n*i-n*j;
      if(a==0||b<=0)continue;
      if(a%b==0){
         printf("%d %d %d\n",i,j,a/b);
         return 0;
      }
   }
   return 0;
}

Measured memory_bytes: 256
N = int(input())
a = list(map(int, input().split()))

num4 = 0
num2 = 0
for ai in a:
    if ai % 4 == 0:
        num4 += 1
    elif ai % 2 == 0:
        num2 += 1
        
if num4*2 + num2 >= N or num4*2 + 1 >= N:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 15020
#include <cstdio>
using namespace std;
int a,b,c;
int main(){
	scanf("%d%d%d",&a,&b,&c);
	int ans=b+c-a;
	if(ans<0){
		printf("0\n");
	}else{
		printf("%d\n",ans);
	}
	return 0;
}

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

#define ll long long
#define ar array

const int mxN=1e6, M=1e9+7;
int r1, r2, c1, c2;
ll iv[3*mxN], f1[3*mxN], f2[3*mxN];

ll nck(int n, int k) {
	return f1[n]*f2[k]%M*f2[n-k]%M;
}

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

	iv[1]=1;
	for(int i=2; i<3*mxN; ++i)
		iv[i]=M-M/i*iv[M%i]%M;
	f1[0]=f2[0]=1;
	for(int i=1; i<3*mxN; ++i) {
		f1[i]=f1[i-1]*i%M;
		f2[i]=f2[i-1]*iv[i]%M;
	}
	cin >> r1 >> c1 >> r2 >> c2;
	//cout << nck(r2+c2+2, c2+1) << " " << nck(r1+c2+1, c2+1) << " " << nck(r1+c1, c1) << endl;
	cout << ((nck(r2+c2+2, c2+1)-nck(r1+c2+1, c2+1)-nck(r2+c1+1, c1)+nck(r1+c1, c1))%M+M)%M;
}

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

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

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v)
{
  out << "vector(" << v.size() << ") [";
  if (v.size() > 0)
  {
    rep(i, v.size()) out << v[i] << ", ";
    out << "\b\b]";
  }
  else
  {
    out << "]";
  }
  return out;
}

template <typename T, typename U>
ostream &operator<<(ostream &out, const pair<T, U> &p)
{
  out << '(' << p.first << ", " << p.second << ")";
  return out;
}

void solve()
{
  int y, m, d;

  cin >> y;
  cin.ignore(1, '/');
  cin >> m;
  cin.ignore(1, '/');
  cin >> d;

  if (m > 4)
  {
    cout << "TBD";
  }
  else
  {
    cout << "Heisei";
  }
  cout << endl;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
ll lcm(ll x, ll y) {
    return x / __gcd(x, y) * y;//先に割り算をして掛けられる数を小さくして掛け算を行う
}

int main() {
  
  ll x,y;
  cin>> x >>y;
  
  cout << lcm(x,y)<< endl;
}
  



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;

const int MAX=1e6+5;

int main() {
  int64_t N,A,B;
  cin>>N>>A>>B;
  vector<int64_t>X(N);
  for(int i=0;i<N;i++){
    cin>>X[i];
  }
  int64_t sum=0;
  for(int i=0;i<N-1;i++){
    if((X[i+1]-X[i])*A>B){sum+=B;}
    else{sum+=(X[i+1]-X[i])*A;}
  }
  cout<<sum<<endl;
  return 0;  
}

Measured memory_bytes: 3976
#include <iostream>
#include <cstring>
#include <map>
using namespace std;
map<int ,int >a;
int main()
{
    int t,n,sum=0;
    cin>>t;
    for(int i=0;i<t;i++)
    {
        cin>>n;
        if(!a.count(n))a[n]=0;

        if(a[n]==0){sum+=1;a[n]=1;}
        else {sum-=1;a[n]=0;}
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 4992
#include <iostream>
#include <string>//
#include <vector>//
#include <map>
#include <cstdlib>
#include <numeric>
#include <algorithm>//ソート等に使用
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <math.h>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <thread>///////////////////
#include <queue>//幅優先等のキュー
#include <stack>
#include <bitset>

#define rep(i,m,n) for(int i=(m);i<(n);i++)
#define mer(i,m,n) for(int i=(m);i>(n);--i)

#define MOD 1000000007
//#define MOD 998244353
//#define MAX 

using namespace std;

using ll = long long int;
using ld = long double;
using std::swap;

vector<int> v;
vector<long long int> vll;
//vector<vector<int>> vec(50, vector<int>(4, 0));
vector<vector<int>> vv;
vector<char> vc;
vector<string> vs;




int main() {
	int N;
	cin >> N;
	v.resize(N+1);
	rep(i, 1, N+1)cin >> v[i];
	int ans = 0;
	rep(i, 1, N + 1) {
		if (i % 2 == 1) {
			if (v[i] % 2 == 1)++ans;
		}
	}

	cout << ans << '\n';
	return 0;
}

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

ans = 0
dp = [0] * N
for i in range(N - 1):
    dp2 = dp[:]
    for j in range(i + 1, N):
        if S[i] == S[j] and j - i > dp2[j-1]:
            dp[j] = dp2[j-1] + 1
            ans = max(ans, dp[j])
        else:
            dp[j] = 0

print(ans)

Measured memory_bytes: 45280
#include<stdio.h>
#define N 10000

int main(void){
  int i,num,j;
  double ts,usets;
  double n;
  int t[N][13],ans[N];

  for(i=0,ts=1.0;i<7;i++){
    ts*=2.0;
  }
  for(i=0;;i++){
    ans[i]=1;
    scanf("%lf",&n);
    if(n==-1.0)
      break;
    usets=ts;
    for(j=0;j<12;j++){
      if(n-usets>=0.0){
        n-=usets;
        t[i][j]=1;
      }
      else
        t[i][j]=0;
      usets/=2;
    }
    if(n>0.0)
      ans[i]=0;
  }
  num=i;
  for(i=0;i<num;i++){
    if(ans[i]==1){
      for(j=0;j<12;j++){
        printf("%d",t[i][j]);
        if(j==7)
          printf(".");
      }
      printf("\n");
    }else
      printf("NA\n");
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,n) for (int64_t i=0; i<(n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()
#define chmax(x,y) x=max(x,y)



//library mod int
template <int mod>
struct modint{
    ll x;

    //constructor
    modint(ll x=0): x((x%mod+mod)%mod){}

    //unary operator
    modint operator-() const { return modint(mod-x);}
    modint inv() const { return this->pow(mod-2);}
    
    //compound assignment
    modint& operator+=(const modint& a){
        if((x+=a.x)>=mod) x-=mod;
        return *this;
    }
    modint& operator-=(const modint& a){
        if((x-=a.x)<0) x+=mod;
        return *this;
    }
    modint& operator*=(const modint& a){
        (x*=a.x)%=mod;
        return *this;
    }
    modint& operator/=(const modint& a){
        return *this *= a.inv();
    }

    //arithmetic
    // なぜmodintの後ろに＆を書いたり書かなかったりしてるかの理解ができていない
    //おそらく＆をつけるとポインタで参照しているのでもとの値を書き換えることができる
    //＆をつけないとコピーを作ってからそれに対して計算するので、もとの値は変更されない
    modint operator-(const modint& a) const {return modint (*this) -= a ; }
    modint operator+(const modint& a) const {return modint (*this) += a ; }
    modint operator*(const modint& a) const {return modint (*this) *= a ; }
    modint operator/(const modint& a) const {return modint (*this) /= a ; }
    //n should not be smaller than 0.
    modint pow(ll n) const{
        auto x=modint(1);
        auto m=*this;
        while(n>0){
            if(n&1) x*=m;
            n>>=1;
            m*=m;
        }
        return x;
    }

    //compare
    bool operator==(const modint& a) const {return x==a.x ; }
    bool operator!=(const modint& a) const {return x!=a.x ; }

    //I/O
    friend istream& operator>>(istream& is, modint& a ) noexcept {return is >> a.x ; }
    friend ostream& operator<<(ostream& os, const modint& a ) noexcept {return os << a.x ; }
};

//modの調整
constexpr int mod = 1e9 + 7;
using mint = modint<mod>;

//////////////////////////////////////////////////////////////////////
//mint power
mint mpow(mint a, mint b){
    auto x=mint(1), m=a;
    auto n=b.x;
    while(n>0){
        if(n&1) x*=m;
        n>>=1;
        m*=m;
    }
    return x;
}

//combination
vector<mint> mintcombvector;
int startmintcomb(int n){
    mintcombvector.push_back(0);
    mintcombvector.push_back(1);
    rep(i,n) mintcombvector.push_back(mintcombvector[i+1]*(i+2));
    return 0;
}
mint comb(mint a, mint b){
    if(a.x<b.x || a.x<=0 || b.x<0) return mint(0);
    if(b.x==0) return mint(1);
    if(a==b) return mint(1);
    return mintcombvector[a.x]*(mintcombvector[b.x].inv())*(mintcombvector[a.x-b.x].inv());
}
//combinationを使いたいときは　startmintcomb(n=代入したい数の最大値); を始めに打つこと




int main(){
    int n; cin>>n;
    startmintcomb(1e6+5);
    mint ans=mpow(10,n);
    ans-=mpow(9,n);
    ans-=mpow(9,n);
    ans+=mpow(8,n);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 11624
n, m = map(int,input().split())
dp = [0 for _ in range(n+1)]
S = input()
a = [0 for _ in range(m)]
for i in range(1,n):
    if S[i-1:i+1] == "AC":
        dp[i] = dp[i-1]+1
    else:dp[i] = dp[i-1]
for i in range(m):
    x, y = map(int,input().split())
    a[i] = dp[y-1] - dp[x-1]
print(*a,sep="\n")

Measured memory_bytes: 53996
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/














int N, L;
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N >> L;

	int mi = inf, mi_i = -1;
	rep(i, 1, N + 1) if (chmin(mi, abs(L + i - 1))) mi_i = i;

	int ans = 0;
	rep(i, 1, N + 1) if (i != mi_i) ans += L + i - 1;
	cout << ans << endl;
}







Measured memory_bytes: 256
import sys
input=sys.stdin.readline

def main():
    H, _ = map(int, input().split())
    G = []
    for i in range(H):
        G.append(input().strip())

    while True:
        find = False
        for i in G:
            if all(j == "." for j in i):
                G.remove(i)
                find = True
                break
        for i in range(len(G[0])):
            b = True
            for j in G:
                if j[i] != ".":
                    b = False
                    break
            if b:
                find = True
                for j,k in enumerate(G):
                    G[j] = k[:i] + k[i+1:]
                break
        if not find:
            for i in G:
                print(i)
            return

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
import heapq

N, M = map(int, input().split())
A = list(map(int, input().split()))
A = list(map(lambda x: -x, A))

heapq.heapify(A)
#print(A)

for i in range(M):
    n = - (-heapq.heappop(A) // 2)
    heapq.heappush(A, n)

ans = - sum(A)
print(ans)

Measured memory_bytes: 14180
#include<bits/stdc++.h>
#define inf 1000000000
#define eb emplace_back
#define pb push_back
#define fi first
#define se second
#define fastread ios::sync_with_stdio(false);cin.tie(NULL)
#define rng_23 mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pii;
typedef vector<ll> vi;
typedef vector<pair<ll,ll>> vii;
typedef set<ll> si;
typedef multiset<ll> msi;
typedef map<ll,ll> mii;
int main()
{
    ll n,k;
    cin>>n>>k;
    if(n<k)
        cout<<min(n,k-n);
    else
        cout<<min(k-n%k,n%k);
}


Measured memory_bytes: 256