akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
using namespace std;
#define rep(i,a,n) for(llint i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define sort(s) sort(s.begin(),s.end())
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<int>>
constexpr auto mod = 1000000007;


//2のn乗を求めるよ！！！
int ni(int n) {
	if (n == 0)return 1;
	int x = ni(n / 2);
	x *= x;
	if (n % 2 == 1)x *= 2;
	return x;
}

//フィボナッチ数列のx番目を求めるよ！
llint f(int x, vector<llint> &s) {
	if (x == 0)return 0;
	if (x == 1)return 1;
	if (s[x] != 0)return s[x];
	return  s[x] = f(x - 1, s) + f(x - 2, s);
	
}

//aとｂの最大公約数を求めるよ！
llint gcd(llint a, llint b) {
	if (a < b)swap(a, b);
	if (b == 0)return a;
	return gcd(b, a % b);
}



// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

// mod. m での a の逆元 a^{-1} を計算するよ！
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}


//aCbをmod.mで割った余りを求める
ll int c(ll int a, ll int b, ll int m) {
	ll int ans = 1;
	for (ll int i = 0; i < b; i++) {
		ans *= a - i;
		ans %= m;
	}
	for (ll int i = 1; i <= b; i++) {
		ans *= modinv(i, m);
		ans %= m;
	}
	return ans;
}

//m進数のn桁を全列挙やで
void dfs(int m, int n) {
	stack<string> st;
	st.push("");
	while (!st.empty()) {
		string now = st.top();
		st.pop();
		if (now.size() == n) {
			cout << now << endl;
		}
		else {
			for (int i = m - 1; i >= 0; i--) {
				string next = now + to_string(i);
				st.push(next);
			}
		}
	}
}
void press(string& v) { v.erase(unique((v).begin(), (v).end()), v.end()); }

llint min(llint a, llint b) {
	if (a < b)return a;
	return b;
}

int main() {
	llint n, V = 0;
	llint W;
	llint sum = 0;
	cin >> n >> W;
	hei(llint) w(n), v(n);
	rep(i, 0, n) {
		cin >> w[i] >> v[i];
		sum += w[i];
		V += v[i];
	}
	vector<vector<llint>> dp(n+1, vector<llint>(V+1, sum));
	dp[0][0] = 0;
	rep(i, 0, n) {
		rep(j, 0, V + 1) {
			if (j-v[i] >=0)dp[i + 1][j] = min(dp[i + 1][j], dp[i][j - v[i]] + w[i]);
			dp[i + 1][j] = min(dp[i][j], dp[i + 1][j]);
		}
	}
	llint ans = 0;
	rep(i, 0, V + 1) {
		if (dp[n][i] <= W)ans = i;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 80256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define pb push_back
#define INF 0x3f3f3f3
#define LINF 0x3f3f3f3f3f3f3f
#define MAXN 2*100005
#define fim '\n'
#define ll long long
#define f first
#define s second
#define FAST cin.tie(0), cout.tie(0), ios::sync_with_stdio(0)
#define debug(x) cout << "DEBUG " << x << fim
#define debug2(x, y) cout << "DEBUG " << x << " " << y << fim
#define debug3(x, y, z) cout << "DEBUG " << x << " " << y << " " << z<< fim
#define max3(x, y, z) max(x, max(y, z))
using namespace std;
using namespace __gnu_pbds;
typedef pair<int, int> pii;
typedef pair<string, int> psi;
typedef pair<unsigned ll, pair<int, int> > piii;
typedef pair<pair<int, int>, int> piii2;
typedef tree<int,null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
    ll xd;
    cin >> xd;
    ll ans = 1000*(xd/500);
    xd -= 500*(xd/500);
    cout << ans + 5*(xd/5) << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long A = sc.nextLong();
    long B = sc.nextLong();
    long N = sc.nextLong();
    sc.close();

    long n = Long.min(N, B - 1) % B;
    long ans = n * A / B;

    System.out.println(ans);
  }
}


Measured memory_bytes: 35516
#include<iostream>
#include<math.h>

using namespace std;
#define int int64_t
signed main() {
	int X, a;
	cin >> X;
	for (int i = X; i < 1000000; i++) {
		a = 0;
		for (int j = 2; j < sqrt(i); j++) {
			if (i % j==0) {
				a++;
				break;
			}
		}
		if (a == 0) {
			cout << i;
			return 0;
		}
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<algorithm>

#define long long long

using namespace std;

long n;
long a[100001], dp[100001];

long cal(int idx) {
    if (idx >= n) return 0;
    if (dp[idx] != -1) return dp[idx];
    dp[idx] = 0;
    
    if (idx + 2 <= n) dp[idx] = min(cal(idx + 1) + abs(a[idx + 1] - a[idx]), cal(idx + 2) + abs(a[idx + 2] - a[idx]));
    else dp[idx] += abs(a[idx + 1] - a[idx]);
    return dp[idx];
}

void FastInput()
{
    ios_base::sync_with_stdio(NULL);
    cin.tie(NULL);
    cout.tie(NULL);
}

void Input()
{
    cin >> n;
    for (int i = 1; i <= n; i ++) cin >> a[i];
    for (int i = 1; i <= n; i ++)
        dp[i] = -1;
}

void Solve()
{
    cout << cal(1);
}

int main()
{
    FastInput();
    Input();
    Solve();
}

Measured memory_bytes: 3328
import math as m
# m.floor m.ceil

n = int(input())
ans = 0
for i in range(1,m.ceil(m.sqrt(n))):
    if n%i==0:
        if n//i == i+1 : break
        ans += n//i -1

if n in [1,2]: ans = 0

print(ans)


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

#define  ll long long
#define  il inline
#define INF 0x3f3f3f3f
#define pii pair<int,int>

const int mod = 1e9 + 7;
const int maxn = 1e5 + 5;
const int maxm = 2e5 + 10;
const double PI = acos(-1.0);

int n;
int a[maxn];
vector<int>b;

int main()
{
    ios::sync_with_stdio(false);cin.tie(0);
    cin >> n ;
    for(int i = 0 ; i < n; i++) cin >> a[i];
    sort(a,a+n);
    int tot = 0;
    for(int i = 0; i < n; i++ ){
        if(a[i] < 0) tot++;
        else break;
    }
    int ans = 0;
    if(tot == 0) tot = 1;
    if(tot == n){
        for(int i = 0; i < n; i++ ){
            if(i < n - 1) ans -= a[i];
            else ans += a[i];
        }
        cout << ans << endl;
        for(int i = 0 ; i < n - 1; i++){
            cout << a[n - 1] << " " << a[i] << endl;
            a[n - 1] -= a[i];
        }
        return 0;
    }
    for(int i = 0; i < n; i++ ){
        if(i < tot) ans -= a[i];
        else ans += a[i];
    }
    cout << ans << endl;
    int cur = a[0];
    for(int i = tot; i < n - 1; i++){
        cout << cur << " " << a[i] << endl;
        cur -= a[i];
    }
    int curr = a[n - 1];
    cout << curr << " " << cur << endl;
    curr -= cur;
    for(int i = 1 ; i < tot; i++){
        cout << curr << " " << a[i] << endl;
        curr -= a[i];
    }


    return 0;

}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

char s[252521];
int n;
int vec[252521];

unordered_map<int,set<int> > yo;
int dp[252521];

int main(){
  scanf("%s",s);
  n = strlen(s);
  vec[0] = 0;
  REP(i,n){
    int id = s[i]-'a';
    vec[i+1] = vec[i] ^ (1<<id);
  }
  REP(i,n+1)yo[vec[i]].insert(i);
  REP(i,n+1)dp[i] = 252521830;
  int ans = 252521830;
  dp[0] = 0;
  REP(i,n){
    int v = vec[i];
    REP(j,27){
      int w = v ^ (1<<j);
      if(j==26)w = v;
      if(w==vec[n]){
        CHMIN(ans,dp[i]+1);
        break;
      }
      if(yo.count(w)==0)continue;
      auto it = yo[w].upper_bound(i);
      if(it!=yo[w].end()){
        int to = *it;
        CHMIN(dp[to], dp[i]+1);
      }
    }
  }
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 29000
#include <stdio.h>
int main(void){
    int i,t,n,s;
    
    for(i=0;i<4;i++){
        scanf("%d %d",&t,&n);
        switch(t){
            case 1 :s=6000*n;break;
            case 2 :s=4000*n;break;
            case 3 :s=3000*n;break;
            case 4 :s=2000*n;break;
        }
        printf("%d\n",s);
    }
    return 0;
}

Measured memory_bytes: 600
function Main(input){
  var arr = input.split("\n")[0].split(" ");
  var a = parseInt(arr[0],10);
  var b = parseInt(arr[1],10);
  if(a % 2 == 0 || b % 2 == 0){
    console.log('No');
  }else {
    console.log('Yes');
  }
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <iostream>
#include<vector>
#include<algorithm>
#include <queue>
#include <string>
#include <set>
#include <bitset>
#include<iomanip>

using namespace std;
#define ff(ii,nn,mm) for(int ii=nn;ii<mm;ii++)
#define i64 int64_t
#define tos(x) to_string(x)

int main() {
	int x, y;
	cin >> x >> y;
	int a[10][10];
	ff(i, 0, 10) {
		ff(j, 0, 10) {
			cin >> a[i][j];
		}
	}
	ff(k, 0, 10) {
		ff(i, 0, 10) {
			ff(j, 0, 10) {
				a[i][j] = min(a[i][j], a[i][k] + a[k][j]);
			}
		}
	}
	int ans = 0;
	ff(i, 0, x) {
		ff(j, 0, y) {
			int w;
			cin >> w;
			if (w != -1)ans += a[w][1];
			else continue;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define endl "\n"
#define pb push_back
#define ll long long
#define d1(x)  cerr << #x << "--> " << x << endl
#define d2(x, y)  cerr << #x << "--> " << x << " | " << #y << "--> " << y <<endl
#define d3(x, y,z)  cerr << #x << "--> " << x << " | " << #y << "--> " << y <<" | " << #z << "--> "<< z<< endl
#define vpll vector<pair<ll,ll>>
#define F first
#define S second
#define T ll tt; cin>>tt; while(tt--)
using namespace std;
ll mode=pow(10,9)+7;
bool cmp(pair<long double, int > x, pair<long double, int> y){ return x.F<y.F && x.S<y.S; }
const ll maxn=2*1e7+10;
ll __lcm(ll a, ll b){ return (a*b)/__gcd(a,b); }
ll random(ll mn, ll mx){
	return (rand() % (mx - mn + 1)) + mn; 
}
void solve(){
	
	ll n,a,b;
	cin>>n>>a>>b;
	ll c=(a+b);
	c=n/c;
	ll ans=0;
	ans+=c*a;
	ll x=(a+b)*c;
	
	if (x==0){
		cout<<min(a, n)<<endl;
		return ;
	}
	n=n%x;
	ans+=min(a, n);
	cout<<ans<<endl;
	
	
	return;
}

int main(){ 
    
    #ifndef ONLINE_JUDGE
  		//freopen("input.txt", "r", stdin);
    #endif
    srand(time(0)); 
    
    ios::sync_with_stdio(0);
    cin.tie(0);
	
	//T{ solve(); }
	solve();
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}
int Madd(int x,int y) {return (x+y)%M;}
int Msub(int x,int y) {return (x-y+M)%M;}
int Mmul(int x,int y) {return (x*y)%M;}


signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);

  int a,b,t;
  cin>>a>>b>>t;
  cout<<b*(t/a)<<endl;


}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
#include <unordered_map>
 
#define fore(i,a,b) for(int i = a; i < (b); i++)
#define fr(i,a,b) for(int i = a - 1; i >= b; i--)
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define N 200005
#define inf 2000000000
#define MOD 1000000007
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> pr;
typedef pair<pair<int, int>, int> tup;
 
 
inline void solve()
{
    int n;
    cin >> n;
    string s,t;
    cin>>s>>t;
    for(int i=0;i<n;i++)
    {
        cout<<s[i]<<t[i];
    }
}
 
int main()
{
	fast;
#if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	solve();
}

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


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

	int max_p = 0;
	int ans = 0;
	for(int i=0;i<N;i++) {
		int p;
		cin >> p;
		max_p = max(p, max_p);
		ans += p;
	}
	ans -= max_p / 2;
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
cost = [None] * n
for i in range(n):
    cost[i] = tuple(map(int, input().split()))
cost = sorted(cost)
x = 0
for a, b in cost:
    if m <= 0:
        break
    x += a * min(b, m)
    m -= b
print(x)


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

int main() {
  int N;
  cin>>N;
  vector<int>A(N);
  for(int i=0;i<N;i++){
    cin>>A.at(i);
  }
 vector<int>B(N);
  for(int i=0;i<N;i++){
    B.at(A.at(i)-1)=i+1;
  }
  for(int i=0;i<N;i++){
    cout<<B.at(i)<<endl;
  }
}


Measured memory_bytes: 1664
#include <stdio.h>
int min(int a,int b)
{
	if(a<b)
		return a;
	return b;
}
int mod(int a,int b)
{
	if(a>b)
		return a-b;
	return b-a;
}
int main(void)
{
	int n,k;
	scanf("%d %d",&n,&k);
	int a[n];
	int ans[n];
	for (int i = 0; i < n; ++i)
	{
		scanf("%d",&a[i]);
	}

	ans[0]=0;
	ans[1]=mod(a[0],a[1]);
	for (int i = 2; i < n; ++i)
	{
		int r=ans[i-1]+mod(a[i-1],a[i]);
		for (int j = 2;j<=i&&j<=k; j++)
		{
			r=min(r,ans[i-j]+mod(a[i-j],a[i]));
		}
		ans[i]=r;
	}
	printf("%d\n",ans[n-1] );
}

Measured memory_bytes: 896
from fractions import gcd
n = int(input())
a = list(map(int, input().split()))

def lcm(a, b):
    return (a * b) // gcd(a, b)

m = a[0]
for i in range(n):
    m = lcm(m, a[i])
ans = 0
for i in range(n):
    ans += (m-1) % a[i]
print(ans)

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

int main() {
  int n;
  cin >> n;
  int A[n];
  for (int i=0; i<n; i++) {
    cin >> A[i];
  }
  vector<int> G;
  for (int h=1; ; ) {
    if (h>n) {
      break;
    }
    G.push_back(h);
    h=3*h+1;
  }
  long long cnt=0;
  for (int i=G.size()-1; i>=0; i--) {
    for (int j=G[i]; j<n; j++) {
      int v=A[j];
      int k=j-G[i];
      while (k>=0 && A[k]>v) {
        A[k+G[i]]=A[k];
        k-=G[i];
        cnt++;
      }
      A[k+G[i]]=v;
    }
  }
  printf("%d\n", G.size());
  for (int i=G.size()-1; i>=0; i--) {
    printf("%d", G[i]);
    if (i) {
      printf(" ");
    }
  }
  printf("\n");
  printf("%lld\n", cnt);
  for (int i=0; i<n; i++) {
    printf("%d\n",A[i]);
  }
  return 0;
}

Measured memory_bytes: 7096
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;
 
int main() {
    ll T1, T2; cin >> T1 >> T2;
    ll A1, A2; cin >> A1 >> A2;
    ll B1, B2; cin >> B1 >> B2;

    using lll = __int128;
    // D1, D2 \neq 0
    lll D1 = (B1 - A1) * T1, D2 = (B2 - A2) * T2;
    // fprintf(stderr, "D1 = %lld, D2 = %lld\n", (ll)D1, (ll)D2);
    
    // 出会わない
    if((D1 > 0 and D2 > 0) or
       (D1 > 0 and D1 + D2 > 0) or
       (D1 < 0 and D2 < 0) or
       (D1 < 0 and D1 + D2 < 0)) {
        cout << 0 << endl;
        return 0;
    }
    // 無限に出会う
    if(D1 * D2 < 0 and D1 + D2 == 0) {
        cout << "infinity" << endl;
        return 0;
    }

    // 正 -> 負 にしておく
    if(D1 < 0 and D2 > 0) {
        D1 *= -1;
        D2 *= -1;
    }

    ll ans = 0;

    // T1
    {
        lll lb = -1, ub = LONGINF;
        while(ub - lb > 1) {
            lll mid = (ub + lb) / 2;
            lll R1 = mid * (D1 + D2);
            lll R2 = mid * (D1 + D2) + D1;
            if(R1 <= 0 and R2 > 0) lb = mid;
            else ub = mid;
        }
        // 最初もカウントしてるので 1 引く
        // fprintf(stderr, "ans1 = %lld\n", (ll)ub - 1);
        ans += (ll)ub - 1;
    }
    
    // T2
    {
        lll lb = -1, ub = LONGINF;
        while(ub - lb > 1) {
            lll mid = (ub + lb) / 2;
            lll R1 = mid * (D1 + D2) + D1;
            lll R2 = mid * (D1 + D2) + D1 + D2;
            // fprintf(stderr, "mid = %lld, c1 = %d, c2 = %d\n", (ll)mid, R1 > 0, R2 <= 0);
            /*
            if(mid < 100) {
                cout << (ll)R1 << " " << (ll)R2 << endl;
            }
            */
            if(R1 >= 0 and R2 < 0) lb = mid;
            else ub = mid;
        }
        // fprintf(stderr, "ans2 = %lld\n", (ll)ub);
        ans += (ll)ub;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <sstream> //string stream its useful!
#include<string>
#include<iostream>
#include<utility> //pair
#include <vector> // vector
#include <algorithm>    // swap,sort,binary_search
#include <functional>   // std::greater
#include <map> //map
#include<set> //set
#include<queue> //queue
#include<list> //list
#include<cmath>
#include<numeric>
#include<cassert>
#include <iomanip> //cout<<setprecision
#include <regex>

typedef long long ll;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
ll W = 1000000007;
// tuple にすれば回るんじゃないかな。


using namespace std;
void omajinai() {
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<setprecision(15);
    //freopen("txt.csv","r",stdin);
}



static function<ll(ll,ll)> sumfunc = [](ll l1,ll l2)->ll{return l1 + l2;};
class UF{
public:
    vector<ll> v;
    vector<ll> v2;
    function<ll(ll,ll)> func;
    UF(long t,function<ll(ll,ll)> func){
        v = vector<ll>(t);
        v2 = vector<ll>(t);
        for(int i = 0; i<v.size();i++) v[i] = i;
        this->func = func;
    }
    long getunion(long t){
        if(v[t] == t) return t;
        v[t] = getunion(v[t]);
        return v[t];
    }
    void unite(pair<long,long> p){
        long a = getunion(p.first), b = getunion(p.second);
        if(a>b) swap(a,b);
        v[b] = a;
        v2[a] = func(v2[b],v2[a]);
    }
    long sizeofunion(){
        long sum = 0;
        for(int i = 0 ; i<v.size();i++) if(v[i] == i ) sum++;
        return sum;
    }
};

class Main{
public:
    
    int N;
    vector<char> s;
    Main(){
        cin>>N;
        s = vector<char>(N+1);
        REP(i,N) cin>>s[i];
        s[N] = s[0];
    }
    
    void run(){
        vector<pair<int, int > > vp = {{0,0},{0,1},{1,0},{1,1}};
        for (pair<int,int> p :vp){
            vector<int> v(N,-1);
            v[0] = p.first; v[1] = p.second;
            FOR(i,2,N){
                if(v[i-1] == 0){
                    if(s[i-1] == 'o')v[i] = v[i-2]; else v[i] = abs(v[i-2] -1);
                }else{
                    if(s[i-1] == 'x')v[i] = v[i-2]; else v[i] = abs(v[i-2] -1);
                }
            }
            if((s[0] == 'o' &&v[0] == 0)||(s[0] == 'x' && v[0] == 1)){
                if(v[1] != v[N-1]) continue;
            }else{
                if(v[1] == v[N-1]) continue;
            }
            
            if((s[N-1] == 'o' &&v[N-1]==0)||(s[N-1] == 'x' && v[N-1] == 1)){
                if(v[N-2] != v[0]) continue;
            }else{
                if(v[N-2] == v[0]) continue;
            }
            REP(i,N) cout<<(v[i] == 0 ? 'S':'W');
            cout<<endl;
            return;
        }
        cout<<-1<<endl;
    }
};

int main(){
    omajinai();
    Main().run();
}


Measured memory_bytes: 888
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_5_A&lang=jp
#include <bits/stdc++.h>
using namespace std;

struct Diameter {
  Diameter () {}
  Diameter (int n) : G(n) {}

  struct edge {
    edge () {}
    edge (int to, int cost) : to(to), cost(cost) {}

    int to, cost;
  };

  using P = pair<int, int>;

  const P id = make_pair(0, -1);
  vector<vector<edge>> G;
  pair<P, int> max_pair;

  void add_edge(int u, int v, int cost) {
    G[u].push_back(edge(v, cost));
    G[v].push_back(edge(u, cost));
  }

  void add_edge(int u, int v) {
    add_edge(u, v, 1);
  }

  P dfs(int v, int pre) {
    P res = id;
    for (const auto &e : G[v]) {
      if (e.to == pre) continue;
      P p = dfs(e.to, v);
      p.first += e.cost;
      res = max(res, p);
    }

    if (res == id) {
      res = make_pair(0, v);
    }
    return res;
  }

  int dist() {
    P l = dfs(0, -1);
    P r = dfs(l.second, -1);
    max_pair = make_pair(P(l.second, r.second), r.first);
    return r.first;
  }
};

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

  Diameter d(n);
  for (int i = 0; i < n - 1; ++i) {
    int u, v, c;
    cin >> u >> v >> c;
    d.add_edge(u, v, c);
  }

  cout << d.dist() << endl;
}

Measured memory_bytes: 12780
a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())

if b > a:
    if a < 0:
        if b < 0:
            ab = -a - -b
        else:
            ab = -a + b
    else:
        ab = b - a
else:
    if b < 0:
        if a < 0:
            ab = -b - -a
        else:
            ab = -b + a
    else:
        ab = a - b


vt = v * t
wt = w * t



if vt - wt >= ab:
    print("YES")
else:
    print("NO")

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

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

}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a;        /*??\????????????*/
	int n;        /*??\???????????°*/
	int c;        /*??°???????????¨?????°*/
	int max;      /*??\?????°??§????????§????????°*/
	int min;  /*??\???????????°??§???????°?????????°*/
	long long sum;   /*??\???????????°???????¨?*/
	
    
	max = -1000000;
	min =  1000000;
	sum = 0;
	
		
	scanf("%d", &n);
	
	for (c = 1; c <= n; c++){
		scanf("%d", &a);
		if (c == 1) {
			max = a;
			min = a;
		}
		if(max < a){
			max = a;
		}
		if(min > a){
			min = a;
		}
		sum = sum + a;
	}
	printf("%d %d %lld\n", min, max, sum);
	
	
	return (0);
}

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

using namespace std;

int main()
{
  int64_t N, D;

  cin >> N >> D;

  vector<vector<int64_t> > X;

  X.resize(N);

  for(int64_t i = 0;
      i < N;
      ++i)
    {
      X[i].resize(D);
      for(int64_t j = 0;
          j < D;
          ++j)
        {
          cin >> X[i][j];
        }
    }

  int64_t ans = 0;

  for(int64_t i = 0;
      i < N;
      ++i)
    {
      for(int64_t j = i + 1;
          j < N;
          ++j)
        {
          int64_t sum = 0;
          for(int64_t k = 0;
              k < D;
              ++k)
            {
              int64_t x = X[i][k] - X[j][k];
              sum += x * x;
            }
          int64_t sqrt_sum = sqrt(sum);
          if(sqrt_sum * sqrt_sum == sum)
            {
              ++ans;
            }
        }
    }

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


Measured memory_bytes: 256
#include <map>
#include <iostream>
using namespace std;
#define M 998244353

int modexp(int x, int e, int m) {
    long long ans = 1, p = x % m;
    while (e > 0) {
        if (e % 2 != 0) ans = (ans * p) % m;
        p = (p * p) % m;
        e >>= 1;
    }
    return ans;
}

int main() {
    int n, m; cin >> n >> m;
    map<int, int> col[n], row[n];
    for (int i = 0; i < m; i++) {
        int a, b, c; cin >> a >> b >> c;
        a--; b--;
        row[a][b] = c;
        col[b][a] = c;
    }
    long long dp[n][2] = {};
    dp[0][0] = dp[0][1] = 1;
    for (int a = 1; a < n; a++) {
        for (int j = 0; j < 2; j++) {
            if (col[a].find(a) != col[a].end() && col[a][a] != j) continue;
            for (int i = 0; i < 2; i++) {
                if (col[a-1].find(a-1) != col[a-1].end() && col[a-1][a-1] != i) continue;
                long long c = 0;
                if (col[a].find(a-1) != col[a].end()) {
                    if (row[a].find(a-1) != row[a].end())
                        c = i^j^col[a][a-1]^row[a][a-1] ? 0 : 1;
                    else
                        c = 1;
                } else {
                    if (row[a].find(a-1) != row[a].end())
                        c = 1;
                    else
                        c = 2;
                }
                if (a > 1) {
                    if (col[a].find(a-2) != col[a].end()) {
                        if (row[a].find(a-2) != row[a].end())
                            if (i^col[a][a-2]^row[a][a-2]) c = 0;
                    } else {
                        if (row[a].find(a-2) == row[a].end()) c *= 2;
                    }
                    int free = a - 2;
                    for (auto p : col[a]) {
                        if (p.first >= a-2) break;
                        int b = p.first;
                        if (row[a].find(b) != row[a].end()) {
                            if (p.second != row[a][b]) { c = 0; break; }
                        }
                        free--;
                    }
                    for (auto p : row[a]) {
                        if (p.first >= a-2) break;
                        int b = p.first;
                        if (col[a].find(b) != col[a].end()) {
                            if (p.second != col[a][b]) { c = 0; break; }
                        } else
                            free--;
                    }
                    c = c * modexp(2, free, M) % M;
                }
                dp[a][j] += c * dp[a-1][i] % M;
            }
            if (dp[a][j] >= M) dp[a][j] -= M;
        }
    }
    cout << (dp[n-1][0] + dp[n-1][1]) % M << endl;
}


Measured memory_bytes: 15872
import numpy as np
N,K= map(int,input().split())
H = np.array(list(map(int, input().split())))

dp = np.zeros(N, dtype=int)

for i in range(1,N):
  s=max(i-K,0)
  dp[i]=np.min(dp[s:i]+np.abs(H[s:i]-H[i]))

print(dp[-1])

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

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

    cout<<2*r*3.14<<endl;
}


Measured memory_bytes: 3784
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	int n, d, i, j, k, ans;
	cin >> n >> d;
	ans = (n + d + d) / (d + d + 1);
	cout << ans << "\n";

	return 0;
}



Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  for(int i=0;i<2;i++)
    for(int j=0;j<2;j++)
      for(int k=0;k<2;k++){
	int sum=s[0]-'0';
	sum+=(i?1:-1)*(s[1]-'0');
	sum+=(j?1:-1)*(s[2]-'0');
	sum+=(k?1:-1)*(s[3]-'0');
	if(sum==7){
	  cout<<s[0]<<(i?'+':'-');
	  cout<<s[1]<<(j?'+':'-');
	  cout<<s[2]<<(k?'+':'-');
	  cout<<s[3]<<"=7"<<endl;
	  return 0;
	}
      }
}


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

int main(){
  ll n,m;cin>>n>>m;
  ll sum = (n-2) * (m-2);
  if (n==1&&m==1){
    cout << 1 << endl;
    return 0;
  }
   else if (n==1 ||m == 1){
    cout << max(n,m) - 2 << endl;
    return 0;
  }
  else {
    cout << sum << endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>

int gcd(int x,int y){

  if(!y) return x;
  x%=y;
  return gcd(y,x);

}

int main(){

  int x,y;

  scanf("%d%d",&x,&y);
  printf("%d\n",gcd(x,y));

  return 0;

}



Measured memory_bytes: 2084
#include<bits/stdc++.h>
using namespace std;
#define IO ios_base::sync_with_stdio(false)
long long a[200000], vs[405][406],vs1[100006],to[500][500],white[500][500];
vector<int>v[200000];
char s[405][405];
void f(int n, int m, int co)
{
    int i, k=0;
    vs[n][m]=1;
    for(i=-1;i<=1; i++)
    for(k=-1; k<=1; k++){
            char ch=s[n+i][m+k];
        if(abs(i+k)==1&&ch!='*'){
            if(vs[n+i][m+k]==0&&((co==1&&ch=='.')||(co==0&&ch=='#'))){
                f(n+i,m+k,1-co);
                to[n][m]+=to[n+i][m+k];
                white[n][m]+=white[n+i][m+k];
            }
        }
    }
    to[n][m]++;
    if(s[n][m]=='.')white[n][m]++;
}
int main()
{
    IO;
    long long i, j, m, k, n, t, l=0, mx,ll,mxx,mx1;
    cin>>n>>m;
    for(i=0; i<=n+1; i++)
        for(j=0; j<=m+1; j++) s[i][j]='*';
    for(i=1; i<=n; i++)
        for(j=1; j<=m; j++) cin>>s[i][j];
    for(i=1; i<=n; i++)
        for(j=1; j<=m; j++){
            if(vs[i][j]==0&&s[i][j]=='#'){
                f(i,j,1);
                l+=(to[i][j]-white[i][j])*white[i][j];
            }
        }
    cout<<l<<endl;
    return 0;

}


Measured memory_bytes: 32512
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int MAX_N = 100005;
ll a[MAX_N],sum[MAX_N];

int main()
{
	int N;
	cin >> N;
	rep(i,N)
	{
		cin >> a[i];
	}

	ll temp = 0, ans1 = 0;
	sum[0] = a[0];
	rep(i,N-1)
	{
		sum[i+1] = sum[i] + a[i+1];
	}
	rep(i,N) //+-+-+-...
	{
		sum[i] += temp;
		if (i % 2 == 0)
		{
			if (sum[i] <= 0)
			{
				ans1 += abs(sum[i]) + 1;
				temp += abs(sum[i]) + 1;
			}
		}
		else
		{
			if (sum[i] >= 0)
			{
				ans1 += abs(sum[i]) + 1;
				temp -= abs(sum[i]) + 1;
			}
		}
	}

	temp = 0;
	ll ans2 = 0;
	rep(i,N)
	{
		sum[i] = 0;
	}
	sum[0] = a[0];
	//cout << sum[0] << " ";
	rep(i,N-1)
	{
		sum[i+1] = sum[i] + a[i+1];
		//cout << sum[i+1] << " ";
	}
	//cout << endl;
	rep(i,N) //-+-+-+...
	{
		sum[i] += temp;
		if (i % 2 == 0)
		{
			if (sum[i] >= 0)
			{
				ans2 += abs(sum[i]) + 1;
				temp -= abs(sum[i]) + 1;
			}
		}
		else
		{
			if (sum[i] <= 0)
			{
				ans2 += abs(sum[i]) + 1;
				temp += abs(sum[i]) + 1;
			}
		}
	}
	cout << min(ans1,ans2) << endl;
	//cout << ans1 << " " << ans2 << endl;
	return 0;
}

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

int nth_bit(int64_t num, int n){
    return (num >> n) & 1;
}

int main(){
    int N;
    cin >> N;
    vector<int> A((1<<N)+1);
    for(int i=0; i<(1<<N); i++) cin >> A[i];
    vector<pair<int, int>> dp(1<<N);
    for(int i=0; i<(1<<N); i++) dp[i] = {i, 1<<N};
    
    auto merge = [&](int i, int j){
        for(int a : {dp[j].first, dp[j].second}){
            if(A[a] > A[dp[i].first]){
                dp[i] = {a, dp[i].first};
            }else if(A[a] > A[dp[i].second]){
                dp[i].second = a;
            }
        }
    };
    for(int i=0; i<N; i++) for(int b=0; b<(1<<N); b++) if(nth_bit(b, i)) merge(b, b-(1<<i));

    vector<int> ans(1<<N);
    for(int i=1; i<(1<<N); i++){
        ans[i] = max(ans[i-1], A[dp[i].first] + A[dp[i].second]);
        cout << ans[i] << endl;
    }
}

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

using namespace std;

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

int main(){
  int n;
  string s;
  cin >> n >> s;
  if(n%2 == 1){
    cout << "No" << endl;
    return 0;
}else{
  rep(i,n/2){
      if(s[i] != s[i+n/2]){
        cout << "No" << endl;
        return 0;
      }
    }
    cout << "Yes" << endl;
  }
}


Measured memory_bytes: 256
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

int data[18] = {};

long long int saiki(int N,int reb)
{
	if (!N)return 1;
	while (data[reb] > N)reb--;
	long long int count = 0;
	for (size_t i = reb; i >0; i--)
	{
		count += saiki(N - data[i], i);
	}
	return count;
}

int main()
{
	int N;
	for (size_t i = 0; i < 18; i++)
	{
		data[i] = i*i;
	}
	while (cin >> N, N)
	{
		cout << saiki(N, 17) << endl;
	}
}

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

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

    string c;
    cin >> c;

    vector<ll> rsumv(n, 0);
    if (c.at(0) == 'R') rsumv.at(0)++;

    for (int i=1; i<n; i++) {
        if (c.at(i) == 'R') {
            rsumv.at(i) = rsumv.at(i-1) + 1;
        } else rsumv.at(i) = rsumv.at(i-1);
    }
    ll rsum = rsumv.at(n-1);
    
    ll ans = 0;
    if (rsum) {
        ans = rsum - rsumv.at(rsum-1);
    }

    cout << ans << endl;

}

Measured memory_bytes: 5240
#include <stdio.h>
#include <algorithm>
 
using namespace std;
 
int main(){
    int H,W;
    while(true){
        scanf("%d %d",&H,&W);
        if(H == 0 && W == 0) break;
        for(int i = 0; i < H; i++){
            for(int j = 0; j < W; j++){
                if((i+j)%2 == 0) printf("#");
                else{
                    printf(".");
                }
            }
            printf("\n");
        }
        printf("\n");
    }
}


Measured memory_bytes: 2612
eval"_,*A="+gets.split*?,
s=*$<
q=[]
f=->i{x,y=s[i]&.bytes&.map{|c|c-65}
x ? 2.times{A[x]>0&&(q<<(y+65).chr;A[x]-=1;A[y]+=1;f[i+1];A[x]+=1;A[y]-=1;q.pop);x,y=y,x} : puts(:Yes,q)+exit}
f[0]
puts :No

Measured memory_bytes: 163384
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int n;
main(){
	cin>>n;
	vector<int>v(n);
	r(i,n)v[i]=i+1;
	do{
		r(i,n)cout<<v[i]<<(i==n-1?'\n':' ');
	}while(next_permutation(v.begin(),v.end()));
}


Measured memory_bytes: 3100
/* ABC176 C */

#include<stdio.h>

int main(void){
    int n, height_front, height_back, diff, i;
    long long total=0;

    scanf("%d", &n);
    for(i=0; i<n; i++){
        scanf("%d", &height_back);
        if(i>0){
            if(height_back < height_front){
                diff = height_front - height_back;
                total += diff;
                height_back += diff;
            }
        }
        height_front = height_back;
    }

    printf("%llu\n", total);
}

Measured memory_bytes: 1736
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <iostream>
#include <climits>
using namespace std;

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

typedef pair<LL, LL> P;

LL a, b;
LL n;

int main() {
	cin >>n >> a >> b;
	int ans = min(b, a* n);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long
#define pb push_back
#define mp make_pair
const int MOD=1e9+7;
const int INF=1e15;

signed main(){
    string S;cin>>S;
    bool ok=true;
    bool Ccheck=false;
    REP(i,S.size()){
        if(i==0){
            if(S[0]!='A'){
                ok=false;
                break;
            }
            continue;
        }
        if(i==1||i==S.size()-1){
            if(S[i]-'a'<0){
                ok=false;
                break;
            }
            continue;
        }
        if(S[i]=='C'){
            if(Ccheck){
                ok=false;
                break;
            }
            Ccheck=true;
            continue;
        }
        if(S[i]-'a'<0){
            ok=false;
            break;
        }

    }
    if(ok&&Ccheck)cout<<"AC"<<endl;
    else cout<<"WA"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int n;
    string s;
    cin >> n;
    cin >> s;
    for(int i = 0; i < s.length(); i++){
        cout << (char)((s[i] - 'A' + n) % 26 + 'A');
    }
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define SZ(x) ((ll)(x).size())
typedef long long ll;
typedef pair<int, int> P;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){if(a>b){a=b;return 1;}return 0;}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){if(a<b){a=b;return 1;}return 0;}


int main(){
    int w,h,n;
    cin >> w >> h >> n;
    vector<int> x(n);
    vector<int> y(n);
    vector<int> a(n);
    REP(i,n){
        cin >> x[i] >> y[i] >> a[i];
        a[i]--;
    }
    vector<vector<bool>> sq(h,vector<bool>(w,true));
    vector<int> m(4);
    m[0]=0;
    m[1]=w;
    m[2]=0;
    m[3]=h;
    REP(i,n){
        switch (a[i]) {
            case 0:
                chmax(m[a[i]],x[i]);
                break;
            case 1:
                chmin(m[a[i]],x[i]);
                break;
            case 2:
                chmax(m[a[i]],y[i]);
                break;
            case 3:
                chmin(m[a[i]],y[i]);
            default:
                break;
        }
    }
    if(m[1]>m[0]&&m[3]>m[2]){
        put((m[1]-m[0])*(m[3]-m[2]));
    }else{
        put(0);
    }
    
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
        int n = sc.nextInt();
        int i;
        int a[] = new int[n];
        double count = 0;
        double ave,check, last = Integer.MAX_VALUE;
        int ans = 0;
        for(i = 0;i < n;i++){
          a[i] = sc.nextInt();
          count += a[i];
        }
        ave = count / n;

		for(i = 0;i < n;i++){
          check = ave - a[i] ;
          check = Math.abs(check);
          if(check < last){
            last = check;
            ans = i;
          }
        }
      	System.out.println(ans);
    }
}

Measured memory_bytes: 35892
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
 
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
 
typedef long long ll;
typedef vector<int> vi;
typedef unsigned long ul;
typedef vector<ll> vl;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
typedef set<int> si;
typedef multiset<int> mi;
 
const ll INF = 1e18;
const int MOD = 1e9+7;
 
int main() {
	
	cin.tie(NULL);
	ios_base::sync_with_stdio(false);

	//ofstream cout ("name.out");
	//ifstream cin ("name.in");

	int n;
	cin>>n;
	if(n>=30) cout<<"Yes\n";
	else cout<<"No\n";

	return 0;
}



Measured memory_bytes: 3620
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

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

#define ll long long
#define pb push_back
#define ld long double
#define mp make_pair
#define F first
#define S second
#define pii pair<ll,ll> 

using namespace :: std;

const ll maxn=1e5+500;
const ll inf=1e17+800;
const ll mod=1e9+7;

ll a[maxn];
ll b[maxn];
ll c[maxn];
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);	
	ll n,x;
	cin>>n>>x;
	for(ll i=0;i<n;i++){
		cin>>a[i];
		b[i]=a[i];
	}
	ll ans=inf;
	for(ll i=0;i<=n;i++){
		ll res=0;
		for(ll j=0;j<n;j++){
			res+=b[j];
		}
		ans=min(ans,res+x*i);
		for(ll j=0;j<n;j++){
			c[j]=min(a[j],b[(j-1+n)%n]);
		}
		for(ll j=0;j<n;j++){
			b[j]=c[j];
		}
	}
	cout<<ans;
}




















Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
#include<cassert>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};

template<typename T>
struct BellmanFord{

  struct edge{
    int u,v;
    T w;
    edge(){}
    edge(int u,int v,T w):u(u),v(v),w(w){}
  };

  int n;
  vector< vector<int> > G;
  vector<int> used,reach;
  BellmanFord(int n):n(n),G(n),used(n,0),reach(n,1){}

  vector<edge> es;
  void add_edge(int u,int v,T c){
    es.emplace_back(u,v,c);
    G[u].emplace_back(v);
  }

  vector<T> build(int from,int &neg_loop){
    vector<T> ds(n,INF);
    ds[from]=0;
    for(int j=0;j<n;j++){
      bool update=0;
      for(auto e:es){
        if(!reach[e.u]||!reach[e.v]||ds[e.u]==INF) continue;
        if(ds[e.v]>ds[e.u]+e.w){
          ds[e.v]=ds[e.u]+e.w;
          update=1;
        }
      }
      if(!update) break;
      if(j==n-1){
        neg_loop=1;
        return ds;
      }
    }
    neg_loop=0;
    return ds;
  }

  void dfs(int v){
    if(used[v]) return;
    used[v]=1;
    for(int u:G[v]) dfs(u);
  }

  T shortest_path(int from,int to,int &neg_loop){
    for(int i=0;i<n;i++){
      fill(used.begin(),used.end(),0);
      dfs(i);
      reach[i]=used[to];
    }
    return build(from,neg_loop)[to];
  }
};

int n,m;ll p;

void solve(){
    cin >> n >> m >> p;
    BellmanFord<ll> bel(n);
    rep(i,m){
        int u,v;ll c;cin >> u >> v >> c;u--;v--;
        bel.add_edge(u,v,p-c);
    }
    int neg=0;
    ll ans=bel.shortest_path(0,n-1,neg);
    if(neg) cout << -1 << endl;
    else cout << max(0ll,-ans) << endl;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(50);
    solve();
}

Measured memory_bytes: 3920
#include <bits/stdc++.h>
  
using namespace std;
  
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
  
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
  
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
  
const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e6 + 555; // TL MB
const double PI = acos(-1.0);
 
void mul(ll &x, ll y){
	x *= y;
	if(x >= mod) x %= mod;
}
 
void add(ll &x, ll y){
	x += y;
	if(x >= mod) x -= mod;
	if(x < 0) x += mod;
}
ll bp(ll a, ll n){
	ll r = 1;
	while(n){
		if(n & 1) mul(r, a);
		mul(a, a);
		n >>= 1;
	}
	return r;
}

void solve()
{
	ll n, k, x, y;
	cin >> n >> k >> x >> y;
	cout << min(n, k) * x + max(0ll, n - k) * y;
}


 // a b c a b c a b c a b c
 
int main()
{
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
    Red;
  	int T = 1;
  //	cin >> T;
  	for(int i = 1; i <= T; ++i){
  		solve();
  	}
  	return 0;

}

Measured memory_bytes: 256
#include<iostream>
#include<numeric>
#include<cmath>
#include<cstdlib>
#include<string>
#include <limits>
using namespace std;

int main(){
	int N,M,C,count=0,ans=0;
	cin>>N>>M>>C;
	int B[M];
	int A[N][M];

	for(int i=0;i<M;i++)
		cin>>B[i];

	for(int i=0;i<N;i++){
		ans = 0;
		for(int j=0;j<M;j++){
			cin>>A[i][j];
			ans += A[i][j]*B[j];
		}
		ans += C;
		if(ans > 0)
			count++;
	}

	cout<<count<<endl;


}

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

using namespace std;

int main(void)
{

	int n,m;

	int i1,i2;

	int s;
	int sum1,sum2;
	int check;
	int t,h;
	int min;


	while(1){
		cin >> n >> m;
		if (n==0 && m==0) break;

		vector<int> v;
		vector<int> w;
		sum1 = 0;
		sum2 = 0;

		for(i1=0;i1<n;i1++){
			cin >> s;
			v.push_back(s);
			sum1 += s;
		}
		for(i1=n;i1<n+m;i1++){
			cin >> s;
			w.push_back(s);
			sum2 += s;
		}

		check = 0;
		min = 200;

		for(i1=0;i1<v.size();i1++){
			for(i2=0;i2<w.size();i2++){

				if( (sum1-v[i1]+w[i2]) == (sum2-w[i2]+v[i1])){
					if(min > (v[i1]+w[i2]) ){
						min = v[i1] + w[i2];
						t=i1;
						h=i2;
					}

					check = 1;
				}  

			}
		}

		if (check==1) cout << v[t] << " " << w[h] << endl;
		else cout << -1 << endl;

	}
	return 0;
}

Measured memory_bytes: 1220
ABCD = input()
for i in range(8):
        s = ""
        for j in range(3):
                s += ABCD[j] 
                if (i >> j) & 1:
                        s += "+" 
                else:
                        s += "-" 
        s += ABCD[3]
        if eval(s) == 7:
                print(s + "=7")
                break

Measured memory_bytes: 3060