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

public class Main {

    static final int NONE = -1;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();

        List<List<Integer>> out = new ArrayList<>();
        List<Set<Integer>> in = new ArrayList<>();
        for (int i = 0; i < N; i++) {
            out.add(new ArrayList<>());
            in.add(new HashSet<>());
        }

        for (int i = 0; i < M; i++) {
            int u = sc.nextInt() - 1;
            int v = sc.nextInt() - 1;
            out.get(u).add(v);
            in.get(v).add(u);
        }

        List<Integer> sol = null;

        for (int u = 0; u < N; u++) {
            List<Integer> cycle = shortestCycle(u, out, in.get(u));
            if (cycle != null && (sol == null || cycle.size() < sol.size())) {
                sol = cycle;
            }
        }

        if (sol == null) System.out.println(-1);
        else {
            System.out.println(sol.size());
            for (int u : sol) System.out.println(u + 1);
        }
    }


    static List<Integer> shortestCycle(int s, List<List<Integer>> adj, Set<Integer> in) {
        int[] pred = new int[adj.size()];
        Arrays.fill(pred, NONE);
        Deque<Integer> deque = new ArrayDeque<>();
        deque.add(s);

        while (!deque.isEmpty()) {
            int u = deque.pollLast();

            for (int v : adj.get(u)) {
                if (pred[v] != NONE) continue;
                if (in.contains(v)) {
                    List<Integer> cycle = new ArrayList<>();
                    while (pred[u] != NONE) {
                        cycle.add(u);
                        u = pred[u];
                    }
                    cycle.add(s);
                    cycle.add(v);
                    return cycle;
                }
                pred[v] = u;
                deque.addFirst(v);
            }
        }

        return null;
    }
}

Measured memory_bytes: 61652
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
#include <bitset> 
#include <iterator> 
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include<deque>
#include <regex>
#include <list> 
#define rep(i,n) for(ll i=0;i<(n); ++i)
#define per(i,n) for(ll i=n-1;i>=0; --i)
#define all(x) (x).begin(),(x).end()
#define _GLIBCXX_DEBUG
using namespace std;
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; }
const long long INF = 1LL << 60;
typedef long long ll;
const ll MOD = 1000000007;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll getDigit(ll n) {
	ll cnt = 0;
	while (n != 0) {
		n /= 10;
		cnt++;
	}
	return cnt;
}
typedef pair<double,long long> pair_t;
bool comp(const pair_t& a, const pair_t& b) {
	if (a.first == b.first)return  a.second > b.second;
	else {
		return a.first > b.first;
	}
}

int main() {
	ll n,cnt=0,Mcnt=-INF;
	cin >> n;
	vector<ll>a(n);
	rep(i, n)cin >> a[i];
	map<ll, ll>bucket;
	for (ll i = 0; i < n; i++) {
		bucket[a[i] + 1]++;
		bucket[a[i]]++;
		bucket[a[i] - 1]++;
	}
	for (ll i = 0; i < pow(10, 5); i++) {
		cnt = bucket[i];
		Mcnt = max(Mcnt,cnt);
	}
	cout << Mcnt << endl;
}


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

int main (void) {
    long long a, b, x;
    std::cin >> a >> b >> x;

    long long na; /* a 未満の x の倍数の個数 */
    long long nb; /* b 以下の x の倍数の個数 */
    na = a/x;
    if ( a % x == 0 ) na--;
    nb = b/x;

    std::cout << nb - na << std::endl;
    return 0;
}


Measured memory_bytes: 3500
#include <iostream>

int main()
{  
  int N;
  long power = 1;
  std::cin >> N;
  
  for(int i = 1; i <= N; i++)
  {
    power *= i;
    power = power % (1000000000 + 7);
  }
  
  std::cout << power;
  return 0;
}

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0;i<(n);++i)
#define LL long long
using namespace std;
int main(void) {
  // O(10^6)                                                                                                                                                                                                                                 
  while(1) {
    int n, m;
    cin >> n >> m;
    if (n+m==0) return 0;
    vector<int> taro(n), hanako(m);
    REP(i, n) cin >> taro[i];
    REP(i, m) cin >> hanako[i];
    int staro = accumulate(taro.begin(), taro.end(), 0);
    int shanako = accumulate(hanako.begin(), hanako.end(), 0);
    if (staro == shanako) {
      int ans = 1000;
      REP(i,n) {
        REP(j,m) {
          if (taro[i] == hanako[j] && ans > taro[i]) {
            ans = taro[i];
          }
        }
      }
      if (ans == 1000) {
        cout << -1 << endl;
      } else {
        cout << ans << " " << ans << endl;
      }
    } else {
      int diff = shanako-staro;
      int ataro = 1000, ahanako = 1000;
      if (diff % 2 == 0) {
        REP(i,n) {
          REP(j,m) {
            if (taro[i] + diff/2 == hanako[j] && ataro+ahanako > taro[i]+hanako[j]) {
              ataro = taro[i];
              ahanako = hanako[j];
            }
          }
        }
        if (ataro+ahanako==2000) {
          cout << -1 << endl;
        } else {
          cout << ataro << " " << ahanako << endl;
        }
      } else {
        cout << -1 << endl;
      }
    }
  }
}



Measured memory_bytes: 2964
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>

using namespace std;

typedef pair<int, int> P;

int vx[]={1,0,-1,0}, vy[]={0,1,0,-1};

// ??¶???????????????????§???????
struct status{
	int count, to;
	int p[10][10];
	status(int c=0, int t=0, status *old=NULL){	//???????????????????????§??¨???????????????????????§???????????????????????????
		if( old ) *this = *old;		// ??¨?????????(memcpy()???????\???§?????????????°???????)
		else fill(p[0], p[0]+10*10, 0);	//?????????????????????????????????????????????????????§
		count = c;
		to = t;
	}
};

int main(){
	int h, w, c;
	while(cin>>h>>w>>c, h|w|c){
		// ???????????§?????°??????????????¨??????????????°???????????§??????
		stack<status> st;
		int ans = 0;
		
		// ??????????????????
		status in;
		for(int i=1; i<=h; i++){
			for(int j=1; j<=w; j++){
				cin >> in.p[i][j];
			}
		}
		in.to = in.p[1][1];
		in.p[1][1] = 8;
		
		// ??±???????????¢?´¢
		st.push( in );
		while( !st.empty() ){
			status s = st.top(); st.pop();
			// s.to??????????????´
			vector< P > check;	//stack??§???????????£??????ans?????°???????????????????????????vector????????´
			for(int i=1; i<=h; i++){	// (1,1)??¨?????????8?????¨????????¢???
				for(int j=1; j<=w; j++){
					if( s.p[i][j] == 8 )
						check.push_back( make_pair(i, j) );
				}
			}
			for( int i=0; i<check.size(); i++ ){	// ??£??\??¨???????????????
				int y = check[i].first, x = check[i].second;
				for(int k=0; k<4; k++){
					if( s.p[ y+vy[k] ][ x+vx[k] ] == s.to ){
						s.p[ y+vy[k] ][ x+vx[k] ] = 8;
						check.push_back( make_pair( y+vy[k], x+vx[k] ) );
					}
				}
			}
			// ?¬?????????????????????????
			if( s.count == 5 ){		// ?????????
				ans = max( ans, (int)check.size() );	//?????§???????????´??°
			}else if( s.count == 4 ){
				st.push( status(s.count+1, c, &s) );
			}else{
				for(int i=1; i<=6; i++){
					if( i != s.to ){
						st.push( status(s.count+1, i, &s) );
					}
				}
			}
		}
		
		// ??????
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1228
#include <stdio.h>
#include <algorithm>

int main(void) {
  int w, h, x, y, r;
  scanf("%d%d%d%d%d", &w, &h, &x, &y, &r);
  if(x - r >= 0 && y - r >= 0 && x + r <= w && y + r <= h) printf("Yes\n");
  else printf("No\n");
  return 0;
}


Measured memory_bytes: 2688
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
typedef unsigned int ui;
int main() {
	int q,i; ll a, b;
	cin >> q;
	for (i = 0; i < q; i++) {
		cin >> a >> b;
		ll out = (ll)sqrt(a*b);
		if (out*out == a * b&&a != b) {
			cout << 2 * out - 3 << endl;
		}
		else if (out*(out + 1) >= a * b) {
			cout << 2 * out - 2 << endl;
		}
		else {
			cout << 2 * out - 1 << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define ll long long
using namespace std;
struct SegTree{
	//
	int n;
	vector<ll> dat,laz;
	//
	SegTree(int n_){
		init(n_);
	}
	//
	void init(int n_){
		n=1;
		while(n<n_){
			n*=2;
		}
		for(int i=0;i<2*n-1;i++){
			dat.push_back(0);
			laz.push_back(0);
		}
	}
	//
	void eval(int l,int k){
		if(k*2+1<n*2-1){
			laz[k*2+1]+=laz[k];
			laz[k*2+2]+=laz[k];
		}
		dat[k]+=laz[k]*l;
		laz[k]=0;
	}
	//
	ll update(int a,int b,int x,int k=0,int l=0,int r=-1){
		if(r==-1){
			r=n;
		}
		eval(r-l,k);
		if(r<=a||b<=l){
			return dat[k]+laz[k]*(r-l);
		}else if(a<=l&&r<=b){
			return dat[k]+(laz[k]+=x)*(r-l);
		}else{
			eval(r-l,k);
			ll va=update(a,b,x,k*2+1,l,(l+r)/2);
			ll vb=update(a,b,x,k*2+2,(l+r)/2,r);
			return dat[k]=va+vb;
		}
	}
	//
	ll query(int a,int b,int k=0,int l=0,int r=-1){
		if(r==-1){
			r=n;
		}
		eval(r-l,k);
		if(r<=a||b<=l){
			return 0;
		}else if(a<=l&&r<=b){
			return dat[k];
		}else{
			ll va=query(a,b,k*2+1,l,(l+r)/2);
			ll vb=query(a,b,k*2+2,(l+r)/2,r);
			return va+vb;
		}
	}
	//
};
int main(){
	int N,Q;
	cin>>N>>Q;
	SegTree Seg(N);
	while(Q--){
		int C;
		cin>>C;
		if(C==1){
			int S,T;
			cin>>S>>T;
			cout<<Seg.query(S-1,T)<<endl;
		}else{
			int S,T,X;
			cin>>S>>T>>X;
			Seg.update(S-1,T,X);
		}
	}
	return 0;
}


Measured memory_bytes: 7140
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
	public static void main (String args[]) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		Map<Long, Integer> map = new HashMap<Long, Integer>();
		for(int i = 0; i < n;i++){
			long a = scan.nextLong();
			if(map.get(a) == null) {
				map.put(a, 0);
			} else {
				System.out.println("NO");
				return;
			}
		}
		System.out.println("YES");
	}
}


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

#define I inline
#define fi first
#define se second
#define LL long long
#define mp make_pair
#define reg register int
#define pii pair<int,int>
#define fo(i, a, b) for(reg i = a; i <= b; i++)
#define fd(i, a, b) for(reg i = a; i >= b; i--)
#define cr const reg&
using namespace std;
const int N = 1 << 18;

I int _max(cr x, cr y) {return x > y ? x : y;}
I int _min(cr x, cr y) {return x < y ? x : y;}
I int read() {
	reg x = 0, f = 1; char ch = getchar();
	while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
	while(ch >= '0' && ch <= '9') x = (x << 3) + (x << 1) + (ch ^ 48), ch = getchar();
	return x * f;
}
I void ptt(LL x) {if(x >= 10) ptt(x / 10); putchar(x % 10 + '0');}
I void put(LL x) {x < 0 ? putchar('-'), ptt(-x) : ptt(x);}
I void pr1(LL x) {put(x), putchar(' ');}
I void pr2(LL x) {put(x), puts("");}

priority_queue<pii, vector<pii>, greater<pii>> g;
int a[N], R[N], l[N], r[N];
vector<pii> q[N];

int main() {
	reg n = read(), S = (1 << n) - 1;
	fo(i, 0, S) a[i] = read() - 1, R[i] = (R[i >> 1] >> 1) | ((i & 1) << n - 1);
	fd(i, S, 0) {
		r[i] = a[i] == -1 ? S : a[i];
		fo(j, 0, n - 1) if(!(i >> j & 1)) r[i] = _min(r[i], r[i | (1 << j)]);
	} fo(i, 0, S) {
		l[i] = a[i] == -1 ? 0 : a[i];
		fo(j, 0, n - 1) if(i >> j & 1) l[i] = _max(l[i], l[i ^ (1 << j)]);
		if(l[i] > r[i]) {puts("NO"); return 0;}
		q[l[i]].push_back(pii{r[i], i});
	} fo(i, 0, S) {
		fo(j, 0, (int)q[i].size() - 1) g.push(q[i][j]);
		if(g.empty()) {puts("NO"); return 0;}
		pii u = g.top(); g.pop();
		if(u.fi < i) {puts("NO"); return 0;}
		a[u.se] = i;
	} puts("YES");
	fo(i, 0, S) pr1(a[R[i]] + 1);
	return 0;
}



Measured memory_bytes: 20224
N=int(input())
S=[input() for i in range(N)]
BA=0
B=0
A=0
cnt=0
for i in S:
  if i[0]=='B'and i[-1]=='A':
    BA+=1
  elif i[0]=='B':
    B+=1
  elif i[-1]=='A':
    A+=1
  for j in range(len(i)-1):
    if i[j]=='A' and i[j+1]=='B':
      cnt+=1
if BA==0:
  print(cnt+min(A,B))
else:
  ans=BA-1
  if B>0:
    ans+=1
    B-=1
  if A>0:
    ans+=1
    A-=1
  print(cnt+min(A,B)+ans)

Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
const int MOD = (int)1e9 + 7;
const int INF = 100100100;
const double PI = 3.14159265358979323846;
typedef long long ll;
#define FOR(i, a, b) for (ll i = (a); i < (b); ++i)
#define REP(i, n) for (ll i = 0; i < (n); ++i)

int main() {
  ll n, a[100001] = {0};
  string ans;
  cin >> n;
  REP(i, n) cin >> a[i];
  ll sum = 0;
  REP(i, n) sum += a[i];
  if (sum % 2 == 1) cout << "NO" << endl;
  if (sum % 2 == 0) cout << "YES" << endl;
  //   ll evenCount = 0, oddCount = 0;
  //   REP(i, n) {
  //     if (a[i] % 2 == 1) {
  //       oddCount++;
  //     } else {
  //       evenCount++;
  //     }
  //   }
  //   ll oddPair = oddCount / 2;
  //   oddCount -= 2 * oddPair;
  //   evenCount += oddPair;
  //   if (evenCount > 0 && oddCount > 0) {
  //     ans = "NO";
  //   } else if (evenCount > 0 && oddCount == 0) {
  //     ans = "YES";
  //   } else if (evenCount == 0 && oddCount > 0) {
  //     ans = "YES";
  //   } else if (evenCount == 0 && oddCount == 0) {
  //     ans = "NO";
  //   }
  //   cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
import           Data.Char                      ( isSpace )
import qualified Data.Vector.Unboxed           as V
import qualified Data.ByteString.Char8         as C

main = do
    n <- readLn :: IO Int
    a <- V.unfoldr (C.readInt . C.dropWhile isSpace) <$> C.getLine
    let zeros = V.replicate n 0 :: V.Vector Int
        ones  = V.replicate n 1
        ans   = V.tail $ V.accumulate_ (+) zeros a ones
        jot vec
            | V.null vec = print 0
            | otherwise = do
                print $ V.head vec
                jot $ V.tail vec
    jot ans


Measured memory_bytes: 9904
#include<stdio.h>

int main(){
  long int N;
  long int A[111111],B[111111];
  scanf("%ld",&N);
  long int i;
  for(i=0;i<=N-1;i++)
    scanf("%ld",&A[i]);
  long int count = 0;
  for(i=0;i<=N-1;i++){
    if(A[i] < 0){
      B[i] = - A[i];
      count++;
      };
    if(A[i] >= 0) B[i] = A[i];
    };
  long int min = B[0];
  for(i=1;i<=N-1;i++)
    if(min > B[i]) min = B[i];
  long int sum = 0;
  for(i=0;i<=N-1;i++)
    sum += B[i];
  if(count % 2 == 1)
    sum = sum - 2 * min;
  printf("%ld",sum);
}

Measured memory_bytes: 1792
#include <cstdio>
#include <cmath>
using namespace std;
long long int count=0;
void merge(int a[],int left,int mid,int right){
	int n1=mid-left,n2=right-mid;
	int l[n1+1],r[n2+1];
	for(int i=0;i<n1;i++)	l[i]=a[left+i];
	for(int i=0;i<n2;i++)	r[i]=a[mid+i];
	l[n1]=(int)1e9+1;	r[n2]=(int)1e9+1;
	int i=0,j=0;
	for(int k=left;k<right;k++){
		if(l[i]<=r[j]){
			a[k]=l[i];
			i++;
		}
		else{
			count+=n1-i;
			a[k]=r[j];
			j++;
		}
	}
}
void mergesort(int a[],int left,int right){
	if(left+1<right){
		int mid=(left+right)/2;
		mergesort(a,left,mid);
		mergesort(a,mid,right);
		merge(a,left,mid,right);
	}
}

int main(){
	int n;	scanf("%d",&n);
	int data[n];
	for(int i=0;i<n;i++){
		scanf("%d",&data[i]);
	}
	mergesort(data,0,n);
	printf("%lld\n",count);
	return 0;
}

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

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

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

int main(){
  vector<int> a(3);
  for(int i=0;i<3;i++) cin>>a[i];
  sort(a.begin(),a.end());
  if(a[0]==5&&a[1]==5&&a[2]==7) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}

Measured memory_bytes: 3604
class stack():
    def __init__(self):
        self.S = []
        
    def push(self, x):
        self.S.append(x)
        
    def pop(self):
        return self.S.pop()
        
    def isEmpty(self):
        if len(self.S) == 0:
            return True
        else:
            return False

areas = input()

S1 = stack()
S2 = stack()

for i, info in enumerate(areas):
    if info == '/':
        if S1.isEmpty():
            continue
        left = S1.pop()
        menseki = i - left
        while True:
            if S2.isEmpty():
                S2.push([menseki, left])
                break
            if S2.S[-1][1] < left:
                S2.push([menseki, left])
                break
            menseki += S2.pop()[0]
    elif info == '\\':
        S1.push(i)

ans = [m[0] for m in S2.S]
print(sum(ans))
if len(ans) == 0:
    print(len(ans))
else:
    print(len(ans), ' '.join(list(map(str, ans))))


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

public class Main {

	public static void main(String[] args) {

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

		 try{

			 int S = Integer.parseInt(br.readLine());

			 System.out.println(S/3600 + ":" + (S%3600)/60 + ":" + S%60);

		 }catch(IOException e){
			 e.printStackTrace();
		 }
	}
}


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

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

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

const long long mod = 1000000007;
// auto mod int
struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

// combination mod prime
struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
    mint p(int n, int k) {
        //if (k < 0 || k > n) return 0;
        return fact[n]*ifact[n-k];
    }
};

int main(){
    int n, m;
    cin >> n >> m;
    combination c(m);
    mint ans = 0;
    rep(i, n+1) {
        mint now = c.p(m-i, n-i);
        now *= c(n, i);
        if (i%2) now = -now;
        ans += now;
    }
    ans *= c.p(m, n);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 11012
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);

    int A = sc.nextInt();
    int B = sc.nextInt();
    int C = sc.nextInt();
    int c = 0;

    if (A == B) c++;
    if (B == C) c++;
    if (C == A) c++;

    if (c == 1) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }

    
    sc.close();
  }
}

Measured memory_bytes: 21844
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#define ll long long
using namespace std;

int main()
{
    int a[3];
    int x=0,y=0;
    for(int i=0; i<3; i++)
    {
        scanf(" %d",&a[i]);
    }
    sort(a,a+3);
    for( ; a[0]<a[2]&&a[1]<a[2]; )
    {
        a[0]++;
        a[1]++;
        x=x+1;
    }
    for( ; a[0]<a[2]; )
    {
        a[0]+=2;
        y++;
    }
    if(a[0]==a[2])
        printf("%d\n",x+y);
    if(a[0]!=a[2])
        printf("%d\n",x+y+1);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
#include <stack>
#include <iomanip>
#include <limits>
using namespace std;

int main(){
  int N;cin>>N;
  vector<vector<int>> data(10,vector<int>(10,0));
  for(int i=1;i<=N;i++){
    string tmp=to_string(i);
    int s=tmp[0]-48;
    int e=tmp[tmp.length()-1]-48;
    data[s][e]++;
  }
  long long ans=0;
  for(int i=1;i<10;i++){
    for(int j=1;j<10;j++){
      if(i==j){
        ans+=data[i][j]*data[i][j];
      }else{
        ans+=data[i][j]*data[j][i];
      }
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int n, A[50];

int solve(int i, int m) {
    if(m==0) return 1;
    if(i>=n) return 0;
    int res = solve(i+1,m) || solve(i+1,m-A[i]);
    return res;
}

int main(void) {
    int q, M, i;

    scanf("%d", &n);
    for(i=0;i<n;i++) scanf("%d",&A[i]);
    scanf("%d",&q);
    for(i=0;i<q;i++) {
        scanf("%d", &M);
        if(solve(0,M)) printf("yes\n");
        else printf("no\n");
    }
    return 0;
}



Measured memory_bytes: 2092
#include<iostream>
#include<algorithm>
#include<string>
#include<sstream>
#include<iomanip>
#include<limits>
#include<deque>
#include<map>
#include<list>
#include<set>
#include <unordered_set>
#include<vector>
#include<cmath>
#include<cstdio>
#include<memory>
#include<bitset>

using namespace std;

int main(void) {
	int n, m; cin >> n >> m;
	map<int, int> mp;
	int k;

	for (int i = 0; i < n; i++) {
		cin >> k;
		for (int j = 0; j < k; j++) {
			int a; cin >> a;
			mp[a] += 1;
		}
	}

	int sum = 0;

	for (pair<int, int> x : mp) {
		if (x.second == n) {
			sum++;
		}
	}

	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.PrintWriter;
public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int k=sc.nextInt();
		int c=sc.nextInt();
		char[] s=sc.next().toCharArray();
		St[] front=new St[n+2];
		St[] back=new St[n+2];
		back[0]=new St(0,-200000);
		int idx=0;
		for(int i=1; i<=n; i++){
			back[i]=back[i-1];
			if(idx<i && s[i-1]=='o'){
				back[i]=new St(back[i].sum+1,i);
				idx=i+c;
			}
		}
		front[n+1]=new St(0,400000);
		idx=n+1;
		for(int i=n; i>=1; i--){
			front[i]=front[i+1];
			if(idx>i && s[i-1]=='o'){
				front[i]=new St(front[i].sum+1,i);
				idx=i-c;
			}
		}
		for(int i=1; i<=n; i++){
			if(s[i-1]=='o'){
				int sum=front[i+1].sum+back[i-1].sum;
				if(sum==k-1 && front[i+1].recent-i>c && i-back[i-1].recent>c){
					System.out.println(i);
				}
			}
		}
	}
	static class St{
		int sum,recent;
		St(int sum,int recent){
			this.sum=sum;
			this.recent=recent;
		}
	}
}


Measured memory_bytes: 61672
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<memory.h>
using namespace std;
int main()
{
  int N;
  cin >> N;
  int P[N],Q[N];
  for(int i=0; i<N; i++) cin >> P[i];
  for(int i=0; i<N; i++) cin >> Q[i];
  
  int A[N],cnt=1,Pcnt=0,Qcnt=0;
  for(int i=0; i<N; i++) A[i] = i+1;
  int s = sizeof(P);
  do{
    if(memcmp(A, P, s)==0){
      if(Pcnt == 0) Pcnt = cnt;
    }
    if(memcmp(A, Q, s)==0){
      if(Qcnt == 0) Qcnt = cnt;
    }
    cnt++;
  }while(next_permutation(A,A+N));

  cout << abs(Pcnt-Qcnt) << endl;
}

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

int N,K;
int A[100010];

int main()
{
    scanf("%d%d",&N,&K);
    for(int i = 0; i < N; i++)
    {
        scanf("%d",A + i);
    }

    sort(A,A + N);

    int ans = 2000000000;
    for(int i = 0; i < N - K + 1; i++)
    {
        ans = min(ans,A[i + K - 1] - A[i]);
    }

    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
 
int main() {
	cin.tie(0);
    ios::sync_with_stdio(false);

    int N, C;
    cin >> N >> C;

    vector<vector<int> > D(C, vector<int>(C));

    for(int i = 0; i < C; i++) {
        for(int j = 0; j < C; j++) {
            cin >> D[i][j];
        }
    }

    vector<vector<int> > c(N, vector<int>(N));

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

    vector<vector<int> > S(3, vector<int>(C));

    for(int i = 0; i < N; i++) {
        for(int j = 0; j < N; j++) {
            S[(j + i) % 3][c[i][j]]++;
        }
    }

    int ans = 1000000000;

    for(int i = 0; i < C; i++) {
        for(int j = 0; j < C; j++) {
            if(i == j) continue;
            for(int k = 0; k < C; k++) {
                if(i == k || j == k) continue;
                int c = 0;
                for(int m = 0; m < C; m++) {
                    c += S[0][m] * D[m][i];
                    c += S[1][m] * D[m][j];
                    c += S[2][m] * D[m][k];
                }
                ans = min(ans, c);
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 1280
#include <iostream>
#include<cmath>
#include<vector>
#define MOD 1000000007

using namespace std;

//二分累乗法 乗数が負は未確認
long long BinaryPower(long long m,long long n) {

	long long ans = 1;

	while (n > 0)
	{
		//指数が偶数
		if (n % 2 == 1) {
			ans = ans * m % MOD;
		}

		m = m * m % MOD;
		n >>= 1;
	}

	return ans;
}

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

	cout << BinaryPower(m, n) << endl;

	return 0;
}



Measured memory_bytes: 3084
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(){
    int N;
    cin >> N;
    int B[N-1];
    for(int i=0;i<N-1;i++) cin >> B[i];
    int A[N];
    A[0] = B[0];
    for(int i=1;i<N-1;i++){
        A[i] = min(B[i-1], B[i]);
    }
    A[N-1] = B[N-2];
    int ans =0;
    for(int i=0;i<N;i++) ans += A[i];
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include <math.h>
#include <set>
#include <map>
#include <stdio.h>
#include <queue>
#include <iomanip>
#include <cstring>
#include <stack>
#include <chrono>
#include <unordered_map>
#include <stdlib.h>
#include <ctime>
using namespace std;
typedef long long ll;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define endl "\n"
#define fi first
#define se second
#define pll pair<ll,ll>
#define forn(i,e) for(ll i = 1; i<=e; i++)
#define forsn(i,s,e) for(ll i = s; i<=e; i++)
#define rforn(i,s) for(ll i = s; i >= 0; i--)
#define rforsn(i,s,e) for(ll i = s; i >= e; i--)
#define dbg(x) cout<<#x<<" = "<<x<<endl
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
// freopen("input.txt","r", stdin);
// freopen("out.txt","w", stdout);
// auto start = chrono::high_resolution_clock::now();
// auto end = chrono::high_resolution_clock::now();
// double time_taken =chrono::duration_cast<chrono::nanoseconds>(end - start).count();
// time_taken *= 1e-9;
// cout << "Time taken by program is : " << fixed << time_taken << setprecision(9);
// cout << " sec" << endl;
ll n,k,a[200010];
bool pred(double x){
    ll cut=0;
    for(ll i=1;i<=n;i++){
        cut=cut + floor(double(a[i])/x);
        if(cut>k)
            return false;
    }
    return true;
}
int main()
{
    cin>>n>>k;
    ll mx=0;
    for(ll i=1;i<=n;i++){
        cin>>a[i];
        mx=max(a[i],mx);
    }
    if(k==0){
        cout<<mx<<endl;
        return 0;
    }
    double l=0,h=1e9+10;
    while(h-l>0.00001){
        double mid=(l+h)/2;
        if(pred(mid))
            h=mid;
        else
            l=mid;
    }
    if(h-floor(h)<0.0001){
        h=floor(h);
        if(h<1)
            h=1;
    }
    cout<<setprecision(10)<<ceil(h)<<endl;
}


Measured memory_bytes: 5292
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
using namespace std;

typedef long long ll;

string s;
int n;

int main() {
	cin >> s;
	n = s.length();
	if (s == "zyxwvutsrqponmlkjihgfedcba") {
		cout << -1 << endl;
		return 0;
	}
	for (char c = 'a'; c <= 'z'; c++) {
		bool flag = true;
		for (int i = 0; i < n; i++) {
			flag &= s[i] != c;
		}
		if (!flag) continue;
		cout << s << c << endl;
		return 0;
	}
	for (int i = n - 1; i >= 0; i--) {
		for (char c = s[i] + 1; c <= 'z'; c++) {
			bool flag = true;
			for (int j = 0; j < i; j++) {
				flag &= c != s[j];
			}
			if (!flag) continue;
			for (int j = 0; j < i; j++) cout << s[j];
			cout << c << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
    int N,M;
    cin >> N >> M;
    if(N==M){
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;    
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int k = sc.nextInt();
    int x = sc.nextInt();
    int y1 = 1000000;
    int y2 = (-1) * y1;
    int x1 = Math.max(x - k + 1, y2);
    int x2 = Math.min(x + k - 1, y1);
    for(int i = x1; i <= x2; i++) {
      System.out.print(i + " ");
    }
  }
}

Measured memory_bytes: 21844
N,M = map(int,input().split())
AC = [0 for i in range(N)]
WA = [0 for i in range(N)]
for i in range(M):
    li = input().split()
    p = int(li[0])
    S = li[1]
    if S == 'AC':
        AC[p-1] = 1
    elif S == 'WA' and AC[p-1] == 0:
        WA[p-1] += 1
WA2 = [AC[i]*WA[i] for i in range(N)]
print(sum(AC),sum(WA2))


Measured memory_bytes: 5540
import bisect, collections, copy, heapq, itertools, math, string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

N = I()
B = make_divisors(N - 1)
b = len(B)

A = make_divisors(N)

cnt = 0
for i in range(1, len(A) // 2 + 1):
    x = A[i]
    y = A[-i - 1]
    while y > x:
        if (y - 1) % x == 0:
            cnt += 1
            break
        elif y % x == 0:
            y //= x
        else:
            break
    if y == x:
        cnt += 1

ans = b - 1 + cnt + 1
print(ans)

Measured memory_bytes: 74644
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <algorithm>
#include <unordered_map>

#define rep(i, a, b) for (ll i = a; i < b; i++)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef unordered_map<string, ll> u_map;

// input
void input() {}
template <class Head, class... Tail>
void input(Head &&a, Tail &&... b)
{
    cin >> a;
    input(forward<Tail>(b)...);
}

template <class V>
void input(vector<V> &v)
{
    for_each(v.begin(), v.end(), [](auto &i) { input(i); });
}

// output
template <class V>
void output(vector<V> &v)
{
    for_each(v.begin(), v.end(), [](auto &x) { cout << x << " "; });
    cout << endl;
}

// math functions
ll mpow(ll a, ll n, ll p)
{
    ll x = 1;
    while (n > 0)
    {
        if (n & 1)
        {
            x = a * x % p;
        }
        a = a * a % p;
        n >>= 1;
    }

    return x;
}

ll mfact(ll n, ll p)
{
    ll res = 1;
    for (ll i = 2; i <= n; i++)
    {
        res = res * i % p;
    }
    return res;
}

ll mcomb(ll n, ll r, ll p)
{
    if (n == 0 && r == 0)
    {
        return 1;
    }
    if (n < r || n < 0 || r < 0)
    {
        return 0;
    }

    ll a = mfact(n, p);
    ll b = mfact(n - r, p);
    ll c = mfact(r, p);
    return (((a * mpow(b, p - 2, p)) % p) * mpow(c, p - 2, p)) % p;
}

ll gcd(ll a, ll b)
{
    if (a < b)
    {
        a ^= b;
        b ^= a;
        a ^= b;
    }
    return b ? gcd(b, a % b) : a;
}

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

int main()
{
    ll N;
    input(N);
    
    vector<ll> v(N+1, 0);
    
    rep(i, 2, N+1)
    {
        ll data;
        input(data);
        v[data] += 1;
    }
    
    rep(i, 1, N+1)
    {
        cout << v[i] << endl;
    }
    
    
    return 0;
}


Measured memory_bytes: 4792
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C,D;
  cin >> A >> B >> C >> D ;
  if ( A + B > C + D){
    cout << "Left" << endl;
  }
  else if ( A + B == C + D){
    cout << "Balanced" << endl;
  }
  else{
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main() {
    string S;
    cin >> S;
    int distance = 0, RIndex = 0;
    vector<int> cnt(2), ans(S.size());
    for (int i = 0; i < S.size(); i++) {
        if (S[i] == 'R') {
            if (S[i+1] == 'R') {
                cnt[distance % 2]++;
                distance++;
            }
            else {
                ans[RIndex = i] = 1 + cnt[distance % 2];
                ans[RIndex + 1] = 1 + cnt[(distance + 1) % 2];
                cnt = vector<int>(2);
                distance = 0;
            }
        }
        if (S[i] == 'L') {
            if (S[i-1] == 'L') {
                cnt[distance % 2]++;
                distance++;
            }
            if (i == S.size() - 1 || S[i+1] == 'R') {
                ans[RIndex] += cnt[(distance + 1) % 2];
                ans[RIndex + 1] += cnt[distance % 2];
                cnt = vector<int>(2);
                distance = 0;
            }
        }
    }
    for (int i : ans) cout << i << " ";
}

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

int main() {
  int N;
  cin >> N;
  double res = 0;
  for (int i = 0; i < N; ++i) {
    double v;
    string s;
    cin >> v >> s;
    if (s == "JPY") res += v;
    else res += v * 380000.0;
  }
  cout << fixed << setprecision(10) << res << endl;
}

Measured memory_bytes: 3796
a,b,q = map(int, input().split())

s = [int(input()) for i in range(a)]
t = [int(input()) for i in range(b)]

import bisect

for i in range(q):
    s2 = 10**12
    t2 = 10**12
    qq = int(input())
    sp = bisect.bisect(s,qq)
    tp = bisect.bisect(t,qq)
    s1 = s[sp-1]
    if sp <a:
        s2 = s[sp]

    t1 = t[tp-1]
    if tp <b:
        t2 = t[tp]
    print(min(abs(qq-s1)+abs(s1-t1),abs(qq-s1)+abs(s1-t2),
              abs(qq-s2)+abs(s2-t1),abs(qq-s2)+abs(s2-t2),
              abs(qq-t1)+abs(t1-s1),abs(qq-t1)+abs(t1-s2),
              abs(qq-t2)+abs(t2-s1),abs(qq-t2)+abs(t2-s2)))

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

typedef long long ll;
typedef long double ld;

#define pb push_back
#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)

const ll mod = 1e9+7;

//最大公約数
ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}

//最小公倍数
ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}

//素数判定
bool isPrime(ll x){
    ll i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

//桁和
int digsum(ll n) {
    int res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

//桁数
int dignum(ll n) {
    int res = 0;
    while(n > 0) {
        res++;
        n /= 10;
    }
    return res;
}

//文字列中の特定の文字カウント
ll stringcount(string s,char c){
    return count(s.cbegin(),s.cend(),c);
}

//階乗
ll ka(ll i){
    ll res=1;
    while(i>0){
        res=res*i;
        i--;
    }
    return res;
}
 
//ncr
ll ncr(ll x,ll y){
    ll a = x;
    ll b = 1;
    if(y>(x/2)){
        y=x-y;
    }
    for(ll i=1;i<y;i++){
        a*=x-i;
        b*=i+1;
    }
    return a/b;
}

//フィボナッチ数列 -92
ll f(ll x){
    ll dp[x+1];
    dp[1]=1;
    dp[2]=1;
    for(ll i=3;i<=x;i++){
        dp[i]=dp[i-1]+dp[i-2];
    }
    return dp[x];
}



int main(){
    string s;
    cin >> s;
    int ans = 0;

    string a="",b="";

    for(int i=0;i<s.size();i++){
        a += s[i];
        if(b!=a){
            ans++;
            b = a;
            a = "";
        }
    }

    cout << ans << endl;
    
    

}

Measured memory_bytes: 640
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
const int N = 5005;
typedef long long ll; 
using namespace std;

int n, m, a[N], b[N][N], r[N], l[N], q[N][N]; 
ll c[N], sum[N], ans; 

template < typename T >
inline T read()
{
	T x = 0, w = 1; char c = getchar();
	while(c < '0' || c > '9') { if(c == '-') w = -1; c = getchar(); }
	while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return x * w; 
}

void add(int l, int r, ll x) { c[l] += x, c[r + 1] -= x; }

int main()
{
#ifndef ONLINE_JUDGE
	freopen("cpp.in", "r", stdin);
#endif
	n = read <int> (), m = read <int> ();
	for(int i = 1; i < n; i++) a[i] = read <int> ();
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= m; j++) b[i][j] = read <int> ();
	for(int i = 1; i <= m; i++) r[i] = 0, l[i] = 1; 
	for(int i = n; i >= 1; i--)
	{
		for(int pos, j = 1; j <= m; j++)
		{
			pos = i + 1; 
			while(l[j] <= r[j] && b[i][j] >= b[q[j][r[j]]][j])
				add(pos, (r[j] > l[j] ? q[j][r[j] - 1] - 1 : n), -b[q[j][r[j]]][j]), r[j]--, pos = q[j][r[j]]; 
			add(i, pos - 1, b[i][j]), r[j]++, q[j][r[j]] = i; 
		}
		add(i + 1, n, -a[i]); 
		for(int j = i; j <= n; j++) sum[j] = sum[j - 1] + c[j], ans = max(ans, sum[j]); 
	}
	printf("%lld\n", ans); 
	return 0; 
}


Measured memory_bytes: 28036
from collections import deque
import sys
sys.setrecursionlimit(200000)
n = int(input())
houseki = list(map(int,input().split()))
g = [[] for i in range(n+2)]
INF = float("inf")
MAX = 0
for i in range(n):
  if houseki[i] <= 0:
    g[0].append([i+1,-houseki[i],len(g[i+1])])
    g[i+1].append([0,0,len(g[0])-1])
  else:
    g[n+1].append([i+1,0,len(g[i+1])])
    g[i+1].append([n+1,houseki[i],len(g[n+1])-1])
    MAX += houseki[i]
  j = (i+1)*2
  while j <= n:
    g[i+1].append([j,INF,len(g[j])])
    g[j].append([i+1,0,len(g[i+1])-1])
    j += i+1
def bfs(s,t):
  global level
  que = deque([s])
  level[s] = 0
  while que:
    v = que.popleft()
    lv = level[v] +1
    for y, cap, rev in g[v]:
      if cap and level[y] is None:
        level[y] = lv
        que.append(y)
  return level[t] if level[t] else 0
def dfs(x,t,f):
  if x == t:
    return f
  for j in range(it[x],len(g[x])):
    it[x] = j
    y, cap, rev = g[x][j]
    if cap and level[x] < level[y]:
      d = dfs(y,t,min(f,cap))
      if d:
        g[x][j][1] -= d
        g[y][rev][1] += d
        return d
  return 0
 
flow = 0
f = INF = float("inf")
level = [None]*(n+2)
while bfs(0,n+1):
  it = [0]* (n+2)
  f = INF
  while f:
    f = dfs(0,n+1,INF)
    flow += f
  level = [None]*(n+2)
print(MAX-flow)

Measured memory_bytes: 40816
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <math.h>
using namespace std;

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> L(n);
    for (int i = 0; i < n; i++) {
        cin >> L[i];
    }
    sort(L.rbegin(), L.rend());
    int ans = 0;
    for (int i = 0; i < k; i++) {
        ans += L[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#pragma comment(linker, "/stack:200000000")

#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")

#include <stdio.h>
#include <bits/stdc++.h>

#define uint unsigned int
#define int long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i > l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define mp(a, b) make_pair(a, b)
#define ret(a) return cout<<a,0;
using namespace std;
const int N = 2 * 1e5 + 10;
int tot  , n , ans , x , a[N]; 

bool was[N];
main(){
	ios::sync_with_stdio(0); cin.tie(0);cout.tie(0);
	
	cin >> n >> x;
	
	int k = 2 * n - 1 ;
	if(x == 1 || x == k)
		return cout <<"No",0;
	if(k == 3 && x == 2){
		cout <<"Yes\n1 2 3";
		return 0;
	}
	
	//x + 2   x - 1 x x + 1 
	if(x - 1 > 0 && x + 2 <= k&& n - 2 > 0){
		cout <<"Yes\n";
		a[n] = x;
		a[n + 1] = x + 1;
		a[n - 1] = x - 1;
		a[n - 2] = x + 2;
		int j = 1;
		for(int i = 1 ; i <= k ; i++){
			if(i == n || i == n + 1 || i == n - 1 || i == n - 2 )
				cout << a[i] << '\n';
			else{
				if(j == x - 1)
					j = x + 2 + 1;
				cout << j << '\n';
				j++;
			}
		}
		return 0;
	}
	//x - 1 x x + 1 x - 2
	if(x  - 2 > 0 && x + 1 <= k && n - 1 > 0){
		a[n] = x;
		a[n + 1] = x + 1;
		a[n + 2] = x - 2;
		a[n - 1] = x - 1;
		int j = 1;
		cout <<"Yes\n";
		for(int i = 1; i <= k  ;i++){
			if(a[i] == 0){
				if(j == x - 2)
					j = x + 3;
				a[i] = j;
				j++;
			}
			cout << a[i] << '\n';
		}
		return 0;
	}
	// x - 2 x + 1 x x - 1
	//if( x - 2 > 0 && x + 1 <= k && )
	cout <<"No";
	
}

Measured memory_bytes: 3072
/// @file
/// @version Accepted.
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, M;
  cin >> N >> M;
  double p = pow(1. / 2, M);  // Bernoulli trial probability.
  double E = 1 / p;  // geometric distribution expectation.
  int coefficient = 1900 * M + 100 * (N - M);
  cout << coefficient * E << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
import static java.lang.Math.*;
class Main{
    public static void main(String[] args){
            Scanner sc = new Scanner(System.in);
            double r = sc.nextDouble();
            System.out.println(String.format("%.6f", r*r*Math.PI) + " " + (String.format("%.6f", 2*r*Math.PI)));
         }
}


Measured memory_bytes: 28300
//2017-10-9
//miaomiao
//
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>

using namespace std;

#define For(i, a, b) for(int i = (a); i <= (int)(b); ++i)
#define N (2000+5)

const int P = 1e9 + 7;

int Mod(int x){
	if(x < 0) x += P;
	return x >= P? x-P: x;
}

int C[N][N], csum[N][N];
int f[N][N], fsum[N][N], g[N][N];

void Init(int n){
	C[0][0] = 1;
	For(i, 1, n){
		C[i][0] = csum[i][0] = 1;
		For(j, 1, i){
			C[i][j] = Mod(C[i-1][j] + C[i-1][j-1]);
			csum[i][j] = Mod(csum[i][j-1] + C[i][j]);
		}
	}

	int l, r;

	For(i, 0, n) f[0][i] = f[i][0] = 1;
	
	fsum[0][0] = f[0][0];
	For(i, 1, n) fsum[i][0] = Mod(fsum[i-1][0] + f[i][0]);

	For(i, 1, n) For(j, 1, n){
		l = max(0, j-i); r = j;
		f[i][j] = csum[j][r];
		if(l) f[i][j] = Mod(f[i][j] - csum[j][l-1]);
	}
	For(j, 1, n){
		fsum[0][j] = f[0][j];
		For(i, 1, n) fsum[i][j] = Mod(fsum[i-1][j]+f[i][j]);
	}

//	puts("----------------------");
//	For(i, 0, 3) For(j, 0, 3) printf("f[%d][%d] = %d\n", i, j, f[i][j]);

	For(i, 0, n) g[0][i] = g[i][0] = 1;
	For(x, 1, n) For(y, 1, n) g[x][y] = fsum[x][y-1];
	
//	puts("----------------------");
//	For(i, 0, 3) For(j, 0, 3) printf("g[%d][%d] = %d\n", i, j, g[i][j]);
}

int main(){
//!
//	freopen("test.in", "r", stdin);
//	freopen("test.out", "w", stdout);
	
	int A, B, x, y, u, v;
	int ans = 0;

	Init(2000);
	scanf("%d%d", &A, &B);
	
//	puts("*********************");
	For(k, 0, A){
		x = A - k; y = B - 1;
		
		For(t, 0, y){
			u = x - (y-t); v = y - t;
			if(u < 0) continue;

//			printf("k = %d u = %d v = %d add = %d\n", k, u, v, g[u][v]);
			ans = Mod(ans + 1ll * g[u][v] * C[y][t] % P);
		}
	}

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

	return 0;
}

Measured memory_bytes: 78720
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Threading.Tasks;

namespace ABC098_C
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var S = Console.ReadLine();
            var w = new int[N];
            var e = new int[N];

            for (int i = 0; i < N-1; i++)
            {
                w[i + 1] = S[i] == 'W' ? w[i] + 1 : w[i];
            }
            for (int i = N - 1; i >= 1; i--)
            {
                e[i-1] = S[i] == 'E' ? e[i] + 1 : e[i];
            }
            var ans = int.MaxValue;
            for (int i = 0; i < N; i++)
            {
                ans = Math.Min(ans, e[i] + w[i]);
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 14432
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
using namespace std;
const int maxn=2025;
const int n=2019;
long long num[maxn];
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    string ss;
    cin>>ss;
    int last=0,times=1;
    for(int i=(int)ss.length()-1;i>=0;i--)
    {
        last=((ss[i]-'0')*times+last)%n;
        num[last]++;
        times=(times*10)%n;
    }
    long long ans=0;
    for(int i=0;i<n;i++)
        ans+=(num[i]*(num[i]-1)/2);
    ans+=num[0];
    cout<<ans<<'\n';
    return 0;
}


Measured memory_bytes: 3756
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (int)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
ll dp[100005];
ll h[100005];
int n;
ll func(int i){
    if(i>=n-1){
        return 0;
    }

    if(dp[i]!=-1)
        return dp[i];

    ll ans1,ans2;
    if(i+1<n){
        ans1=func(i+1)+abs(h[i+1]-h[i]);
    }
    else{
        ans1=1e9;
    }

    if(i+2<n){
        ans2=func(i+2)+abs(h[i+2]-h[i]);
    }
    else{
        ans2=1e9;
    }

    return dp[i]=min(ans1,ans2);
}
int main(){
    cin>>n;

    memset(dp,-1,sizeof dp);
    for(int i=0;i<n;i++)
        cin>>h[i];

    cout<<func(0);
}

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

#define MOD 1000000007

typedef unsigned long long ull;
typedef long long ll;
using namespace std;

void testCase() {
	int n;
	cin >> n;
	int num = n % 10;
	if(num == 2 || num == 4 || num == 5 || num == 7 || num == 9) {
		cout << "hon\n";
	} else if(num == 0 || num == 1 || num == 6 || num == 8) {
		cout << "pon\n";
	} else if(num == 3) {
		cout << "bon\n";
	}
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int T = 1;
	//cin >> T;
	while(T--) {
		testCase();
	}
}


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

int main(){
    ll N; cin >> N;
    vector<ll> A(N);
    rep(i, 0, N) cin >> A[i];

    ll cnt = 0;
    rep(i, 1, N) if(A[i-1] >= A[i]) cnt++;
    cout << 1 + cnt << endl;
    cout << N << endl;
}


Measured memory_bytes: 3608