akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>

using namespace std;

int main(void){
  string s;
  cin >> s;
  int res = s.size();
  for (int i = 0; i < s.size()-1; ++i) {
    if (s[i] != s[i+1])
        res = min(res, max(i+1, (int)s.size()-i-1));
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#include<unistd.h>
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;

int main(){
    int N,M;cin>>N>>M;
    vector<vector<int>> graph(N);
    REP(i,M){
        int a,b; cin>>a>>b;
        a--;b--;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    vector<int> f,b;
    vector<bool> used(N,false);
    bool judge=false;
    f.push_back(0);
    b.push_back(graph[0][0]);
    used[0]=used[graph[0][0]]=true;
    while(!judge){
        judge=true;
        for(auto e:graph[f.back()]){
            if(!used[e]){
                judge=false;
                f.push_back(e);
                used[e]=true;
                break;
            }
        }
        if(!judge) continue;
        for(auto e:graph[b.back()]){
            if(!used[e]){
                judge=false;
                b.push_back(e);
                used[e]=true;
                break;
            }
        }
    }
    cout<<f.size()+b.size()<<endl;
    for(int i=f.size()-1;i>=0;--i){
        cout<<f[i]+1<<" ";
    }
    REP(i,b.size()){
        cout<<b[i]+1<<" \n"[i==b.size()-1];
    }
}


Measured memory_bytes: 6844
fn main() {
    use std::io::Read;
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    
    let n: usize = iter.next().unwrap().parse().unwrap();
    let k: usize = iter.next().unwrap().parse().unwrap();
    let mut h: Vec<u64> = (&mut iter).take(n).map(|x| x.parse().unwrap()).collect();
    h.sort();
    
    let mut ret = 1u64 << 60;
    for i in (0..).take_while(|&i| i + k - 1 < n) {
        ret = std::cmp::min(ret, h[i+k-1] - h[i]);
    }
    println!("{}", ret);
}

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

int main() {
  int w, h, x, y, r;
  cin >> w >> h >> x >> y >> r;

  string ans = "Yes";
  if (x - r < 0 || x + r > w || y - r < 0 || y + r > h) {
    ans = "No";
  }

  cout << ans << endl;
}



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

int main()
{
int i;
int iVal;
char S[ 10 ];

	ios::sync_with_stdio( false );
	cin.tie( 0 );

	cin >> S;

	iVal = 0;
	for( i = 0; i < 4; i++ )
	{
		if( S[ i ] == '+' )
			iVal++;
		else
			iVal--;
	}

	cout << iVal << endl;

	return 0;
}






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

public class Prog
{
    public struct Pair { public int x, y; public Pair(int x, int y) { this.x = x; this.y = y; } }
    public static void Solve()
    {
        int A = NextInt();
        int B = NextInt();
        Console.WriteLine(Math.Max(A-B,Math.Max(A+B,A*B)));
    }
    public static void Main()
    {
        var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        Solve();
        Console.Out.Flush();
    }

    public static long RepPow(long x, long p, long m = 1000000007)
    {
        if (p == 0) return 1;
        if (p == 1) return x % m;
        long b = RepPow(x, p / 2, m) % m;
        if (p % 2 == 0) { return (b * b) % m; }
        else { return (x * ((b * b) % m)) % m; }
    }
}
public class MinTree
{
    private List<int> table = new List<int>();
    private static int size = 1;
    private static int high = 1;
    public MinTree(int n, int k = 0)
    {
        while (size < n) size *= 2;
        high = (int)Math.Log(size, 2);
        for (int i = 0; i < 2 * size - 1; i++) table.Add(k);
    }
    public void Add(int x, int v)
    {
        x += size - 1;
        table[x] += v;
        table[x] = Math.Max(0, table[x]);
        while (x != 0)
        {
            x = (x % 2 == 0 ? x / 2 - 1 : x / 2);
            table[x] = table[x * 2 + 1] + table[x * 2 + 2];
        }
    }
    public int MLS(int k)
    {
        if (table.First() == 0) return -1;
        int index = 0;
        for (int y = 0; y < high; y++)
        {
            int left = index * 2 + 1;
            int right = index * 2 + 2;
            if (table[left] >= k) index = left;
            else { k -= table[left]; index = right; }
        }
        return index - size + 1;
    }
}
public class Input
{
    public const long MOD = 1000000007;
    public const int INF = 1000000007;
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
    public long Abs(long a, long b) => Math.Abs(a - b);
}


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

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pl;

const int INT_INF = 2147483646;
const ll LL_INF = 9223372036854775807;

bool SecondCompare(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}
 
bool SecondCompareDes(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
}

ll minll(ll a, ll b){
    if(a >= b)  return b;
    else    return a;
}

ll maxll(ll a, ll b){
    if(a >= b)  return a;
    else    return b;
}

ll gcd(ll a, ll b){
    ll tmp;
    if(a%b == 0){
        return b;
    }
    else{
        return gcd(b, a%b);
    }
}
const double PI=3.1415926535897932;

const ll SIZE = 1e5+10;

double a,b,x;

int main(){
    cin >> a >> b >> x;
    double tei = a*b;
    double ans1 = 2.0*x/tei;
    

    if(ans1 > a){
        ans1 = 2*(a*a*b-x);
        ans1 = ans1 / (a*a);
        ans1 = atan2(ans1,a) / PI * 180.0;
    }
    else{
        ans1 = atan2(b,ans1)/PI * 180.0;
    }
    cout << setprecision(10) << ans1 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <algorithm>
#include <vector>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
using pii = pair<int, int>;
using pll = pair<LL, LL>;


int main()
{
    cin.sync_with_stdio(0);

    int N, K;
    cin >> N >> K;

    vector<int> nrs;
    while (N--)
    {
        int nr;
        cin >> nr;

        nrs.emplace_back(nr);
    }

    partial_sort(begin(nrs), begin(nrs) + K, end(nrs));

    cout << accumulate(begin(nrs), begin(nrs) + K, 0);
}

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

int main()
{
    long long n;
    cin >> n;
    map<long long,long long>mp;
    for(long long i=0;i<n;i++)
    {
        long long a;
        cin >> a;
        mp[a]++;
        if(mp[a]!=1)
        {
            mp[a]=0;
        }
    }
    map<long long,long long>::iterator it;
    long long res =0;
    for(it=mp.begin();it!=mp.end();it++)
    {
        if(it->second==1)
        {
         //   cout << it->first << ' ';
            res ++;
        }
    }
    cout << res << '\n';
    return 0;
}


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

int main() {
  ll N;
  string S;
  cin >> N >> S;
  
  ll R = 0;
  ll B = 0;
  ll G = 0;
  for(ll i = 0; i < N; i++) {
    if (S[i] == 'R') R++;
    if (S[i] == 'B') B++;
    if (S[i] == 'G') G++;
  }
  
  ll teg = R * B *G;
  ll exc = 0;
 
  for (ll i = 1; i <= (N-1)/2; i++) {
    for (ll j = 0; j < N - 2*i; j++) {
      if (S[j] != S[j+i] && S[j+i] != S[j+2*i] && S[j+2*i] != S[j]) {
        exc += 1; 
      }
    }
  }
  
  cout << teg - exc << endl;
}

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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i) os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1) printEoln();
  if (suc == 2) printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U>
void chmax(T &a, U b) {
  if (a < b) a = b;
}

template <class T, class U>
void chmin(T &a, U b) {
  if (b < a) a = b;
}

template <class T>
T Sq(const T &t) {
  return t * t;
}

const int mod = 1e9 + 7;

int d, g, ans = 1e9;
vector<tuple<int, int, int>> q;

void check(bool isComp[]) {
  int score = 0, cnt = 0, max_index = 0;
  REP(i, d) {
    if (isComp[i] == false) {
      chmax(max_index, i);
      continue;
    }
    cnt += get<1>(q[i]);
    score += get<2>(q[i]);
  }
  if (score < g) {
    int bs = get<0>(q[max_index]);
    int remain_cnt = ceil((g - score) / (bs * 1.0));
    if (remain_cnt > get<1>(q[max_index])) return;
    cnt += remain_cnt;
  }
  chmin(ans, cnt);
}

void dfs(bool isComp[], int index) {
  if (index == d) {
    check(isComp);
    return;
  }
  isComp[index] = true;
  dfs(isComp, index + 1);
  isComp[index] = false;
  dfs(isComp, index + 1);
}

signed main() {
  cin >> d >> g;
  REP(i, d) {
    int p, c, bs = (i + 1) * 100;
    cin >> p >> c;
    q.PB(make_tuple(bs, p, (bs * p) + c));
  }
  bool isComp[d];
  dfs(isComp, 0);
  print(ans);
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <functional>
#include <array>

using namespace std;
using P = pair<int, int>;

int main(){
    int64_t H, W, N;
    cin >> H >> W >> N;

    map<P, int> m;
    vector<int64_t> ans(10, 0);
    ans[0] = (H - 2) * (W - 2);
    for(int i = 0; i < N; ++i){
        int a, b;
        cin >> a >> b;
        --a, --b;
        for(int x = -1; x <= 1; ++x) for(int y = -1; y <= 1; ++y){
            int nx = b + x;
            int ny = a + y;
            if(0 < nx && nx < W-1 && 0 < ny && ny < H-1){
                ans[m[P(ny, nx)]] --;
                m[P(ny, nx)] ++;
                ans[m[P(ny, nx)]] ++;
            }
        }
    }

    for(int i = 0; i <= 9; ++i){
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 56448
# 2020/04/29
# AtCoder Beginner Contest 044 - B

# Input
w = input()

# Init
d = dict()

# Calc
for i in range(len(w)):
    if d.get(w[i]) == None:
        d[w[i]] = 1
    else:
        d[w[i]] = d[w[i]] + 1

ans = 'Yes'
for key in d:
    if d[key] % 2 == 1:
        ans = 'No'
        break

# Output
print(ans)


Measured memory_bytes: 2940
using System;
using System.Collections.Generic;
using static System.Math;
using System.Linq;
using System.Text;
 
class DandA {
    static void Main(string[] args) {
        int[] ab = ReadLineIntArray();
        if (ab[1] == 1) {
            Console.WriteLine(0);
        } else {
            int rtn = 1;
            int n = ab[1] - ab[0];
            while (n > 0) {
                n -= ab[0] - 1;
                rtn++;
            }
            Console.WriteLine(rtn);
        }
    }
 
    static string Alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ";
    static string[] strAry = new string[] {"L", "R", "U", "D"}; 
  
    static private string ReadLineStr() {return Console.ReadLine();}
    static private int ReadLineInt() {return int.Parse(Console.ReadLine());}
    static private long ReadLineLong() {return long.Parse(Console.ReadLine());}
    static private double ReadLineDouble() {return double.Parse(Console.ReadLine());}
    static private string[] ReadLineStrArray() {return Console.ReadLine().Trim().Split();}
    static private int[] ReadLineIntArray() {return Console.ReadLine().Trim().Split().Select(a => int.Parse(a)).ToArray();}
    static private long[] ReadLineLongArray() {return Console.ReadLine().Trim().Split().Select(a => long.Parse(a)).ToArray();}
    static private double[] ReadLineDoubleArray() {return Console.ReadLine().Trim().Split().Select(a => double.Parse(a)).ToArray();}
    static private decimal[] ReadLineDecimalArray() {return Console.ReadLine().Trim().Split().Select(a => decimal.Parse(a)).ToArray();}
    static private string[][] ReadMLineStrArray(int arg) { return new int[arg].Select(_ => Console.ReadLine().Split()).ToArray();}
    static private int[][] ReadMLineIntArray(int arg) { return new int[arg].Select(_ => Console.ReadLine().Split().Select(int.Parse).ToArray()).ToArray();}
 
    static private bool IsPrime(int num) {
        if (num < 2) return false;
        if (num == 2) return true;
        else if (num % 2 == 0) return false;
        double sqrtNum = Math.Sqrt(num);
        for (int i = 3; i <= sqrtNum; i += 2) {
            if (num % i == 0) return false;
        }
        return true;
    }
  
    static private string IntToNString(int x, int n) {
        var nstring = "";
        var numbers = new string[] { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f" };
        int r = 1;
        int q = x;
        while (q > 0) {
            r = q % n;
            nstring += numbers[r];
            q = q / n;
        }
        return string.Join("",nstring.Reverse());
     }
}

Measured memory_bytes: 13396
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <bitset>
#include <math.h>
#include <iomanip>
#include <queue>
#define inp(X) cin >> X
#define out(X) cout << X << endl
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define MAX(A) *max_element(A.begin(),A.end())
#define MIN(A) *min_element(A.begin(),A.end())
#define SORT(A) sort(A.begin(),A.end())
using namespace std;

typedef long long int ll;
#define MOD 1000000007
#define INF 1000000001

ll gcd(ll x, ll y){
	if(y==0) return x;
	return gcd(y,x%y);
}

bool bfs(vector<vector<int>> g, vector<int> &dist, int sv)
{
	queue<int> q;
	q.push(sv);
	dist[sv]=0;
	while(!q.empty()){
		int now = q.front(); q.pop();
		for(auto v : g[now]){
			if(dist[v]!=-1) continue;
			dist[v] = dist[now]+1;
			q.push(v);
		}
	}
}

int main(void) {
	ll n,w; cin >> n >> w ;
	vector<ll> wei(n);
	vector<ll> val(n);
	rep(i,n) cin >> wei[i] >> val[i];
	vector<vector<ll>> dp(n,vector<ll> (w+1,-1));
	rep(j,w+1) dp[0][j] = wei[0]<=j ? val[0] : 0;
	rep2(i,1,n)rep(j,w+1){
		//入れない場合
		dp[i][j] = max(dp[i][j],dp[i-1][j]);
		//入れる場合
		if(wei[i]<=j) dp[i][j] = max(dp[i][j],dp[i-1][j-wei[i]]+val[i]);
	}
	out(dp[n-1][w]);
}




Measured memory_bytes: 79360
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream> 
#include<map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
using namespace std;
#define MAX_MOD 1000000007
#define REP(i,n) for(int i = 0;i < n;++i)
#define LONGINF 1000000000000000000
int main() {
	int n;
	cin >> n;
	vector<int> a;
	REP(i, n) {
		int tmp;
		cin >> tmp;
		a.push_back(tmp);
	}
	int ans = 0;
	for (int i = 0;i < n;++i) {
		if (a[a[i]-1] == i + 1) ans++;
	}
	cout << ans / 2 << endl;
	return 0;
}

Measured memory_bytes: 1020
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define deb(x) cout << #x << " = "<< x << "\n";

signed main() {
	//freopen("in.txt", "r",stdin);
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	
	int n; cin >> n;
	n %= 1000;
	cout << (1000 - n) % 1000;
	
	
	
}


Measured memory_bytes: 3608
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <complex>
typedef long long int LL;
using namespace std;

// 插入此處

int main() {
    int n;
    scanf("%d", &n);
    int c = n;
    int d = 0;
    while (c > 0) {
        d += (c % 10);
        c /= 10;
    }
    printf("%s\n", n % d == 0 ? "Yes" : "No");
}


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

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

        String s = sc.next();
        String t = sc.next();
        out.println(s.equals(t.substring(0, t.length() - 1))? "Yes" : "No");
        out.flush();
    }

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

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


Measured memory_bytes: 35752
#include <bits/stdc++.h>
#define  X first
#define  Y second

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll;

const ll INF = 2e18;
const int inf = 1e9+10;
const int maxN = 3e5+10;
const int maxD = 15;
const int maxH = 100; 
const int MOD = 998244353;

int V[maxN];
int W[maxN];
int main()
{
	int ans = 0;
	for(int i=1;i<=5;i++)
	{
		scanf("%d",&W[i]);
		if(W[i] == 0)
		{
			ans = i;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3660
S = input()


table = {}
pairs = [[((i*10 + j)%13, i) for i in range(13)] for j in range(13)]
mod = 10**9 + 7
for i in range(13):
    table[i] = tuple((i + j*13)//10 for j in range(10))

dp =[[0 for i in range(13)] for i in range(len(S))]

if S[0] == "?":
    for i in range(10):
        dp[0][i] = 1
else:
    s = int(S[0])
    dp[0][s] = 1

for i in range(1, len(S)):
    s = S[i]
    if s == "?":
        for j in range(13):
            for k in table[j]:
                dp[i][j] += dp[i-1][k]
            dp[i][j] %= mod
    else:
        s = int(s)
        for pair in pairs[s]:
            dp[i][pair[0]] = dp[i-1][pair[1]] % mod

print(dp[len(S)-1][5] % mod)


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

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static void main(String[] args) throws Exception {

		int n = nextInt();
		long[] b = nextLongs();
		long[] a = Arrays.copyOf(b, b.length);

		long ansN = 0;
		long sum=0;
		//-から始まる場合
		for(int i=0;i<n;i++){
			if(i%2==0){
				if(a[i]+sum>=0){
					ansN+=a[i]+sum+1;
					a[i]+=(a[i]+sum+1)*-1;
				}
				sum+=a[i];
			}else{
				if(a[i]+sum<=0){
					ansN+=Math.abs(a[i]+sum)+1;
					a[i]+=Math.abs(a[i]+sum)+1;
				}
				sum+=a[i];
			}
		}

		a = Arrays.copyOf(b, b.length);
		long ansP = 0;
		sum=0;
		//+から始まる場合
		for(int i=0;i<n;i++){
			if(i%2==0){
				if(a[i]+sum<=0){
					ansP+=Math.abs(a[i]+sum)+1;
					a[i]+=Math.abs(a[i]+sum)+1;
				}
				sum+=a[i];
			}else{
				if(a[i]+sum>=0){
					ansP+=Math.abs(a[i]+sum)+1;
					a[i]+=(Math.abs(a[i]+sum)+1)*-1;
				}
				sum+=a[i];
			}
		}

		System.out.println(Math.min(ansN, ansP));

	}

	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


Measured memory_bytes: 48960
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007
ll a[100001]={0};
int main()
{//ios_base::sync_with_stdio(false);
ll n;
string s;
map<string,ll>m;
cin>>n;
while(n--)
 {
     cin>>s;
     m[s]++;
 }
 cout<<m.size();
}


Measured memory_bytes: 19180
//  299143BT
#include<bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define mod 998244353
#define pi 3.1415926535
#define fi first
#define se second
#define vll vector<ll>
#define vpll vector<pair <ll,ll> >
#define vvll vector< vll >
#define str string
#define umap unordered_map
#define uset unordered_set
#define rep(i,n) for(ll i=0;i<n;i++)
#define repA(i,s,n) for(ll i=s;i<=n;i++)
#define repD(i,s,n) for(ll i=s;i>=n;i--)
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define elif else if
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ALL(v) v.begin(),v.end()
#define sortA(v) sort(ALL(v))
#define sortD(v) sort(ALL(v),greater <ll> ())
#define print(v) for(auto itr:v) cout<<*itr<<" ";
#define sz size()
#define nl cout<<"\n";
using namespace std;
ll factorial(ll n){return (n==1||n==0)?1:n*factorial(n-1);}
ll power(ll x,ll y){ll res=1;while(y>0){if(y&1)res=res*x;y=y>>1;x=x*x;}return res;}
ll powerMod(ll x,ll y,ll m){if(y==0)return 1;ll p=powerMod(x,y/2,m)%m;p=(p*p)%m;return (y%2==0)?p:(x*p)%m;}
ll modInverse(ll a,ll m){return powerMod(a,m-2,m);}
ll gcd(ll a,ll b){if(a==0){return b;}else if(b==0){return a;}else{if(a>b){return gcd(a%b,b);}else{return gcd(b%a,a);}}}

void pre(){

}

void solve(){
    ll a=0,b=0,c=0,d=0;
    cin>>a>>b>>c>>d;
    ll m=-999999999999999999;
    ll x=-1e9;
    m=max(m,a*c);
    m=max(m,b*d);
    m=max(m,a*d);
    m=max(m,b*c);
    cout<<m;
}

int main(){
    fast
    ll t=1;
//    cin>>t;
    pre();
    while(t--) solve();
    return 0;
}


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

int main(void){
    int ans=0;
    int n, m, c;
    cin >> n >> m >> c;
    vector<int> b(m);
    for(int i=0; i < m; i++){
        cin >> b.at(i);
    }
    for(int j=0; j < n; j++){
        int sum=0;
        vector<int> a(m);
        for(int i=0; i < m; i++){
            cin >> a.at(i);
        }
        for(int i=0; i < m; i++){
            sum += a.at(i)*b.at(i);
        }
        sum += c;
        if(sum > 0){
            ans++;
        }

    }
    cout << ans << endl;
    return 0;
}


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

typedef long double ld;

const ld EPS = 1e-9;
const ld INF = 1e10;
const ld PI = M_PI;

struct Point{
  ld x, y;
  Point(ld x, ld y):x(x), y(y){}
  Point(){}
};

Point operator+(const Point &a, const Point &b){
  return Point(a.x + b.x, a.y + b.y);
}
Point operator-(const Point &a, const Point &b){
  return Point(a.x - b.x, a.y - b.y);
}
Point operator*(const Point &a, const ld b){
  return Point(a.x * b, a.y * b);
}
Point operator*(const Point &a, const Point &b){
  return Point(a.x*b.x-a.y*b.y, a.x*b.y+a.y*b.x);
}
Point operator/(const Point &a, const ld b){
  return Point(a.x / b, a.y / b);
}

ld cross(const Point &a, const Point &b){
  return a.x*b.y - a.y*b.x;
}

ld dot(const Point &a, const Point &b){
  return a.x*b.x + a.y*b.y;
}

ld norm(const Point &a){
  return dot(a, a);
}

struct Line:vector<Point>{
  Line(Point a = Point(0, 0), Point b = Point(0, 0)){
    this->push_back(a);
    this->push_back(b);
  }
};

int ccw(Point a, Point b, Point c){
  b = b - a;
  c = c - a;
  if(cross(b, c) > EPS) return +1; // 反時計周り
  if(cross(b, c) < -EPS) return -1; // 時計周り
  if(dot(b, c) < 0) return +2; // c -- a -- b がこの順番に一直線上
  if(norm(b) < norm(c)) return -2; // a -- b -- c がこの順番に一直線上
  return 0; // a -- c -- b が一直線上
}

Point crosspoint_SS(const Line &s, const Line &t){
  Point b = t[1] - t[0];
  ld d1 = abs(cross(b, s[0]-t[0]));
  ld d2 = abs(cross(b, s[1]-t[1]));
  ld tt = d1 / (d1 + d2);
  
  return s[0] + (s[1]-s[0]) * tt;
}

int main(){  
  int q;
  cin >> q;
  while(q--){
    Point p0, p1;
    Line l1, l2;
    cin >> p0.x >> p0.y >> p1.x >> p1.y;
    l1 = Line(p0, p1);
    
    cin >> p0.x >> p0.y >> p1.x >> p1.y;
    l2 = Line(p0, p1);
    
    Point ans = crosspoint_SS(l1, l2);
    printf("%.10Lf %.10Lf\n", ans.x, ans.y);
  }
  
  return 0;
}

Measured memory_bytes: 1256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define forE(i,x) for(int i=head[x];i!=-1;i=ne[i])
using namespace std;
typedef long long i64;
typedef unsigned long long u64;
typedef unsigned u32;
typedef pair<int,int> pin;
#define mk(a,b) make_pair(a,b)
#define lowbit(x) ((x)&(-(x)))
#define sqr(a) ((a)*(a))
#define clr(a) (memset((a),0,sizeof(a)))
#define ls ((x)<<1)
#define rs (((x)<<1)|1)
#define mid (((l)+(r))>>1)
#define pb push_back
#define w1 first
#define w2 second
inline void read(int &x){
	x=0;int f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	x*=f;
}
inline void judge(){
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
}
/*******************************head*******************************/
const int maxn=5005;
int f[maxn][maxn];
int sum[maxn],n,m,k;
const int mod=1e9+7;
int main(){
	read(n);read(m);read(k);
	f[0][0]=1;
	rep(i,1,n+m-1){
		sum[0]=f[i-1][0];
		rep(j,1,m)sum[j]=(sum[j-1]+f[i-1][j])%mod;
		rep(j,0,m)f[i][j]=(sum[j]-((j>=k)?(sum[j-k]):0)+mod)%mod;
	}
	int res=0;
	for(;m>0;m-=k-1)res=(res+f[(n+m-1)/(k-1)][m])%mod;
	printf("%d\n",res);
	return 0;
}


Measured memory_bytes: 79360
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <stdexcept>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, done) for (int i = (a); i < (done); ++i)
#define all(a) (a).begin(), (a).end()
#define x first
#define y second
#define debug(a) cout << (a) << endl
namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;
template <class T>
bool chmax(T &a, const T &b)
{
	if (a < b)
	{
		a = b;
		return 1;
	}
	return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
	if (a > b)
	{
		a = b;
		return 1;
	}
	return 0;
}

ll M = 1000000007;
int dp[(int)1e5+1][3];
void solve()
{
	int n;
	cin>>n;
	vector<vector<int>>util(n,vector<int>(3));
	rep(i,n){
		rep(j,3){
			cin>>util[i][j];
		}
	}
	rep(i,n){
		rep(j,3){
			dp[i][j]=0;
		}
	}
	rep(i,3){
		dp[0][i]=util[0][i];
	}
	rep(i,n){
		if(i){
			rep(j,3){
				rep(k,3){
					if(j!=k)chmax(dp[i][j],dp[i-1][k]+util[i][j]);
				}
			}
		}
	}
	int ans=0;
	rep(i,3){
		chmax(ans,dp[n-1][i]);
	}
	cout<<ans<<endl;

}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	solve();
	return 0;
}


Measured memory_bytes: 6912
#include <stdio.h>

int main(void){
  int n,m,i;
  int s[100],c[100];
  int result[10] = {0};
  int setted[10] = {0};
  int error=0;
  
  scanf("%d %d",&n,&m);
  for(i=0;i<m;i++) scanf("%d %d", &s[i],&c[i]);
  
  if(n>=2) result[0] = 1;
  for(i=0;i<m;i++){
    if(setted[s[i]-1]==1 && result[s[i]-1]!=c[i]){
      //kuichigai
      error=1;
      break;
    }else if(n >= 2 && s[i] == 1 && c[i] == 0){
      error=1;
      break;
    }
    result[s[i]-1] = c[i];
    setted[s[i]-1] = 1;
  }
  
  if(error==1) printf("-1");
  else for(i=0;i<n;i++) printf("%d", result[i]);
  
  return 0;
}


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

int main()
{
    int x, y;
    cin >> x >> y;
    for (int i = 0; i <= x;i++){
        if(i*2+(x-i)*4==y){
            cout << "Yes" << endl;
            exit(0);
        }
    }
    cout<<"No"<<endl;
}

Measured memory_bytes: 3620
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        String s1 = scan.next();
        String s2 = scan.next();
        String s3 = scan.next();
        int a = s1.toCharArray()[0]-32;
        int b = s2.toCharArray()[0]-32;
        int c = s3.toCharArray()[0]-32;
        StringBuilder sb = new StringBuilder();
        sb.append((char)a);
        sb.append((char)b);
        sb.append((char)c);
        System.out.println(sb.toString());
    }
}


Measured memory_bytes: 21844
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
 
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
 
using namespace std;
 
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
 
const int INF=1<<29;
const double EPS=1e-9;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

struct node {
	int key;
	node *left;
	node *right;
	node(int k) : key(k), left(nullptr), right(nullptr){
	}
};

void insert(node *to, node *v) {
	if (v->key < to->key) {
		if (to->left != nullptr) {
			insert(to->left, v);
		} else {
			to->left = v;
		}
	} else {
		if (to->right != nullptr) {
			insert(to->right, v);
		} else {
			to->right = v;
		}
	}
}

void print_first(node *target) {
	cout << " " << target->key;
	if (target->left != nullptr) print_first(target->left);
	if (target->right != nullptr) print_first(target->right);
}
void print_mid(node *target) {
	if (target->left != nullptr) print_mid(target->left);
	cout << " " << target->key;
	if (target->right != nullptr) print_mid(target->right);
}

void deletetree(node *target) {
	if (target->left != nullptr) deletetree(target->left);
	if (target->right != nullptr) deletetree(target->right);
	delete target;
}

int main() {
	int N;
	int num;
	string inst;

	cin >> N;
	
	cin >> inst;
	cin >> num;
	N--;

	node *root = new node(num);
	for (int i = 0; i < N; ++i) {
		cin >> inst;
		if (inst == "insert") {
			cin >> num;
			node *v = new node(num);
			insert(root, v);
			
		} else if (inst == "print") {
			print_mid(root);
			cout << endl;
			print_first(root);
			cout << endl;
		}
	}
	deletetree(root);
	
}

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


int D;
double V[16];
double interpolate(int n, int E) {
  double sum = 0.0;
  for (int k=0; k<D+3; ++k) {
    if (k == n || k == E) continue;
    double p = V[k];
    for (int i=0; i<D+3; ++i)
      if (! (i == k || i == n || i == E))
	p *= (n-i)/(double)(k-i);
    sum += p;
  }
  return sum;
}

bool outlier(int E) {
  for (int i=0; i<D+3; ++i) {
    if (i==E) continue;
    double p = interpolate(i, E);
    if (abs(p - V[i]) > 0.1)
      return false;
  }
  return true;
}

int main() {
  while (cin >> D && D) {
    for (int i=0; i<D+3; ++i) cin >> V[i];
    for (int i=0; i<D+3; ++i)
      if (outlier(i)) {
	cout << i << endl;
	break;
      }
  }
}

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

int main(){
    string s;
    cin >> s;
    string ans;
    for(int i = 0; i < s.size(); i++) {
        if(s[i] == '0') {
            ans += '0';
        }
        if(s[i] == '1') {
            ans += '1';
        }
        if(s[i] == 'B'){
            ans = ans.substr(0 , ans.size()-1);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<cstdio>

int n, h, w, a, b, ans;
int main(){
	scanf("%d %d %d", &n, &h, &w);
	while(n--){
		scanf("%d %d", &a, &b);
		ans += (a>=h && b>=w);
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 128
// -----------------------------------
// Author     : MatsuTaku
// Affiliation: Tokushima University
// Country    : Japan
// Date       : 03/28/2020
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  int a,b,h; cin>>a>>b>>h;
  if (a > b)
    swap(a,b);
  int ans = a*h+(b-a)*h/2;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
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));
		String line;
		int a = 0;
		String s = "";
		try {
			line = br.readLine();
			a = Integer.parseInt(line);
			s = br.readLine();
		} catch (IOException e) {
			e.getStackTrace();
		}
		
		if(a >= 3200) {
			System.out.println(s);
		}else {
			System.out.println("red");
		}
	}
}

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

int main(){
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  
  int l_plate= a + b;
  int r_plate= c + d;
  if (r_plate < l_plate){
    cout << "Left" << endl;
  }
  else if (r_plate > l_plate){
    cout << "Right" << endl;
  }
  else{
    cout << "Balanced" << endl;
  }
}


Measured memory_bytes: 3592
#include <cstdio>
int a,b,c;
int main ()
{
	scanf ("%d %d %d",&a,&b,&c);
	printf ("%d\n",a+b<a+c?a+b<b+c?a+b:b+c:a+c<b+c?a+c:b+c);
	return 0;
}


Measured memory_bytes: 128
n = gets.chomp.to_i
a = gets.chomp.split(" ").map(&:to_i)
a.unshift(0)
a.push(0)
res = 0

(n+1).times do |i|
    res += (a[i] - a[i+1]).abs
end

1.upto(n) do |i|
    puts res + (a[i-1] - a[i+1]).abs - (a[i-1] - a[i]).abs - (a[i] - a[i+1]).abs
end

Measured memory_bytes: 12548
//Author : Siriuslight
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"
#define FIO ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0),cout<<setprecision(10)<<fixed;
//#define int long long
#define F first
#define S second

using namespace std;
using namespace __gnu_pbds;

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

typedef long long ll;
typedef long double ld;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

const ll inf = 1e9+100, N = 23;
const ll INF = 1e18+100, MOD = 1e9+7;

ll powmod(ll a,ll b,ll m=MOD){ll r=1;while(b>0){if(b&1)r=r*a%m;a=a*a%m;b>>=1;}return r;}
ll power(ll a,ll b){ll r=1;while(b>0){if(b&1)r=r*a;a=a*a;b>>=1;}return r;}
ll gcd(ll a,ll b){if(!b)return a;return gcd(b,a%b);}
ll inv(ll a, ll m = MOD){return powmod(a,m-2,m);}
ll lcm(ll a,ll b){return(a*b)/gcd(a,b);}

//ordered_set X;
//X.insert(3);
//X.order_of_key(3) no of elements less than 3
//*X.find_by_order(n) nth greatest element(0-indexed)

int n, a[N][N], dp[1LL << N][N];

int solve(int mask, int id){
    if(id == 0){
        return mask == ((1LL << (n + 1)) - 1);
    }
    int &res = dp[mask][id];
    if(res != -1) return res;
    res = 0;
    for(int j = 1; j <= n; ++j){
        if(a[id][j] == 1 && ((mask >> j)&1) == 0){
            res += solve(mask | (1LL << j), id - 1);
            res %= MOD;
        }
    }
    return res;
}

int32_t main(){
    FIO;
    cin >> n;
    for(int i = 1; i <= n; ++i){
        for(int j = 1; j <= n; ++j){
            cin >> a[i][j];
        }
    }
    memset(dp, -1, sizeof(dp));
    cout << solve(1, n);
}


Measured memory_bytes: 753920
import java.util.*;
import java.awt.Point;

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

		while(true){
			int w = sc.nextInt();
			int h = sc.nextInt();
			if(w == 0 && h == 0) break;

			int[][][] t = new int[h+2][w+2][2];
			LinkedList<Point> open = new LinkedList<Point>();
			open.add(new Point(1,0));
			open.add(new Point(0,1));
			t[0][1][0] = 1;
			t[1][0][1] = 1;

			while(!open.isEmpty()){
				Point p = open.poll();

				t[p.y][p.x+1][0] = (t[p.y][p.x+1][0] + t[p.y][p.x][0]) % 100000;
				t[p.y][p.x+2][0] = (t[p.y][p.x+2][0] + t[p.y][p.x][1]) % 100000;
				t[p.y+1][p.x][1] = (t[p.y+1][p.x][1] + t[p.y][p.x][1]) % 100000;
				t[p.y+2][p.x][1] = (t[p.y+2][p.x][1] + t[p.y][p.x][0]) % 100000;

				Point np = new Point(p.x+1,p.y);
				if(!open.contains(np) && (np.x!=w-1 || np.y!=h-1) && np.x<w) open.add(np);
				np = new Point(p.x,p.y+1);
				if(!open.contains(np) && (np.x!=w-1 || np.y!=h-1) && np.y<h) open.add(np);
			}

			System.out.println((t[h-1][w-1][0] + t[h-1][w-1][1] +
													t[h-1][w][0] + t[h-1][w][1] + 
													t[h][w-1][0] + t[h][w-1][1]) % 100000);
		}
	}
}

Measured memory_bytes: 13000
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<time.h>
#include<math.h>
struct node
{
	int key;
	struct node *parent;
	struct node *left;
	struct node *right;
};
char com[500010][10];
int x[500010];
struct node *root;
void insert(int z)
{
	struct node *v;
	if(!root)
	{
		v=(struct node *)malloc(sizeof(struct node));
		v->key=z;
		v->left=v->parent=v->right=NULL;
		root=v;
		return;
	}
	struct node *x,*y;
	y=NULL;
	x=root;
	while(x!=NULL)
	{
		y=x;
		if(z<x->key)
			x=x->left;
		else
			x=x->right;
	}
	v=(struct node *)malloc(sizeof(struct node));
	v->left=v->parent=v->right=NULL;
	v->key=z;
	v->parent=y;
	if(z<y->key)
		y->left=v;
	else
		y->right=v;
	return;
}
int find(int k)
{
	struct node *u;
	u=root;
	while(u!=NULL && k!=u->key)
	{
		if(k<u->key)
			u=u->left;
		else
			u=u->right;
	}
	if(!u)
		return 0;
	return 1;
}
void inorder(struct node *u)
{
	if(!u)
		return;
	inorder(u->left);
	printf(" %d",u->key);
	inorder(u->right);
	return;
}
void preorder(struct node *u)
{
	if(!u)
		return;
	printf(" %d",u->key);
	preorder(u->left);
	preorder(u->right);
	return;
}
int main()
{
	int n,i;
	
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%s",com[i]);
		if(strcmp(com[i],"insert")==0)
			scanf("%d",&x[i]);
		if(strcmp(com[i],"find")==0)
			scanf("%d",&x[i]);
	}
	for(i=1;i<=n;i++)
	{
		if(strcmp(com[i],"insert")==0)
			insert(x[i]);
		if(strcmp(com[i],"print")==0)
		{
			inorder(root);
			printf("\n");
			preorder(root);
			printf("\n");
		}
		if(strcmp(com[i],"find")==0)
		{
			if(find(x[i]))
				printf("yes\n");
			else
				printf("no\n");
		}
	}
	return 0;
}


Measured memory_bytes: 27328
#include <iostream>
#include <cstring>
#include <cstdio>
#define maxn 100006
using namespace std;
int n;
int a[maxn];
int b[maxn];
int d;
int main(){
	//freopen("main.in","r",stdin);
	scanf(" %d",&n);
	for(int i = 1; i <= n; i++) scanf(" %d",&a[i]);

	for(int i = 1; i <= n; i++){
		if(b[a[i]] == 0){
			d++;
			b[a[i]] = 1;
		}
	}

	if(d != 1 && d != 2){
		cout << "No" << endl;
		return 0;
	}

	if(d == 1){
		if(a[1] == n-1 || n/a[1] >= 2){
			cout << "Yes" << endl;
		}else {
			cout << "No" << endl;
		}
	}else if(d == 2){
		int x = 0, y = 0;
		int aa = a[1], bb;
		for(int i = 1; i <= n; i++){
			if(a[i] == a[1]){
				x++;
			}else {
				bb = a[i];
				y++;
			}
		}

		if(aa > bb){
		       	swap(aa,bb);
			swap(x,y);
		}
		if(bb != aa+1 || x + y != n){
			cout << "No" << endl;
			return 0;
		}

		if((aa + 1 - x > 0) && y/(aa+1-x) >= 2 && n - 1 >= bb){
			cout << "Yes" << endl;
		}else {
			cout << "No" << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 1024
import math

dishes = []
rest = 10

for i in range(5):
    n = int(input())
    dishes.append(math.ceil(n / 10) * 10)
    if 0 < n % 100 % 10 < rest:
        rest = n % 100 % 10 

print(sum(dishes) - (10- rest))

Measured memory_bytes: 9192
#include<iostream>
#include<iomanip>
using namespace std;
int main()
{
	float n,a=0;
	cin >> n;
	if(n == 1)a = 1.0;
	else if(int(n) % 2 == 0)a =(int(n) / 2)/n;
	else if(int(n)%2==1)a = (int(n) / 2 + 1)/n;
	cout << setiosflags(ios::fixed);
	cout <<setw(10)<<setprecision(10)<< a << endl;
  return 0;
}

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

// BE CAREFUL WITH HASH TABLE & UNORDERED MAP
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
using namespace std;

#define MOD 998244353
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = (b-1); i >= (a); i--)
#define RF0(i,b) RFO(i,0,b)
#define lli long long int
#define pii pair<int,int>
#define add(a,b) ((int) (((lli) (a) + (b))%MOD))
#define mul(a,b) ((int) (((lli) (a) * (b))%MOD))
#define PB emplace_back
#define F first
#define S second

// ifstream cin ("cinput.in");
// ofstream cout ("coutput.out");

int N, u, v;
vector<int> graph [100000];
int visited [100000][2];
// Helper Functions

void dfs(int node, int dist, int ind) {
    visited[node][ind] = dist;
    for (int neigh: graph[node]) {
        if (visited[neigh][ind] != -1) continue;
        visited[neigh][ind] = dist+1;
        dfs(neigh, dist+1, ind);
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> N >> u >> v;
    u--; v--;
    memset(visited, -1, sizeof(int)*N*2);
    F0R(i,N-1) {
        int a,b;
        cin >> a >> b;
        a--; b--;
        graph[a].PB(b);
        graph[b].PB(a);
    }
    dfs(u,0,0);
    dfs(v,0,1);
    int ans = 0;
    F0R(i,N) {
        // cout << i+1 << ' ' << visited[i][0] << ' ' << visited[i][1] << '\n';
        if (visited[i][0] < visited[i][1]) {
            ans = max(ans, visited[i][1]-1);
        }
    }
    cout << ans << '\n';
}

// even diff = -1. odd diff rts

Measured memory_bytes: 14884
fun main(args: Array<String>) {
    val (N, X) = readLine()!!.split(" ").map { it.toInt() }
    val L = readLine()!!.split(" ").map { it.toInt() }
    var d = 0; var count = 1
    for (i in 2..N + 1) {
        d += L[i - 2]
        if (d <= X) count++
    }
    println(count)
}

Measured memory_bytes: 36036
#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#define int long long
#define double long double
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define ms(v,x) memset(v,x,sizeof(v))
#define pii pair<int,int>
#define ff first
#define ss second
#define frr(i,n) for(int i=0;i<n;i++)
#define td(v) v.begin(),v.end()
#define inf 1000000000 // 1e9
#define M   1000000007 // 1e9 + 7
using namespace std;
inline int mod(int n, int m){ int ret = n%m; if(ret < 0) ret += m; return ret; }
int gcd(int a, int b){return (b == 0 ? a : gcd(b, a%b));}
int lcm(int a,int b){return (a*b)/gcd(a,b);}
int exp(int a,int b,int m){
    if(b==0) return 1;
    if(b==1) return mod(a,m);
    int k = mod(exp(a,b/2,m),m);
    if(b&1){
        return mod(a*mod(k*k,m),m);
    }
    else return mod(k*k,m);
}
#define psx pair<string,int>
bool cmp(psx a,psx b){
    return (a.ff == b.ff ? a.ss > b.ss : a.ff < b.ff);
}
int32_t main(){
    fastio;
    int n;
    cin >> n;
    vector<psx > v(n),q;
    map<psx,int> m;
    frr(i,n) cin >> v[i].ff >> v[i].ss;
    q = v;
    sort(td(q),cmp);
    for(int i=0;i<n;i++){
        m[v[i]] = i+1;
    }
    for(psx k : q){
        cout << m[k] << endl;
    }
}

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

int main()
{
    int A, B;
    cin >> A >> B;
    int ans = 0;
    ans = max(ans, A + A - 1);
  	ans = max(ans, B + B - 1);
  	ans = max(ans, A + B);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstdlib>
#include <stack>
#include <queue>
#include <valarray>
#include <utility>

using namespace std;

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,n) for(int i=1;i<=(int)(n);i++)
#define rep3(i,n) for(int i=0;i<=(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define REP2(i,m,n) for(int i=m+1;i<=(int)(n);i++)
#define REP3(i,m,n) for(int i=m;i<=(int)(n);i++)
#define INF 2000000000
#define INFLL 9000000000000000000
#define MOD (1e9)+7

typedef long long int ll;

// a 0x61  z 0x7a  0 0x30

int main() {
    const int M = 100010;
    int N;

    cin >> N;

    int a[N];

    rep(i, N) {
        cin >> a[i];
    }

    int count[M] = {}; //枚数

    rep(i, N) {
        count[a[i] - 1]++;
    }

    double times = 0;

    rep(i, M) {
        if (count[i] >= 2) {
            times += count[i] - 1;
        }
    }

    int t = (int) (ceil(times / 2));

    cout << N - t * 2 << endl;

    return 0;
}



Measured memory_bytes: 1024
#include<stdio.h>
#include<string.h>
int main(void){
        int i,n,j,num;
        int a[4][13]; //S = 0,H =1, C = 2, D =3
        char mark;
        scanf("%d",&n);
        for(j=0;j<4;j++){
                for(i=0;i<13;i++){
                        a[j][i] = 1;
                }
        }
        for(i=0;i<n;i++){
                scanf(" %c",&mark);
                scanf("%d",&num);
                switch(mark){
                        case 'S' : a[0][num-1] = 0;
                        break;
                        case 'H' : a[1][num-1] = 0;
                        break;
                        case 'C' : a[2][num-1] = 0;
                        break;
                        case 'D' : a[3][num-1] = 0;
                        break;
                        }
        }
        for(i=0;i<13;i++){
                if(a[0][i] == 1) printf("S %d\n",i+1);
        }
        for(i=0;i<13;i++){
                if(a[1][i] == 1) printf("H %d\n",i+1);
        }
        for(i=0;i<13;i++){
                if(a[2][i] == 1) printf("C %d\n",i+1);
        }
        for(i=0;i<13;i++){
                if(a[3][i] == 1) printf("D %d\n",i+1);
        }
        return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  int w,a,b;
  cin>>w>>a>>b;
  if(a+w<b) cout<<b-a-w<<endl;
  else if(b+w<a) cout<<a-b-w<<endl;
  else cout<<0<<endl;
}

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

int main(int argc, const char * argv[]) {
    int n; cin >> n;
    vector<int> org(n+1), x(n+1);
    x[0] = org[0]= 0;
    for(int i = 1; i <= n; i++) {
        int ix; cin >> ix;
        x[i] = org[i] = ix;
    }
    
    sort(x.begin(), x.end());
    
    double avg = (x[n/2] + x[n/2+1]) / 2.0;
    
    for(int i = 1; i <= n; i++) {
        if(org[i] >= avg) {
            cout << x[n/2] << endl;
        } else {
            cout << x[n/2+1] << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3712