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



int main() {
#ifdef HOME
    assert(freopen("in", "r", stdin));
#endif

    int n, m;
    while (scanf("%d%d", &n, &m) == 2) {
        vector<int> cnt(n);
        for (int i = 0; i < m; i++) {
            int u, v;
            scanf("%d%d", &u, &v);
            --u; --v;
            if (u > v) swap(u, v);
            if (u == 0) cnt[v]++;
            if (v == n - 1) cnt[u]++;
        }
        string ans = "IMPOSSIBLE";
        for (int i = 1; i < n - 1; i++) {
            if (cnt[i] >= 2) {
                ans = "POSSIBLE";
            }
        }
        cout << ans << endl;
    }

#ifdef HOME
    cerr << "time: " << clock() * 1.0 / CLOCKS_PER_SEC << endl;
#endif
    return 0;
}

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

using namespace std;;

int main(){

	long long n,w;
	cin>>n>>w;
	
	vector<long long> berat(n+1), value(n+1);
	
//	long long berat[n],value[n];
	
	for (long long i=1;i<=n;i++){
		cin>>berat[i]>>value[i];
	}
	
	vector<vector<long long>> dp(n+1, vector<long long> (w+1,0));
//	long long dp[n+1][w+1];
	
//	memset(dp,0,sizeof dp);
	
	for (long long i=1;i<=n;i++){
		for (long long j=0;j<=w;j++){
			dp[i][j]=dp[i-1][j];
			if (j-berat[i]>=0){
				dp[i][j]=max(dp[i][j],dp[i-1][j-berat[i]]+value[i]);
			}
		}
	}

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

	return 0;
}


Measured memory_bytes: 83048
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>
#include<complex>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef complex<double> P;

#define MAX 1010

int josephus(int n, int k, int s) {
  long x = k * s;
  while (x > n)
    x = ((x - n) * k - 1) / (k - 1);
  return (int) x - 1;
}

int main(){
  int n, m;
  while(cin>>n>>m, n+m)
    cout << josephus(n, m, n) + 1 << endl;
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <cmath>
#include <cstring>
#include <assert.h>
#include <utility>
#include <tuple>
#include <array>
#include <bitset>
#include <cstdlib>

using int64 = long long;
using uint64 = unsigned long long;

using namespace std;

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

    string n;
    cin >> n;

    if (count(begin(n), end(n), '7')) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}



Measured memory_bytes: 3012
def main():
    from bisect import bisect_left
    from operator import itemgetter

    N, D, A = map(int, input().split())

    xh = []
    xs = set()
    for _ in range(N):
        x, h = map(int, input().split())
        xh.append((x, h))
        xs.add(x)
        xs.add(x + D)
        xs.add(x + D * 2)

    xh.sort(key=itemgetter(0), reverse=True)

    *xs, = sorted(xs)

    imos = [0] * (len(xs) + 10)
    mons = [0] * (len(xs) + 10)
    for x, h in xh:
        i = bisect_left(xs, x)
        mons[i] += h

    ret = 0
    for i in range(len(xs) + 1):
        d = (mons[i] - imos[i] + A - 1) // A
        if d > 0:
            ret += d
            imos[i] += d * A
            imos[bisect_left(xs, xs[i] + D * 2) + 1] -= d * A
        imos[i + 1] += imos[i]

    print(ret)


if __name__ == '__main__':
    main()

# import sys
#
# sys.setrecursionlimit(10 ** 7)
#
# input = sys.stdin.readline
# rstrip()
# int(input())
# map(int, input().split())


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

#define lint long long
#define P pair<int, int>
#define LLP pair<long long, long long>
#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define repr(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())

const int IINF = 1e9 + 10;
const long long LLINF = (long long)1e18 + 10;
const long long MOD = (long long)1e9 + 7;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;

    vector<string> v(3);
    rep(i, 3){
        cin >> v[i];
    }

    int ans = 0;

    rep(i, n){
        set<char> st;
        rep(j, 3){
            st.insert(v[j][i]);
        }
        ans += (int)st.size() - 1;
    }

    cout << ans << endl;

    return 0;

}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;
const int INF = 1e+9;

int main() {
	int n, k;
	cin >> n >> k;
	vector<int> h(n), dp(n + 10, INF);
	for (int i = 0; i < n; ++i) cin >> h[i];
	dp[0] = 0;
	for (int i = 0; i < n - 1; ++i) {
		for (int j = 1; j <= k; ++j) {
			if (i + j < n) dp[i + j] = min(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
		}
	}
	cout << dp[n - 1] << endl;
	return 0;
}

Measured memory_bytes: 1024
N,K=list(map(int,input().split()))
if K==0:
   print(N**2)
   exit()
ans=0
for i in range(1,N+1):#割る数
   if i<=K:
      continue
   else:
      ans+=(N//i)*(i-K)
      ans+=N-(N//i)*i-(K-1) if N-(N//i)*i-(K-1)>0 else 0
print(ans)

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

int main() {
    int r, g, b;
    cin >> r >> g >> b;
    if((r * 100 + g * 10 + b) % 4 == 0) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

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

bool binarySearch(int s[], int n, int v) {
    int left = 0;
    int right = n;
    while (left < right) {
        int mid = (left + right) / 2;
        if (s[mid] == v) {
            return true;
        } else if (s[mid] < v) {
            left = mid + 1;
        } else if (s[mid] > v) {
            right = mid;
        }
    }
    return false;
}

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

    int q;
    cin >> q;
    int t[q];
    for (int i = 0; i < n; i++) cin >> t[i];

    int cnt = 0;
    for (int i = 0; i < q; i++) {
        if (binarySearch(s, n, t[i])) {
            cnt++;
        }
    }

    cout << cnt << endl;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long int ll;
int main()
{
  int n,w;
  scanf("%d%d",&n,&w);
  ll ws[n], vs[n];
  ll dp[n+1][w+1] = {};
  REP(i,n){
    cin >> ws[i] >> vs[i];
  }
  
  REP(i,n){
    for(int sum_w=0; sum_w<=w; sum_w++){
      if(sum_w - ws[i] >= 0) dp[i+1][sum_w] = max(dp[i][sum_w], dp[i][sum_w-ws[i]]+vs[i]);
      else dp[i+1][sum_w] = dp[i][sum_w];
    }
  }
  cout << dp[n][w] << endl;
}

Measured memory_bytes: 79104
//This Code was made by Chinese_zjc_.
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<bitset>
#include<cmath>
#include<queue>
#include<stack>
#include<string>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<map>
#include<set>
#include<time.h>
// #include<windows.h>
#define int long long
#define PI 3.14159265358979323
#define INF 0x3fffffffffffffff
using namespace std;
int n,k,m,a[3005][3005],dp[3005][3005][4],X,Y,V,ans;
signed main()
{
    ios::sync_with_stdio(false);
    cin>>n>>m>>k;
    for(int i=1;i<=k;++i)
    {
        cin>>X>>Y>>V;
        a[X][Y]=V;
    }
    for(int i=1;i<=n;++i)
    {
        for(int j=1;j<=m;++j)
        {
            if(i>1)
            {
                for(int l=0;l<=3;++l)
                {
                    dp[i][j][0]=max(dp[i][j][0],dp[i-1][j][l]);
                }
            }
            if(j>1)
            {
                for(int l=0;l<=3;++l)
                {
                    dp[i][j][l]=max(dp[i][j][l],dp[i][j-1][l]);
                }
            }
            for(int l=3;l>0;--l)
            {
                dp[i][j][l]=max(dp[i][j][l],dp[i][j][l-1]+a[i][j]);
            }
        }
    }
    for(int i=0;i<=3;++i)
    {
        ans=max(dp[n][m][i],ans);
    }
    cout<<ans<<endl;
    return 0;
}

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

#define rep(i, a, b) for (ll i = (a); i < (b); i++)
typedef uint64_t ull;
typedef int64_t ll;
typedef pair<ll, ll> PLL;

const ll M = 1e9+7;

// 以下を満す(a,b)の組の数を返す
// a+b=s
// a^b=x
// aのbitが立っている位置の集合 ⊇ bのbitが立っている位置の集合
ll f(ll s, ll x){
    static map<PLL, ll> memo;
    auto it = memo.find(PLL(s,x));
    if (it!=memo.end())
        return it->second;

    // printf("f(%d,%d)\n",s,x);
    if (s==0)
        return 1;
    else if (x==0)
        return (s/2)+1;

    ll res = f(s/2,x/2) %M;
    if (s>0 && x>0)
        (res += f((s-1)/2, (x-1)/2)) %= M;
    if (s>1)
        (res += f((s-2)/2, x/2)) %= M;
    return memo[PLL(s,x)] = res;
}

signed main() {
    ll n;
    cin>>n;
    cout<<f(n,n)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <queue>
#include <vector>
#include <cmath>

using namespace std;

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

int main(void){
  int K, S;
  cin >> K >> S;

  int cnt = 0;

  for (int x = 0; x <= K; x++) {
    for (int y = 0; y <= K; y++) {
      int z = S - x - y;
      if (0 <= z && z <= K) cnt ++;
    }
  }

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

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <queue>
#include <cmath>
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
#pragma warning (disable: 4996)

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

	if (N % 2 == 1) cout << "No" << endl;
	else {
		string V1 = S.substr(0, N / 2);
		string V2 = S.substr(N / 2, N / 2);
		if (V1 == V2) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
	int n, k, x = 1;
	scanf("%d %d", &n, &k);
	
	for (int i = 0; i < n; i++) {
		if (x < k) {
			x *= 2;
		} else {
			x += k;
		}
	}
	printf("%d\n", x);
	
	return 0;
}

Measured memory_bytes: 1732
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int main() {
  int H, W, D;
  cin >> H >> W >> D;

  vector<pair<int, int>> hash(H*W+1);

  int temp = 0;
  for(int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> temp;
      hash[temp] = make_pair(i,j);
    }
  }

  int Q;
  cin >> Q;
  vector<int> d(H*W+1, 0);
  for (int i = D+1; i <= H*W; i++) {
    d[i] = d[i-D] + abs(hash[i].first - hash[i-D].first) + abs(hash[i].second - hash[i-D].second);
  }
  while(Q--) {
    int L, R;
    cin >> L >> R;
    cout << d[R] - d[L] << endl;
  }
  return 0;
}

Measured memory_bytes: 2176
// problem: "https://atcoder.jp/contests/abc154/tasks/abc154_c"

#include<bits/stdc++.h>

using namespace std;

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

    int i;
    vector<int>V(n);
    for(i=0;i!=n;i++)
        cin>>V[i];

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

    for(i=1;i!=n;i++)
        if(V[i] == V[i-1])
        {
            cout<<"NO";
            exit(0);
        }

    cout<<"YES";

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>
#include <queue>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
	#define DBG(X) cout << #X << "=" << (X) << '\n';
#else
	#define DBG(X)
#endif
 
using namespace std;

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

const int INT_INF = (int)(2e9);
const ll  LL_INF  = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for(auto el: v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for(auto& elem: ret) cin >> elem; return ret; }

const int MAXN = (int)2e5 + 7777;

struct Node {
	int mn, mx;

	Node(): mn(INT_INF), mx(-INT_INF) {}
	Node(int x): mn(x), mx(x) {}
	Node(int _mn, int _mx): mn(_mn), mx(_mx) {}

	Node combine(const Node& other) const {
		return Node(min(mn, other.mn), max(mx, other.mx));
	}
};

int a[MAXN], dp[MAXN], n, k;
Node tree[2 * MAXN];

void build() {
	for(int i = 0; i < n; ++i) {
		tree[i + n] = Node(a[i]);
	}

	for(int i = n - 1; i > 0; --i) {
		tree[i] = tree[2 * i].combine(tree[2 * i + 1]);
	}
}

Node get(int l, int r) {
	l += n;
	r += n + 1;
	Node rez;

	while(l < r) {
		if(l & 1) {
			rez = rez.combine(tree[l++]);
		}

		if(r & 1) {
			rez = rez.combine(tree[--r]);
		}

		l /= 2;
		r /= 2;
	}

	return rez;
}

void solve() {
	cin >> n >> k;

	for(int i = 0; i < n; ++i) {
		cin >> a[i];
	}

	build();

	for(int i = 0; i < n; ++i) {
		dp[i] = 1;

		if(i > 0 && a[i - 1] < a[i]) {
			dp[i] += dp[i - 1];
		}
	}

	int answ = 0;

	for(int i = 0; i + k - 1 < n; ++i) {
		if(dp[i + k - 1] < k) {
			int good = 1;

			if(i + k < n) {
				auto info = get(i, i + k);

				if(info.mn == a[i] && info.mx == a[i + k]) {
					good = 0;
				}
			}

			answ += good;
		}
	}

	for(int i = 0; i < n; ++i) {
		if(dp[i] >= k) {
			++answ;
			break;
		}
	}

	cout << answ << '\n';
}

int main() {
	fast_io();
	solve();

	return 0;
}


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

int main(){
    int a,b,c,sum1,sum2,sum3;

    cin >> a >> b >> c;

    sum1 = a + b;
    sum2 = b + c;
    sum3 = c + a;

    if ( sum1 < sum2 && sum1 < sum3 ) {
        cout << sum1 << endl;
    } else if ( sum2 < sum1 && sum2 < sum3 ) {
        cout << sum2 << endl;
    } else if( sum3 < sum1 && sum3 < sum2){
        cout << sum3 << endl;
    } else if( a == b && b == c ){
        cout << sum1 << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>

using ll = long long int;
using P = std::pair<ll, int>;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

ll c[30],s[400][30];
std::vector<P> v;

int main(void){
	int d,i,j,n=26;
	std::cin >> d;
	for(i=0; i<26; ++i){
		std::cin >> c[i];
	}
	for(i=0; i<d; ++i){
		for(j=0; j<n; ++j){
			std::cin >> s[i][j];
			v.push_back(P(s[i][j],j+1));
		}
		std::sort(v.begin(),v.end(),std::greater<P>());
		std::cout << v[0].second << std::endl;
		v.clear(); 
	}
	return 0;
}


Measured memory_bytes: 3748
#---------------------------------[インポート]---------------------------------#
from collections import deque
#---------------------------------[入力受取・初期設定]---------------------------------#
H, W = map(int, input().split())
C = tuple(map(int, input().split())) # 魔法の位置
D = tuple(map(int, input().split())) # ゴール
D_y = D[0] -1 # 0スタート
D_x = D[1] -1 # 0スタート
S = [list(input()) for _ in range(H)]
visited = [[-1] * W for _ in range(H)]
visited[C[0]-1][C[1]-1] = 0 # 初期値
moves = [(1, 0), (0, 1), (-1, 0), (0, -1)] # 普通の移動
main_q = deque()
magic_q = deque() # マジック用のキュー
main_q.append((C[0]-1, C[1]-1))
#---------------------------------[BFS]---------------------------------#
while main_q:
    y, x = main_q.popleft()
    magic_q.append((y, x))
    for move in moves:
        dy, dx = move
        moved_y = y + dy
        moved_x = x + dx

        if moved_y < 0 or H -1 < moved_y or moved_x < 0 or W -1 < moved_x:
            continue
        if S[moved_y][moved_x] == '#':
            continue
        if S[moved_y][moved_x] == '.' and visited[moved_y][moved_x] == -1:
            main_q.append((moved_y, moved_x))
            visited[moved_y][moved_x] = visited[y][x]
    #---------------------------------[マジック用のBFS]---------------------------------#
    if not main_q: # main_qが空になった場合は探索済みからマジックを使う
        while magic_q:
            y, x = magic_q.popleft()
            for dy in range(-2, 3):
                for dx in range(-2, 3):
                    moved_y = y + dy
                    moved_x = x + dx

                    if moved_y < 0 or H -1 < moved_y or moved_x < 0 or W -1 < moved_x:
                        continue
                    if S[moved_y][moved_x] == '#':
                        continue
                    if S[moved_y][moved_x] == '.' and visited[moved_y][moved_x] == -1:
                        main_q.append((moved_y, moved_x))
                        visited[moved_y][moved_x] = visited[y][x] + 1
#---------------------------------[回答表示]---------------------------------#
answer = visited[D_y][D_x]
print(answer)


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

#define rep(i,n) for(int i=0; i<n ; ++i)
#define REP(i,a,b) for(ll i=a; i<b; ++i)
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

//プロトタイプ宣言
void faster(void);
ll gcd(auto , auto);
ll get_digent(auto);
ll POW(auto , auto);
ll vec_max(auto & , string);
ll vec_min(auto & , string);

int main(){
  faster();
  ll d,n;
  cin >> d >> n;
  ll cnt1=0,cnt2=0,ans=1e18;
  REP(i,1,10010000){
    ll temp=i;
    cnt1=0;
    while(temp/100){
      if(temp%100!=0) break;
      cnt1++;
      temp/=100;
    }
    if(d == cnt1){
      ans = i;
      cnt2++;
    }
    if(cnt2 == n) break;
  }
  cout << ans << endl;
}






























//以下、ライブラリ

//同期解除
void faster(void){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}

//ユークリッドの互除法
ll gcd(auto a, auto b) {
  return (b ? gcd(b, a%b) : a);
} 

//桁数取得
ll get_digent(auto x){
  string s;
  s = to_string(x);
  ll digent = s.size();
  return digent;
} 

//べき乗計算
ll POW(auto x, auto y){
  if(y==0) return 1;
  if(y%2 == 1){
    ll temp = POW(x,y-1);
    return (temp*x);
  }
  else{
    ll temp = POW(x,y/2);
    return temp*temp;
  }
} 

//配列内の最大要素のイテレータ取得or要素取得
ll vec_max(auto &v, string s){
  auto itr = max_element(v.begin(),v.end());
  ll element = *itr;
  ll place = itr - v.begin();
  if(s == "element") return element;
  else if(s == "place") return place;
  else return -1;
}

ll vec_min(auto &v, string s){
  auto itr = min_element(v.begin(),v.end());
  ll element = *itr;
  ll place = itr - v.begin();
  if(s == "element") return element;
  else if(s == "place") return place;
  else return -1;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<functional>
#include<algorithm>
#include<iostream>
#define rep1(i,a) for(i=1;i<=a;i++) 
#define rep2(j,a) for(j=i+1;j<=n;j++)
#define rep3(k,a) for(k=j+1;k<=n;k++)
using namespace std;
int main(void)
{
	int n,x,sum;
	int i,j,k;
    while(1){
        cin>>n>>x;
        if(n==0&&x==0)break;
        rep1(i,n)rep2(j,n)rep3(k,n){
			if(i+j+k==x)sum+=1;
        }
        cout<<sum<<endl;
		sum=0;
    }
return 0;
}

Measured memory_bytes: 3056
#include <iostream>
#include <cmath>

using namespace std;

class A {
	int x, a, b;
public:
	void solve()
	{
		cin >> x >> a >> b;

		if (abs(x - a) < abs(x - b)) cout << "A" << endl;
		else cout << "B" << endl;
	}
};


int main()
{
	A solution;
	solution.solve();

	return 0;
}

Measured memory_bytes: 256
//----------------------------------------------------------------------
// ITP1_2_C   Sorting Three Numbers
//----------------------------------------------------------------------

//----------------------------------------------------------------------
// Includes
//----------------------------------------------------------------------
#include <iostream>
#include <vector>
#include <algorithm>

//----------------------------------------------------------------------
// Definitions
//----------------------------------------------------------------------

//----------------------------------------------------------------------
// Entry point
//----------------------------------------------------------------------
int main()
{
    //----------------------------------------------------------------------
    // Input
    //----------------------------------------------------------------------
    std::vector<int> numbers( 3, 0 );
    {
        for( size_t cnt = 0; cnt < 3; ++cnt )
        {
            int tmp = 0;

            std::cin >> tmp;
            numbers[cnt] = tmp;
        }

    }

    //----------------------------------------------------------------------
    // Sort
    //----------------------------------------------------------------------
    std::sort( numbers.begin(), numbers.end() );

    //----------------------------------------------------------------------
    // Output
    //----------------------------------------------------------------------
    std::cout << numbers[0];

    for( size_t idx = 1; idx < numbers.size(); ++idx )
    {
        std::cout << ' ' << numbers[idx];
    }

    std::cout << std::endl;

    return 0;
}

Measured memory_bytes: 3124
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
## dp ##
def DD2(d1,d2,init=0): return [[init]*d2 for _ in range(d1)]
def DD3(d1,d2,d3,init=0): return [DD2(d2,d3,init) for _ in range(d1)]
## math ##
def to_bin(x: int) -> str: return format(x, 'b') # rev => int(res, 2)
def to_oct(x: int) -> str: return format(x, 'o') # rev => int(res, 8)
def to_hex(x: int) -> str: return format(x, 'x') # rev => int(res, 16)
MOD=10**9+7
def divc(x,y) -> int: return -(-x//y)
def divf(x,y) -> int: return x//y
def gcd(x,y):
    while y: x,y = y,x%y
    return x
def lcm(x,y): return x*y//gcd(x,y)
def enumerate_divs(n):
    """Return a tuple list of divisor of n"""
    return [(i,n//i) for i in range(1,int(n**0.5)+1) if n%i==0]
def get_primes(MAX_NUM=10**3):
    """Return a list of prime numbers n or less"""
    is_prime = [True]*(MAX_NUM+1)
    is_prime[0] = is_prime[1] = False
    for i in range(2, int(MAX_NUM**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i*2, MAX_NUM+1, i): is_prime[j] = False
    return [i for i in range(MAX_NUM+1) if is_prime[i]]
def prime_factor(n):
    """Return a list of prime factorization numbers of n"""
    res = []
    for i in range(2,int(n**0.5)+1):
        while n%i==0: res.append(i); n //= i
    if n != 1: res.append(n)
    return res
## libs ##
from itertools import accumulate as acc, combinations as combi, product, combinations_with_replacement as combi_dup
from collections import deque, Counter
from heapq import heapify, heappop, heappush
from bisect import bisect_left
#======================================================#

def main():
    n = II()
    ss = [IS() for i in range(n)]
    ab_type = {}
    ab_type['_ab_'] = 0
    ab_type['b__a'] = 0
    ab_type['___a'] = 0
    ab_type['b___'] = 0
    for s in ss:
        for i in range(len(s)-1):
            if s[i:i+2] == 'AB':
                ab_type['_ab_'] += 1
        if s[0] == 'B' and s[-1] == 'A':
            ab_type['b__a'] += 1
        elif s[-1] == 'A':
            ab_type['___a'] += 1
        elif s[0] == 'B':
            ab_type['b___'] += 1
    cnt = 0
    cnt += ab_type['_ab_']
    if ab_type['b__a'] > 0:
        cnt += ab_type['b__a']-1
        if ab_type['___a'] > 0:
            cnt += 1
            ab_type['___a'] -= 1
        if ab_type['b___'] > 0:
            cnt += 1
            ab_type['b___'] -= 1
    cnt += min(ab_type['___a'], ab_type['b___'])
    print(cnt)

if __name__ == '__main__':
    main()

Measured memory_bytes: 4084
#include <bits/stdc++.h>
#define all(a) (a).begin(),(a).end()
using namespace std;

int main(){
	ios_base::sync_with_stdio(false);

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

	int n = (int)s.size();
	int m = (int)t.size();

	vector<vector<int>>lookup(n+1,vector<int>(m+1,0));

	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if( s[i-1] == t[j-1] ){
				lookup[i][j] = max({ lookup[i][j], lookup[i-1][j-1]+1 });
			}
			lookup[i][j] = max({ lookup[i][j], lookup[i-1][j], lookup[i][j-1] });
		}
	}

	string ans="";
	int i = n , j = m;
	while(i > 0 && j > 0){
		if(s[i-1] == t[j-1]){
			ans += s[i-1];
			i--;
			j--;
		}else if(lookup[i-1][j] > lookup[i][j-1]){
			i--;
		}else{
			j--;
		}
	}

	reverse(all(ans));

	cout << ans << endl ;

	return 0;
}


Measured memory_bytes: 38644
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please


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


	ll N, S;
	cin >> N >> S;

	for (int b = 2; b <= sqrt(N); b++) {
		ll s = 0;
		ll n = N;
		while (n) {
			s += n % b;
			n /= b;
		}
		if (s == S) {
			co(b);
			return 0;
		}
	}

	for (ll x = sqrt(N); x > 0; x--) {
		ll y = S - x;
		if ((N - y) % x == 0) {
			ll b = (N - y) / x;
			if (y < b && x < b && b >= 2 && y >= 0) {
				co(b);
				return 0;
			}
		}
	}
	if (N == S) {
		co(N + 1);
		return 0;
	}
	co(-1);

	Would you please return 0;
}

Measured memory_bytes: 256
import numpy as np
import copy
D=int(input())

c_list=list(map(int,input().split()))
c_list=np.array(c_list)
c_ll=np.array([0]*26)

d_list=[]
for i in range(D):
    dl=list(map(int,input().split()))
    d_list.append(np.array(dl))

# score
score=0

#expect
exp=[0]*26
for d in range(D):
    c_ll+=1
    for i in range(26):
        exp[i]+=d_list[d][i]
        c_ll2=copy.deepcopy(c_ll)
        c_ll2[i]=0
        exp[i]-=sum(c_list*c_ll2)

    j=exp.index(max(exp))
    c_ll[j]=0
    print(j+1)


Measured memory_bytes: 27336
#include<bits/stdc++.h>
using namespace std;
int minCoins(int coinList[], int n, int value) {
   int coins[value+1];

   if(value == 0)
      return 0;

   coins[0] = 0;

   for (int i=1; i<=value; i++)
      coins[i] = INT_MAX;

   for (int i=1; i<=value; i++) {
      for (int j=0; j<n; j++)
         if (coinList[j] <= i) {
            int tempCoins = coins[i-coinList[j]];
         if (tempCoins != INT_MAX && tempCoins + 1 < coins[i])
            coins[i] = tempCoins + 1;
      }
   }
   return coins[value];
}

int main() {


int coins[100100];
   int ind = 0 ;
   coins[ind++] = 1;





 int value ;


  cin >> value;
   int ans = 6;
   while(ans<=value)
   {
       coins[ind++] = ans;
       ans *= 6 ;
   }
   ans = 9 ;
   while(ans<=value)
   {
       coins[ind++] = ans;
       ans *= 9 ;
   }

   sort(coins,coins+ind) ;

   cout << minCoins(coins, ind, value);

   return 0;
}


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

const int MAX_N = 100009, MAX_Q = 100009;

int N, Q, l[MAX_Q], r[MAX_Q];
string S;

int s[MAX_N];

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

    s[0] = 0, s[1] = 0;
    for (int i = 1; i < N; i++) {
        if (S[i-1] == 'A' && S[i] == 'C') s[i+1] = s[i] + 1;
        else s[i+1] = s[i];
    }

    for (int i = 0; i < Q; i++) {
        cin >> l[i] >> r[i];
        cout << s[r[i]] - s[l[i]] << endl;
    }

    return 0;
}

Measured memory_bytes: 2176
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>

#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (int i = beg; end <= i; i--)

using namespace std;

struct Process {
	int i;
	int64_t p;
};

void traverse(int n,const multimap<int, int>& edges, const vector<int64_t>& vals, vector<int64_t>& anss)
{
	vector<bool> is_reached(n + 1);

	queue<Process> search;
	search.push({ 1, 0 });
	is_reached[1] = true;

	while (!search.empty()) {
		Process p = search.front();
		search.pop();

		int64_t next_p = p.p + vals[p.i];
		anss[p.i] = next_p;
		auto it = edges.lower_bound(p.i);
		while (it != edges.end() && it->first == p.i) {
			if (is_reached[it->second]) {
				it++;
				continue;
			}

			search.push({ it->second, next_p });
			is_reached[it->second] = true;
			it++;
		}
	}
}

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

	int n, q; cin >> n >> q;

	multimap<int, int> edges;
	FOR_LT(i, 0, n - 1) {
		int a, b; cin >> a >> b;
		edges.insert({ a,b });
		edges.insert({ b,a });
	}

	vector<int64_t> vals(n + 1);
	FOR_LT(i, 0, q) {
		int p; cin >> p;
		int64_t v; cin >> v;
		vals[p] += v;
	}

	vector<int64_t> anss(n + 1);
	traverse(n, edges, vals, anss);

	FOR_LE(i, 1, n) {
		cout << anss[i] << " ";
	}
	cout << endl;

	return 0;
}

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

const int MAX_N = 110;
int G[MAX_N][MAX_N];
int D[MAX_N], F[MAX_N], V[MAX_N];

void dfs(int u, int n, int& count) {
  int i;
  V[u] = 1;
  D[u] = ++count;
  for (i = 0; i < n; ++i) {
    if (G[u][i] && !V[i]) {
      dfs(i, n, count);
    }
  }
  F[u] = ++count;
}

int main() {
  int i, j, u, k, v, n, count;
  
  cin >> n;

  for (i = 0; i < n; ++i) {
    cin >> u >> k;
    for (j = 0; j < k; ++j) {
      cin >> v;
      G[u - 1][v - 1] = 1;
    }
  }

  count = 0;
  for (i = 0; i < n; ++i) {
    if (!V[i]) dfs(i,n,count);
  }

  for (i = 0; i < n; ++i) {
    cout << i + 1 << ' ' << D[i] << ' ' << F[i] << '\n';
  }

  return 0;
}


Measured memory_bytes: 3140
#include<cstdio>
#include<cstring>
#include<iostream>
#include<cctype>
#include<string>
#include<cmath>
using namespace std;

int main(){
    int n; // 学生の数

    while(cin >> n){
        if(0 == n){
            break;
        }
        // cout << n << endl;

        int s[n]; // 得点
        int sum = 0; // 合計
        double m = 0; // 平均値

        for(int i = 0; i < n; i++){
            cin >> s[i];
            // cout << s[i] << " ";
            sum += s[i];
        }
        // cout << endl;
        // cout << sum << endl;
        m = (double)sum / (double)n;
        // cout << m << endl; 

        double aaa = 0;
        for(int i = 0; i < n; i++){
            // cout << s[i] - m << endl;
            aaa += pow(s[i] - m, 2);
            // cout << aaa << endl;
        }
        aaa = sqrt(aaa / n);
        // cout << aaa << endl;
        printf("%lf\n", aaa);
    }

    return 0;
}


Measured memory_bytes: 3188
#!/usr/bin/env python3
# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(N: int, A: int, B: int, C: int, s: "List[int]"):
    v = [A, B, C]
    ans = []
    if sum(v) == 0:
        return None
    if sum(v) == 1:
        for l, r in s:
            if v[l] + v[r] == 0:
                return None
            if v[l] == 0:
                ans.append(l)
            else:
                ans.append(r)
            v[l], v[r] = v[r], v[l]
        return ans
    if sum(v) > 1:
        for i in range(N):
            l, r = s[i]
            if v[l] + v[r] == 0:
                return None
            if v[r] == 1 and v[l] == 1 and i != N - 1 and s[i] != s[i+1]:
                ln, rn = s[i + 1]
                if r == ln or r == rn:
                    ans.append(r)
                    v[l] -= 1
                    v[r] += 1
                else:
                    ans.append(l)
                    v[l] += 1
                    v[r] -= 1
            elif v[r] == 0 or v[l] > v[r]:
                ans.append(r)
                v[l] -= 1
                v[r] += 1
            else:
                ans.append(l)
                v[l] += 1
                v[r] -= 1
        return ans


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    def s2i(s: str):
        return ord(s[0])-ord('A'), ord(s[1])-ord('A')

    def i2s(i: int):
        return chr(i + ord('A'))

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    s = [s2i(next(tokens)) for _ in range(N)]  # type: "List[int]"
    ans = solve(N, A, B, C, s)
    if ans == None:
        print(NO)
    else:
        print(YES)
        print("\n".join(list(map(i2s, ans))))


if __name__ == '__main__':
    main()


Measured memory_bytes: 89608
#include <cstdio>
#include <iostream>
using namespace std;
string a;
int main()
{
    cin>>a;
    int n=a.length();
    for(register int i=0;i<n;i++)
    if(a[i]=='C')
	{
    	for(register int j=i+1;j<n;j++)
    	if(a[j]=='F')
    	{
    		printf("Yes");
			return 0;
		}
		break;
	}
	printf("No");
    return 0;
}

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

using namespace std;

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

	int n;
	cin >> n;

	int cnt = 0, p;

	for(int i = 1; i <= n; i++) {
		cin >> p;
		if(p != i) cnt++;
	}

	if(cnt <= 2) cout << "YES";
	else cout << "NO";

	return 0;
}

Measured memory_bytes: 256
import std.stdio;
import std.algorithm;
import std.string;
import std.range;
import std.array;
import std.conv;
import std.complex;
import std.math;
import std.ascii;
import std.bigint;
import std.container;

double dot(int[] u, int[] v) {
	return u[0]*v[0]+u[1]*v[1];
}
double cross(int[] u, int[] v) {
	return u[0]*v[1]-u[1]*v[0];
}
double angle(int[] u, int[] v) {
	return 1-dot(u,v)/sqrt(dot(u,u))/sqrt(dot(v,v));
}

bool near(int[] p0, int[] p1, int[] p2, int[] p3) {
	int[2] v1 = p1[] - p0[];
	int[2] v2 = p2[] - p1[];
	int[2] v3 = p3[] - p1[];
	double a2 = angle(v1, v2);
	double a3 = angle(v1, v3);
	double eps = 1e-5;
	if(abs(a2-a3) < eps)
		return dot(v2, v2) < dot(v3,v3);
	else
		return a2<a3;
}

void main() {
	int n = to!int(readln().strip());
	while(n) {
		int[][] p;
		foreach(i; 0..n) {
			p ~= array(map!(to!int)(readln().strip().split()));
		}

		int[] p0 = [0,-1];
		int[] p1 = [0,0];
		double l = 0;
		while(n--) {
			int pi = 0;
			foreach(i; 1..p.length) {
				if(near(p0, p1, p[i], p[pi]))
					pi = cast(int)i;
			}
			int[2] v = p[pi][] - p1[];
			l += sqrt(dot(v,v));
			p0 = p1;
			p1 = p[pi];
			p = p[0..pi]~p[pi+1..$];
		}
		writefln("%.1f",l);

		n = to!int(readln().strip());
	}
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

typedef long long ll;
typedef long double ld;

const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int money[4] = {300000, 200000, 100000, 0};
    int x, y;
    cin >> x >> y;
    x--, y--;
    if (x > 3) x = 3;
    if (y > 3) y = 3;
    if (x == 0 && y == 0) cout << money[x] + money[y] + 400000 << endl;
    else cout << money[x] + money[y] << endl;
    
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a,b,c,r,d,s;
	
	scanf("%d %d %d",&a,&b,&c);
	
	if(a>=b){
		r=a;
		a=b;
		b=r;
	}if(b>=c){
		s=b;
		b=c;
		c=s;
	}if(a>=b){
		d=a;
		a=b;
		b=d;
	}
	
	printf("%d %d %d\n",a,b,c);
		
	return 0;
}


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

int main(){
  string S;
  bool flag = true;
  cin >> S;
  for(int i=0; i<S.size(); i+=2){
    if(S[i]=='L'){
      flag=false;
      break;
    }
  }
  for(int i=1; i<S.size(); i+=2){
    if(S[i]=='R'){
      flag=false;
      break;
    }
  }
  if(flag){
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
def gcd(p, q):
    if p % q == 0:
        return q
    else:
        return gcd(q, p % q)
k = int(input())
ans = 0
for m in range(1, k+1):
    for n in range(1, k+1):
        for l in range(1, k+1):
            ans += gcd(gcd(m, n), l)
print(ans)

Measured memory_bytes: 74244
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#include <time.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;
 
using namespace std;

 
int main(int argc, char* argv[])
{
    int n,m;
    scanf("%d%d", &n, &m);
    vector<pair<int,int> > z;
    int i;
    for(i=0; i<n; i++) {
        int a,b;
        scanf("%d%d", &a, &b);
        z.push_back(make_pair(a,b));
    }
    sort(z.begin(),z.end());

    ll ans=0;
    set<pair<int,int> > zz;  // val,id
    int curr=0;
    for(i=1; i<=m; i++) {
        while(curr<n && z[curr].first<=i) {
            zz.insert(make_pair(z[curr].second,curr));
            curr++;
        }
        if(!zz.empty()) {
            auto it=zz.rbegin();
            ans+= it->first;
            zz.erase(*it);
        }
    }
    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 5620
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef  unsigned long long int ull;
typedef pair<ll,ll> P;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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 (a>b) { a=b; return 1; } return 0; }
V<ll> a,sum;
 ll n,m;
 bool dbag;
bool C(ll mid){
    ll cnt=0;
    ll d;
    for(int i=0;i<n;i++){
        d=mid-a[i];
        ll t=a.end()-lower_bound(all(a),d);
        cnt+=t;
    }
    if(cnt>=m){
        return true;
    }
    return false;
}
ll make(ll mid){
    ll cnt=0,res=0,d;
for(int i=0;i<n;i++){
        d=mid-a[i];
        ll t=a.end()-lower_bound(all(a),d);
        cnt+=t;
        res+=a[i]*t+sum[n]-sum[n-t];
        }
        return res-mid*(cnt-m);
    }
int main(){
 cin>>n>>m;
 a.resize(n),sum.assign(n+1,0);
 for(int i=0;i<n;i++)cin>>a[i];
 sort(all(a));
 for(int i=0;i<n;i++)sum[i+1]=a[i]+sum[i];
 //for(int i=0;i<n;i++)cout<<a[i]<<" ";
 //cout<<endl;
 ll ok=0,ng=1e18,mid;
 while(ng-ok>1){
     mid=(ok+ng)/2;
    if(C(mid))ok=mid;
    else ng=mid;
 }
 cout<<make(ok)<<endl;
}



Measured memory_bytes: 1920
Scanf.(Array.(
  let n,k=scanf" %d %d"@@fun u v->u,v in
  let h=init n@@fun _->scanf" %d"@@fun v->v in
  sort compare h;
  init(n-k+1)(fun i->h.(i+k-1)-h.(i))
  |>fold_left min max_int
  |>print_int))

Measured memory_bytes: 5376
#!/usr/bin/env python

def main():
    a, b, m = map(int, input().split())
    a_list = list(map(int, input().split()))
    b_list = list(map(int, input().split()))
    c_list = [list(map(int, input().split())) for _ in range(m)]

    cost = min(a_list) + min(b_list)

    for i in range(m):
        discount = a_list[c_list[i][0] - 1] + b_list[c_list[i][1] - 1] - c_list[i][2]
        if cost > discount:
            cost = discount

    print(cost)

if __name__ == '__main__':
    main()


Measured memory_bytes: 38444
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve(args);
    }

    public void solve(String[] args) {
        MyScanner scanner = new MyScanner();
        int N = scanner.nextInt();
        String ans = "No";
        for(int i = 1; i <= 9; i++) {
        	for (int x = 1; x <= 9; x++) {
        		if(N == i * x) {
        			ans = "Yes";
        			break;
        		}
        	}
        }
        System.out.println(ans);

     }



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

    private static long lcm(long m, long n) {
        return m * n / gcd(m, n);
    }

    private class MyScanner {
        String[] s;
        int i;
        BufferedReader br;
        String reg = " ";
        MyScanner () {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        public String next() {
            try {
                if (i < s.length) return s[i++];
                String line = br.readLine();
                while (line.equals("")) {line = br.readLine();}
                s = line.split(reg, 0);
                i = 0;return s[i++];
            } catch (Exception e) {e.printStackTrace();}
            return null;
        }
        public int nextInt() {
            try {return Integer.parseInt(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public double nextDouble() {
            try {return Double.parseDouble(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public long nextLong()  {
            try {return Long.parseLong(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
    }
}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define test ll t; cin>>t; while(t--)
#define ll long long 
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define forn(i, n) for (int i = 0; i < int(n); i++)

int main()
{
    fast;

     ll a[5];
     for(ll i=0;i<5;i++)
     cin>>a[i];
     for(ll i=0;i<5;i++){
         if(a[i]==0){
         cout<<i+1<<"\n";
         break;
         }
    
    }
}



            
        


Measured memory_bytes: 3608
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getInts(N int) []int {
	ret := make([]int, N)
	for i := 0; i < N; i++ {
		ret[i] = getInt()
	}
	return ret
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)
	K := getInt()
	a := 7
	cnt := 1
	for {
		// out(a, cnt)
		if a%K == 0 {
			out(cnt)
			return
		}
		if cnt > 10000000 {
			break
		}
		a = a*10 + 7
		cnt++
		a %= K
	}
	out(-1)
}


Measured memory_bytes: 1792
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace NotFounds
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            new Program().Solve(new ConsoleInput(Console.In, ' '));
            Console.Out.Flush();
        }

        public void Solve(ConsoleInput cin)
        {
            checked
            {
                var train = cin.ReadIntArray(2).Min();
                var bus = cin.ReadIntArray(2).Min();
                WriteLine(train + bus);
            }
        }
    }

    public class HashMap<K, V> : Dictionary<K, V>
    {
        public HashMap() : base() { }
        public HashMap(int cap) : base(cap) { }
        public HashMap(IDictionary<K, V> dictionary) : base(dictionary) { }
        new public V this[K i]
        {
            get
            {
                V v;
                return TryGetValue(i, out v) ? v : base[i] = default(V);
            }
            set { base[i] = value; }
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
        public void ReadIntArrays(long N, out int[] A, out int[] B) { A = new int[N]; B = new int[N]; for (long i = 0; i < N; ++i) { A[i] = ReadInt; B[i] = ReadInt; }}
        public void ReadLongArrays(long N, out long[] A, out long[] B) { A = new long[N]; B = new long[N]; for (long i = 0; i < N; ++i) { A[i] = ReadLong; B[i] = ReadLong; }}
    }
}


Measured memory_bytes: 13396
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] a = new int[n];
    for(int i = 0; i < n; i++) {
      a[i] = sc.nextInt();
    }
    Arrays.sort(a);
    int p = 0;
    String ans = "YES";
    for(int i = 0; i < (n - 1); i++) {
      if(a[i] == a[i + 1]) p++;
    }
    if(p > 0) ans = "NO";
    System.out.println(ans);
  }
}


Measured memory_bytes: 66428
#include <stdio.h>

int main(void) {
   int A, B , K , C;{
    

       scanf("%d %d",&A ,&B);
        K=(A+B)/2;
        C=(A+B)%2;
       
     if (C==0)
      printf("%d\n",K);
      else
      printf("IMPOSSIBLE\n");





  
     }  return 0;
}

Measured memory_bytes: 256