akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector< vector<int> > VVI;
typedef vector< vector<int> > VVL;
typedef pair<int,int> PII;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair

int main(){
  int N,M;
  cin>>N>>M;
  VL X(N),Y(N),Z(N);
  rep(i,N) cin>>X[i]>>Y[i]>>Z[i];
  ll ans=0;
  rep(i,8){
    VL A(N);
    rep(j,N) A[j]=X[j]*pow(-1,(i&1))+Y[j]*pow(-1,(i&2)/2)+Z[j]*pow(-1,(i&4)/4);
    sort(all(A));
    ll sum=0;
    rep(j,M) sum+=A[N-1-j];
    ans=max(ans,sum);
  }
  cout<<ans<<endl;
}

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

int main() {
	 
	int D, L, ans;
	cin >> D >> L;

	/* カエルが何回飛んだか計算 */
	ans = D / L + D % L;  /* 大ジャンプの回数は商で求まり、小ジャンプの回数は余りで求まる*/

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3124
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using vvl = vector<vector<long>>;
using pii = pair<int, int>;
using pil = pair<int, long>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20)
#define YES cout << "Yes" << endl
#define NO cout << "No" << endl
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,s,t) for(int i=s; i<t; i++)
#define RNG(i,s,t,u) for(int i=s; i<t; i+=u)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()
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; }

vector<bool> prime_vec(long n){ //2からnまでの素数を列挙した配列
    vector<bool> vec(n,true);
    vec.at(0) = false;
    vec.at(1) = false;
    for(int i=2; i<n; i++){
        if(vec.at(i)){
            for(int j=2; i*j<n; j++){
                vec.at(i*j) = false;
            }
        }
    }
    return vec;
}

int main(){
  int n;
  cin >> n;
  vl a(n);
  rep(i,n) cin >> a.at(i);
  vb isprime = prime_vec(1000010);
  vb primeref = prime_vec(1000010);
  bool flag = false;
  rep(j,n){
    long tmp = a.at(j);
    if(primeref.at(tmp)){
      if(isprime.at(tmp)){
        isprime.at(tmp) = false;
        continue;
      }else{
        flag = true;
        break;
      }
    }
    for(int i=2;i<=min(tmp,(long)sqrt(a.at(j)+10));i++){
      if(!primeref.at(i)) continue;
      if(tmp % i == 0){
        while(tmp % i == 0){
          //cout << tmp << " "; 
          tmp /= i;
          //cout << tmp << endl;
        }
        if(isprime.at(i)){
          isprime.at(i) = false;
        }else{
          flag = true;
          break;
        }
      }
    }
    if(flag) break;
    if(tmp == 1) continue;
    if(isprime.at(tmp)){
      isprime.at(tmp) = false;
    }else{
      flag = true;
      break;
    }
  }

  if(!flag){
    cout << "pairwise coprime" << endl;
    return 0;
  }
  long g = __gcd(a.at(0), a.at(1));
  rep(i,n){
    g = __gcd(a.at(i), g);
  }
  if(g == 1) cout << "setwise coprime" << endl;
  else cout << "not coprime" << endl;
}

Measured memory_bytes: 11364
#include <bits/stdc++.h>
using namespace std;
#define int long long 
 
#define pi pair<int,int>
#define pb push_back
#define F first
#define S second
#define mod 1000000007
#define mx 1000000
#define mn 0
#define hello 123

signed main()
{
    int d,t,s;
    cin>>d>>t>>s;
    if(t*s>=d)cout<<"Yes";
    else cout<<"No";
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <deque>
using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

int main(){
	int n;
	ll a,b;
	cin>>n>>a>>b;
  ll h[n];
	REP(i,n)cin >> h[i];
	ll mi=0,ma=1000000000;
	while(ma-mi>1){
		ll mid=(mi+ma)/2;
		long long int cnt=0;
		for(int i=0;i<n;i++){
			if(h[i]>b*mid){
				cnt+=(h[i] - b * mid + a - b - 1) / (a-b);
			}
		}
		if(cnt>mid){
			mi=mid;
		}
		else{
			ma=mid;
		}
	}
	cout<<ma<<endl;
	return 0;
}


Measured memory_bytes: 1024
let rec solve maxLen current rest =
  match rest with
  | 'A'::x -> solve maxLen (current + 1) x
  | 'C'::x -> solve maxLen (current + 1) x
  | 'G'::x -> solve maxLen (current + 1) x
  | 'T'::x -> solve maxLen (current + 1) x
  | _::x -> if current > maxLen then solve current 0 x else solve maxLen 0 x
  | [] -> if current > maxLen then current else maxLen

stdin.ReadLine().ToCharArray()
|> Array.toList
|> solve 0 0
|> printfn "%d"

Measured memory_bytes: 29972
#include <iostream>
#define INF 1000000000
using namespace std;
int dp[41][401][401];
int main(){
	int N, Ma, Mb;
	cin >> N >> Ma >> Mb;
	int a[N], b[N], c[N];

	for (int i=0; i<N; i++) {
		cin >> a[i] >> b[i] >> c[i];
	}

	for (int dpi=1; dpi<=N; ++dpi) {
		for (int i=0; i<=400; i++) {
			for (int j=0; j<=400; j++) {
				dp[dpi][i][j] = dp[dpi-1][i][j];
			}
		}
		if (dp[dpi][a[dpi-1]][b[dpi-1]] == 0) {
			dp[dpi][a[dpi-1]][b[dpi-1]] = c[dpi-1];
		} else {
			if (dp[dpi][a[dpi-1]][b[dpi-1]] > c[dpi-1]) {
				dp[dpi][a[dpi-1]][b[dpi-1]] = c[dpi-1];
			}
		}
		for (int i=0; i<=400; i++) {
			for (int j=0; j<=400; j++) {
				if (dp[dpi-1][i][j] == 0) {
					continue;
				}
				if (i+a[dpi-1] > 400 || j+b[dpi-1] > 400)continue;
				int pre = dp[dpi-1][i][j] + c[dpi-1];
				int now = dp[dpi][i+a[dpi-1]][j+b[dpi-1]];
				if (now == 0) {
					dp[dpi][i+a[dpi-1]][j+b[dpi-1]] = pre;
				}
				else {
					dp[dpi][i+a[dpi-1]][j+b[dpi-1]] = now < pre ? now: pre;
				}
			}
		}
	}
	int min = INF;
	for (int r=1; Ma*r <= 400 && Mb*r <= 400; r++) {
		int ma = Ma*r;
		int mb = Mb*r;
		if (dp[N][ma][mb] != 0) {
			if (dp[N][ma][mb] < min) {
				min = dp[N][ma][mb];
			}
		}
	}
	if (min == INF ) {
		cout << -1 << endl;
		return 0;
	}
	cout << min << endl;

	return 0;
}


Measured memory_bytes: 25344
#include <iostream>
#include <numeric>
#include<math.h>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
int Max(int(a), int(b), int(c)) {
	return max(max(a, b), c);
}
int Min(int(a), int(b), int(c)) {
	return min(min(a, b), c);
}

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



int main() {
	double A,B,H,M,hu;
	cin >> A>>B>>H>>M;
	static const double pi = 3.141592653589793;
	hu = H * 60 + M;
	H =hu* pi / 360;
	M *= pi / 30;
	cout << fixed << setprecision(10);
		cout << sqrt(A*A+B*B-2*A*B*cos(H-M)) << endl;
	
	

}

Measured memory_bytes: 4224
#include<bits/stdc++.h>
using namespace std;
const int N=1e6+7;
int n,w[N],cnt[N];
inline int read()
{
    int num=0; char g=getchar();
    while(g<48||57<g) g=getchar();
    while(47<g&&g<58) num=(num<<1)+(num<<3)+g-48,g=getchar();
    return num;
}
int main()
{
	n=read(); int val=0,sum; for(int i=1;i<=n;i++) w[i]=read(),cnt[w[i]]++,val=max(val,w[i]);
	if(n!=2&&val==1) {puts("Impossible"); return 0;} sum=val+1;
	while(sum>0)
	{
		if(sum>=2) {if(cnt[val]<2) {puts("Impossible"); return 0;} cnt[val]-=2,sum-=2;}
		else {if(cnt[val]<=0) {puts("Impossible"); return 0;} sum--,cnt[val]--;} val--;
	}
	val++; for(int i=1;i<=n;i++) if(cnt[i]&&i<=val) {puts("Impossible"); return 0;} puts("Possible");
	return 0;
}

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

#define int long long
#define pb push_back 
#define mp make_pair
#define fr first
#define sc second
#define Rep(i, n) for( int i = 0; i < (n); i++ )
#define Rrep(i, a, n) for( int i = (a); i < (n); i++ )
#define All(v) v.begin(), v.end()

typedef pair<int, int> Pii; 
typedef pair<int, Pii> Pip;
const int INF = 1107110711071107;

signed main() {
  int x;
  cin >> x;
  if ( x % 7 == 0 ) {
    cout << "thu" << endl;
  }
  if ( x % 7 == 1 ) {
    cout << "fri" << endl;
  }
  if ( x % 7 == 2 ) {
    cout << "sat" << endl;
  }
  if ( x % 7 == 3 ) {
    cout << "sun" << endl;
  }
  if ( x % 7 == 4 ) {
    cout << "mon" << endl;
  }
  if ( x % 7 == 5 ) {
    cout << "tue" << endl;
  }
  if ( x % 7 == 6 ) {
    cout << "wed" << endl;
  }
  return 0;
}

Measured memory_bytes: 3092
import itertools
n=int(input())
lf=[list(map(int,input().split())) for _ in range(n)]
lp=[list(map(int,input().split())) for _ in range(n)]
lit=list(itertools.product([0,1],repeat=10))[1:]
ans=-10**9
for i in lit:
    tmp=0
    for num,j in enumerate(lf):
        com=sum([k*l for k,l in zip(i,j)])
        tmp+=lp[num][com]
    ans=max(ans,tmp)
print(ans)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define ll long long int
#define vi vector< int >
#define vc vector< char >
#define vvi vector < vector< int > >
#define vvc vector < vector< char > >
#define vl vector< ll >
#define vll vector<pair<ll,ll>>
#define pii pair< int, int >
#define pll pair<ll, ll>
#define pf push_front
#define pb push_back
// #define range(c) c.begin(), c.end()
// #define ranger(c) c.rbegin(), c.rend()
#define all(c) c.begin(), c.end()
#define allr(c) c.rbegin(), c.rend()
#define forn(i, n) for(ll i = 0; i < n; ++i)
#define fornr(i, n) for(ll i = n-1; i >= 0; --i)
#define foro(i, n) for(ll i = 1; i <= n; ++i)
#define foror(i, n) for(ll i = n; i >= 1; --i)
#define endl '\n'
#define MOD 998244353
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pr(a) for(auto it :a) cout << (it) << " "; cout << endl;
#define pr2(a) for(int i = 0; i<a.size(); ++i){ for(int j = 0; j<a[i].size(); ++j) cout << a[i][j] << ' '; cout << endl;}
#define test ll T; cin >> (T); while(T--)

#define present(container, element) (container.find(element) != container.end())
// for set and maps
#define cpresent(container, element) (find(all(container),element) != container.end())
// for vectors

using namespace std;

int main() {
// #ifndef ONLINE_JUDGE
//     freopen("/home/shivam/input.txt", "r", stdin);
//     freopen("/home/shivam/output.txt", "w", stdout);
//     freopen("/home/shivam/error.txt", "w", stderr);
// #endif

    FIO;

    int n;
    cin >> n;
    vi arr(n);
    forn(i, n)
    cin >> arr[i];
    int pp = 0, p = abs(arr[1] - arr[0]), curr;

    for (int i = 2; i < n; ++i) {
        curr = min(p + abs(arr[i] - arr[i - 1]), pp + abs(arr[i] - arr[i - 2]));
        pp = p;
        p = curr;
    }

    cout << p << endl;

    return 0;
}


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

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

const double PI = acos(-1);
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;

#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
#define REP(i,n) for (int i = 0; i<n; i++)
#define ALL(a) begin(a), end(a)

int main (void) {
    int N;
    string S;
    cin>>N>>S;
    int ans = inf;
    vector<int> B(N+1,0),W(N+1,0);
    for (int i=1;i<=N;i++) {
        if (S[i-1] == '#') {
            B[i] = B[i-1] + 1;
        }
        else {
            B[i] = B[i-1] ;
        }
    }
    int BB = B[N];
    for (int i=1;i<=N;i++) {
        if (S[i-1] == '.') {
            W[i] = W[i-1] + 1;
        }
        else {
            W[i] = W[i-1] ;
        }
    }
    int WW = W[N];
    REP(i,N+1) {
        int temp = 0;
        int lb = B[i];
        int rb = BB - lb;
        int lw = W[i];
        int rw = WW - lw;
        temp = lb + rw;
        ans = min(temp,ans);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 2180
#include <bits/stdc++.h>
 
using namespace std;
 
using ll = long long;
constexpr ll MOD = 1e9 + 7;
constexpr ll INF = 1e18;
 
int main() {
    int n;
    cin >> n;
    vector<ll> v(n);
    for(auto& x:v){
        cin >> x;
    }
    ll res = 1e9;
    for (int i = -100; i <= 100; i++) {
        ll cnt = 0;
        for(int j = 0; j < n; j++){
            cnt += (v[j] - i) * (v[j] - i);
        }
        res = min(res, cnt);
    }
    cout << res << endl;
}

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

using namespace std;

int main(int argc, char * argv[])
{
    unsigned int n = 0;
    cin >> n;

    vector<unsigned int> a(n, 0);
    for (unsigned int i = 0; i < a.size(); ++i) {
        cin >> a[i];
    }

    unsigned int count = 0;
    unsigned int j = 0;
    for (unsigned int i = 1; i <= n; ++i) {
        if ( a[a[i - 1] - 1] == i ) {
            ++count;
        }
    }
    cout << count / 2 << endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << endl
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;

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

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      s << '\n';
  }
  return s;
}

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;
}

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

string S, T;
int N;


bool A_win(int L, int s, char p, char m) {
  int l = 0, r = L - 1;
  rep(i, N) {
    if (T[i] == m)
      r = min(r + 1, L - 1);
    else if (T[i] == p)
      l = max(l - 1, 0);

    if (S[i] == m)
      l++;
    else if (S[i] == p)
      r--;

    if (l > r)
      return false;
  }
  if (l <= s && s <= r)
    return true;
  else
    return false;
}

signed main() {
  int H, W;
  cin >> H >> W;
  cin >> N;
  int sr, sc;
  cin >> sr >> sc;
  sr--, sc--;
  cin >> S >> T;
  reverse(all(S));
  reverse(all(T));


  if (A_win(H, sr, 'D', 'U') && A_win(W, sc, 'R', 'L'))
    cout << "YES\n";
  else
    cout << "NO\n";
}

Measured memory_bytes: 920
///supercalifragilisticexpialidocious.
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cassert>
#include <cstdlib>
#include <cctype>
#include <ctime>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <numeric>
#include <utility>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <list>
#include <bitset>
#include <complex>
using namespace std;
#define f first
#define s second
#define PB pop_back 
#define pb push_back
#define mp make_pair
#define int long long
#define sz(s) (int)s.size()
#define seper(n) setprecision(n)
#define all(v) v.begin(),v.end()
#define mem(a,b) memset(a,b,sizeof a)
#define IOS ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
typedef long long ll; 
typedef map<int , int> mii;
typedef pair<int , int> pii; 
typedef map<string , int> msi;
typedef pair<int , string> pis; 
typedef pair<int , pair<int , int> > piii;
double p;
int n;
int32_t main()
{
		cin >> n;
		if(n & 1)
				p = (double)(n / 2 + 1) / n;
		else
				p = (double)(n / 2) / n;
		return cout << fixed << seper(6) << p << endl , 0;
}


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

using namespace std;
const int mod = 1e9 + 7;
const long long INF = 1e18;
#define PI 3.141592653589793
#define REP(i, n) for(long long i = 0;i < n;i++)
int main()
{
  double D,T,S;
  cin>>D>>T>>S;
  string ans="Yes";
  if(T<D/S){
      ans="No";
  }
  cout<<ans;
  return 0;
}




Measured memory_bytes: 3752
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int N = sc.nextInt();
		int K = sc.nextInt();
		for (int i = 0; i < K; ++i) {
			int a = sc.nextInt()-1;
			int b = sc.nextInt()-1;
			int s = Math.min(a, N - 1 - a);
			int u = Math.min(b, N - 1 - b);
			System.out.println(Math.min(s, u) % 3 + 1);
		}
	}

}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
#define f(i, k, n) for (int i = k; k < n ? i < n : i > n; k < n ? i += 1 : i -= 1)
#define ll long long
#define pb push_back
#define fr first
#define sc second
#define len(s) s.size()
#define all(v) v.begin(), v.end()
#define tr(it, v) for (auto &it : v)
#define bit(x) __builtin_popcount(x)
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef map<int, int> mii;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
// =================
void impgraph(int n, int m);
void dfs(int u, int par);

const int mod = 1e9;
const int N = 3e5 + 1;

vi g[N];
int a[N];

void solve()
{
    int n, m, ans = 0, cnt = 0, k;
    cin >> n >> m;
    int w[n], v[n];
    f(i, 0, n)
    {
        cin >> w[i] >> v[i];
        cnt += v[i];
    }
    vi dp(cnt + 1, mod); //min weight to take home items of total value i
    dp[0] = 0;
    f(item, 0, n)
    {
        f(i, cnt - v[item], -1)
        {
            dp[i + v[item]] = min(dp[i + v[item]], dp[i] + w[item]);
        }
    }
    f(i, 0, cnt + 1)
    {
        if (dp[i] <= m)
            ans = max(ans, i);
    }
    cout << ans << endl;
}

int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int t = 1;
    //cin >> t;
    while (t--)
        solve();
    return 0;
}

void impgraph(int n, int m)
{
    int i, u, v;
    while (m--)
    {
        cin >> u >> v;
        g[u].pb(v);
        g[v].pb(u);
    }
}

void dfs(int u, int par)
{
    for (int v : g[u])
    {
        if (a[v])
        {
        }
        dfs(v, 0);
    }
}

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

using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<(int)(n);i++)

class Mint{
    public:
    int v;
    const long long MOD = 1000000007;
    Mint():v(0){}
    Mint(signed v):v(v){}
    Mint(long long t){v=t%MOD; if(v<0)v+=MOD;}

    Mint pow(long long k){
        Mint res(1), tmp(v);
        while(k){
            if(k&1)res*=tmp;
            tmp*=tmp;
            k>>=1;
        }
        return res;
    }
    Mint inv(){return pow(MOD-2);}

    Mint& operator+=(Mint a){v+=a.v; if(v>=MOD)v-=MOD; return *this;}
    Mint& operator-=(Mint a){v+=MOD-a.v; if(v>=MOD)v-=MOD; return *this;}
    Mint& operator*=(Mint a){v=1LL*v*a.v%MOD; return *this;}
    Mint& operator/=(Mint a){return (*this)*=a.inv();}

    Mint operator+(Mint a) const{return Mint(v)+=a;};
    Mint operator-(Mint a) const{return Mint(v)-=a;};
    Mint operator*(Mint a) const{return Mint(v)*=a;};
    Mint operator/(Mint a) const{return Mint(v)/=a;};

    Mint operator-(){return v ? MOD-v : v;}
    bool operator==(Mint a)const{return v==a.v;}
    bool operator!=(Mint a)const{return v!=a.v;}

    Mint operator=(Mint a) {v=a.v;return a;}

    friend ostream& operator<<(ostream& os, const Mint& mint){
        os << mint.v;
        return os;
    }
};

class cmbs{
    public:
    vector<Mint> fact, finv, inv;
    cmbs(){
        fact.clear(); finv.clear(); inv.clear();
    }
    void init(int n){
        if(n+1 <= (signed)fact.size())return;
        fact.assign(n+1,1);
        finv.assign(n+1,1);
        inv.assign(n+1,1);

        for(int i=1; i<=n; i++) fact[i] = fact[i-1]*Mint(i);
        finv[n] = Mint(1)/fact[n];
        for(int i=n; i>=1;i--) finv[i-1] = finv[i]*Mint(i);
        for(int i=1; i<=n; i++) inv[i] = finv[i]*fact[i-1];
    }
    Mint comb(long long n, int k){
        if(n<k||k<0)return Mint(0);
        Mint res(1);
        for(int i=0; i<k; i++){
            res *= Mint(n-i);
            res /= Mint(i+1);
        }
        return res;
    }
    Mint C(int n,int k){
        if(n<k||k<0)return Mint(0);
        init(n);
        return fact[n]*finv[n-k]*finv[k];
    }
    Mint P(int n, int k){
        if(n<k || k<0)return Mint(0);
        init(n);
        return fact[n]*finv[n-k];
    }
    Mint H(int n, int k){
        if(n<0||k<0)return Mint(0);
        if(!n&&!k)return Mint(1);
        init(n+k-1);
        return C(n+k-1,k);
    }
    Mint S(int n, int k){
        Mint res;
        init(k);
        for(int i=0; i<=k; i++){
            Mint v = (C(k,i) * Mint(k-i).pow(n));
            if(i%2==0) res+=v;
            else res-=v;
        }
        return res;
    }
};

int main(){
    ll n,k;
    cin>>n>>k;
    if(n<k){
        cout<<"0"<<endl;
        return 0;
    }
    cmbs cmb;
    cout<<cmb.S(n,k)<<endl;
    return 0;
}


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

int main() {
    string S,T;
    cin >> S >> T;
    
    long long count=0;
    for(long long i=0;i<S.length();i++){
        if(S[i]!=T[i]){
            count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 3916
N = int(input())
lstB = list(map(int,input().split()))
 
lstA = []
 
for i in range(N):
    if i == 0:
        lstA.append( lstB[i] )
    elif i == N-1:
        lstA.append( lstB[i-1] )
    else:
        lstA.append( min(lstB[i],lstB[i-1]))
        
print(sum(lstA))
 
  

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

int main() {
	int N;
	cin >> N;
	vector<int> L;
	int ans = 0;

	for (int i=0; i<N; i++) {
		int t;
		cin >> t;
		L.push_back(t);
	}

	for (int i=0; i<N-2; i++) {

		for(int j=i+1; j<N-1; j++){
			for (int k=j+1; k<N; k++) {
				int a = L.at(i); int b = L.at(j); int c = L.at(k);
				if (a == b|| a == c || b == c) {
				} else {
					if (a + b > c && a+c>b && b+c>a) {
						ans++;
					}
				}
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3628
import math

A, B, H, M = map(int, input().split())

H_L = 0.5 * (H * 60 + M)
M_L = 6 * M

R = math.cos(math.radians(abs(H_L - M_L)))

X = A ** 2 + B ** 2 - 2 * A * B * R
Y = math.sqrt(X)

print(Y)


Measured memory_bytes: 9568
#include<iostream>
#include<string>
#define UE 0
#define SHITA 1
#define MIGI 2
#define HIDARI 3
#define N_U_MIGI 4
#define N_S_MIGI 5
#define N_U_HIDARI 6
#define N_S_HIDARI 7
using namespace std;

const int MAX_N = 260;
void loop(string v[], int y, int x, int type, int n, int deep);
int tmp;

int main(){
	int n;
	while(cin >>n){
		if(n == 0) break;
		string v[MAX_N];
		int max = 0;
		for(int i = 0; i < n; i++){
			cin >>v[i];
		}
		for(int i = 0; i < n; i++){
			for(int j = 0; j < n; j++){
				if(v[i][j] == '1'){
					int u, s, m, h, num, nsm, nuh, nsh;
					//cout <<"v[" <<i <<"][" <<j <<"] = 1" <<endl;
					
					tmp = 0; loop(v, i, j, UE, n, 0);
					u = tmp;
					
					tmp = 0; loop(v, i, j, SHITA, n, 0);
					s = tmp;
					
					tmp = 0; loop(v, i, j, MIGI, n, 0);
					m = tmp;
					
					tmp = 0; loop(v, i, j, HIDARI, n, 0);
					h = tmp;
					
					tmp = 0; loop(v, i, j, N_U_MIGI, n, 0);
					num = tmp;
					
					tmp = 0; loop(v, i, j, N_S_MIGI, n, 0);
					nsm = tmp;
					
					tmp = 0; loop(v, i, j, N_U_HIDARI, n, 0);
					nuh = tmp;
					
					tmp = 0; loop(v, i, j, N_S_HIDARI, n, 0);
					nsh = tmp;
					
					//cout <<"u + s = " <<u + s + 1 <<endl;
					//cout <<"m + h = " <<m + h + 1 <<endl;
					//cout <<"num + nsh = " <<num + nsh + 1 <<endl;
					//cout <<"nuh + nsm = " <<nuh + nsm + 1 <<endl;
					
					if(max < u + s + 1){
						max = u + s + 1;
					} if(max < m + h + 1){
						max = m + h + 1;
					} if(max < num + nsh + 1){
						max = num + nsh + 1;
					} if(max < nuh + nsm + 1){
						max = nuh + nsm + 1;
					}
					//cout <<"max = " <<max <<endl;
					
				}
			}
		}
		cout <<max <<endl;
	}
	return 0;
}

void loop(string v[], int y, int x, int type, int n, int deep){
	int plusx[8] = {0, 0, 1, -1, 1, 1, -1, -1}, plusy[8] = {-1, 1, 0, 0, -1, 1, -1, 1};
	if(x < 0 || y < 0 || x >= n || y >= n || v[y][x] == '0'){
		//cout <<"x = " <<x <<" y = " <<y <<" deep - 1 = " <<deep - 1 <<endl;
		tmp += (deep - 1);
	} else{
		loop(v, (y + plusy[type]), (x + plusx[type]), type, n, deep + 1);
	}
}

Measured memory_bytes: 1000
# https://atcoder.jp/contests/abc104/tasks/abc104_c

D, G = map(int, input().split())

p = []  # 各点数台の問題数のリスト
c = []  # 各点数台のコンプリートボーナス

# 各点数台を、完全に解くかどうかのリスト　1問も解かないとして初期化
solve_completely_list = [False] * D

# 入力処理
for d in range(D):
    p_i, c_i = map(int, input().split())
    p.append(p_i)
    c.append(c_i)


def dfs(i, solve_completely_list, completed_amount_list):
    if i >= D:
        is_larger_than_G = False    # フラグ初期化
        # total_score計算
        total_score = 0
        completed_amount = 0
        for d in range(D):
            if solve_completely_list[d]:
                total_score += (d+1) * 100 * p[d] + c[d]
                completed_amount += p[d]


        # total_scoreがGより小さいとき
        # Gより大きくなるまで、一番大きい配点を足す
        # 一番大きい配点をp-1個足してもGより小さい場合、諦めて他の枝に移る
        if total_score < G:
            # solve_completely_list[D]がTrueのときは、(D-1) * 100を最大の配点とする
            # solve_completely_list[i]がFalseであるiのうち最大のiの配点を使う
            max_d = -1
            for d_i in reversed(range(D)):
                if solve_completely_list[d_i] == False:
                    max_d = d_i
                    break
            # 多分ありえないけど一応
            if max_d == -1:
                return

            for p_d in range(p[max_d] - 1):
                total_score += (max_d + 1) * 100
                completed_amount += 1
                if total_score >= G:
                    is_larger_than_G = True
                    break
        else:
            is_larger_than_G = True
        
        if is_larger_than_G:
            completed_amount_list.append(completed_amount)
        return
    

    # 完全に解く(100i 点の問題を pi 問解く)場合
    solve_completely_list[i] = True
    dfs(i + 1, solve_completely_list, completed_amount_list)

    # 1問も解かない場合
    solve_completely_list[i] = False
    dfs(i + 1, solve_completely_list, completed_amount_list)

completed_amount_list = []    # 回答した数のリスト
dfs(0, solve_completely_list, completed_amount_list)
print(min(completed_amount_list))



Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define outc cout
#define int long long
signed main(){
  int a;
  int b=0,c=1,d,e=0,f=0,l=0;
  cin>>a>>b>>c;
  d=max(b,c)-min(b,c);
  if(d%2==0) cout<<"Alice";
  else cout<<"Borys";
  cout<<"\n";}

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

ll solve() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    ll s = 0;
    for ( int i = 0; i < N; i++ ) {
        cin >> A[i];
        s += A[i];
    }
    ll m = 1000000, ix = 0;
    for ( int i = 0; i < N; i++ ) {
        ll x = abs(A[i]*N-s);
        if ( m > x ) {
            m = x;
            ix = i;
        }
    }
    return ix;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
void swap(int A[],int B[],int i,int j)
{
    int temp;
    temp=A[i];
    A[i]=A[j];
    A[j]=temp;
    temp=B[i];
    B[i]=B[j];
    B[j]=temp;
}

void pushdown(int A[],int B[],int f,int l)
{
    int p=f;
    int c=2*p;
    while (c<=l)
    {
        if(c<l&&(B[c-1]<B[c]))c++;
        if(B[c-1]<B[p-1])break;
        swap(A,B,c-1,p-1);
        p=c;
        c=2*p;
    }
}

void heap_sort(int A[],int B[],int n)
{
    int i;
    for(i=n/2;i>0;i--)pushdown(A,B,i,n);
    for(i=n;i>1;i--)
    {
        swap(A,B,0,i-1);
        pushdown(A,B,1,i-1);
    }
}
int main()
{
    int N;
    int i;
    int t=0;
    scanf("%d",&N);
    int A[N],B[N];
    for(i=0;i<N;i++)scanf("%d %d",&A[i],&B[i]);
    heap_sort(A,B,N);
    for(i=0;i<N;i++)
    {
        t+=A[i];
        if(t>B[i])
        {
            printf("No");
            return 0;
        }
    }
    printf("Yes");
    return 0;
}

Measured memory_bytes: 1792
import math

N = int(input())
root_N = math.sqrt(N)
root_N_int = int(root_N // 1)

if root_N.is_integer():
    n = root_N
    m = root_N
else:
    for i in range(root_N_int, 0, -1):
        if N % i == 0:
            n = N / i
            m = N / n
            break

ans = n + m -2

print(int(ans))



Measured memory_bytes: 3060
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

//Util
func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func maxInt(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func minInt(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}

func absInt(a int) int {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func absFloat64(a float64) float64 {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func minFloat64(a, b float64) float64 {
	if a > b {
		return b
	} else {
		return a
	}
}

func str2Int(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}

//Main
var sc = bufio.NewScanner(os.Stdin)
var H, W int
var dist [110][110]int

type Point struct {
	y, x int
}

func main() {
	sc.Split(bufio.ScanWords)
	H, W = nextInt(), nextInt()

	c := make([]string, H)
	whnum := 0
	for i := 0; i < H; i++ {
		c[i] = nextStr()
		for j := 0; j < W; j++ {
			if string(c[i][j]) != "#" {
				whnum++
			}
			dist[i][j] = -1
		}
	}

	//左、上、下、右移動
	dy := []int{0, 1, -1, 0}
	dx := []int{-1, 0, 0, 1}

	q := []Point{}
	q = append(q, Point{0, 0})
	dist[0][0] = 1
	//fmt.Println(c, done, s, g)
	for len(q) > 0 {
		//キューから取り出し
		u := q[0]
		q = q[1:]

		//次の訪問先をキューについて
		for i := 0; i < 4; i++ {
			nexty := u.y + dy[i]
			nextx := u.x + dx[i]
			//枠外ならスキップ
			if nexty < 0 || nexty >= H || nextx < 0 || nextx >= W {
				continue
			}
			//未訪問かつ通れる場合は評価
			if dist[nexty][nextx] == -1 && string(c[nexty][nextx]) != "#" {
				dist[nexty][nextx] = dist[u.y][u.x] + 1
				q = append(q, Point{nexty, nextx})
				//fmt.Println(q)
			}
		}
	}

	if dist[H-1][W-1] == -1 {
		fmt.Println(-1)
	} else {
		fmt.Println(whnum - dist[H-1][W-1])
	}

}


Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long int
#define pb push_back
#define mp make_pair
const int mod=1e9+7;
ll t[200100]={};
void solve()
{
  int n,x;
  cin>>n;
  int V[n];
  for(int i=0;i<n;i++)
  {
    cin>>V[i];
    t[--V[i]]++;
  }
  ll sum=0,res=0;
  for(int i=0;i<n;i++)
  sum+=(t[i]*(t[i]-1))/2;
  for(int i=0;i<n;i++)
  {
    res=sum+1-t[V[i]];
    cout<<res<<endl;
  }
}
int main()
{
  fastio
  solve();
}


Measured memory_bytes: 3968
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin >> a >> b;
  if(a%3==0) cout << "Possible" << endl;
  else if(b%3==0) cout << "Possible" << endl;
  else if((a+b)%3==0) cout << "Possible" << endl;
  else cout << "Impossible" << endl;
}


Measured memory_bytes: 256
import sys
readline = sys.stdin.readline
write = sys.stdout.write
def check(N, C, T, x):
    used = [0]*N
    S = [0]*(T+1)
    cap = x
    f = 0
    for t in range(T):
        cap += S[t]
        if cap == 0:
            continue
        for i in range(f, N):
            if used[i]:
                continue
            m, l, k = C[i]
            if t+m > T:
                break
            if t % (l + k) <= l:
                used[i] = 1
                S[t+m] += 1
                cap -= 1
                if i == f:
                    while f < N and used[f]:
                        f += 1
                if cap == 0:
                    break
    cap += S[T]
    return sum(used) == N and cap == x

def solve():
    N, T = map(int, readline().split())
    if N == 0:
        return False
    C = [list(map(int, readline().split())) for i in range(N)]
    for x in range(N+1):
        if check(N, C, T, x):
            write("%d\n" % x)
            break
    return True
while solve():
    ...


Measured memory_bytes: 5732
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
#define ALL(C)     (C).begin(),(C).end()

typedef long long ll;

int dp[100][101];

bool bt(int n,int now,int *inp,int *vol);

set<ll> D[100];
bool distribute(int n,int now,int *inp,int *vol){
  if (vol[now] == 0)return bt(n,now+1,inp,vol);

  ll state = 0;
  REP(i,now,n){
    state=(state<<1);
    if (vol[i] == inp[i])state++;
  }
  
  if (D[now].find(state) != D[now].end())return false;
  D[now].insert(state);
  if (vol[now] == 0)return false;



  REP(i,now+1,n){
    if (vol[i] != 0)continue;
    if (vol[now]-inp[i] < 0)continue;
    if (i-1 >= now+1 && inp[i-1] == inp[i] && vol[i-1] == 0)continue;
    vol[now]-=inp[i];
    vol[i]=inp[i];
    if (distribute(n,now,inp,vol))return true;
    vol[i]=0;
    vol[now]+=inp[i];
  }
  return false;
}

set<ll> S[100];
bool bt(int n,int now,int *inp,int *vol){
  if (now == n){
    return true;
  }


  /*
  ll state = 0;
  REP(i,now,n){
    state=(state<<1);
    if (vol[i] == inp[i])state++;
  }

 
  if (S[now].find(state) != S[now].end())return false;
  S[now].insert(state);
  */
  if (vol[now] == 0)return false;
 

  //through
  if (bt(n,now+1,inp,vol))return true;

  //distribute
  if (distribute(n,now,inp,vol))return true;
  return false;
}

main(){
  int n;
  while(cin>>n && n){
    int in[n];
    int vol[n];
    vector<int> a;
    rep(i,n){
      cin>>in[i];vol[i]=0;a.push_back(in[i]);
      S[i].clear();
      D[i].clear();
    }
    sort(in,in+n,greater<int>());
    sort(ALL(a));
    vol[0]=in[0];
    if (bt(n,0,in,vol) == true)puts("YES");
    else puts("NO");
  }
  return false;
}

Measured memory_bytes: 3152
#include <stdio.h>

int main(void)
{
  int n;
  char s[5001];
  int t[5001][5001] = {};

  scanf("%d", &n);
  scanf("%s", s);

  for (int i = n - 1; i >= 0; i--) {
    for (int j = n - 1; j > i; j--) {
      if (s[i] == s[j]) t[i][j] = t[i + 1][j + 1] + 1;
    }
  }

  int ans = 0;

  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      if (t[i][j] <= j - i && t[i][j] > ans) ans = t[i][j];
    }
  }
  printf("%d\n", ans);
}


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

int main()
{
    int n;
    while(cin>>n)
    {
        cin.ignore();
        double w,h;
        cin>>w;cin.ignore();cin>>h;
        if(w/pow(h,2)>=25)cout<<n<<endl;
    }
    return 0;
}

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

class Seq {
 public:
 	Seq(const string& s) : s_(s) {
 		tot_ = 0;
 		mn_ = 0;
 		for (auto	 c : s) {
 			if (c == '(') {
 				tot_++;
 			} else {
 				tot_--;
 			}
 			mn_ = min(mn_, tot_);
 		}
 	}

 	string s_;
 	int mn_;
 	int tot_;

 	bool operator< (const Seq& rhs) const {
 		return mn_ < rhs.mn_;
 	}
};

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	int n;
	cin >> n;
	int tot = 0;
	vector<Seq> vpos, vmin;
	for (int i = 0; i < n; ++i) {
		string s;
		cin >> s;
		Seq cseq(s);
		tot += cseq.tot_;
		if (cseq.tot_ >= 0) {
			vpos.push_back(cseq);
		} else {
			for (int j = 0; j < s.size(); ++j) {
				if (s[j] == '(') s[j] = ')';
				else s[j] = '(';
			}
			reverse(s.begin(), s.end());
			vmin.emplace_back(s);
		}
	}
	if (tot) {
		cout << "No\n";
		return 0;
	}

	sort(vpos.begin(), vpos.end());
	reverse(vpos.begin(), vpos.end());

	tot = 0;
	for (const auto& cseq : vpos) {
		if (tot + cseq.mn_ < 0) {
			cout << "No\n";
			return 0;
		}
		tot += cseq.tot_;
	}

	sort(vmin.begin(), vmin.end());
	reverse(vmin.begin(), vmin.end());

	tot = 0;
	for (const auto& cseq : vmin) {
		if (tot + cseq.mn_ < 0) {
			cout << "No\n";
			return 0;
		}
		tot += cseq.tot_;
	}

	cout << "Yes\n";
	return 0;
}

Measured memory_bytes: 42544
<?php

fscanf(STDIN, "%d", $n);
$a_list = explode(' ', trim(fgets(STDIN)));

$answer = 0;
for ($i = 0; $i < $n - 1; ++$i) { 
    if ($a_list[$i + 1] < $a_list[$i]) {
        $answer += ($a_list[$i] - $a_list[$i + 1]);
        $a_list[$i + 1] = $a_list[$i];
    }
}

echo $answer;


Measured memory_bytes: 31908
#include<iostream>
#include<vector>
#include<algorithm>
#include<unordered_set>
#define ios ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
using namespace std;
int main()
{
    ios;
    int n,m;    cin >> n >> m;
    unordered_set<int> s[n + 1];
    int h[n+1];
    for(int i = 1; i < n + 1; i++)
        cin >> h[i];
    int a,b; 
    int ans = 0;
    for(int i = 0; i < m; i++)
    {
        cin >> a >> b;
        s[a].insert(b);
        s[b].insert(a);
    }
    for(int i = 1; i <= n; i++)
    {
        int f = 1;
        for(auto it = s[i].begin(); it != s[i].end(); it++)
        {
            if(h[*it] >= h[i])
            {
                f = 0;
                break;
            }
        }
        if(f)
        {
            ans++;
            // cout << i << " ";
        }
    }
    // cout << '\n';
    // for(int i = 1; i <= n; i++)
    // {
    //     cout << "Set " << i << ": ";
    //     for(auto it = s[i].begin(); it != s[i].end(); it++)
    //         cout << *it << " ";
    //     cout << '\n';
    // }
    cout << ans << '\n';
}

Measured memory_bytes: 19008
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <vector>

static const int IINF = 1 << 30;
static const long long LINF = 1LL << 60;
static const long long MOD = 1.0e+9 + 7;

template <typename T> std::vector<T> vectors(std::size_t n, T val) {
  return std::vector<T>(n, val);
}

template <typename T, typename... Args>
auto vectors(std::size_t n, Args... args) {
  return std::vector<decltype(vectors<T>(args...))>(n, vectors<T>(args...));
}

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

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

template <class T> inline void chadd(T &a, const T &b) {
  a += b, a %= MOD;
  // TODO minus case
}

template <class T>
std::ostream &operator<<(std::ostream &s, const std::vector<T> &v) {
  if (v.empty())
    return s;
  s << *v.begin();
  for (auto iter = v.begin() + 1; iter != v.end(); ++iter)
    if (std::is_fundamental<T>::value)
      s << " " << *iter;
    else
      s << std::endl << *iter;
  return s;
}

int main() {
  // Input
  int N;
  std::cin >> N;
  std::vector<long long> A(N);
  for (int i = 0; i < N; ++i) {
    std::cin >> A[i];
  }

  // Main
  int numNegative = 0;
  long long minAbs = LINF;
  int minAbxIndex = -1;
  for (int i = 0; i < N; ++i) {
    if (A[i] < 0)
      ++numNegative;
    if (abs(A[i]) < minAbs) {
      minAbs = abs(A[i]);
      minAbxIndex = i;
    }
  }
  // std::cout << numNegative << std::endl;

  long long res = 0;
  if (numNegative % 2 == 0) {
    for (int i = 0; i < N; ++i) {
      res += abs(A[i]);
    }
  } else {
    for (int i = 0; i < N; ++i) {
      assert(minAbxIndex != -1);
      if (i == minAbxIndex)
        continue;
      res += abs(A[i]);
    }
    res -= abs(A[minAbxIndex]);
  }

  // Output
  std::cout << res << std::endl;

  return 0;
}


Measured memory_bytes: 1024
s = sorted(list(input()))
t = sorted(list(input()), reverse=-1)

flag = 0
for elem1, elem2 in zip(s, t):
  if ord(elem1) < ord(elem2):
    print('Yes')
    quit()
  elif ord(elem1) == ord(elem2):
    pass
  else:
    flag = 1
    break
if flag == 1:
  print('No')
else:
  if len(s) < len(t):
    print('Yes')
  else:
    print('No')

Measured memory_bytes: 3064
//#define _GLIBCXX_DEBUG
//#include "atcoder/all"
//using namespace atcoder;
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
#define dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define bit(n, k) (((n) >> (k)) & 1) /*nのk bit目*/
namespace mydef {
const int INF = 1ll << 60;
const int MOD = 1e9 + 7;
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
void Yes(bool flag = true) {
    if (flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}
void No(bool flag = true) {
    Yes(!flag);
}
void YES(bool flag = true) {
    if (flag)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}
void NO(bool flag = true) {
    YES(!flag);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
bool dbg = true;
}  // namespace mydef
using namespace mydef;
#define pb push_back
//#define mp make_pair
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vp vector<pair<int, int>>
#define vvp vector<vector<pair<int, int>>>
#define pi pair<int, int>
//#define P pair<int, int>
//#define V vector<int>
//#define S set<int>
#define asn ans

int N;

void solve() {
}

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

    int cnt = 0;
    int flag = false;
    cin >> N;
    while (N--) {
        int a, b;
        cin >> a >> b;
        if (a == b) {
            cnt++;
            if (cnt >= 3)
                flag = true;
        } else
            cnt = 0;
    }
    Yes(flag);

    solve();
    return 0;
}


Measured memory_bytes: 3640
def abc113_b():
    import numpy as np
    n = int(input())
    t, a = map(int, input().split())
    h = np.array(list(map(int, input().split())))
    temp = np.abs(a - (t - h * 0.006))
    return np.argmin(temp) + 1


print(abc113_b())

Measured memory_bytes: 21688
N=str(input())
le=len(N)
ans=0
for i in range(le):
    tm='9'*i;p='9'*(le-i-1)
    for j in range(10):
        res=tm+str(j)+p
        if(int(res)>int(N)):
            continue
        cnt=0
        for k in range(len(res)):
            cnt+=int(res[k])
        ans=max(ans,cnt)
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include <algorithm>
using namespace std;

int main() {
    int n;
    cin >> n;
    std::vector<float> v(n);
    for(int i = 0; i < n; i++) cin >> v[i];

    sort(v.begin(), v.end());

    for(int i = 1; i < n; i++) {
        v[i] = (v[i-1] + v[i])/2;
    }

    cout << v[n-1] << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
using namespace std;
using ll = long long;

struct Graph {
    struct Vertex { int n; };
    struct Edge { int i, n, k; };
    Graph(int n, int m) : v(n, { -1 }), e(m), n(n), m(0) {}
    void add_edge(int i, int j, int k) {
        e[m] = { j, v[i].n, k };
        v[i].n = m;
        m++;
    }
    bool dfs(int i, int p) {
        if (i == g) return true;
        for (int j = v[i].n; j >= 0; j = e[j].n) {
            Edge &o = e[j];
            if (o.i == p) continue;
            if (dfs(o.i, i)) {
                t ^= 1LL << o.k;
                return true;
            }
        }
        return false;
    }
    ll foo(int u, int v) {
        t = 0; g = v;
        dfs(u, -1);
        return t;
    }
    vector<Vertex> v;
    vector<Edge> e;
    int n, m;
    ll t;
    int g;
};

using ull = unsigned long long;
constexpr ull f(int i) {
    return ~0ULL / (1 + (1ULL << (1 << i)));
}
int popcnt(ull t) {
    t = (t & f(0)) + (t >>  1 & f(0));
    t = (t & f(1)) + (t >>  2 & f(1));
    t = (t & f(2)) + (t >>  4 & f(2));
    t = (t & f(3)) + (t >>  8 & f(3));
    t = (t & f(4)) + (t >> 16 & f(4));
    t = (t & f(5)) + (t >> 32);
    return t;
}

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

    Graph g(n, (n - 1) * 2);
    for (int i = 0; i < n - 1; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;

        g.add_edge(a, b, i);
        g.add_edge(b, a, i);
    }

    int m;
    cin >> m;

    vector<ll> x(m), y(1 << m);
    for (int i = 0; i < m; i++) {
        int u, v;
        cin >> u >> v;
        u--; v--;

        x[i] = y[1 << i] = g.foo(u, v);
    }

    ll r = 0;
    for (int k = 1; k < 1 << m; k++) {
        int o = k & -k;
        y[k] = y[k ^ o] | y[o];

        ll s = popcnt(k) % 2 ? 1 : -1;
        int c = (n - 1) - popcnt(y[k]);
        r += s << c;
    }

    r = (1LL << (n - 1)) - r;
    cout << r << endl;

    return 0;
}

Measured memory_bytes: 8448
#include "bits/stdc++.h"
using namespace std;
#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define LLINF ((long long) 1e18)//1234567890987654321
#define INF 1234567890ll
#define pb emplace_back
#define ins insert
#define f first
#define s second	
#define db 0
#define EPS (1e-7)    //0.0000001 the value
#define PI (acos(-1))
#define MAXN (300006)
#define MAXK 26
#define MAXX 15000006
#define ll long long int 
#define ld long double
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
#define FOR(ii, ss, ee) for(ll ii = ss; ii < ee; ++ii)
#define space " "
#define cbr cerr << "hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ((ll)x.size())
#define ph emplace
#define btinpct(x) __builtin_popcountll(x)
#define p2(x) (1LL<<(x))
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
typedef pair <ll, ll> pi;
typedef pair <ll, pi> spi;
typedef pair <pi, pi> dpi;
inline ll rand(ll x, ll y) { ++y; return (rng() % (y-x)) + x; } //inclusivesss
ll n,r,g,b,ans;
int main()
{
	FAST
	cin>>r>>g>>b>>n;
	FOR(i,0,n/r+5) {
		FOR(j,0,n/g+5) {
			if(i*r+j*g<=n&&(n-(i*r)-(j*g))%b==0) {
				ans++;
			}
		}
	}
	cout<<ans;
}


Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n = I()
    s = S()
    m = n>>1
    if s[:m] == s[m:]:
        print("Yes")
    else:
        print("No")
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 39024
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#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; string s;
  cin >> a >> s;
  if(a>=3200){
    cout << s << endl;
  }else{
    cout << "red" << endl;
  }
}


Measured memory_bytes: 256