akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int A=scan.nextInt();
		int B=scan.nextInt();
		int C=scan.nextInt();
		if(A+B>=C)
		{
			System.out.println("Yes");
		}
		else
		{
			System.out.println("No");
		}

	}

}


Measured memory_bytes: 35784
import java.util.*;

public class Main{
    void solve(){
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        Integer[] a = new Integer[n];
        for(int i = 0; i < n; i++) a[i] = scan.nextInt();
        int[] b = new int[n];
        for(int i = 0; i < n; i++) b[i] = scan.nextInt();
        Integer[] c = new Integer[n];
        for(int i = 0; i < n; i++) c[i] = scan.nextInt();
        Arrays.sort(a);
        Arrays.sort(b);
        Arrays.sort(c);
        long out = 0;
        for(int i = 0; i < n; i++){
            long ca = ~Arrays.binarySearch(a, b[i], (x, y) -> x.compareTo(y) >= 0 ? 1 : -1);
            long cc = n - ~Arrays.binarySearch(c, b[i], (x, y) -> x.compareTo(y) > 0 ? 1 : -1);
            out += ca * cc;
        }
        System.out.println(out);
    }
    
    public static void main(String[] args){
        new Main().solve();
    }
}


Measured memory_bytes: 63948
import sys
def I(): return(int(sys.stdin.readline())) 
def LI(): return(list(map(int,sys.stdin.readline().split())))

def main():
    N = I()
    H = LI()
    for i in range(N-2,-1,-1):
        if H[i]>H[i+1]+1:
            return("No")
        if H[i]==H[i+1]+1:
            H[i] -= 1
    return("Yes")
    
    
if __name__ == "__main__":
    print(main())


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

using ll = long long int;

const ll MAX_N = (ll)(1e5 + 100);
const ll MOD = (ll)(1e9 + 7);

ll n, m;

map<ll, ll> cnt;

ll ans = 1;

/////////////////////////////////////////////////////////////
class CombinationModula {
public:
  const ll MOD = (ll)(1e9 + 7);

  ll fact[MAX_N];
  ll inv[MAX_N];
  ll fact_inv[MAX_N];

  CombinationModula(ll n) {
    init(n);
  }

  void init(ll n) {
    inv[1] = fact[0] = fact_inv[0] = 1;
  	for (int i = 2; i <= n; i++) inv[i] = (MOD - (MOD / i) * inv[MOD % i] % MOD) % MOD;
  	for (int i = 1; i <= n; i++) fact[i] = fact[i - 1] * i % MOD;
  	for (int i = 1; i <= n; i++) fact_inv[i] = fact_inv[i - 1] * inv[i] % MOD;
  }

  ll comb(ll n, ll r) {
    if (r > n) return 0;
  	return fact[n] * fact_inv[r] % MOD * fact_inv[n - r] % MOD;
  }
};
/////////////////////////////////////////////////////////////

map<ll, ll> prime_factorization(ll n) {
  map<ll, ll> res;
  for (ll i = 2; i * i <= n; ++i) {
    while (n % i == 0) {
      res[i] += 1;
      n /= i;
    }
  }

  if (n != 1) res[n] = 1;
  return res;
}

int main(void) {
  // Here your code !
  scanf("%lld %lld", &n, &m);

  cnt = prime_factorization(m);

  CombinationModula comb_mod(n + 100);

  for (auto itr = cnt.begin(); itr != cnt.end(); ++itr) {
    ans *= comb_mod.comb(n - 1 + itr->second, n - 1);
    ans %= MOD;
  }

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

  return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
long long n,m,k,ans=0,a,b,c,d;
string s,alph="abcdefghijklmnopqrstuvwxyz",t,u;
int main(){
  cin >> n;
  if(n==1){
    cout << 1 << endl;
    return 0;
  }
  for(int i=2;i<=n;i++){
    for(int j=2;j<n;j++){
      a=pow(i,j);
      if(a==n){
        cout << n << endl;
        return 0;
      }else if(a>n){
        if(j>2){
          ans=max(ans,a/i);
        }
        break;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    private static Scanner scan = new Scanner(System.in);

    public static void main(String[] args) {
	int X = Integer.parseInt(scan.next());

	int count = 0;
	int i = 1;
	while(X > 0) {
	    count++;
	    X -= i;
	    i++;
	}

	System.out.println(count);
	scan.close();
    }
}


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

using namespace std;

int main()
{
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int dx = x2 - x1;
    int dy = y2 - y1;

    cout << dx - dy + x1 << ' ' << dx + dy + y1 << ' ' << -dy + x1 << ' ' << dx +y1 << endl;

}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#include <bitset>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < (n); i++)

using namespace std;

void solve() {
  string S;
  cin >> S;
  vector<long> result(S.size(), 1);
  rep (i, S.size()) {
    if (S[i] == 'L') continue;
    if (S[i + 1] == 'L') continue;
    result[i+2] += result[i];
    result[i] = 0;
  }
  for (long i = S.size() - 1; i >= 0; i--) {
    if (S[i] == 'R') continue;
    if (S[i - 1] == 'R') continue;
    result[i-2] += result[i];
    result[i] = 0;
  }
  bool flag = false;
  for (auto it: result) {
    if (flag) cout << " ";
    flag = true;
    cout << it;
  }
  cout << endl;
}

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


Measured memory_bytes: 1488
#include <iostream>
#include <vector>
#include <cmath>
#include <numeric>
#include <cassert>

double distance(const std::vector<int>& v0, const std::vector<int>& v1)
{
    assert(v0.size() == v1.size());
    double L2 = std::inner_product(v0.begin(), v0.end(), v1.begin(), 0,
            std::plus<>(), [](int x0, int x1)->int{ return std::pow(x1-x0, 2); });
    return std::sqrt(L2);
}

int main()
{
    int N;
    int D;
    std::cin >> N >> D;
    std::vector<std::vector<int>> X(N, std::vector<int>(D, 0));

    for (int n = 0; n < N; ++n)
    {
        for (int d = 0; d < D; ++d)
        {
            std::cin >> X[n][d];
        }
    }

    int count = 0;
    for (int i = 0; i < N; ++i)
    {
        for (int j = i + 1; j < N; ++j)
        {
            const double d = distance(X[i], X[j]);
            if (d == std::ceil(d))
            {
                ++count;
            }
        }
    }
    std::cout << count << std::endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int redNum = sc.nextInt();
        int greenNum = sc.nextInt();
        int blueNum = sc.nextInt();
        int operation = sc.nextInt();
        sc.close();

        int needTime = 0;
        while(greenNum<=redNum){
            greenNum = greenNum * 2;
            needTime++;
        }
        while(blueNum<=greenNum){
            blueNum = blueNum * 2;
            needTime++;
        }

        if(needTime>operation){
            System.out.println("No");
        }
        else{
            System.out.println("Yes");
        }
    }
}

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

#define ll long long
#define mod 1000000007
#define pii pair<ll,ll>

#define debug(a) { cout << #a << " = " << a << endl;}

const int maxn = 1001;
ll arr[maxn];
unordered_map<string,bool> u;

ll __min(ll a, ll b) {
    return a < b ? a : b;
}

ll __max(ll a, ll b) {
    return a > b ? a : b;
}

ll tr(int i, int j, int k) {
	if (arr[i] >= arr[j] + arr[k] || arr[j] >= arr[i] + arr[k] || arr[k] >= arr[i] + arr[j])
		return false;
	return true;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
	u.clear();
	ll n;
	cin >> n;
	unordered_map<ll,ll> cnt;
	for (int i=0;i<n;i++) cin>>arr[i],cnt[arr[i]]++;
	//sort(arr,arr+n);
	ll ans =0;
	for (int i=0;i<n;i++) {
		for (int k=0;k<i;k++) {
			for (int j=0;j<k;j++) {
				if (arr[i]!=arr[j]&&arr[j]!=arr[k]&&arr[k]!=arr[i]&&tr(i,j,k)) {
					//cout << j+1 << "-" << k+1 << "-" << i+1 << "\n";
					ans ++;
				}
			}
		}
	}
	cout << ans << "\n";
}



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

int main(){
  int k,n;
  cin >> k >> n;
  VI a(n);
  rep(i,n){
    cin >> a.at(i);
  }
  VI b(n);
  rep(i,n-1){
    b.at(i)=a.at(i+1)-a.at(i);
  }
  b.at(n-1)=a.at(0)+k-a.at(n-1);
  int bmax=0;
  rep(i,n){
    bmax = max(bmax, b.at(i));
  }
  cout << k-bmax <<endl;
      
      
}

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

using namespace std;

struct random_class {
	struct xorshift {
		using result_type = unsigned int;
		result_type x=123456789u,y=362436069u,z=521288629u,w;
		static constexpr result_type min() {return 0u;}
		static constexpr result_type max() {return UINT_MAX;}
		xorshift(result_type a) : w(a) {}
		result_type operator()() {
			result_type t;
			t = x ^ (x << 11);
			x = y; y = z; z = w;
			return w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));
		}
	};
	random_device rd;
	xorshift xor128;
	random_class() : rd(), xor128(rd()) {}
	random_class(unsigned int seed) : rd(), xor128(seed) {}
	double make_random(double min_v, double max_v) { return uniform_real_distribution<double>(min_v, max_v)(xor128);}
};

random_class R(123);

template<class T>
struct Treap {
	struct node {
		T val;
		double pri;
		node *lch, *rch;
		int cnt;
		node(T v) : val(v), lch(nullptr), rch(nullptr), cnt(1) {
			pri = R.make_random(DBL_MIN, DBL_MAX);
		}
	};
	node* top;
	Treap(node* t = nullptr) : top(t) {}
	node* update(node* n) {
		n->cnt = count(n->lch) + count(n->rch) + 1;
		return n;
	}
	inline int count(node* n) {
		return !n ? 0 : n->cnt;
	}
	node* merge(node* l, node* r) {
		if (!l || !r) return !l ? r : l;
		if (l->pri > r->pri) {
			l->rch = merge(l->rch, r);
			return update(l);
		} else {
			r->lch = merge(l, r->lch);
			return update(r);
		}
	}
	pair<node*, node*> split(node* t, int k) {
		if (!t) return make_pair(nullptr, nullptr);
		if (k <= count(t->lch)) {
			pair<node*, node*> s = split(t->lch, k);
			t->lch = s.second;
			return make_pair(s.first, update(t));
		} else {
			pair<node*, node*> s = split(t->rch, k - count(t->lch) - 1);
			t->rch = s.first;
			return make_pair(update(t), s.second);
		}
	}
	void insert(const T&& val) {
		int pos = 0;
		node* n = top;
		while (n) {
			if (val < n->val) n = n->lch;
			else pos += count(n->lch) + 1, n = n->rch;
		}
		auto t = split(top, pos);
		n = merge(t.first, new node(val));
		top = update(merge(n, t.second));
	}
	const T& at(int idx) {
		node* n = top;
		int sz;
		while ((sz = count(n->lch)) != idx) {
			if (sz + 1 <= idx) idx -= sz + 1, n = n->rch;
			else n = n->lch;
		}
		return n->val;
	}
	inline const int size() {
		return count(top);
	}
	// void dfs(node* n) {
	// 	if (!n) return;
	// 	cout << "node " << n->val << " ";
	// 	if (n->lch) cout << "left : " << n->lch->val << " ";
	// 	if (n->rch) cout << "right : " << n->rch->val << " ";
	// 	cout << endl;
	// 	dfs(n->lch);
	// 	dfs(n->rch);
	// }
	// void print() {
	// 	dfs(top);
	// }
};

int main() {
	Treap<int> T;
	int N;
	cin >> N;
	vector<int> v;
	for (int i = 0; i < N; i++) {
		int t; cin >> t;
		T.insert(t-i);
		v.push_back(t-i);
	}
	int b = T.at(N / 2);
	long long res = 0;
	for (auto x : v) {
		res += abs(x - b);
	}
	cout << res << endl;
}

Measured memory_bytes: 10356
from itertools import accumulate
from bisect import bisect_right
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a = list(accumulate(A))
b = list(accumulate(B))

ans = 0
for i in range(N):
    tmp = a[i]
    if tmp <= K:
        j = bisect_right(b, K-tmp)
        ans = max(ans, i+j+1)
ans = max(ans, bisect_right(b, K))
print(ans)


Measured memory_bytes: 47400
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iomanip>

using namespace std;

int main()
{
  string S;
  cin >> S;

  int abs_min = 753 - 111;
  for (int i = 0; i < (int)S.size()-2; ++i)
  {
    int sum = (S[i] - '0') * 100 + (S[i + 1] - '0') * 10 + (S[i + 2] - '0');
    if (abs(753 - sum) < abs_min) abs_min = abs(753 - sum);
  }
  cout << abs_min << endl;
}

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

const int INF = 1000000000;

int main() {
    int H, N;
    cin >> H >> N;
    vector<int> A(N), B(N);
    for (int i = 0; i < N; i++) cin >> A[i] >> B[i];

    vector<vector<int>> dp(N + 1, vector<int>(20001, INF));
    dp[0][0] = 0;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j <= 20000; j++) {
            dp[i + 1][j] = min(dp[i][j], dp[i + 1][j - A[i]] + B[i]);
        }
    }

    int res = INF;
    for (int i = H; i <= 20000; i++) {
        res = min(res, dp[N][i]);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 78592
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
const int maxn=2e5+10;
#define INF 1e9
int n,m;
struct Edge
{
    int u,v,w;
    Edge(int u,int v,int w):u(u),v(v),w(w) {}
};

struct Node
{
    int d,u;
    Node(int d,int u):d(d),u(u) {}
    bool operator <(const Node &rhs)const
    {
        return d > rhs.d;
    }
};

vector<Edge> edges;
vector<int> G[maxn];
bool done[maxn];
int d[maxn];

void init()
{
    for(int i=0; i<n; i++)
        G[i].clear();
    edges.clear();
}

void AddEdge(int u,int v,int w)
{
    edges.push_back(Edge(u,v,w));
    int mm=edges.size();
    G[u].push_back(mm-1);
}

void dijkstra()
{
    priority_queue<Node> Q;
    for(int i=0; i<=n; i++) d[i]=INF;
    d[0]=0;
    memset(done,0,sizeof(done));
    Q.push(Node(d[0],0));

    while(!Q.empty())
    {
        Node x=Q.top();
        Q.pop();
        int u=x.u;
        if(done[u]) continue;
        done[u]=true;

        for(int i=0; i<G[u].size(); i++)
        {
            Edge e=edges[G[u][i]];
            if(d[e.v] > d[u]+e.w)
            {
                d[e.v] = d[u]+e.w;
                Q.push(Node(d[e.v],e.v));
            }
        }
    }
}

int main()
{
   
    while(scanf("%d%d",&n,&m)==2)
    {
        
        init();
        for(int i=0; i<m; i++)
        {
            int u,v,d;
            scanf("%d%d",&u,&v);
            u--,v--;
            AddEdge(u,v,1);
            AddEdge(v,u,1);
        }
        dijkstra();
      
        if(d[n-1]>2)
        	puts("IMPOSSIBLE");
        else
        	puts("POSSIBLE");
    }
    return 0;
}


Measured memory_bytes: 20012
#include <stdio.h>
#include <stdlib.h>
#define N_MAX 210000

int n;
long long a[N_MAX];
long long k;

int cmpfunc ( const void * a, const void * b ){
    
    if ( *(long long *)a < *(long long *)b ){
        return -1;
    } else if ( *(long long *)a == *(long long *)b ){
        return 0;
    } else if ( *(long long *)a > *(long long *)b ){
        return 1;
    }
}

long long count( long long x ){
    
    long long total = 0;
    
    for ( int i=0; i<n; i++ ){
        if ( a[i] < 0 ){
            int l = -1;
            int r = n;
            while ( l+1 < r ){
                int c = (l+r)/2;
                if ( a[c] * a[i] < x ) r = c;
                else                   l = c;
            }
            total += n-r;
        } else {
            int l = -1;
            int r = n;
            while ( l+1 < r ){
                int c = (l+r)/2;
                if ( a[c] * a[i] < x ) l=c;
                else                   r=c;
            }
            total += r;
        }
        if ( a[i] * a[i] < x ) total--;
    }
    total /= 2;
    return total;
}


int main(){
    
    if ( scanf("%d %lld",&n,&k) != 2 ){
        printf("N,K,読み込み失敗\n");
        exit (-1);
    }
    
    for ( int i=0; i<n; i++ ){
        int check = scanf("%lld",&a[i]);
        if ( check != 1 ){
            printf("a[%d]読み込み失敗\n",i);
            exit (-1);
        }
    }
    
    qsort( a, n, sizeof(long long), cmpfunc );
    
    long long l = -((long long)1.0e18)-1;
    long long r =  ((long long)1.0e18)+1;
    
    while ( l+1 < r ){
        
        long long x = (l+r)/2;
        //printf("count(x) : %lld\n",count(x));
        if ( count(x) < k ) l=x;
        else                r=x;
        //printf("x        : %lld\n",x);
        //printf("\n");
    }
    
    //printf("k : %lld\n",k);
    printf("%lld\n",l);
    
}


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

int main(){
  while(1){
      int m,nmin,nmax,max,ans=0,ansp=0;
  int p[201];
  cin>>m>>nmin>>nmax;
  if(m+nmin+nmax==0) break;
  for(int i=0;i<m;i++)cin>>p[i];
  sort(p,p+m);
  for(int i=nmin;i<=nmax;i++){
    max=p[m-i]-p[m-i-1];
    if(ans<=max)ans=max,ansp=i;
  }
  cout<<ansp<<endl;
  }
  return 0;
}

Measured memory_bytes: 1180
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll a, b;
    cin >> a >> b;
    cout << a * b / __gcd(a, b);
}


Measured memory_bytes: 256
n, m = map(int, input().split())
can_open = []
cost = []
for _ in range(m):
    a, b = map(int, input().split())
    cost.append(a)
    it = map(int, input().split())
    x = 0
    for c in it:
        x += 1 << (c-1)
    can_open.append(x)

n_bit = 1 << n
INF = 10**18
dp = [INF]*n_bit
dp[0] = 0

for i in range(m):
    for j in range(n_bit):
        dp[j | can_open[i]] = min(dp[j | can_open[i]], dp[j]+cost[i])

print(dp[-1] if dp[-1] != INF else -1)

Measured memory_bytes: 45784
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ll N;
  cin >> N;
  ll T[N];
  for (int i = 0; i < N; i++) {
    cin >> T[i];
  }
  for (int i = 1; i < N; i++) {
    T[i] = (T[i] / __gcd(T[i] , T[i - 1])) * T[i - 1];
  }
  cout << T[N - 1] << endl;
  return 0;
}

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

using namespace std;

int main(){
  int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int k;
  cin>>k;
  cout<<a[k-1];
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
	char a;
	cin >> a;
	if (a == 'A') cout << "T" << endl;
	else if (a == 'T') cout << "A" << endl;
	else if (a == 'G') cout << "C" << endl;
	else if (a == 'C') cout << "G" << endl;
}

Measured memory_bytes: 256
n = int(input())
hs = [int(i) for i in input().split()]

maxmove = 0
nowrecord = 0

for i in range(n-1):
  if hs[i+1] > hs[i]:
    nowrecord = 0
  else:
    nowrecord += 1
  maxmove = max(maxmove, nowrecord)

print(maxmove)

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

int main() {
	int k,n;
	string s,ans="";
	cin>>k>>s;
	n = s.length();
    if(n<=k)
    {
        cout<<s<<endl;
    }
    else{
        for(int i=0;i<k;i++)
        {
            ans +=s[i];
        }
        ans += "...";
        cout<<ans<<endl;
    }
	return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define int long long
using namespace std;

typedef pair<int, int> Pii;

template<typename T>
void readvec(vector<T> &a);
void readindex(vector<int> &a);



signed main(){

    int A, B;
    cin >> A >> B;
    string S;
    cin >> S;

    string ans = "Yes";

    REP(i, A + B + 1){
        int x = (int)(S[i] - '0');
        if(i != A && (!(0 <= x && x <= 9))) ans = "No";
    }
    if(S[A] != '-') ans = "No";

    cout << ans;
    
    return 0;
}


template<typename T>
void readvec(vector<T> &a){
    REP(i, a.size()){
        cin >> a[i];
    }
}
void readindex(vector<int> &a){
    REP(i, a.size()){
        cin >> a[i];
        a[i]--;
    }
}

Measured memory_bytes: 256
package main

import (
    "fmt"
)

func main() {
    var N int
	is_prime := [55555+1]bool{}
	for i:= 2; i < len(is_prime); i++ {
		is_prime[i] = true
	}
	num :=[]int64{}
	for i := (int64)(2); i < (int64)(len(is_prime)); i++ {
		if (is_prime[i]) {
			if (i%5 == 1){
				num = append(num, i)
			} 
			for j:=i*i; j < (int64)(len(is_prime)); j+=i {
				is_prime[j] = false
			}
		}
	}

    fmt.Scan(&N)
	for i:= 0; i < N; i++ {
		fmt.Print(num[i])
		fmt.Print(" ")
	}
}

Measured memory_bytes: 640
fun main(args : Array<String>) {
    val (n, m, k) = readLine()!!.split(" ").map { it.toInt() }
    val excl = Array(n) { mutableListOf<Int>() }
    val unionFind = UnionFind(n)

    repeat(m) { rep ->
        val (a, b) = readLine()!!.split(" ").map { it.toInt() - 1 }
        excl[a].add(b)
        excl[b].add(a)
        unionFind.merge(a, b)
    }

    repeat(k) { rep ->
        val (c, d) = readLine()!!.split(" ").map { it.toInt() - 1 }
        if (unionFind.isSame(c, d)) {
            excl[c].add(d)
            excl[d].add(c)
        }
    }

    println((0 until n).map {
        unionFind.size(it) - excl[it].size - 1
    }.joinToString(separator = " "))
}

private data class UnionFind(val initSize: Int) {
    private val parents = IntArray(this.initSize) { it }
    private val sizes = LongArray(this.initSize) { 1L }

    fun root(idx: Int): Int {
        if (idx == parents[idx]) return idx

        val rootP = root(parents[idx])
        parents[idx] = rootP
        return rootP
    }

    // NOTE: merge to the larger group
    fun merge(p1: Int, p2: Int) {
        if (this.isSame(p1, p2)) return

        val rootP1 = root(p1)
        val rootP2 = root(p2)

        if (this.sizes[rootP1] >= this.sizes[rootP2]) {
            this.sizes[rootP1] += this.sizes[rootP2]
            this.parents[rootP2] = this.parents[rootP1]
        } else {
            this.sizes[rootP2] += this.sizes[rootP1]
            this.parents[rootP1] = this.parents[rootP2]
        }
    }

    fun isSame(p1: Int, p2: Int): Boolean {
        return this.root(p1) == this.root(p2)
    }

    fun size(idx: Int): Long {
        return this.sizes[this.root(idx)]
    }
}

Measured memory_bytes: 90700
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define MAX 100005
#define MOD 1000000007
#define INF 1e9
#define vi vector<int>
#define vl vector<ll> 
#define pii pair<int,int>
#define pll pair<ll,ll> 
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define error(args...) { vector<string> _v = split(#args, ','); err(_v.begin(), args); cerr<<'\n';}
vector<string> split(const string& s, char c) { vector<string> v; stringstream ss(s); string x; while (getline(ss, x, c)){ v.emplace_back(x);} return move(v); }
void err(vector<string>::iterator it) {}
template<typename T, typename... Args> void err(vector<string>::iterator it, T a, Args... args) { cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << ", "; err(++it, args...); }
//int bit[MAX], p[MAX];
//void upd(int i, int v=1) {while(i < MAX){bit[i] += v; i += i&-i;}}
//int read(int i) {int s=0; while(i > 0){s += bit[i]; i -= i&-i;} return s;}
//int fs(int i) {while(i != p[i]){p[i]=p[p[i]]; i=p[i];} return i;}
//ll modexp(ll a, ll b, ll c=MOD) { ll res=1;while(b){res=b&1?(res*a)%c:res; a=(a*a)%c; b>>=1;} return res; }
// auto f = [](int a, int b) -> int { return a+b; };

int main()
{
	int n,k,i,x,c=1;
	cin>>n>>k;
	for(i=0;i<n;++i)
	{
		if(2*c - c < k) c = c*2;
		else c += k;
	}
	cout<<c<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> b(n);
  int i,j = 0;
  for(i = 0; i< n;i++){
    cin >> a[i];
  }
  for(i = 0; i< n;i++){
    if(a[i] < 0)j++;
  }
  for(i = 0; i< n;i++){
    b[i] = abs(a[i]);
  }
  sort(b.begin(), b.end());
  long ans = 0;
  if(j %2 ==1){
    ans = b[0] * -1;
    for(i = 1; i< n;i++){
      ans += b[i];
    }
  }else{
    for(i = 0; i< n;i++){
      ans += b[i];
    }
  } 
  cout << ans << endl;
}

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

#define MAXN (100010)

int n, fa[MAXN], sz[MAXN];
std::set<int> set[MAXN];
std::queue<std::pair<int, int> > queue;

int getfather(int x) { return x == fa[x] ? x : fa[x] = getfather(fa[x]); }

int main(){
	scanf("%d", &n);
	
	for(int i = 1; i <= n; ++ i){
		fa[i] = i;
		sz[i] = 1;
	}
	
	for(int i = 0; i < ((n - 1) << 1); ++ i){
		int u, v;
		scanf("%d%d", &u, &v);
		if(set[u].count(v)){
			queue.push({u, v});
		}
		else{
			set[u].insert(v);
			set[v].insert(u);
		}
	}
	
	while(!queue.empty()){
		int u = queue.front().first, v = queue.front().second;
		queue.pop(); 
		u = getfather(u); v = getfather(v);
		
		assert(u != v);
		
		if(sz[u] > sz[v]) std::swap(u, v);
		fa[u] = v;
		sz[v] += sz[u];
		getfather(u);
		
		for(auto w : set[u]){
			set[w].erase(u);
			if(w == v) continue;
			if(set[v].count(w)){
				queue.push({w, v});
			}
			else{
				set[v].insert(w);
				set[w].insert(v);
			}
		}
		
		set[u].clear();
	}
	
	printf(sz[getfather(1)] == n ? "YES\n" : "NO\n");
	return 0;
}

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

using namespace std;

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

int main(int argc, char** argv) {
  int n;
  cin >> n;
  int a[n];
  rep(i, n) {
    cin >> a[i];
  }

  if (n == 1) { // Early return
    cout << "Yes";
    return 0;
  }

  int left = a[0];
  for (int i = 1; i < n; ++i) {
    if (a[i] == left) { // OK
      // Do nothing
    } else if (a[i] > left) { // OK
      a[i] -= 1;
      // Do nothing
    } else {
      cout << "No";
      return 0;
    }

    left = a[i];
  }

  // rep(i, n) {
  //   cout << "a[" << i << "]:" << a[i] << endl;
  // }

  cout << "Yes";
  return 0;
  // cout << n << endl;
  // cout << a[0] << endl;
  // cout << a[1] << endl;
}


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

int main() {
    int A, B, C, D, E;
    cin >> A >> B >> C >> D >> E;

    int a, b, c, d, e, ans;

    if (A % 10 != 0) a = 10 - A % 10;
    else a = 0;
    if (B % 10 != 0) b = 10 - B % 10;
    else b = 0;
    if (C % 10 != 0) c = 10 - C % 10;
    else c = 0;
    if (D % 10 != 0) d = 10 - D % 10;
    else d = 0;
    if (E % 10 != 0) e = 10 - E % 10;
    else e = 0;

    ans = A + B + C + D + E + a + b + c + d + e - max(a, max(b, max(c, max(d, e))));
   
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int d=0;
  int c[26]={0};
  int s[365][26]={0};
  
  int lastDay[27]={0};
  int tmp=0;
  int i,j;
  
  scanf("%d",&d);

  for(i=0;i<26;i++){
    scanf("%d",&c[i]);
  }
  
  for(i=0;i<365;i++){
    for(j=0;j<26;j++){
      scanf("%d",&s[i][j]);
    }
  }

  for(i=0;i<365;i++){
    int max_t=1;
    int max=s[i][0]-(c[0]*((i+1)-lastDay[max_t]));
    for(j=1;j<26;j++){
      if(s[i][j]-(c[j]*((i+1)-lastDay[j+1]))>max){
	max_t=j+1;
	max=s[i][j]-(c[j]*((i+1)-lastDay[j+1]));
      }
    }
    lastDay[max_t]=i+1;
    printf("%d\n",max_t);
  }

  return 0;
}


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

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

  for (int i{}; i < (1 << (s.length() - 1)); ++i) {
    ostringstream oss;
    int num{s[0] & 0xF};
    oss << s[0];
    for (int j{}; j < s.length() - 1; ++j) {
      if (i & (1 << j)) {
        oss << '+';
        num += s[j+1] & 0xF;
      } else {
        oss << '-';
        num -= s[j+1] & 0xF;
      }
      oss << s[j+1];
    }
    if (num == 7) {
      cout << oss.str() << "=7" << endl;
      break;
    }
  }

  return 0;
}


Measured memory_bytes: 256
/*No.1192 Tax Rate Changed*/

#include <stdio.h>

int main(void)
{
  FILE *fp;  
  int X_tax;        /*?¶?????¨???? ?????´???*/
  int Y_tax;        /*?¶?????¨???? ?????´???*/
  int X_price;      /*?????´????¨???????????¨??????????*/
  int Y_price;      /*?????´????¨???????????¨??????????*/
  int price_sum;    /*?¶?????¨?????????´???????????????????¨????????¨???????*/
  int max_price=0;  /*??°?¶?????¨??????§????¨????????¨???????????????§*/
  int price_A;      /*??????????????????????¨??????????????£?*/;
  int price_B ;     /*??????????????????????¨??????????????£?*/;

    while(1)
   {
      scanf("%d%d%d",&X_tax,&Y_tax,&price_sum);
      if( X_tax<0 || X_tax>=100 || Y_tax<0 || Y_tax>=100 || price_sum<10 || price_sum>=1000 || X_tax==Y_tax)
        {
	  break;
        }

      for(price_A=1;price_A<1000;price_A++){ 
          for(price_B=999;price_B>0;price_B--){
	    X_price=(price_A*(100+X_tax)/100)+(price_B*(100+X_tax)/100);

          if(X_price==price_sum){
	    Y_price= (price_A*(100+Y_tax)/100)+(price_B*(100+Y_tax)/100);
	    if(max_price<Y_price){
	       max_price=Y_price;
              }
            }
         }
     } 
      printf("%d\n",max_price);
      max_price=0;
   }
  return 0;
}

Measured memory_bytes: 600
#include "bits/stdc++.h"
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(s) s.begin(), s.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
const ll mod = 1e9+7;

ll n,k;

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


Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <bits/stdc++.h>
#include<queue>
#include <numeric>
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define fore(i,a) for(auto &i:a)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
 



int main(){
    string S;
    cin >> S;
    map<char,int> mp;
    for(int i=0;i<S.length();++i){
        mp[S[i]]++;
    }
    bool exist=true;
    for(char i='a';i<='z';++i){
        if(mp[i]%2!=0){
            exist=false;
        }
    }
    if(exist){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys 
from collections import Counter
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
Q, A, B, C = map(int, readline().split())
N = A + B + C
SS = []
for _ in range(Q):
    S = readline().decode().rstrip()
    a = 0 if S == 'AB' else 1 if S == 'AC' else 2 
    SS.append(a)
ans = [] 
if N == 0:
    print('No')
    sys.exit()
elif N == 1:
    nums = [A,B,C]
    for n in range(Q):
        num = SS[n]
        i,j = (0,1) if num == 0 else (0,2) if num == 1 else (1,2)  
        if nums[i] == nums[j]:
            print('No')
            sys.exit()
        if nums[i] > nums[j]:
            i,j = j,i
        nums[i] += 1
        nums[j] -= 1
        ans.append(i)
else:
    nums = [A,B,C]
    num = SS[0]
    i,j = (0,1) if num == 0 else (0,2) if num == 1 else (1,2) 
    if nums[i] == 0 and nums[j] == 0:
        print('No')
        sys.exit()
    if N == 2:
        for n in range(Q):
            num = SS[n]
            i,j = (0,1) if num == 0 else (0,2) if num == 1 else (1,2)
            if nums[i] == 1 and nums[j] == 1 and n < Q-1:
                if SS[n] != SS[n+1]:
                    ni,nj = (0,1) if SS[n+1] == 0 else (0,2) if SS[n+1] == 1 else (1,2)
                    a = Counter([i,j,ni,nj])
                    b = a.most_common()[0][0] ## 2つあるの探す 
                    if j == b:
                        i,j = j,i   
            if nums[i] > nums[j]:
                i,j = j,i
            nums[i] += 1
            nums[j] -= 1
            ans.append(i)
    else:
        for n in range(Q):
            num = SS[n]
            i,j = (0,1) if num == 0 else (0,2) if num == 1 else (1,2)
            if nums[i] > nums[j]:
                i,j = j,i
            nums[i] += 1
            nums[j] -= 1
            ans.append(i)
        
print('Yes')
ABC = 'ABC'
answer = list(ABC[i] for i in ans)
print('\n'.join(answer))

Measured memory_bytes: 12152
#include<iostream>


int main() {
	unsigned long long int H, W;
	std::cin >> H;
	std::cin >> W;

	unsigned long long int oddCount = 0, evenCount = 0;
	if (H == 1 || W == 1) {
		std::cout << 1;
		return 0;
	}

	oddCount = H / 2 + H % 2;
	evenCount = H / 2;

	unsigned long long int totalCount = oddCount * (W / 2 + W % 2) + evenCount * (W / 2);

	std::cout << totalCount;
}


Measured memory_bytes: 256
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String S = sc.next(); 
		String[] sp = S.split("");
		int count = 0;
		for(int i = 0; i < sp.length-2; i++) {
		    if(sp[i].equals("A")) {
		        if(sp[i+1].equals("B")) {
                    if(sp[i+2].equals("C")) {
                        i+=2;
                        count++;
                    }else {
                        i++;
                    }
		        }
		    }
		}
		
		System.out.println(count);
	}
}


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

using namespace std;

using ll = long long;
constexpr ll MOD = 1e9 + 7;
constexpr ll INF = 1e18;

int main() {
    ll K, T;
    cin >> K >> T;
    vector<ll> a(T);
    ll S = 0,M = -1;
    for(auto &x : a) {
        cin >> x;
        M = max(M,x);
    }
    cout << max(2*M-1-K,0ll) << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int cnt = 0;

    for(int i = a; i <= b; i++){
      String s = String.valueOf(i);
      boolean flag = true;
      for(int j = 0; j < s.length()/2; j++){
        if(s.charAt(j) != s.charAt(s.length()-j-1)){
          flag = false;
          break;
        }
      }
      if(flag){cnt++;}
    }

    System.out.println(cnt);

  }
}

/*
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
String blank = sc.nextLine();
String s = sc.nextLine();
System.out.println();
System.exit(0)
*/


Measured memory_bytes: 27220
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,b;
  list<int>a;
  cin>>n;
  string s;
  while(n--){
    cin>>s;
    if(s.size()<=6){
      cin>>b;
      if(s[0]=='i')a.push_front(b);
      else{
        list<int>::iterator it=a.begin();
        while(it!=a.end()){
          if(*it==b){a.erase(it);break;}
          it++;
        }
      }
    }
    else{
      if(s[6]=='F')a.pop_front();
      else a.pop_back();
    }
  }
  list<int>::iterator it=a.begin();
  for(int i=0;it!=a.end();it++,i++){
    if(i)cout<<' ';
    cout<<(*it);
  }
  cout<<endl;
}


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

const int INF = 2100000000;

int main() {
  auto min = [](int a, int b) { return (a < b ? a : b); };
  int N;
  std::cin >> N;
  std::vector<int> h(N+1);
  for (int i = 1; i <= N; i++) std::cin >> h[i];

  // dp[i] := 足場 i に移動するのに要するコスト
  std::vector<int> dp(N + 3, INF);
  dp[0] = 0;
  dp[1] = 0;

  for (int i = 1;i<N; i++){
    dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i + 1] - h[i]));
    dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i + 2] - h[i]));
  }
  std::cout << dp[N] << std::endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <queue>
#include <algorithm>

using int64 = long long;

int main()
{
    int N, M;

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

    std::sort(A.begin(), A.end());

    std::priority_queue<std::pair<int, int>> pq;
    for (int i = 0; i < M; i++) {
        int B, C;
        std::cin >> B >> C;
        pq.push(std::make_pair(C, B));
    }

    int64 sum = 0;
    for (int i = 0; i < N; i++) {
        std::pair<int, int> p = std::make_pair(0, 0);
        if (!pq.empty())
            p = pq.top();

        if (A[i] < p.first) {
            pq.pop();

            sum += p.first;
            p.second--;
            if (p.second != 0)
                pq.push(p);
        }
        else
            sum += A[i];
    }

    std::cout << sum << std::endl;
    return 0;
}


Measured memory_bytes: 1784
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5+5;
const int INF=1e9+7;
const ll mod=1e9+7;
ll dp[105][5][5][5];
map<int,string> p;
bool check(int a,int b,int c,int d)
{
    if (p[a]+p[b]+p[c]=="AGC") return 0;
    if (p[b]+p[c]+p[d]=="AGC") return 0;
    if (p[b]+p[a]+p[c]=="AGC") return 0;
    if (p[a]+p[c]+p[d]=="AGC") return 0;
    if (p[a]+p[c]+p[b]=="AGC") return 0;
    if (p[c]+p[b]+p[d]=="AGC") return 0;
    if (p[a]+p[b]+p[d]=="AGC") return 0;
    if (p[b]+p[d]+p[c]=="AGC") return 0;
}
int main()
{
    p[0]="0";
    p[1]="A";
    p[2]="G";
    p[3]="C";
    p[4]="T";
    int n;
    cin>>n;
    if (n<=2)
    {
        int ans=1;
        for (int q=1;q<=n;q++) ans*=4;
        cout<<ans<<endl;
        return 0;
    }

    dp[0][0][0][0]=1;
    for (int q=1;q<=n;q++)
        for (int w=1;w<=4;w++)
            for (int e=0;e<=4;e++)
                for (int r=0;r<=4;r++)
                    for (int t=0;t<=4;t++)
                    {
                        if (check(w,e,r,t))
                        dp[q][w][e][r]+=dp[q-1][e][r][t];
                        dp[q][w][e][r]%=mod;
                    }

    ll ans=0;
    for (int q=1;q<=4;q++)
        for (int w=1;w<=4;w++)
            for (int e=1;e<=4;e++)
                ans=(ans+dp[n][q][w][e])%mod;
    cout<<ans<<endl;



    return 0;
}

Measured memory_bytes: 384
#import <Foundation/Foundation.h>

int main() {
	@autoreleasepool {
		int n;
		char s[101];
		char t[101];
		scanf("%d %s %s",&n,s,t);
		NSString *S = [NSString stringWithUTF8String:s];
		NSString *T = [NSString stringWithUTF8String:t];
		for(int i=0;i<n;i++){
			if([[S substringFromIndex:i] isEqualToString:[T substringToIndex:n-i]]) {
				printf("%d\n",n+i);
				return 0;
			}
		}
		printf("%d\n",2*n);
	}
}

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

namespace AGC007A{
    public class Program{
        public static void Main(string[] args){
            var sr = new StreamReader();
            //---------------------------------
            var H = sr.Next<int>();
            var W = sr.Next<int>();
            var A = sr.Next<string>(H).Select(s => s.ToCharArray()).ToArray();
            Func<int, int, bool> isInside = (x, y) => 0 <= x && x < W && 0 <= y && y < H;

            var B = new char[H][];
            for(var i = 0; i < H; i++){
                B[i] = new char[W];
                for(var j = 0; j < W; j++){
                    B[i][j] = '.';
                }
            }

            Func<char[][], char[][], bool> isSame = (c1, c2) =>{
                for(var i = 0; i < H; i++){
                    for(var j = 0; j < W; j++){
                        if(c1[i][j] != c2[i][j]) return false;
                    }
                }
                return true;
            };

            var res = false;
            Action<int, int> dfs = null;
            dfs = (x, y) =>{
                if(isInside(x, y)){
                    B[y][x] = '#';
                    if(isSame(A, B)) res = true;
                    dfs(x + 1, y);
                    dfs(x, y + 1);
                    B[y][x] = '.';
                }
            };

            dfs(0, 0);
            Console.WriteLine(res ? "Possible" : "Impossible");
            //---------------------------------
        }
    }

    public class StreamReader{
        private readonly char[] _c = {' '};
        private int _index = -1;
        private string[] _input = new string[0];
        private readonly System.IO.StreamReader _sr = new System.IO.StreamReader(Console.OpenStandardInput());

        public T Next<T>(){
            if(_index == _input.Length - 1){
                _index = -1;
                while(true){
                    string rl = _sr.ReadLine();
                    if(rl == null){
                        if(typeof(T).IsClass) return default(T);
                        return (T)typeof(T).GetField("MinValue").GetValue(null);
                    }
                    if(rl != ""){
                        _input = rl.Split(_c, StringSplitOptions.RemoveEmptyEntries);
                        break;
                    }
                }
            }
            return (T)Convert.ChangeType(_input[++_index], typeof(T), System.Globalization.CultureInfo.InvariantCulture);
        }

        public T[] Next<T>(int x){
            var ret = new T[x];
            for(var i = 0; i < x; ++i) ret[i] = Next<T>();
            return ret;
        }

        public T[][] Next<T>(int y, int x){
            var ret = new T[y][];
            for(var i = 0; i < y; ++i) ret[i] = Next<T>(x);
            return ret;
        }
    }
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int N;
int A[111111];

int sumabs[111111];
int sum[111111];
int dp[111111];
signed main(){
    cin>>N;
    rep(i,N){
        char op='+';
        if(i)cin>>op;
        cin>>A[i];
        if(op=='-')A[i]*=-1;
    }

    rep(i,N)sumabs[i+1]=sumabs[i]+abs(A[i]);
    rep(i,N)sum[i+1]=sum[i]+A[i];

    vint pos;
    rep(i,N)if(A[i]<0)pos.pb(i);

    int ans=accumulate(A,A+N,0ll);

    for(int i=0;i+1<pos.size();i++){
        int x=pos[i];
        int y=pos[i+1];
        int tmp=sum[x+1];
        tmp-=sum[y]-sum[x+1];
        tmp+=sumabs[N]-sumabs[y];
        chmax(ans,tmp);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3704
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String W = br.readLine().toLowerCase();
		
		int ans = 0;
		String line;
		while (!((line = br.readLine()).equals("END_OF_TEXT"))) {
			line = line.toLowerCase();
			StringTokenizer st = new StringTokenizer(line, " ");
			while (st.hasMoreTokens()) {
				if (st.nextToken().equals(W)) ans++;
			}
		}
		
		System.out.println(ans);
	}

}

Measured memory_bytes: 24156
import java.io.*;
import java.util.*;

 
public class Main {            
    static StringBuilder out=new StringBuilder();
    static FastReader in=new FastReader();
    public static int[] getIntArray(int n){
        int arr[]=new int[n];
        for(int i=0;i<n;i++){
            arr[i]=in.nextInt();
        }
        return arr;
    }
 
    static int  mod=(int)1e9 +7;
    static int [][]dp;
    
    
    public static void solve(){
        int ac=0,wa=0, tle=0,re=0;
        int n=in.nextInt();
        for(int i=0;i<n;i++){
            String s=in.nextLine();
            if(s.equals("AC")){
                ac++;
            }else if(s.equals("WA")){
                wa++;
            }else if(s.equals("TLE")){
                tle++;
            }else{
                re++;
            }
        }
        out.append("AC x "+ac).append('\n');
        out.append("WA x "+wa).append('\n');
        out.append("TLE x "+tle).append('\n');
        out.append("RE x "+re).append('\n');
    }

    public static void main(String args[]){
        int t=1;
        while(t-->0){
            solve();
            out.append('\n');
        }
        System.out.println(out);
    }
}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
class FastReader {
    BufferedReader br;
    StringTokenizer st;
 
    public FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }
 
    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }
 
    int nextInt() {
        return Integer.parseInt(next());
    }
 
    long nextLong() {
        return Long.parseLong(next());
    }
 
    double nextDouble() {
        return Double.parseDouble(next());
    }
 
    String nextLine() {
        String str = "";
        try {
            str = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return str;
    }
}

class tree{
    int n, t[];
    public tree(int arr[]){
        n=arr.length;
        t=new int[n*4];
        build(arr, 1,0,n-1);
    }
    public int build(int arr[],int i,int l,int r){
        if(l==r){
            t[i]=arr[l];
            return 1;
        }
        int mid=l+(r-l)/2;
        int h=Math.min(build(arr,i*2,l,mid),build(arr,i*2+1,mid+1,r));
        if(h%2==0){
            t[i]=t[i*2] ^ t[i*2 +1 ];
        }else{
            t[i]=t[i*2] | t[i*2 + 1];
        }
        return ++h;
    }
    public int update(int i, int l,int r, int p,int b){
        if(l==r){
            t[i]=b;
            return 1;
        }
        int mid=l+(r-l)/2;
        int h=0;
        if(p>mid){
            h=update(i*2+1,mid+1,r,p,b);
        }else{
            h=update(i*2,l,mid,p,b);
        }
        if(h%2==0){
            t[i]=t[i*2] ^ t[i*2 +1 ];
        }else{
            t[i]=t[i*2] | t[i*2 + 1];
        }
        return ++h;
    }
}

Measured memory_bytes: 43036