akhauriyash/Code-Regression huggingface dataset:
/* -------------------------------- Template -------------------------------- */

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <locale>
#include <iostream>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()

using namespace std;

using ll = long long;
using ld = long double;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

template<typename T> constexpr T inf = [](){ assert(false); };
// template<> constexpr int inf<int> = 1e9;
// template<> constexpr ll inf<ll> = 1e18;
// template<> constexpr ld inf<ld> = 1e30;

struct yes_no : numpunct<char> {
  string_type do_truename()  const { return "Yes"; }
  string_type do_falsename() const { return "No"; }
};

class range {
  class Index {
    int x;
  public:
    Index(int x) : x(x) {}
    int operator*() const { return x; }
    bool operator!=(Index &r) { return x < r.x; }
    void operator++() { ++x; }
  };
  Index i, n;
public:
  range(int n) : i(0), n(n) {}
  range(int i, int n) : i(i), n(n) {}
  Index &begin() { return i; }
  Index &end() { return n; }
};

/* -------------------------------- Library -------------------------------- */

/* ---------------------------------- Main ---------------------------------- */

int main() {
  locale loc(locale(), new yes_no);
  cout << boolalpha;
  cout.imbue(loc);

  int n;
  cin >> n;
  vector<int> a(n);
  for (int &i: a) cin >> i;
  int res = 1e9;
  for (int i: range(-100, 101)) {
    int sum = 0;
    for (int j: a) sum += (i - j) * (i - j);
    chmin(res, sum);
  }
  cout << res << endl;
  return 0;
}


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

#include <iostream>
using namespace std;
int main() {
  string s, t;
  cin >> s >> t;
  bool flag = true;
  for (int i = 0; i < s.size(); ++i) {
    if (s[i] != t[i]) {
      flag = false;
      break;
    }
  }
  if (flag) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 3628
#include <cstdio>
#include <iostream>
using namespace std;
int main()
{
        int a, b, k;
        scanf("%d %d %d", &a, &b, &k);
        int imax = max(a, b);
        int n = 0;
        for (int i = imax; i >= 1; --i)
        {
                if (a % i == 0 && b % i == 0)
                {
                        n++;
                }
                if (n == k)
                {
                        printf("%d\n", i);
                        break;
                }
        }
        return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;

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

int main()
{
	int n;
	cin >> n;
	int sum = 0;

	REP(i , n){
		int a, b;
		cin >> a >> b;
		sum += (b - a) + 1;
	}

	cout << sum << endl;

	
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
  static int n;
  static char[] s;

  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    n = sc.nextInt();
    s = sc.next().toCharArray();

    int x = 0;
    int max = 0;
    for(int i = 0; i < s.length; i++){
      if(s[i] == 'I'){
        ++x;
      }
      else{
        --x;
      }
      max = Math.max(max, x);
    }

    System.out.println(max);
  }
}


Measured memory_bytes: 22608
import java.util.Scanner;

public class Main {
	public void exec() {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		if(a>b) {
			System.out.println("a > b");
		}else if(a<b){
			System.out.println("a < b");
		}else{
			System.out.println("a == b");
		}
	}

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

Measured memory_bytes: 25968
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
#define se cout << "test ok" << endl;
#define sp << " " <<
using namespace std;
using ll = long long;
using ld = long double;
ll mod = ll(1e9)+7;
ll inf = ll(1e18);
template<typename T1, typename T2> ll ceill(T1 a, T2 b){ return (a+b-1)/b; }
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b){a=b; return true;} return false; }
template<typename T> inline bool chmin(T &a, T b){ if(a>b){a=b; return true;} return false; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){ fill((T*)array, (T*)(array+N), val); }
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

#include <iostream>
#include <vector>
#include <map>
using namespace std;

namespace dbg {
    using ll = long long;

    class Debug {
    public:
        Debug(){}
        template<typename T>
        void vd(vector<T> vec);
        template<typename T>
        void vd2(vector<vector<T>> vec);
        template<typename T>
        void ad(T *arr, ll n);
        template<typename T, size_t N>
        void ad2(T (&arr)[N], ll n);
        template<typename T>
        void md(T mp);
    };

    template<typename T>
    void Debug::vd(vector<T> vec) {
        for (auto vv : vec) cout << vv << " ";
        cout << endl;
    }

    template<typename T>
    void Debug::vd2(vector<vector<T>> vec) {
        for (auto vv : vec) for (auto vvv : vv) cout << vvv << " ";
        cout << endl;
    }

    template<typename T>
    void Debug::ad(T *arr, ll n) {
        for (int i = 0; i <= n; i++) cout << arr[i] << " ";
        cout << endl;
    }

    template<typename T, size_t N>
    void Debug::ad2(T (&arr)[N], ll n) {
        for (int i = 0; i <= N; i++) for (int j = 0; j <= n; j++) cout << arr[i][j] << " ";
        cout << endl;
    }

    template<typename T>
    void Debug::md(T mp) {
        cout << "key : value" << endl;
        for (auto const &m : mp) cout << m.first << " : " << m.second << endl;
        cout << endl;
    }

}

#endif //INCLUDE_DEBUG_HPP

using dbg::Debug;
Debug debug;

class BNotFound {
public:
	void solve(std::istream& in, std::ostream& out) {
	    string s;
	    in >> s;
	    set<char> st;
	    for(int i=0; i<26; i++){
	        st.insert(char('a'+i));
	    }

	    for(int i=0; i<s.length(); i++){
	        st.erase(s[i]);
	    }

	    string res = "None";
	    for(auto e : st){
	        res = e;
	        break;
	    }

	    out << res << endl;
	}
};


int main() {
	BNotFound solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 512
#include <stdio.h>
#include <string.h>

int main(void)
{
	int a[100], b[100], i = 0;
	char op[100][2];
	
	do {
		scanf("%d %s %d", &a[i], op[i], &b[i]);
	} while (strcmp(op[i++], "?"));
	
	i = 0;
	
	while (strcmp(op[i], "?")) {
		if (strcmp(op[i], "+") == 0)
			printf("%d\n", a[i] + b[i]);
		else if (strcmp(op[i], "-") == 0)
			printf("%d\n", a[i] - b[i]);
		else if (strcmp(op[i], "*") == 0)
			printf("%d\n", a[i] * b[i]);
		else if (strcmp(op[i], "/") == 0)
			printf("%d\n", a[i] / b[i]);
		i++;
	}
	
	return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100 * 3

int n;

int main() {
	cin >> n;
	int cnt = 1, sum = 0;
	while (1) {
		sum += cnt;
		if (sum >= n)break;
		cnt++;
	}
	for (int i = cnt; i > 0; i--) {
		if (n >= i) {
			n -= i;
			cout << i << endl;
		}
	}
}

Measured memory_bytes: 256
import java.util.*;
public class Main {

	public void doIt(){
		Scanner sc = new Scanner(System.in);
		sc.useDelimiter("[, \\r\\n]+");
		while(sc.hasNext()){
			double x1 = sc.nextDouble();
			double y1 = sc.nextDouble();
			double x2 = sc.nextDouble();
			double y2 = sc.nextDouble();
			double xq = sc.nextDouble();
			double yq = sc.nextDouble();
			double ansx, ansy;

			if(y1 == y2){
				ansx = xq;
				ansy = y1 * 2 - yq;
			}
			else if(x1 == x2){
				ansx = x1 * 2 - xq;
				ansy = yq;
			}
			else{
				double pa = (y2 - y1) / (x2 - x1);
				double pb = y1 - pa * x1;
				double qa = (double)-1 / pa;
				double qb = yq - qa * xq;
				double midx = (pb - qb) / (qa - pa);
				double midy = qa * midx + qb;
				ansx = midx * 2 - xq;
				ansy = midy * 2 - yq;
			}
			System.out.printf("%1.6f %1.6f\n", ansx,ansy);
		}

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

	}

}

Measured memory_bytes: 12000
import java.util.*;

public class Main {
    public static void main(String[] args) {

      Scanner sc = new Scanner(System.in);
      int x = sc.nextInt();
      int a = sc.nextInt();
      int b = sc.nextInt();
      
      int j = 0;
      int k = 0;
      
      if(x > a){
          j = x - a;
      } else {
          j = a - x;
      }
      if(x > b){
          k = x - b;
      } else {
          k = b - x;
      }
      
      if(j < k){
          System.out.println("A");
      } else {
          System.out.println("B");
      }
      sc.close();
    }
}

Measured memory_bytes: 22868
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <cmath>
#include <numeric>
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <list>
#include <unordered_map>
#include <tuple>
#include <complex>


#define FOR(i, a, b)		for(int i = (int)(a); i < (int)(b); ++i)
#define FORE(i, a, b)		for(int i = (int)(a); i <= (int)(b); ++i)
#define REP(i, n)			FOR(i, 0, n)
#define REPE(i, n)			FORE(i, 0, n)
#define ALL(x)				(x).begin(),(x).end()
#define DEBUG_DC(x)			cout << #x << ": " << x << endl
#define ANS_DC(x)			cout <<  x << endl
#define VEC_TYPE			ll	
#define INF					1e5+1

using namespace std;
typedef long long ll;
typedef vector<VEC_TYPE> vdef;
typedef vector<vdef> vvdef;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T>inline T mygcd(T a, T b) { return b ? mygcd(b, a%b) : a; }
template<typename T>inline T mylcm(T a, T b) { return a * b / mygcd(a, b); }

struct opr
{
	int num;
	ll val;

	opr(int b, ll c)
	{
		num = b;
		val = c;
	}
};

bool cmp(const opr &a, const opr &b)
{
	return a.val > b.val;
}

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

	vdef a(n, (ll)0);
	for (int i = 0; i < n; ++i) cin >> a[i];
	sort(ALL(a));

	ll ans = (ll)0;

	vector<opr> oprVec;
	for (int i = 0; i < m; ++i)
	{
		int b;
		cin >> b;
		ll c;
		cin >> c;
		oprVec.emplace_back(opr(b, c));
	}

	sort(ALL(oprVec), cmp);

	int cnt = 0;

	for (int i = 0; i < n; ++i)
	{
		if (chmax(a[i], oprVec[cnt].val))
		{
			--oprVec[cnt].num;
			if (oprVec[cnt].num == 0)
				++cnt;
		}
		ans += a[i];
	}

	ANS_DC(ans);
	return 0;
}

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#include <map>
#include <algorithm> 
#include <vector> 
#include <string.h> 
#include <math.h> 
#include <stdio.h> 
#include <stdlib.h> 
#include <chrono> 
#include <thread> 
#include <iomanip>
#include <typeinfo>
 
//define
#define trav(i,v)   for(auto i: v)
#define rep(i,n)    for(int i=0;i<n;i++)
#define repu(i,k,n) for(int i=k;i<=n;i++)
#define repd(i,k,n) for(int i=k;i>=n;i--)
#define se second
#define fi first
#define pb push_back
#define mp make_pair
#define all(v)  v.begin(), v.end()
#define itn int 

//typedef
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef std::pair<int, int> pii;
typedef std::vector<int> vi;
typedef std::vector< pii > vii;
typedef std::vector< ll > vll;
typedef std::vector< std::pair < pii, int > > vpp;
 
const long long MOD = 1000000007;
// const long long MOD = 998244353;
const long long inf = 100000000000000;

using namespace std;

ll modpow(ll x,ll n){
    ll res=1;
    while(n>0){
        if(n&1) res=res*x%MOD;
        x=x*x%MOD;
        n>>=1;
    }
    return res;
}

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

void solve()
{
    ll d, t, s;
    cin>>d>>t>>s;
    if(t*s>=d)
    {
        cout<<"Yes\n";
    }
    else
    {
        cout<<"No\n";
    }
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    int t = 1, tt=1;
    // cin>>t;
    while(tt<=t)
    {
        // cout<<"Case #"<<tt<<": ";
        solve();
        tt++;
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 3792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define debug(x) cerr << "[(" << __LINE__ << ") " << (#x) << "]: " << x << endl;

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

    int n;
    cin >> n;
    int a[n];
    ll sm = 0;
    map<int, int> m;
    for (int& e : a) {
        cin >> e;
        sm += m[e];
        m[e]++;
    }

    for (int i=0; i<n; i++) {
        cout << sm - m[a[i]]+1 << "\n";
    }
}


Measured memory_bytes: 8320
fun main(args: Array<String>) {
    val (h, w) = readLine()!!.split(' ').map { it.toInt() }

    val grid = (0 until h).map {
        readLine()!!.split(' ').map { it.toInt() }.toIntArray()
    }.toTypedArray()

    val ops = mutableListOf<Pair<Pair<Int, Int>, Pair<Int, Int>>>()

    for (i in 0 until h) {
        for (j in 0 until w - 1) {
            if (grid[i][j] % 2 == 1) {
                grid[i][j] -= 1
                grid[i][j + 1] +=1
                ops.add((i + 1 to j + 1) to (i + 1 to j + 2))
            }
        }
        if (i < h - 1 && grid[i][w - 1] % 2 == 1) {
            grid[i][w - 1] -= 1
            grid[i + 1][w - 1] +=1
            ops.add((i + 1 to w) to (i + 2 to w))
        }
    }

    println(ops.size)
    ops.forEach { println("${it.first.first} ${it.first.second} ${it.second.first} ${it.second.second}") }
}


Measured memory_bytes: 98012
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;

int main() {
	int n;
	cin >> n;
	int ans = 100000;
	for (int i = 1; i <= (n / 2); i++) {
		int a = i, b = n - i;
		int ansi = 0;
		while (a > 0) {
			ansi += a % 10;
			a /= 10;
		}
		while (b > 0) {
			ansi += b % 10;
			b /=10;
		}
		ans = min(ans, ansi);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

// ARC 86-D
// https://beta.atcoder.jp/contests/arc086/tasks/arc086_b

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		
		int M = in.nextInt();
		System.out.println(24 + 24 - M);
	}
}


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

int main()
{
    string S;
    cin >> S;
    int a[26] = {0};

    for(int i=0; i<S.size(); i++) a[S[i]-'a'] += 1;
    for(int i=0; i<26; i++)
    {
        if(2 <= a[i])
        {
            cout << "no" << endl;
            return 0;
        }
    }
    cout << "yes" << endl;
    return 0;
}

Measured memory_bytes: 3584
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecS = vector<string>;
using VecVec = vector<Vec>;
using Tree = vector<VecP>;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T& b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T& b){if(a > b){a = b; return true;} return false;}
template <typename T>
void co(const T n){cout << n << endl;}
template <typename T>
void cosp(const T n){cout << n << ' ';}
void coVec(const Vec &v){for(ll i : v) cosp(i); cout << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const double PI = acos(-1);
const double EPS = 1e-9;

int main(void){
	string s;
	cin >> s;

	ll len = s.length()+1;
	bitset<100010> bits(s);
	rep(i, len){
		if(bits[i]) bits.reset(i);
		else{
			bits.set(i);
			break;
		}
	}
	

	Vec num2(100010), num3(100010);
	rep(i, len){
		if(!i){
			num2[i] = 1;
			num3[i] = 1;
		}
		else{
			num2[i] = (num2[i-1]<<1)%MOD;
			num3[i] = (num3[i-1]*3)%MOD;
		}
	}

	ll ans = 0, cnt = 0, tmp = 0;
	repr(i, len) if(bits[i]){
		ans += (num3[i]*num2[cnt])%MOD;
		ans %= MOD;
		cnt++;
	}
	co(ans);

	return 0;
}


Measured memory_bytes: 2048
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <cmath>

using namespace std;
using ll = long long;
using ull = unsigned long long;

constexpr ll LLINF {1001002003004005006};//ll = 9*LLINF
constexpr int INTINF {1000000000};//int = 2*INTINF

#define  rep(i,n)   for(int i = 0; i < (n); ++i)
#define rrep(i,n)   for(int i = 1; i <= (n); ++i)
#define drep(i,n)   for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for(int i = s; i < t;  ++i)

template<typename T>
void maxs(T& x, T&& y) {
  x=std::max(x,y);
}
template<typename T>
void maxs(T& x, T& y) {
  x=std::max(x,y);
}

template<typename T>
void mins(T& x, T&& y) {
  x=std::min(x,y);
}
template<typename T>
void mins(T& x, T& y) {
  x=std::min(x,y);
}

int main() {
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int A;
  cin >> A;
  cout << (3.14159265*A*2) << '\n';
}


Measured memory_bytes: 3252
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<complex>

using namespace std;

#define ll long long
#define ld long double
#define EPS 1e-9
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<int,pii> pip;
typedef vector<pii> vp;
typedef vector<vi> vvi;

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

class Dijkstra{
private:
    struct edge { int to, cost;};
    vector< vector<edge> > g;

public:
    Dijkstra(){};
    Dijkstra(int size){
        g.resize(size);
    }
    vvi dist;

    void add_edge(int a, int b, int c){//無向辺
        edge e1 = {b, c}, e2 = {a, c};
        g[a].push_back(e1);
        //g[b].push_back(e2);//有向辺の場合はここをコメントアウトする
    }

    void calc(int s){
        priority_queue< pip, vector<pip>, greater<pip> > q;
        int n = g.size();
        dist = vvi (n, vi(3,LINF));
        dist[s][0] = 0;
        q.push(pip(0, pii(s,0)));

        while(!q.empty()){
            pip p = q.top();
            q.pop();
            int v = p.second.first;
            int num = p.second.second;
            if(dist[v][num] < p.first)continue; //更新されていたら何もしない
            for(int i = 0; i < g[v].size(); i++){
                edge e = g[v][i];
                if(dist[e.to][(num+e.cost)%3] > dist[v][num] + e.cost){
                    dist[e.to][(num+e.cost)%3] = dist[v][num] + e.cost;
                    q.push(pip(dist[e.to][(num+e.cost)%3], pii(e.to,(num+e.cost)%3)));
                }
            }
        }
    }

};

signed main(void) {
    int n,m;
    cin >> n >> m;
    Dijkstra dij(n);
    rep(i,m){
        int a,b;
        cin >> a >> b;
        dij.add_edge(a-1,b-1,1);
    }
    int s,t;
    cin >> s >> t;
    s--,t--;
    dij.calc(s);
    int ans = dij.dist[t][0];
    if(ans < LINF){
        cout << ans/3 << endl;
    }else{
        cout << -1 << endl;
    }
}


Measured memory_bytes: 11136
# 050_a
A, op, B = input().split()
A = int(A)
B = int(B)
if (1 <= A & A <= 10 ** 9) & (1 <= B & B <= 10 ** 9) & ((op == '+') | (op == '-')):
    if op == '+':
        result = A + B
    elif op == '-':
        result = A - B
    print(result)

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

using ll = long long;
using ull = unsigned long long;

#define MOD 1000000007

int main(void) {
    ll N, L;
    vector<string> lis;
    cin >> N >> L;
    lis.resize(N);
    for(ll i = 0;i < N;i++) cin >> lis[i];
    sort(lis.begin(), lis.end());
    for(auto &i: lis) cout << i;
    cout << endl;
    return 0;
}


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

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

using namespace std;

int main()
{
    string s;
    while(cin >> s)
    {
        if(s == "#") break;
        
        int cnt = 0;
        string t = "yuiophjklnm*";
        bool right = true;
        if(t.end() != find(t.begin(),t.end(),s[0])) {
            right = false;
        }
        rep(i,s.size()) {
            if(right) {
                if(t.end() != find(t.begin(),t.end(),s[i])) {
                    cnt++;
                    right = false;
                }
            }
            else {
                if(t.end() == find(t.begin(),t.end(),s[i])) {
                    cnt++;
                    right = true;
                }
            }
        }

        cout << cnt << endl;
    }

    return 0;
}

Measured memory_bytes: 1192
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	char c[n+1];
	int ans[n+2];
	for(int i=0;i<n;i++){
		cin>>c[i];
		if(c[i]=='o'){
			c[i]='0';
		}
		else{
			c[i]='1';
		}
		ans[i]=-1;
	}
	c[n]=c[0];
	for(int i=0;i<5;i++){
		if(i==0){
			ans[0]=0;
			ans[1]=0;
		}
		else if(i==1){
			ans[0]=0;
			ans[1]=1;
		}
		else if(i==2){
			ans[0]=1;
			ans[1]=0;
		}
		else if(i==3){
			ans[0]=1;
			ans[1]=1;
		}
		else{
			cout<<"-1";
			return 0;
		}
		for(int j=2;j<n+2;j++){
			ans[j]=ans[j-2]^ans[j-1]^(c[j-1]-'0');
		}
		if(ans[0]==ans[n]&&ans[1]==ans[n+1]){
			for(int i=0;i<n;i++){
				if(ans[i]==0){
					cout<<"S";
				}
				else{
					cout<<"W";
				}
			}
			return 0;
		}
	}
} 

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

int i,j;
const int INF=100000000;


int main (){
  int n,a,b,c;
  
    ll k;
  cin >> n >> k;
  int A[n];
  int to[n+2];
  int past[n];
 
  for(i=0;i<n;i++)
  {
    cin >> A[i] ;
    A[i]--;
    past[i]=INF;
  }
  to[0]=0;
  past[0]=0;
  for(i=0;i<n+1;i++)
  {
   // cout << i << " ";
    to[i+1]=A[to[i]];
  //  cout << to[i+1] << endl;
    if(past[to[i+1]]==INF)
    {
      past[to[i+1]]=i+1;
    }
    else
    {
      
      a=past[to[i+1]];
      b=i+1-a;
      break;
    }
  }
//  cout << a <<" " << b << endl;
  
  if(k<a)
  {
    cout << to[k]+1 << endl;
  }
  if(k>=a)
  {
    k=(k-a)%b+a;
    cout << to[k]+1 << endl;
  }
  
  
  
}  
  

Measured memory_bytes: 5912
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;

template <typename T1, typename T2>
string print_iterable(T1 begin_iter, T2 end_iter, int counter) {
    bool done_something = false;
    stringstream res;
    res << "[";
    for (; begin_iter != end_iter and counter; ++begin_iter) {
        done_something = true;
        counter--;
        res << *begin_iter << ", ";
    }
    string str = res.str();
    if (done_something) {
        str.pop_back();
        str.pop_back();
    }
    str += "]";
    return str;
}

vector<int> SortIndex(int size, std::function<bool(int, int)> compare) {
    vector<int> ord(size);
    for (int i = 0; i < size; i++) ord[i] = i;
    sort(ord.begin(), ord.end(), compare);
    return ord;
}

template <typename T>
bool MinPlace(T& a, const T& b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
bool MaxPlace(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template <typename Container>
int SZ(const Container& S) { return S.size(); }

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

template <typename T>
ostream& operator <<(ostream& out, const vector<T>& v) {
    out << "[";
    for (int i = 0; i < (int)v.size(); i++) {
        out << v[i];
        if (i != (int)v.size()-1) out << ", ";
    }
    out << "]";
    return out;
}

#if DEBUG && !ONLINE_JUDGE
    ifstream input_from_file("input.txt");
    #define cin input_from_file

    #define dbg_var(x) clog << #x  << ": " << x << endl;
    #define dbg_array(x, len) clog << #x << ": " << print_iterable(x, x+len, -1) << endl;
#else
    #define dbg_var(x)
    #define dbg_array(x, len)
#endif

///////////////////////////////////////////////////////////////////////////
//////////////////// DO NOT TOUCH BEFORE THIS LINE ////////////////////////
///////////////////////////////////////////////////////////////////////////

const int MAXN = 310;
LL din[MAXN][MAXN];
LL f[MAXN][MAXN]; 

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); // Remove in problems with online queries!

    LL N, K, mod;
    cin >> N >> K >> mod;
    for (LL m = 1; m < MAXN; m++) f[m][0] = 1;
    for (LL n = 0; n < MAXN; n++) din[n][1] = 1;
    for (LL q = 1; q < MAXN; q++) {
        for (LL m = 1; m < MAXN; m++)  {
            f[m][q] = 0;
            for (LL l = 1; l <= m; l++) f[m][q] += l*f[l][q-1];
            f[m][q] %= mod;
        }
    }
    for (LL k = 2; k < MAXN; k++) {
        for (LL n = 0; n < MAXN; n++) {
            din[n][k] = din[n][k-1];
            for (LL q = 1; q <= n; q++) din[n][k] += (din[n-q][k-1]*f[n-(q-1)][q]) % mod;
            din[n][k] %= mod;
        }
    }
    cout << din[N][K] << "\n";
}



Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<int,int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,1,-1,1,-1,-1,0};
int dy[]={0,1,1,-1,-1,1,0,-1};

static const int MAX_SIZE = 1 << 20; 

LL segMax[2 * MAX_SIZE - 1], segAdd[2 * MAX_SIZE - 1];

//区間[a, b)に値xを加算する.
void add(int a, int b, LL x, int k = 0, int l = 0, int r = MAX_SIZE)
{
    if (r <= a || b <= l) return;

    if (a <= l && r <= b){
        segAdd[k] += x;
        return;
    }

    add(a, b, x, k * 2 + 1, l, (l + r) / 2);
    add(a, b, x, k * 2 + 2, (l + r) / 2, r);

    segMax[k] = max(segMax[k * 2 + 1] + segAdd[k * 2 + 1], segMax[k * 2 + 2] + segAdd[k * 2 + 2]);
}

LL getMax(int a, int b, int k = 0, int l = 0, int r = MAX_SIZE)
{
    if (r <= a || b <= l) return 0;

    if (a <= l && r <= b) return (segMax[k] + segAdd[k]);

    LL left = getMax(a, b, k * 2 + 1, l, (l + r) / 2);
    LL right = getMax(a, b, k * 2 + 2, (l + r) / 2, r);

    return (max(left, right) + segAdd[k]);
}



int main(){
    int n;
    LL d,a;cin >> n >> d >> a;
    vector<P> v(n);
    vector<LL> x(n);
    for (int i = 0; i < n; i++) {
        cin >> v[i].fs >> v[i].sc;
        x[i] = v[i].fs;
    }
    sort(ALL(v));
    sort(ALL(x));
    for (int i = 0; i < n; i++) {
        add(i,i+1,v[i].sc);
    }
    LL ans = 0;
    for (int i = 0; i < n; i++) {
        LL t = getMax(i,i+1);
        if(t <= 0) continue;
        LL p = (t + a - 1) / a;
        LL r = upper_bound(ALL(x),v[i].fs + 2 * d) - x.begin();
        add(i,r,- p * a);
        ans += p;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 15872
#include<stdio.h>
int main(){
  int a,b,t,y;
  scanf("%d%d",&a,&b);
  if(a<b){
    t=a;
    a=b;
    b=t;
  }

  y=a%b;
  while(y!=0){
    a=b;
    b=y;
    y=a%b; 
  }
  
  printf("%d\n",b);
  return 0;
}
  



Measured memory_bytes: 2128
#include <cmath>
#include <cstdio>

#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <numeric>
#include <string>
#include <array>

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

using namespace std;
typedef long long int ll;

int main() {
  ll n, m;
  cin >> n >> m;
  ll p=1;
  rep(i, m) p*=2;
  ll ans = 1900*m*p+ (n-m)*100*p;
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#define _USE_MAT_DEFINES
#include<iostream>
#include <iomanip>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <stack>
#include <deque>
#include <numeric>
#include <functional>
using namespace std;

int main() {

    long long N, K;
    cin >> N >> K;
    vector<long long>cnt(100000 + 1, 0);
    for (int i = 0; i < N; i++) {
        int a, b;
        cin >> a >> b;
        cnt[a] += b;
    }

    long long c = 0;
    for (int i = 0; i < cnt.size(); i++) {
        c += cnt[i];
        if (c >= K) {
            cout << i << endl;
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 1024
use Math::Trig 'pi';
my $S =<>;chomp $S;
my ($A,$B,$H,$M) = split(/ /,$S);


my $AT = (((30*$H)+(0.5*$M))/360)*2*pi; 
my $BT = ((6*$M)/360)*2*pi;

my $BX = $B * sin($BT);
my $BY = $B * cos($BT);
my $AX = $A * sin($AT);
my $AY = $A * cos($AT);

my $ans = sqrt(($BX-$AX)**2 + ($BY-$AY)**2);

print "$ans";

Measured memory_bytes: 7968
fn solve() {
    let (n, x, t): (usize, usize, usize) = (read::<usize>(), read::<usize>(), read::<usize>());
    println!(
        "{}",
        if n % x == 0 {
            n / x * t
        } else {
            (n / x + 1) * t
        }
    );
}

fn main() {
    let stack_size = 104_857_600;
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}

// =========
#[allow(unused_imports)]
use std::cmp::{max, min, Reverse};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap, HashSet};
#[allow(unused_imports)]
use std::process::exit;

#[allow(dead_code)]
const MOD: usize = 1000000007;

fn read<T: std::str::FromStr>() -> T {
    use std::io::Read;
    let stdin = std::io::stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

// =========


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

int main()
{
    int k, s, count = 0;
    cin >> k >> s;

    for (int i = 0; i <= k; i++)
    {
        for (int j = 0; j <= k; j++)
        {
            if (s - i - j <= k && 0 <= s - i - j)
                count++;
        }
    }

    cout << count << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vec2(a,b) vector<vec>(a,vec(b))
#define vec2ll(a,b) vector<vecll>(a,vecll(b))
#define vec3(a,b,c) vector<vector<vec>>(a,vec2(b,c))
#define vec3ll(a,b,c) vector<vector<vecll>>(a,vec2ll(b,c))
#define fi first
#define se second
#define endl "\n"
#define all(c) begin(c),end(c)
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))
#define MM " "
#define INF INT_MAX
using namespace std;
int in() {int x;cin>>x;return x;}
ll lin() {ll x;cin>>x;return x;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> inline void print(pair<T,T> p){cout<<"("<<p.first<<","<<p.second<<") ";}
template<class T> inline void print(vector<pair<T,T>> v){for(auto e:v)print(e); cout<<endl;}
template<class T> inline void print(T v){for(auto e:v)cout<<e<<" ";cout<<endl;}


    
void go();
int n;

main(){
    ios
    ll int a=in(),b=in(),c=in();
    ll int l=a+b-c;
    if(c-a-b<=0){
        cout<<"No";
        return 0;
    }
    ll R=l*l,L=4ll*a*b;
    cout<<(L<R ? "Yes":"No");

}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long N,P,answer=1,frequency;
  cin >> N >> P;
  if (N == 1) {
    cout << P;
  } else {
    for (int i = 2; 1ll*i*i <= P; i++) {
      for (frequency = 0; !(P%i); frequency++, P /= i);
      answer *= pow(i,frequency/N);
    }
    cout << answer;
  }
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);

		long a = scan.nextLong();
		long b = scan.nextLong();
		long x = scan.nextLong();

		long a1 = a / x;
		long b1 = b / x;

		long aa = a % x;
		long bb = b % x;


		long ab=b1 - a1;

		if(aa==0) {
			ab=ab+1;
		}

		System.out.println(ab);
	}

}

Measured memory_bytes: 23764
input1=list(map(int,input().split()))
input2=list(map(int,input().split()))
input3=list(map(int,input().split()))
input4=list(map(int, input().split()))

input2.sort(reverse=True)
input3.sort(reverse = True)

raw_final=input2[:input1[0]]+input3[:input1[1]]+input4

raw_final.sort(reverse=True)

print(sum(raw_final[:input1[0]+input1[1]]))

Measured memory_bytes: 24112
/*
 * @Author: Kaizyn
 * @Date: 2020-04-28 10:26:14
 * @LastEditTime: 2020-04-28 11:22:56
 */
#include <bits/stdc++.h>

// #define DEBUG

using namespace std;

const int N = 57;
const int T = 5e3+7;
const int MOD = 998244353;
const int INF = 0x3f3f3f3f;
const double eps = 1e-7;
const double PI = acos(-1);
typedef pair<int, int> pii;

struct Edge {
    int v, a, b;
};

struct Node {
    int u, s;
    long long t;
    Node (const int &_u, const int &_s, const long long &_t) : u(_u), s(_s), t(_t) {}
    friend bool operator < (const Node &lhs, const Node &rhs) {
        return lhs.t > rhs.t;
    }
};

int n, m, s, sums;
int c[N], d[N];
long long t[N][T];
vector<Edge> e[N];
priority_queue<Node> q;

signed main()
{
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    cin >> n >> m >> s;
    for (int i = 1, u, v, a, b; i <= m; ++i) {
        cin >> u >> v >> a >> b;
        // e[u].emplace_back(v, a, b);
        e[u].push_back({v, a, b});
        e[v].push_back({u, a, b});
        sums += a;
    }
    for (int i = 1; i <= n; ++i) {
        cin >> c[i] >> d[i];
    }
    memset(t, 0x3f, sizeof t);
    s = min(s, sums);
    for (int i = 0; i <= s; ++i) t[1][i] = 0;
    q.push(Node(1, s, 0));
    while (q.size()) {
        Node cur = q.top();
        q.pop();
        if (cur.t > t[cur.u][cur.s]) continue;
        #ifdef DEBUG
        cout << cur.u << " " << cur.s << " " << cur.t << endl;
        #endif
        for (auto &edge : e[cur.u]) {
            if (edge.a > cur.s) continue;
            if (t[edge.v][cur.s-edge.a] <= edge.b+cur.t) continue;
            t[edge.v][cur.s-edge.a] = edge.b+cur.t;
            q.push(Node(edge.v, cur.s-edge.a, edge.b+cur.t));
        }
        for (int i = 1, nexts; ; ++i) {
            nexts = min(sums, cur.s+i*c[cur.u]);
            if (t[cur.u][nexts] <= cur.t+1ll*i*d[cur.u]) break;
            t[cur.u][nexts] = cur.t+1ll*i*d[cur.u];
            q.push(Node(cur.u, nexts, t[cur.u][nexts]));
            if (nexts == sums) break;
        }
    }
    for (int i = 2; i <= n; ++i) {
        long long res = t[i][0];
        for (int j = 1; j <= sums; ++j) res = min(res, t[i][j]);
        cout << res << endl;
    }
    return 0;
}

Measured memory_bytes: 9604
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stdlib.h>
#include <map>
#include <cmath>
#define MOD_P 1000000007
#define MOD_Q 998244353
#define PI 3.14159265358979
#define ll long long
using namespace std;


int main()
{
	string str;
	cin >> str;
	int n = str.size();
	int ans = 0;

	for (int i = 0; i < n; i++) {
		int t = (int)(str[i] - '0');
		//printf("%d", t);
		ans += t;
		ans %= 9;
	}
	
	printf("%s", ans ? "No" : "Yes");

	return 0;
}


Measured memory_bytes: 3844
import java.util.Scanner;

public class Main {

    private static int solve(int N) {
        int s = 0;
        while (N > 0) {
            int m = N % 10;
            if (m == 2) {
                s += 1;
            }
            N /= 10;
        }
        return s;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();

        System.out.println(solve(N));
    }
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
typedef long long ll;
typedef long long unsigned int llu;
ll MOD = 1000000007;
ll INF = 1000000009;

void solve(){

    int a,b;
    cin >> a >> b;
    cout << 6-a-b << endl;
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int d,n;
    cin>>d>>n;
    int x = n;
    if(n==100){
    x++;
    }
    for(int i=0;i<d;i++){
       x*=100;
    }
   cout<<x<<endl;
	return 0;
}



Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <cmath> //sqrt pow
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
 
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  int x;
  cin >> x;
  for(int i = 1; i <= x; i++){
    if(i * (i + 1) >= 2 * x){
      cout << i << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

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

	public void run() {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int ma=sc.nextInt();
		int mb=sc.nextInt();

		int a[] = new int[n];
		int b[] = new int[n];
		int c[] = new int[n];
		for(int i=0; i<n; i++) {
			a[i]=sc.nextInt();
			b[i]=sc.nextInt();
			c[i]=sc.nextInt();
		}
		int dp[][][] = new int[n+1][400+1][400+1];

		int max = 100*40+5;
		for(int i=0; i<=n; i++) {
			for(int j=0; j<=400; j++) {
				for(int k=0; k<=400; k++) {
					dp[i][j][k]=max;
				}
			}
		}
		dp[0][0][0]=0;

		for(int i=1; i<=n; i++) {
			for(int j=0; j<=400; j++) {
				for(int k=0; k<=400; k++) {
					dp[i][j][k] = dp[i-1][j][k];
					if(j-a[i-1]>=0 && k-b[i-1]>=0 && dp[i-1][j-a[i-1]][k-b[i-1]]!=max) {
						dp[i][j][k] = Math.min(dp[i][j][k], dp[i-1][j-a[i-1]][k-b[i-1]] + c[i-1]);
					}
				}
			}
		}

		int ans = 100*40+5;
		for(int i=1; i<=400; i++) {
			for(int j=1; j<=400; j++) {
				if(dp[n][i][j] != max) {
					if(i*mb == j*ma) {
						ans = Math.min(ans, dp[n][i][j]);
					}
				}
			}
		}
		if(ans == max) {
			System.out.println(-1);
		}else {
			System.out.println(ans);
		}
		sc.close();
	}


}


Measured memory_bytes: 69588
n, m = map(int,input().split())

A = [[0] * m for i in range(n)]
b = [0] * m

for i in range(n):
    A[i] = list(map(int,input().split()))

for j in range(m):
    b[j] = int(input())

for i in range(n):
    C = 0
    for j in range(m):
        C = C + A[i][j] * b[j]
    print(C)


Measured memory_bytes: 5956
#include <iostream>
#include <vector>

using namespace std;
using ll = long long;
const ll MOD = 1000000007;

int main() {
    int h, w, k;
    cin >> h >> w >> k;
    --k;
    vector<vector<ll>> dp(h + 1, vector<ll>(w, 0));
    dp[0][0] = 1;

    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            for (int bit = 0; bit < 1 << (w - 1); ++bit) { // つながっているのかを
                bool ok = true;
                for (int k = 0; k < w - 2; ++k) {  // i, i+1, i+2本目がつながっている場合はfalse
                    if ((bit >> k & 1) && (bit >> (k + 1) & 1)) ok = false; 
                }
                if (!ok) continue;

                int nj = j;  // 次にどのポジションにいるか。
                if ((bit >> j) & 1) nj = j + 1;  // 右側とつながっている場合
                else if (j > 0 && ((bit >> (j - 1)) & 1)) nj = j - 1; // 左側とつながっている場合

                dp[i + 1][nj] += dp[i][j];
                dp[i + 1][nj] %= MOD;
            }
        }
    }
    cout << dp[h][k] << endl;
}

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

#define BR "\n"
#define SP " "
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << SP; } cout << BR;
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << BR;

int main() {
  ll r;
  cin >> r;

  cout << (3*r*r) << "\n";
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <vector>

using namespace std;

// BEGIN NO SAD
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef vector<int> vi;
// END NO SAD

typedef long long ll;
typedef pair<int, int> pii;
typedef bitset<51> bs;

int id[55][55];
int dp[55][55];

int s[20];
int t[20];
bs cover[20];

void init(int idx) {
  int a = s[idx];
  int b = t[idx];
  while(dp[a][b] > 1) {
    bool found = false;
    for(int i = 1; i <= 50; i++) {
      if(dp[a][i] == 1 && dp[a][b] == dp[a][i] + dp[i][b]) {
        cover[idx].set(id[a][i]);
        a = i;
        found = true;
        break;
      }
    }
    assert(found);
  }
  cover[idx].set(id[a][b]);
}

void solve() {
  int n;
  cin >> n;
  memset(id, -1, sizeof(id));
  memset(dp, 1, sizeof(dp));
  for(int i = 0; i < n-1; i++) {
    int a, b;
    cin >> a >> b;
    id[a][b] = i;
    id[b][a] = i;
    dp[a][b] = 1;
    dp[b][a] = 1;
  }
  for(int i = 1; i <= n; i++) dp[i][i] = 0;
  for(int i = 1; i <= n; i++) for(int j = 1; j <= n; j++) for(int k = 1; k <= n; k++) dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
  for(int i = 1; i <= n; i++) for(int j = 1; j <= n; j++) for(int k = 1; k <= n; k++) dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
  for(int i = 1; i <= n; i++) for(int j = 1; j <= n; j++) for(int k = 1; k <= n; k++) dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
  int m;
  cin >> m;
  for(int i = 0; i < m; i++) {
    cin >> s[i] >> t[i];
    init(i);
  }
  ll ret = 0;
  for(int mask = 0; mask < (1 << m); mask++) {
    bs must;
    for(int i = 0; i < m; i++) {
      if(mask&(1<<i)) must |= cover[i];
    }
    int free = n - 1 - must.count();
    if(__builtin_popcountll(mask)%2) ret -= (1LL << free);
    else ret += (1LL << free);
  }
  cout << ret << "\n";
}

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


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] arg) throws java.io.IOException {
        Scanner scan = new Scanner(System.in);
        while (true) {
            int n = scan.nextInt();
            if (n == 0)
                break;
            int[] a = new int[n];
            int max = -500000000;
            for (int i = 0; i < n; i++)
                a[i] = scan.nextInt();
            for (int i = 0; i < n; i++) {
                int sum = 0;
                for (int j = i; j < n; j++) {
                    sum += a[j];
                    max = Math.max(max, sum);
                }
            }
            System.out.println(max);
        }
    }
}

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

int main(){
    int n, sum = 0, ans = 0;
    cin >> n;
    vector<int> v;
    for (int i = 0; i < n; i++)
    {
        int x; cin >> x;
        v.push_back(x);
        sum += x;
    }
    double ave = double(sum) / double(n);
    for (int i = 0; i < n; i++)
    {
        ans += (v[i] - round(ave)) * (v[i] - round(ave));
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace ABC134_C
{
    class Program
    {
        static void Main(string[] args) {
            long n = long.Parse(Console.ReadLine());

            List<long> list = new List<long>();
            long max = 0;
            long secondMax = 0;
            for (int i = 0; i < n; i++) {
                list.Add(long.Parse(Console.ReadLine()));
                if(list[i] > max) {
                    max = list[i];
                }else if(list[i] > secondMax) {
                    secondMax = list[i];
                }
            }

            
            for(int i = 0; i < n; i++) {
                if(list[i] == max) {
                    Console.WriteLine(secondMax);
                } else {
                    Console.WriteLine(max);
                }
            }
        }
    }
}

Measured memory_bytes: 20564
#include<iostream>
#include<string>
#include <cmath>
#include <algorithm>
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main(){

int x;

cin >> x;

if(x < 1200) cout << "ABC" << endl;
else cout << "ARC" << endl; 

return 0;
}

Measured memory_bytes: 256