akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int int64_t
#define rep(i, a, b) for(int i = a; i < b; ++i)

int debug = 0;

const int N = 5e5;

int mod = 1e9 + 7;
int n, k, ans, sg[N], take[N];
array <int, 2> a[N];

void mul(int &a, int b) {
    a = (a * b + mod * mod + mod) % mod;
}

int get_sign(int x) {
    return (x > 0) ? 1 : (x < 0) ? -1 : 0;
}

int solve() {
    cin >> n >> k;
    rep(i, 0, n) {
        int x;
        cin >> x;
        a[i] = {{abs(x), get_sign(x)}};
    }
    sort(a, a + n);
    reverse(a, a + n);
    int sign = 1;
    rep(i, 0, k) {
        take[i] = 1;
        sign *= a[i][1];
    }
    if (debug) {
        cerr << " a: ";
        rep(i, 0, n) cerr << " {" << a[i][0] << ", " << a[i][1] << "}, ";
        cerr << "\n";
    }
    if (sign == 1 || k == n) {
        ans = 1;
        rep(i, 0, k) {
            mul(ans, a[i][0] * a[i][1]);
        }
        return ans;
    }
    if (sign == 0 || a[k][0] == 0) {
        return 0;
    }
    /// sign == -1, k < n
    if (debug) {
        puts(" We are in sign == -1 && k < n");
    }
    int lst_mns = -1, nx_mns = -1;
    int lst_pls = -1, nx_pls = -1;
    rep(i, 0, k) {
        if (a[i][1] == 1) {
            lst_pls = i;
        } else if (a[i][1] == -1) {
            lst_mns = i;
        }
    }
    for (int i = n - 1; i >= k; --i) {
        if (a[i][1] == 1) {
            nx_pls = i;
        } else if (a[i][1] == -1) {
            nx_mns = i;
        }
    }
    if (debug) {
        cerr << " lst_mns: " << lst_mns << " nx_mns: " << nx_mns << '\n';
        cerr << " lst_pls: " << lst_pls << " nx_pls: " << nx_pls << '\n';
    }
    if (lst_pls == -1 && nx_pls == -1) {
        if (a[n - 1][0] == 0) {
            return 0;
        }
        ans = 1;
        for (int i = n - 1; i >= n - k; --i) {
            mul(ans, a[i][0] * a[i][1]);
        }
        return ans;
    }
    bool f1 = (lst_mns != -1) && (nx_pls != -1);
    bool f2 = (lst_pls != -1) && (nx_mns != -1);
    if (f1 && !f2) {
        take[lst_mns] = 0;
        take[nx_pls] = 1;
    } else if (!f1 && f2) {
        take[lst_pls] = 0;
        take[nx_mns] = 1;
    } else if (f1 && f2) {
        int x = a[lst_mns][0];
        int y = a[nx_pls][0];
        int z = a[lst_pls][0];
        int w = a[nx_mns][0];
        if (y * z > x * w) {
            take[lst_mns] = 0;
            take[nx_pls] = 1;
        } else {
            take[lst_pls] = 0;
            take[nx_mns] = 1;
        }
    } else {
        assert(0);
    }
    if (debug) {
        cerr << " take: ";
        rep(i, 0, n) cerr << take[i] << ' ';
        cerr << '\n';
    }
    ans = 1;
    rep(i, 0, n) {
        if (take[i]) {
            mul(ans, a[i][0] * a[i][1]);
        }
    }
    return ans;
}

main() {
    cout << solve() << '\n';
}

Measured memory_bytes: 8328
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
#include <bitset>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
#define vec_unique(_a) _a.erase(std::unique(all(_a)), _a.end());
#define vvec vector<vector<ll>>
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
const int mod = 1000000007;
ll power(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x *= x; p /= 2; } else { a *= x; p--; } }return a; }
ll mpower(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x = x * x % mod; p /= 2; } else { a = a * x % mod; p--; } }return a; }
ll c(ll n, ll k) { ll a = 1; rep(i, 1, k) { a *= n - i + 1; a /= i; }return a; }
ll mc(ll n, ll m) { ll k = 1, l = 1; rep(i, n - m + 1, n + 1) k = k * i % mod; rep(i, 1, m + 1) l = l * i % mod; l = mpower(l, mod - 2); return k * l % mod; }

int main() {
	string s;
	ll sum = 0, v;
	cin >> s;
	rep(i, 0, 1 << (s.size() - 1)) {
		v = 0;
		//printf("i:%d\n", i);
		rep(i2, 0, s.size()) {
			v *= 10;
			v += s[i2] - '0';
			if (!(i >> i2 & 1)) {
				//if(v)printf("%lld\n", v);
				sum += v;
				v = 0;
			}
		}
	}
	printf("%lld\n", sum);
	return 0;
}

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

using namespace std;

using ll = long long;

const ll MOD = 1000000007;

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

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int a, b, c; cin >> a >> b >> c;
    cout << min(a+b, min(b+c, c+a)) << endl;
}

Measured memory_bytes: 256
s=input()
n=len(s)
ans=0
for i in range(2**(n-1)):
    binary=bin(i)[2:].zfill(n-1)
    m=[0]+[j+1 for j in range(n-1) if binary[j]=="1"]+[n]
    ans+=sum( int(s[m[j-1]:m[j]]) for j in range(1,len(m)) )
print(ans)

Measured memory_bytes: 40176
//package Beginner121;

import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        int m = s.nextInt();
        ArrayList<pair> arr = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            arr.add(new pair(s.nextInt(), s.nextInt()));
        }

        Collections.sort(arr);

        long ans = 0;
        int i = 0;
        while(m != 0) {
            pair p = arr.get(i);
            if(p.quan >= m) {
                ans += (long) p.val * (long)m;
                m = 0;
            } else {
                ans += (long) p.val * (long)p.quan;
                m -= p.quan;
            }
            i++;
        }

        System.out.println(ans);
    }

    private static class pair implements Comparable<pair>{
        int val;
        int quan;

        @Override
        public String toString() {
            return this.val + " " + this.quan;
        }

        public pair(int val, int quan) {
            this.val = val;
            this.quan = quan;
        }

        @Override
        public int compareTo(pair o) {
            return Integer.compare(this.val, o.val);
        }
    }
}


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

typedef long long ll;
#define REP(i,n) for(ll i=0; i<(ll)(n); i++)
#define REPM(i,n) for(ll i=(n); 0<=i; i--)
#define VI vector<int>
#define VL vector<ll>
#define VD vector<double>
#define VS vector<string>
#define V_SORT_U(x) sort(x.begin(), x.end());
#define V_SORT_D(x) sort(x.begin(), x.end(),greater<int>());
#define V_SUM(x) accumulate(x.begin(), x.end(), 0)
#define STR_TRANS_UP(x) transform(x.begin(), x.end(), x.begin(), ::toupper);
#define STR_TRANS_LOW(x) transform(x.begin(), x.end(), x.begin(), ::tolower);

int main(void){
    ll N;

    cin >> N;

    VL tmp(N);
    ll result=1;
    
    REP(i,N)
    {
        cin >> tmp.at(i);

        if(tmp.at(i) == 0)
        {
            cout << "0" << endl;
            return 0;
        }         
    }

    REP(i,N)
    {
        if(tmp.at(i)==1)
        {
            continue;
        }

        //除算で行わないと判定がおかしくなる
        if( tmp.at(i)<=(1000000000000000000/result) )
        {
            result *= tmp.at(i);
        }
        else
        {
            cout << "-1" << endl;
            return 0;
        }
    }

    cout << result << endl;

    return 0;
}

Measured memory_bytes: 4032
#include<bits/stdc++.h>
#define ll long long int 
using namespace std;
int main()
{
 	string s;
  cin>>s;
  ll c=0;
  ll n=s.length()/2;
  for(ll i=0;i<n;i++)
  {
    if(s[i]!=s[s.length()-i-1])
      c++;
  }
  cout<<c<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
#define ll long long
int main()
{
    int n;
    ll d;
    scanf("%d%lld",&n,&d);
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        ll x,y;
        scanf("%lld%lld",&x,&y);
        ans+=(x*x+y*y<=d*d);
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 1736
import bisect

n = int(input())
# bisectが昇順のリストにしか対応していないのでマイナスをかける。
# -> ansの順序が昇順で管理できるようになる。最小値をans[-1]で管理する。
A = [- int(input()) for _ in range(n)]

num = 1
ans = [A[0]]
for a in A[1:]:
  # ansの最小値以下の数値 -> append, else: a > ans[?] を満たす左端の?の値を書き換える。
  if a >= ans[-1]:
    ans.append(a)
    num += 1
  else:
    pos = bisect.bisect_right(ans, a) 
    ans[pos] = a 
print(num)

Measured memory_bytes: 8604
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#include <functional>
#include <time.h>
#pragma warning(disable:4996) 

typedef long long ll;
typedef unsigned long long ull;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define LINF3 1000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;


void solve()
{
    int n, m;
    scanf("%d%d", &n, &m);
    vector<ll> x(n), sx(n+1), y(m), sy(m+1);
    int i;
    for (i = 0; i < n; i++) {
        scanf("%lld", &x[i]);
        sx[i + 1] = (sx[i] + x[i])%MOD;
    }

    for(i=0; i<m; i++) {
        scanf("%lld", &y[i]);
        sy[i + 1] = (sy[i] + y[i])%MOD;
    }
    ll s0 = 0;
    for (i = 1; i < n; i++) {
        s0 = (s0 + sx[n] - sx[i] - sx[i] + MOD*2)%MOD;
    }
    ll s1 = 0;
    for (i = 1; i < m; i++) {
        s1 = (s1 + sy[m] - sy[i] - sy[i] + MOD*2)%MOD;
    }
    ll ans = (s0 * s1)%MOD;
    printf("%lld\n", ans);


    return;
}


int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T;
    scanf("%d", &T);
    int t;
    for(t=0; t<T; t++) {
        //printf("Case #%d: ", t+1);
        solve();
    }
#endif
    return 0;
}


Measured memory_bytes: 5904
N,M=map(int,input().split())
a=[]
ans=1
def calc(n):#nの素因数分解
    for i in range(2,int(n**0.5)+10):
        count=0
        while n%i==0:
            n//=i
            count+=1
        if count>=1:
            a.append([i,count])
    if n!=1:
        a.append([n,1])
calc(M)
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result
for i in range(len(a)):
    ans*=cmb(a[i][1]+N-1,a[i][1])
print(ans%(10**9+7))

Measured memory_bytes: 3064
#include<stdio.h>
#define P 10000
int w[100005];
int n;int k;
int can_fill(int load_w);
int main(){
	scanf("%d %d",&n,&k);
	for(int i=0;i<n;i++){
		scanf("%d",&w[i]);
	}
	int left=1;int right=100000*10000;
	while(left<right){
		int mid=(left+right)/2;
		if(can_fill(mid)) right=mid;
		else left=mid+1;
	}
	printf("%d\n",left-1);
}
int can_fill(int load_w){
	int constant=load_w;int count=0;
	int huo_num=0;
for(int i=0;i<k;i++){
	int p=constant;
	while(huo_num<n&&p-w[huo_num]>0){
		p=p-w[huo_num];
		huo_num++;
	}	
}
if (huo_num==n) return 1;
else return 0; 
}


Measured memory_bytes: 3080
#include <stdio.h>


int main(int argc, char **argv)
{
  int a,b,x;
  scanf("%d %d",&a,&b);
  int i,ab,aa;
  ab = b - a;
  aa = 0;
  for(i = 1 ; i < ab ; i++){
    aa = aa + i;
  }
  x = aa - a;
  printf("%d\n",x);

  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int a[1000010];
int main()
{
	int n,x;
	cin>>n>>a[1];
	for(int i=2;i<=n+1;i++)
		cin>>a[i];
	n++;
	sort(a+1,a+n+1);
	int res=a[2]-a[1];
	for(int i=3;i<=n;i++)
		res=__gcd(res,a[i]-a[i-1]);
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long mod = 1e9 + 7;

ll gcd(ll a, ll b) {
	return b ? gcd(b, a % b) : a;
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

ll f(ll a, ll x) {
	if (a == -1) {
		return 0;
	}
	return a / x + 1;
}

int main() {

	ll a, b, x;
	cin >> a >> b >> x ;

	ll ans = f(b, x) - f(a-1, x);
	
	cout << ans << endl;
}


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

int32_t main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    // cin >> t;
    while (t--) {
        int a;
        cin >> a;
        cout << a + a * a + a * a * a;
    }
    return 0;
}

Measured memory_bytes: 3648
N = int(input())

a = []
for i in range(1, N + 1):
    s, p = input().split()
    a.append((s, int(p), i))
a.sort(key=lambda x: (x[0], -x[1]))
# 市昇順, 点数降順

for _, _, i in a:
    print(i)


Measured memory_bytes: 38384
// オーバーキルだがしゃくとりでやるか
package main

import "fmt"

func main() {
	var S string
	fmt.Scan(&S)
	T := make([]string, len(S))
	for i, c := range []rune(S) {
		T[i] = string(c)
	}
	ans := 0
	r := 0
	for l := 0; l < len(S); l++ {
		for r < len(S) && (T[r] == "A" || T[r] == "C" || T[r] == "G" || T[r] == "T") {
			r++
		}
		ans = max(ans, r-l)
		if l == r {
			r += 1
		}
	}
	fmt.Println(ans)
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

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


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
int main()
{
  int n;
  cin >> n;
  int t = 0;
  rep(i, n)
  {
    if ((t + 1) * t / 2 >= n)
      break;
    t++;
  }
  while (n != 0)
  {
    if (t <= n)
    {
      cout << t << endl;
      n -= t;
    }
    t--;
  }
  return 0;
}

Measured memory_bytes: 256
s = input()
t = input()

m = len(s) - len(t)
res = len(t)
for i in range(m+1):
    tmp = s[i:i+len(t)]
    x = 0
    for j in range(len(t)):
        if tmp[j] != t[j]:
            x += 1
    res = min(res, x)

print(res)


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

const long long int mod = 1000000007;

long long int fact[100005];

int main(){
    int n, m;
    cin >> n >> m;
    if(abs(n-m) >= 2)cout << 0 << endl;
    else{
        fact[1] = 1;
        for(int i=2;i<=100000;++i){
            fact[i] = i * fact[i-1] % mod;
        }

        long long int ans = fact[n] * fact[m] % mod;
        if(n == m)ans = (ans*2) % mod;
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <climits>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>
#include <cstdio>
#include <climits>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <cstring>
#include <set>
#include <map>
#include <complex>
#include <tuple>

#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
long long MOD = 1000000007;
long long INF = 1000000000000000000; //10^18
typedef long long ll;
typedef unsigned long long ull;


ll powMod(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll t = powMod(x, n/2, mod);
  t = t * t % mod;
  if (n & 1) return t * x % mod;
  return t;
}

ll gcd(ll a, ll b) {
  if (a == 0 || b == 0) return a + b;
  if (b > a) return gcd(b, a);
  return gcd(b, a % b);
}



int main(void) {

  int k;
  set<int> s;
  cin >> k;

  int t = 0;
  int ans = 0;
  while (true) {
    ans++;
    t = (t*10%k+7)%k;
    if (t == 0) {
      cout << ans << endl;
      return 0;
    }
    if (s.find(t) != s.end()) {
      cout << -1 << endl;
      return 0;
    }
    s.insert(t);
  }
}
  


Measured memory_bytes: 50504
import java.util.*;

public class Main {
    static int n = 0;
    static int res = 0;
    
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        n = Integer.parseInt(sc.next());
        
        dfs(0);
        
        System.out.println(res);
    }
    
    public static void dfs(long l){
        if(l > n){
            return;
        }
        
        String str = String.valueOf(l);
        
        if(str.contains("3") && str.contains("5") && str.contains("7")){
            res++;
        }
        
        dfs(10*l+3);
        dfs(10*l+5);
        dfs(10*l+7);
    }
}

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


typedef long long ll;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBAC
/*map<Keyの型, Valueの型> 変数名;
queue<型> 変数名;
priority_queue<型> 変数名;
priority_queue<型, vector<型>, greater<型>> 変数名;*/
//copy(v1.begin(), v1.end(), back_inserter(v2));
using namespace std;

int gcd(int a, int b) {
	int c;
	if (a < b) {
		c = a; a = b; b = c;
	}
	while (b != 0) {
		c = a % b; a = b; b = c;
	}
	return a;
}

int sort_greater(int m,int n) {
	vector<int> a(m);
	for (int i = 0; i < m; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end(),greater<int>());
	for (int i = 0; i < n; i++) {
		cout << a[i];
	}
		return 0;
}

int bubblesort(int a[], int n) {
	int sw = 0;
	bool flag = 1;
	for (int i = 0; flag; i++) {
		flag = 0;
		for (int j = n - 1; j >= i + 1; j--) {
			if (a[j] < a[j - 1]) {
				swap(a[j], a[j - 1]);
				flag = 1;
				sw += 1;
			}
		}
	}
	return sw;
}

int a_z()
{
	for (int i = 0; i <= ('Z' - 'A'); i++) {
		cout << (char)('A' + i);
	}
	return 0;
}

int selecttionsort(int a[], int n) {
	int t,sw = 0, minj;
	for (int i = 0; i < n - 1; i++) {
		minj = i;
		for (int j = 0; j < n - 1; j++) {
			if (a[j] < a[minj]) {
				minj = j;
			}
		}
		t = a[i]; a[i] = a[minj]; a[minj] = t;
		if (i != minj) sw += 1;

	}
	return sw;
}

bool is_prime(int x) {
	if (x <= 1) return false;
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0) return false;
	}
	return true;
}

map<string, int> memo;

using P=pair<int, int>;

struct Clock {
	int hour, minute, second;
	void set(int h, int m, int s) {
		hour = h; minute = m; second = s;
	}
	string to_str() {
		string h, m, s;
		h = to_string(hour);
		m= to_string(minute);
		s= to_string(second);
		if (h.size() < 2) h = "0" + h;
		if (m.size() < 2) m = "0" + m;
		if (s.size() < 2) s = "0" + s;
		return h + ":" + m + ":" + s;
	}
	void shift(int diff_second) {
		int h, m;
		h = diff_second / 3600;
		m = diff_second / 60;
		diff_second %= 60;
		second += diff_second;
		
	}
};


/*void dfs(int v, int p = -1) {
	for (int u : to[v]) {
		if (u == p) continue;
		ans[u] += ans[v];
		dfs(u, v);
	}
}*/
int main() {
	//sort(a.begin(),a.end());
	int a, b;
	cin >> a >> b;
	if ((a + b) % 2 == 0) cout << (a + b) / 2;
	else cout << "IMPOSSIBLE";
	return 0; 
}









Measured memory_bytes: 256
#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)

typedef long long ll;

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

int gcd(int a, int b) {
    if (b == 0) {
        return a;
    } else {
        return gcd(b, a % b);
    }
}

int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    rep (i, 3) {
      string t;  cin >> t;
      cout << t[0];
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
from math import floor
l = input().split()
n = int(l[0])
m = int(l[1])
s = [-1]
c = [-1]
for i in range(m):
    l = input().split()
    s.append(int(l[0]))
    c.append(int(l[1]))
result = -1
if n == 1:
    for i in range(10):
        poss = True
        for i2 in range(m):
            if i != c[i2 + 1]:
                poss = False
                break
        if poss:
            result = i
            break
elif n == 2:
    for i in range(10,100):
        poss = True
        ilist = [-1]
        ilist.append(floor(i/10))
        ilist.append(i - ilist[1] * 10)
        for i2 in range(m):
            if ilist[s[i2 + 1]] != c[i2 + 1]:
                poss = False
                break
        if poss:
            result = i
            break
else:
    for i in range(100,1000):
        poss = True
        ilist = [-1]
        ilist.append(floor(i/100))
        ilist.append(floor((i - ilist[1] * 100)/10))
        ilist.append(i - ilist[1] * 100 - ilist[2] * 10)
        for i2 in range(m):
            if ilist[s[i2 + 1]] != c[i2 + 1]:
                poss = False
                break
        if poss:
            result = i
            break
print(result)

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

using namespace std;
using ll = unsigned long long;
using P = pair<ll, ll>;

const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

const int CASES = 2;

void solve() {
    map<string, int> mp;
    mp["SUN"] =7;
    mp["MON"] =6;
    mp["TUE"] =5;
    mp["WED"] =4;
    mp["THU"] =3;
    mp["FRI"] =2;
    mp["SAT"] =1;
    string s; cin >> s;
    cout << mp[s] << endl;
}

int main() {
#ifdef MYLOCAL
    vector<string> filenames {"input1.txt", "input2.txt", "input3.txt", "input4.txt"};
    cout << "------------\n";
    for(int i = 0; i < CASES; ++i){
        ifstream in(filenames[i]);
        cin.rdbuf(in.rdbuf());
        solve();
        cout << "------------\n";
    }
#else

    solve();

#endif
    return 0;
}



Measured memory_bytes: 256
N, X, Y = map(int, input().split())
dist_list = [0]*N

for i in range(N-1):
    for j in range(i+1, N):
        a = j - i
        b = abs(i+1 - X) + abs(j+1 -Y) + 1
        dist_list[min(a,b)] += 1

for k in range(N-1):
    print(dist_list[k+1])



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

int main(){

    string s,t;
    cin >> s >> t;
    sort(s.begin(),s.end());
    sort(t.begin(),t.end());
    reverse(t.begin(),t.end());

    if(s < t){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }



    return 0;
}

Measured memory_bytes: 256
n = int(input())
p = list(map(float,input().split()))
dp = [[0] * (n + 1) for i in range(n)]

for i in range(n):
    for j in range(n):
        if i == 0:
            dp[0][0] = 1 - p[0]
            dp[0][1] = p[0]

        else:
            #裏の時、表が出た枚数jはかわらない+確率は1-p[i]
            dp[i][j] += dp[i - 1][j] * (1 - p[i])
            if dp[i - 1][j] == 0:continue
            #表の時、表が出た数は+1、確率はp[i]
            dp[i][j + 1] += dp[i - 1][j] * p[i]
print(sum(dp[-1][n//2 + 1:]))


Measured memory_bytes: 254216
#include <iostream>
#include <set>
#include <vector>
using namespace std;

typedef long long ll;


ll gcd(ll a, ll b) {
  return a % b == 0 ? b : gcd(b, a % b);
}

int main() {
  ll a,b;
  cin >> a >> b;
  set<ll> A,B;
  for(ll i = 1; i * i <= a; i++) {
    ll tmp = a / i;
    if(a % i == 0) {
      A.insert(tmp);
      A.insert(i);
    }
  }
  for(ll i = 1; i * i <= b; i++) {
    ll tmp = b / i;
    if(b % i == 0) {
      B.insert(tmp);
      B.insert(i);
    }
  }


  vector<ll> ans;
  for(auto itr = A.begin(); itr != A.end(); ++itr) {
    if(B.find(*itr) != B.end()) {
      bool ok = true;
      ll t = *itr;
      for(int i = 0; i < ans.size(); i++) {
	if(gcd(t,ans[i]) != 1) {
	  ok = false;
	  break;
	}
      }
      if(ok) ans.push_back(t);
    }
  }
  cout << ans.size() << endl;
 
}


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

long long unsigned int a[1000], cnt = 1;
int main() {
	int n; cin >> n;
	for (int i = 2; i <= n; i++) {
		int k = i;
		for (int j = 2; j <= k; j++) {
			while (k % j == 0) {
				a[j]++;
				k /= j;
			}
		}
	} 

	for (int i = 2; i <= n; i++) {
		cnt = cnt * (a[i] + 1) % 1000000007;
	}

	cout << cnt << endl;

	return 0;
}


Measured memory_bytes: 256
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) (a.begin(),a.end())
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

int  n,k; 
int a[52];
int dp[2][52];

int fun(int idx,int sum){
    if (idx>n ) return (sum%2==k); 
    if (dp[sum][idx] != -1) return dp[sum][idx];
    return  dp[sum][idx] = fun(idx+1,sum%2) + fun(idx+1,(sum+a[idx])%2) ; 
}


inline void solve(){
    memset(dp,-1,sizeof(dp));
    cin>>n>>k;
    for (int i=1;i<=n;i++) cin>>a[i];
    cout << fun(1,0) << endl;
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 3588
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
    int n,bi=0,sub=0,count=0;
    cin >> n;
    vector <int> a(n);
    for(int i=0;i<n;i++)
    {
        cin >> a[i];
        bi=max(bi,a[i]);
    }
    for(int i=0;i<n;i++)
    {
        if(a[i]==bi){
            count++;
            if(count>=2) sub=bi;
        }
        else{
            sub=max(sub,a[i]);
        }
    }
    for(int i=0;i<n;i++)
    {
        if(a[i]<bi) cout << bi << '\n';
        else cout << sub << '\n';
    }
    return 0;
}

Measured memory_bytes: 2432
#include<stdio.h>
    int main()
    {
        int A,p[51],B=0, i;
        scanf("%d",&A);
        for(i=1;i<=A;i++){
            scanf("%d",&p[i]);
        }
        for(i=1;i<=A;i++){
            if(p[i]!=i){
                B++;
            }
        }
		if(B==2||B==0){
            printf("YES");
        }else{
            printf("NO");
        }
     
    return 0;
    }

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

def gcdOld(x, y):
    while y != 0:
        x, y = y, x%y
    return x, y

def gcd(a, b):
    dividend = max(a, b)
    divider = min(a, b)

    if divider == 0:
        return dividend

    while dividend % divider != 0:
        r = dividend % divider
        dividend = divider
        divider = r
	#dividend, divider = divider, dividend % divider
    return divider

#dividend, divider = max(a, b), min(a, b)
#r = dividend % divider
#divider = min(a, b)

# while dividend % divider != 0:
#     r = dividend % divider
#     dividend = divider
#     divider = r
#print(r)

#print(gcdOld(20, 0))
print(gcd(a, b))


Measured memory_bytes: 5600
#include <bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define sort stable_sort
#define all(x) (x).begin(),(x).end()
#define rep(i,x) for (int (i)=(1);(i)<=(x);(i)++)
#define rep2(i,x) for (int (i)=(x);(i)>=(1);(i)--)
#define foreach(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
using namespace std;
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	if (a==b&&b==c&&a==c) puts("Yes"); else puts("No");return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define MAX 200000
#define SENTINEL 2000000000
typedef long long llong;

int L[MAX /2+2],R[MAX / 2+2];

llong merge(int A[], int n, int left, int mid, int right){
  int i,j,k;
  llong cnt = 0;
  int n1 = mid - left;
  int n2 = right - mid;
  
  for(i=0;i<n1;i++) L[i] = A[left + i];
  for(i=0;i<n2;i++) R[i] = A[mid + i];
  L[n1] = R[n2] = SENTINEL;
  i = j = 0;
  for(k=left;k<right;k++){
    if(L[i] <= R[j]){
      A[k] = L[i++];
    }else{
      A[k] = R[j++];
      cnt += n1 - i;
    }
  }
  return cnt;
}

llong mergeSort(int A[], int n, int left, int right){
  int mid;
  llong v1,v2,v3;

  if(left + 1<right){
    mid = (left + right) /2;
    v1 = mergeSort(A,n,left,mid);
    v2 = mergeSort(A,n,mid,right);
    v3 = merge(A,n,left,mid,right);

    return v1+v2+v3;
  }else return 0;
}

int main(){
  int A[MAX],n,i;

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

  llong ans = mergeSort(A,n,0,n);
  cout << ans <<endl;

  return 0;
}



Measured memory_bytes: 4664
#include <bits/stdc++.h>
// #include <atcoder/all>

using std::cin;
using std::cout;
using std::endl;
using std::vector;
// using namespace atcoder;
typedef long long ll;

#ifdef _DEBUG
#define DEBUG(x) cout << #x << ": " << x << endl;
#else
#define DEBUG(x)
#endif

#define ALL(obj) (obj).begin(), (obj).end()
#define BIT(n) (1LL << (n))

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

int main()
{
    std::ios::sync_with_stdio(false);
    cin.tie(0);
    // write code below
    int n;
    cin >> n;
    int c = 0;
    bool b = false;
    for (int i = 0; i < n; i++)
    {
        int d1, d2;
        cin >> d1 >> d2;
        if (d1 == d2)
        {
            c++;
        }
        else
        {
            c = 0;
        }

        if (c >= 3 && !b)
        {
            cout << "Yes" << endl;
            b = true;
        }
    }
    if (!b)
        cout << "No" << endl;

    // write code above
    return 0;
}


Measured memory_bytes: 3648
while True:
    a,op,b = input().split()
    a = int(a)
    b = int(b)
    
    if op == '?':
        break
    elif op == '+':
        print(a + b)
    elif op == '-':
        print(a - b)
    elif op == '/':
        print(a // b)
    else :
        print(a * b)
    



Measured memory_bytes: 5596
#include<stdio.h>
 
int main(){
  int n,q,S[10000],T[500],i,j,count=0;
 
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&T[i]);
  }
 
  for(i=0;i<q;i++){
    for(j=0;j<n;j++){
      if(T[i]==S[j]){
    count++;
    break;
      }
    }
  }
 
  printf("%d\n",count);
 
  return 0;
}

Measured memory_bytes: 636
<?php
list($a[0]) = fscanf(STDIN, '%d');
list($a[1]) = fscanf(STDIN, '%d');
list($a[2]) = fscanf(STDIN, '%d');
list($a[3]) = fscanf(STDIN, '%d');
list($a[4]) = fscanf(STDIN, '%d');
list($k) = fscanf(STDIN, '%d');

$flg = true;
for($i=0;$i<5;$i++){
    for($j=$i+1;$j<5;$j++){
        if($a[$j]-$a[$i]>$k){
            $flg = false;
            break;
        }
    }
}
echo $flg ? "Yay!" :  ":("

?>


Measured memory_bytes: 4728
#include<iostream>
using namespace std;
#include<utility>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>

typedef pair<double, double> point;
typedef point* data;

inline double dist(const point &a, const point &b)
{
    double dx = a.first - b.first, dy = a.second - b.second;
    return sqrt(dx * dx + dy * dy);
}

bool sort_y(const point &P1, const point &P2){ return P1.second < P2.second; }

double closest(data P, int n)
{
    if(n <= 1) return 1000;
    if(n == 2) return dist(P[0], P[1]);
    int m = n / 2;
    sort(P, P + n, sort_y); // y_sort, down to up.
	double median = P[m].second;
    double d = min(closest(P, m), closest(P + m, n - m));

    sort(P, P + n);
    vector<point> V;
	
    int i, k, a = 0, size = 0;
    for(i = 0; i < n; i++){
        if(fabs(P[i].second - median) > d) continue;
        V.push_back(P[i]);
        size++;
        for(k = a; k < size - 1; k++){
            if(V[size - 1].first - V[k].first > d){ a++; }
            else{
                d = min(d, dist(V[size - 1], V[k]));
            }
        }
    }
    return d;
}

int main()
{
	int i, n;
	double x, y;
	scanf("%d", &n);
	data P;
	P = new point [n];

	for(i = 0; i < n; i++){
		scanf("%lf %lf", &x, &y);
		P[i] = make_pair(x, y);
	}
	printf("%.12f\n", closest(P, n));

	return 0;
}

Measured memory_bytes: 5600
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define int long long
#define float long double
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define endl '\n'
#define pii pair<int,int>
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define all(x) x.begin(),x.end()
#define fill(a,b) memset(a,b,sizeof(a))
#define sz(x) (int)x.size()
#define sp(x) setprecision(x)
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define bs binary_search

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int n; cin>>n;
    int arr[n],ans=0,mex=0;
    for(int i=0;i<n;i++){
        cin>>arr[i];
        mex=max(mex,arr[i]);
        ans+=mex-arr[i];
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 5164
#ifdef __GNUC__ 
#include <bits/stdc++.h>
auto & in = std::cin;
#else
std::istringstream in;
#endif
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/dynamic_bitset.hpp>
#include <boost/preprocessor.hpp>

using namespace std;
#define ALL(v) std::begin(v),std::end(v)
#define RALL(v) std::rbegin(v),std::rend(v)

using u6 = std::uint64_t;
using u3 = std::uint32_t;
constexpr u6 moduloNo = 1'000'000'000 + 7; //' 1e9 + 7

#define DEFVALUE1(r,type,name) type name;
#define DEFINIT0(r,type,name) in >> calc.name;
#define DEFINIT1(r,size,name) calc.name.resize(size);
#define DEF_TYPEEXTSELECTOR(fnext,tpl)BOOST_PP_IF(BOOST_PP_TUPLE_ELEM(0, fnext)  ,BOOST_PP_TUPLE_ELEM(2, fnext),BOOST_PP_TUPLE_ELEM(0, tpl) )
#define DEFVALUEIMPL(r,fnext,tpl) BOOST_PP_LIST_FOR_EACH(BOOST_PP_TUPLE_ELEM(1,fnext),DEF_TYPEEXTSELECTOR(fnext,tpl), BOOST_PP_TUPLE_TO_LIST(BOOST_PP_TUPLE_POP_FRONT(tpl)))
#define DEFVALUES(expr) DEFIMPL(expr,0,DEFINIT0,0,_)
#define DEFIMPL(expr,deftypeindex,initcode,c,ext)														\
	BOOST_PP_SEQ_FOR_EACH(DEFVALUEIMPL,(0,DEFVALUE1,_),BOOST_PP_VARIADIC_SEQ_TO_SEQ(expr))				\
		template <typename U> struct Initer<deftypeindex,U>{											\
			template <typename T>static void init(T & calc){											\
				BOOST_PP_SEQ_FOR_EACH(DEFVALUEIMPL,(c,initcode,ext),BOOST_PP_VARIADIC_SEQ_TO_SEQ(expr)) }};
#define DEFVECS(size,expr)  DEFIMPL(expr,1,DEFINIT1,1,size)

template <typename T>
struct invecT {
	decltype(auto) begin()const {
		return std::istream_iterator<T>(in);
	}
	decltype(auto) end()const {
		return std::istream_iterator<T>();
	}
};
template <typename T>invecT<T> invec;

u6 pow2(u6 n) {
	if(n<64)return (u6(1) << n) % moduloNo;
	vector<bool> mod2;
	while (n >= 64) {
		mod2.push_back(n&1);
		n >>= 1;
		
	}
	u6 result = (u6(1) << n) % moduloNo;
	result = std::accumulate(mod2.rbegin(), mod2.rend(), result, [](u6 st, bool i) {return ((st*st)<<u6(i))%moduloNo; });
	return result;
}
//*/

struct Calc {
	template <int i,typename U=void> struct Initer {
		template <typename T>static void init(T & ) {}
	};
	/*******************************************************************************/
	DEFVALUES(
		(size_t,n,k)
		(string,s)
	);
	auto calc() {
		s[k-1] = std::tolower(s[k-1]);
		return s;
	}
	/*******************************************************************************/
};
Calc calc;

int main() {
	ios::sync_with_stdio(false);cin.tie(0);
#ifndef __GNUC__ 
	in.str("4 3\nCABA");
#endif
	Calc::Initer<0>::init(calc);
	Calc::Initer<1>::init(calc);
	cout << calc.calc() << endl;
}


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

#define rep(i,n)  for(int i = 0; i < (int)(n); i++)
#define sz(x)     ((int)(x).size())
#define all(x)    (x).begin(),(x).end()

using ll = long long;

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }

int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  std::string s, t; std::cin >> s >> t;

  ll ans = 1e9;
  for(int i=0; i<sz(s); i++) {
    ll cnt = 0;
    for(int j=0; j<sz(t); j++) {
      if ( s[i+j] != t[j] ) cnt++;
      if ( i + j >= sz(s) ) {
        std::cout << ans << std::endl;
        return 0;
      }
    }
    ans = std::min<ll>(ans,cnt);
  }
  std::cout << ans << std::endl;
  return 0;
}



Measured memory_bytes: 3660
use List::Util qw(sum);
my ($N,$K) = glob<>;
my @P = glob<>;
my $sum = 0;
my $res = 0;
sub getNextSum{
    my ($curIndex) = @_;
    my $tmp = 0;
    if($sum == 0){
        $sum = sum(@P[$curIndex..($curIndex+$K-1)]);
    }else{
        $sum = $sum - $P[$curIndex-1] + $P[$curIndex+$K-1];
    }
}
for($i=0;$i<@P-($K-1);$i++){
    getNextSum($i);
    $res = $sum > $res ? $sum : $res;
}
print (($res+$K)/2);


Measured memory_bytes: 52400
from bisect import bisect_right

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

    maxv = 0
    acum = [0] * (n + 1)
    bcum = [0] * (m + 1)
    for i in range(n):
        acum[i + 1] = acum[i] + a[i]
    for i in range(m):
        bcum[i + 1] = bcum[i] + b[i]

    for i in range(n + 1):
        if acum[i] > k:
            continue
        maxv = max(maxv, i + bisect_right(bcum, k - acum[i]) - 1)
    print(maxv)

if __name__ == '__main__':
    main()

Measured memory_bytes: 47356
n = int(input())
a = list(map(int, input().split()))

cnt = [0] * 8
free = 0

for _a in a:
    if 1 <= _a <= 399:
        cnt[0] = 1
    elif 400 <= _a <= 799:
        cnt[1] = 1
    elif 800 <= _a <= 1199:
        cnt[2] = 1
    elif 1200 <= _a <= 1599:
        cnt[3] = 1
    elif 1600 <= _a <= 1999:
        cnt[4] = 1
    elif 2000 <= _a <= 2399:
        cnt[5] = 1
    elif 2400 <= _a <= 2799:
        cnt[6] = 1
    elif 2800 <= _a <= 3199:
        cnt[7] = 1
    else:
        free += 1

if free == n:
    print(1, free)
else:
    print(sum(cnt), sum(cnt) + free)

Measured memory_bytes: 3064
n=int(input())
x=[int(i) for i in input().split()]

sum=0
for i in range(n):
  sum=sum+x[i]

if (sum/n)%1<=0.5:
  p=int((sum/n))
else:
  p=int((sum/n))+1
  
answer=0
for i in range(n):
  answer=answer+(x[i]-p)**2

print(answer)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define P pair<int, int>
#define F first
#define S second
#define mod 1000000007
#define INF 4000000000000000000
int dx8[8]={-1,0,1,1,1,0,-1,-1};
int dy8[8]={1,1,1,0,-1,-1,-1,0};
int dx4[4]={-1,0,1,0};
int dy4[4]={0,-1,0,1};
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int uni[100010];
int root(int a){
    if(uni[a]<0)return a;
    return uni[a]=root(uni[a]); 
}
bool connect(int a,int b){
    a=root(a);
    b=root(b);
    if(a==b)return false;
    if(uni[a]>uni[b]){
        swap(a,b);
    }
    uni[a]=uni[a]+uni[b];
    uni[b]=a;
    return true;
}
signed main(void){
    int n;cin>>n;
    string s,t;cin>>s>>t;
    string ans="";
    rep(i,n){
        ans+=s[i];ans+=t[i];
    }
    cout<<ans<<endl;
}
        


Measured memory_bytes: 256
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

int main(){
  int n;
  cin>>n;
  
  vector<ll> A(n);
  rep(i,n){
    cin>>A[i];
  }
  
  ll ans=0;
  sort(ALL(A));
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      for(int k=j+1;k<n;k++){
        if(A[i]+A[j]>A[k] && A[i]!=A[j] && A[j]!=A[k] && A[k]!=A[i]) ans++;
      }
    }
  }
  cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 3628
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main{
    public static void main(String[] args){
        FastScanner sc = new FastScanner();
        int S = sc.nextInt();
        int M = S/60;
        S %= 60;
        int H = M/60;
        M %= 60;
        System.out.println(H+":"+M+":"+S);
    }

    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(String s) {
            try {
                br = new BufferedReader(new FileReader(s));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String nextToken() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(nextToken());
        }

        long nextLong() {
            return Long.parseLong(nextToken());
        }

        double nextDouble() {
            return Double.parseDouble(nextToken());
        }
    }
}



Measured memory_bytes: 24472
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fto(i, s, e) for(int i = (s); i <= (e); ++i)
#define fto1(i, s, e) for(int i = (s); i < (e); ++i)
#define fdto(i, s, e) for(int i = (s); i >= (e); --i)
#define fit(it, var) for(auto it = (var).begin(); it != (var).end(); ++it)
#define frit(it, var) for(auto it = (var).rbegin(); it != (var).rend(); ++it)
 
#define bc __builtin_popcountll
#define onb(x, bit) (((x >> bit) & 1) != 0)
#define y1 ansdj
 
#define ll long long
#define ii pair<int, int>
#define x first
#define y second
#define pb push_back
#define sz(v) int((v).size())
#define all(v) (v).begin(), (v).end()
 
template<class T1, class T2> ostream& operator<< (ostream &os, pair<T1, T2> const &v) {
	return os << '(' << v.x << ", " << v.y << ')';
}
 
template<class T> ostream& operator<< (ostream &os, vector<T> const &v) {
	for (int i = 0; i < sz(v); ++i) { os << v[i]; if (i < sz(v)-1) os << ' '; }
	return os;
}
 
template<class T> void bug(T const &v) { cout << v << endl; }
template<class T, class... Args> void bug(T const &v, Args const&... args) { cout << v << ' '; bug(args...); }
 
double const pi = acos(-1);
#define oo 1000000007
#define OO 1000000000000000003LL
int const maxn = 1e5+3;

int n;
ii a[maxn];
ii f[maxn];
ii g[maxn];

int main() {
	#ifdef KITTENS
		freopen("main.inp", "r", stdin);
		freopen("main.out", "w", stdout);
	#endif
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	
	cin >> n;
	fto (i, 1, n) cin >> a[i].x >> a[i].y;
	sort(a+1, a+1+n);

	int r = oo;
	int l = 0;

	fto (i, 1, n) {
		r = min(r, a[i].y);
		l = a[i].x;
		if (l > r) break;
		f[i] = {l, r};
	}

	r = oo;
	l = a[n].x;

	fdto (i, n, 1) {
		r = min(r, a[i].y);
		if (l > r) break;
		g[i] = {l, r};
	}


	int ans = 0;
	fto1 (i, 1, n) {
		int giao1 = f[i].y-f[i].x;
		if (f[i].x) giao1++;
		int giao2 = g[i+1].y-g[i+1].x;
		if (g[i+1].x) giao2++;
		ans = max(ans, giao1+giao2);
		if (i > 1) {
			giao1 = a[i].y-a[i].x+1;
			giao2 = 0;
			if (f[i-1].x && g[i+1].x) giao2 = max(min(f[i-1].y, g[i+1].y) - max(f[i-1].x, g[i+1].x)+1, 0);
			ans = max(ans, giao1+giao2);
		}
	}

	bug(ans);

	#ifdef KITTENS
		cerr << 0.001*clock() << endl;
	#endif
	return 0;
}

Measured memory_bytes: 2560
#include <iostream>
using namespace std;
int main(void){
    int c[3][3];
    
    for(int i = 0; i < 3;i++){
        for(int j = 0; j < 3;j++){
            cin >> c[i][j];
        }
    }
    
    
    
    for(int j = 0; j < 3;j++){
        for(int i = 0; i < 3;i++){
            //cout << c[j%3][i]-c[(j+1)%3][i] << endl;
            if(c[j%3][0]-c[(j+1)%3][0]!=c[j%3][i]-c[(j+1)%3][i]){
                cout <<"No"<<endl;
                return 0;
            }
        }
    }
    
    for(int j = 0; j < 3;j++){
        for(int i = 0; i < 3;i++){
            //cout << c[i][j%2]-c[i][(j+1)%2]<<endl;
            if(c[0][j%3]-c[0][(j+1)%3]!=c[i][j%3]-c[i][(j+1)%3]){
                cout <<"No"<<endl;
                return 0;
            }
        }
    }
    cout <<"Yes"<<endl;
    
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin,(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    string a,b;
    a = "ABC";
    cin >> b;
    cout << a+b << endl;
    return 0;
}

Measured memory_bytes: 256
;; -*- coding:utf-8 -*-

(eval-when (:compile-toplevel :load-toplevel :execute)
  (defparameter O3 '(optimize (speed 3) (safety 0) (debug 0)))
  (defparameter O2 '(optimize (speed 3) (safety 1))))

(defmacro print-line (obj &optional (stream '*standard-output*))
  `(prog1 (princ ,obj ,stream) (terpri ,stream)))


;; Hauptteil

(defmacro split-and-bind (arg-lst string &body body)
  (let ((pos1 (gensym "POS"))
	(pos2 (gensym "POS"))
	(str-evaled (gensym "STR")))
    (labels ((expand (arg-lst &optional (init-pos1 t))
	       (if (null arg-lst)
		   body
		   `((let* ((,pos1 ,(if init-pos1 0 `(1+ ,pos2)))
			    (,pos2 (position #\space ,str-evaled :start ,pos1 :test #'char=))
			    (,(car arg-lst) (parse-integer ,str-evaled :start ,pos1 :end ,pos2)))
		       ,@(expand (cdr arg-lst) nil))))))
      `(let ((,str-evaled ,string))
	 ,@(expand arg-lst)))))

(deftype unum () '(integer 0 1000000000))

(defun qsort (arr)
  (declare #.O3
	   ((simple-array unum) arr))
  (labels ((quicksort (arr lo hi)
	     (declare (unum hi lo)
		      ((simple-array unum) arr))
	     (if (> hi lo)
		 (let* ((mid (round (+ lo hi) 2))
			(i lo)
			(j (+ hi 1))
			(p (aref arr mid)))
		   (declare (unum i j))
		   (rotatef (aref arr mid) (aref arr lo))
		   (loop
		      (loop do (incf i)
			 until (or (> i hi)
				   (> p (aref arr i)))) ; beliebige Präd.
		      (loop do (decf j)
			 until (or (<= j lo)
				   (> (aref arr j) p))) ; beliebige Präd.
		      (if (< j i) (return))
		      (rotatef (aref arr i)(aref arr j)))
		   (rotatef (aref arr lo) (aref arr j))
		   (quicksort arr lo (- j 1))
		   (quicksort arr i hi)))
	     arr))
    (quicksort arr 0 (- (length arr) 1))))

(defun main ()
  (declare #.O3)
  (let* ((n (the unum (read)))
	 (init-hp (read))
	 (max-a 0)
	 (arr-b (make-array n :element-type 'unum)))
    (dotimes (idx n)
      (split-and-bind (a b) (the string (read-line))
	(declare (unum a b))
	(when (>= a max-a) (setf max-a a))
	(setf (aref arr-b idx) b)))
    (let* ((arr-b (qsort arr-b)))
      (declare ((simple-array unum) arr-b))
      (print-line
       (loop with hp of-type fixnum = init-hp
	  for idx of-type unum from 0 below n
	  until (> max-a (aref arr-b idx))
	  do (decf hp (aref arr-b idx))
	    (when (<= hp 0)
	      (return (+ idx 1)))
	  finally (return (+ idx
			     (ceiling (max hp 0) max-a))))))))

#-swank(main)


;; Für Test
(defun get-clipbrd ()
  (with-output-to-string (out)
    (run-program "C:/msys64/usr/bin/cat.exe" '("/dev/clipboard") :output out)))

(defun test ()
  (with-input-from-string (*standard-input* (delete #\return (get-clipbrd)))
    (main)))


;; Für Benchmark
(defparameter *file-path* *load-pathname*)
(defparameter *dir-path* (pathname (directory-namestring *file-path*)))
(defparameter *dat-path* (merge-pathnames "test.dat" *dir-path*))

#+swank
(with-open-file (out *dat-path*
		     :direction :output :if-exists :supersede)
  )

(defun bench ()
  (let ((*standard-output* (make-broadcast-stream)))
    (with-open-file (*standard-input* *dat-path*)
      (time (main)))))


Measured memory_bytes: 53736
#include <iostream>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <stdlib.h>
#include <cstring>

using namespace std;


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

    cin >> N >> A >> B;
    cout<<min(N*A,B)<<endl;

    return 0;

}

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

int main(){
  int N;
  cin>>N;
  int T[N+10];
  for (int i=1;i<N+1;i++){
    cin>>T[i];
  }
  int M;
  cin>>M;
  int P[M+10];
  int X[M+10];
  for (int i=1;i<M+1;i++){
    cin>>P[i]>>X[i];
  }
  int total=0;
  for (int i=1;i<N+1;i++){
    total=total+T[i];
  }

  for (int i=1;i<M+1;i++){   
    int temp=P[i];

    cout<<total-T[P[i]]+X[i]<<endl;
  }
  return 0;
}
    
    
  

Measured memory_bytes: 764
from collections import Counter
h,w = map(int,input().split())
c = [list(map(int,input().split())) for _ in range(10)]
a = []
for i in range(h):
    a += list(map(int,input().split()))
C = Counter(a)
for k in range(10):
    for i in range(10):
        for j in range(10):
            c[i][j] = min(c[i][j], c[i][k] + c[k][j])
ans = 0
for i,n in C.items():
    if i != -1:
        ans += c[i][1]*n
print(ans)

Measured memory_bytes: 41308