akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ii pair<int,int>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<ii>
 
using namespace std;

void solve(){

	return;
}
 
int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n,m;

	cin >> n >> m;

	cout << (n == m ? "Yes": "No") << endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder2 {
	class Program {
		static void Main(string[] args) {
          
          
	var inputArray = retreiveLongArray();
			var inputCount = 4;

			// 不正な入力は処理しない
			if (inputArray.Length != inputCount) {
				Console.WriteLine("invalid input");
				return;
			}
			double A = inputArray[0];
			double B = inputArray[1];
			double H = inputArray[2];
			double M = inputArray[3];

			//まず何度離れているかを求める
			var angleA = (Math.PI * 2) * ((H / 12) + (1.0 / 12.0) * (M / 60));
			var angleB = (Math.PI * 2) * (M / 60);

			var bigger = Math.Max(angleA, angleB);
			var smaller = Math.Min(angleA, angleB);


			var angle = Math.Min(bigger - smaller, Math.PI * 2 - (bigger - smaller));

			//余弦定理より
			var ansjijou = A * A + B * B - 2 * A * B * Math.Cos(angle);

			//答えの出力
			var ans = Math.Sqrt(ansjijou);
			Console.WriteLine(ans);

		}

		/// <summary>
		/// スペースで区切られた文字列配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static string[] retreiveStringArray() {
			var inputArray = Console.ReadLine().Split(' ');
			return inputArray;
		}

		/// <summary>
		/// スペースで区切られた整数配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static long[] retreiveLongArray() {
			var inputArray = Console.ReadLine().Split(' ');
			var longArray = inputArray.Select(s => long.Parse(s));
			return longArray.ToArray();
		}
	}
}


Measured memory_bytes: 28564
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = 1; i < (int)(n+1); i++)
const long long INF = 1LL << 60;
int main(){
   ll a,b;
   cin>>a>>b;
   ll mod=1000000007;
   if(abs(a-b)<=1){
       ll ans=1;
       rrep(i,a){
           ans*=i;
           ans%=mod;
       }
       rrep(i,b){
           ans*=i;
           ans%=mod;
       }
     	if(a==b){
          ans*=2;
        }
       cout<<ans%mod<<endl;
   }
   else{
       cout<<0<<endl;
   }
}



Measured memory_bytes: 3536
while True:
    m,f,r = map(int,input().split())
    if m == -1 and f == -1 and r == -1:
        break
    if m == -1 or f == -1:
        print("F")
    elif m + f >= 80:
        print("A")
    elif m + f >= 65:
        print("B")
    elif m + f >= 50:
        print("C")
    elif m + f >= 30:
        if r >= 50:
            print("C")
        else:
            print("D")
    else:
        print("F")


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

#define ll long long
#define mp make_pair
#define pb push_back

#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define rep(i, n) for (int i = 0; i < (int)(n); ++ i)

int n;
ll ans = 0;

int main() {
	scanf("%d", &n);
	rep(i, n) ans += 1LL * (i + 1) * (n - i);
	rep(i, n - 1) {
		int u, v;
		scanf("%d %d", &u, &v);
		-- u; -- v;
		if (u > v) swap(u, v);
		ans -= 1LL * (u + 1) * (n - v);
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 3828
# https://atcoder.jp/contests/apc001/tasks/apc001_b

n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
t = sum(b) - sum(a)
pos = 0
neg = 0
for i in range(n):
    d = a[i] - b[i]
    if d > 0:
        pos += d
    elif d < 0:
        neg += -1 * d // 2
if pos <= neg:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 41488
///int ->(-2147483648<->2147483647)
///unsigned int(0<->4294967295)
///long long int (-9,223,372,036,854,775,808 to 9,223,372,036,854,775,807)
///unsigned long long int (0 to 18,446,744,073,709,551,615)
//#include<bits/stdc++.h>
#include<iostream>
#include<vector>
#include<queue>
#include<stdio.h>
#include<map>
#include<math.h>
#include<algorithm>
#include<string>
#include<utility>
#include<stack>
#include<cstring>
#include<iterator>
#include<unordered_map>
#include<unordered_set>
#include<set>
#include<iomanip> ///setprecision
#include<cmath>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

#define FIO ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define OPEN freopen("in.txt","r",stdin)
#define OUT freopen("out.txt","r",stdin)
#define INF 1000000000
#define ll long long
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pcc pair<char,char>
#define pdd pair<double,double>
#define vi vector<int>
#define vll vector<long long>
#define vc vector<char>
#define vd vector<double>
#define sci(value) scanf("%d%*c",&value)
#define scl(value) scanf("%lld%*c",&value)
#define pi  (2*acos(0))
#define pb push_back
#define valid(value123,value234,limitrow,limitcol) value123>=0&&value123<limitrow&&value234>=0&&value234<limitcol
//int fx[]= {0,0,1,-1,-1,1,-1,1};//kings move
//int fy[]= {1,-1,0,0,-1,1,1,-1};//kings move
//int fx[]={-2,-2,-1,-1, 1,1, 2,2};  // Knights Move
//int fy[]={-1, 1,-2, 2,-2,2,-1,1}; // Knights Move
//ll powFunction(ll a,ll b){if(b==0)return 1;ll re=powFunction(a,b/2);re=(re*re);if(b&1)re=(re*a);return re;}
///ll digitSum(ll a){ll ans=0;while(a){ans+=(a%10);a/=10;}return ans;}

#define MX 100005
#define mod 1000000007
vector<int>graph[MX];
int dist[MX],vis[MX];
void dfs(int src)
{
    vis[src]=1;
    int val=0;
    for(int i=0;i<graph[src].size();i++)
    {
        if(!vis[graph[src][i]])
        {
            dfs(graph[src][i]);
        }
        val=max(val,dist[graph[src][i]]);
    }
    dist[src]=val+1;
}
int main()
{
    int n,m,a,b;
    sci(n),sci(m);
    for(int i=0;i<m;i++)
    {
        sci(a),sci(b);
        graph[a].push_back(b);
    }
    for(int i=1;i<=n;i++)
    {
        if(vis[i]==0)
            dfs(i);
    }
    int val = *max_element(dist,dist+n+1);
    printf("%d\n",val-1);
}



Measured memory_bytes: 8576
// 基本テンプレート

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

typedef pair<int, int> pii;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

int N, M;
int deg[100010];

signed main() {
    cin >> N >> M;
    rep(i,0,M) {
        int a, b; cin >> a >> b;
        deg[a]++; deg[b]++;
    }
    bool ok = true;
    rep(i,0,N) {
        // printf("deg = %lld\n", deg[i]);
        ok &= !(deg[i] % 2);
    }
    cout << (ok ? "YES" : "NO") << endl;
    return 0;
}

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

int main() {
	int c[3][3];
	for(int i = 0; i < 3; ++i) {
		for(int j = 0; j < 3; ++j) {
			std::cin >> c[i][j];
		}
	}

	int a[3], b[3];
	a[0] = 0;
	for(int j = 0; j < 3; ++j) {
		b[j] = c[0][j];
	}
	a[1] = c[1][0] - b[0];
	a[2] = c[2][0] - b[0];

	bool ans = true;
	for(int i = 0; i < 3; ++i) {
		for(int j = 0; j < 3; ++j) {
			if(a[i] + b[j] != c[i][j]) {
				ans = false;
				break;
			}
		}
	}

	std::cout << (ans ? "Yes" : "No") << std::endl;
}


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

int x, y;
int n, m;

struct modular_arithmetic{
	int mod;

	modular_arithmetic(){
		mod = 1000000007;
	}
	//No specific settings.
	int add(int x,int y){return (x+=y)<mod?x:x-mod;}
	int sub(int x,int y){return (x-=y)>=0?x:x+mod;}
	int mul(int x,int y){return (int)((long long int)x*y%mod);}
	int pw(int base, int p) {
		int res = 1, mu = base%mod;
		for(;p>0;p/=2) {
			if (p&1) res = mul(res, mu);
			mu = mul(mu, mu);
		}
		return res;
	}
	int rev(int x) {return pw(x, mod-2);}
};
modular_arithmetic ma;

int main() {
	scanf("%d%d", &x, &y);
	
	n = (x+y)/3;
	m = x - n;
	if(m<(n-m)) m = n-m;
	if((x+y)%3 || n<0 || m>n) {
		puts("0");
		return 0;
	}
	
	int res = 1;
	for(int i=m+1;i<=n;i++)
		res = ma.mul(res, i);
	for(int i=n-m;i>1;i--)
		res = ma.mul(res, ma.rev(i));
	printf("%d\n", res);
	
	return 0;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: usize
    }
    println!("{}", ((n + 1) / 2) as f64 / n as f64);
}


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

#define    ll     long long int

int main( )
{
    int n, i, l, r;
    int s = 0;
    cin >> n;
    while (n--) {
        cin >> l >> r;
        s += (r - l + 1);
    }
    cout << s << '\n';
    return 0;
}

Measured memory_bytes: 256
def et():
    lis = []
    for n in eat:
        eat[n] = eat[n]-1
        if eat[n] == 0:
            ct(n)
            lis.append(n)
    for n in lis:
        del eat[n]
        
def ct(n):
    for i, s in enumerate(counter):
        if s == n:
            counter[i] = '_'
            
def wt():
    for n in wait:
        wait[n] = wait[n]+1
        
def ck(n, w):
    c = 5 if n%5 == 1 else 2
    for i, s in enumerate(counter):
        if s == '_':
            if counter[i:i+c] == ['_']*c:
                for i in range(i,i+c):
                    counter[i] = n
                else:
                    res[n] = w
                    return True
    
res = {}       
procession = []
wait = {}
eat = {}
counter = ['_' for i in range(17)]
t = 0
while True:
    et()
    wt()
    if procession:
        for n in procession[:]:
            if ck(n, wait[n]):
                del wait[n]
                del procession[0]
                eat[n] = 17*(n%2)+3* (n%3)+19
            else:
                break
    if len(res) == 100:
        break
    if t <= 495:
        if t%5 == 0:
            n = t/5
            if not procession and ck(n, 0):
                eat[n] = 17*(n%2)+3* (n%3)+19
            else:
                procession.append(n)
                wait[n] = 0
    t += 1
    
while True:
    try:
        print res[input()]
    except EOFError:
        break

Measured memory_bytes: 4332
import java.util.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int a=Integer.parseInt(sc.next());
int b=Integer.parseInt(sc.next());
int c=Integer.parseInt(sc.next());
int x=Integer.parseInt(sc.next());
int ans=0;
for(int i=0;i<=a;i++){
  for(int j=0;j<=b;j++){
  for(int k=0;k<=c;k++){
  if(i*500+j*100+k*50==x)ans++;
  }
  }
}
  System.out.println(ans);
}}

Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define P pair<int, int>
#define ll long long

using namespace std;
int mod = 1000000007;

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

  int n=s.size();

  rep(i, n) {
    string now;
    rep(j, n) {
      now.push_back(s.at((i+j)%n));
    }
    if (now == t) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String arg[]){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] A = new int[n];
		int max = 100000*100000;
		for(int i=0; i<n; i++){
			A[i] = sc.nextInt();
		}
		int ans = solve(n, k, A);	
		System.out.println(ans);
		
	}
	public static int check(int p, int n, int k, int A[]){
		int i = 0;
		for(int j =0; j<k; j++){
			int s = 0;
			while(s + A[i] <= p){
				s += A[i];
				i++;
				if (i==n) return n;
			}
		}
		return i;	
	}
	
	public static int solve(int n, int k, int A[]){
		int left = 0;
		int right = 100000 * 100000;
		int mid;
		while (right-left > 1){
			mid = (right + left) / 2;
			int v = check(mid, n, k, A);
			if (v>=n) {
				right=mid;
			} else {
				left = mid;
			}
		}
		return right;
	}
}



Measured memory_bytes: 70144
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
#define rep(i,n) for (int i = 0;i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int INF = 1e9;
void chmax(int& a, int b) { a = max(a, b);}
void chmin(int& a,int b) {a = min(a,b);}

int main(){
    int n;cin >> n;
    vector<vector<int>> dp(2005,vector<int>(2005,-INF));
    vector<int> a(3*n);rep(i,3*n) cin >> a[i],--a[i];

    int m = n+1;
    auto upd = [&](int i,int j,int x){
        chmax(dp[i][j],x);
        chmax(dp[j][i],x);
        chmax(dp[j][n],x);
        chmax(dp[n][j],x);
        chmax(dp[i][n],x);
        chmax(dp[n][i],x);
        chmax(dp[n][n],x);
    };

    upd(a[0],a[1],0);
    int base = 0;
    for(int ai = 2;ai < 3*n-1;ai += 3){
        int x = a[ai],y = a[ai+1],z = a[ai+2];
        if(x == y && y == z) {
            base++;
            continue;
        }
        vector<tuple<int,int,int>> q;
        rep(ri,3){
            {
                rep(b,m){
                    int now = dp[b][n];
                    if(y == z) chmax(now,dp[b][y]+1);
                    q.emplace_back(b,x,now);
                }
            }
            {
                int now = max(dp[n][n],dp[z][z]+1);
                q.emplace_back(x,y,now); 
            }
            swap(x,y);swap(y,z);
        }
        for(auto t:q){
            int i,j,k;
            tie(i,j,k) = t;
            upd(i,j,k);
        }
    }
    int ans = dp[n][n];
    int l = a[3*n-1];
    chmax(ans,dp[l][l]+1);
    cout << ans+base << endl;   
}

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

using namespace std;

#define endl '\n'


int main(){

  ios_base :: sync_with_stdio(false);
  cin.tie(NULL);

  int n;
  cin >> n;
  int a[n];

  for(int i=0;i<n;i++)
    cin >> a[i];

  int ans[n] = {0};

  for(int i=0;i<31;i++){
    int cnt = 0;
    for(int j=0;j<n;j++){
      if(a[j] & (1 << i))
        cnt++;
    }
    if(cnt % 2 == 0){
      for(int j=0;j<n;j++)
        ans[j] += (a[j] & (1 << i));
    }else{
      for(int j=0;j<n;j++){
        if((a[j] & (1 << i)) == 0)
          ans[j] += (1 << i);
      }
        
    }
  }

  for(int i=0;i<n;i++)
    cout << ans[i] << " ";
  cout << endl;
 
  return 0;
}

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

int main(){

  long int max=0,min;
  int n;
  int r;
 
  cin >> n;

  cin >> r;
  min = r;

  cin >> r;
  max = r-min;
  if(min>r){ min = r; }

  for(int i=2; i<n; i++){
    cin >> r;
    if(max<r-min){
      max = r-min;
    }
    if(min>r){
      min = r;
    }
  }

  cout << max << endl;

  return 0;
}

Measured memory_bytes: 1164
#include <stdio.h>

int main(void){
  int K,S;
  scanf("%d%d",&K,&S);

  int cnt = 0;
  for(int i = 0;i <= K;i++){
    for(int j = i;j <= K;j++){
      int k = S-i-j;
      if(0 <= k && k <= K && k >= j){
          if(i != j && j != k && k != i) cnt += 6;
          else if(i == j && j == k && k == i) cnt++;
          else cnt += 3;
      }
    }
  }

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

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

static const int maxai = 1e9;

long long CountDifferent(const vector<int> &a, const vector<int> &b, long long v) {
  long long t = 0;
  int p = static_cast<int>(a.size()) - 1;
  for (int i = 0; i < b.size(); i++) {
    while (p >= 0 && 1LL * a[p] * b[i] > v) p--;
    t += a.size() - p - 1;
  }
  return t;
}

long long CountSame(const vector<int> &a, long long v) {
  long long t = 0;
  int p = static_cast<int>(a.size()) - 1;
  for (int i = 0; i < a.size(); i++) {
    while (p >= 0 && 1LL * a[p] * a[i] >= v) p--;
    if (i > p)
      t += p + 1;
    else
      t += p;
  }
  return t;
}

int main() {
  int n;
  long long k;
  scanf("%d %lld", &n, &k);

  vector<int> positive, negative;
  int num_zero = 0;
  for (int i = 0; i < n; i++) {
    int a;
    scanf("%d", &a);
  
    if (!a)
      num_zero++;
    else if (a > 0)
      positive.push_back(a);
    else
      negative.push_back(a);
  }
  
  sort(positive.begin(), positive.end());
  sort(negative.begin(), negative.end(), greater<int>());
  for (auto i = 0; i < negative.size(); i++)
    negative[i] = -negative[i];

  long long r = 1LL * maxai * maxai, l = -r;
  while (l < r) {
    long long m = (l + r + 1) >> 1;
    
    long long t;
    if (m <= 0)
      t = CountDifferent(positive, negative, -m) + CountDifferent(negative, positive, -m);
    else 
      t = 2LL * positive.size() * negative.size()
        + (2LL * n - num_zero - 1) * num_zero 
        + CountSame(positive, m) + CountSame(negative, m);

    if (t >> 1 <= k - 1)
      l = m;
    else
      r = m - 1;
  }
  printf("%lld\n", l);

  return 0;
}

Measured memory_bytes: 1400
import sys
input = sys.stdin.readline
def ii(): return int(input())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def li(): return list(input().rstrip())
# template


N, Q = mi()
# print(N, Q)
S = li()
Alist = []
for i in range(N - 1):
    if S[i] == 'A' and S[i + 1] == 'C':
        Alist.append(i)
Aset = set(Alist)
AClist = [0]*(N+1)
for i in range(N-1):
    if i in Aset:
        AClist[i + 2] = AClist[i + 1] + 1
    else:
        AClist[i+2] = AClist[i+1]
        # print(AClist)

for i in range(Q):
    l, r = mi()
    if AClist[l - 1] != AClist[l]:
        print(AClist[r] - AClist[l])
    else:
        print(AClist[r] - AClist[l-1])

Measured memory_bytes: 11084
s=input()
s_len = len(s)

if s == s[::-1]:
    s1 = s[0:(s_len-1)//2]
    if s1 == s1[::-1]:
        s2 = s[(s_len+3)//2-1:]
        if s2 == s2[::-1]:
            print("Yes")
        else:
            print("No")
    else:
        print("No")
else:
    print("No")

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

int main() {
  char a;
  cin >> a;
  
  if(97 <= a && a <= 122){
    cout << "a" << endl;
  }
  else if(65 <= a && a <= 90){
    cout << "A" << endl;
  }
  else {
    cout << "error" << endl;
  }

}


Measured memory_bytes: 3632
#![allow(non_snake_case)]

use std::io::{stdin, Read};
use std::str::FromStr;
fn read_option<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok()
}
fn read<T: FromStr>() -> T {
    let opt = read_option();
    opt.expect("failed to parse token")
}

fn main() {
    let X: usize = read();
    let mut sum = 0;
    for i in 1..=X {
        sum += i;
        if sum >= X {
            println!("{}", i);
            return;
        }
    }
}


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

int main() {
  int A, B, C, D, x, y;
  cin >> A >> B >> C >> D;
  
  x = A + B;
  y = C + D;
  
  if (x > y) {
    cout << "Left" << endl;
  }
  if(x == y) {
    cout << "Balanced" << endl;
  }
  if (x < y) {
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
n, k = list(map(int, input().split()))
m = (n - 1) * (n - 2) / 2
if k > m:
  print(-1)
  exit()
e = []
for i in range(1, n):
  e.append((i, n))
for i in range(1, n):
  for j in range(i + 1, n):
    if m == k:
      break
    e.append((i, j))
    m -= 1
print(len(e))
for u, v in e:
  print("%d %d" % (u, v))

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

#define MAX 3000

int main(){
  int N;
  cin >> N;

  double p[N+1];
  for (int i = 1; i <= N; i++) {
    cin >> p[i];
  }

  double dp[N+1][N+1];
  dp[0][0] = 1.0;
  for (int i = 1; i <= N; i++) {
    for (int j = 0; j <= i; j++) {
      if (0 < j) {
        if ( (i-1) < j ) {
          dp[i][j] = dp[i-1][j-1] * p[i];
        } else {
          dp[i][j] = dp[i-1][j-1] * p[i] + dp[i-1][j] * (1 - p[i]);
        }
      } else {
        dp[i][j] = dp[i-1][j] * (1 - p[i]);
      }
    }
  }
  double ans = 0.0;
  for (int i = (N / 2) + 1; i <= N; i++) {
    ans = ans + dp[N][i];
  }
  cout << setprecision(10) << ans << endl;
}


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

int main(void) {
    int A, B;
    cin >> A >> B;
    if (A > 12) {
		cout << B;
	}
	else if (A > 5) {
		cout << B/2;
	}
	else{
        cout << 0;
	}
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)
#define RREP(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define ALL(v) (v).begin(), (v).end()

vector<ll> col;
vector<vector<ll>> net;
vector<ll> num;

// 各頂点と根とする部分技の頂点数
vector<ll> nc;

// 各頂点を根とする部分技において、各色を根とする部分技に含まれる頂点の数
vector<unique_ptr<unordered_map<ll, ll>>> nc_by_col;

void dfs(ll cur, ll par){
    const ll curc = col.at(cur);
    nc.at(cur) = 1;
    ll maxidx = -1;

    for(ll nxt : net.at(cur)){
        if(nxt == par){ continue; }
        dfs(nxt, cur);

        const ll tmp = nc.at(nxt) - (*nc_by_col.at(nxt))[curc];
        num.at(curc) += tmp * (tmp - 1) / 2 + tmp;

        nc.at(cur) += nc.at(nxt);

        if(maxidx == -1 ||
           nc_by_col.at(nxt)->size() > nc_by_col.at(maxidx)->size()){
            maxidx = nxt;
        }
    }

    if(maxidx == -1){  // leaf
        nc_by_col.at(cur).reset(new unordered_map<ll, ll>());
    }else{
        nc_by_col.at(cur) = move(nc_by_col.at(maxidx));
        for(ll nxt : net.at(cur)){
            if(nxt == par || nxt == maxidx){ continue; }
            for(auto it = nc_by_col.at(nxt)->cbegin();
                it != nc_by_col.at(nxt)->cend(); ++it){
                (*nc_by_col.at(cur))[it->first] += it->second;
            }
        }
    }
    (*nc_by_col.at(cur))[curc] = nc.at(cur);

    // cerr << "nc[" << cur << "]=" << nc.at(cur) << endl;
    // for(auto it = nc_by_col.at(cur)->cbegin();
    //     it != nc_by_col.at(cur)->cend(); ++it){
    //     cerr << "  " << it->first << " " << it->second << endl;
    // }
}

int main(){
    ll n;
    cin >> n;

    col.resize(n);
    REP(i, n){
        cin >> col.at(i);
        col.at(i)--;
    }

    net.resize(n);
    REP(i, n - 1){
        ll ai, bi;
        cin >> ai >> bi;
        ai--; bi--;
        net.at(ai).push_back(bi);
        net.at(bi).push_back(ai);
    }

    num.resize(n, 0);
    nc.resize(n);
    nc_by_col.resize(n);
    dfs(0, -1);

    REP(c, col.size()){
        const ll tmp = nc.at(0) - (*nc_by_col.at(0))[c];
        num.at(c) += tmp * (tmp - 1) / 2 + tmp;
    }

    // REP(c, col.size()){
    //     cerr << "num[" << c << "]=" << num.at(c) << endl;
    // }

    REP(i, n){
        cout << n * (n - 1) / 2 + n - num.at(i) << endl;
    }
    return 0;
}


Measured memory_bytes: 67644
x = int(input())
li = list(map(int,input().split()))#listp
li_o = list(range(1,x))

a = 0
for i in range(x-1):
	
	b = 0
	#print (li[i])
    
	if int(li[i]) == int(li_o[i]):
		b=b+1
	else:
		a=a+1
	#print(a)
	#print('endofloop')
    
#print(a)

if a <= 2 :
	print('YES')
else:
	print('NO')

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int main(){
    int N;
    cin >> N;
    int A[N];
    double ans=0,tmp=0;
    for(int i=0;i<N;i++){
        cin >> A[i];
        tmp += (double) 1/A[i];
    }
    cout << 1/tmp << endl;
}

Measured memory_bytes: 256
import sys
n,m = map(int,input().split())
n_li=[list(map(int,input().split())) for i in range(m)]
 
ans_num = ["x"]*n
ans = "Y"
 
for i in n_li:
    if n >= 2:
        if i[0] == 1 and i[1] == 0:
            ans = "N"
if ans == "Y":
    for i in n_li:
        if ans_num[i[0]-1] == "x" or ans_num[i[0]-1] == i[1]:
            ans_num[i[0]-1] = i[1]
        elif ans_num[i[0]-1] != i[1]:
            ans = "N"
if n ==1:
    if m == 0:
        print(0)
        sys.exit()
if n == 1 and m == 1:
    if n_li == [[1,0]]:
        print(0)
        sys.exit()
if ans == "Y":
    for j in range(len(ans_num)):
        if ans_num[j] == "x":
            if j == 0:
                ans_num[j] = 1
            else:
                ans_num[j] = 0
    print(*ans_num,sep="")
else:
    print(-1)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <list>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <bitset>
#include <functional>

using namespace std;

#define FOR(i,n) 		for(int(i)=0;(i)<(int)(n);(i)++)
#define FORN(i,a,b,c) 	for(int(i)=a;i<(int)(b);i+=(c))
#define RES(x,nilai)	memset(x,nilai,sizeof(x));
#define pb              push_back
#define mp              make_pair
#define INF				1000000000

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

inline string IS(int a){
    char x[100];
    sprintf(x,"%d",a); string s = x;
    return s;
}

inline int SI(string a){
    char x[100]; int res;
    strcpy(x,a.c_str()); sscanf(x,"%d",&res);
    return res;
}

//==============================================

bool cmp(int x,int y) {return x>y;}

int n, prima[10101];

void PRIME() {
	prima[0] = prima[1] = -1;
	for(int i = 2; i < 10100;i++) {
		if (prima[i] == 0) {
			int j = i+i;
			while (j< 10010) {
				prima[j] = -1;
				j+=i;
			}
		}
	}
}

int main() {
	//freopen("in.txt","r",stdin);
	//freopen("13.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	
	PRIME();
	while(cin >> n) {
		int ans = 0;
		for(int i = 1 ;i <= n;i++ ) {
			int j = n-i+1;
			if (prima[i] == 0 && prima[j] == 0) ans++;
		} cout << ans << endl;
	}
	
    return 0;
}

Measured memory_bytes: 3144
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Contest.cs
{
	class Program
	{
		static void Main(string[] args)
		{
			ReadInt();
			var input = ReadInt();
			int ans = 0;
			for(int i = 0;i < input.Length; i++)
			{
				for(int j = i+1;j < input.Length; j++)
				{
					int sa = Math.Abs(input[i] - input[j]);
					if(sa > ans)
					{
						ans = sa;
					}
				}
			}
			Console.WriteLine(ans);
		}

		static string[] ReadStr()
		{
			return Console.ReadLine().Split(' ').ToArray();

		}

		static int[] ReadInt()
		{
			return Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
		}
	}
}

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

const int N = 1e3 + 10;
const int M = 199999;
#define mk make_pair
#define P pair<int,int>
#define ll  long long
int dp[N][N];
int main() {
    string s1, s2;
    cin >> s1 >> s2;
    int n = s1.size();
    int m = s2.size();
    s1 = " " + s1;
    int ans = 0;
    for (int i = 1; i+m-1 <= n; i++)
    {
        int temp = 0;
        for(int j=0;j<m;j++)
        {
            if(s1[i+j] == s2[j])
            {
                temp++;
            }
        }
        ans = max(ans,temp);
    }
    cout << m - ans << "\n";
    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <climits>
using namespace std;

template<typename Monoid>
struct SegmentTree {
    using OP = function<Monoid(Monoid, Monoid)>;
    
    vector<Monoid> tree;
    int size;
    const OP f; // bin' operation
    const Monoid e; // neutral element
                                           
    SegmentTree(int nmemb, const Monoid &e, const OP &f):
        f(f),
        e(e)
    {
        size = 1;
        while (size < nmemb) {
            size *= 2;
        }

        tree.assign(2 * size - 1, e);
    }

    void update(int k, Monoid dat)
    {
        k += size - 1;
        tree[k] = dat;
        
        while(k > 0) {
            k = (k - 1) / 2;
            tree[k] = f(tree[2 * k + 1], tree[2 * k + 2]);
        }
    }

    // [l, r)
    Monoid query(int l, int r)
    {
        l += size - 1;
        r += size - 1;

        Monoid d = e;
        while (l < r) {
            if (l % 2 == 0) {
                d = f(d, tree[l]);
                l++;
            }
            if (r % 2 == 0) {
                r--;
                d = f(d, tree[r]);
            }

            l = (l - 1) / 2;
            r = (r - 1) / 2;
        }

        return d;
    }
};

int n, arr[200005];

int main()
{
    cin >> n;

    SegmentTree<int> seg(n, 0, [](int a, int b){return max(a, b);});

    for (int i = 0; i < n; i++) {
        cin >> arr[i];
        seg.update(i, arr[i]);
    }

    for (int i = 0; i < n; i++) {
        seg.update(i, 0);
        cout << seg.query(0, n) << endl;
        seg.update(i, arr[i]);
    }

    return 0;
}


Measured memory_bytes: 4480
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define eb emplace_back
using namespace std;
const int mod = 1e9 + 7;
const int maxn = 2e5 + 233;
int a[maxn];
int main()
{
	int n;cin>>n;
	int cur = 1;
	for(int i=1;i<=n;i++){
		int x;scanf("%d",&x);
		if(x==cur)cur++;
	}
	cur--;
	int ans = n-cur;
	if(ans==n)puts("-1");
	else cout << ans << endl;
}


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

int main() {
    int N;
    cin >> N;
    vector<int> p(N);
    for(int i=0;i<N;i++){
        cin >> p.at(i);
    }
    sort(p.begin(),p.end());
    int sum=0;
    for(int i=0;i<N;i++){
        sum+=p.at(i);
    }
    cout << sum-p.at(N-1)/2 << endl;
}

Measured memory_bytes: 256
import numpy

N = int( input() )
A = list( map( int ,input().split()) )
cnt = sum( lop < 0 for lop in A)

nA = numpy.array(A)
nA = numpy.abs(nA)

lA = nA.tolist()
if min(lA) == 0 or cnt % 2 == 0:
    print(sum(lA))
else :
    print(sum(lA)-min(lA)*2)



Measured memory_bytes: 23316
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <set>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

using namespace std;

int main() {
    
    int n;
    string s;
    cin >> n >> s;
    
    int e=0;
    FOR(i, 0, n){ //Eの数
        if(s[i]=='E'){
            e++;
        }
    }
    int re=e,le=0;
    int rw=n-e,lw=0;
    vector<int> ans(n,0);
    
    if(s[0]=='E'){
        re=e-1;
        ans[0]=e-1;
    }else{
        rw=n-e-1;
        ans[0]=e;
    }
    
    
    
    FOR(i, 1, n){
        if(s[i]=='E'){
            re--;
            if(s[i-1]=='E'){
                le++;
            }else{
                lw++;
            }
        }else{
            rw--;
            if(s[i-1]=='E'){
                le++;
            }else{
                lw++;
            }
        }
        
        ans[i] = re+lw;
    }
    
    int min = *min_element(ans.begin(),ans.end());
    cout << min << endl;
    
    return 0;
}


Measured memory_bytes: 1796
#include <bits/stdc++.h>
using namespace std;
 
string S; int N, cnt;
 
int main() {
	string S,T;
    cin >> S >> T;
    int ans=0;
    for(int i=0;i<3;i++){
        if(S[i]==T[i])ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3612
import collections

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
  
U = 2*10**6
MOD = 10**9+7
 
fact = [1]*(U+1)
fact_inv = [1]*(U+1)
 
for i in range(1,U+1):
  fact[i] = (fact[i-1]*i)%MOD
fact_inv[U] = pow(fact[U],MOD-2,MOD)
 
for i in range(U,0,-1):
  fact_inv[i-1] = (fact_inv[i]*i)%MOD
 
def comb(n,k):
  if k < 0 or k > n:
    return 0
  z = fact[n]
  z *= fact_inv[k]
  z %= MOD
  z *= fact_inv[n-k]
  z %= MOD
  return z

n, m = map(int, input().split())
c = collections.Counter(prime_factorize(m))
ans = 1
for i in c.values():
  ans *= comb(i+n-1, n-1)
  ans %= MOD
print(ans)

Measured memory_bytes: 161652
#include <iostream>
#include <cmath>
#include <vector>
using namespace std;
typedef long long ll;

int main()
{
	ll n; cin>>n; vector<int> x;
	while(n != 0){
		x.push_back(abs(n%2));

		n =( n - abs(n%2) )/(-2);
	}

	for(int i=x.size()-1;i>=0;i--) cout<<x[i];

	if(x.size() == 0) cout<<"0";	
}

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

int main() {
  int N;
  cin >> N;
  int count = 1;
  vector<int> a(N);
  for(int i = 0; i < N; i++){
      cin >> a.at(i);
  }
  sort(a.begin(),a.end());
  for(int i = 0; i < N; i++){
      
  
      if(i==N-1){
       continue;
      }
     else if(a.at(i) != a.at(i+1)){
         count++;
     }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int solve(int,int);
int n,data[20];
int main(){
  int q,m;
  int i;
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&data[i]);
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&m);
    if(solve(0,m))printf("yes\n");
    else printf("no\n");
  }
  return 0;
}

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




Measured memory_bytes: 2108
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,a,b) for(int i =(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPm(i,n) for(int i=(n)-1;i>=0;i--)
#define REP1(i,n) for(int i=1;i<=(n);i++)
typedef long long ll;

int main(){
    int N;
    cin >> N;
    int ans = 0;
    REP(i,N){
        int l,r;
        cin >> l >> r;
        ans += r-l+1;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N,K;
  double ans=0,tmp;
  vector<double> p(N+1,0);
  cin >> N >> K;
  for(int i=0;i<N;i++){
    cin >> tmp;
    tmp=(tmp+1)/2;
    p.at(i+1)=tmp+p.at(i);
  }
  for(int i=K;i<N+1;i++){
    tmp=p.at(i)-p.at(i-K);
    ans=max(ans,tmp);
  }
  cout << fixed << setprecision(10) << ans << endl;
}

Measured memory_bytes: 49664
#include<iostream>
using namespace std;
long long int a,b;
int gcd(int a,int b)
{
	if(b==0) return a;
	return gcd(b,a%b);
}

int main()
{
	
	while(cin>>a>>b)
	{
		int x = gcd(a,b);
		cout<<x<<" "<<a/x*b<<endl; 
	}
}


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

using namespace std;

inline int ctoi(char c) { if(c < '0' || '9' < c) throw invalid_argument("ctoi error"); return c - '0'; }
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for(int i = (int)(k); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

template <typename T>
inline T gcd(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("gcd error: x <= 0 or y <= 0");
	
	if(x < y) swap(x, y);
	T r = x % y;

	while(r != 0){
		x = y;
		y = r;
		r = x % y;
	}

	return y;
}
template <typename T>
inline T lcm(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("lcm error: x <= 0 or y <= 0");

	return x * y / gcd(x, y);
}

int main(){
	vector<string> ans;

	while(1){
		string str1;
		cin >> str1;
		if(str1 == ".") break;

		string str2;
		cin >> str2;

		vector<vector<char>> vec1;
		vector<vector<char>> vec2;

		vector<char> v;
		int d = 0;
		rep(i, str1.size()){
			if(str1[i] == '"'){
				d++;

				if(d % 2 == 1){
					if(v.size() != 0){
						vec1.push_back(v);
						v.clear();
					}

					v.push_back('"');
				}
				else{
					v.push_back('"');
					vec1.push_back(v);
					v.clear();
				}
			}
			else{
				v.push_back(str1[i]);
			}
		}

		if (v.size() != 0){
			vec1.push_back(v);
			v.clear();
		}

		d = 0;

		rep(i, str2.size()){
			if (str2[i] == '"'){
				d++;

				if (d % 2 == 1){
					if (v.size() != 0){
						vec2.push_back(v);
						v.clear();
					}

					v.push_back('"');
				}
				else{
					v.push_back('"');
					vec2.push_back(v);
					v.clear();
				}
			}
			else{
				v.push_back(str2[i]);
			}
		}

		if (v.size() != 0){
			vec2.push_back(v);
			v.clear();
		}

		d = 0;
		
		/*
		cout << "input1:" << endl;
		rep(i, vec1.size())
		{
			rep(j, vec1[i].size())
			{
				cout << vec1[i][j];
			}

			cout << endl;
		}
		cout << endl;

		cout << "input2:" << endl;
		rep(i, vec2.size())
		{
			rep(j, vec2[i].size())
			{
				cout << vec2[i][j];
			}

			cout << endl;
		}
		cout << endl;
		*/

		if (vec1.size() != vec2.size()){
			ans.push_back("DIFFERENT");
		}
		else{
			int diff = 0;
			int dq = 0;

			rep(i, vec1.size()){
				if (vec1[i] != vec2[i]){
					if(vec1[i][0] == '"'){
						diff++;
					}
					else{
						diff += 2;
					}
				}
			}

			// cout << diff << endl;

			if(diff == 0) ans.push_back("IDENTICAL");
			else if(diff == 1) ans.push_back("CLOSE");
			else ans.push_back("DIFFERENT");
		}
	}

	rep(i, ans.size()){
		// cout << i << " : " << ans[i];
		cout << ans[i] << endl;
	}

	return 0;
}


Measured memory_bytes: 3184
#include<iostream>
#include<bits/stdc++.h>
#include<climits>
#include<math.h>

#define forn(e,n,s) for(int i = e; i < n;i += s)
#define forr(e,n,s) for(int i = e; i >= n; i -= s)
#define PI 3.14159265358979323846264338327950L

using namespace std;

int MOD = 1e9+7;

void go(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout<<fixed;
  cout<<setprecision(20);

  #ifndef ONLINE_JUDGE
       freopen("input.txt","r",stdin);
       freopen("output.txt","w",stdout);
  #endif
}

int main(){
    go(); 

    // code here
    int n,m;cin>>n>>m;
    vector<vector<char>> grid(n,vector<char>(m));
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m ; j++){
            cin>>grid[i][j];
        }
    }
    vector<vector<int>> dp(n,vector<int>(m,0));
    dp[n-1][m-1] = 1;
    for(int i = n - 1; i >=0 ; i--){
        for(int j = m - 1; j >= 0; j--){
            if(i==(n-1) and j == (m-1)) continue;
            if((i+1)< n and grid[i+1][j]=='.') dp[i][j] += dp[i+1][j]; 
            dp[i][j] %= MOD;
            if((j+1)< m and grid[i][j+1]=='.') dp[i][j] += dp[i][j+1];
            dp[i][j] %= MOD;
        }
    }
    cout<<dp[0][0]<<endl;
   
}





Measured memory_bytes: 8196
#include "bits/stdc++.h"
using namespace std;

/* macro */
#define rep(i,a,b) for(int i=a;i<b;i++)
#define revrep(i,a,b) for(int i = a; i > b; i--)
#define int long long
#define exist(s,e) ((s).find(e)!=(s).end())
#define all(v) (v).begin(), (v).end()
#define each(s,itr) for(auto (itr) = s.begin(); (itr) != s.end(); (itr)++)
#define sum(v) accumulate(all(v), (0LL))
#define isin(a, b, c) (b <= a && a <= c)
#define println cout << "\n";
#define sz(v) (int)v.size()
#define bin(x) static_cast<bitset<16> >(x)



/* alias */
template<class T> using vec = vector<T>;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef tuple<int, int, int> ti;
typedef map<int, int> mi;
typedef set<int> si;


/* constant */
const int inf = 1LL << 62;
const int mod = 1e9 + 7;
const int dx[8]={1,0,-1,0,-1,1,-1,1};
const int dy[8]={0,1,0,-1,-1,-1,1,1};
const string alphabet = "abcdefghijklmnopqrstuvwxyz";

/* io_method */
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
template<class T> void printx(T n){cout << n;}
template<class T, class U> void printx(pair<T, U> p){cout << "(" << p.first << "," << p.second << ")";}
template<class T, class U, class V> void printx(tuple<T, U, V> t){cout << "{" << get<0>(t) << "," << get<1>(t) <<"," << get<2>(t) << "}" << endl;}
template<class T> void printx(vector<T> v){cout << "{";rep(i,0,v.size()){printx(v[i]);if(i != v.size()-1)printx(",");}cout << "}";}
template<class T> void print(T n){printx(n);cout << endl;}
template<class T> void print(set<T> s){cout << "{";each(s, e){if(e != s.begin()) printx(",");printx(*e);}cout << "}" << endl;}
template<class T, class U> void print(map<T, U> mp){cout << "{";each(mp, e){cout << "(" << e -> first << "," << e -> second << ")";}cout << "}" << endl;}
template<class T> void printans(vec<T> v){rep(i,0,sz(v)){cout << v[i] << (i == sz(v) - 1 ? "" : " ");}cout << endl;}


/* general_method */
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 (b<a) { a=b; return 1; } return 0; }
template<class T>T cut(T &a, int l, int r){return T(a.begin()+l, a.begin()+r);}

/* main */

int n;
void in(){
    cin >> n;
}

vi seat(100010);
int query(int i){
    print(i);
    string res = raw_input();
    int ans;
    if(res == "Vacant") ans = -1;
    if(res == "Male") ans = 0;
    if(res == "Female") ans = 1;
    seat[i] = ans;
    if(ans == -1) exit(0);
    return ans;
}

int l = 0; int r;

bool check(int mid){
    int res = query(mid);

    int lenleft = mid - l + 1;
    int lenright = r - mid;

    if(lenleft % 2 == 1){
        if(seat[l] == seat[mid]) return true;
        else return false;
    }else{
        if(seat[l] == seat[mid]) return false;
        else return true;
    }

}

void solve(){
    query(0);
    query(n - 1);

    r = n - 1;

    rep(i,0,18){
        int mid = (l + r) / 2;
        if(check(mid)){
            l = mid;
        }else{
            r = mid;
        }
    }



}

signed main(){

    cin.tie(0);
    ios::sync_with_stdio(false);
    in();
    solve();
    
}

Measured memory_bytes: 1620
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string F;
  int U=0;
  cin>>F;
  if(F=="10"||F=="100000"||F=="100"||F=="1000"||F=="10000"){
    cout<<10<<endl;
  }
  else{
    for(int X=0;X<F.size();X++){
      U+=(int)F[X]-'0';
    }
    cout<<U<<endl;
  }
}

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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
ll INF = LLONG_MAX;
 
using vc = vector<char>;
using vi = vector<int>;

int K;
vi arr;

ll rem (ll start) {
    for (int item : arr) {
        start = start / item * 1LL* item;
    }
    return start;
}

ll find(int end) {
    ll lo = 0;
    ll hi = 1e15;
    while (lo < hi) { 
        ll mid = lo + (hi - lo + 1) / 2;
        if (rem(mid) <= end)
            lo = mid;
        else
            hi = mid - 1;
    }
    return lo;
}
int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> K;
    arr.resize(K);
    F0R(i, K) cin >> arr[i];
    ll l = find(1) + 1;
    ll h = find(2);
    if (rem(h) == 2) {
        cout << l << " " << h << endl;
    } else {
        cout << -1 << endl;
    }
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int mod=1e9+7;
int ksm(int b,int n){
	int res=1;
	while(n){
		if(n&1) res=res*b%mod;
		b=b*b%mod; n>>=1;
	}
	return res;
} 
int a[100005];
signed main(){
	int n;
	cin>>n;
	for(int i=1;i<=n;++i)
		cin>>a[i];
	int ans=0,sum=0;
	for(int i=1;i<n;++i){
		sum=sum+ksm(i,mod-2);sum%=mod;
		ans+=sum*(a[i+1]-a[i])%mod; ans%=mod;
	}
	for(int i=2;i<n;++i)
		ans=ans*i%mod;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 4364
X,K,D = (int(x) for x in input().split())
if X > 0:
    num = int(X/D)
    ans = 0
    if num >= K:
        ans = X - D*K
    else:
        a = X - num*D
        b = X - (num+1)*D
        if (K-num)%2 == 0:
            ans = a
        else:
            ans = b
else:
    num = int(-X/D)
    ans = 0
    if num >= K:
        ans = X + D*K
    else:
        a = X + num*D
        b = X + (num+1)*D
        if (K-num)%2 == 0:
            ans = a
        else:
            ans = b
print(abs(ans))

Measured memory_bytes: 9212
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int lim = 1e5+100;
const ll mod = 1e9 + 7;

ll dp[lim];
int a[lim];

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

    for(int i=0; i<m; i++){
        int tmp;
        cin >> tmp;
        a[tmp] = 1;
    }

    dp[0] = 1;

    for(int i=0; i<n; i++){
        if(a[i+1] != 1){
            dp[i+1] += dp[i];
            dp[i+1] %= mod;
        }
        if(a[i+2] != 1){
            dp[i+2] += dp[i];
            dp[i+2] %= mod;
        }
    }
    cout << dp[n] << endl;
}

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

long long int A, B, C, K, N;

int main(){
    scanf("%lld%lld%lld%lld", &A, &B, &C, &K);
    N = A - B;
    if(abs(N) > 1000000000000000000LL)return 0 & puts("Unfair");
    printf("%lld", ((K & 1) ? -1 : 1) * N);
    return 0;
}

Measured memory_bytes: 768
N = int(input())
P = list(map(int, input().split()))
minP = []
ans = 0
for idx, p in enumerate(P):
    if idx == 0:
        minP.append(p)
    else:
        minP.append(min(minP[idx-1], p))

for idx in range(N):
    if P[idx] <= minP[idx]:
        ans += 1

print(ans)

Measured memory_bytes: 85584
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod2 = 1000000007;
constexpr ll mod = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[6] = {1, 0, -1, 0,1,-1};
const int dy[6] = {0, 1, 0, -1,1,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ---------------------------------------------------------------------------

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    vector<int> A(N*2);
    for(int i=0; i<N*2; i++){
        A[i] = i+1;
    }
    int M;
    cin >> M;
    for(int i=0; i<M; i++){
        int id;
        cin >> id;
        if(id == 0){
            vector<int> temp;
            for(int j=0; j<N; j++){
                temp.push_back(A[j]);
                temp.push_back(A[j+N]);
            }
            A = temp;
        }else{
            vector<int> temp;
            for(int j=id; j<2*N; j++){
                temp.push_back(A[j]);
            }
            for(int j=0; j<id; j++){
                temp.push_back(A[j]);
            }
            A = temp;
        }
        // for(int j=0; j<2*N; j++){
        //     cout << A[j] << " ";
        // }
        // cout << enld;
    }
    for(int i=0; i<2*N; i++){
        cout << A[i] << enld;
    }
    return 0;
}


Measured memory_bytes: 3216