akhauriyash/Code-Regression huggingface dataset:
A,B,C,X,Y=map(int,input().split())

price=1000000000
for p in range(0,max(X,Y)*2+1,2):
    q=max(0,X-p//2)
    r=max(0,Y-p//2)
    if price>p*C+q*A+r*B:
        price=p*C+q*A+r*B
print(price)

Measured memory_bytes: 9184
#include<stdio.h>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<map>
#include<queue>
#include<cstdlib>
#include<ctime>
#define rep(i,j,k) for(register int i = j; i <= k; i++)
#define dow(i,j,k) for(register int i = j; i >= k; i--)
#define ll long long
#define mp make_pair
using namespace std;
 
inline int read() {
	int s = 0, t = 1; char c = getchar();
	while( !isdigit(c) ) { if( c == '-' ) t = -1; c = getchar(); }
	while( isdigit(c) ) s = s * 10 + c - 48, c = getchar();
	return s * t;	
} 

const int N = 1e5+5, p = 1e9+7;
int n, m, a[N]; ll f[N], g[N];
inline void solve(int x,int y) { 
	if( y > x ) { 
		f[y]++;
		f[x]--;
		g[x] -= y - x;
		g[x] += y - x;
		g[m] += y - x;
		g[y] -= y - x;
	} else { 
		f[y]++;
		f[m]++;
		g[m] += y;
		f[x]--;
		g[x] -= y + m - x;
		g[x] += y + m - x;
		g[y] -= y + m - x;  
	}
}

int main() {
	n = read(), m = read();
	rep(i,1,n) a[i] = read();
	rep(i,1,n-1) solve(a[i],a[i+1]);
	dow(i,m,1) f[i] += f[i+1];
	dow(i,m,1) g[i] += g[i+1], g[i] += f[i];
	int id = 1;
	rep(i,2,m) if( g[i] < g[id] ) id = i;
	cout<<g[id]<<endl;
    return 0;
} 

Measured memory_bytes: 2176
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int x;
    cin >> x;
    cout << (x^1) << "\n";
    return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ALL(x) x.begin(), x.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;
using lld = long double;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
using PII = pair<int, int>;
random_device rnd;
mt19937 mt(rnd());

const int IINF = 1 << 30;
const ll INF = 1ll << 60;
const ll MOD = 1e9 + 7;
int n, m, q;
VVI req;
ll ans = -1;

ll calc(VI &A)
{
    ll ret = 0;
    for (auto &&x : req)
    {
        int a = x[0];
        int b = x[1];
        int c = x[2];
        int d = x[3];
        a--;
        b--;
        if (A[b] - A[a] == c)
        {
            ret += d;
        }
    }
    return ret;
}

void dfs(int cur, VI A)
{
    if (cur == n)
    {
        chmax(ans, calc(A));
        return;
    }
    int start;
    if (A.size() == 0)
    {
        start = 1;
    }
    else
    {
        start = A.back();
    }
    rep(i, start, m + 1)
    {
        A.push_back(i);
        dfs(cur + 1, A);
        A.pop_back();
    }
}

int main()
{
    cin >> n >> m >> q;
    req = VVI(q, vector<int>(4));
    rep(i, q)
    {
        cin >> req[i][0] >> req[i][1] >> req[i][2] >> req[i][3];
    }
    dfs(0, {});
    cout << ans << endl;
    return 0;
}

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

int main() {
    int n;
    cin >> n;
    
    int p;
    int m = INT_MAX;
    int ans = 0;
    rep(i,n) {
        cin >> p;
        if (p <= m) {
            m = p;
            ans++;
        }
    }

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

Measured memory_bytes: 3608
// Hail god Yato
 
#include <bits/stdc++.h> 
using namespace std;
 
#define hs ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
const ll mod = 1000000007;
const ll INF = 1e18;
const ll MAX = 100001;
//
//
void solve(){
    int k, n;
    cin>>k>>n;
    vector<int> vec(n);
    for(int i = 0; i< n; i++)
        cin>>vec[i];
    int ans = INT_MAX;
    for(int i = 0; i < n; i++){
        if(i == 0)
            ans = min(ans, vec[n-1]-vec[0]);
        else
            ans = min(ans, k-(vec[i]-vec[i-1]));
    }
    cout<<ans;
}
int main(){ 
        hs;
        ll t;
        t=1;
        // cin>>t;
        for (int i=1; i<=t; i++){
                //cout<<"Case #"<<i<<": ";
                solve();
         }
        return 0; 
}

Measured memory_bytes: 3996
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using std::cerr;
using std::cin;
using std::cout;
using std::endl;

struct Pos {
  int x, y;
  Pos(int a, int b) {
    x = a;
    y = b;
  }
};

int main(void) {
  cout << std::fixed << std::setprecision(10);
  cin.tie(0);
  std::ios::sync_with_stdio(false);

  int n;
  cin >> n;
  std::vector<Pos> red, blue;
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    red.push_back(Pos(a, b));
  }
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    blue.push_back(Pos(a, b));
  }

  bool isblue[201][201] = {}, isred[201][201] = {};
  for (auto p : red) {
    isred[p.y][p.x] = true;
  }
  for (auto p : blue) {
    isblue[p.y][p.x] = true;
  }

  int result = 0;

  for (int c = 1; c <= 200; c++) {
    for (int r = 1; r <= 200; r++) {
      if (!isblue[r][c]) continue;
      bool found = false;
      for (int rr = r - 1; rr >= 0; rr--) {
        for (int rc = c - 1; rc >= 0; rc--) {
          if (isred[rr][rc]) {
            isblue[r][c]  = false;
            isred[rr][rc] = false;
            result++;
            found = true;
            break;
          }
        }
        if (found) break;
      }
    }
  }

  cout << result << endl;

  return 0;
}


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

template<typename T, typename U>
using pv=vector<pair<T,U>>;
template<typename T>
using matrix=vector<vector<T>>;
template<typename T>
using pque=priority_queue<T>;
template<typename T>
using lpque=priority_queue<T,vector<T>,greater<T>>;

using ll=long long;
using intpair=pair<int,int>;
using llpair=pair<ll,ll>;
using ilpair=pair<int,ll>;
using lipair=pair<ll,int>;
using intvec=vector<int>;
using llvec=vector<ll>;
using intq=queue<int>;
using llq=queue<ll>;
using intmat=vector<intvec>;
using llmat=vector<llvec>;

#define PI 3.141592653589793
#define INTINF ((1<<30)-1)
#define LLINF 1LL<<60
#define MPRIME 1000000007
#define MPRIME9 998244353
#define MMPRIME (1ll<<61)-1

#define len length()
#define pushb push_back
#define fi first
#define se second

#define setpr fixed<<setprecision(15)
#define all(name) name.begin(),name.end()
#define rall(name) name.rbegin(),name.rend()
#define gsort(vbeg,vend) sort(vbeg,vend,greater<>())

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

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

template<class T>
inline void init(T& v) {
	for(auto &a: v) cin>>a;
}
template<class T, class U>
inline void init(vector<pair<T,U>>& v) {
	for(auto &a: v) cin>>a.first>>a.second;
}
template<class T, class N>
inline void init(T& v, N n) {
	v.resize(n);
	for(auto &a: v) cin>>a;
}
template<class T, class U, class N>
inline void init(vector<pair<T,U>>& v, N n) {
	v.resize(n);
	for(auto &a: v) cin>>a.first>>a.second;
}

inline void out() {
	cout<<endl;
}
template<class T, class... U>
inline void out(T a, U... alist) {
	cout<<a<<" ";
	out(forward<U>(alist)...);
}

template<class N>
void resiz(N n) {
	//empty
}
template<class N, class T, class... U>
void resiz(N n, T&& hd, U&&... tl) {
	hd.resize(n);
	resiz(n,forward<U>(tl)...);
}

ll binpow(ll a, ll ex, ll p) {
	ll result=1;
	while(ex>0) {
		if(ex&1) result=result*a%p;
		ex>>=1;
		a=a*a%p;
	}
	return result;
}

ll nCr(ll n, ll r) {
	if (n == r) { return 1; }
	if (r > n) { return 0; }

	if (r > n / 2) { r = n - r; }

	if (n == 0) { return 0; }
	if (r == 0) { return 1; }
	if (r == 1) { return n; }

	double result = 1;
	for (double i = 1; i <= r; i++) {
		result *= (n - i + 1) / i;
	}

	return (ll)result;
}



int N;
intvec A;
ll res;

void input() {
	cin>>N;
	init(A,N);
}

void solve() {
	int r=0;
	int sum=0;
	for(int l=0; l<N; l++) {
		while(r<N && sum+A[r]==(sum^A[r])) {
			sum+=A[r];
			r++;
		}
		res+=r-l;
		sum-=A[l];
	}
	cout<<res<<endl;
}

int main() {
	int t=1;
	while(t) {
		input();
		solve();
		t--;
	}
}


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

int main(){
	int a,b;
	cin >>a>>b;
	if(a>b){
	    cout<<"a > b" <<endl;
	}else if(a==b){
		cout<<"a == b"<<endl;
	}else{
		cout<<"a < b"<<endl;
	}
    return 0;
}

Measured memory_bytes: 3076
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
using namespace __gnu_pbds; 
using namespace std;
#define ull         unsigned long long int
#define ll          long long int
#define pb          push_back
#define pii         pair<int,int>
#define F           first
#define S           second
#define vi          vector<int>
#define vli          vector<ll>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define M_PI        3.14159265358979323846
#define mp          make_pair
#define sz(x)       (int)x.size()
#define matrix      vector<vector<ll>>
#define forn(i,a,b)  for(int i=a;i<b;i++)
#define eps 0.0000000001
#define all(a)      (a).begin(),(a).end()
#define ordered_set     tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update> 
 
const long long INF = (long long) 1e11+1;
const long long mod = (long long) 998244353;
const long long hell = (long long) 1000000007;

ll power(ll x,ll y){
  ll res=1;
  while(y>0){
    if(y%2) res=(x*res);
    x=(x*x);    
    y=y/2;
  }
  
  return res%hell;
}
 
ll modinv(ll x){
  return power(x,hell-2);
}

ll gcd(ll a,ll b){
    while( b != 0)
	{
		ll  t = b;
		b= a %t;
		a = t;
	}
	return a;
}    
    
void fastIO(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}

void solve(){
    int ang;
    cin>>ang;
    int g=gcd(ang,360);
    cout<<(360)/g;
}    

int main(){
   fastIO();
   int test;
   //cin>>test;
   test=1;    
    
   while(test--)
   solve();
}

Measured memory_bytes: 3644
//INCLUDE
//------------------------------------------
#include <bits/stdc++.h>
//DEFINE
//------------------------------------------
#define ll long long
#define ld long double
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
//CONST
//------------------------------------------
#define INF 1010000000000000017LL
#define MOD 1000000007LL
#define EPS 1e-12
#define PI 3.14159265358979323846
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
//-----------------------------------------
#define dcml(n) fixed<<setprecision(n)
using namespace std;
int main(void){
    ll L,R;cin>>L>>R;
    ll ans=INF;
    ll cnti=0,cntj=0;
    FOR(i,L,R+1){
        if(cnti>=2019)break;
        ll n1=i%2019;
        cntj=0;
        FOR(j,i+1,R+1){
            if(cntj>=2019)break;
            ll n2=j%2019;
            //cout<<n1<<" "<<n2<<" ";
            ans=min(ans,n1*n2%2019);cntj++;
        }
        cnti++;
    }
    cout<<ans<<"\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ll mod = 1e9 + 7;
//const ll mod = 998244353;
#define REP(i,n) for(int i=0;i<(int)n;++i)
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
string num2bit(ll num, ll len){
    string bit = "";
    REP(i, len){
    bit += char('0'+(num>>i & 1));
    }
    return bit;
}

vector< int64_t > divisor(int64_t n) {
  vector< int64_t > ret;
  for(int64_t i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

ll f(ll x, ll y){
    return x*x*x*x*x - y*y*y*y*y;
}

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

    ll X;
    cin >> X;

    auto div = divisor(X);

    ll B = 0;
    while(1){
        for(auto d: div){
            ll p = f(B+d, B);
            ll q = f(-B+d, -B);
            if(p==X){
                cout << B+d << " " << B << endl;
                return 0;
            }
            if(q==X){
                cout << -B+d << " " << -B << endl;
                return 0;
            }
        }
        B++;
    }

    return 0;
}

Measured memory_bytes: 3652
N = int(input())
A = list(map(int, input().split()))

A = [0]+A+[0]
total = 0
for i in range(N+1):
    total += abs(A[i]-A[i+1])

ans = []
for i in range(1,N+1):
    if A[i-1]<=A[i]:
        if A[i]<=A[i+1]:
            ans.append(total)
        else:
            minus = (A[i]-max(A[i-1],A[i+1]))*2
            ans.append(total-minus)
    else:
        if A[i]>=A[i+1]:
            ans.append(total)
        else:
            minus = (min(A[i-1],A[i+1])-A[i])*2
            ans.append(total-minus)
print(*ans, sep='\n')

Measured memory_bytes: 14172
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
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字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
    詰まった時に、別の分野の問題として考え直す（これdpでは？、グラフとしてみればいいのでは？）
    多くの問題はパターンマッチだが、パターンに落とし込むまでが難しく、そのための訓練としてわからない問題をあれこれ色々な角度から考察してみるのではないか
    cin.tie(0);
    ios::sync_with_stdio(false);<- これら、printfとかと併用しない方が良さそう

*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

/* <--------------------------------------------> */


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

    string s, t; cin >> s >> t;
    int n=s.size(), m=t.size();
    vector<vector<int>> dp(n+5, vector<int>(m+5, 0));
    rep(i, n) rep(j, m){
        if(s[i]==t[j]) dp[i+1][j+1] = dp[i][j]+1;
        else dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j]);
    }

    string ans="";
    int i=n, j=m;
    while(i>0 && j>0){
        if(dp[i-1][j] < dp[i][j] && dp[i][j-1] < dp[i][j]) { ans=s[i-1]+ans; --i; --j; }
        else if(dp[i-1][j] == dp[i][j]) --i;
        else if(dp[i][j-1] == dp[i][j]) --j;
    }
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 35712
N = int(input())
if N < 10:
  print(N)
elif N < 100:
  print(9)
elif N < 1000:
  print(9 + N - 99)
elif N < 10000:
  print(909)
elif N < 100000:
  print(909 + N - 9999)
else:
  print(90909)

Measured memory_bytes: 2940
// E - Max GCD
#include <bits/stdc++.h>

using namespace std;

int main(int argc, char *argv[])
{
	ios::sync_with_stdio(false); cin.tie(0);

	long long n, k, s = 0;
	cin >> n >> k;
	vector<long long> a(n);
	for (int i = 0; i < n; i++) cin >> a[i], s += a[i];

	vector<long long> d;
	for (long long x = 2; x * x <= s; x++)
		if (s % x == 0) {
			d.push_back(x);
			if (x != s / x) d.push_back(s / x);
		}
	d.push_back(s);
	sort(d.begin(), d.end(), greater<long long>());

	long long ans = 1;
	for (int i = 0; i < d.size(); i++) {
		long long x = d[i];
		vector<int> v;
		for (int j = 0; j < n; j++) v.push_back(a[j] % x);
		sort(v.begin(), v.end());
		long long d = 0, r = 0;
		for (int ii = 0, jj = n - 1; ii <= jj; )
			if (d >= 0) {
				d -= v[ii];
				r += v[ii];
				ii++;
			} else {
				d += x - v[jj];
				r += x - v[jj];
				jj--;
			}
		if (r <= k * 2 && d == 0) {
			ans = x;
			break;
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstring>
#include <cstdio>

using namespace std ;

char s[100] ;

int main ()
{
	gets(s+1);
	if ( s[1]=='M' ) puts("6");
	else if ( s[1]=='W' ) puts("4");
	else if ( s[1]=='F' ) puts("2");
	else if ( s[1]=='S' ) puts(s[2]=='U'?"7":"1");
	else if ( s[1]=='T' ) puts(s[2]=='U'?"5":"3");
	return 0 ;
}


Measured memory_bytes: 128
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
import numpy as np

n = ii()
A = iil()

l = np.cumsum(A)
su = l[-1]
#print(l)
ans = 1e18
for i in range(n-1):
    x = l[i]
    y = su - x
    ans = min(ans,abs(x-y))

print(ans)

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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { std::cout << #a << " = " << a << "\n"; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T, class V> istream& operator>> (istream& ist, pair<T, V>& p) { return ist >> p.first >> p.second; }
template<class T> ostream& operator<< (ostream& ost, pair<T, T>& p) { return ost << p.first << ", " << p.second; }
template<class T> istream& operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) ist >> e; return ist; }

typedef long long ll;
int const inf = INT_MAX / 2;

int main() {
  int n; cin >> n;
  string a, b; cin >> a >> b;
  rep(i, n) {
    cout << a[i] << b[i];
  }
  cout << endl;
}


Measured memory_bytes: 256
use std::io::*;

const MAX: usize = 7368792;

fn make_prime_list(m: usize) -> Vec<usize> {
    let mut sieve = vec![true;MAX];
    let mut vs: Vec<usize> = Vec::with_capacity(500010);
    for index in m..MAX {
        if sieve[index] {
            vs.push(index);
            if vs.len() >= 500001 {
                break;
            }
            let mut k = index * 2;
            while k < MAX {
                sieve[k] = false;
                k+=index;
            }
        }
    }
    vs
}

fn solve(m: usize, n: usize) -> usize {
    let vs = make_prime_list(m);
    vs[n]
}

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();

    loop {
        let m:usize=iter.next().unwrap().parse().unwrap();
        let n:usize=iter.next().unwrap().parse().unwrap();
        if n == 0 && m == 0 {
            break;
        }
        println!("{}", solve(m, n));
    }
}



Measured memory_bytes: 17308
#include<bits/stdc++.h>
using namespace std;
const double pi = acos(-1);
const int N = 100 + 5;

int main(){
	int a,b,h,m;
	cin >> a >> b >> h >> m;
	double ang = fabs(30.00 * h - 5.50 * m) * pi / 180.00;
	double ans = sqrt(a*a*1.00 + b*b*1.00 - 2.00*a*b*cos(ang));
	printf("%.20lf\n",ans);
    return 0;
} 

Measured memory_bytes: 4092
H,W,K=map(int,input().split())#高さ,縦線,Kへたどり着く
mod=10**9+7

from collections import defaultdict
NOW = defaultdict(int)

VAR=dict()

VAR[-2]=1
VAR[-1]=1
VAR[0]=1
VAR[1]=1
VAR[2]=2

for i in range(3,W+1):
    VAR[i]=VAR[i-1]+VAR[i-2]

NOW[1]=1
#print(NOW)
for i in range(H):
    NEXT = defaultdict(int)

    for j in NOW:
        if j<=0 or j>W:
            continue
        x=NOW[j]

        NEXT[j-1]=(NEXT[j-1]+x*VAR[j-2]*VAR[W-j])%mod
        NEXT[j]=(NEXT[j]+x*VAR[j-1]*VAR[W-j])%mod
        NEXT[j+1]=(NEXT[j+1]+x*VAR[j-1]*VAR[W-j-1])%mod

    NOW=NEXT

    #print(NOW)

print(NOW[K]%mod)

Measured memory_bytes: 3316
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	final int MOD = 1000000007;
	final int MAX = Integer.MAX_VALUE;
	final long LMAX = Long.MAX_VALUE;


	void doIt() {
		int N = sc.nextInt();
		int K = sc.nextInt();
		int h[] = new int[N];
		for(int i = 0; i < N; i++) 
			h[i] = sc.nextInt();
		int dp[] = new int[N];
		Arrays.fill(dp, (int)1e9);
		dp[0] = 0;
		for(int i = 0; i < N; i++) {
			for(int j = 1; j <= K; j++)
				if(i + j < N) 
					dp[i + j] = Math.min(dp[i + j], dp[i] + diff(h[i], h[i + j]));

		}
		System.out.println(dp[N - 1]);
	}
	int diff(int a, int b) {
		return Math.abs(a - b);
	}




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


Measured memory_bytes: 50724
#include <stdio.h>

#define MAX(a, b) ((a) > (b) ? (a) : (b))

typedef struct {
  int parent;
  int left;
  int right;
} Node;

Node node[26];

int getSibling(int id) {
  int p = node[id].parent;
  if (p == -1) return -1;

  return node[p].left == id ? node[p].right : node[p].left;
}

int getDegree(int id) {
  int cnt = 0;

  if (node[id].right != -1) cnt++;
  if (node[id].left != -1) cnt++;

  return cnt;
}

int getHeight(int id, int h) {
  int left;
  int right;
  if (id == -1) {
    return h - 1;
  }

  left = node[id].left;
  right = node[id].right;
  h += 1;
  return MAX(getHeight(left, h), getHeight(right, h));
}

int getDepth(int id, int d) {
  if (node[id].parent != -1) {
    return getDepth(node[id].parent, ++d);
  }
  else {
    return d;
  }
}

char *getType(int id) {
  if (node[id].parent == -1) {
    return "root";
  }
  else if (node[id].left == -1 && node[id].right == -1) {
    return "leaf";
  }
  else {
    return "internal node";
  }
}

void preOrder(int id) {
    if (id == -1) {
        return;
    }
    printf(" %d", id);
    preOrder(node[id].left);
    preOrder(node[id].right);
}

void inOrder(int id) {
    if (id == -1) {
        return;
    }
    inOrder(node[id].left);
    printf(" %d", id);
    inOrder(node[id].right);
}

void postOrder(int id) {
    if (id == -1) {
        return;
    }
    postOrder(node[id].left);
    postOrder(node[id].right);
    printf(" %d", id);
}

int main() {
  int n, id, left, right;
  int i, root;

  scanf("%d", &n);

  for (i = 0; i < n; i++) {
    node[i].parent = -1;
  }

  for (i = 0; i < n; i++) {
    scanf("%d %d %d", &id, &left, &right);
    node[id].left = left;
    node[id].right = right;
    if (left != -1) {
      node[left].parent = id;
    }
    if (right != -1) {
      node[right].parent = id;
    }
  }

  for (i = 0; i < n; i++) {
    if (node[i].parent == -1){
        root = i;
        break;
    }
  }

    printf("Preorder\n");
    preOrder(root);

    printf("\nInorder\n");
    inOrder(root);

    printf("\nPostorder\n");
    postOrder(root);
    printf("\n");



  return 0;
}



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

int main()
{
	int N, K;
	cin >> N >> K;

	int *h = new int[N];
	int *r = new int[N];

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

	for(int n=0; n<N; n++){
		for(int k=0; k<K; k++){
			if(n-k-1 < 0)continue;
			int res = abs(h[n] - h[n-k-1]) + r[n-k-1];
			if(k==0 || res < r[n]){
				r[n] = res;
			}
		}
	}

	cout << r[N-1] << endl;

	return 0;
}


Measured memory_bytes: 1152
#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<LL,LL> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;



int main(){
    LL n;cin >> n;
    vector<vector<int>> a(n,vector<int> (n));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n-1; j++) {
            cin >> a[i][j];
            a[i][j]--;
        }
    }
    vector<int> c(n,0);
    vector<int> x(n,0);
    auto q = clock();
    for (int i = 1; i <= n*(n-1)/2+1; i++) {
        if(clock()-q >= 1000000){
            cout << n*(n-1)/2 << endl;
            return 0;
        }
        bool f = false;
        bool t = false;
        for (int j = 0; j < n; j++) {
            if(c[j]==n-1) continue;
            t=true;
            int en = a[j][c[j]];
            if(x[j]==i||x[en]==i) continue;
            if(c[en]==n-1) continue;
            if(j==a[en][c[en]]){
                c[j]++;
                c[en]++;
                x[j]=i;
                x[en]=i;
                f = true;
            }
        }
        if(!t){
            cout << i-1 << endl;
            return 0;
        }
        if(!f){
            puts("-1");
            return 0;
        }
    }
    return 0;
}



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

int main(){
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  if (A + B > C + D){
    cout << "Left" << endl;
  }
  else if (A + B < C + D){
    cout << "Right" << endl;
  }
  else {
    cout << "Balanced" << endl;
  }
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)
typedef long long ll;

using namespace std;

template <typename T> void output(T, int);
int gcd(int a, int b);

int main() {
    // source
    string s;
    cin >> s;
    int count = 0;
    repd(i, 1, s.size()) {
        if (s[i - 1] != s[i]) {
            count++;
        }
    }

    cout << count << endl;
    return 0;
}

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

template <typename T> T min(T a, T b) {

    if (a < b) {
        return a;
    } else {
        return b;
    }
}

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


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

int main()
{
	int n, a[100], i, sum = 0, num = 0;
	double ave, min;

	scanf("%d", &n);

	for (i = 0;i < n;i++) {
		scanf("%d", &a[i]);
	}

	for (i = 0;i < n;i++) {
		sum += a[i];
	}
	ave = (double)sum / n;
	min = fabs(a[0] - ave);
	
	for (i = 0;i < n;i++) {
		if (min > fabs(a[i] - ave)) {
			min = fabs(a[i] - ave);
			num = i;
		}
	}

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

	return 0;
}

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

int main(){
  int n;
  int a, b, c;
  ll ans = 0;

  cin >> n;
  for(a=1;a<n;a++){
    for(b=1;a*b<n;b++){
      c = n - a*b;
      if(a*b+c==n)ans++;
    }
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 3624
import java.util.*;

class Main{
        public static void main(String[] args){
                Scanner sc = new Scanner(System.in);
                int[][][] ink = new int[3][][];
                ink[0] = new int[][]{{0,1,0},{1,1,1},{0,1,0}};
                ink[1] = new int[3][3];
                for(int i = 0; i < 3; i++){
                        for(int j = 0; j < 3; j++){
                                ink[1][i][j] = 1;
                        }
                }
                ink[2] = new int[5][5];
                int[][] tmp = ink[2];
                for(int i = 1; i < 4;i++){
                        for(int j = 1; j < 4; j++){
                                tmp[i][j] = 1;
                        }
                }
                tmp[0][2] = 1;
                tmp[2][0] = 1;
                tmp[2][4] = 1;
                tmp[4][2] = 1;
                int[][] paper = new int[14][14];
                while(sc.hasNext()){
                        String[] s = sc.nextLine().split(",");
                        int x = Integer.parseInt(s[0])+2;
                        int y = Integer.parseInt(s[1])+2;
                        int size = Integer.parseInt(s[2])-1;
                        drop(paper, x, y, ink[size]);
                }
                sc.close();
                int white = 0;
                int max = 0;
                for(int i = 2; i < 12; i++){
                        for(int j = 2; j < 12; j++){
                                if(paper[i][j] == 0){
                                        white++;
                                }else{
                                        max = Math.max(paper[i][j], max);
                                }
                        }
                }
                System.out.println(white+"\n"+max);
        }
        static void drop(int[][] paper, int x, int y, int[][] ink){
                x -= ink.length/2;
                y -= ink.length/2;
                for(int i = 0; i < ink.length; i++){
                        for(int j = 0; j < ink.length; j++){
                                paper[i+x][j+y] += ink[i][j];
                        }
                }
        }
}

Measured memory_bytes: 11000
#include <stdio.h>
#define Q 10
int main(void) {
	int i,j;
	for(i=1;i<Q;i++)
	{
		for(j=1;j<Q;j++)
		{
			printf("%dx%d=%d\n",i,j,i*j);
		}
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 524
#include <iostream>
#include <cstdio>
#include <string>
#include <string.h>
#include <queue>
#include <math.h>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <bitset>
#include <list>
#include <ctype.h>
#include <cassert>
#include <stack>
#include <fstream>
#include <unordered_map>
#include <unordered_set>
#include <ctime>
#include <functional>
#include <ctime>
#include <limits>
#include <tuple>
#include <complex>
#include <numeric>

using namespace std;

#define snd second
#define fst first
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define ld long double
#define pb push_back
#define left _left
#define right _right

const ld pi = acos(-1.0l);

template<typename T>
T abs(T x) {
    return x > 0 ? x : -x;
}

template<typename T>
T sqr(T x) {
    return x * x;
}

template<typename T>
bool chmin(T &x, T y) {
    if (x > y) {
        x = y;
        return true;
    }
    return false;
}

template<typename T>
bool chmax(T &x, T y) {
    if (x < y) {
        x = y;
        return true;
    }
    return false;
}

template<typename U, typename V>
ostream &operator<<(ostream &s, const pair<U, V> &x) {
    s << "(" << x.fst << ", " << x.snd << ")";
    return s;
}

template<typename U>
ostream &operator<<(ostream &s, const vector<U> &x) {
    s << "[";
    bool was = false;
    for (auto it : x) {
        if (was) {
            s << ", ";
        }
        was = true;
        s << it;
    }
    s << "]";
    return s;
}

template<typename U>
ostream &operator<<(ostream &s, const set<U> &x) {
    s << "{";
    bool was = false;
    for (auto it : x) {
        if (was) {
            s << ", ";
        }
        was = true;
        s << it;
    }
    s << "}";
    return s;
}

template<int sz>
ostream operator<<(ostream &s, const bitset<sz> &x) {
    for (int i = 0; i < sz; i++) {
        s << x[i];
    }
    return s;
}


//-----------------------------------------------------------------------------


int main() {
    srand(time(NULL));

    retry:
#ifdef LOCAL
    // gen();

    freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);
#else
    //freopen(".in", "r", stdin);
    //freopen(".out", "w", stdout);
#endif

    string a;
    string s;
    cin >> s;
    for (char c : s) {
        if (a.empty() || !(a.back() == 'S' && c == 'T')) {
            a.pb(c);
        } else {
            a.pop_back();
        }
    }

    cout << a.size() << endl;


    return 0;
}

Measured memory_bytes: 776
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int main()
{
    long int n,h,m=0,i;
    scanf("%ld %ld",&h,&n);
    long int a[n];
    for(i=0;i<n;i++)
    {
        scanf("%ld",&a[i]);
        m+=a[i];
    }
    if(m>=h)
        printf("Yes");
    else
        printf("No");
    return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using V = vector<ll>;
#define _GLIBCXX_DEBUG
#define rep(i, a, b) for(int i = a; i < b; i++)
#define ALL(v) v.begin(), v.end()


int main(){
    int n,ans=0; cin>>n;
    V v(n),c(n);
    rep(i,0,n) cin>>v[i];
    rep(i,0,n) cin>>c[i];
    rep(i,0,n){
        int dif=v[i]-c[i];
        if(dif>0) ans+=dif;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using VI = vector<int>;

int main() {
#ifdef LOCAL_EXEC
//	freopen("sample.in", "r", stdin);
//	freopen("sample.out", "w", stdout);
#else
  ios_base::sync_with_stdio(false); cin.tie(NULL);
#endif

  int n, W; cin >> n >> W;
  vector<ll> dp(W + 1);
  for (int i = 1; i <= n; i++) {
    int w, v; cin >> w >> v;
    for (int j = W; j >= w; j--) {
      dp[j] = max(dp[j], v + dp[j - w]);
    }
  }
  cout << dp[W] << endl;

  return 0;
}


Measured memory_bytes: 1024
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr long double EPS = 1e-8;

long long int N, M, K, L, R, H, W;
//int N, M, K, L, R, H, W;


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

	cin >> H >> W >> N >> M >> K;
	vector<long long int>a(N);
	vector<long long int>b(M);
	vector<long long int>c(K);
	for (auto &i : a)cin >> i;
	for (auto &i : b)cin >> i;
	for (auto &i : c)cin >> i;
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	sort(c.begin(), c.end());
	reverse(a.begin(), a.end());
	reverse(b.begin(), b.end());
	reverse(c.begin(), c.end());
	while (a.size() > H)a.pop_back();
	while (b.size() > W)b.pop_back();
	vector<long long int>d;
	for (auto i : a)d.push_back(i);
	for (auto i : b)d.push_back(i);
	sort(d.begin(), d.end());
	reverse(d.begin(), d.end());
	long long int ret = accumulate(d.begin(), d.end(), 0LL);
	long long int ans = ret;
	long long int add = 0;
	for (int i = 0; i < min(d.size(), c.size()); i++) {
		add += c[i];
		add -= d[d.size() - 1 - i];
		ans = max(ans, ret + add);
	}
	cout << ans << endl;
}


Measured memory_bytes: 4852
var input: string = require('fs').readFileSync('/dev/stdin', 'utf8');
var inputLines: string[] = input.trim().split("\n");
var parts = inputLines[0].split(" ");

var vowels = ["a", "i", "u", "e", "o"];
var c = parts[0];
console.log(vowels.some(vowel => vowel == c) ? "vowel" : "consonant");

Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n;
	cin>>n;
	ll sum=0;
	for(ll i=sqrt(n);i>=0;i--){
		if(n%i==0){
			sum=n/i;
			break;
		}
	}
	ll ans=0;
	while(sum!=0){
		ans++;
		sum/=10;
	}
	cout <<ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int k,N,M,array[35]={},a;
    scanf("%d %d",&N,&M);
    for(int i=0;i<N;i++){
        scanf("%d",&k);
        for(int j=1;j<=k;j++){
            scanf("%d",&a);
            array[a]++;
        }
    }
    int count=0;
    for(int i=0;i<=M;i++){
        if(array[i]==N) count++; 
    }
    printf("%d\n",count);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstdint>
#include <cmath>
#include <numeric>
#include <functional>
#include <queue>
#include <stack>

using namespace std;

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

  cout << (int)floor((t + 0.5)/a) * b << endl;

  return 0;
}


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

using namespace std;

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

    int n;
    cin >> n;
    double ans = 0;
    for (int i = 0; i < n; i++) {
        double a;
        cin >> a;
        ans += 1.0 / a;
    }
    printf("%.10f\n", 1 / ans);
}

Measured memory_bytes: 256
import sys
import os

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    W, H, x, y = il()
    print((W*H)/2, 1 if W/2 == x and H/2 == y else 0)


if __name__ == '__main__':
    main()


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

using namespace std;

typedef long long ll;
typedef long double ld;

const int N=10000+5;
const int K=100+5;
const int MOD=(int)1e9+7;

int add(int a,int b)
{
    a+=b;
    if(a>=MOD)
    {
        a-=MOD;
    }
    if(a<0)
    {
        a+=MOD;
    }
    return a;
}

int mul(int a,int b)
{
    return a*(long long)b%MOD;
}

int dp[N][K];
int dp2[N][K];
int n;
string s;
int k;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin>>s>>k;
    n=s.size();
    s="0"+s;
    for(int i=1;i<=9;i++)
    {
        dp[1][i%k]++;
    }
    for(int i=0;i<=9;i++)
    {
        dp2[1][i%k]++;
    }
    dp2[0][0]=1;
    for(int l=2;l<=n;l++)
    {
        for(int ant=0;ant<k;ant++)
        {
            if(dp[l-1][ant]==0) continue;
            for(int put=0;put<=9;put++)
            {
                int now=(ant+put)%k;
                dp[l][now]=add(dp[l][now],dp[l-1][ant]);
            }
        }
    }
    for(int l=2;l<=n;l++)
    {
        for(int ant=0;ant<k;ant++)
        {
            if(dp2[l-1][ant]==0) continue;
            for(int put=0;put<=9;put++)
            {
                int now=(ant+put)%k;
                dp2[l][now]=add(dp2[l][now],dp2[l-1][ant]);
            }
        }
    }
    int ans=0;
    for(int l=1;l<n;l++)
    {
   //     cout<<l<<" : "<<dp[l][0]<<"\n";
        ans=add(ans,dp[l][0]);
    }
    int cur=0;
    for(int p=0;p<=n;p++)
    {
        cur=add(cur,s[p]-'0');
        if(p==n)
        {
            if(cur%k==0)
            {
                ans=add(ans,1);
            }
            continue;
        }
        int delta=ans;
        int st;
        if(p==0) st=1;
        else st=0;
        int dr=s[p+1]-'0'-1;
      ///  cout<<st<<" "<<dr<<"\n";
        for(int now=st;now<=dr;now++)
        {
            cur+=now;
            int inv=-cur;
            inv%=k; inv+=k; inv%=k;
            ans=add(ans,dp2[n-p-1][inv]);
      ///      cout<<p<<" ::: "<<cur<<" , "<<n-p<<" "<<inv<<"\t\t\t\t "<<dp2[n-p][inv]<<"\n";
            cur-=now;
        }
     ///   cout<<p<<" "<<ans-delta<<"\n";
    }
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 8448
#define int long long

struct meshi { int time, umami; } meshi[3000];
n, t, dp[3010][3011];

comparator (const void *a, const void *b) {
    return ((struct meshi*)a)->time - ((struct meshi*)b)->time;
}

main ()
{
    scanf("%lld %lld", &n, &t);

    for(int i = 0; i < n; i++) scanf("%lld %lld", &meshi[i].time, &meshi[i].umami);
    qsort(meshi, n, sizeof(struct meshi), comparator);

    for(int tt = 0; tt <= t; tt++)
    {
        for (int nn = 0; nn < n; nn++)
        {
            int taberu = 0, tabenai = 0;

            if (tt >= (tt == t ? 1 : meshi[nn].time))
            {
                taberu += meshi[nn].umami;
                if (nn > 0) taberu += dp[tt - (tt == t ? 1 : meshi[nn].time)][nn - 1];
            }

            if (nn > 0)
            {
                tabenai += dp[tt][nn - 1];
            }

            dp[tt][nn] = taberu > tabenai ? taberu : tabenai;
        }
    }

    printf("%lld\n", dp[t][n - 1]);
}


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

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

    for(int i=1; i<=n; i++){
        x = i;
        if(x%3==0) cout << ' ' << i << flush;
        else{
	    while(x>0){
	        if(x%10==3){
		    cout << ' ' << i << flush;
		    break;
		}
		x /= 10;
	    }
	}
	if(i==n) cout << endl;
    }
}

Measured memory_bytes: 3072
#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[3][3];
    int card[3][3];
    rep(i,3) {
        rep(j,3) {
            cin >> a[i][j];
            card[i][j] = 0;
        }
    }
    int n;
    cin >> n;
    rep(i,n) {
        int b;
        cin >> b;
        rep(i,3) rep(j,3) {
            if (b == a[i][j]) {
                card[i][j] = 1;
            }
        }
    }
    bool ok = false;
    rep(i,3) {
        int row = 0;
        rep(j,3) { 
            row += card[i][j];
        }
        if (row == 3) {
            ok = true;
        }
    }
    rep(j,3) {
        int column = 0;
        rep(i,3) { 
            column += card[i][j];
        }
        if (column == 3) {
            ok = true;
        }
    }
    if (card[0][2] + card[1][1] + card[2][0] == 3) ok = true;
    if (card[0][0] + card[1][1] + card[2][2] == 3) ok = true;
    if (ok) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

typedef long long ll;

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

int main() {
    ll a, b;
    cin >> a >> b;
    return cout << a * b / gcd(a, b) << "\n", 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int P,Q,R;
int Not(int x){
    if(x==0) return 2;
    else if(x==1) return 1;
    else return 0;
}
int seki(int x,int y){
    if(x==0||y==0) return 0;
    else if(x==1||y==1) return 1;
    else return 2;
}
int wa(int x,int y){
    if(x==2||y==2) return 2;
    else if(x==1||y==1) return 1;
    else return 0;
}
int eval_pos;                   // 現在処理中の論理式の位置
int eval(char *str){
    char token;                 // これから処理する文字
    unsigned short v1, v2;                 // 引数の値
    token = str[eval_pos++];    // １文字取得
    switch(token){
        case '0':                   // 定数 0
            return 0;
        case '1':                   // 定数 1
            return 1;
        case '2':                   // 定数 2
            return 2;
        case 'P':
            return P;
        case 'Q':
            return Q;
        case 'R':
            return R;
        case '-':                   // 論理否定
            v1 = eval(str);         // 引数の値を求める
            return Not(v1);
        case '(':                   // 左括弧開始
            v1 = eval(str);                 // 第一引数の値を求める
            if(str[eval_pos++]=='+'){       // EXOR演算
                v2 = eval(str);             // 第二引数の値を求める
                if(str[eval_pos++] != ')')
                    fprintf(stderr, "missing ) for ^\n");   // 文法誤り
                return wa(v1,v2);             // EXOR演算を適用
            }
            else {                          // 論理積演算
                v2 = eval(str);             // 第二引数の値を求める
                if(str[eval_pos++] != ')')
                    fprintf(stderr, "missing ) for ^\n");   // 文法誤り
                return seki(v1,v2);             // 論理積演算を適用
            }
        default:
            break;
    }
    return 0;
}
int value(char *str){
    eval_pos = 0;
    return eval(str);
}
int main(void){
    while(1){
        char buff[90];
        fgets(buff,85,stdin);
        if(buff[0]=='.') break;
        int count=0;
        for(int i=0;i<=2;i++){
            for(int j=0;j<=2;j++){
                for(int k=0;k<=2;k++){
                    P=i,Q=j,R=k;
                    if(value(buff)==2) count++;
                }
            }
        }
        printf("%d\n",count);
    }
}



Measured memory_bytes: 2028
#include<bits/stdc++.h>
#include <math.h>
#include <map>
#include <unordered_map>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define pb(s) push_back(s)
#define CST(x) cout<<fixed<<setprecision(x)
#define ci(x) cin >>x
#define co(x) cout<<x<<endl
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vvpl=vector<vector<pl>>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};

  


int main() {
  ll A;
  ll B;
  cin >>A>>B;
  
  cout<<A*B<<endl;
}



Measured memory_bytes: 3592
#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(){
    string S, T;
    cin >> S;
    cin >> T;
    int ans = T.size();
    for(int i=0; i<=S.size()-T.size(); i++ ){
        string sub = S.substr(i,T.size());
        int mismatch = 0;
        rep(j,T.size()){
            if( sub[j] != T[j] ) ++mismatch;
        }
        ans = min(ans,mismatch);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3620
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException{

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		while(true){
			String str = br.readLine();
			if(str == null || str.length() == 0){
				break;
			}
			String[] str1Ary = str.split(" ");
			int value = Integer.parseInt(str1Ary[0]) + Integer.parseInt(str1Ary[1]);
			int keta = 1;
			while(true){
				if(value >= 10){
					value /= 10;
					keta++;
				}else{
					break;
				}
			}
			System.out.println(keta);
		}
	}
}

Measured memory_bytes: 17000
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		
		int x1 = (int)(n / 1.08);
		int n1 = (int)(x1 * 1.08);
		int x2 = x1 + 1;
		int n2 = (int)(x2 * 1.08);
		
		if( n == n1 ){
			System.out.println(x1);
		} else if( n == n2 ){
			System.out.println(x2);
		} else{
			System.out.println(":(");
		}
	}
}

Measured memory_bytes: 22868