akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
#define fore(i,a,b) for(ll i=(a);i<=(b);++i)
#define rep(i,n) fore(i,0,(n)-1)
#define rfore(i,a,b) for(ll i=(b);i>=(a);--i)
#define rrep(i,n) rfore(i,0,(n)-1)
#define all(x) (x).begin(),(x).end()
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
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>
ll sum(const T& a){return accumulate(all(a),0LL);}

void solve(){
    vl a(3);rep(i,3)cin>>a[i];
    sort(all(a));
    rep(i,3){
        if(i>0)cout<<" ";
        cout<<a[i];
    }
    cout<<endl;
}

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



Measured memory_bytes: 3208
#include <iostream>

std::string A = "abcdefghijklmnopqrstuvwxyz";

int main(){
  std::string S;
  std::cin >>S;

  if((int)S.size() < 26){
    for(auto itr = S.begin();itr!=S.end();++itr){
      A.erase(A.begin() + A.find(*itr));
    }
    std::cout << S + A[0] << std::endl;
  }else if(S == "zyxwvutsrqponmlkjihgfedcba"){
    std::cout << -1 << std::endl;
  }else{
    std::string pool;
    for(auto itr = S.end() - 1; itr!=S.begin(); itr--){
      if( *(itr-1) < *itr){
        pool = *(itr-1);
        S.erase(itr-1,S.end());
        break;
      }
    }
    for(auto itr = S.begin();itr!=S.end();++itr){
      A.erase(A.begin() + A.find(*itr));
    }
    std::cout << S + A[A.find(pool) + 1] << std::endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define FASTIO std::ios::sync_with_stdio(false);
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define inf 1e18
#define g(x) cout<<x<<" "<<endl;
#define gg(x,y) cout<<x<<" & "<<y<<" "<<endl
#define ggg(x,y,z) cout<<x<<" & "<<y<<" & "<<z<<" "<<endl
#define all(x) x.begin(),x.end()
#define input_from_file  freopen("input.txt", "r", stdin);
#define mod 1000000007
#define sz 100005
using namespace std;

ll n,k;
ll dp[101][sz];
ll a[sz];
ll tim = 0;

int main()
{

    FASTIO
    cin.tie(NULL);

    cin >> n >> k;
    for(ll i=1;i<=n;i++)cin >> a[i];
    for(ll i=a[n];i>=0;i--)dp[n][i] =1;
    for(ll i=1;i<=k;i++)dp[n][i]+=dp[n][i-1];

    for(ll j=n-1;j>=0;j--)
    {
      for(ll i=k;i>=0;i--)
      {
        if(i-a[j]>0){
        dp[j][i] = dp[j+1][i] - dp[j+1][(i-a[j])-1] + mod;
        dp[j][i]%=mod;
      }
      else
      dp[j][i] = dp[j+1][i];
      //  if(j == 2&&i == 2)g(dp[j][i]);
      }
      for(ll i=1;i<=sz;i++)dp[j][i] = (dp[j][i] + dp[j][i-1])%mod;


    }


    ll ans = dp[1][k] - dp[1][k-1] + mod;ans%=mod;



cout << ans << endl;


return 0;
}


Measured memory_bytes: 79232
#include <stdio.h>
#include <vector>
#include <queue>
using namespace std;
int main() {
    int V, k, source, target, current, next;
    bool oneVisited;
    scanf("%d", &V);
    vector<int> G[V+1];
    bool visited[V+1];
    int disc[V+1];
    fill(visited, visited+V+1, 0);
    fill(disc, disc+V+1, -1);
    for (int i = 0; i < V; i++) {
        scanf("%d %d", &source, &k);
        for (int j = 0; j < k; j++) {
            scanf("%d", &target);
            G[source].push_back(target);
        }
    }
    queue<int> q;
    q.push(1);
    int d = 0; disc[1] = 0;
    visited[1] = true;
    while (!q.empty()) {
        current = q.front(); q.pop();
        for (int i = 0; i < G[current].size(); i++) {
            next = G[current][i];
            if (!visited[next]) {
                visited[next] = true;
                disc[next] = disc[current]+1;
                q.push(next);
            }
        }
    }
    for (int i = 1; i <= V; i++) printf("%d %d\n", i, disc[i]);
    return 0;
}



Measured memory_bytes: 2756
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;
ll MOD = 1e9+7;
//LLONG_MIN

//WA

int main(void){
	string s[3];
	int x[3]={},cur=0;
	rep(j,3)cin>>s[j];
	while(1){
		if(x[cur]==s[cur].size())break;
		x[cur]++;
		cur=s[cur][x[cur]-1]-'a';
	}
	cout<<char(cur+'A')<<endl;
	return 0;
}

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

using namespace std;

using i64 = int64_t;


signed main(){
    int e, y;
    cin >> e >> y;
    vector<int> v{1868, 1912, 1926, 1989, 2017};
    string s = "MTSH";
    if(e == 0){
        int r = 0;
        while(v[r] <= y)
            ++r;
        --r;
        cout << s[r];
        cout << y - v[r] + 1 << endl;
    }
    else{
        cout << v[e - 1] + y - 1 << endl;
    }
}



Measured memory_bytes: 3232
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const ll INF = 1LL << 60;

int main(){
    int n;
    cin >> n;
    int high=0;
    for(int i=0; i<n; i++){
        int h;
        cin >> h;
        if(high - 2 >= h){
            cout << "No" << endl;
            return 0;
        }
        high = max(high,h);
    }
    cout << "Yes" << endl;
    return 0;


}

Measured memory_bytes: 3640
N, K = (int(i) for i in input().split(' '))
N = str(N)
listN = [str(n+1) for n in range(int(N))]
for i in range(K):
    d = int(input())
    A = input().split(' ')
    for j in A:
        if j in listN:
            listN.remove(j)
print(len(listN))

Measured memory_bytes: 9192
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
  int n;
  cin>>n;
  double p[n];
  for(int i=0;i<n;i++)
  {
    cin>>p[i];
  }
  double dp[n+1][n+1];
  dp[0][0]=1;
  for(int i=1;i<n+1;i++)
  {
    dp[0][i]=0;
    dp[i][0]=dp[i-1][0]*(1-p[i-1]);
  }
  for(int i=1;i<=n;i++)
  {
    for(int j=0;j<=n;j++)
    {
      dp[i][j]=(p[i-1]*dp[i-1][j-1])+((1-p[i-1])*dp[i-1][j]);
    //  cout<<dp[i][j]<<" ";
    }
  //  cout<<endl;
  }
  double total=0;
  for(int i=(n+1)/2;i<=n;i++)
  {
    total+=dp[n][i];
  }
  cout<<setprecision(10)<<total<<endl;
}


Measured memory_bytes: 70528
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 998244353LL;

int main() {
    cin.sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int n, s;
    cin >> n >> s;

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

    vector < vector<ll> > dp(n + 1, vector<ll>(3005));

    ll ans = 0;
    for (int i = 0; i < n; i++) {
        for (int j = s; j; j--) {
            dp[i + 1][j] += dp[i][j];
            dp[i + 1][j] %= MOD;

            if (j + a[i] <= s) {
                dp[i + 1][j + a[i]] += dp[i][j];
                dp[i + 1][j + a[i]] %= MOD;
            }
        }

        dp[i + 1][a[i]] += i + 1;
        dp[i + 1][a[i]] %= MOD;

        ans += dp[i + 1][s];
        ans %= MOD;
    }

    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 70784
#include <iostream>
using namespace std;
 int main()
   {
     int N,s=0;
     cin>>N;
     int a[N];
     for(int i=1;i<=N;i++)
        {
          cin>>a[i];
          if(a[i]%2!=0&&i%2!=0)
            {
              s++;
            }
        }
    cout<<s<<endl ;
  
   }


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

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

long long di(long long x,long long y){
	return (x-x%y)/y;
}

int main (){
	long long a,b,c,d,l,ans;
	cin >> a >> b >> c >> d;
	l=c*d/gcd(c,d);
	ans=(di(b,c)+di(b,d)-di(b,l))-(di(a-1,c)+di(a-1,d)-di(a-1,l));
	ans=(b-a+1)-ans;
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cassert>
#include <algorithm>
#include <vector>

using namespace std;

int main()
{
    int n, x;
    cin >> n >> x;
    vector<int> m;
    int sum = 0;
    int a;
    for (int i = 0; i < n; i++)
    {
        cin >> a;
        m.push_back(a);
        sum += a;
    }
    int cnt = 0;
    x -= sum;
    cnt += n;

    int min = *min_element(m.begin(), m.end());
    // cout << min << endl;
    while (x >= min)
    {
        x -= min;
        cnt++;
    }
    cout << cnt << endl;
    return 0;
}


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

int gcd(int a, int b){ //a>=0,b>=0,￢(a=b=0)
  while(min(a,b)>0) {if(a<b) swap(a,b); a = a%b;} return max(a,b);
}

int main(){
 int n,m;
  cin >> n >> m;
  if(m-n<1){
    cout << 0 << endl;
    return 0;
  }
  int ans=0;
  vector<int> x(m),dif(m-1);
  rep(i,m) cin >> x[i];
  sort(x.begin(),x.end());
  rep(i,m-1) dif[i]=x[i+1]-x[i];
  sort(dif.begin(),dif.end());
  rep(i,m-n) ans += dif[i];


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

Measured memory_bytes: 1024
import scala.io.StdIn

object Main extends App {
  val inputs = StdIn.readLine().split(" ")
  val stack = inputs.foldLeft(new Stack()){ (acc, elem) => acc.push(elem) }
  println(stack.pop)
}

class Stack(val elems: List[String]){
  def this() = this(Nil)

  def push: (String) => Stack = {
    case "+" =>
      val (x1, x2, xs) = pop2
      new Stack((x1 + x2).toString :: xs)
    case "-" =>
      val (x1, x2, xs) = pop2
      new Stack((x2 - x1).toString :: xs)
    case "*" =>
      val (x1, x2, xs) = pop2
      new Stack((x1 * x2).toString :: xs)
    case elem =>
      new Stack(elem :: elems)
  }

  def pop: String = elems.head

  def pop2: (Int, Int, List[String]) = {
    elems match {
      case x1 :: x2 :: xs =>
        (x1.toInt, x2.toInt, xs)
      case _ => (0, 0, elems)
    }
  }
}

Measured memory_bytes: 43768
#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")

#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <functional>
#include <iomanip>
#include <numeric>
#include <cassert>
#include <bitset>

using namespace std;
using ll = long long;

const int N = 1e4 + 5;

vector<int> g[N];
int deg[N];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    for (int i = 1; i < n; i++) {
        int a, b;
        cin >> a >> b;
        deg[a]++;
        deg[b]++;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    vector<int> c(n);
    int ans = 0;
    for (int i = 0; i < n; i++) {
        cin >> c[i];
        ans += c[i];
    }
    sort(c.begin(), c.end());
    ans -= c[n - 1];

    vector<int> leaves;
    for (int i = 1; i <= n; i++) {
        if (deg[i] == 1) {
            leaves.push_back(i);
        }
    }

    int cur = 0;
    vector<int> col(n + 1);
    for (int i = 0; i < leaves.size(); i++) {
        col[leaves[i]] = c[cur++];
        for (int j : g[leaves[i]]) {
            if (--deg[j] == 1) {
                leaves.push_back(j);
            }
        }
    }

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

Measured memory_bytes: 1152
extern crate core;

use std::io::{self, Read};

#[macro_export]
macro_rules! input {
  ($s:expr=>$($t:tt)*) => {
    let mut lines=$s.split("\n");
    $(
        line_parse!(lines,$t);
    )*
  };
}

macro_rules! line_parse {
  ($lines:expr,($($name:ident:$t:tt)*)) => {
    let mut line=$lines.next().unwrap().split_whitespace();
    $(value_def!(line,$name,$t);)*
  };

  //複数行
  ($lines:expr,{$n:expr;$name:ident:$t:tt}) => {
    values_def!($lines,$n,$name,$t);
  };
}

macro_rules! value_def {
    ($line:expr, $name:ident, $t:tt) => {
        let $name = value!($line, $t);
    };
}

macro_rules! values_def {
    ($lines:expr, $n:expr, $name:ident, $t:tt) => {
        let $name = {
            let mut vec = Vec::new();
            for i in 0..$n {
                let mut next = $lines.next().unwrap().split_whitespace();
                vec.push(value!(next, $t));
            }
            vec
        };
    };
}

macro_rules! value {
  //配列
  ($line:expr,[$t:tt]) => {
    $line.map(|x|{
      let mut iter=::std::iter::once(x);
      value!(iter,$t)
    }).collect::<Vec<_>>()
  };
  //タプル
  ($line:expr,($($t:tt),*)) => {
    ($(value!($line,$t),)*)
  };
  //文字列
  ($line:expr,#) => {
    $line.next().unwrap()
  };
  //インデックス(-1)
  ($line:expr,@) => {
    $line.next().unwrap().parse::<usize>().unwrap()-1
  };
  //単一値
  ($line:expr,$t:ty) => {
    $line.next().unwrap().parse::<$t>().unwrap()
  };
}

fn main() {
    let mut input = String::new();
    io::stdin().read_to_string(&mut input).unwrap();
    let output = solve(input.trim().to_string());
    println!("{}", output);
}

fn solve(input: String) -> String {
    input!(input=>(n:i64 k:i64));
    if k % 2 != 0 {
        let x = n / k;
        x * x * x
    } else {
        let c = n / k;
        let d = n / k + if n % k >= k / 2 { 1 } else { 0 };
        c * c * c + d * d * d
    }.to_string()
}

macro_rules! tests {
    ($($name:ident: $input:expr=>$output:expr,)*) => {
        mod tests {
            $(
                #[test]
                fn $name() {
                    assert_eq!($output.trim().to_string(),super::solve($input.trim().to_string()));
                }
            )*
        }
    }
}

tests! {
    test1: "3 2" => "9",
    test2: "5 3" => "1",
    test3: "31415 9265" => "27",
    test4: "35897 932" => "114191",
}


Measured memory_bytes: 4352
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
int main(){
	int n,a[110],ans=0;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		if(i%2==1&&a[i]%2==1){
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
} 

Measured memory_bytes: 3632
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

using namespace std;

typedef pair<long long int, long long int> P;
long long int INF = 1e18;
long long int MOD = 998244353;

long long int conv[400000] = {};
long long int pown[400000] = {};

long long int pow_m1(long long int num){
	long long int pow_num = MOD - 2;
	long long int mod_num = MOD;
	long long int pow_cur = num;
	long long int ret = 1;
	while(pow_num > 0){
		if(pow_num % 2 == 1){
			ret *= pow_cur;
			ret %= mod_num;
		}
		pow_cur *= pow_cur;
		pow_cur %= mod_num;
		pow_num /= 2;
	}
	return ret;
}

int main(){
	
	long long int N, A, B, K;
	cin >> N >> A >> B >> K;
	
	long long int num = 1;
	for(int i = 1; i <= N; i++){
		num *= i;
		num %= MOD;
		pown[i] = num;
	}
	pown[0] = 1;
	
	
	for(int i = 0; i <= N; i++){
		num = pown[N];
		num *= pow_m1(pown[i]);
		num %= MOD;
		num *= pow_m1(pown[N - i]);
		num %= MOD;
		conv[i] = num;
	}
	
	long long int ans = 0;
	
	for(long long int i = 0; i <= N; i++){
		long long int rem = K - A * i;
		if(rem % B == 0 && rem / B >= 0 && rem / B <= N){
			ans += (conv[i] * conv[rem / B]) % MOD;
			ans %= MOD;
		}
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 6400
import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;


public class Main {
	
	public static void main(String[] args) throws IOException {
		new Main().exec();
	}
	
	public void exec() throws IOException {
		InputUtil in = new InputUtil();
		PrintWriter out = new PrintWriter(System.out);
		int N = in.nextInt();
		int[] A = in.nextInt(new int[N]);
		int[] cnt = new int[100000];
		for(int i=0; i<N; i++)
			cnt[A[i]]++;
		int ans=cnt[0]+cnt[1];
		for(int i=1;i<99999;i++){
			ans=Math.max(ans, cnt[i-1]+cnt[i]+cnt[i+1]);
		}
		ans=Math.max(ans, cnt[99998]+cnt[99999]);
		out.println(ans);
		out.flush();
	}
	
}

class InputUtil {
	//Static Fields
	private static final int BUFSIZ = 100000;
	
	//Fields
	protected InputStream in;
	private byte[] buf = null;
	private int ptr = 0;
	private int max = -1;
	private DataInputStream dis = null;
	//Constructors
	public InputUtil() {this(System.in,BUFSIZ);}
	public InputUtil(InputStream in, int bufsiz) {
		initBuf(bufsiz);
		initIn(in);
	}
	
	//Methods
	//Initializer
	protected void initIn(InputStream in) {dis = new DataInputStream(this.in = in);}
	protected void initBuf(int bufsiz) {buf = new byte[bufsiz];}
	
	//buffer operation
	private void next() throws IOException {ptr++; readBuf();}
	private void readBuf() throws IOException {
		if(ptr >= max && dis.available()>0) {
			if(max>0) Arrays.fill(buf,0,max,(byte)0);
			max = dis.read(buf);
			ptr = 0;
		}
	}
	
	//Number Input Reader/Parser
	private boolean isNum(byte b) {return '0' <= b && b <= '9'; }
	private boolean isMinus(byte b) {return b=='-'; }

	private int _nextInt() throws IOException {
		int sign = 1;
		int res = 0;
		byte c;
		while (!isNum(c=buf[ptr]) && !isMinus(c)) 
			next();
		if (isMinus(buf[ptr])) {
			sign = -1;
			next();
		}
		while (isNum(c=buf[ptr])) {
			res *= 10;
			res += c - '0' ;
			next();
		}
		next();
		return sign * res;
	}
	
	public int nextInt() throws IOException {
		readBuf();
		return _nextInt();
	}

	public int[] nextInt(int[] result) throws IOException {
		readBuf();
		for(int i=0; i<result.length; i++) {
			result[i] = _nextInt();
		}
		return result;
	}
	
	//Close 
	public void close() throws IOException {
		if(!this.in.equals(System.in)) 
			this.in.close();
	}

}

Measured memory_bytes: 23380
#include "bits/stdc++.h"
#define PRECISION(x) cout << fixed << setprecision(x)
#define FAST_IO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define ALLR(X) (X).rbegin(), (X).rend()
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define F first
#define S second

using namespace std;
 
template<class T> void max_self(T & a, const T & b) { if(a < b) a = b; }
template<class T> void min_self(T & a, const T & b) { if(a > b) a = b; }
typedef long long LL;
const int INF = 1e9 + 7;
const double PI = acos(-1.0);
const double EPS = (1e-9);


int main(){
  FAST_IO  
  int N, h, trial = 0, best = 0; cin >> N >> h;
  vector<int> onetime;

  for(int rep = 0; rep < N; ++rep){
    int a, b; cin >> a >> b;
    max_self(best, a);
    onetime.PB(b);
  }
  sort(ALLR(onetime));

  for(int ele : onetime){
    if(ele <= best || h <= 0) break;
    h -= ele;
    trial++;
  }

  if(h > 0) trial += (h / best) + (h % best > 0);

  cout << trial << "\n";
  return 0;
}

Measured memory_bytes: 892
# 2020-05-22
def main():
    n, m, k = [int(x) for x in input().split()]
    friends = [set() for _ in range(n)]
    blocks = [set() for _ in range(n)]
    for _ in range(m):
        a, b = [int(x) - 1 for x in input().split()]
        friends[a].add(b)
        friends[b].add(a)
    for _ in range(k):
        a, b = [int(x) - 1 for x in input().split()]
        blocks[a].add(b)
        blocks[b].add(a)

    networks = {}  # The dict of networks as sets. Keys are leaders.
    net_leaders = [-1] * n  # The leaders of the networks that the ones joined.
    visited = [False] * n
    for person in range(n):
        if visited[person]:
            continue
        network = set()
        stack = [person]
        while stack:
            new = stack.pop()
            visited[new] = True
            net_leaders[new] = person
            network.add(new)
            for adj in friends[new]:
                if visited[adj]:
                    continue
                stack.append(adj)
        networks[person] = network

    answers = []
    for person in range(n):
        net = networks[net_leaders[person]]
        ans = len(net) - len(friends[person]) - 1
        for block in blocks[person]:
            if block in net:
                ans -= 1
        answers.append(ans)

    print(*answers)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 122272
#include <bits/stdc++.h>
using namespace std;
typedef pair<double, double> line;
#define point line
#define fi first
#define se second
int n;
double a[50005], b[50005], c[50005];
line l[50005];
bool cmp(line x,line y){
	if (x.fi * y.fi < 0) return x.fi <= 0;
	return x.fi >= y.fi;
}
bool cmp2(point x,point y){
	if (abs(x.fi - y.fi) < 1e-9) return x.se > y.se;
	return x.fi < y.fi;
}
double resx, resy;
vector <point> lst;
int fw[50005];
int fw_get(int x){
	int res = 0; for(;x;x-=x&-x) res+= fw[x]; return res;
}
void fw_upd(int x){
	for(;x<=n;x+=x&-x) fw[x] ++;
}
double solve(){
	sort(l+1,l+n+1,cmp);
	double L = -1e12, R = 1e12;
	//for(int i=1;i<=n;i++) cout << l[i].fi << ' ' << l[i].se << endl;
	for(int _time=0;_time<300;_time++){
		double divide_line = (L+R)/2;
		//cout << "div " << divide_line << endl;
		lst.clear();
		fill(fw,fw+n+5,0);
		for(int i=1;i<=n;i++)
			lst.push_back(point((divide_line - l[i].se) / l[i].fi, i));
		sort(lst.begin(), lst.end());
		int cnt = 0;
		for(int i=0;i<n;i++)
			cnt += fw_get(lst[i].se),
			fw_upd(lst[i].se);
			//cout << lst[i].fi << ' ' << lst[i].se << ' ';
			//cout << endl;
		// cnt equals !inverse
		
		if (cnt < ((n * (n-1) / 2)+1) / 2) 
			L = divide_line;
		else
			R = divide_line;
		//cout << cnt << endl;
	}
	return L;
}
int main(){
	iostream::sync_with_stdio(0);
	cin >> n;
	for(int i=1;i<=n;i++)
		cin >> a[i] >> b[i] >> c[i], c[i] = -c[i]; // ax + by + c = 0
	
	for(int i=1;i<=n;i++)
		l[i].fi = - a[i] / b[i],
		l[i].se = - c[i] / b[i];
	resy = solve();
	for(int i=1;i<=n;i++)
		l[i].fi = - b[i] / a[i],
		l[i].se = - c[i] / a[i];
	resx = solve();
	cout << fixed << setprecision(10) << resx << ' ' << resy;
}


Measured memory_bytes: 3192
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
#define vec(s) vector

#define vvec(s) vector<vector
>
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YN(x) cout<<(bool x?"Yes":"No")<<endl;
#define out(s) cout<<s<<endl;
#define pb(s) push_back(s);
#define sp " ";
#define INF 10000000000
#define all(s) s.begin(),s.end()
void vout(vi v){
    for(int i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    lli n, k,ans=0;
    cin >> n >> k;
    rep(i,n){
        lli h;
        cin >> h;
        if(h>=k){
            ans++;
        }
    }
    out(ans);
}

Measured memory_bytes: 3584
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>

using namespace std;

const long long MOD = 1000000007;

int main(){
	double n;
	cin >> n;
	for(double x=1;x<=n;x++){
		if(n<=x*1.08 && x*1.08<n+1){
			cout << x << endl;
			return 0;
		}
	}
	cout << ":(" << endl;
	return 0;
}

Measured memory_bytes: 256
def match(x, y):
    return x == y or x == '?' or y == '?'


def check(s, t):
    M = 10 ** 4
    ANS = [1] * (2 * M)
    S = len(s); T = len(t)
    for i in range(S):
        for j in range(T):
            if not match(s[i], t[j]):
                ANS[i - j + M] = 0
    return ANS


def solve(a, b, c):
    M = 10 ** 4
    lenA = len(a)
    lenB = len(b)
    lenC = len(c)

    AB = check(a, b)
    AC = check(a, c)
    BC = check(b, c)

    ans = lenA + lenB + lenC
    for i in range(-lenB, lenA + lenB + 1):
        for j in range(-lenC, lenA + lenC + 1):
            if AB[i + M] and AC[j + M] and BC[j - i + M]:
                L = min(0, min(i, j))
                R = max(lenA, max(lenB + i, lenC + j))
                ans = min(ans, R - L)

    return ans


a = input()
b = input()
c = input()


ans = min(solve(a, b, c), min(solve(b, c, a), solve(c, a, b)))

print(ans)


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

int main() {
  string S;
  cin >> S;

  if (S == "Sunny") {
    cout << "Cloudy";
  } else if (S == "Cloudy") {
    cout << "Rainy";
  } else {
    cout << "Sunny";
  }

  cout << endl;
}


Measured memory_bytes: 256
#include<cstdio>

using namespace std;

int main(){
	char s[3][110];
	scanf("%s %s %s", s[0], s[1], s[2]);
	int p[3] = {}, t = 0;
	while(1){
		if(s[t][p[t]] == '\0') break;
		t = s[t][p[t]++] - 'a';
	}
	printf("%c\n", "ABC"[t]);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,count = 0;
  cin >> n;
  vector<int> v(n,0);
  for(int i=0;i<n;i++){
    cin >> v[i];
  }
  for(int i=1;i<n-1;i++){
   int mid = v.at(i);
  
   if((mid > v.at(i-1) && mid < v.at(i+1)) || (mid < v.at(i-1) && mid > v.at(i+1))){ count++; }
  }  
   cout << count << endl;
}


Measured memory_bytes: 256
from sys import stdin
hi = 10**5
dp = [10**6] * (hi + 5)
dp[0] = 0
coins = [1]
cur = 1
while True:
 cur *= 6
 if cur > hi:
  break
 coins.append(cur)
cur = 1
while True:
 cur *= 9
 if cur > hi:
  break
 coins.append(cur)
for v in coins:
 for i in xrange(v,100001):
  dp[i] = min(dp[i], dp[i-v] + 1)
n = int(stdin.readline())
print dp[n]

Measured memory_bytes: 5764
#include<stdio.h>
int main()
{
	long long int n, d;
	scanf("%lld %lld", &n, &d);
	long long int i;
	long long int x, y;
	long long int ans = 0;
	for (i = 0; i < n; i++)
	{
		scanf("%lld %lld", &x, &y);
		if (x * x + y * y <= d * d)
			ans++;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 1736
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#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 Sort(v) sort(v.begin(), v.end())
#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};

const ll INF = 1LL << 50;

const ll mod = 1000000007;
ll fact[200200];
ll invfact[200200];

inline ll take_mod(ll a) { return (a % mod + mod) % mod; }

inline ll add(ll a, ll b) { return take_mod(a + b); }

inline ll sub(ll a, ll b) { return take_mod(a - b); }

inline ll mul(ll a, ll b) { return take_mod(a * b); }

inline ll pow(ll x, ll n) {
  ll res = 1LL;
  while (n > 0) {
    if (n & 1) res = mul(res, x);
    x = mul(x, x);
    n >>= 1;
  }
  return res;
}

ll mod_inv(ll x) { return pow(x, mod - 2); }

void make_fact(ll n) {
  fact[0] = 1;
  ll res = 1;
  for (int i = 1; i <= n; i++) {
    fact[i] = res;
    res = mul(res, i + 1);
  }
}

void make_invfact(ll n) {
  invfact[0] = 1;
  invfact[n] = mod_inv(fact[n]);
  for (int i = n - 1; i >= 1; i--) {
    invfact[i] = mul(invfact[i + 1], i + 1);
  }
}

ll perm(ll n, ll k) { return mul(fact[n], invfact[n - k]); }

ll comb(ll n, ll k) { return mul(mul(fact[n], invfact[n - k]), invfact[k]); }

int main() {
  ll k, t;
  cin >> k >> t;

  priority_queue<ll> q;
  rep(i, t) {
    ll t;
    cin >> t;
    q.push(t);
  }

  while(q.size() >= 2){
    ll a = q.top();
    q.pop();
    ll b = q.top();
    q.pop();
    a -= b;
    if (a > 0) q.push(a);
  }

  ll ans = 0;
  if (q.size()) ans += q.top()-1;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
# ==================== mod 10**9+7    
mod=10**9+7

def add(a, b):
    return (a + b) % mod

def sub(a, b):
    return (a + mod - b) % mod

def mul(a, b):
    return ((a % mod) * (b % mod)) % mod

def power(x, y):
    if   y == 0     : return 1
    elif y == 1     : return x % mod
    elif y % 2 == 0 : return power(x, y//2)**2 % mod
    else            : return power(x, y//2)**2 * x % mod

def div(a, b):
    return mul(a, power(b, mod-2))

n=int(input())

m=(power(10,n)-power(9,n)*2+power(8,n))%mod
print(m)



Measured memory_bytes: 61976
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
// Hey! 僕の提出を見てくれてありがとう.
// ロボ子さん可愛いぞ！！！！！君もV沼にはまろう↓
// https://www.youtube.com/channel/UCDqI2jOz0weumE8s7paEk6g
using namespace std;
namespace mp = boost::multiprecision;
// 任意長整数型
using bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using real1024 = mp::number<mp::cpp_dec_float<1024>>;
// ついでに有理数型
using rat = boost::rational<bint>;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}//a,bの最大公約数(gcd)を求める
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}//a,bの最小公倍数(lcm)を求める
vector<ll> enum_div(ll n){vector<ll> ret;for(int i=1 ; i*i<=n ; i++){if(n%i == 0){ret.push_back(i);if(i!=1 && i*i!=n)ret.push_back(n/i);}}ret.push_back(n);return ret;}
//↑nの約数を求める
vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
//↑エラトステネスの篩で素数を求める
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend //切り上げ割り算
#define all(x) (x).begin(),(x).end() //xの初めから終わりまでのポインタ
#define size_t ll //size_tは自動でllに変換される
#define pb(x) push_back(x)
#define pri_queue priority_queue //優先度付きキュー
#define syo(x) fixed << setprecision(x) //iostreamで小数をx桁表示
//sortを降順にする時は greater<型>()

int main(){
  ll h,w,k;
  vector<vector<char>> c;
  cin >> h >> w >> k;
  c.resize(h,vector<char>(w));
  vector<ll> cs;
  ll sum=0;
  for (int i = 0; i < h; i++) {
    ll a=0;
    for (int l = 0; l < w; l++) {
      cin >> c[i][l];
      if(c[i][l] == '#'){a++;sum++;}
    }
    cs.pb(a);
  }
  for (int i = 0; i < w; i++) {
    ll a=0;
    for (int l = 0; l < h; l++) {
      if(c[l][i] == '#')a++;
    }
    cs.pb(a);
  }
  ll ans = 0;
  for (int bit = 0; bit < (1<<(h+w)); bit++) {
    vector<vector<char>>x(c);
    ll s=0;
    for (int i = 0; i < h+w; i++) {
      if(bit & (1 << i)){
        if(i < h){
          for (int l = 0; l < w; l++) {
            x[i][l] = '!';
          }
        }else{
          for (int l = 0; l < h; l++) {
            x[l][i-h] = '!';
          }
        }
      }  
    }
    for (int i = 0; i < h; i++) {
      for (int l = 0; l < w; l++) {
        if(x[i][l] == '#')s++;
      }
    }
    if(s == k){
      ans++;
    }  
  }
  cout << ans << endl;
}


Measured memory_bytes: 3604
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <iomanip>
using namespace std;
typedef long long ll;

 
int main() {
    int N, H, W; cin >> N >> H >> W;
    vector<int> A(N), B(N);
    for(int i = 0; i < N; i++){
        cin >> A[i] >> B[i];
    }
    int cnt=0;
    for(int i = 0; i < N; i++){
        if(A[i] >= H && B[i] >= W) cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
a,b,k=map(int,input().split(" "))


l=[]

for i in range(1,min(a,b)+1):
	if(a%i==0 and b%i==0):
		l.append(i)
l=sorted(l)
l=l[::-1]
# print(l)
print(l[k-1])


	


	


	

	

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, N) for (int i = 0; i < (int)N; i++)
#define all(a) (a).begin(), (a).end()

int N, C;

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

  vector<int> s(N), t(N), c(N);
  rep(i,N) {
    cin >> s[i] >> t[i] >> c[i];
    c[i]--;
  }
  int T = 2 * (*max_element(all(t)));
  vector<int> sm(T+1, 0);
  rep(k,C) {
    vector<int> tt(T+1, 0);
    rep(i,N) if(c[i] == k) tt[s[i]*2-1]++, tt[t[i]*2]--;
    rep(t,T) tt[t+1] += tt[t];
    rep(t,T+1) sm[t] += min(tt[t], 1);
  }

  cout << *max_element(all(sm)) << endl;

  return 0;
}


Measured memory_bytes: 2944
def fib_memo(n):
    memo = [0] * (n + 1)

    def _fib(n):
        if n <= 1:
            return 1
        if memo[n] != 0:
            return memo[n]
        memo[n] = _fib(n-1) + _fib(n-2)
        return memo[n]

    return _fib(n)

N = int(input())
print(fib_memo(N))


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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);	
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll ,ll> 			pll;
typedef pair<ld,ld> 			pld;
typedef unordered_map<ll,ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5+7;
const ll 	MAX7 	= 	1e+7+7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const ll  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9+7;

/*vll adj[MAXN];ll visit[MAXN]={};
ll dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1};
ll dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};
*/
// <------------- Declare Variables Here ------------> //

ll T=1;
ll n,x,y,m,k,d;
string s,t;
//vll a,b;
// <------------- Implement Functions Here ----------> //


// <------------- Start of main() -------------------> //

void MAIN() {
	cin >> x >> k >> d;
	ll moves = abs(x)/d ;

	if(moves >= k) {
		cout<<abs(x) - k*d;
	}
	else {
		ll exp = abs(x) - (moves)*d;
		if(abs(exp) < abs(exp-d)) {
			k-=moves;
		}
		else {
			k-=moves+1;
		}
		if(k%2==0) {
			cout<<min(abs(exp),abs(exp-d));
		}
		else {
			cout<<max(abs(exp),abs(exp-d));	
		}
	}
}

int main() {
	fastio;randomINT;
	//cin>>T;
	while(T--) {
		MAIN();
	}
	return 0;
}



Measured memory_bytes: 3664
#include <stack>
#include <iostream>
using namespace std;
// long long bruteforce(int *a, int n) {
//     long long ans = 1<<30;
//     for (int i = 0; i <= n; i++) {
//         long long count = 0;
//         if (i > 0) {
//             count++;
//             long long t = -2LL * a[i-1];
//             for (int j = i-2; j >= 0; j--) {
//                 count++;
//                 long long s = -2LL * a[j];
//                 while (s > t) { s *= 4; count += 2; }
//                 t = s;
//             }
//         }
//         if (i < n-1) {
//             long long t = a[i];
//             for (int j = i+1; j < n; j++) {
//                 long long s = a[j];
//                 while (s < t) { s *= 4; count += 2; }
//                 t = s;
//             }
//         }
//         ans = min(ans, count);
//     }
//     return ans;
// }

int main() {
    int n; cin >> n;
    int a[n]; for (int i = 0; i < n; i++) cin >> a[i];
    long long dp1[n+1], dp2[n+1];
    dp1[0] = dp2[n] = dp2[n-1] = 0;
    dp1[1] = 1;
    stack<pair<int, int> > st;
    st.push({0, 1<<30});
    for (int i = 1; i < n; i++) {
        if (a[i-1] >= a[i]) {
            dp1[i+1] = dp1[i] + 1;
            long long t = a[i];
            int k = 0;
            while (4 * t <= a[i-1]) { t *= 4; k += 2; }
            if (k > 0) {
                st.push({i, k});
            }
        } else {
            long long l = -2 * a[i-1], r = -2 * a[i];
            int k = 1;
            while (l > r) {
                l *= 4;
                st.top().second -= 2;
                k += 2 * (i - st.top().first);
                if (st.top().second == 0) st.pop();
            }
            dp1[i+1] = dp1[i] + k;
        }
    }

    st = stack<pair<int, int> >();
    st.push({n, 1<<30});
    for (int i = n-2; i >= 0; i--) {
        if (a[i] <= a[i+1]) {
            dp2[i] = dp2[i+1];
            long long t = a[i];
            int k = 0;
            while (4 * t <= a[i+1]) { t *= 4; k += 2; }
            if (k > 0) {
                st.push({i+1, k});
            }
        } else {
            long long l = a[i], r = a[i+1];
            int k = 0;
            while (l > r) {
                r *= 4;
                st.top().second -= 2;
                k += 2 * (st.top().first - i - 1);
                if (st.top().second == 0) st.pop();
            }
            dp2[i] = dp2[i+1] + k;
        }
    }

    long long ans = 1LL<<60;
    for (int i = 0; i <= n; i++) ans = min(ans, dp1[i] + dp2[i]);
    cout << ans << endl;

    // long long ans2 = bruteforce(a, n);
    // if (ans == ans2) cerr << "OK" << endl;
    // else {
    //     cerr << "wrong: expect " << ans2 << " but got " << ans << endl;
    //     cerr << n << endl;
    //     for (int i = 0; i < n; i++) cerr << a[i] << " ";
    //     cerr << endl;
    // }
}


Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
typedef pair<int,int> P;
const int INF = 1000000000;
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
int main(){
    int H,W;cin >> H >> W;
    vector<vector<char> > grid(H,vector<char>(W));
    vector<vector<int> > dist(H,vector<int>(W,INF));
    int cnt = 0;
    rep(i,H){
        rep(j,W){
            cin >> grid[i][j];
            if(grid[i][j] == '.')cnt++;
        }
    }
    queue<P> que;
    que.push(make_pair(0,0));
    dist[0][0] = 0;
 
    while(!que.empty()){
        P p = que.front();
        que.pop();
        if(p.first == H-1 && p.second == W-1)break;
        rep(i,4){
            int ny = p.first + dy[i];
            int nx = p.second + dx[i];
            if(nx < 0 || ny < 0 || nx >= W || ny >= H)continue;
            if(dist[ny][nx] != INF || grid[ny][nx] != '.')continue;
            que.push(make_pair(ny,nx));
            dist[ny][nx] = dist[p.first][p.second]+1;
        }
    }
    if(dist[H-1][W-1] == INF)puts("-1");
    else{
        int ans = cnt - dist[H-1][W-1] - 1;
        cout << ans << endl;
    }
    return 0;
}

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

using namespace std;

typedef long long ll;

const int INF = 1000000000;

struct UF
{
  vector<int> parent_, rank_;
  UF(int N) : parent_(N + 5), rank_(N + 5, 1) {
    for (int i = 0; i <= N; ++i) { parent_[i] = i; }
  }

  int find_set(int x)
  {
    if (x != parent_[x]) {
      parent_[x] = find_set(parent_[x]);
    }
    return parent_[x];
  }

  void unite(int x, int y)
  {
    int s1 = find_set(x), s2 = find_set(y);
    if (s1 == s2) { return; }
    if (rank_[s1] > rank_[s2]) {
      parent_[s2] = s1;
    }
    else {
      parent_[s1] = s2;
      if (rank_[s1] == rank_[s2]) {
        ++rank_[s2];
      }
    }
  }

  bool is_connected(int x, int y) { return find_set(x) == find_set(y); }
};

int main()
{
  int N, M; scanf("%d %d", &N, &M);
  vector<int> P(N + 1);
  for (int i = 1; i <= N; ++i) {
    scanf("%d", &P[i]);
  }
  UF uf(N + 1);
  for (int i = 0; i < M; ++i) {
    int x, y;
    scanf("%d %d", &x, &y);
    uf.unite(x, y);
  }
  int ans = 0;
  for (int i = 1; i <= N; ++i) {
    if (uf.is_connected(P[i], i)) { ++ans; }
  }
  printf("%d\n", ans);
  return 0;
}


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

int main(){
  long long N;
  cin>>N;
  vector<int> a(N),f(N);
  for(int i=0;i<N;i++){
    a[i]=0;
    cin>>f[i];
  }
  int ans,ans2;
  ans2=0;
    for(int i=N-1;i>=0;i--){
    ans=0;
      for(int j=i;j<N;j+=i+1){
        ans+=a[j];
      }
      if(ans%2==f[i]){
        continue;
      }
      else{
        ans2++;
        a[i]=1;
        continue;
      }
  }
  cout<<ans2<<endl;
   for(int i=0;i<N;i++){
    if(a[i]==1){
      cout<<i+1;
     if(i!=N-1){
       cout<<" ";
     }
    }
  }
  cout<<endl;
  }

Measured memory_bytes: 2432
import sys
input = sys.stdin.readline


def readstr():
    return input().strip()


def readint():
    return int(input())


def readnums():
    return map(int, input().split())


def readstrs():
    return input().split()


def main():
    A, B, C, K = readnums()
    if A > K:
        print(K)
    elif A + B >= K:
        print(A)
    elif A + B < K:
        print(A - (K - (A + B)))


if __name__ == "__main__":
    main()


Measured memory_bytes: 9196
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<complex>
#include<cfloat>
#include<cassert>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define EPS (1e-10)
using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef complex<double> P;

#define PI (3.1415926535)
#define EPS (1e-10)

int main(){
  int n;
  while(cin>>n,n){
    vector<int> a(n);
    vector<int> s(n+1);
    int ans = INT_MIN;
    REP(i,n){
      cin>>a[i];
      s[i+1] = s[i];
      s[i+1] += a[i];
    }
    REP(i,n) for(int j=i+1; j<=n; j++){
      ans = max(ans, s[j]-s[i]);
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 0
alpha = input()

large = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L',
            'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']

small = [i.lower() for i in large]

if alpha in large:
    print("A")
else:
    print("a")

Measured memory_bytes: 9052
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
#define MAX 20002
 
int dy1[6]={1,0,-1,-1,0,1};
int dx1[6]={1,2,1,0,-1,0};
 
int dy2[6]={-1,-2,-1,0,1,0};
int dx2[6]={1,0,-1,-1,0,1};
 
int dy3[6]={1,0,-1,-1,0,1};
int dx3[6]={-1,-2,-1,0,1,0};
 
int dy4[6]={1,2,1,0,-1,0};
int dx4[6]={1,0,-1,-1,0,1};
 
int n;
 
map<P,int> T,F,vd;
map<P,P> G;
 
int Y[MAX],X[MAX];
char c[MAX];
bool flg[MAX];
 
 
bool rec(int x,int y){
  //  cout<<x<<' '<<y<<endl;
 
  P p=P(x,y);
  P q=G[p];
  vd[p]=true;
  vd[q]=true;
  F[p]=1;
  F[q]=2;
  int id=T[p];
  flg[id]=true;
  P to;
  int ny,nx;
  for(int i=0;i<6;i++){
    if(c[id]=='x'){
      if(y==Y[id]&&x==X[id]){
    ny=y+dy1[i];
    nx=x+dx1[i];
      }else{
    ny=y+dy3[i];
    nx=x+dx3[i];
      }
    }else{
      if(y==Y[id]&&x==X[id]){
    ny=y+dy4[i];
    nx=x+dx4[i];
      }else{
    ny=y+dy2[i];
    nx=x+dx2[i];
      }
    }
    to=P(nx,ny);
 
    if(i<3&&F[to]==1)return false;
    if(i>=3&&F[to]==2)return false;
    if(vd[to])continue;
    if(T[to]==0)continue;
    if(i<3){
      nx=G[to].first;
      ny=G[to].second;
    }
    if(!rec(nx,ny))return false;
  }
 
  return true;
}
 
bool solve(){
  for(int i=1;i<=n;i++){
    if(flg[i])continue;
    if(!rec(X[i],Y[i]))return false;
  }
  return true;
}
 
 
int main() {
 
  while(cin >> n && n) {
    T.clear();
    G.clear();
    vd.clear();
    F.clear();
    for(int i=1; i<=n; i++) {
      cin >> X[i] >> Y[i] >> c[i];
      P a,b;
      a.first=X[i],a.second=Y[i];
      if(c[i]=='x'){
    b.first=a.first+1;
    b.second=a.second;
    T[a]=i;
    T[b]=i;
    G[a]=b;
    G[b]=a;
      }else{
    b.first=a.first;
    b.second=a.second+1;
    T[a]=i;
    T[b]=i;
    G[a]=b;
    G[b]=a;
      }
    }
    for(int i=1;i<=n;i++)flg[i]=false;
    cout<<(solve()?"Yes":"No")<<endl;
    /*
    for(int i=5;i>=0;i--){
      for(int j=0;j<=5;j++){
    cout<<vd[P(i,j)];
      }
      cout<<endl;
    }
    */
  }
  return 0;
}

Measured memory_bytes: 39200
a=input()
def dfs(i,s,l):
    if i==3:
        if s==7:
            print(l+'=7')
            exit()
    else:
        dfs(i+1,s+int(a[i+1]),l+'+'+a[i+1])
        dfs(i+1,s-int(a[i+1]),l+'-'+a[i+1])

dfs(dfs(0,int(a[0]),a[0]))

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

using namespace std;

#define int long long
#define INF 21000000000

struct stu{
                int num;
                int kazu;
};

bool cmp(stu a,stu b){
                return a.kazu < b.kazu;
}
signed main(){
                int n;
                cin >> n;
                vector<stu> a;
                for(int i=0;i<n;i++){
                                int tmp;
                                cin >> tmp;
                                stu o;
                                o.num = i+1;
                                o.kazu = tmp;
                                a.push_back(o);
                }
                sort(a.begin(),a.end(),cmp);
                for(auto& A : a) cout << A.num << ' ';
}


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


int main()
{
	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a + 3);
	if (a[0] + a[1] == a[2]) {
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V))

vector<string> split(string,string);

//template<typename T>
//void swap(T*,T*);
//char ToUpper (char cX) { return toupper(cX); }

int main()
{
    string s;
    cin >> s;
    int c = 0;
    rep(i,3)
    {
        if(s[i] == '1')
            c++;
    }
    cout << c;
}


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

class Test {
	static void Main(string[] args) {
      var inputs = System.Console.ReadLine()
    	.Split(' ')
    	.Select(s => int.Parse(s))
    	.ToArray();
      int N = inputs[0];
      Console.WriteLine((10000-N)%1000);
	}
}

Measured memory_bytes: 18864
#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 K;
	string S;
	cin >> K >> S;
	if (S.size() <= K)
		cout << S;
	else {
		rep(i, K) cout << S.at(i);
		cout << "...";
	}
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint unsigned
#define pii pair<int,int>
#define pll pair<ll,ll>
#define PB push_back
#define fi first
#define se second
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define CLR(a,v) memset(a,v,sizeof(a));
#define CPY(a,b) memcpy(a,b,sizeof(a));
using namespace std;
const int N=205;
int n,m,fl[N];
char s[N][N];
int f[2][N][N][N];
int g[2][N][N][N];
int main(){
	scanf("%d%d",&n,&m);
	For(i,1,n) scanf("%s",s[i]+1);
	For(i,1,n) For(j,1,m)
		s[i][j]=(s[i][j]=='.'?0:1);
	For(i,1,n){
		For(j,1,m) fl[j]=s[i][j];
		For(j,i,n){
			For(k,1,m)
				if (s[j][k]!=fl[k])
					fl[k]=2;
			int las=fl[m],ed=m;
			f[0][i][j][m+1]=m+1;
			Rep(k,m,1){
				if (las!=fl[k]) las=fl[k],ed=k;
				f[0][i][j][k]=(las==2?k:ed+1);
			}
		}
	}
	For(i,1,m){
		For(j,1,n) fl[j]=s[j][i];
		For(j,i,m){
			For(k,1,n)
				if (s[k][j]!=fl[k])
					fl[k]=2;
			int las=fl[n],ed=n;
			g[0][i][j][n+1]=n+1;
			Rep(k,n,1){
				if (las!=fl[k]) las=fl[k],ed=k;
				g[0][i][j][k]=(las==2?k:ed+1);
			}
		}
	}
	int pr=0,su=1;
	For(ans,0,100){
		if (f[pr][1][n][1]==m+1){
			printf("%d\n",ans);
			return 0;
		}
		For(i,1,n) For(j,i,n) For(k,1,m+1)
			f[su][i][j][k]=f[pr][i][j][f[pr][i][j][k]];
		For(i,1,m) For(j,i,m) For(k,1,n+1)
			g[su][i][j][k]=g[pr][i][j][g[pr][i][j][k]];
		For(i,1,n) For(j,i,n){
			int ed=1;
			For(k,1,m){
				ed=max(ed,k);
				for (;ed<m+1&&g[pr][k][ed][g[pr][k][ed][i]]>j;++ed);
				f[su][i][j][k]=max(f[su][i][j][k],ed);
			}
		}
		For(i,1,m) For(j,i,m){
			int ed=1;
			For(k,1,n){
				ed=max(ed,k);
				for (;ed<n+1&&f[pr][k][ed][f[pr][k][ed][i]]>j;++ed);
				g[su][i][j][k]=max(g[su][i][j][k],ed);
			}
		}
		swap(pr,su);
	}
}

Measured memory_bytes: 129024