akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC061A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b, c;
            string hantei;
            var word = Console.ReadLine().Split(' ');
            a = int.Parse(word[0]);
            b = int.Parse(word[1]);
            c = int.Parse(word[2]);

            if (c >= a && b >= c)
                hantei = "Yes";
            else
                hantei ="No";
            Console.WriteLine(hantei);
            Console.ReadKey();

        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T, class U> using Pa = pair<T, U>;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    cout << ((S[0]!=S[1] || S[1]!=S[2])? "Yes\n":"No\n");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ld long double
#define int long long
using namespace std;
const int N = 2e5 + 50;
const int mod = 1e9 + 7;
const int inf = 1e17;
int dx[] = {0, 1, -1, 0, -1, 1, 1, -1};
int dy[] = {1, 0, 0, -1, -1, 1, -1, 1};
int32_t main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0); cout.tie(0);
  int a, b, q;
  cin >> a >> b >> q;
  vector<int> tem(a, 0), shr(b, 0);
  for(int i = 0; i < a; i++){
  	cin >> tem[i];
  }
  for(int i = 0; i < b; i++){
  	cin >> shr[i];
  }
  while(q--){
  	int s;
  	cin >> s;
  	int ans = 1e17;
  	int in1 = lower_bound(tem.begin(), tem.end(), s) - tem.begin();
  	int in2 = in1 - 1;
  	int in3 = lower_bound(shr.begin(), shr.end(), s) - shr.begin();
  	int in4 = in3 - 1;
  	if(in1 < a && in3 < b){
  		ans = min(min(shr[in3], tem[in1]) - s + abs(shr[in3] - tem[in1]), ans);
  	}
  	if(in2 >= 0 && in3 < b){
  		int d1 = abs(shr[in3] - s);
  		int d2 = abs(s - tem[in2]);
  		int temp1 = 2LL * d1 + d2;
  		int temp2 = 2LL * d2 + d1;
  		ans = min(ans, min(temp1, temp2));
  	}
  	if(in2 >= 0 && in4 >= 0){
  		ans = min(s - max(shr[in4], tem[in2]) + abs(shr[in4] - tem[in2]), ans);
  	}if(in4 >= 0 && in1 < a){
  		int d1 = abs(s - shr[in4]);
  		int d2 = abs(tem[in1] - s);
  		int temp1 = 2LL * d1 + d2;
  		int temp2 = 2LL * d2 + d1;
  		ans = min(ans, min(temp1, temp2));
  	}
  	cout << ans << endl;
  }
}

Measured memory_bytes: 2944
/*
 * atcoder/abc098_2nd/c.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

/*
 * WEWEWEEEWWWE
 * 112233334444
 * 011223455556
 */
int N;
vector<int> E, W;
void solve() {
  cin >> N;
  char c;
  E.resize(N+1); W.resize(N+1);
  E[0] = W[0] = 0;
  loop(n,1,N+1) {
    cin >> c;
    E[n] = E[n-1] + (c == 'E');
    W[n] = W[n-1] + (c == 'W');
  }

  int min_ = 400000;
  loop(k,1,N+1) {
    chmin(min_, W[k-1] + E[N] - E[k]);
  }
  cout << min_ << endl;
}
int main() {
  // cout.precision(15); cout << fixed;

  solve();

  return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define repb(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define int long long
#define fi first
#define se second
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;


signed main() {
	int m, n, f, y, c, p;
	double r;
	cin >> m;
	rep(x, 0, m) {
		int MAX = 0;
		cin >> c >> y >> n;
		rep(i, 0, n) {
			cin >> f >> r >> p;
			int a = c;
			if (f) {
				rep(i, 0, y){
					a += (int)((double)a*r) - p;
				}
			}
			else {
				int sum = 0;
				rep(i, 0, y) {
					sum += (int)((double)a*r);
					a -= p;
				}
				a += sum;
			}
			MAX = max(MAX, a);
		}
		cout << MAX << endl;
	}
}

Measured memory_bytes: 1228
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n, k, i, j;
    cin >> n >> k;
    int a[n];
    long dp[k+1] = {0}, m = 1000000007;
    for(i = 0; i < n; ++i) 
        cin >> a[i];
    for(j = 0; j <= a[0]; ++j) 
        dp[j] = 1;
    for(i = 1; i < n; ++i) {
        for(j = 0; j < k; ++j) 
            dp[j+1] = (dp[j] + dp[j+1]) % m;
        for(j = k; j >= 0; --j)
            if(j-a[i]-1 >= 0) 
                dp[j] = (dp[j] - dp[j-a[i]-1] + m) % m;
    }
    cout << dp[k] % m;
    return 0;
}

Measured memory_bytes: 4392
use std::io::*;
use std::str::FromStr;

#[allow(unused_macros)]
macro_rules! scan {
  ($e:expr; $t:ty) => {
    $e.get::<$t>()
  };
  ($e:expr; $($t:ty), *) => {
    ($($e.get::<$t>(),)*)
  };
  ($e:expr => $i:expr; $t:ty) => {
    (0..$i).map(|_| $e.get::<$t>()).collect::<Vec<$t>>()
  };
  ($e:expr => $row:expr, $col:expr; $t:ty) => {
    (0..$i).map(|_| scan!($e => $col; $t)).collect::<Vec<$t>>()
  }
}

struct Scanner<R: Read> {
  reader: R
}

#[allow(dead_code)]
impl<R: Read> Scanner<R> {
  fn new(reader: R) -> Scanner<R> {
    Scanner { reader: reader }
  }
  fn safe_get<T: FromStr>(&mut self) -> Option<T> {
    let token = self.reader.by_ref().bytes().map(|c| c.unwrap() as char)
      .skip_while(|c| c.is_whitespace())
      .take_while(|c| !c.is_whitespace())
      .collect::<String>();
    if token.is_empty() { None } else { token.parse().ok() }
  }
  fn get<T: FromStr>(&mut self) -> T {
    if let Some(v) = self.safe_get() { v } else {
      writeln!(stderr(), "Terminated with EOF").unwrap();
      std::process::exit(0);
    }
  }
}

trait Writable {
  fn write(&self, sep: &'static str) -> String;
}

impl<T: ToString> Writable for Vec<T> {
  fn write(&self, sep: &'static str) -> String {
    self.iter().map(|e| e.to_string()).collect::<Vec<String>>().join(sep)
  }
}

fn main() {
  let cin = stdin();
  let cin = cin.lock();
  let mut sc = Scanner::new(cin);
  let (_, k, s) = scan!(sc; i32, usize, String);
  let mut s = s.as_bytes().to_vec();
  s[k - 1] -= 'A' as u8;
  s[k - 1] += 'a' as u8;
  println!("{}", String::from_utf8(s).unwrap());
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007ll
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define pb push_back
#define mp make_pair
#define x first
#define y second
#define db(x) cout << #x << " = " << x << '\n'
#define sep cout << "********************************************\n"
#define fast ios_base::sync_with_stdio(false), cin.tie(NULL)

ll n, w;
ll dp[2][100005];
int main(int argc, char const *argv[])
{
	fast;
	cin >> n >> w;
	memset(dp, -1, sizeof(dp));
	dp[0][0] = dp[1][0] = 0;
	for (int i = 0; i < n; ++i)
	{
		ll wt, val;
		cin >> wt >> val;
		ll f = (i & 1);
		for (int j = 0; j <= 100000; ++j)
		{
			dp[f][j] = dp[1 - f][j];
		}
		for (int j = 0; j + val <= 100000; ++j)
		{
			if (dp[1 - f][j] != -1)
			{
				if (dp[f][j + val] == -1)
					dp[f][j + val] = wt + dp[1 - f][j];
				else
					dp[f][j + val] = min(dp[f][j + val], wt + dp[1 - f][j]);
			}
		}
	}
	ll mx = 0;
	for (int i = 0; i <= 100000; ++i)
	{
		
		if (dp[(n - 1) & 1][i] != -1 && dp[(n - 1) & 1][i] <= w)
			mx = i;
	}
	cout << mx;
	return 0;
}

Measured memory_bytes: 1792
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		Main mainObj = new Main();
		mainObj.solve();
	}

	public void solve() throws IOException {
		FastScanner fs = new FastScanner();
		long n = fs.nextLong();
		
		if(n == 2){
			System.out.println(1);
			return;
		}
		
		long ans = 0;
		long sub1 = n - 1;
		
		ArrayList<Long> yakusuuList = yakusuu(sub1);
		HashSet<Long> yakusuuSet = new HashSet<Long>(yakusuuList);
		ans+=yakusuuList.size();
		yakusuuList = yakusuu(n);
		for(Long longVal : yakusuuList){
			long nCopy = n;
			while(nCopy % longVal == 0){
				nCopy = nCopy / longVal;
			}
			
			if(nCopy % longVal == 1){
				yakusuuSet.add(longVal);
//				ans++;
			}
		}
		System.out.println(yakusuuSet.size()+2);
	}
	
	ArrayList<Long> yakusuu(long n){
		ArrayList<Long> ret = new ArrayList<>();
		for(long i = 2; i*i <= n; i++){
			if(n % i == 0){
				ret.add(new Long(i));
				ret.add(new Long(n/i));
			}
		}
		return ret;
	}

	public class FastScanner {

		BufferedReader reader;
		private StringTokenizer st;

		public FastScanner() {
			st = null;
			reader = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() throws IOException {
			if (st == null || !st.hasMoreElements()) {
				st = new StringTokenizer(reader.readLine());
			}
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			st = null;
			String readLine = null;
			readLine = reader.readLine();
			return readLine;
		}

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		public int[] nextIntArr(int n) throws NumberFormatException, IOException {
			int[] retArr = new int[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextInt();
			}
			return retArr;
		}

		public long[] nextLongArr(int n) throws NumberFormatException, IOException {
			long[] retArr = new long[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextLong();
			}
			return retArr;
		}

		public void close() throws IOException {
			reader.close();
		}
	}

}


Measured memory_bytes: 21716
#include<cstdio>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cstring>
using namespace std;

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

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

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }

int N;
pair<int, int> A[100111];

int main() {
    scanf("%d", &N);
    REP (i, N) {
	scanf("%d", &A[i].first);
	A[i].second = i;
    }
    sort(A, A+N);

    int ans = 0;
    REP (i, N) if (i % 2 != A[i].second % 2) ans++;
    printf("%d\n", ans / 2);


    return 0;
}



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

const int INF = 1e9;

const int MAXN = 1.1e5;
const int MAXM = 2.1e5;
int N, M;
map<int, vector<int>> adj[MAXN];

map<int, int> dist[MAXN];

bool update(int v, int c, int d) {
	if (!dist[v].count(c) || dist[v][c] > d) {
		dist[v][c] = d;
		return true;
	} else {
		return false;
	}
}

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> N >> M;
	for (int e = 0; e < M; e++) {
		int p, q, c; cin >> p >> q >> c;
		adj[p][c].push_back(q);
		adj[q][c].push_back(p);
	}

	deque<tuple<int, int, int>> que;
	que.emplace_back(0, 1, 0);
	dist[1][0] = 0;

	while (!que.empty()) {
		int d, v, c; tie(d, v, c) = que.front();
		que.pop_front();
		if (d != dist[v][c]) continue;

		if (v == N) {
			cout << d << '\n';
			exit(0);
		}

		if (c == 0) {
			for (auto& p : adj[v]) {
				if (update(v, p.first, d+1)) {
					que.emplace_back(d+1, v, p.first);
				}
			}
		} else {
			if (update(v, 0, d)) {
				que.emplace_front(d, v, 0);
			}
			for (auto& nv : adj[v][c]) {
				if (update(nv, c, d)) {
					que.emplace_front(d, nv, c);
				}
			}
		}
	}

	cout << -1 << '\n';

	return 0;
}


Measured memory_bytes: 73344
#include <iostream>
#include <vector>
using namespace std;
#define int long long

auto main() -> signed {
    int n;
    cin >> n;
    vector<int> v(n);
    for(int i=0; i<n; ++i) cin >> v[i];


    int ans1 = 0;
    /**
     * 0 => +
     * 1 => -
     */
    int f = 0;
    int t = 0;
    t = v[0];
    if(t<=0) {
        ans1 += abs(t-1);
        t = 1;
    }
    for(int i=1; i<v.size(); ++i) {
        if(f==0 && t+v[i]>=0) {
            ans1 += abs(t+v[i])+1;
            t = -1;
        }
        else if(f==1 && t+v[i]<=0) {
            ans1 += abs(t+v[i])+1;
            t = 1;
        }
        else t += v[i];
        f = (f+1)%2;
    }

    int ans2 = 0;
    /**
     * 0 => +
     * 1 => -
     */
    f = 1;
    t = 0;
    t = v[0];
    if(t>=0) {
        ans2 += t+1;
        t = -1;
    }
    for(int i=1; i<v.size(); ++i) {
        if(f==0 && t+v[i]>=0) {
            ans2 += abs(t+v[i])+1;
            t = -1;
        }
        else if(f==1 && t+v[i]<=0) {
            ans2 += abs(t+v[i])+1;
            t = 1;
        }
        else t += v[i];
        f = (f+1)%2;
    }
    cout << min(ans1, ans2) << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#define ll long long
using namespace std;
int main(){
    string s,t;
    cin>>s>>t;
    int n=s.length();
    
    for(int i=0;i<n;i++){
        string temp;
        for(int j=0;j<n;j++){
            temp+=s[(i+j)%n];
        }
        if(t==temp){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}

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

int main(){
    int N;
    cin >> N;
    vector<long long> A(N);
    for(int i=0; i<N; i++)
        cin >> A[i];
    for(int i=0; i<N; i++)
        A[i] -= i+1;

    sort(A.begin(), A.end());
    int b = A[N/2];
    long long ans = 0;
    for(int i=0; i<N; i++){
        ans += abs(A[i]-b);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<map>
#include<queue>
std::map<std::string,int> mp;
std::queue< std::string > q;
int n,m,ans=0; 
int main()
{
	std::cin>>n;
	for (int i=1;i<=n;i++)
	{
		std::string st;
		std::cin>>st;
		mp[st]++;
		q.push(st); 
	}
	std::cin>>m;
	for (int i=1;i<=m;i++)
	{
		std::string st;
		std::cin>>st;
		mp[st]--;
		q.push(st); 
	}
	while (!q.empty())
	{
		std::string st=q.front();q.pop();
		ans=std::max(ans,mp[st]);
	}
	std::cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << " ";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define tp tuple
#define ft first
#define sc second
#define ve vector
#define tos to_string
#define len length
#define rt return 0
#define br break
#define con continue
#define lcm(n, m) (n * m / gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define repill(i, m, n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define repll(i, n) repill(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m);i>(int)(n);i--)
#define rev(i, n) revi(i, 0, n)
#define revill(i, m, n) for(ll i=(ll)(m);i>(ll)(n);i--)
#define revll(i, n) revill(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define all(n) (n.begin(), n.end())
#define sp(n) cout << fixed << setprecision(n)
#pragma endregion
// sqrt ルート, int 2*10^9, gcd　最大公約数 __builtin_popcount bitの個数

int main() {
  int N, M;
  ci(N, M);
  map<int, int> A;
  rep(i, N){
    int K;
    ci(K);
    rep(j, K){
      int a;
      ci(a);
      if(A.count(a)){
        A.at(a)++;
      }
      else{
        A[a] = 1;
      }
    }
  }
  int c = 0;
  each(i, A){
    if(i.sc == N){
      c++;
    }
  }
  co(c);
}

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

void Judge(int,int);

int main()
{
	int a,b;
	cin >> a >> b;
	Judge(a,b);
	return 0;
}

void Judge(int a,int b){
	if(a<b){
		cout << "a < b" << endl;
	}
	else if(a>b){
		cout << "a > b" << endl;
	}
	else{
		cout << "a == b" << endl;
	}
}

Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
int main(){
  
  int n;
  cin >> n;
  
  vector<int> v(n);
  
  for(int i; i < n; i++){
    cin >> v.at(i);
  }
  
  sort(v.begin(), v.end());
  reverse(v.begin(), v.end());
  
  int s = 0;
  
  for(int i; i < n; i++){
    s += v.at(i);
  }
  
  if(s > 2 * v.at(0)){
    cout << "Yes" << endl;
  }
  
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

int main()
{
  int n;
  char str[10];
  
  scanf("%d %s",&n,str);
  
  if(n<3200)
    printf("red\n");
  else
    printf("%s\n",str);
  
  return 0;
}
  
  
  


Measured memory_bytes: 128
import java.lang.*;
import java.util.*;
public class Main {
    public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int fh = n/500;
    n= n - (fh*500);
    int f = n/5;
    long ans = (fh*1000)+(f*5);
    System.out.print(ans);
    }
}

Measured memory_bytes: 23252
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		
		int k=sc.nextInt();
		String s=sc.next();
		
		String ans="";
	
		if(s.length()<=k){
			System.out.println(s);
		}else {
			for(int i=0;i<k;i++){
				ans=ans+s.charAt(i);
			
		}
		System.out.println(ans+"...");
		}
	}

}

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

#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for (int i = (n); i >= 0; i--)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int dp[101][10001];

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

    int v[n + 1], w[n + 1];
    for (int i = 1; i <= n; i++)
        cin >> v[i] >> w[i];

    for (int j = 0; j <= W; j++)
        dp[0][j] = 0;

    for (int i = 1; i <= n; i++)
    {
        for (int j = 0; j <= W; j++)
        {
            if (j - w[i] >= 0)
                dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w[i]] + v[i]);
            else
                dp[i][j] = dp[i - 1][j];
        }
    }

    OP(dp[n][W]);

    return 0;
}


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

int main()
{
    int A, B, C, D;
    int AB, CD;
    cin >> A >> B >> C >> D;
    AB = A * B;
    CD = C * D;
    if (AB > CD)
    {
        cout << AB << endl;
    }
    else
    {
        cout << CD << endl;
    }
}

Measured memory_bytes: 256
import math

s=input()
t=input()
n=len(s)

ok=False

for i in range(n):
    tmp=True
    for j in range(n):
        if(s[(i+j)%n]!=t[j]):
            tmp=False

    if(tmp):
        ok=True


if ok:
    print("Yes")
else:
    print("No")



Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;

namespace kyoupuro {

    class MainClass {

        public static void Main() {

            var N = Input.NextInt();
            var list = Input.IntList();

            Console.WriteLine(
                Enumerable
                .Range(-100, 201)
                .Select(x => list.Aggregate(0, (prev, now) => prev + (x - now)*(x - now)))
                .Min()
            );
        }
    }

    class Input {
        static IEnumerator<string> enumerator;

        public static string Line() {
            return Console.ReadLine();
        }

        public static int NextInt() {
            if (enumerator == null || !enumerator.MoveNext()) {
                enumerator = StrArr().AsEnumerable().GetEnumerator();
                enumerator.MoveNext();
            }
            return int.Parse(enumerator.Current);
        }

        public static long NextLong() {
            if (enumerator == null || !enumerator.MoveNext()) {
                enumerator = StrArr().AsEnumerable().GetEnumerator();
                enumerator.MoveNext();
            }
            return long.Parse(enumerator.Current);
        }

        public static string[] StrArr() {
            return Line().Split(' ');
        }

        public static List<int> IntList() {
            return StrArr().Select(int.Parse).ToList();
        }

        public static List<long> LongList() {
            return StrArr().Select(long.Parse).ToList();
        }

        public static void Skip(int line = 1) {
            enumerator.Reset();
            for (int i = 0; i < line; i++) Console.ReadLine();
        }

        public static void Reset() {
            enumerator.Reset();
        }
    }
}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int main() {
    // メインプログラムここから
    ll a, b, c; cin >> a >> b >> c;
    if (a >= b && a>= c && a == b + c)  {
        cout << "Yes" << endl;
    }
    else if (b >= c && b >= a && b == a + c) {
        cout << "Yes" << endl;
    }
    else if (c >= a && c >= b && c == a + b) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
        
    // ここまで
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest._800problems
{
    class AGC006_C
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);

            Method(args);

            Out.Flush();
        }

        static void Method(string[] args)
        {
            int n = ReadInt();
            long[] xs = ReadLongs();
            long[] mk = ReadLongs();
            long m = mk[0];
            long k = mk[1];
            int[] array = ReadInts();
            long[] deltas = new long[n - 1];
            for(int i = 0; i < n-1; i++)
            {
                deltas[i] = xs[i + 1] - xs[i];
            }
            int[][] swaps = new int[100][];
            swaps[0] = new int[n - 1];
            for(int i = 0; i < n-1; i++)
            {
                swaps[0][i] = i;
            }
            for(int i = 0; i < m; i++)
            {
                int left = array[i] - 2;
                int right = left + 1;
                int tmp = swaps[0][left];
                swaps[0][left] = swaps[0][right];
                swaps[0][right] = tmp;
            }
            for(int i = 1; i < 100; i++)
            {
                swaps[i] = new int[n - 1];
                for(int j = 0; j < n-1; j++)
                {
                    swaps[i][j] = swaps[i - 1][swaps[i - 1][j]];
                }
            }

            int[] kSwap = new int[n - 1];
            for (int i = 0; i < n - 1; i++) kSwap[i] = i;
            long cnt = 1;
            int pow = 0;
            while (cnt<=k)
            {
                if ((k & cnt)>0)
                {
                    int[] next = new int[n - 1];
                    for(int i = 0; i < n - 1; i++)
                    {
                        next[i] = kSwap[swaps[pow][i]];
                    }
                    kSwap = next;
                }
                cnt *= 2;
                pow++;
            }

            WriteLine(xs[0]);
            long now = xs[0];
            for(int i = 0; i < n - 1; i++)
            {
                now += deltas[kSwap[i]];
                WriteLine(now);
            }
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e16+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

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

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<std::setprecision(10);

    ll n;
    cin>>n;
    ll ans=0;
    Vec able(105001,0);
    REP(i,1,1001){
        REP(j,i*100,i*105+1){
         able[j]=1;
        }
    }
    cout<<able[n]<<endl;
    return  0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i, n) for(long long i=0; i<n; i++)
#define REPR(i, n) for(long long i=n-1; i>=0; i--)
#define FOR(i, m, n) for(long long i=m; i<=n; i++)
#define FORR(i, m, n) for(long long i=m; i>=n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;


ll n;
ll dp[102][4][4][4];
int main(){FIN

    cin>>n;
    dp[0][3][3][3] = 1;
    REP(i,n){
        REP(j,4){
            REP(k,4){
                REP(l,4){
                    if(dp[i][j][k][l]==0)continue;
                    REP(a,4){
                        if (j==0 && l==1 && a==2)continue;
                        if (j==0 && k==1 && a==2)continue;
                        if (k==1 && l==0 && a==2)continue;
                        if (k==0 && l==1 && a==2)continue;
                        if (k==0 && l==2 && a==1)continue;
                        dp[i+1][k][l][a]+=dp[i][j][k][l];
                        dp[i+1][k][l][a]%=mod;
                    }
                }
            }

        }

    }
    ll ans = 0;
    REP(i,4){
        REP(j,4){
            REP(k,4){
                ans+=dp[n][i][j][k];
                ans%=mod;
            }
        }
    }
    ans%=mod;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
INF = 10**18
MOD = 998244353

N = int(input())
robots = [(-INF, INF)]

for _ in range(N):
    x, d = map(int, input().split())
    robots.append((x, x + d))

robots.sort()
stack = list()

tree = [[] for _ in range(N + 1)]

for i in range(N + 1)[::-1]:
    x, r = robots[i]
    while stack and stack[-1][0] < r:
        y, j = stack.pop()
        tree[i].append(j)
    stack.append((x, i))

stack = list()
stack.append(0)

visited = [0 for _ in range(N + 1)]
visited[0] = 1
order = [None for _ in range(N + 1)]
order[0] = 0
od = 0

while stack:
    node = stack.pop()
    for adj in tree[node]:
        if not visited[adj]:
            visited[adj] = 1
            od += 1
            order[od] = adj
            stack.append(adj)

dp = [1 for _ in range(N + 1)]

for node in order[::-1]:
    for adj in tree[node]:
        dp[node] *= dp[adj]
    dp[node] += 1
    dp[node] %= MOD

print(dp[0] - 1)

Measured memory_bytes: 113316
#include<stdio.h>

int main()
{
    int N,K,a,i,j;
    int S[100],B[100][100],num[100];

    while(scanf("%d%d",&N,&K),N+K){

        a=1;
        for(i=0;i<100;i++){
            num[i]=0;
        }

        for(i=0;i<K;i++){
            scanf("%d",&S[i]);
        }
        for(i=0;i<N;i++){
            for(j=0;j<K;j++){
                scanf("%d",&B[i][j]);
            }
        }

        for(j=0;j<K;j++){
            for(i=0;i<N;i++){
                num[j]+=B[i][j];
            }
        }

        for(i=0;i<K;i++){
            a*=S[i]<num[i]?0:1;
        }
        if(a){
            puts("Yes");
        } else {
            puts("No");
        }
    }
    return 0;

}

Measured memory_bytes: 620
# include <bits/stdc++.h>
using namespace std;
const int maxn =100+5;
int x[maxn],y[maxn];
int main ()
{
  int m,n,a,b;
  cin>>n>>m>>a>>b;
  for (int i=0;i<n;++i)
      cin>>x[i];
  for (int i=0;i<m;++i)
      cin>>y[i];
  sort (x,x+n);
  sort (y,y+m);
  int zmin=x[n-1]+1,zmax=y[0]; 
  if (zmin>zmax)
    printf ("War\n");
  else 
    {
    	if (a<zmin&&b>zmax)
    	  printf ("No War\n");
    	else
    	  printf ("War\n");
	}
	return 0; 
} 

Measured memory_bytes: 256
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args){

		solve_abc158_d();
	}
  
  	public static void solve_abc158_d(){

		Scanner sc = new Scanner(System.in);

		
		StringBuilder sb = new StringBuilder(sc.next());
		StringBuilder front = new StringBuilder();
		StringBuilder bak = new StringBuilder();
		
		int q = sc.nextInt();
		
		boolean rev = false;
		
		for(int i=0;i<q;i++){
			
			int t = sc.nextInt();
			
			if(t == 1){
				rev = !rev;
			}
			else if(t == 2){
				int f = sc.nextInt();
				
				
				if((f == 1 && !rev ) || (f == 2 && rev)){
					/*
					StringBuilder sbtmp = new StringBuilder(sc.next());
					sbtmp.append(sb);
					sb = sbtmp;
					*/
					//sb.insert(0, sc.next());
					
					front.append(sc.next());
				}
				else {
					bak.append(sc.next());
					//sb.append(sc.next());
				}
			}
		}
		
		front.reverse();
		front.append(sb).append(bak);
		
		if(rev) front.reverse();
		
		System.out.println(front);

		sc.close();

	}
}

Measured memory_bytes: 126456
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define rSort(v) sort(v.rbegin(), v.rend())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

/* Macros reg. ends here */

const ll INF = 1LL << 50;

ll const mod = 998244353;

int main() {
  // ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll n;
  cin >> n;
  vll as(n), bs(n);
  rep(i, n) cin >> as[i] >> bs[i];
  Sort(as), Sort(bs);

  ll idx = (n - 1) / 2;
  ll meda = as[(n - 1) / 2];
  ll medb = bs[(n - 1) / 2];
  if (n % 2 == 0) {
    meda += as[idx+1];
    medb += bs[idx+1];
  }

  ll ans = medb - meda + 1;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 6264
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 300005;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int N; string S;
    cin >> N >> S;
    char W = 'W', E = 'E';
    vector<int> cntW(MAX), cntE(MAX);
    for (int i = 0; i < N; i++) {
        cntW[i] += S[i] == W;
        cntE[i] += S[N - 1 - i] == E;
    }
    for (int i = 0; i < N - 1; i++) {
        cntW[i + 1] += cntW[i];
        cntE[i + 1] += cntE[i];
    }
    int ans = INF;
    for (int i = 0; i < N; i++) {
        ans = min(ans, cntW[i] + cntE[N - 1 - i] - 1);
    }
    cout << ans << '\n';
}


Measured memory_bytes: 2948
import math
import sys
import bisect
readline = sys.stdin.readline


def main():
    n = int(readline().rstrip())
    A = list(map(int, readline().rstrip().split()))
    k = 0

    if A.count(1) == 0:
        print(-1)
        return

    for i in range(n):
        if A[i] == k + 1:
            k += 1

    print(n - k)


if __name__ == '__main__':
    main()


Measured memory_bytes: 32372
package scc;
sub new{
	return bless[map[],1..$_[1]],$_[0];
}
sub add_edge{
	my$self=shift;
	push@{$self->[$_[0]]},$_[1];
}
sub scc{
	my$self=shift;
	my$now_ord=0,$group_num=0,@low,@ord=(-1)x@{$self},@ids;
	my@visited;
	my$dfs;
	$dfs=sub{
		my$v=shift;
		$low[$v]=$ord[$v]=$now_ord++;
		push@visited,$v;
		for$to(@{$self->[$v]}){
			if($ord[$to]==-1){
				$dfs->($to);
				$low[$v]=$low[$to]if$low[$v]>$low[$to];
			}
			else{
				$low[$v]=$ord[$to]if$low[$v]>$ord[$to];
			}
		}
		if($low[$v]==$ord[$v]){
			my$u=-1;
			while($u!=$v){
				$u=pop@visited;
				$ord[$u]=@{$self};
				$ids[$u]=$group_num;
			}
			$group_num++;
		}
	};
	my$cnt=0;
	for$i(@ord){
		$dfs->($cnt)if$i==-1;
		$cnt++;
	}
	$_=$group_num-1-$_ for@ids;
	my@groups=map[],1..$group_num;
	$cnt=0;
	for$i(@ids){
		push@{$groups[$i]},$cnt++;
	}
	return\@groups;
}
package main;
my($N,$M)=split$",<>;
my$scc=scc->new($N);
for(1..$M){
	my($a,$b)=split$",<>;
	$scc->add_edge($a,$b);
}
$groups=$scc->scc();
print scalar(@{$groups}),$/;
for$L(@{$groups}){
	print scalar(@{$L}),$","@{$L}",$/;
}


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

int main()
{
    int c = 1000, f = -1;
    string str;

    cin >> str;

    for (int i = 0; i < str.size(); i++) {
        if (str[i] == 'C' && c == 1000) c = i;
        if (str[i] == 'F') f = i;
    }

    if (c < f) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N = 1001;
#define fr(i,low,up) for(register int i = low;i <= up; ++i)
#define nfr(i,low,up) for(register int i = low;i >= up; --i)

int ans[N][N];
int h,w,a,b;

int main(){
   scanf("%d%d%d%d",&h,&w,&a,&b);
   fr(i,1,b){
      fr(j,1,a)ans[i][j] = 0;
      fr(j,a+1,w)ans[i][j] = 1;
   }
   fr(i,b+1,h){
      fr(j,1,a)ans[i][j] = 1;
      fr(j,a+1,w)ans[i][j] = 0;
   }
   fr(i,1,h){
      fr(j,1,w){
         cout << ans[i][j];
      }
      cout << endl;
   }
   return 0;
}


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

// Max, Min and Sum

int main(){
	int n;
	int inputNum;
	int min, max;
	long sum;

	cin >> n;
	cin >> inputNum;
	min = max = sum = inputNum;

	for (int i = 1; i < n; i++){
		cin >> inputNum;
		if (inputNum > max) max = inputNum;
		if (inputNum < min) min = inputNum;
		sum += inputNum;
	}
	cout << min << ' ' << max << ' ' << sum << endl;

	return 0;
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
#define PI 3.141592653589793




int main(){
   string s;
   cin >> s;
   int n=s.size();
   bool a=false;
   rep(i,n-1){
       if(s.at(i)=='A' && s.at(i+1)=='C')a=true;
   } 
   if(a)cout <<  "Yes" << endl;
   else cout << "No" << endl;
}


Measured memory_bytes: 3632
while True:
	try:
		N=input()
	except:
		break
	a=list(map(int, input().split()))
	#print(a)
	ans=1
	for v in a:
		ans*=v
		if 1000000000000000000 < ans:
			ans = -1
			break
	if any([v==0 for v in a]):
		ans=0
	print(ans)


Measured memory_bytes: 21700
#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 maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
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;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}

int main() {
  int H,W;
  cin >> H >> W;
  v(v(char)) M(H,v(char)(W));
  rep(i,H) {
    rep(j,W) {
      cin >> M[i][j];
    }
    
  }
  v(v(P)) G(H,v(P)(W,P(0,0)));
  rep(i,H) {
    int start = INF;
    rep(j,W) {
      if(M[i][j] == '#') {
        for(int k = j-1;k >= start;k--) {
          G[i][k] = P(j - start,G[i][k].second);
        }
        start = INF;
      } else {
        if(start == INF) start = j;
      }
    }
    if(start != INF) {
      for(int k = W-1;k >= start;k--) {
        G[i][k] = P(W - start,G[i][k].second);
      }
    }
  }
  rep(i,W) {
    int start = INF;
    rep(j,H) {
      if(M[j][i] == '#') {
        for(int k = j-1;k >= start;k--) {
          G[k][i] = P(G[k][i].first,j - start);
        }
        start = INF;
      } else {
        if(start == INF) start = j;
      }
    }
    if(start != INF) {
      for(int k = H-1;k >= start;k--) {
        G[k][i] = P(G[k][i].first,H - start);
      }
    }
  }

  int ans = -INF;
  rep(i,H) {
    rep(j,W) {
      int n = G[i][j].first + G[i][j].second;
      ans = max(ans,n);
    }
  }
  cout << ans -1 << endl;
  return 0;
}

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


using namespace std;

int main() {
	int X[3];
	cin >> X[0];
	cin >> X[1];
	cin >> X[2];

	int res;
	int n;
	switch (X[0] % 2 + X[1] % 2 + X[2] % 2)
	{
	case 0:
	case 3:
		n = max_element(X, X + 3) - X;
		res = (X[n] * 3 - (X[0] + X[1] + X[2])) / 2;
		break;
	case 1:
		X[0] += X[0] % 2 ? 0 : 1;
		X[1] += X[1] % 2 ? 0 : 1;
		X[2] += X[2] % 2 ? 0 : 1;
		n = max_element(X, X + 3) - X;
		res = (X[n] * 3 - (X[0] + X[1] + X[2])) / 2 + 1;
		break;
	case 2:
		X[0] += X[0] % 2;
		X[1] += X[1] % 2;
		X[2] += X[2] % 2;
		n = max_element(X, X + 3) - X;
		res = (X[n] * 3 - (X[0] + X[1] + X[2])) / 2 + 1;
		break;
	}
	cout << res << endl;
	return 0;

}

Measured memory_bytes: 256
S = input()
if S[0] == S[1] and S[2] == S[3] and S[0] != S[2]:
	print('Yes')
elif S[0] == S[2] and S[1] == S[3] and S[0] != S[1]:
	print('Yes')
elif S[0] == S[3] and S[1] == S[2] and S[0] != S[1]:
	print('Yes')
else:
	print('No')

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

int main(void){
    int n;
    cin >> n;
    if(n >= 1000)cout << "ABD" << endl;
    else cout << "ABC" << endl;
    return 0;
}

Measured memory_bytes: 256
class SCCGraph
    def initialize(n = 0)
        @n, @edges = n, []
    end
  
    def add_edge(from, to); @edges << [from, to]; end
  
    # returns list of strongly connected components
    # the components are sorted in topological order
    # O(N + M)
    def scc
        group_num, ids = scc_ids
        counts = Array.new(group_num, 0)
        ids.each { |x| counts[x] += 1 }
        groups = Array.new(group_num) { [] }
        ids.each_with_index { |x, i| groups[x] << i }
        groups
    end

    def scc_ids
        start, elist = csr
        now_ord = group_num = 0
        visited, low, ord, ids = [], [], [-1] * @n, []

        dfs = ->(v) {
            low[v] = ord[v] = now_ord
            now_ord += 1
            visited << v
            (start[v]...start[v + 1]).each do |i|
                to = elist[i]
                low[v] = if ord[to] == -1
                    dfs.(to)
                    [low[v], low[to]].min
                else
                    [low[v], ord[to]].min
                end
            end

            if low[v] == ord[v]
                loop do
                    u = visited.pop
                    ord[u] = @n
                    ids[u] = group_num
                    break if u == v
                end
                group_num += 1
            end
        }
        @n.times { |i| dfs.(i) if ord[i] == -1 }
        ids = ids.map { |x| group_num - 1 - x }
        [group_num, ids]
    end
  
    def csr
        start = Array.new(@n+1, 0)
        elist = Array.new(@edges.size)
        @edges.each { |(i, _)| start[i + 1] += 1 }
        @n.times { |i| start[i + 1] += start[i] }
        counter = start.dup
        @edges.each do |(i, j)|
            elist[counter[i]] = j
            counter[i] += 1
        end
        [start, elist]
    end
end

class Two_Sat
    def initialize(n)
        @n = n
        @answer = Array.new(n)
        @scc = SCCGraph.new(2 * n)
    end

    def add_clause(i, f, j, g)
        @scc.add_edge(2 * i + (f ? 0 : 1), 2 * j + (g ? 1 : 0))
        @scc.add_edge(2 * j + (g ? 0 : 1), 2 * i + (f ? 1 : 0))
    end

    def satisfiable
        id = @scc.scc_ids[1]
        @n.times do |i|
            return false if id[2 * i] == id[2 * i + 1]
            @answer[i] = id[2 * i] < id[2 * i + 1]
        end
        true
    end

    def answer; @answer; end
end

n, d = gets.split.map(&:to_i)
ts = Two_Sat.new(n)

xy = []
n.times do |i|
    s, t = gets.split.map(&:to_i)
    xy.each_with_index do |(x, y), j|
        ts.add_clause(i, false, j, false) if (s - x).abs < d
        ts.add_clause(i, false, j, true) if (s - y).abs < d
        ts.add_clause(i, true, j, false) if (t - x).abs < d
        ts.add_clause(i, true, j, true) if (t - y).abs < d
    end
    xy << [s, t]
end

if ts.satisfiable
    puts "Yes"
    ts.answer.each_with_index {|e, i| puts e ? xy[i][0] : xy[i][1]}
else
    puts "No"
end

Measured memory_bytes: 14736
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
typedef long long int ll;
const int N = 1e5 + 5;
//const int INF = 1e9 + 5;
//int a[N];
void solve_test_case(){
	char c;
	cin>>c;
	if((int)c >= 65 && (int)c <= 90){
		cout<<"A"<<"\n";
		return;
	}
	cout<<"a\n";
}
 
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int t = 1;
	//cin>>t;
	for(int i = 0;i < t;++i){
		solve_test_case();
	}
}


Measured memory_bytes: 3692
#include<iostream>
using namespace std;
int a = 1000,b = 5000,c = 10000;

void calc(int n,int y){
     
  for(int i = 0; i<=n; i++){
    for(int j = 0; j<=n-i;j++){
      for(int k = 0;k<=n-i-j;k++){
          
        if(c * i + b * j + a * k == y){
          if(i + j + k == n){
            cout << i << " " << j << " " << k << endl;
            return;
          }
        }
      }
    }
  }
  
  cout << -1 << " " << -1 << " " << -1 << endl;
  return;
} 
 
int main(){
 
  int n,y;
  cin >> n >> y;
 
  calc(n,y);
  
  return 0;
  
}

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

using namespace std;

const int INF = 1 << 30;

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

  if((B - A) % 2 == 0) {
    cout << "Alice" << endl;
  } else {
    cout << "Borys" << endl;
  }
}


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

int main() {
  int a,b;
  cin >>a>>b;
  cout << a*b<<endl; 
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>	
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define ld long double
#define pii pair <int, int>
#define sz(a) (int)(a.size()) 
#define resize(v) v.resize(unique(all(v)) - v.begin()); 
#define all(a) a.begin(), a.end()
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it ++)

// random_device rd; mt19937 g(rd());    
                                        	
using namespace std;
using namespace __gnu_pbds;
 
void Fast_Read_Out()
{
    ios_base::sync_with_stdio(0);
    cin.tie(), cout.tie();
}
 
void Random()
{
    unsigned int seed;                                                                        
    asm("rdtsc" : "=A" (seed));
    srand(seed);        
}
 
unsigned int Time()
{
     unsigned int time = clock() / 1000.00;                           
     return time;
}

template <typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>; 
 
const int mod = (int)1e9 + 7;

int main ()
{
	#ifdef JUDGE
		freopen("input.txt", "r", stdin);
	#endif		
	Fast_Read_Out();
	Random();
	long long n, a, b;
	cin >> n >> a >> b;         
	if(a == 0) cout << 0, exit(0);
	long long ans = a * (n / (a + b)) + min(n % (a + b), a);
	cout << ans;
}      

Measured memory_bytes: 256
int main()
{
  int i,max,min,a[1000],sum,n;
  while(1){
    sum=0;
  scanf("%d",&n);
  if(n==0)break;
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
    sum=sum+a[i];
    if(i==0){
      max=a[i];
      min=a[i];
    }
    if(max<a[i])
      max=a[i];
    if(min>a[i])
      min=a[i];
  }
  sum=sum-max-min;
  printf("%d\n",sum/(n-2));
  }
  return 0;
}

Measured memory_bytes: 600
n=int(input())
t,a=map(int,input().split())
hl = list(map(int,input().split()))

temp=[]
c=t-hl[0]*0.006
ans=abs(c-a)
temp.append(ans)
for i in range(1,n) :
  cal=abs((t-hl[i]*0.006)-a)
  temp.append(cal)
  if ans>cal :
    ans=cal
print(temp.index(ans)+1)

Measured memory_bytes: 3064