akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define Cout(s) cout << s << endl;
using ll = long long;
using P = pair<int, int>;

const ll INF = 1ll << 60;
ll MOD = 1e9 + 7;

int main()
{

    int n;
    cin >> n;
    vector<int> a(n, 0), b(n, 0);
    int ans = 0;
    REP(i, n)
    cin >> a[i];
    REP(i, n)
    cin >> b[i];

    REP(i, n)
    {
        int v = a[i] - b[i];
        if (v > 0)
            ans += v;
    }
    Cout(ans);

    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 all(x) (x).begin(), (x).end()
#define INF 1e9
typedef long long ll;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

int N;
//double v[100];
vector<double> v;
void solve(){
  sort(all(v));
  double ans = (v[0] + v[1])/2;
  for(int i = 2; i < N; i++){
    ans = (ans + v[i]) / 2;
  }
  cout << ans << endl;
}

int main(){
  cin >> N;
  rep(i, N){
    double tmp;
    cin >> tmp;
    v.push_back(tmp);
  }
  solve();
}

Measured memory_bytes: 256
n ,l = map(int, input().split())
apple = []
for i in range(n):
    apple.append(l + i)

if l - 1 + n - 1 < 0:
    print(sum(apple[:n - 1]))
elif l < 0 and  0 <= l - 1 + n - 1:
    print(sum(apple))
elif 0 <= l:
    print(sum(apple[1:]))

Measured memory_bytes: 9076
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>

int main(){
    int n;
    scanf("%d",&n);
    long long int a[n];
    int i;
    for(i=0;i<=n-1;i++)scanf("%lld",&a[i]);
    int ans=0;
    i=0;
    while(i<=n-1){
        i++;
        if(a[i-1]<a[i]){
            while(a[i-1]<=a[i])i++;
            ans++;
        }else if(a[i-1]>a[i]){
            while(a[i-1]>=a[i])i++;
            ans++;
        }
        
    }
    if(ans==0)ans=1;
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 896
#include<stdio.h>
#include<algorithm>
#include<cstring>
#include<map>
#include<cmath>
using namespace std;

int a[5010];
int n, k;

int check(int m) {
    int s = 0, t = 0, sum = 0, f = 0;
    for(;;) {
        while(t < n && sum + m < k) {
            if(a[t] == m && f == 0) { f = 1; t++; continue; }
            sum += a[t++];
        }
        //printf("sum = %d %d\n", sum , sum + m);
        if(sum + m < k) break;
        if(sum < k) return 1;
        if(a[s] == m && f == 1) { f = 2; s++; }
        sum -= a[s++];
    }
    return 0;
}

/*int sreach() {
    //return check(10);
    int l = 0, h = n - 1, mid;
    if(check(a[0])) return -1;
    if(!check(a[n - 1])) return n - 1;
    for(int i = 0; i < 30; i++) {
        mid = (l + h) / 2;
        //printf("%d\n", check(a[mid]));
        if(!check(a[mid])) l = max(mid, l);
        else h = min(h, mid);
        //printf("mid = %d\n", mid);
    }
    return mid;
}
*/
int main()
{
    while(~scanf("%d %d", &n, &k)) {
        int sum = 0;
        for(int i = 0; i < n; i++) {
            scanf("%d", &a[i]);
        }
        sort(a, a + n);
        //printf("5 = %d\n", check(2));
        if(check(a[0])) { printf("0\n"); continue; }
        for(int i = 1; i < n; i++) {
            if(check(a[i])) {printf("%d\n", i); break; }
        }
        if(!check(a[n - 1])) printf("%d\n", n);
       // printf("%d\n", k + 1);
    }
    return 0;
}


Measured memory_bytes: 128
import math
import bisect


def divisorGenerator(n):
    large_divisors = []
    for i in range(1, int(math.sqrt(n) + 1)):
        if n % i == 0:
            yield i
            if i*i != n:
                large_divisors.append(n // i)
    for divisor in reversed(large_divisors):
        yield divisor
        
a = input().split()
a = [int(i) for i in a]
lister = list(divisorGenerator(a[1]))
ind = bisect.bisect_left(lister, a[0])
print(a[1] // lister[ind])


Measured memory_bytes: 38768
#include<cstdio>

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

	for(int i = 0; i < m; i++){
		scanf("%d", &b[i]);
	}

	for(int i = 0; i < n; i++){
		int t = 0;
		for(int j = 0; j < m; j++){
			t += a[i][j] * b[j];
		}
		printf("%d\n", t);
	}
}

Measured memory_bytes: 1068
import pprint

N = int(input())

MOD = pow(10, 9) + 7

# length 
dp = [[[[0 for _ in range(4)] for _ in range(4)] for _ in range(4)] for _ in range(N+1) ]

dp[0][3][3][3] = 1


for index in range(N):
    for c1 in range(4):
        for c2 in range(4):
            for c3 in range(4):
                if dp[index][c1][c2][c3] == 0:
                    continue

                # 新しく追加する文字
                for n in range(4):
                    if n == 2 and c1 == 1 and c2 == 0:
                        continue
                    if n == 2 and c1 == 0 and c2 == 1:
                        continue
                    if n == 1 and c1 == 2 and c2 == 0:
                        continue
                    if n == 2 and c1 == 1 and c3 == 0:
                        continue
                    if n == 2 and c2 == 1 and c3 == 0:
                        continue

                    dp[index + 1][n][c1][c2] += dp[index][c1][c2][c3]
                    dp[index + 1][n][c1][c2] %= MOD

                    

ans = 0
for c1 in range(4):
    for c2 in range(4):
        for c3 in range(4):
            ans += dp[N][c1][c2][c3]
            ans %= MOD

 
print(ans)




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

#include <set>
#include <iterator>
using namespace std;
// using namespace __gnu_pbds;


#define f first
#define s second
#define pb push_back
#define all(x) x.begin(),x.end()

#define ll long long int
#define vi vector<int>
#define vii vector<pair<int,int> >
#define pii pair<int,int>
#define plii pair<pair<ll, int>, int>
#define piii pair<pii, int>
#define viii vector<pair<pii, int> >
#define vl vector<ll>
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define mp make_pair
#define ms(x, v) memset(x, v, sizeof x)
#define pr_vec(v) for(int i=0;i<v.size();i++) cout << v[i] << " " ;

#define f_in(st) freopen(st,"r",stdin)
#define f_out(st) freopen(st,"w",stdout)

#define INF (ll)1e17
#define matrix vector<vector<ll> >

#define fr(i, a, b) for(i=a; i<=b; i++)
#define fb(i, a, b) for(i=a; i>=b; i--)
#define ASST(x, l, r) assert( x <= r && x >= l )
#define maxbits 9
#define maxmask (1ll<<maxbits)
// typedef tree<pll, null_type, less<pll>, rb_tree_tag,
//              tree_order_statistics_node_update>
//     new_data_set;
const int  N=1e3 +10, M=(ll)1e9+1 ;
const int mod =(ll)1e9+7 ,sz=5, MAX=(ll)1e6+10;
string fir="Monocarp",sec="Bicarp";

void work(){
  string ans,s;
  cin >> s;
  ll q;
  cin >> q;
  ll rev=0;
  deque<char> dq;
  for(ll i=0;i<s.size();i++)
    dq.push_back(s[i]);
  while(q--){
    ll t,f;
    char ch;
    cin >> t;
    if(t==1)
      rev=1-rev;
    else{
      cin >> f >> ch;
      if(f==1){
        if(rev==0)
          dq.push_front(ch);
        else
          dq.push_back(ch);
      }
      else{
        if(rev==0)
          dq.push_back(ch);
        else
          dq.push_front(ch);
      }
    }
  }
  while(!dq.empty()){
    ans+=dq.front();
    dq.pop_front();
  }
  if(rev)
    reverse(ans.begin(),ans.end());

  cout << ans ;
} 
int main(){
 ios_base::sync_with_stdio(0);
 cin.tie(0);
    ll t;
    // cin >> t;
    t=1;
    while(t--){
            work();
    }
   return 0;
}


Measured memory_bytes: 1368
//author: Harsh :)
#include <bits/stdc++.h>
using ll = long long;
using ld = long double;
#define F first
#define S second
const ll mod = 1e9 + 7;
const ll INF = 922337203685477;
#define pb push_back
#define deb(x) cout << '>' << #x << ':' << x << endl;
#define fastio ios_base::sync_with_stdio(false); cin.tie(0);
#define maxN 100007
using namespace std;
int main() {
  fastio;
  ll n = 0;
  cin >> n;
  vector<ll>d(n, 0), m(n, 0);
  for (ll i = 0; i < n; ++i) cin >> d[i];
  ll t = 1, x = 0;
  for (ll i = 0; i < n; ++i) {
    if (t) x += d[i];
    else x -= d[i];
    t ^= 1;
  }
  m[0] = x;
  for (ll i = 1; i < n; ++i) m[i] = 2 * d[i - 1] - m[i - 1];
  for (auto i : m) cout << i << " ";
}


Measured memory_bytes: 4760
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = 1e9 + 7;
//constexpr ll MOD = 998244353;
//constexpr ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
constexpr ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
#define FINALANS(A) do {cout << (A) << '\n'; exit(0);} while (false)

int main()
{
  ll A, B;
  cin >> A >> B;

  const ll N = 20000;
  for (ll i = 0; i <= N; i++)
  {
    if (i * 8 / 100 == A && i * 10 / 100 == B)
      FINALANS(i);
  }
  FINALANS(-1);
}

Measured memory_bytes: 256
main :: IO ()
main = getLine >>= mapM_ print . solve . map read . words

solve :: [Double] -> [Double]
solve [a, b, c] = let x = c * pi / 180
                      s = a * b * sin x / 2
                      l = a + b + sqrt (a ^ 2 + b ^ 2 - 2 * a * b * cos x)
                      h = b * sin x
                   in [s, l, h]


Measured memory_bytes: 4020
#include <iostream>
#define NMAX 100
#define KMAX 100000
#define MOD 1000000007

using namespace std;

int n, k, b, dp[3][KMAX+10], sp[3][KMAX+10], v[NMAX+10];

int main()
{
    cin >> n >> k;
    for(int i=1; i<=n; i++) cin >> v[i];
    dp[0][0] = sp[0][0] = 1;
    for(int i=1; i<=v[1]; i++) dp[0][i] = 1, sp[0][i] = sp[0][i-1] + 1;
    for(int i=v[1]+1; i<=k; i++) sp[0][i] = sp[0][i-1];

    for(int i=2; i<=n; i++)
        {   b = 1 - b;
            dp[b][0] = sp[b][0] = 1;
            for(int j=1; j<=v[i]; j++) dp[b][j] = sp[1-b][j], sp[b][j] = (sp[b][j-1] + dp[b][j]) % MOD;
            for(int j=v[i]+1; j<=k; j++) dp[b][j] = (sp[1-b][j] - sp[1-b][j-v[i]-1] + MOD) % MOD, sp[b][j] = (sp[b][j-1] + dp[b][j]) % MOD;
        }
    cout << dp[b][k] << '\n';
    return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cctype>
#include<cstdlib>
#include<algorithm>
#include<bitset>
#include<vector>
#include<list>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<ctime>
#include<complex>
#include<functional>
#include<climits>
#include<cassert>
#include<iterator>
#include<unordered_set>
#include<unordered_map>
using namespace std;


#define MAX 200002

int n;
int m;

vector<int> v;

map<int, set<int> > d;
map<int, set<int> > sav;
int stk[MAX];

int solve() {
	for (int i = 0; i < MAX; i++) {
		stk[i] = i + 1;
	}
	vector<int> ar;
	ar = v;
	sort(ar.begin(), ar.end());
	int pr = -1;
	int idx = -1;
	int save = 0;
	int cr = ar.size();
	for (int i = ar.size() - 1; i >= 0; i--) {
		if (pr != ar[i]) {
			pr = ar[i];
			idx = ar[i];
		}
		else {
			idx--;
		}
		d[idx].insert(ar[i]);
		stk[ar[i]] = idx;
		if (idx >= 1 && idx <= cr) {
			cr = idx-1;
			sav[idx].insert(ar[i]);
			save++;
		}
	}
	return ar.size() - save;
}

int main() {
	cin >> n >> m;
	//if (n > 2000 || m > 2000)return 1;
	for (int i = 0; i < n; i++) {
		int a;
		scanf("%d", &a);
		v.push_back(a);
	}
	int ans = v.size()-solve();
	for (int i = 0; i < m; i++) {
		int x, y;
		scanf("%d%d", &x, &y);
		x--;
		{
			int val = v[x];
			if (stk[val]>=1&&sav[stk[val]].count(val)) {
				sav[stk[val]].erase(val);
				ans--;
			}
			d[stk[val]].erase(val);
			if (stk[val]>=1&&d[stk[val]].size() && sav[stk[val]].empty()) {
				int v = *d[stk[val]].begin();
				if (stk[val] - 1 >= 0 && sav[stk[val] - 1].size() && d[stk[val]].count(*sav[stk[val] - 1].begin())) {
					v = *sav[stk[val] - 1].begin();
				}
				sav[stk[val]].insert(v);
				ans++;
			}
			stk[val]++;
		}
		{
			v[x] = y;
			stk[y]--;
			d[stk[y]].insert(y);
			if (stk[y]>=1&&sav[stk[y]].empty()) {
				sav[stk[y]].insert(y);
				ans++;
			}
			else {
				if (stk[y] >= 1) {
					sav[stk[y]].clear();
					sav[stk[y]].insert(y);
				}
			}
		}
		printf("%d\n", n-ans);
	}
	return 0;
}

Measured memory_bytes: 78052
// Hail god Yato
 
#include <bits/stdc++.h> 
using namespace std;
 
#define hs ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
const ll MOD = 998244353;
const ll INF = 1e18;
const ll MAX = 100001;
//
//

struct mi {
    ll v; explicit operator ll() const { return v; }
    mi() { v = 0; }
    mi(ll _v) { 
        v = (-MOD < _v && _v < MOD) ? _v : _v % MOD;
        if (v < 0) v += MOD;
    }
    friend bool operator==(const mi& a, const mi& b) { 
        return a.v == b.v; }
    friend bool operator!=(const mi& a, const mi& b) { 
        return !(a == b); }
    friend bool operator<(const mi& a, const mi& b) { 
        return a.v < b.v; }
   
    mi& operator+=(const mi& m) { 
        if ((v += m.v) >= MOD) v -= MOD;
        return *this; }
    mi& operator-=(const mi& m) { 
        if ((v -= m.v) < 0) v += MOD; 
        return *this; }
    mi& operator*=(const mi& m) { 
        v = v*m.v%MOD; return *this; }
    mi& operator/=(const mi& m) { return (*this) *= inv(m); }
    friend mi pow(mi a, ll p) {
        mi ans = 1; assert(p >= 0);
        for (; p; p /= 2, a *= a) if (p&1) ans *= a;
        return ans;
    }
    friend mi inv(const mi& a) { assert(a.v != 0); 
        return pow(a,MOD-2); }
        
    mi operator-() const { return mi(-v); }
    mi& operator++() { return *this += 1; }
    mi& operator--() { return *this -= 1; }
    mi operator++(int) { mi temp; temp.v = v++; return temp; }
    mi operator--(int) { mi temp; temp.v = v--; return temp; }
    friend mi operator+(mi a, const mi& b) { return a += b; }
    friend mi operator-(mi a, const mi& b) { return a -= b; }
    friend mi operator*(mi a, const mi& b) { return a *= b; }
    friend mi operator/(mi a, const mi& b) { return a /= b; }
    friend ostream& operator<<(ostream& os, const mi& m) {
        os << m.v; return os;
    }
    friend istream& operator>>(istream& is, mi& m) {
        ll x; is >> x;
        m.v = x;
        return is;
    }
};
void solve(){
    ll n, k;
    cin>>n>>k;
    vector<pair<int, int>> range(k);
    mi ans= 0 ;
    mi dp[n+1];
    dp[1] = 1;
    dp[2] = -1;
    for(int i = 0; i < k; i++)
        cin>>range[i].first>>range[i].second;

    for(int i = 1; i <= n; i++){
        if(i > 1)
            dp[i] += dp[i-1];
        for(auto num : range){
            if(num.first + i <= n)
                dp[num.first+i] += dp[i];
            if(num.second + i + 1 <= n)
                dp[num.second+i+1] -= dp[i];
        }
    }
    cout<<dp[n];
}
int main(){ 
        hs;
        ll t;
        t=1;
        // cin>>t;
        for (int i=1; i<=t; i++){
                //cout<<"Case #"<<i<<": ";
                solve();
         }
        return 0; 
}

Measured memory_bytes: 5096
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
public class Main {

	public static void main(String[] args) throws Exception  {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();

		//3????????´??°a,b,c?????\???
		String[] num = str.split(" ");

		Arrays.sort(num);
		System.out.println(num[0]+" "+num[1]+" "+num[2]);
	}
}

Measured memory_bytes: 24468
S = input().strip()
T = input().strip()
N = len(S)
C = {}
D = {}
flag = 0
for i in range(N):
    if S[i] not in C:
        C[S[i]] = T[i]
    elif C[S[i]]!=T[i]:
        flag = 1
        break
    if T[i] not in D:
        D[T[i]] = S[i]
    elif D[T[i]] != S[i]:
        flag = 1
        break
if flag==0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 68472
#include <iostream>
#include <string>
#include <vector>
#include <queue>

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


// int main(){
//   int n,x,y;
//   std::cin >> n>>x>>y;
//   std::vector<std::vector<int> > G(n+1);
//   std::vector<int> ans(n+1,0);
//
//   for (int i = 1; i < n; i++) {
//     G[i].push_back(i+1);
//     G[i+1].push_back(i);
//   }
//   G[x].push_back(y);
//   G[y].push_back(x);
//
//
//   rep(i,n+1){
//     std::vector<int> dist(n+1,-1);
//     queue<int> que;
//     dist[i]=0;
//     que.push(i);
//
//     while (!(que.empty())) {
//       int v=que.front();
//       que.pop();
//       for (int nv : G[v]) {
//         if(dist[nv]!=-1)continue;
//         dist[nv]=dist[v]+1;
//         que.push(nv);
//       }
//       break;
//     }
//     rep(j,n+1)ifans[dist[j]]++;
//
//   }
//
//   for (int i = 1; i < n; i++)std::cout << ans[i]/2 << '\n';
//
//
//   return 0;
// }


#include <iostream>
#include <string>
#include <vector>
#include <queue>

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


int main(){
  int n,x,y;
  std::cin >> n>>x>>y;
  std::vector<std::vector<int> > G(n+1);
  std::vector<int> ans(n+1,0);

  for (int i = 1; i < n; i++) {
    G[i].push_back(i+1);
    G[i+1].push_back(i);
  }
  G[x].push_back(y);
  G[y].push_back(x);


  rep(i,n+1){
    std::vector<int> dist(n+1,-1);
    queue<int> que;
    dist[i]=0;
    que.push(i);

    while (!(que.empty())) {
      int v=que.front();
      que.pop();
      for (int nv : G[v]) {
        if(dist[nv]!=-1)continue;
        dist[nv]=dist[v]+1;
        que.push(nv);
      }
    }
    rep(j,n+1)if(dist[j]>=0)ans[dist[j]]++;

  }

  for (int i = 1; i < n; i++)std::cout << ans[i]/2 << '\n';


  return 0;
}



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

typedef long long ll;

int main() {
  ll N;
  ll A, B;
  cin >> N >> A >> B;
  ll ans;
  if (A <= B) {
    if (N > 1) {
      //ans = ((N - 2) * B - (N - 2) * A) + 1;
      ans = (N - 2) * (B - A) + 1;
    } else {
      if (A == B) ans = 1;
      else ans = 0;
    }
  } else {
    ans = 0;
  }
  // 解答
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S; cin >> S;
    if (S == "AAA" || S == "BBB") {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,K;
  int yasu=0;
  cin >> N >> K;
  vector<int>vec(N);
  for (int X=0; X<N; X++){
    cin >> vec.at(X);
  }
  sort(vec.begin(), vec.end());
  for (int X=0; X<K; X++){
    yasu+=vec.at(X);
  }
  cout << yasu << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
long long n,a[100005],ans;
vector <long long> v;
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	sort(a,a+n);
	/*v.push_back(a[0]);
	for(int i=1;i<n;i++)
	{
		if(a[i]!=a[i-1])
			v.push_back(a[i]);
	}*/
	int cur=1;
	for(int i=1;i<n;i++)
	{
		if(a[i]==a[i-1])
		{
			cur++;
		}
		else
		{
			if(cur<a[i-1])
				ans+=cur;
			cur=1;
		}
		if(cur>a[i])
		{
			ans+=(cur-a[i]);
			cur=a[i];
		}
	}
	if(cur<a[n-1])
		ans+=cur;
	cout<<ans<<"\n";
	return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define ep emplace_back
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(v) v.begin(), v.end()
#define revall(v) v.rbegin(), v.rend()
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){ if(y<h && y>=0 && x<w && x>=0) return true; return false; }
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; }





int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	vector<int> a(n);
	rep(i,n) cin >> a.at(i);
	ll sum1 = 0, sum2 = 0, ans1 = 0, ans2 = 0;
	rep(i,n){
		sum1 += a.at(i);
		sum2 += a.at(i);
		if(i % 2 == 0){
			if(sum1 <= 0){
				ans1 += 1 - sum1;
				sum1 = 1;
			}
			if(sum2 >= 0){
				ans2 += abs(-1 - sum2);
				sum2 = -1;
			}
		}
		else{
			if(sum2 <= 0){
				ans2 += 1 - sum2;
				sum2 = 1;
			}
			if(sum1 >= 0){
				ans1 += abs(-1 - sum1);
				sum1 = -1;
			}
		}
	}
	cout << min(ans1, ans2) << endl;
}


Measured memory_bytes: 640
Imports System

Module Program
    Sub Main(args As String())
        Dim tmpA As String() = Split(Console.ReadLine(), " ")

        Dim N As Long = CLng(tmpA(0))
        Dim R As Long = CLng(tmpA(1))

        Dim Score As Long = 0

        If N < 10 Then
            Score = R + 100 * (10 - N)
        Else
            Score = R
        End If


        Console.WriteLine(Score)
    End Sub
End Module


Measured memory_bytes: 13536
import java.util.*;

public class Main{
	public static void main(String[] args){
		//new Main().printHelloWorld();
		//System.out.println(new Main().ITP1_1_B(Integer.parseInt(new Scanner(System.in).next())));
		//new Main().ITP1_1_C();
		//new Main().ITP1_1_D();
		new Main().ITP1_2_A();
	}

	public void printHelloWorld(){
		System.out.println("Hello World");
	}

	public int ITP1_1_B(int x){
		return x*x*x;
	}

	public void ITP1_1_C(){
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		System.out.println(a*b + " " + 2*(a+b));
	}

	public void ITP1_1_D(){
		int seconds = new Scanner(System.in).nextInt();
		System.out.println(seconds/3600 + ":" + (seconds%3600)/60 + ":" + (seconds%3600)%60);
	}

	public void ITP1_2_A(){
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		System.out.println((a==b)?"a == b":(a > b)?"a > b":"a < b");
	}
}

Measured memory_bytes: 26100
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (ll)(n); i++)

int main() {
    ll n, k; cin >> n >> k;
    ll res = k;
    rep(i, n-1) res *= k-1;
    cout << res << endl;
}

Measured memory_bytes: 3592
#include<stdio.h>
#include<string.h>
#include<math.h>
#include <stdlib.h>
 
int main() {
    long x,k,d;
    scanf("%ld %ld %ld",&x,&k,&d);
    long t=labs(x/d);
    if (k>=t) {
        k=k-t;
        if(x>=0) {
          	x=x-t*d;
            if (k%2==1) x=labs(x-d);
          	else x=labs(x);
        } else {
          	x=x+t*d;
            if (k%2==1) x=labs(x+d);
          	else x=labs(x);
        }
    } else {
        if (x>=0) x=labs(x-k*d);
        else x=labs(x+k*d);
    }
    printf("%ld\n",x);
    return 0;
}

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

#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

using ll = long long;
using namespace std;
constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int MOD = 1000000007;

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
string s;
cin>>s;
if(s[0]>='a'){
    cout<<"a"<<endl;
}
else{
    cout<<"A"<<endl;
}
return 0;
}

Measured memory_bytes: 3648
// D.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <set>
#include <vector>

using namespace std;

typedef long long LL;

static const LL MOD = 1000000007;

int main(int argc, char *argv[]) {
	static LL dp[4][100002];
	dp[0][0] = 1;
	string s;
	cin >> s;
	for (int i = 0; i < (int)s.length(); ++i) {
		for (int j = 0; j < 4; ++j) {
			dp[j][i + 1] = s[i] == '?' ? ((dp[j][i] * 3) % MOD) : dp[j][i];
		}
		if (s[i] == 'A' || s[i] == '?') {
			dp[1][i + 1] = (dp[1][i + 1] + dp[0][i]) % MOD;
		}
		if (s[i] == 'B' || s[i] == '?') {
			dp[2][i + 1] = (dp[2][i + 1] + dp[1][i]) % MOD;
		}
		if (s[i] == 'C' || s[i] == '?') {
			dp[3][i + 1] = (dp[3][i + 1] + dp[2][i]) % MOD;
		}
	}
	cout << dp[3][(int)s.length()] << endl;
	return 0;
}


Measured memory_bytes: 3648
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

typedef tuple<int, int, int> T;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, q;
    cin >> n >> q;
    vector<T> a(n);
    vector<int> ans(q, -1);
    rep(i,n){
        int s, t, x;
        cin >> s >> t >> x;
        s -= x;
        t -= x;
        a[i] = make_tuple(x, s, t);
    }
    stable_sort(a.begin(), a.end());
    set<P> st;
    rep(i,q){
        int d;
        cin >> d;
        st.insert(make_pair(d, i));
    }
    rep(i,n){
        int x, l, r;
        tie(x, l, r) = a[i];
        auto it = st.lower_bound(P(l, -1));
        while(it != st.end()){
            if(it->first >= r) break;
            ans[it->second] = x;
            st.erase(it++);
        }
    }
    rep(i,q) cout << ans[i] << endl;
    return 0;
}


Measured memory_bytes: 15656
#include<cstdio>
int main() {
	int a[4];
	for (int i = 0; i < 4; i++)scanf("%d", &a[i]);
	a[0] += a[1];
	a[2] += a[3];
	if (a[0] == a[2])printf("Balanced");
	else if (a[0] > a[2])printf("Left");
	else printf("Right");
	return 0;
}

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

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

Measured memory_bytes: 256
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List
import Control.Monad.ST
import Data.Array.ST
import qualified Data.Vector.Unboxed as VU

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    [n,k] <- getIntList
    as <- VU.fromList <$> getIntList
    print $ solve n k as

solve n k as = runST $ do
    arr <- newArray ((-1,-1),(n,k)) 0 :: ST s (STUArray s (Int,Int) Int)
    writeArray arr (0,0) 1
    forM_ [0..n] $ \i -> do
        let ai = as VU.! (i-1)
        forM_ [0..k] $ \j -> do
            if i == 0 then
                writeArray arr (0,j) (if j == 0 then 1 else 0)
            else do
                ij1 <- readArray arr (i,j-1)
                i1j <- readArray arr (i-1,j)
                ijm <- readArray arr (i-1, max (j-ai-1) (-1))
                writeArray arr (i,j) $ (ij1 + i1j - ijm) `mod` 1000000007
    readArray arr (n,k)

Measured memory_bytes: 85372
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>
#include <fstream>
#include <complex>
#include <cstdint>
#define _USE_CMATH_DEFINES

const long INF = (1l << 30);
const long LINF = (1l << 60); //1.15*10^18

long x[5];

int main(){
    for(long i = 0; i < 5; i++){
        scanf("%ld", &x[i]);
        if(x[i] == 0){
            printf("%ld\n", i+1);
            return 0;
        }
    }
}


Measured memory_bytes: 3816
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

// Unionfind
struct UF {
	vector<int> p;

	UF() = default;
	explicit UF(int n) : p(n + 1, -1) { p.back() = n; }

	bool unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y) return false;
		if (p[x] > p[y]) swap(x, y);
		p[x] += p[y];
		p[y] = x;
		p.back()--;
		return true;
	}
	int find(int x) { return (p[x] < 0 ? x : p[x] = find(p[x])); }
	bool same(int x, int y) { return find(x) == find(y); }
	int size(int x) { return -p[find(x)]; }
	int count() { return p.back(); }
};

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

    int N, M;
    cin >> N >> M;
    UF uf(N);
    REP (i, M) {
        int X, Y, Z;
        cin >> X >> Y >> Z;
        X--; Y--;
        uf.unite(X, Y);
    }
    cout << uf.count() << endl;
}

Measured memory_bytes: 1024
/* https://atcoder.jp/contests/abc083/tasks/arc088_a */

#include <iostream>
#include <vector>
#include <cmath>

/* {{{ Variables */
long long X, Y;
/* }}} */

int main(int argc, char *argv[])
{
  /* {{{ Input */
  std::cin >> X >> Y;
  /* }}} */

  /* {{{ Output */
  int seq_len = 0;
  long long scale = 1;

  while (X*scale <= Y) {
    seq_len++;
    scale *= 2;
  }

  std::cout << seq_len << std::endl;
  /* }}} */

  return 0;
}


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

typedef long long ll;

typedef struct {
	bool to[8];
} node;

node _node[8];

int n,m;
int ans = 0;

void go(int now,bool x[8],int cnt) {
	if (cnt == n - 1) {
		/*for (int i = 0;i < 8;i++) {
			if (x[i] == true) {
				cout << i << " ";
			}
		}*/
		// cout << now << " ";
		ans++;
		return;
	}
	for(int i = 0;i < 8;i++) {
		if (_node[now].to[i] == true && x[i] == false) {
			bool y[8];
			for (int j = 0;j < 8;j++) {
				y[j] = x[j];
			}
			y[i] = true;
			go(i,y,cnt+1);
		}
	}
	return;
}

int main() {
	cin >> n >> m;
	for (int i = 0;i < 8;i++) {
		for (int j = 0;j < 8;j++) {
			_node[i].to[j] = false;
		}
	}
	for (int i = 0;i < m;i++) {
		int a,b;
		cin >> a >> b;
		_node[a-1].to[b-1] = true;
		_node[b-1].to[a-1] = true;
	}
	bool start[8] = {true,false,false,false,false,false,false,false};
	go(0,start,0);
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()
#define let auto const

template<typename... Types>
struct dynarr: std::vector<Types...> {
  using std::vector<Types...>::vector;
  using size_type = typename std::vector<Types...>::size_type;
  auto&& operator[](size_type i) { return this->at(i); }
  auto&& operator[](size_type i) const { return this->at(i); }
};

int main() {
  vector<i64> vec(4);
  rep(i,0,4) cin >> vec[i];
  sort(all(vec));
  if(vec[0] == vec[1] && vec[2] == vec[3]) {
    cout << "yes" << endl;
  }
  else {
    cout << "no" << endl;
  }
}



Measured memory_bytes: 3144
using System;
using System.Linq;

namespace Test
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var n = input[0];
            var x = input[1];
            var t = input[2];

            if (n % x == 0)
            {
                Console.WriteLine((n / x) * t);
            }
            else
            {
                Console.WriteLine((n / x + 1) * t);
            }
        }
    }
}


Measured memory_bytes: 28264
n=int(input())
ans=0
def c(i,j):
  ret=0
  for k in range(1,n+1):
    if str(k)[0]==str(i) and str(k)[-1]==str(j):
      ret+=1
  return ret
for i in range(1,10):
  for j in range(i,10):
    if i==j:
      ans+=c(i,j)*c(j,i)
    else:
      ans+=2*c(i,j)*c(j,i)
print(ans)

Measured memory_bytes: 44068
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int k,ans; 
int main()
{
	cin>>k;
    for(int a=1;a<=k;a++)
    for(int b=1;b<=k;b++)
    for(int c=1;c<=k;c++)
    {
        ans+=__gcd(__gcd(a,b),c); 
    }
cout<<ans;
return 0;
}

Measured memory_bytes: 3676
#include<stdio.h>
int main(){
  int n,i,j,v,A[100][100],a,b;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      A[i][j]=0;   
    }
  }

  for(i=0;i<n;i++){
    scanf("%d%d",&a,&b);
    for(j=0;j<b;j++){
      scanf("%d",&v);
      A[i][v-1] = 1;
    }
  }
    
    for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      printf("%d",A[i][j]);
      if(j < n-1) printf(" ");   
    }
    printf("\n");
  }
    return 0;
}

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

typedef long long ll;

int main() {
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	int n;
	cin>>n;

	ll sum = 0;

	for(int i = 1; i <= n; ++i){
		if(i%3 != 0 && i%5 != 0){
			sum += i;
		}
	}

	cout<< sum << endl;

}


Measured memory_bytes: 3640
f=lambda:map(int,input().split())
def r(x):
  while p[x]>=0: x=p[x]
  return x
def u(x,y):
  x,y=r(x),r(y)
  if x==y: return
  if x>y: x,y=y,x
  p[x]+=p[y]
  p[y]=x
n,m=f()
p=[-1]*n
for _ in range(m):
  a,b=f()
  u(a-1,b-1)
print(sum(i<0 for i in p)-1)

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

int main(){
  int N;
  cin >> N;
  vector<int> btn(N);
  for (int i = 0; i< N;i++){
    cin >> btn.at(i);
  } 
  
  int light = 1;
  for (int i = 0; i < N; i++){
    if (light == 2){
      cout << i << endl;
      return 0;
      }
    light = btn.at(light - 1);
    }
  cout << -1 << endl;
}


Measured memory_bytes: 640
currAndRot2FBLR = {
    'N':{'N':'F','E':'R','S':'B','W':'L'},
    'E':{'E':'F','S':'R','W':'B','N':'L'},
    'S':{'S':'F','W':'R','N':'B','E':'L'},
    'W':{'W':'F','N':'R','E':'B','S':'L'}
}

dice = {
    '1': {'F':'2F', 'R':'4R', 'B':'5B', 'L':'3L'},
    '2': {'F':'6F', 'R':'4F', 'B':'1F', 'L':'3F'},
    '3': {'F':'6L', 'R':'2F', 'B':'1R', 'L':'5F'},
    '4': {'F':'6R', 'R':'5F', 'B':'1L', 'L':'2F'},
    '5': {'F':'6B', 'R':'3F', 'B':'1B', 'L':'4F'},
    '6': {'F':'5B', 'R':'4L', 'B':'2F', 'L':'3R'}
}

faces = list(map(int, input().split()))
cmd = input()

## initial state
currNum = '1'
currDir = 'N'

for c in cmd:
    numDir = dice[currNum][currAndRot2FBLR[currDir][c]]
    currNum = numDir[0]
    currFBLR = numDir[1]
    currDir = {v:k for k,v in currAndRot2FBLR[currDir].items()}[currFBLR]

print(faces[int(currNum) - 1])

Measured memory_bytes: 7860
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
// 繰り返し二乗法 O(log n)
ll f[3000000] = {0}; // f(n) = (n!) % mod
//階乗テーブルの初期化を忘れない
//f[0] = f[1] = 1;
//for(int i=2; i<=w+h-2; ++i) f[i] = (i * f[i-1]) % mod;
ll mod_pow(ll x, ll n){
    ll res = 1LL;
    while(n > 0){
        if(n & 1) res = res * x % mod;
        x = x*x % mod;
        n >>= 1;
    }
    return res;
}
ll mod_inv(ll x){
    return mod_pow(x, mod-2) % mod;
}
// nCr % mod
ll comb(int n, int r){
    return (((f[n] * mod_inv(f[r])) % mod) * mod_inv(f[n-r])) % mod;
}
int main(){

    int x,y;
    cin >> x >> y;
    if((x+y)%3!=0) cout<<0<<endl;
    else{
        int n1 = (2*x-y)/3;
        int n2 = (2*y-x)/3;
        if(n1<0 || n2<0){
            cout<<0<<endl;
            return 0;
        }else{
            f[0] = f[1] = 1;
            //cout<< n1 <<" "<< n2 << endl;
            for(int i=2; i<=n1+n2+1000; ++i) f[i] = (i * f[i-1]) % mod;
            cout<<comb(n1+n2,n1)<<endl;
        }
    }

    return 0;
}

Measured memory_bytes: 6400
#include <bits/stdc++.h>
#define int long long
#define f(i,n) for(int i=0;i<n;i++)
using namespace std;main(){int x,y,z,n;cin>>x>>y>>z>>n;int a[x],b[y],c[z];vector<int>r;f(i,x)cin>>a[i];f(i,y)cin>>b[i];f(i,z)cin>>c[i];sort(a,a+x,greater<int>()),sort(b,b+y,greater<int>()),sort(c,c+z,greater<int>());f(i,x)f(j,y)f(k,z)if((i+1)*(j+1)*(k+1)<=n)r.push_back(a[i]+b[j]+c[k]);sort(r.begin(),r.end(),greater<int>());f(i,n)cout<<r[i]<<'\n';}

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

char map[101][101] ;
char d[] = { '>' , 'v' , '<' , '^' } ;
int dx[] = { 1,0,-1,0 } ;
int dy[] = { 0,1,0,-1 } ;

void move( int y , int x ){
	if( map[y][x] == '.' ) cout << x << ' ' << y << endl ;
	else if( map[y][x] == '0' ) cout << "LOOP" << endl ;
	else {
		for( int j=0 ; j<4 ; j++ ){
			if( map[y][x] == d[j] ){
				map[y][x] = '0' ;
				move( y+dy[j] , x+dx[j] ) ;
			}
		}
	}
}

int main(){
	
	int h , w ;
	
	while( cin >> h >> w , h ){
		for( int i=0 ; i<h ; i++ ){
			for( int j=0 ; j<w ; j++ ){
				cin >> map[i][j] ;
			}
		}
		
		move(0,0) ;
	}
	
return 0 ;
}

Measured memory_bytes: 1204
N, M = map(int,input().split())

num_dict = {}

if N == 0:
    print(0)
else:
    for i in range(N):
        data = list(map(int,input().split()))
        if len(data) > 1:        
            for j in range(len(data)-1):
                if data[j+1] in num_dict:
                    num_dict[data[j+1]] = num_dict[data[j+1]] + 1
                else:
                    num_dict[data[j+1]] = 1

if num_dict == {} or N not in num_dict.values():
    print(0)
else: 
    keys = [k for k, v in num_dict.items() if v == N]
    print(len(keys))

Measured memory_bytes: 3064
import java.io.PrintWriter;
import java.util.*;

public class Main {



    int gcd(int m, int n) {
        if (m < n) return gcd(n, m);
        if (n == 0) return m;
        return gcd(n, m % n);
    }

    void run() {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        int n = sc.nextInt();
        List<Integer> list = new ArrayList<>();
        boolean existsOne = false;
        for (int i = 0; i < n; i++) {
            int a = sc.nextInt();
            if (a == 1) {
                if (existsOne) {
                    continue;
                }
                existsOne = true;
            }
            list.add(a);
        }

        int gcd = list.get(0);
        for (int i = 1; i < list.size(); i++) {
            gcd = gcd(list.get(i), gcd);
        }

        if (gcd != 1) {
            System.out.println("not coprime");
            return;
        }


        if (list.size() > 80000) { // num of primes
            System.out.println("setwise coprime");
            return;
        }


        Set<Integer> set = new HashSet<>();
        for (int i = 0; i < list.size(); i++) { // 8 * 10^4
            int a = list.get(i);
            for (int j = 1; j * j <= a; j++) { // 10 ^2
                if (a % j == 0) {
                    if (j != 1) {
                        if (set.contains(j)) {
                            System.out.println("setwise coprime");
                            return;
                        }
                        set.add(j);
                    }
                    int k = a / j;
                    if (k != j) {
                       if (set.contains(k)) {
                           System.out.println("setwise coprime");
                           return;
                       }
                       set.add(k);
                    }
                }
            }
        }
        System.out.println("pairwise coprime");


        // out.println("Hello World");
        out.flush();
    }

    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

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


Measured memory_bytes: 88216
import sys
input = sys.stdin.readline

def Main(a, b):
    if(a > 0 and a < 10 and b > 0 and b < 10):
        return a*b
    else: 
        return -1

def main():
    A, B = map(int, input().split())
    print(Main(A, B))

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
import java.util.*;

/**
 * Main
 */
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int N = sc.nextInt();
		Integer Array[] = new Integer[N];
		for(int i = 0; i < N; i++){
			Array[i] = sc.nextInt();
		}
		Arrays.sort(Array);
		if(Array[N/2-1]==Array[N/2]){
			System.out.println(0);
		}else{
			System.out.println(Array[N/2]-Array[N/2-1]);
		}
		sc.close();
	}
};

Measured memory_bytes: 61132
#include<bits/stdc++.h>
using namespace std; 
int dp[8001][16002];
int a[8001];
int main()
{
	 string s;
	 int x,y;
	 cin>>s>>x>>y;
	 int a1=0;
	 int b1=0;
	 for(int i=0;i<s.size();i++)
	 {
	 	if(s[i]=='F')a1++;
	 	else
	 		if(s[i]=='T')
	 		{
	 			b1++;
			 	a[b1]=a1;
				a1=0; 	
	 		}
	 }
	 b1++;
	 a[b1]=a1;
	 dp[1][a[1]+8000]=1;
	 for(int i=3;i<=b1;i+=2)
	 {
	 	for(int j=0;j<=16000;j++)
	 	{
	 		if(j+a[i]<=16000)
	 		dp[i][j]=dp[i-2][j+a[i]];
	 		if(j-a[i]>=0)
	 		dp[i][j]=dp[i][j]||dp[i-2][j-a[i]];
	 	}
	 }
	 dp[0][8000]=1;
	 for(int i=2;i<=b1;i+=2)
	 {
	 	for(int j=0;j<=16000;j++)
	 	{
	 		if(j+a[i]<=16000)
	 		dp[i][j]=dp[i-2][j+a[i]];
	 		if(j-a[i]>=0)
	 		dp[i][j]=dp[i][j]||dp[i-2][j-a[i]];
	 	}
	 }
	 int ans=0;
	 if(b1%2==0)
	 {
	 	if(dp[b1][y+8000]&&dp[b1-1][x+8000])ans=1;
	 }
	 else
	 {
	 	if(dp[b1][x+8000]&&dp[b1-1][y+8000])ans=1;	
	 }
	 if(ans==1)cout<<"Yes";
	 	else	cout<<"No";
	return 0;
}

Measured memory_bytes: 497792
def solve(node):
    global ans
    for i in range(N-1, 0, -1):
        s = 0
        maxi = 0
        num = len(paths[i])-1

        for to in paths[i]:
            s += dp[to]
            if(maxi<dp[to]):
                maxi=dp[to]
        if(i == node and num >= 2):
            num -= 1
            s -= maxi
        
        dp[i] = s / num + 1
    if(ans>dp[1]):
        ans = dp[1]


N, M = map(int, input().split())
paths = [[0]for i in range(N + 1)]
dp = [0 for i in range(N+1)]
ans = 1e12
for i in range(M):
    s, t = map(int, input().split())
    paths[s].append(t)
for i in range(N):
    solve(i)
print(ans)

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

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

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

int main() {
  double x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  cout << fixed << setprecision(8) << sqrt(pow(x2 - x1, 2) + pow(y2 - y1, 2)) << endl;
  return 0;
}



Measured memory_bytes: 3280
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;

int main()
{
    int H, W;
    cin >> H >> W;
    vector<vector<char>> img(H, vector<char>(W));
    for (int i = 0; i < H; ++i)
    {
        for (int j = 0; j < W; ++j)
        {
            cin >> img[i][j];
        }
    }
    for (int i = 0; i < W + 2; ++i) cout << '#';
    cout << endl;
    for (int i = 0; i < H; ++i)
    {
        cout << '#';
        for (int j = 0; j < W; ++j)
        {
            cout << img[i][j];
        }
        cout << '#' << endl;
    }
    for (int i = 0; i < W + 2; ++i) cout << '#';
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
f=->x,y,s,t{(x-s).abs+(y-t).abs};i=->{gets.split.map &:to_i};N,M=i[];A=(1..N).map{i[]};C=(1..M).map{i[]};A.map{|a,b|i=0;p C.map{|c,d|i+=1;[f[a,b,c,d],i]}.sort[0][1]}

Measured memory_bytes: 1788
#include <stdio.h>
#include <stdlib.h>
#define N 100000
#define INF 1000000

typedef struct{
  int v;
  int b;
  int c;
}data;

void Single(int);

int n,A[N];
data G[500000];

int main()
{
  int i,u,k,j,cnt=0;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    G[i].v = -1;
    G[i].b = -1;
    G[i].c = -1;
}
  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    for(j=0;j<k;j++){
      G[cnt].b = u;
      scanf("%d%d",&G[cnt].v,&G[cnt].c);
      cnt++; //入れた回数をカウント
    }
  }
  
  Single(cnt); //入れた回数分処理するために引数にいれる

  return 0;
}

void Single(int num)
{
  int i,flag=0;

  for(i=0; i<n; i++)
    A[i] = INF; //初期化
  A[0] = 0; //始点

  while(flag != 1){
    flag = 1;
    for(i=0;i<num;i++){
      if(G[i].c + A[G[i].b] < A[G[i].v]){
	A[G[i].v] = G[i].c + A[G[i].b];
	flag = 0;
      }
    }
  }
    for(i=0;i<n;i++)
      printf("%d %d\n",i,A[i]);
}



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

#define endl "\n"
// g++ a.cpp -o a

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

    char s;
    cin >> s;

    int n = int(s);

    if(n <= 90) {
        cout << 'A' << endl;
    }
    else{
        cout << 'a' << endl;
    }

    return 0;
}

Measured memory_bytes: 3636
#pragma GCC optimize ("O3")
// #pragma GCC target ("avx")
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
#include<queue>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}


void MAIN() {
    int N;
    scanf("%d", &N);
    LL ans = 0;
    vector<pair<int, int> > L, R;

    REP (i, N) {
	int k, l, r;
	scanf("%d%d%d", &k, &l, &r);
	int g = min(l, r);
	ans += g;
	l -= g;
	r -= g;
	if (l < r) {
	    R.emplace_back(k, r);
	} else {
	    L.emplace_back(k, l);
	}
    }

    sort(L.begin(), L.end());
    sort(R.begin(), R.end());

    {
	priority_queue<int> Q;
	int idx = (int)L.size()-1;
	for (int pos=L.size(); pos--;) {
	    while (idx >= 0 && L[idx].first > pos) {
		Q.emplace(L[idx].second);
		idx--;
	    }

	    if (Q.size()) {
		ans += Q.top();
		Q.pop();
	    }
	}
    }
    {
	priority_queue<int> Q;
	int idx = 0;
	for (int pos=L.size(); pos<N; pos++) {
	    while (idx < (int)R.size() && R[idx].first <= pos) {
		Q.emplace(R[idx].second);
		idx++;
	    }

	    if (Q.size()) {
		ans += Q.top();
		Q.pop();
	    }
	}
    }

    printf("%lld\n", ans);
}

int main() {
    int TC = 1;
    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



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

long long N;

int main() {
  cin >> N;
  cout << (1 + N - 1) * (N - 1) / 2 << endl;
  return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    long long int i, ii, k, d, mon,n,tmp, kab, a[200001];
    long long int max;
    scanf("%lld", &n);
    for (i = 0; i < n; i++)
        scanf("%lld", a + i);
    mon = 1000 % a[0];
    kab = 1000/a[0];
    max = 1000;
    for (d = 1; d < n; d++)
    {
        if (a[d] < a[d - 1])
        {
            mon = max % a[d];
            kab = max / a[d];
        }
        else if (a[d] > a[d - 1])
            max = mon + kab * a[d];
        
    }
    printf("%lld", max);
}


Measured memory_bytes: 1732
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct Node {
    int key;
    struct Node *next,*prev;
};

struct Node *nil;

struct Node* listSearch(int key){
    struct Node *cur = nil->next; 
    while( cur != nil && cur->key != key){
        cur=cur->next;
    }
    return cur; }

void input(){ 
    nil = (struct Node *)malloc(sizeof(struct Node));
    nil->next=nil;
    nil->prev=nil;
}

void print(){
    struct Node *cur = nil->next;
    int i = 0;
    while(1){
        if( cur == nil) break;
        if( i++>0 ) printf(" ");
        printf("%d",cur->key);
        cur = cur->next;
    }
    printf("\n");
}

void deleteNode(struct Node *t){
    if(t==nil) return; 
    t->prev->next = t->next;
    t->next->prev = t->prev;
    free(t);
}

void deletefirst(){
    deleteNode(nil->next);
}

void deletelast(){
    deleteNode(nil->prev);
}

void deleteKey(int key){
    deleteNode(listSearch(key));
}

void insert(int key){
    struct Node *x = (struct Node *)malloc(sizeof(struct Node));
    x->key = key; 
    x->next = nil->next;
    nil->next->prev = x;
    nil->next = x;
    x->prev = nil;
}

int main(){
    int key,n,i;
    int size = 0;
    char com[20];
    int np=0,nd=0;
    
    scanf("%d",&n);
    
    input();
    
    for(i=0;i<n;i++){
        scanf(" %s %d",com,&key);
        if( com[0] == 'i'){
            insert(key);
            np++;
            size++;
        }else if( com[0] == 'd'){
            if(strlen(com) > 6){
                if(com[6]=='F') deletefirst();
                else if( com[6]=='L') deletelast();
            }else{
                deleteKey(key);
                nd++;
            }
            size--;
        }
    }
    
    print();
    
    return 0;
    
}



Measured memory_bytes: 32956