akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
const long long maxn = 1e16 + 10;
int n;

int main() {
    long long a, b;
    cin >> n;
    cin >> a >> b;
    int x, y;
    long long star=1,endd=maxn,mid;
    for (int i = 1; i < n; i++) {
        cin >> x >> y;
        star=1;
        endd=maxn;
        while (star<=endd) {
            mid=(star+endd)/2;
            if(x*mid>=a&&y*mid>=b)
                endd=mid-1;
            else
                star=mid+1;
        }
        if(x*mid<a||y*mid<b) {
            mid = max((a-x*mid)/x,(b-y*mid)/y)+mid;
        }
        while (x*mid<a||y*mid<b) {
            mid++;
        }
        a = x*mid;
        b = y*mid;
    }
    cout<<a+b<<endl;
    return 0;
}

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

int main() {
	int N,K;
	cin >> N >> K;
	
	string a;
	cin >> a;
	
	a[K-1] = (char)(((int)a[K-1])+32);
	cout << a;
	
	return 0;
}


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

int n, m;
map<string, int> mp;

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	cin >> n;
	for(int i=0; i<n; ++i){
		string s;
		cin >> s;
		if(mp.find(s) == mp.end()) mp[s] = 1;
		else mp[s]++;
	}
	cin >> m;
	for(int i=0; i<m; ++i){
		string s;
		cin >> s;
		if(mp.find(s) != mp.end()) mp[s]--;
	}
	int ans = 0;
	for(auto ite = mp.begin(); ite != mp.end(); ++ite)
		ans = max(ans, ite->second);
	cout << ans << "\n";
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner stdin=new Scanner(System.in);
		int  a=stdin.nextInt();
		int  b=stdin.nextInt();
		String s=stdin.next();
		char c[]=s.toCharArray();
		int flag=0;
//		for(int i=0;i<c.length;i++)
//			System.out.println(c[i]);

		if(a>5 || b>5){
			//			System.out.println("No");
			flag=1;
		}
		if(c[a]!='-' || c.length!=a+b+1){
			//			System.out.println("No");
			flag=1;
		}
		for(int i=0;i<a;i++){
			if(c[i]=='-')
				flag=1;
		}
		for(int i=a+1;i<a+b+1;i++){
			if(c[i]=='-')
				flag=1;
		}


		if(flag==1)
			System.out.println("No");
		else if(flag!=1)
			System.out.println("Yes");
	}
}

Measured memory_bytes: 23380
N,M,X = map(int, input().split())
C = [list(map(int, input().split())) for _ in range(N)]
ans = 100000000000
for i in range(1 << N):
    c = 0
    lis = [0 for _ in range(M)]
    for j in range(N):
        if (i >> j)& 1:
            c += C[j][0]
            lis = [x + y for (x, y) in zip(lis, C[j][1:])]
    if (min(lis) >= X):
        ans = min(ans, c)
if (ans == 100000000000):
    print(-1)
else:
    print(ans)

Measured memory_bytes: 9228
#include<iostream>
using namespace std;
#define MAX 500000
#define SENTINEL 2000000000
int L[MAX/2+2],R[MAX/2+2];
int cnt;
void merge(int A[],int n,int left,int mid,int right){
int n1=mid-left;
int n2=right-mid;
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]=R[n2]=SENTINEL;
int i=0,j=0;
for(int k=left;k<right;k++){
cnt++;
if(L[i]<=R[j]){
A[k]=L[i++];
}else{
A[k]=R[j++];
}
}
}
void mergeSort(int A[],int n,int left,int right){
if(left+1<right){
int mid=(left+right)/2;
mergeSort(A,n,left,mid);
mergeSort(A,n,mid,right);
merge(A,n,left,mid,right);
}
}
int main(){
int A[MAX],n,i;
cnt=0;
cin>>n;
for(i=0;i<n;i++)cin>>A[i];
mergeSort(A,n,0,n);
for(i=0;i<n;i++){
if(i)cout<<" ";
cout<<A[i];
}
cout<<endl;
cout<<cnt<<endl;
return 0;
}



Measured memory_bytes: 7004
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;
typedef vector<P> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<ll,vector<ll>,greater<ll>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
const int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30);
const int INF = (1LL << 60);
const double EPS = (1 >> 30);
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}



signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    int a[7];
    rep(i,7) cin>>a[i];
    int k=0,s=0;
    k+=a[0]+a[3]+a[4]-(a[0]%2+a[3]%2+a[4]%2);
    if(a[0]>0&&a[3]&&a[4]){
        a[0]--;a[3]--;a[4]--;
        s+=3;
    }
    s+=a[0]+a[3]+a[4]-(a[0]%2+a[3]%2+a[4]%2);
    cout<<max(k,s)+a[1]<<endl;
    
}

Measured memory_bytes: 256
N, W = gets.split.map(&:to_i)
# dp = Array.new(N+1){Array.new(W+1, 0)}
dp = Array.new(W+1, 0)
lists = []
N.times do |i|
  lists << gets.split.map(&:to_i)
end
# lists.sort_by!{|x|x[0]}
1.upto(N) do |i|
  noww = lists[i-1][0]
  nowv = lists[i-1][1]
  # lists[i-1][0].upto(W) do |j|
  W.downto(noww) do |j|
      # dp[i][j] = [dp[i-1][j], dp[i-1][j - lists[i-1][0]] + lists[i-1][1]].max
    dp[j] = dp[j - noww] + nowv if dp[j] < dp[j - noww] + nowv
  end
end
# p dp
puts dp.max

Measured memory_bytes: 2556
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		string[] input = Console.ReadLine().Split(' ');
		int n = int.Parse(input[0]);
		int r = int.Parse(input[1]);

    if(n >= 10) Console.WriteLine(r);
    else Console.WriteLine(r+1000-100*n);
	}
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
#define N 200
using namespace std;

int m,n,ans,dp[2][N][N][N];
char mm[N][N];
bool now,cur;

inline void Max(int &u,int v){if(v>u) u=v;}
int main()
{
    int i,j,p,q,l,r,mid;
    cin>>m>>n;
    for(i=1;i<=m;i++) scanf("%s",mm[i]+1);
    now=1;
    for(q=1;q<=m;q++)
    {
	for(p=q;p>=1;p--)
	{
	    for(i=n;i>=1;i--)
	    {
		if(p==q)
		{
		    if(i==n) dp[now][p][q][i]=n+1;
		    if(mm[p][i]==mm[p][i+1]) dp[now][p][q][i]=dp[now][p][q][i+1];
		    else dp[now][p][q][i]=i+1;
		}
		else
		{
		    if(mm[q-1][i]==mm[q][i]) dp[now][p][q][i]=min(dp[now][p][q-1][i],dp[now][q][q][i]);
		    else dp[now][p][q][i]=i;
		}
//		cout<<p<<" "<<q<<" "<<i<<" "<<dp[now][p][q][i]<<endl;
	    }
	}
    }
//    return 0;
    for(ans=0;;ans++)
    {
//	cout<<" "<<dp[now][1][m][1]<<" "<<dp[now][1][1][1]<<" "<<dp[now][2][3][1]<<endl;
	if(dp[now][1][m][1]==n+1)
	{
	    cout<<ans;
	    return 0;
	}
	swap(now,cur);
	for(p=1;p<=m;p++)
	{
	    for(q=p;q<=m;q++)
	    {
		for(i=1;i<=n;i++)
		{
		    if(dp[cur][p][q][i]==n+1) dp[now][p][q][i]=n+1;
		    else dp[now][p][q][i]=dp[cur][p][q][dp[cur][p][q][i]];
		    for(l=p,r=q;l<r;)
		    {
			mid=((l+r)>>1);
//			if(p==1&&q==m&&i==1) cout<<mid<<" "<<q<<" "<<dp[cur][p][mid][i]<<" "<<dp[cur][mid+1][q][i]<<endl;
			Max(dp[now][p][q][i],min(dp[cur][p][mid][i],dp[cur][mid+1][q][i]));
			if(dp[cur][p][mid][i]>dp[cur][mid+1][q][i]) l=mid+1;
			else r=mid;
		    }
		}
	    }
	}
    }
}


Measured memory_bytes: 61440
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        try(Scanner sc = new Scanner(System.in)){
            while(true){
                int n = sc.nextInt();
                if(n == 0) {break;}
                int[] scores = new int[n];
                for(int i=0;i<scores.length;i++){
                    scores[i] = sc.nextInt();
                }
                double average = 0,variance = 0;
                
                double sum = 0;
                for(int i=0;i<n;i++){
                    sum += scores[i];
                }
                average = sum/n;

                int sumsq = 0;
                for(int i=0;i<n;i++){
                    variance += ((scores[i] - average)*(scores[i] - average));
                }


                System.out.println(Math.sqrt(variance/n));
            }
        }
    }
}


Measured memory_bytes: 31456
#include <bits/stdc++.h>
#include <atcoder/all>
#define rep(i,n) for (int i = 0; i < (int)(n); i ++)
#define irep(i,n) for (int i = (int)(n) - 1;i >= 0;--i)
using namespace std;
using namespace atcoder;
using ll = long long;
using PL = pair<ll,ll>;
using P = pair<int,int>;
constexpr int INF = 1000000001;
constexpr long long HINF = 1000000000000000;
constexpr long long MOD = 1000000007;// = 998244353;
constexpr double EPS = 1e-4;
constexpr double PI = 3.14159265358979;

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

    int N,K; cin >> N >> K;
    vector<vector<int>> A(N,vector<int>(N));
    rep(i,N)rep(j,N) cin >> A[i][j];

    mcf_graph<ll,ll> mcf(2*N + 2);
    int s = 2*N,t = 2*N +1;
    
    mcf.add_edge(s,t,(ll)N*K,INF);
    rep(i,N) mcf.add_edge(s,i,K,0);
    rep(i,N) mcf.add_edge(N + i,t,K,0);

    rep(i,N)rep(j,N) {
        mcf.add_edge(i,j + N,1,INF - A[i][j]);
    }

    PL ans = mcf.flow(s,t,(ll)N*K);
    auto E = mcf.edges();
    vector<vector<char>> grid(N,vector<char>(N,'.'));
    for (auto &e:E) {
        if (e.from == s || e.to == t || e.flow == 0) continue;
        grid[e.from][e.to - N] = 'X';
    }
    cout << (ll)N*K*INF - ans.second << '\n';
    rep(i,N) {
        rep(j,N) cout << grid[i][j];
        cout << '\n';
    }
    return 0;
}

Measured memory_bytes: 3932
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define MM 1e9

string str;

void input() {
    cin >> str;
}

void solve(){
    int wincnt=0;
    int k=str.length();
    for (char c:str) {
        //cout << c << endl;
        if (c == 'o') wincnt++; 
    }

    if (15-k + wincnt >= 8) cout << "YES" << endl;
    else cout << "NO" << endl;
    //cout << wincnt << endl;
    //cout << k << endl;
}

int main() {
    input();
    solve();
}



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

int main() {
    ll n;
    cin >> n;
    if(n < 10) cout << n << endl;
    else if (n < 100 && n >= 10) cout << 9 << endl;
    else if (n >= 100 && n <= 999) cout << n - 90 << endl;
    else if (n >= 1000 && n <= 9999) cout << 909 << endl;
    else if (n >= 10000 && n <= 99999) cout <<(n - 9090) << endl;
    else if (n >= 100000 && n <= 999999) cout << 90909 << endl;
    else cout << n - 909090 << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace CSharpSample01
{

    class Vector
    {
        public double x;
        public double y;

        public Vector() { }

        public Vector(double x, double y)
        {
            this.x = x;
            this.y = y;
        }

    }
    
    class Program
    {       
        
        static void Main(string[] args)
        {
            double[] data = Console.ReadLine().Split(' ').Select(x => double.Parse(x)).ToArray();

            Vector p1 = new Vector(data[0], data[1]);
            Vector p2 = new Vector(data[2], data[3]);
            Vector ground = new Vector(data[2] - data[0], data[3] - data[1]);

            int q = int.Parse(Console.ReadLine());

            for(int i = 0; i < q; i++)
            {
                string[] str = Console.ReadLine().Split(' ');
                Vector p = new Vector(int.Parse(str[0]), int.Parse(str[1]));
                Vector hypo = new Vector(p.x - p1.x, p.y - p1.y);

                Vector ans = new Vector();

                ans.x = p1.x + ground.x * (hypo.x * ground.x + hypo.y * ground.y) / (ground.x * ground.x + ground.y * ground.y);
                ans.y = p1.y + ground.y * (hypo.x * ground.x + hypo.y * ground.y) / (ground.x * ground.x + ground.y * ground.y);

                Console.WriteLine($"{ans.x:f8} {ans.y:f8}");

            }

            

        }
    }
}



Measured memory_bytes: 18456
module Main where

import Control.Applicative
import Control.Monad
import Data.List
import qualified Data.ByteString.Char8 as B

readi b | Just (n, _) <- B.readInt b = n

main :: IO ()
main = do
    [_, k] <- fmap readi . B.words <$> B.getLine :: IO [Int]
    as <- fmap readi . B.words <$> B.getLine :: IO [Int]
    let m1 = sortOn length . group . sort $ as
    case length m1 of
        s | s <= k    -> print 0
          | otherwise -> do
                let bs = take (s - k) m1
                print . sum . fmap length $ bs

Measured memory_bytes: 55676
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>

using namespace std;

struct edge {
	int src;
	int dst;
	bool usable;
};

const int inf = 1 << 30;

vector<int> get_distances_from(int N, const vector<vector<edge>> &g, int u)
{
	vector<int> d(N, inf);

	vector<bool> visited(N, false);
	queue<int> q;

	auto visit = [&](int y) {
		if (!visited[y]) {
			visited[y] = true;
			q.push(y);
		}
	};

	visit(u);

	for (int depth = 0; !q.empty(); ++depth) {
		queue<int> q2;
		swap(q, q2);
		while (!q2.empty()) {
			int x = q2.front();
			q2.pop();
			d[x] = depth;
			for (auto &e : g[x]) {
				if (e.usable) {
					visit(e.dst);
				}
			}
		}
	}

	return d;
}


int main()
{
	int N;
	cin >> N;
	int u, v;
	cin >> u >> v;
	--u;
	--v;

	vector<vector<edge>> g(N);
	for (int i = 0; i < N - 1; ++i) {
		int A, B;
		cin >> A >> B;
		--A;
		--B;
		edge eA = { A, B, true };
		edge eB = { B, A, true };
		g[A].push_back(eA);
		g[B].push_back(eB);
	}

	auto d_from_v = get_distances_from(N, g, v);
	auto d_from_u = get_distances_from(N, g, u);

	//cout << "d_from_v" << endl;
	//for (int i = 0; i < N; ++i) {
	//	cout << u + 1 << " -> " << i + 1 << " : " << d_from_v[i] << endl;
	//}

	//cout << "d_from_u" << endl;
	//for (int i = 0; i < N; ++i) {
	//	cout << u  + 1 << " -> " << i + 1 << " : " << d_from_u[i] << endl;
	//}

	int unused_count = 0;

	vector<int> p;
	int cur = v;
	p.push_back(cur);
	while (cur != u) {
		for (auto &e : g[cur]) {
			if (d_from_u[cur] == d_from_u[e.dst] + 1) {
				cur = e.dst;
				p.push_back(cur);

				if (unused_count < (d_from_u[v] + 1) / 2) {
					//cout << "*** " << e.src + 1 << " -> " << e.dst + 1 << " is unusable." << endl;
					for (auto &f : g[e.dst]) {
						if (f.dst == e.src) {
							//cout << "*** " << f.src + 1 << " -> " << f.dst + 1 << " is unusable." << endl;
							f.usable = false;
							break;
						}
					}
					e.usable = false;
					++unused_count;
				}

				break;
			}
		}
	}

	//for (auto x : p) {
	//	cout << " -> " << x + 1;
	//}
	//cout << endl;

	auto d_from_u2 = get_distances_from(N, g, u);
	//for (int i = 0; i < N; ++i) {
	//	cout << u + 1 << " -> " << i + 1 << " : " << d_from_u2[i] << endl;
	//}

	int ans = 0;

	for (int i = 0; i < N; ++i) {
		if (d_from_u2[i] < inf && g[i].size() == 1) {
			ans = max(ans, d_from_v[i] - 1);
		}
	}


	cout << ans << endl;
}


Measured memory_bytes: 8064
#include<stdio.h>
#include<math.h>
void sort(int d[]){
	int i,j,t;
	for(i=0;i<3;i++)
		for(j=i;j<3;j++)
			if(d[i]>d[j]){
				t=d[i];
				d[i]=d[j];
				d[j]=t;
}
}
int main(){
int d[4],i,n,r;
double t;
for(;scanf("%d %d %d",&d[0],&d[1],&d[2])&&(d[0]||d[1]||d[2]);){
		sort(d);
		t=sqrt((double)(d[0]*d[0])+(double)(d[1]*d[1]));
		scanf("%d",&n);
		for(i=0;i<n&&scanf("%d",&r);i++){
			if(2.0*(double)r>t)printf("OK\n");
else printf("NA\n");}}return 0;
}

Measured memory_bytes: 0
#include <iostream>
using namespace std;
int main(void){
    // Here your code !
    int n,a,ans = 0;
    cin >> n >> a;
    
    for(int i = 0; i < n; i++){
        int b;
        cin >> b;
        ans += min(2*b,(a-b)*2);
    }
    
    cout << ans << endl;
    
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int H[100000];
 
int main()
{
	int n, k, r=0;
	cin >> n >> k;
	for (int i = 0; i < n; ++i)
	{
		cin >> H[i];
	if (H[i] >= k)
	r = r + 1;
	}
	cout << r;
    
}

Measured memory_bytes: 640
#include <stdio.h>

int main(){
  int i,j,h;
  int H, W;

  for(h=0;;h++){
    scanf("%d %d", &H, &W);
    if(H == 0 && W == 0){
      break;
    }

    for(i=0; i<H; i++){
      for(j=0; j<W; j++){

        if((i+j) % 2){
          printf(".");
        }

        else{
          printf("#");
        }

      }
    printf("\n");
    }
    printf("\n");
  }

  return 0;

}



Measured memory_bytes: 2108
#include<iostream>
#include<algorithm>

using namespace std;

int main()
{
    int a,b;

    while(cin>>a>>b&&!(a==0&&b==0))
    {
        if(a>b)
        {
            swap(a,b);
        }
        cout<<a<<" "<<b<<endl;
    }

    return 0;
}



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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, K;
  cin >> N >> K;
  vector<int64_t> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  int64_t sum = 0;
  for (auto a : A) {
    sum += a;
  }
  vector<int64_t> divisor;
  for (int64_t i = 1; i * i < sum + 1; i++) {
    if (sum % i == 0) {
      divisor.emplace_back(i);
      divisor.emplace_back(sum / i);
    }
  }
  int64_t res = 0;
  for (auto d : divisor) {
    vector<int64_t> R(N);
    for (int i = 0; i < N; i++) {
      R[i] = A[i] % d;
    }
    sort(R.begin(), R.end());
    vector<int64_t> ACC = {0}, BCC = {0};
    for (auto r : R) {
      ACC.emplace_back(ACC.back() + r);
      BCC.emplace_back(BCC.back() + ((2 * d - r) % d));
    }
    for (int i = 0; i < (int)ACC.size(); i++) {
      if (BCC.back() - BCC[i] == ACC[i] && ACC[i] <= K) {
        res = max(res, d);
      }
    }
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 3620
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>
using namespace std;
#define ALL(x) (x).begin(), (x).end()
#define OUT(x) cout << (x) << endl
typedef long long ll;

int main() {
    string s;
    cin >> s;
    int len = s.size();
    int cnt = 0;
    for (int i = 0; i < len / 2; i++) {
        if (s[i] != s[len - 1 - i]) cnt++;
    }
    OUT(cnt);
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <iomanip>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// #define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define For(i,x,y) for(int i = x; i <= y; ++i)
#define FOR For
#define rev_For(i,x,y) for(int i = x; i >= y; --i)
#define REV_FOR rev_For
#define ll long long
#define Size(v) ((int)v.size())
#define _section "\n--------------------\n"
#define fi first
#define se second
#define pb push_back
using namespace std;
// using namespace __gnu_pbds;


int n, M;
const int nax = 105;
int a[nax];

void input() {
	cin >> n >> M;
	FOR (i, 1, n) {
		cin >> a[i];
	}
}

void solve() {
	int sum = 0;
	FOR (i, 1, n) sum += a[i];

	int cnt = 0;
	FOR (i, 1, n) {
		if (double(a[i]) >= sum * double(1) / (4 * M)) ++cnt;
	}

	if (cnt >= M) cout << "Yes";
	else cout << "No";
}

signed main() {
#ifdef _DEBUG
	// freopen("INPUT.inp", "r", stdin);
	//freopen("OUTPUT.out", "w", stdout);
	clock_t start, end;
	start = clock();
#endif
	ios_base::sync_with_stdio(0);
	cin.tie(0);
//------------------------------------------------------------------------------------
//----------------------------------MAIN PROGRAM--------------------------------------
	int t = 1;
	while (t--) {
		input();
		solve();
	}
//--------------------------------------END-------------------------------------------
//------------------------------------------------------------------------------------
#ifdef _DEBUG
	end = clock();
	cerr << "\n----------\nTime Elapsed: " << fixed << double(end - start) / double(CLOCKS_PER_SEC) << setprecision(6) << '\n';
#endif
	return 0;
}

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

int main()
{
	int a, b, all = 0;
	int c[100000];
	//string str;
	cin >> a >> b;

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

	a -= all;
	if (a >= 0)
	{
		//a -= all;
		cout << a << "\n";
	}
	else
	{
		cout << "-1" << "\n";
	}
}

Measured memory_bytes: 3684
//
// Created by Nihith on 22-02-2020.
//
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int N,R;
    cin>>N>>R;
    if(N>=10) cout<<R<<endl;
    else cout<<(R+100*(10-N))<<endl;
    return 0;
}



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

typedef long double ld;

const int Maxn = 606;

int n, m;
vector <int> neigh[Maxn];
ld a[Maxn], b[Maxn];
ld res = Maxn;

void Fill(int lef, int rig)
{
    for (int j = rig; j >= lef; j--) {
        a[j] = b[j] = 0;
        for (int z = 0; z < neigh[j].size(); z++) {
            int k = neigh[j][z];
            a[j] += a[k];
            b[j] += 1.0l + b[k];
        }
        a[j] /= ld(neigh[j].size());
        b[j] /= ld(neigh[j].size());
    }
}

int main()
{
    scanf("%d %d", &n, &m);
    for (int i = 0; i < m; i++) {
        int a, b; scanf("%d %d", &a, &b);
        neigh[a].push_back(b);
    }
    for (int x = 0; x < n; x++) {
        Fill(x + 1, n - 1);
        a[x] = 1; b[x] = 0;
        Fill(1, x - 1);
        if (x == 0) res = min(res, b[1]);
        else if (neigh[x].size() > 1) {
            ld sum = 0, mx = 0;
            for (int z = 0; z < neigh[x].size(); z++) {
                int k = neigh[x][z];
                sum += 1.0l + b[k];
                mx = max(mx, 1.0l + b[k]);
            }
            ld val = (sum - mx) / ld(int(neigh[x].size()) - 1);
            res = min(res, a[1] * val + b[1]);
        }
    }
    cout << fixed << setprecision(10) << res << endl;
    return 0;
}


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

int main(void) {
  int a, b;
  char op;
  cin >> a >> op >> b;
  if(op == '+')
  cout << a+b << endl;
  else
  {
    cout << a-b << endl;
  }
  
}

Measured memory_bytes: 3616
#http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_7_D
require 'matrix'

n,m,l = gets.split.map(&:to_i)

a = []
b = []

n.times do
    a.push gets.split.map(&:to_i)
end

m.times do
    b.push gets.split.map(&:to_i)
end

A = Matrix.rows(a)
B = Matrix.rows(b)

c = A * B
c.to_a.each do |row|
    puts row.join(" ")
end

Measured memory_bytes: 7424
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;

vector<int>bitSearch(int bit,int n){
    vector<int>S;
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}

ll gcd(ll a,ll b){
    if(b==0)return a;
    return gcd(b,a%b);
}

const int mod = INF+7;
int main(){
    ll a,b;cin>>a>>b;
    ll n = gcd(a,b);
    ll res = 1;
    for(ll i=2;i*i<=n;i++){
        if(n%i!=0)continue;
        res++;
        while(n%i==0)n /= i;
    }
    if(n!=1)res++;
    cout<<res<<endl;
}



Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"log"
	"math"
	"os"
	"strconv"
	"strings"
)

func lcm(a, b int) int {
	return a / gcd(a, b) * b
}
func gcd(m, n int) int {
	if n == 0 {
		return m
	}
	return gcd(n, m%n)
}
func main() {
	scanner := makeWordScanner()
	a := eGetInt(scanner)
	b := eGetInt(scanner)
	fmt.Println(lcm(a, b))
}

////////////////////////////////////////////////////////////////////////////////
// ライブラリ
////////////////////////////////////////////////////////////////////////////////
func makeScanner(maxByte int) *bufio.Scanner {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]uint8, 0, 8192), maxByte)
	return scanner
}
func makeCharScanner() *bufio.Scanner {
	scanner := makeScanner(8192)
	scanner.Split(bufio.ScanRunes)
	return scanner
}
func makeWordScanner() *bufio.Scanner {
	scanner := makeScanner(8192)
	scanner.Split(bufio.ScanWords)
	return scanner
}
func eGetLine(r *bufio.Scanner) string {
	if r.Scan() {
		return r.Text()
	}
	err := r.Err()
	if err != nil {
		log.Fatal(err)
	}
	// EOF
	return ""
}
func eGetInt(r *bufio.Scanner) int {
	line := eGetLine(r)
	return eAtoi(line)
}
func eGetInt64(r *bufio.Scanner) int64 {
	line := eGetLine(r)
	return eAtoInt64(line)
}
func eGetFields(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Fields(line)
}
func eGetInts(r *bufio.Scanner) []int {
	fields := eGetFields(r)
	ints := make([]int, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoi(fields[i])
	}
	return ints
}
func eGetInt64s(r *bufio.Scanner) []int64 {
	fields := eGetFields(r)
	ints := make([]int64, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoInt64(fields[i])
	}
	return ints
}
func eGetChars(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Split(line, "")
}
func eAtoi(s string) int {
	n, err := strconv.Atoi(s)
	if err != nil {
		log.Fatal(err)
	}
	return n
}
func eAtoInt64(s string) int64 {
	n, err := strconv.ParseInt(s, 10, 64)
	if err != nil {
		log.Fatal(err)
	}
	return n
}
func pow(a, n int) int {
	return int(math.Pow(float64(a), float64(n)))
}
func countBitOfOn(i, numbits int) int {
	count := 0
	var bit uint64
	for bit = 0; bit < uint64(numbits); bit++ {
		t := 1 << bit
		if i&t > 0 {
			count++
		}
	}
	return count
}


Measured memory_bytes: 640
#include <stdio.h>

int main(){
	int sx, sy, tx, ty, i;
	scanf("%d%d%d%d", &sx, &sy, &tx, &ty);
	for(i = sx; i < tx; i++){
		printf("R");
	}
	for(i = sy; i < ty; i++){
		printf("U");
	}
	printf("R");
	for(i = ty; i >= sy; i--){
		printf("D");
	}
	for(i = tx; i >= sx; i--){
		printf("L");
	}
	printf("U");
	for(i = sy; i < ty; i++){
		printf("U");
	}
	for(i = sx; i < tx; i++){
		printf("R");
	}
	printf("U");
	for(i = tx; i >= sx; i--){
		printf("L");
	}
	for(i = ty; i >= sy; i--){
		printf("D");
	}
	printf("R\n");
	return 0;
}

Measured memory_bytes: 128
S = list(input())
if (S[0] == S[1] and S[2] == S[3] and S[0] != S[2])or (S[0] == S[2] and S[1] == S[3] and S[0] != S[1])or (S[0] == S[3] and S[1] == S[2] and S[0] != S[1]):
    print('Yes')
else:
    print("No")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int> >;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define mp make_pair
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
typedef long long ll;
const int INF = 2000000000;
const ll INF64 = 1000000000000000ll;
const ll MOD = 1000000007LL;
typedef unsigned int uint;
int main(){
    int a,b;
    std::cin >> a>>b;
    if(a<b){
        rep(i,b)std::cout << a ;
        std::cout << std::endl;
    }
    else{
        rep(i,a)std::cout << b ;
        std::cout << std::endl;
    }
}

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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 30;

int main() {
  int n;
  cin >> n;
  vector<ll> v(n + 2);
  for (int i = 1; i <= n; i++) {
    cin >> v[i];
  }

  ll res = 0;                     // 先に全て回った時の合計を計算しておく
  for (int i = 0; i <= n; i++) {  // {0,3,-5,1,0}みたいな
    res += abs(v[i + 1] - v[i]);
  }

  for (int i = 0; i < n; i++) {
    int d = abs(v[i + 2] - v[i]) - (abs(v[i + 1] - v[i]) + abs(v[i + 2] - v[i + 1]));
    cout << res + d << endl;
  }
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
const int maxn=1e5+5;
char s[maxn];
int  is[maxn];
bool solve(int x, int y, int len)
{
      int i, j;
      is[0]=x;
      is[1]=y;
      for(i=2; i<=len+1; i++)
      {
	 if(is[i-1])
	 {
	    if(s[i-1]=='o')is[i]=is[i-2];
	    else is[i]=!is[i-2];
	 }
	 else  //前面的人说了假话
	 {
	    if(s[i-1]=='o')is[i]=!is[i-2];
	    else is[i]=is[i-2];
	 }
      }
	  /* for(i=0; i<len+2; i++)
	   {
	      printf(is[i]?"S":"W");
	   }
	   printf("\n");
	   */
      if(is[len]== is[0] && is[len+1]==is[1])
      {
	   for(i=0; i<len; i++)
	   {
	      printf(is[i]?"S":"W");
	   }
	   printf("\n");
	   return 1;
      }
      return 0;

}

int main()
{
   int n;
   scanf("%d", &n);
   int i;
   scanf("%s", s);
   int len=strlen(s);
   s[len]=s[0];
   s[len+1]=s[1];
   s[len+2]='\0';
   int j;
   for(i=0; i<2; i++)
   {
     for(j=0; j<2; j++)
     {
	if(solve(i, j, len))return 0;
     }
   }
   printf("-1\n");
}

Measured memory_bytes: 768
#include<cstdio>
#include<algorithm>
using namespace std;

typedef long long ll;
const int Maxn=1e6;
const ll Mod=1e9+7;

ll fac[Maxn+5],inv_fac[Maxn+5];
ll QuickPow(ll a,ll k) {
	ll ret=1;
	while(k) {
		if(k&1)ret=(ret*a)%Mod;
		a=(a*a)%Mod;
		k>>=1;
	}
	return ret;
}
void init() {
	fac[0]=1;
	for(int i=1;i<=Maxn;i++)
		fac[i]=fac[i-1]*i%Mod;
	inv_fac[0]=1,inv_fac[Maxn]=QuickPow(fac[Maxn],Mod-2);
	for(int i=Maxn-1;i>=1;i--)
		inv_fac[i]=inv_fac[i+1]*(i+1)%Mod;
}
ll C(int n,int m){return fac[n]*inv_fac[m]%Mod*inv_fac[n-m]%Mod;}

ll calc(int n,int m,int num,int l,int r) {
	if(num-1LL*r*m<0)return 0;
	else num-=(r*m);
	ll ret=0;
	for(int i=0,dir=1;i<=n-m&&num>=0;i++,num-=l,dir*=-1)
		ret=(ret+1LL*dir*C(num+n,n)%Mod*C(n-m,i)%Mod+Mod)%Mod;
	return ret*C(n,m)%Mod;
}
ll Solve(int n,int m,int num) {
	ll ret=C(n+num,n);
	for(int i=num;i>=1;i--) {
		int del=(calc(n,m,num,i,i)-calc(n,m,num,i,i+1)+Mod)%Mod;
		ret=(ret-del+Mod)%Mod;
	}
	return ret;
}

int main() {
	#ifdef LOACL
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
	#endif
	int N,M,L,R;
	init();
	scanf("%d %d %d %d",&N,&M,&L,&R);
	printf("%lld\n",(Solve(N,M,R)-Solve(N,M,L-1)+Mod)%Mod);
	return 0;
}

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

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

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

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF   = 1e9;
const ll  INFLL = 1e18;
typedef pair<int, int> PII;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};

int main()
{
    ios::sync_with_stdio(false);

    int K, S;
    cin >> K >> S;

    int ans = 0;
    for (int X=0; X<=K; X++) {
        for (int Y=0; Y<=K; Y++) {
            int Z = S - X - Y;
            if (0 <= Z && Z <= K) ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
#include<iostream>
using namespace std;
int main()
{
int a,b,x;
cin>>a>>b>>x;
int y=a+b; 
if(a-1<x&&y>x)
cout<<"YES";
else if(a-1<x&&y==x)
cout<<"YES";
else
cout<<"NO";
system ("pause");
return 0;
}

Measured memory_bytes: 504
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); } bool DEBUG = 0; 
void log(A ...)(lazy A a){ if(DEBUG) print(a); }
void print(){ writeln(""); } void print(T)(T t){ writeln(t); } void print(T, A ...)(T t, A a){ write(t, " "), print(a); }
string unsplit(T)(T xs){ return xs.array.to!(string[]).join(" "); }
string scan(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T scan(T)(){ return scan.to!T; } T[] scan(T)(int n){ return n.iota.map!(i => scan!T()).array; }
T lowerTo(T)(ref T x, T y){ if(x > y) x = y; return x; } T raiseTo(T)(ref T x, T y){ if(x < y) x = y; return x; }

// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- //

void solve(){
	int n = scan!int;
	long[] as = scan!long(n);
	long ans = 1;
	foreach(a; as) ans = lcm(ans, a);
	ans.writeln;    
}


/// 最大公約数。最大の公約数。
/// 例 gcd(12, -18) = 6, gcd(-12, -18) = 6, gcd(12, 0) = 12, gcd(0, 0) = 0
/// ※本当は gcd(0, 0) は存在しないが便宜上 0 を返している
long gcd(long a, long b){
	if(a < 0) a = -a;
	if(b == 0) return a;
	if(b < 0) return gcd(a, -b);
	if(a % b == 0) return b;
	if(a < b) return gcd(b, a);
	else return gcd(b, a % b);
}

/// 最小公倍数。0以上で最小の公倍数。
/// 例 lcm(12, -18) = 36, lcm(-12, -18) = 36, lcm(12, 0) = 36, lcm(0, 0) = 0
long lcm(long a, long b){
	if(a < 0) a = -a; if(b < 0) b = -b;
	if(a == 0 && b == 0) return 0;
	return (a / gcd(a, b) * b);
}



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


#include "boost/multiprecision/cpp_int.hpp"
#include "boost/multiprecision/cpp_dec_float.hpp"
namespace mp = boost::multiprecision;
typedef mp::cpp_int LL;
typedef mp::number<mp::cpp_dec_float<1024>> DD;// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)

 
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define rrep(i,r,l) for(ll i=r;i>=l;i--)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"  //インタラクティブで消す！！！！！！！！！！！！！！！！！！！！！
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
template<class T,class S>
inline bool chmax(T &a, S b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T,class S>
inline bool chmin(T &a, S b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

void mod_print(ll k){
    ll P=1000;
    rep(y,1,P){
        ll x=mod(y*k);
        if(x+P>=i_7){
            x-=i_7;
        }
        if(abs(x)<=P){
            //cout<<x<<"/"<<y;
            cout<<setprecision(5)<<(dd)x/(dd)y;
            return;
        }
    }
    cout<<"nun"<<endl;
}
#define all(c) c.begin(),c.end()
//////////////////////////




int main(){fastio
    ll n;cin>>n;
    vector<ll> v[n+1];
    rep(i,1,n-1){
        ll a,b;cin>>a>>b;
        if(a>b)swap(a,b);
        v[b].pb(a);
    }
    ll ans=0;
    rep(i,1,n){
        ll res=0;
        v[i].pb(0);v[i].pb(i);
        SORT(v[i]);
        reverse(all(v[i]));
        ll vs=v[i].size();
        rep(j,0,vs-2){
            res+=(1-j)*(v[i][j]-v[i][j+1]);
        }
        ans+=res*(n+1-i);
    }
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 19480
#include<stdio.h>
#include<math.h>

#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2

int prim(int);

int M[N][N];

int main(void){
  int n;
  int i,j;

  scanf(" %d",&n);
  for(i = 0; i < n; i++){
    for(j = 0; j < n; j++){
      scanf(" %d",&M[i][j]);
    }
  }

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

int prim(int n){
  int sum=0,mincost,color[N],d[N],p[N];
  int i,v,u;

  for(i = 0; i < n; i++){
    color[i] = WHITE;
    d[i] = (int)INFINITY;
  }
  d[0] = 0;
  p[0] = -1;

  while(1){
    mincost = (int)INFINITY;
    for(i = 0; i < n; i++){
      if(color[i] != BLACK && d[i] < mincost){
	mincost = d[i];
	u = i;
      }
    }

    if(mincost == (int)INFINITY){
      break;
    }

    color[u] = BLACK;

    for(v = 0; v < n; v++){
      if(color[v] != BLACK && M[u][v] != -1){
	if(M[u][v] < d[v]){
	  d[v] = M[u][v];
	  p[v] = u;
	  color[v] = GRAY;
	}
      }
    }
  }

  for(i = 0; i < n; i++){
    sum += d[i];
  }

  return sum;
}



Measured memory_bytes: 2112
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	ll a, b;
	while (cin >> a >> b) {
		if (a == 0 && b == 0)break;
		ll k = b - a;
		ll x = k / 1000;
		ll y = (k - 1000 * x) / 500;
		ll z = (k - 1000 * x - 500 * y) / 100;
		cout << z << " " << y << " " << x << endl;
	}
}



Measured memory_bytes: 3088
N,L = map(int,input().split())
s = 0
lst = []
for i in range(1,N+1):
  s += i + L - 1
  lst.append(abs(i+L-1))
if L >= 0:
  ans = s - min(lst)
else:
  ans = s + min(lst)
print(ans)


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

long long a, b;
long long cnt;

int main() {
	cin >> a >> b;
	if (a == 0 || b == 0)
		return cout << "Zero" << '\n', 0;
	if (a > 0 && b > 0)
		return cout << "Positive" << '\n', 0;
	if ((a < 0 && b > 0) || (b < 0 && a > 0)) 
		return cout << "Zero" << '\n', 0;
	else {
		a *= -1;
		b *= -1;

		cnt = max(a, b) - min(a, b) + 1;
	
		if (cnt % 2 == 0)
			return cout << "Positive" << '\n', 0;
		else
			return cout << "Negative" << '\n', 0;
	}
	return 0;
}


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

ll dp[102][100003]={-1};

ll solve(pair<ll,ll>p[],ll W,ll n)
{
if(n==0||W==0)
    return 0;
if(dp[n][W]!=-1)
        return dp[n][W];
if(p[n-1].first<=W){
    return dp[n][W]=max(p[n-1].second+solve(p,W-p[n-1].first,n-1),solve(p,W,n-1));
}
else return dp[n][W]=solve(p,W,n-1);
}

int main(){
    memset(dp,-1,sizeof(dp));
ll n,W,i;
cin>>n>>W;
pair<ll,ll>p[n];
for(i=0;i<n;i++){
    ll w,v;
    cin>>w>>v;
    p[i].first=w;
    p[i].second=v;
}
cout<<solve(p,W,n)<<endl;
return 0;
}


Measured memory_bytes: 83324
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split();
            int n = int.Parse(str[0]);
            int m = int.Parse(str[1]);

            int l = (m + 1) / 2;
            int r = m / 2;

            for (int i = 1; i <= l; ++i)
            {
                Console.Write(i);
                Console.Write(" ");
                Console.WriteLine(2 * l - (i - 1));
            }
            for (int i = 1; i <= r; ++i)
            {
                Console.Write(i + 2 * l);
                Console.Write(" ");
                Console.WriteLine(2 * m + 1 - (i - 1));
            }
        }
    }
}


Measured memory_bytes: 33304
#include <iostream>
using namespace std;
int main(){
    char A,B,C;
    char D,E,F;
    cin >> A >> B >> C;
    cin >> D >> E >> F;
    if(A == F){
        if(D == C){
            if(B ==E){
                cout << "YES" << endl;
            }
             else {
        cout << "NO" << endl; }
        }
         else {
        cout << "NO" << endl;
    }
    }
    else {
        cout << "NO" << endl;
    }

}

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 ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll a,b,n;
  cin >> a >> b >> n;
  ll ans;
  if(n>=b){
    ans = (a*(b-1)/b);
  }else{
    ans = (a*n/b);
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3568
#include<iostream>
using namespace std;
int main(){
   int n;
   cin>>n;
   if(n%10==7)
      cout<<"Yes";
   else{
      n/=10;
      if(n%10==7)
      cout<<"Yes";
      else{
         n/=10;
         if(n==7)
            cout<<"Yes";
         else cout<<"No";
      }
   }
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define rep(var,cnt) for(int (var)=0; (var)<(int)(cnt); ++(var))
#define Rep(var,init,cnt) for(int (var)=(init); (var)<(int)(cnt); ++(var))
#define ran(var,vec) for(auto &(var):(vec))
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define SORT(v) sort(all(v))
#define RSORT(v) sort(rall(v))
#define SUM(v) accumulate(all(v),0)
#define tget(tp,idx) get<idx>(tp)
#define TF(flag) ((flag)?1:0)
#define YN(flag) cout<<(flag?"YES":"NO")<<endl;
#define Yn(flag) cout<<(flag?"Yes":"No")<<endl;
#define yn(flag) cout<<(flag?"yes":"no")<<endl;
#define Cout(v) cout<<(v)<<endl
using namespace std;

using ll = long long;
using ull = unsigned long long;
using pi = pair<int,int>;
using pl = pair<ll,ll>;
using ti = tuple<int,int,int>;
using tl = tuple<ll,ll,ll>;

template<typename T>
using vec = vector<T>;
template<typename T>
using mat = vector<vec<T>>;
template<typename T>
using cub = vector<mat<T>>;
template<typename T>
using val = valarray<T>;

template<typename T>
using pq = priority_queue<T>;
template<typename T>
using rpq = priority_queue<T,vec<T>,greater<T>>;

template<typename T1,typename T2>
ostream &operator<<(ostream &os, const pair<T1,T2> &p){
  os<<"P("<<p.first<<", "<<p.second<<") ";
  return os;
}

template<typename T1,typename T2>
istream &operator>>(istream &is, pair<T1,T2> &p){
  is>>p.first>>p.second;
  return is;
}

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  cout<<"V{";
  for(int i=0; i<(int)v.size(); ++i){
    os<<v[i]<<(i+1!=v.size()?" ":"");
  }
  cout<<"}";
  return os;
}

template<typename T>
istream &operator>>(istream &is, vector<T> &v){
  for(T &in:v) is>>in;
  return is;
}

template<typename T>
ostream &operator<<(ostream &os, const valarray<T> &v){
  cout<<"V{";
  for(int i=0; i<(int)v.size(); ++i){
    os<<v[i]<<(i+1!=v.size()?" ":"");
  }
  cout<<"}";
  return os;
}

template<typename T>
istream &operator>>(istream &is, valarray<T> &v){
  for(T &in:v) is>>in;
  return is;
}

// Usual Template End ===================

// Template End =========================

int main(void){
  int N; cin>>N;
  YN(N==3||N==5||N==7);
}












Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  vi a(3);
  rep(i,3) cin >> a[i];
  sort(rng(a));
  uni(a);
  cout << sz(a) << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[50];
int ptr;
int main()
{
	int n,k;
	cin>>n>>k;
	while(n!=0){
		a[ptr++]=n%k;
		n/=k;
	}
	reverse(a,a+ptr);
	cout<<ptr<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
using namespace std;
char a[100], b[100];
int main(){
	cin >> a >> b;
	int n = 0, m = 0;
	int len1 = strlen(a);
	int len2 = strlen(b);
	while (n < len1||m < len2){
		while (n < len1){ cout << a[n]; n++; break; }
		while (m < len2){ cout << b[m]; m++; break; }
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define FOR(n) for(int i=0;i<n;i++)
#define FORJ(n) for(int j=0;j<n;j++)
#define PRN(n) printf("%d\n",n)
#define PRF(n) printf("%lf\n",n)
#define PRL(n) printf("%lld\n",n)
#define PRS(s) printf("%s\n",s)
#define PRC(c) printf("%c",c)
#define INI(n) scanf("%d",&n)
#define INL(n) scanf("%lld",&n)
#define INS(s) scanf("%s",s)
#define INF 10000000000
#define mod 1000000007
#define X 1000000
typedef long long int ll;
ll finv[X];
ll fac[X];
ll inv[X];
ll usort(const void *a, const void *b){return *(ll*)a-*(ll*)b;}
ll dsort(const void *a, const void *b){return *(ll*)b-*(ll*)a;}
ll ssort(const void *a, const void *b){return strcmp((char*)a,(char*)b);}
ll min(ll a,ll b){
  if(a>b)return b;
  return a;
}
ll max(ll a,ll b){
  if(a>b)return a;
  return b;
}
ll z(ll a){return max(a,-a);}
ll gcd(ll a,ll b){if(!b){return a;}else{return gcd(b,a%b);}}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
ll kt(ll a){
  ll sum=0;
  while(a){
    a/=10;
    sum++;
  }
  return sum;
}
ll ks(ll a){
  ll sum=0;
  while(a){
    sum+=a%10;
    a/=10;
  }
  return sum;
}
void nCrReady(){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  for (int i=2;i<X;i++){
    fac[i]=fac[i-1]*i%mod;
    inv[i]=mod-inv[mod%i]*(mod/i)%mod;
    finv[i]=finv[i-1]*inv[i]%mod;
  }
}
ll nCr(int n,int k){
  return fac[n]*(finv[k]*finv[n-k]%mod)%mod;
}

int main(void){
  int n,k,cnt=0;
  INI(n);
  INI(k);
  for(;n;n/=k,cnt++){}
  PRN(cnt);
  return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
#include<stdlib.h>

int main(){
	int max,temp,a[100],N,i,sum=0,c,k;
	scanf("%d",&N);
	for(i=1;i<=N;i++){
		scanf("%d",&a[i]);
	}
	for(k=1,i=2;i<=N;i++){
		if(a[k]<a[i]){
			k=i;
			temp=a[k];
			a[k]=a[i];
			a[i]=temp;
		}
	}
	for(i=1;i<=N;i++){
		if(i==k){
			sum+=a[i]/2;
		}
		else{
			sum+=a[i];
		}
	}


	printf("%d",sum);
	system("pause");
}






Measured memory_bytes: 376
#include <iostream>
#include <vector>
#include <iomanip>
#include <stack>
#include <array>
#include <deque>
#include <forward_list>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <algorithm>
#include <iterator>
#include <string>
#include <cstring>
//#include <fstream>
#include <complex>
#define _USE_MATH_DEFINES
#include <cmath>
#include <math.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n;i>0;i--)
#define arep(a,i,n) for(int i=(a);i<(n);i++)
#define SORT(v) sort((v).begin(),(v).end())
const ll INF = (1LL << 50);
typedef pair<int, int> P;

int main() {

	int N;
	cin >> N;

	vector<int>A(N);

	REP(i, N) cin >> A[i];

	if (N == 1) {
		cout << 1 << endl;
		return 0;
	}

	int cnt = 0;
	int i = 0;
	while(true) {
		if (A[i + 1] == A[i]) {
			i++;
		}
		else if (A[i + 1] > A[i]) {
			while (A[i + 1] >= A[i]) {
				i++;
				if (i == N - 1) {
					cnt++;
					break;
				}
			}
			if (i == N - 1) break;
			cnt++;
			i++;
		}
		else {
			while (A[i + 1] <= A[i]) {
				i++;
				if (i == N - 1) {
					cnt++;
					break;
				}
			}
			if (i == N - 1) break;
			cnt++;
			i++;
		}

		if (i == N - 1) {
			cnt++;
			break;
		}

	}

	cout << cnt << endl;

	return 0;

}

Measured memory_bytes: 640