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

using namespace std;
using namespace std::chrono;

#define rep(i,a,b) for(int i = a;i<(b);++i)
#define trav(a,v) for(auto& a : v)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;

const ll big = 1000000007ll;
const ll big2 = 1000000009ll;
ll n,m,k,q,w,h;

ll F[26] = {0};

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("autput.txt","w",stdout);
    ll a,b,c,d;

    cin >> n >> m;

    for(ll c1 = 0; c1 < n; c1++){
        for(ll c2 = 0; c2 < m; c2++){
            char ch;
            cin >> ch;
            F[ch-'a']++;
        }
    }

    ll n1 = 0;
    ll n2 = 0;
    ll n4 = 0;

    for(ll c1 = 0; c1 < 26; c1++){
        if(F[c1]%4 == 0){
            n4++;
        }
        else{
            if(F[c1]%2 == 0){
                n2++;
            }
            else{
                n1++;
            }
        }
    }

    if(n%2 == 0 && m%2 == 0){

        if(n1+n2 > 0){
            cout << "No\n";
        }
        else{
            cout << "Yes\n";
        }

    }

    if(n%2 == 0 && m%2 != 0){

        if(n1 != 0 || n2 > n/2){
            cout << "No\n";
        }
        else{
            cout << "Yes\n";
        }

    }

    if(n%2 != 0 && m%2 == 0){

        if(n1 != 0 || n2 > m/2){
            cout << "No\n";
        }
        else{
            cout << "Yes\n";
        }

    }

    if(n%2 != 0 && m%2 != 0){

        if(n1 > 1 || n2 > n/2+m/2){
            cout << "No\n";
        }
        else{
            cout << "Yes\n";
        }

    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
//#define int long long
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

vector<int> init(int size){
  vector<int> par(size,-1);
  return par;
}

int root(int x, vector<int>& par){
  if(par[x] < 0){
    return x;
  }else{
    return par[x] = root(par[x],par);
  }
}

bool same(int x, int y, vector<int>& par){
  return root(x, par) == root(y, par);
}

void unite(int x, int y, vector<int>& par){
  x = root(x, par), y = root(y, par);
  if(same(x,y, par))return;
  par[x] += par[y];
  par[y] = x;
}

int size(int x, vector<int>& par){
  return -par[root(x, par)];
}

int pow(int x, int n){
  if(n == 0)return 1;
  if(n % 2 == 0)return pow(x * x % MOD, n/2);
  else return x * pow(x, n-1) % MOD;
}

int n;vector<int> v[110000];int c[110000],ans[110000];pair<int,int> dig[110000];
int cind,ansM;

void f(int ver){
  //cout << "ver : " << ver << endl;
  vector<int> next;
  for(int nver : v[ver]){
    if(ans[nver] != -1)continue;
  //cout << "nver : " << nver << " " << cind << endl;
    next.push_back(nver);
    ans[nver] = c[cind];
    ansM += c[cind];
    cind++;
  }
  for(int nver : next){
    f(nver);
  }
}
signed main(){
  cin>>n;
  rep(i,110000){
    dig[i].first = 0;
    dig[i].second = i;
  }
  rep(i,n-1){
    int a,b;cin>>a>>b;a--;b--;v[a].push_back(b);v[b].push_back(a);
    dig[a].first++;dig[b].first++;
  }
  rep(i,n)cin>>c[i];
  sort(c,c+n,greater<int>());
  rep(i,n){
    sort(v[i].begin(), v[i].end(), [](const int &a, const int &b){
      return dig[a].first > dig[b].first;
    });
  }
  sort(dig,dig+n,greater<pair<int,int>>());
  cind = 1;
  rep(i,n)ans[i] = -1;
  ans[dig[0].second] = c[0];
  //cout << "flkjdlfjd" << dig[0].second << endl;
  f(dig[0].second);
  cout << ansM << endl;
  rep(i,n)cout << ans[i] << " ";cout << endl;

}


Measured memory_bytes: 4864
import Control.Applicative

minkowski n x y = (sum $ map ((**n) . abs) $ zipWith (-) x y) ** (1/n)
chebyshev x y = maximum $ map abs $ zipWith (-) x y

main = do
	_ <- getLine
	x <- map read . words <$> getLine
	y <- map read . words <$> getLine
	print $ minkowski 1 x y
	print $ minkowski 2 x y
	print $ minkowski 3 x y
	print $ chebyshev x y

Measured memory_bytes: 4424
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <array>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>

using namespace std;
using lli = long long int;
// #define DEBUG
#ifdef DEBUG
#define debug(var) cout << (#var) << ": " << (var) << endl;
template<class T> void dump_array_impl(const T& a) {
  bool first = true;
  for (auto&& x : a) {
    if (!first) cout << ", "; else first = false; cout << x;
  }
}
#define debug_array(a) cout<<(#a)<<": ";dump_array_impl(a);cout<<endl
#else
#define debug(var) {}
#define debug_array(a) {}
#endif
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) {
  v = vector<T>(n, x);
}
template<class T> void read_n(vector<T>& v, size_t n) {
  v = vector<T>(n); for (lli i=0; i<n; ++i) cin >> v[i];
}
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

lli n, k;
vector<lli> h;
vector<lli> c;
int main() {
  cin >> n >> k; read_n(h, n);
  init_n(c, n, 1e9);
  c[0] = 0;
  for (lli i=1; i<n; ++i) {
    for (lli j=i-1; j>=0 && j>=i-k; --j) {
      c[i] = min(c[i], c[j] + abs(h[i] - h[j]));
    }
  }
  cout << c[n-1] << endl;
  return 0;
}


Measured memory_bytes: 1792
#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>
#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;
    scanf("%d", &n);

    vector<pair<int,int> > z;
    int i;
    for(i=0; i<n; i++) {
        int tmp;
        scanf("%d", &tmp);
        z.push_back(make_pair(tmp,i));
    }
    sort(z.begin(), z.end());

    int cnt=0;
    for(i=0; i<n; i++) {
        int id=z[i].second;
        if((id+i)%2) cnt++;
    }
    
    printf("%d\n", cnt/2);

    return 0;
}


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

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

    int a, b;
    cin >> a >> b;

    if(a==b) cout << a + b << endl;
    else cout << max(a, b) * 2 - 1 << endl;
}

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vll = vector<ll>;
template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

int main() {
        ll N, M;
        cin >> N >> M;
        int sum[100006] = {};   

        for (int i = 0; i < N; i++) {
                int l, r;
                cin >> l >> r;
                int minv = M + 1;
                for (int j = 1; j < minv && j * j <= r; j++) {
                        int a = l / j * j, b = r / j * j;
                        if (l <= a && a <= r || l <= b && b <= r) sum[j]++, sum[j + 1]--;
                        int dl = l / j, dr = r / j;
                        if (dl * j < l) dl++;
                        dl = max(dl, j + 1);
                        dr = min(dr, minv - 1);
                        if (dl > dr) continue;
                        sum[dl]++, sum[dr + 1]--;
                        minv = min(minv, dl);
                }
        }
        int d = 0;      
        for (int i = 1; i <= M; i++) {
                d += sum[i];
                cout << d << el;
        }
    return (0);
}

Measured memory_bytes: 1280
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL


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

    int A, B, C;
    cin >> A >> B >> C;

    cout << MIN(B / A, C) << "\n";
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	long int deposit;
	long int X;
	int i;

	scanf("%ld", &X);

	deposit = 100;

	for (i = 0; deposit < X; i++)
	{
		deposit *= 1.01;
	}

	printf("%d\n", i);

	return 0;
}

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

typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const int mod = 1e9+7;

#define pi pair<int,int>
#define pl pair<lld,lld>

#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl

#define mem0(x) memset(x,0,sizeof(x))
#define fillnum(x,n) fill(begin(x),end(x),n)
#define asort(x) sort(x.begin(),x.end())
#define dsort(x,t) sort(x.begin(),x.end(),greater<t>())
#define vuniq(x) x.erase(unique(x.begin(), x.end()), x.end())

#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)

int main() {
    string S,T;
    int A,B;
    cin >> S >> T;
    cin >> A >> B;
    string s;
    cin >> s;
    cout << A - (S == s) << " " << B - (T == s) << endl;
}

Measured memory_bytes: 3632
N = int(input())
MOD = 10**9 + 7
memo = [{} for i in range(N+1)]

def ok(last4):
    for i in range(4):
        t = list(last4)
        if i >= 1:
            t[i-1], t[i] = t[i], t[i-1]
        if "".join(t).count("AGC"):
            return False
    return True

def dfs(cur,last3):
    if last3 in memo[cur]:
        return memo[cur][last3]
    if cur == N:
        return 1
    ret = 0
    for c in "ACGT":
        if ok(last3+c):
            ret=ret+dfs(cur+1,last3[1:]+c)
            ret%=MOD
        memo[cur][last3] = ret
    return ret
print(dfs(0,"TTT"))

Measured memory_bytes: 3872
while True:
    a=int(input())
    if a==0:
        break
    b=((1000-a)//500)
    c=(((1000-a)-500*b)//100)
    d=(((1000-a)-500*b-100*c)//50)
    e=(((1000-a)-500*b-100*c-50*d)//10)
    f=(((1000-a)-500*b-100*c-50*d-10*e)//5)
    g=((1000-a)-500*b-100*c-50*d-10*e-5*f)
    print(b+c+d+e+f+g)


Measured memory_bytes: 5584
import java.io.PrintWriter
import kotlin.math.max
import kotlin.math.min

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextLongList() = nextList().map(String::toLong)
fun nextDoubleList() = nextList().map(String::toDouble)

val pw = PrintWriter(System.out)
fun print(s: Any = "") = pw.print(s)
fun println(s: Any = "") = pw.println(s)

fun <T> Iterable<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)
fun <T> Array<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)

fun main(args: Array<String>) {
    main()
    pw.flush()
}

fun main() {
    val (N, M, X) = nextIntList()
    val A = Array(N) { nextIntList() }
    val ans = rec_bit(A, M, X)
    println(ans)
}

fun rec_bit(seeds: Array<List<Int>>, M: Int, X: Int, pos: Int = 0, patterns: Array<Int> = emptyArray()): Int {
    return if (pos < seeds.size) {
        val res1 = rec_bit(seeds, M, X, pos + 1, patterns + pos)
        val res2 = rec_bit(seeds, M, X, pos + 1, patterns)
        if (res1 >= 0 && res2 >= 0) min(res1, res2) else max(res1, res2)
    } else {
        var cost = 0
        val A = IntArray(M)
        for (i in patterns) {
            val CA = seeds[i]
            cost += CA[0]
            for (j in 0 until M) {
                A[j] += CA[j + 1]
            }
        }
        if (A.all { it >= X }) cost else -1
    }
}

Measured memory_bytes: 42996
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(long long i = 0; i < (n); ++i)
#define ll long long
#define P pair<ll,ll>
#define all(v) (v).begin(),(v).end()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
    ll x,k,d;
    cin >> x >> k >> d;
    x = abs(x);
    ll n = min(k,x/d);
    k -= n;
    x -= n*d;
    if(k%2) cout << abs(x-d) << endl;
    else cout << x << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <utility>
using namespace std;

#define Q 1000000007
#define N 100000
#define W 0
#define WB 1

vector<pair<int,int> > adj[N];
int visited[N];
long long dp[N];


void dfs(int now){
  visited[now] = 1;
  for (auto it = adj[now].begin(); it != adj[now].end(); it++){
    if (visited[it->first]) continue;
    dp[it->first] = dp[now] + it->second;
    dfs(it->first);
  }
}

int main(void){
  int n, q, k;
  cin >> n;
  for (int i=0; i<n; i++){
    visited[i] = 0;
    adj[i] = vector<pair<int, int>>();
  }
  for (int i=0; i<n-1; i++){
    int a, b, c;
    cin >> a >> b >> c;
    adj[a-1].push_back(make_pair(b-1,c));
    adj[b-1].push_back(make_pair(a-1,c));
  }
  cin >> q >> k;
  dp[k-1] = 0;
  dfs(k-1);
  for (int i=0; i<q; i++){
    int x, y;
    cin >> x >> y;
    cout << (dp[x-1] + dp[y-1]) << endl;
  }
  return 0;
}

Measured memory_bytes: 11520
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        long n = sc.NextLong();

        long[] dp = new long[n + 1];
        for (long i = 1; i <= n; i++)
        {
            dp[i] = 10000000;
        }

        for (long i = 1; i <= n; i++)
        {
            for (long j = 1; j <= 5; j++)
            {
                if (i - j >= 0)
                {
                    dp[i] = Math.Min(dp[i], dp[i - j] + j);
                }
            }

            for (long j = 1; i - Math.Pow(6, j) >= 0; j++)
            {
                dp[i] = Math.Min(dp[i], dp[i - (long)Math.Pow(6, j)] + 1);
            }

            for (long j = 1; i - Math.Pow(9, j) >= 0; j++)
            {
                dp[i] = Math.Min(dp[i], dp[i - (long)Math.Pow(9, j)] + 1);
            }
        }

        long answer = dp[n];

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


Measured memory_bytes: 28408
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0; (i)<(n); (i)++)
#define all(v) (v).begin(), (v).end()

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

    if(n[0] == '7' || n[1] == '7' || n[2] == '7'){
        cout << "Yes";
    }
    else{
        cout << "No";
    }
}

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

#define mp make_pair
#define pb push_back

typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ll, ll> l4;


ll solve(ll x, ll n)
{
  if (n%x==0)
    {
      return 2*n-x;
    }
  else
    {
      ll ret = (n/x)*x*2+solve(n%x, x);
      return ret;
    }
}

ll n, x;
ll solve()
{
  return n + solve(x, n-x);
}

int main()
{
  scanf("%lld %lld", &n, &x);
  printf("%lld\n", solve());
}


Measured memory_bytes: 256
import collections
import heapq
x,y,z,k = map(int,(input().split()))
a = list(map(int,(input().split())))
b = list(map(int,(input().split())))
c = list(map(int,(input().split())))
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)
big = [(-a[0]-b[0]-c[0],0,0,0)]
heapq.heapify(big)

visited = collections.defaultdict(int)

ans = []
C = 0
while C < k:
    if big[0][1]+1 < len(a) and not visited[(big[0][1]+1,big[0][2],big[0][3])]:
        heapq.heappush(big, (-a[big[0][1]+1]-b[big[0][2]]-c[big[0][3]],big[0][1]+1,big[0][2],big[0][3] ) )
        visited[(big[0][1]+1,big[0][2],big[0][3])] = 1
    if big[0][2]+1 < len(b) and not visited[(big[0][1],big[0][2]+1,big[0][3])]:
        heapq.heappush(big, (-a[big[0][1]]-b[big[0][2]+1]-c[big[0][3]],big[0][1],big[0][2]+1,big[0][3] ) )
        visited[(big[0][1],big[0][2]+1,big[0][3])] = 1
    if big[0][3]+1 < len(c) and not visited[(big[0][1],big[0][2],big[0][3]+1)]:
        heapq.heappush(big, (-a[big[0][1]]-b[big[0][2]]-c[big[0][3]+1],big[0][1],big[0][2],big[0][3]+1 ) )
        visited[(big[0][1],big[0][2],big[0][3]+1)] = 1
    ans.append(heapq.heappop(big))
    C += 1

for i in ans:
    print(-i[0])

Measured memory_bytes: 55384
#include <iostream>
using namespace std;
using ll = long long;

int cnt[256];

int main() {
  string A;
  cin >> A;
  ll dame = 0;
  for (char c: A) {
    ++cnt[c];
    dame += cnt[c];
  }
  ll n = A.size();
  ll res = n * (n + 1) / 2 + 1 - dame;
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 644
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;


int main() {
    int a, b, c, d;

    cin >> a >> b >> c >> d;

    int break_t, break_a;
    if(a % d == 0){
        break_t = a/d;
    }
    else{
        break_t = a / d + 1;
    }
    if(c % b == 0){
        break_a = c/b;
    }
    else{
        break_a = c / b + 1;
    }

    if(break_a <= break_t){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

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

int main (){
    int ans=0;
    string a,b;
    cin >> a;
    cin >> b;
    
    for(int i=0;i<3;i++){
        if(a[i]==b[i]) ans++;
    }
    cout << ans <<endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void) {
	int n,i,ai,min,max;
	long sum;
	sum=0;
	min=1000000;
	max=-1000000;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%d",&ai);
		sum+=ai;
		if(min>ai){
			min=ai;
		}
		if(max<ai){
			max=ai;
		}
	}
	printf("%d %d %lld\n",min,max,sum);
	
	return 0;

}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
const double pi=acos(-1);
double Naiseki(vector<double> x,vector<double> y);

int main(){
    double a,b,h,m;
    cin>>a>>b>>h>>m;

    vector<double> A={a,0};
    vector<double> B={b,0};

    double time=60*h+m;

    double theta=pi*time/360;
    double phi=pi*time/30;

    A={a*cos(theta),a*sin(theta)};
    B={b*cos(phi),b*sin(phi)};

    cout<<setprecision(10);
    cout<<sqrt(a*a+b*b-2*Naiseki(A,B))<<endl;
}

double Naiseki(vector<double> x,vector<double> y){
    double ip=0;
    for(int i=0; i<x.size(); i++){
        ip+=x[i]*y[i];
    }

    return ip;
}

Measured memory_bytes: 4136
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define VV vector
#define pb push_back
#define bitc  __builtin_popcountl
#define m_p make_pair
#define inf 200000000000000
#define MAXN 1000001
#define eps 0.0000000001
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();

//////////////

#define S second
#define F first
#define int long long  

//////////

signed main()
{
    fastio;
    int n;
    cin>>n;
    pair<int,pair<int,int>> a[n],b[n];
    for(int i=0;i<n;++i)
    {
        int x,y;
        cin>>x>>y;
        a[i].F=x+y;
        b[i].F=x+y;
        a[i].S.F=x;
        b[i].S.F=y;
        a[i].S.S=i;
        b[i].S.S=i;
    }
    sort(a,a+n);
    sort(b,b+n);
    int ans=0;
    int vis[n]={};
    int x=n-1,y=n-1;
    for(int i=0;i<n;++i)
    {
        while(vis[a[x].S.S]==1)
            --x;
        while(vis[b[y].S.S]==1)
            --y;
        if(i%2==0)
        {
            ans+=a[x].S.F;
            vis[a[x].S.S]=1;
        }
        else
        {
            ans-=b[y].S.F;
            vis[b[y].S.S]=1;
        }
    }
    cout<<ans;
}

Measured memory_bytes: 5760
#include<stdio.h>
 
int main(){
    int n,a;

    scanf("%d",&n);
    while(n!=0){
        a=0;
        while(n!=1){
            if(n%2==0)
                n=n/2;
            else
                n=n*3+1;
            a++;
        }
        printf("%d\n",a);
        scanf("%d",&n);
    }
     
    return 0;
}

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

int main(){
	int H,W;
	while (true){	
		cin>>H>>W;  
		if (H==0&&W==0) break;
		for ( int k=0; k<H; k++){
			for ( int r=0; r<W; r++){
				cout<<"#";
			}
		cout<<endl;
		}
		cout<<endl;
	}
	return 0;
}



Measured memory_bytes: 3052
#include<iostream>

using namespace std;

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

int main() {
  int q;
  cin >> q;
  long long a = 0, b = 0;
  rep (i, q) {
    int s, t;
    char p;
    cin >> s >> p >> t;
    if (p == ')') a += t;
    else b += t;
    if (a == b) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define call(var) cout<<#var<<"="<<var<<endl;
#define dup(x,y) (((x)+(y)-1)/(y))
using ll=long long;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;
const int INTMAX = 2147483647;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

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

    vb dp(k+10,0);
    rep(i,k+1){
        bool ok = true;
        rep(j,n){
            if(i - a[j] >= 0){
                ok = (ok & dp[i - a[j]]);
            }
        }
        dp[i] = !ok;
    }
    //rep(i,k+1) cout << "i = " << i << " " << dp[i] << endl;
    cout << (dp[k]? "First" : "Second") << "\n";
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define N 100000

int partition(int *, int, int);

int main()
{

  int A[N], n, i, j, x;
  
  scanf("%d", &n);
  for ( i = 0 ; i < n ; i++){
    scanf("%d", &A[i]);
  }

  x = partition(A, 0, n-1);
  
  for ( i = 0 ; i < n-1 ; i++){
    if (i==x){
      printf("[%d] ", A[i]);
    }
    else {
      printf("%d ", A[i]);
    }
  }
  printf("%d\n", A[i]);

  return 0;
}

int partition(int *A, int p, int r)
{
  int x, i, j, a, b;
  
  x = A[r];
  i = p-1;
  for(j = p ; j < r ; j++){
    if (A[j] <= x){
      i = i+1;
      /*A[i] ??¨ A[j] ?????????*/
      a = A[i];
      A[i] = A[j];
      A[j] = a;
    }
  }
  /*A[i+1] ??¨ A[r] ?????????*/
  b = A[i+1];
  A[i+1] = A[r];
  A[r] = b;
  
  return i+1;
}

Measured memory_bytes: 988
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

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

    int ans = 0;
    int highest = h[0];

    for(int i=0; i<N; i++){
        if(highest <= h[i]){
            ans++;
            highest = h[i];
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int max_n = 1e6;
struct edge{
  int u,v,cost;
};
int unip[max_n],unir[max_n];
void init(int n){
  for(int i=0 ; i<n ; i++){
    unip[i] = i;
    unir[i] = 0;
  }
}
int find(int x){
  if(unip[x] == x){
    return x;
  }else{
    return unip[x] = find(unip[x]);
  }
}
void unite(int x, int y){
  x = find(x);  y = find(y);
  if(unip[x] == unip[y]){
    return;
  }
  if(unir[x] < unir[y]){
    unip[x] = y;
  }else{
    unip[y] = x;
    if(unir[x] == unir[y]){
      unir[x]++;
    }
  }
}
bool same(int x, int y){
  return find(x) == find(y);
}

ll solve();
priority_queue<pair<ll,p>,//cost,from,to
  vector<pair<ll,p> >,
  greater<pair<ll,p> > > pq;

vector<pair<p, int> > v;
ll n;
ll calccost(int x, int y){//2つの頂点を表す
  return min(
    abs(v[x].first.first-v[y].first.first),
    abs(v[x].first.second-v[y].first.second)
  );
}
void setedge();
int main(){
  cin >> n;
  init(n+1);
  for(int i=0 ; i<n ; i++){
    ll x, y; cin >> x >> y;
    v.push_back(make_pair(make_pair(x,y), i));
  }
  setedge();
  cout << solve() << endl;
  return 0;
}
void setedge(){
  sort(v.begin(), v.end());
  for(int i=1 ; i<n ; i++){
    ll now = calccost(i-1, i);
    pq.push(make_pair(now,make_pair(v[i-1].second,v[i].second)));
  }
  for(int i=0 ; i<n ; i++){
    swap(v[i].first.first, v[i].first.second);
  }
  sort(v.begin(), v.end());
  for(int i=1 ; i<n ; i++){
    ll now = calccost(i-1, i);
    pq.push(make_pair(now,make_pair(v[i-1].second,v[i].second)));
  }
}
ll solve(){
  ll ans = 0;
  while(pq.size()){
    pair<ll, p> now = pq.top();
    pq.pop();
    if(!same(now.second.first, now.second.second)){
      ans += now.first;
      unite(now.second.first, now.second.second);
    }
  }
  return ans;
}


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

constexpr long long kInf = 1e18;

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

  int n;
  cin >> n;
  vector<long long> a(n);
  for (auto& e: a)
    cin >> e;

  long long result = 1;
  sort(a.begin(), a.end());
  for (auto e: a) {
    __int128_t cur = (__int128_t) result * e;
    if (cur > kInf) {
      result = -1;
      break;
    }

    result = cur;
  }

  cout << result << endl;
}

Measured memory_bytes: 3992
#include <bits/stdc++.h>
using namespace std;
int main(){
  int k;
  string s;
  cin>>k>>s;
  if(s.size()<=k){
    cout<<s<<endl;
  }else{
    string t=s.substr(0,k);
    cout<<t+"..."<<endl;
  }
  return 0;
}

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

ll dp[3001][3001][2];
ll solve(vector<int> & v,int i,int j,bool turn){

    if(i>j){
      return 0;
    }

    if(dp[i][j][turn]!=-1){
      return dp[i][j][turn];
    }

    if(turn==1){
      return dp[i][j][turn]=max(v[i]+solve(v,i+1,j,0),v[j]+solve(v,i,j-1,0));
    }
    else {
       return dp[i][j][turn]=min(solve(v,i+1,j,1),solve(v,i,j-1,1));
    }
}
int main(){
   
   int n;
   cin>>n;

   vector<int> v(n+1);
   memset(dp,-1,sizeof(dp));
   ll sum=0;
   for(int i=1;i<=n;i++){
      cin>>v[i];
      sum+=v[i];
   }

   ll scoreX=solve(v,1,n,1);
   ll scoreY=sum - scoreX;
   cout<<scoreX-scoreY;
   return 0;

}

Measured memory_bytes: 144600
import math
from copy import deepcopy
import bisect
import itertools
from collections import deque
import numpy as np


def read():
    return int(input())


def readlist():
    return list(map(int, input().split()))


def readmap():
    return map(int, input().split())


N = read()


def is_10(n):
    while n > 1:
        if n % 10:
            return False
        else:
            n = n // 10

    return True


if is_10(N):
    print(10)
else:
    strN = str(N)
    ans = 0
    for num in strN:
        ans += int(num)
    print(ans)

Measured memory_bytes: 15624
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define ff first
#define ss second

int n, q, pos;
int a[500002], tree[4*500002], idx[500002], ans[500002];
pair <int,pair<int,int> > qy[500002];

bool cmp(pair<int,pair<int,int> > a, pair<int,pair<int,int> > b){
    return a.ss.ff<b.ss.ff;
}

void update(ll pos, ll l, ll r, ll idx, ll value){
    if(l==r && l==idx){
        tree[pos]=value;
        return;
    }
    ll mid=(l+r)/2;
    if(idx>=l && idx<=mid) update(pos*2,l,mid,idx,value);
    if(idx>=(mid+1) && idx<=r) update(pos*2+1,mid+1,r,idx,value);
    tree[pos]=tree[pos*2]+tree[pos*2+1];
}

ll query(ll pos, ll l, ll r, ll L, ll R){
    if(l>=L && r<=R) return tree[pos];
    if(r<L || l>R) return 0;
    ll mid=(l+r)/2;
    ll q1=query(pos*2,l,mid,L,R);
    ll q2=query(pos*2+1,mid+1,r,L,R);
    return q1+q2;
}

int main()
{
    scanf("%d %d",&n,&q);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    for(int i=0;i<q;i++){
        scanf("%d %d",&qy[i].ff,&qy[i].ss.ff);
        qy[i].ss.ss=i;
    }
    sort(qy,qy+q,cmp);
    pos=1;
    for(int i=0;i<q;i++){
        while(pos<=qy[i].ss.ff){
            int x=a[pos];
            if(idx[x]) update(1,1,n,idx[x],0);
            update(1,1,n,pos,1);
            idx[x]=pos;
            pos++;
        }
        ans[qy[i].ss.ss]=query(1,1,n,qy[i].ff,qy[i].ss.ff);
    }
    for(int i=0;i<q;i++) printf("%d\n",ans[i]);
    return 0;
}


Measured memory_bytes: 19604
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>

using namespace std;
using ll = long long int;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;

ll factor(int n){
    ll ret=1;
    for(int i=2;i<=n;i++) ret*=i;
    return ret;
}

int main(){
    int H,A;
    cin>>H>>A;
    if(H%A==0) cout<<H/A<<endl;
    else cout<<H/A+1<<endl;
    
    return 0;
}


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

int digit_length(long long a)
{
    long long lengh = 0;
    while (a > 0)
    {
        a = a / 10;
        lengh++;
    }
    return lengh;
}

int main()
{
    long long N, A, B;
    long long int ans, temp = 0;
    cin >> N;

    ans = digit_length(N);

    for (long long i = 1; i * i <= N; i++)
    {
        if (N % i != 0)
            continue;
        A = i;
        B = N / A;

        if ((A * B) == N)
        {
            temp = max(digit_length(A), digit_length(B));
            ans = min(ans, temp);
        }
    }

    // for (int i = 1; i <= N; i++)
    // {
    //     for (int j = 1; i * j <= N; j++)
    //     {
    //         if ((i * j) == N)
    //         {
    //             temp = max(digit_length(i), digit_length(j));
    //             ans = min(ans, temp);
    //         }
    //     }
    // }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
s=input()
ans='NA'
m=['01','02','03','04','05','06','07','08','09','10','11','12']
if s[:2] not in m and s[2:] in m:
    ans='YYMM'
elif s[:2] in m and s[2:] not in m:
    ans='MMYY'
elif s[:2] in m and s[2:] in m:
    ans='AMBIGUOUS'
print(ans)

Measured memory_bytes: 3064
#include<stdio.h>
#define MAX 500000
int maxHeapify(int);
int H,A[MAX];
int main(){
  int i;
  scanf("%d",&H);
  for(i=1;i<=H;i++){
    scanf("%d",&A[i]);
  }
  for(i=H/2;i>=1;i--){
    maxHeapify(i);
  }
  for(i=1;i<=H;i++){
    printf(" %d",A[i]);
  }
  printf("\n");
  return 0;
}
int maxHeapify(int i){
  int l,r,q,biggest;
  l = i*2;
  r = i*2+1;
  if(l<=H && A[l]> A[i])  biggest= l;
  else  biggest = i;
  if(r<=H && A[r] > A[biggest]) biggest = r;
  if(biggest != i){
    q=A[i];
    A[i]=A[biggest];
    A[biggest]=q;
    maxHeapify(biggest);
  }
}


Measured memory_bytes: 3684
#include <stdio.h>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include<math.h>
#include<bitset>
#include<iomanip>
using namespace std;

int main() {
	int N,ans=0; cin >> N;
	vector<int> a(N), b(N), c(N), d(N);
	map<int, int> x;
	for (int i = 0; i < N; i++) {
		cin >> a[i] >> b[i];
	}
	for (int i = 0; i < N; i++) {
		cin >> c[i] >> d[i]; x[c[i]] = d[i];
	}
	sort(c.begin(), c.end());
	for (int i = 0; i < N; i++) {
		int z = -1,k;
		bool y = 0;
		for (int j = 0; j < N; j++) {
			if (c[i] > a[j] && b[j] < x[c[i]]&&b[j]!=-1) {
				if (z < b[j]) {
					z = b[j]; k = j; y = 1;
				}
			}
		}
		if (y) { b[k] = -1; ans++; }
	}

	cout << ans << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <random>
#include <chrono>
#include <atcoder/all>
 
using namespace std;
using namespace __gnu_pbds;
using namespace atcoder;
 
#define endl '\n'
 
typedef long long ll;
typedef pair<int, int> pii;
typedef tree<int, null_type,less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
template<typename T>
static T randint(T lo, T hi){
	return uniform_int_distribution<T>(lo, hi)(rng);
}


int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
 
	// freopen("capastaty_input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);

	int n, m;
	cin >> n >> m;

	const ll mod = 998244353;

	vector<ll> a(n), b(m);
	for(int i = 0; i < n; i++)
		cin >> a[i];

	for(int i = 0; i < m; i++)
		cin >> b[i];

	vector<ll> c = convolution<mod>(a, b);
	for(int i = 0; i < c.size(); i++)
		cout << c[i] << " \n"[i + 1 == c.size()];

	return 0;
}


Measured memory_bytes: 27256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define INF 1e9+7
#define rep(i,n) for(ll i=0;i<n;i++)
#define pii pair<int,int>
#define pll pair<ll,ll>
const int maxn = 1000000;
const int maxa = 200000;
ll mod = INF;

ll ans;
ll n,a,b;

ll mpow(ll x,ll y){
    if(y==0){
        return 1;
    }else if(y==1){
        return x;
    }else if(y%2==0){
        ll a=mpow(x,y/2)%mod;
        return (a*a)%mod;
    }else{
        ll a=mpow(x,(y-1)/2)%mod;
        return ((a*a)%mod*x)%mod;
    }
}

int main(){

    cin >> n>>a>>b;
    ans=mpow(2,n);
    ans-=1;

    ll s=1;
    for(ll i=0;i<a;i++){
        s=s*(n-i)%mod;
    }
    ll t=1;
    for(ll i=1;i<=a;i++){
        t=t*i%mod;
    }
    t=mpow(t,mod-2);
    s=s*t%mod;

    ans-=s;
    while(ans<0)ans+=mod;
    ////
    s=1;
    for(ll i=0;i<b;i++){
        s=s*(n-i)%mod;
    }
    t=1;
    for(ll i=1;i<=b;i++){
        t=t*i%mod;
    }
    t=mpow(t,mod-2);
    s=s*t%mod;

    ans-=s;
    while(ans<0)ans+=mod;

    cout << ans<<endl;
    return 0;
}

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

int main()
{
    int N;
    cin >> N;
    vector<int> H(N);
    for (int i = 0; i < N; i++)
    {
        cin >> H.at(i);
    }

    int maxx = 0;
    int hozon = 0;

    for (int i = 0; i < N-1; i++)
    {
        if (H.at(i) >= H.at(i+1))
        {
            hozon++;
        }

        else
        {
            hozon = 0;
        }

        maxx = max(hozon, maxx);
        
        
    }

    cout << maxx;
    
}

Measured memory_bytes: 640
#include<iostream>
#define ll long long int
using namespace std;
int main()
{
	ll a,b,c,d,e,f,g,h;
	cin>>a>>b>>c>>d;
	e=a*c;
	f=a*d;
	g=b*c;
	h=b*d;
	if(e>=f && e>=g && e>=h)
	{
		cout<<e<<endl;
	}
    else if(f>=e && f>=g && f>=h)
	{
		cout<<f<<endl;
	}
	else if(g>=f && g>=e && g>=h)
	{
		cout<<g<<endl;
	}
	else
	{
		cout<<h<<endl;
	}
	return 0;
}


Measured memory_bytes: 3220
#include <bits/stdc++.h>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
using ll = long long;
using ld = long double;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(void)
{
    ll x, y, z;

    cin >> x >> y >> z;
    
    cout << z << " " << x << " " << y << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int mod = pow(10, 9) + 7;
//const int mod = 998244353;
//const int mod = ;
const int INF = 1LL << 60;
const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const string abc = "abcdefghijklmnopqrstuvwxyz";
template <class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}

signed main()
{
  int N, M;
  cin >> N >> M;
  vector<int> L(M), R(M);
  for (int i = 0; i < M; i++)
  {
    cin >> L.at(i) >> R.at(i);
  }

  int l = -INF, r = INF;
  for (int i = 0; i < M; i++)
  {
    chmax(l, L.at(i));
    chmin(r, R.at(i));
  }

  int ans = max(r - l + 1, (int)0);
  
  cout << ans << endl;
}

Measured memory_bytes: 1792
using System;

public class Hello
{
    public static void Main()
    {
        var cname = new string[] { "light fly", "fly", "bantam", "feather", "light", "light welter", "welter", "light middle", "middle", "light heavy", "heavy" };
        var cv = new double[] {  48, 51, 54, 57, 60, 64, 69, 75, 81, 91, 150 };
        string line;
        for (; (line = Console.ReadLine()) != null;)
        {
            var w = double.Parse(line.Trim());
            for (int i = 0; i < cv.Length; i++)
                if (w <= cv[i]) { Console.WriteLine(cname[i]); break; }
        }
    }
}

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

int main() 
{  
   int A,B;
   std::cin >> A >> B;
   if (((A+B)<(A-B)) && ((A*B)<(A-B)) )
      std::cout << (A-B);
   else
      if ((A+B)<(A*B))
        std::cout << (A*B);
      else 
        std::cout << (A+B);
   return 0;
}

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

using namespace std;

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

int dp[3100][3100] = {0};

int main() {
  string s, t;
  cin >> s >> t;

  for(int i = 0; i < s.size(); ++i) {
    for(int j = 0; j < t.size(); ++j) {
      if(s[i] == t[j]) {
        chmax(dp[i + 1][j + 1], dp[i][j] + 1);
      }
      chmax(dp[i + 1][j + 1], dp[i + 1][j]);
      chmax(dp[i + 1][j + 1], dp[i][j + 1]);
    }
  }

  string result = "";
  int i         = s.size();
  int j         = t.size();
  while(i > 0 && j > 0) {
    if(dp[i][j] == dp[i - 1][j]) {
      i--;
    } else if(dp[i][j] == dp[i][j - 1]) {
      j--;
    } else {
      result = s[i - 1] + result;
      --i;
      --j;
    }
  }

  cout << result << endl;

  return 0;
}

Measured memory_bytes: 37120
// AtCoder Regular Contest 079
// C - Cat Snuke and a Voyage

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;


const int MAX_N = 200000;

int N, M;
bool trans[MAX_N];

int main() {

    int a, b;
    bool ans = false;

    cin >> N >> M;
    memset(trans, 0, sizeof(trans));
    for (int i = 0; i < M; i++) {
        cin >> a >> b;
        a--; b--;
        if (b == 0 || b == N - 1) {
            swap(a, b);
        }
        if (a == 0 || a == N - 1) {
            if (trans[b]) {
                ans = true;
                break;
            }
            trans[b] = true;
        }
    }

    cout << (ans ? "POSSIBLE" : "IMPOSSIBLE") << endl;

    return 0;

}





Measured memory_bytes: 384
try while 0=0do let a=Array.init 10(fun _->Scanf.scanf"%d,"(fun i->i*2000))in Scanf.scanf"%d,%d
"(fun v w->let rec($)i z=if Array.fold_left(+)0a/(v+w)*v<=z+a.(i)then Printf.printf"%d
"(i+1)else(i+1)$(z+a.(i))in 0$0)done with _->()

Measured memory_bytes: 2388
#include<stdio.h>

int main()
{

 int a, b;

 scanf("%d", &a);
 scanf("%d", &b);

 if (a > b)
{
   printf("a > b\n");
}
 else if (a < b)
{
   printf("a < b\n");
}
 else if (a == b)
{
   printf("a == b\n");
}

 return 0;

}


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


int main()
{
	int n;
	long long ans=0;
	scanf("%d",&n);
	for(int i=1;i<=n;++i) {
		if(i%3==0||i%5==0) continue;
		ans+=i;
	}
	cout<<ans;
}

Measured memory_bytes: 3688
#include <bits/stdc++.h>
#define int long long

using namespace std;

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

	string s; cin >> s;
	int sum_ = 0;
	for(int i = 0; i < (int) s.length(); i++) sum_ += s[i] - '0';     

	cout << (sum_ % 9 ? "No" : "Yes");

  return 0;
}


Measured memory_bytes: 3736
#include<algorithm>
#include <bits/stdc++.h>
#include <math.h>
#include <queue>
using namespace std;
int main(void){
	int a,b;
	cin>>a>>b;
	if(a+b>=10)cout<<"error"<<endl;
	else cout<<a+b<<endl;
	return 0;
}

Measured memory_bytes: 256
import sys
from collections import deque
from operator import itemgetter


def input():
    return sys.stdin.readline().rstrip()


def main():
    N = int(input())
    A = []
    B = []
    C = []
    for i in range(N):
        a, b, c = map(int, input().split())
        A.append(a)
        B.append(b)
        C.append(c)
    dp = [[0] * 3 for _ in range(N + 1)]
    for i in range(1, N + 1):
        dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + A[i - 1]
        dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + B[i - 1]
        dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + C[i - 1]
    print(max(dp[N]))


if __name__ == "__main__":
    main()


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

int main(){
    string s, t;
    cin >> s >> t;
    int cnt = 0;
    rep(i, 3){
        if(s[i] == t[i]){
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;

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

typedef tree <ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
#define endl "\n"

template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) 
{
    os << "{ ";
    for(auto& y : x) 
    {
        os << y << " ";
    }
    return os << "}";
}

template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) 
{
    return os << "[" << p.ff << ", " << p.ss << "]";
}

ll gcd(ll a, ll b)
{
    if(b==0)
    {
        return a;
    }

    return gcd(b, a%b);
}

ll modexp(ll a, ll b, ll c)
{   
    a%=c;

    ll ans = 1;

    while(b)
    {
        if(b&1)
        {
            ans = (ans*a)%c;
        }

        a = (a*a)%c;
        b >>= 1;
    }

    return ans;
}

ll nxt()
{
    ll x;
    cin >> x;
    return x;
}

const ll L = 3e3+5;
ll dp[L][L];

void solve()
{
    ll n = nxt();
    basic_string <ll> a(n, 0);
    generate(all(a), nxt);

    for(ll i=n-1; i>=0; i--)
    {
        for(ll j=i; j<n; j++)
        {
            if(i == j)
            {
                dp[i][j] = a[i];
                continue;
            }

            dp[i][j] = max(a[i] - dp[i+1][j], a[j] - dp[i][j-1]);
        }
    }   

    cout << dp[0][n-1] << endl;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    
    ll T = 1;
    // T = nxt();

    while(T--)
    {
        solve();
    }

    return 0;
}

Measured memory_bytes: 70016
#include<stdio.h>


int main(void)
{
	int A,B,T;
	int sum = 0;
	int i;
	scanf("%d",&A);
	scanf("%d", &B);
	scanf("%d", &T);
	for (i = 1; A*i < T + 0.5; i++)
		sum += B;
	

	printf("%d",sum);

	}

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

using ll = long long int;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()


bool my_cp(pair<int, int> a, pair<int, int> b){
  return (double)b.first / (double)(b.second+1) < (double)a.first / (double)(a.second+1);
}

ll cnt_rep = 0;
ll powmod(ll N, ll P, ll M){
  cnt_rep++;
  if(P == 0) return 1;
  if(P%2 == 0){
    ll t = powmod(N, P/2, M);
    return t*t % M;
  }
  return (N * powmod(N, P-1, M)) % M;
}





// substr(start, len)

int main(){
  ll h, w, ans = 0;
  cin >> h >> w;

  if(h == 1){
    cout << 1 << endl;
    return 0;
  }else if(w == 1){
    cout << 1 << endl;
    return 0;
  }

  if(h%2 == 0 && w % 2 == 0){
    ans = h*w/2;
  }else if(h%2 == 0 && w % 2 != 0){
    ans = h/2 * w;
  }else if(w%2 == 0 && h % 2 != 0){
    ans = h * w/2;
  }else{
    ans = h*(w-1)/2 + (h+1)/2;
  }

  cout << ans << endl;

// CHECK if it's possible to overflow!!
}

Measured memory_bytes: 256
// C - HonestOrUnkind2
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(s);i<(e);++i)

int A[15], X[15][15], Y[15][15];

int main(){
	int N; scanf("%d",&N);
	rp(i, 0, N){ scanf("%d",A+i); rp(j, 0, A[i]){ scanf("%d%d",X[i]+j,Y[i]+j); X[i][j]--; } }

	int ans = 0;
	rp(bits, 1, 1<<N){
		int count=0, ok=1;
		for(int i=0; i<N && ok; ++i)
			if((bits>>i)&1){
				count++;
				for(int j=0; j<A[i] && ok; ++j) if(((bits>>X[i][j])&1) != Y[i][j]) ok = 0;
			}
		if(ok) ans = max(ans, count);
	}
	printf("%d\n", ans);
}

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
const int inf = 1000000001;
const ll INF = 1e16;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<<fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };

int main() {
	ll n, a, b, i, j;
	cin >> n >> a >> b;
	vl x(n);
	for (i = 0; i < n; i++) {
		cin >> x[i];
	}
	ll ans = 0;
	for (i = 1; i < n; i++) {
		if ((x[i] - x[i - 1])*a < b) {
			ans += (x[i] - x[i - 1])*a;
		}
		else {
			ans += b;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
h, w = map(lambda x: int(x)+2, input().split())
MOD = 10**9+7
MAZE = ['#'*w]
for _ in range(h-2):
    MAZE.append('#'+input()+'#')
else:
    MAZE.append('#'*w)

route = [[0]*w for _ in range(h)]
for j in range(1, w):
    if MAZE[1][j] == '.':
        route[1][j] = 1
        continue
    break
for i in range(1, h):
    if MAZE[i][1] == '.':
        route[i][1] = 1
        continue
    break

for i in range(1, h-1):
    for j in range(1, w-1):
        x = i+1
        y = j+1
        if MAZE[x][y] == '#':
            continue
        route[x][y] = route[x-1][y]+route[x][y-1]
        
print(route[-2][-2] % MOD)

Measured memory_bytes: 217072