akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void debug_out() { cout << "\n"; }
template <class T, class... Args>
void debug_out(const T &x, const Args &... args) { cout << x << " "; debug_out(args...);}
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

int n, m;

ll dfs(int i, int bit, const vector<vector<int> > &G) {
  if (bit == (1<<n)-1) return 1;
  ll res = 0;
  for (auto u : G[i]) {
    if (bit & (1<<u)) continue;
    int nbit = bit|(1<<u);
    res += dfs(u, nbit, G);
  }
  return res;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  cin >> n >> m;
  vector<vector<int> > G(n);
  rep(i,m) {
    int a,b;
    cin >> a >> b;
    a--; b--;
    G[a].emplace_back(b);
    G[b].emplace_back(a);
  }
  ll ans = dfs(0,1,G);
  cout << ans << endl;
  return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    int A, B, C, D, E, F;
    cin >> A >> B >> C >> D >> E >> F;

    int w, s;
    double p = -1;
    for (int a = 0; 100 * A * a <= F; a++)
    for (int b = 0; 100 * (A * a + B * b) <= F; b++)
    for (int c = 0; 100 * (A * a + B * b) + C * c <= F; c++)
    for (int d = 0; 100 * (A * a + B * b) + C * c + D * d <= F; d++) {
        int wn = 100 * (A * a + B * b), sn = C * c + D * d;
        double pn = (double)sn / (wn + sn);
        if (pn > p && E * wn / 100 >= sn) {
            p = pn;
            w = wn;
            s = sn;
        }
    }
    cout << w + s << " " << s << endl;
    return 0;
}

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


int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    while (true)
    {
        c = c - b;
        if (c <= 0)
        {
            cout << "Yes";
            break;
        }
        a = a - d;
        if (a <= 0)
        {
            cout << "No";
            break;
        }
    }
}

Measured memory_bytes: 3624
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(n: int, a: "List[int]"):
    if n % 2 == 0:
        b = list(reversed(a[::2]))+a[1::2]
    else:
        b = list(reversed(a[1::2]))+a[::2]
    print(*reversed(b), sep=" ")

    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    n = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(n)]  # type: "List[int]"
    solve(n, a)


if __name__ == '__main__':
    main()


Measured memory_bytes: 34968
# ed ans
n = int(input())
s = input()

if len(set(s)) == 1:
    print(0)
    exit()

# i について，whiteとblackの個数を見て最小

# 全部白，全部黒にする
# ans1 = s.count(".")
# ans2 = s.count("#")

# wwwbbbbbの形にする
# 初期
black_left = 0
white_right = s.count(".")
ans = white_right
# print(0, black_left, white_right, ans)

for ch in s:
    if ch == '#':
        black_left += 1
    else:
        white_right -= 1
    ans = min(ans, black_left + white_right)
    # print(i, black_left, white_right, ans)

# print(min(ans, ans2))
print(ans)
    

Measured memory_bytes: 53744
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100000000;

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

	vector<int> h(n);
	rep(i,n)
	{
		cin >> h[i];
	}

	for(int i=n-1;i>0;i--)
	{
		if(h[i-1]>h[i])h[i-1]--;
		//cout<<h[i-1]<<h[i]<<endl;
		if(h[i-1]>h[i])
		{
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;
public class Main{
    public static void pre(Node nodes[], int root){
        System.out.print(" " + root);
        if(nodes[root].left != null)
            pre(nodes,nodes[root].left.index);
        if(nodes[root].right != null)
            pre(nodes,nodes[root].right.index);
    }
    public static void in(Node nodes[], int root){
        if(nodes[root].left != null)
            in(nodes,nodes[root].left.index);
        System.out.print(" " + root);
        if(nodes[root].right != null)
            in(nodes,nodes[root].right.index);
    }
    public static void post(Node nodes[], int root){
        if(nodes[root].left != null)
            post(nodes,nodes[root].left.index);
        if(nodes[root].right != null)
            post(nodes,nodes[root].right.index);
        System.out.print(" " + root);
    }
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int root = 0;
        Node nodes[] = new Node[n];
        for(int i = 0 ; i < n ; i++)
            nodes[i] = new Node(i);
        for(int i = 0 ; i < n ; i++){
            int index = sc.nextInt();
            int l = sc.nextInt();
            int r = sc.nextInt();
            if(l != -1)
                nodes[index].left = nodes[l];
            if(r != -1)
                nodes[index].right = nodes[r];
        }
        for(int i = 0 ; i < n ; i++){
            if(nodes[i].right != null)
                nodes[i].right.parent = nodes[i];
            if(nodes[i].left != null)
                nodes[i].left.parent = nodes[i];
        }
        for(int i = 0 ; i < n ; i++){
            if(nodes[i].parent == null)
                root = i;
        }        
        System.out.println("Preorder");
        pre(nodes,root);
        System.out.println();
        System.out.println("Inorder");
        in(nodes,root);
        System.out.println();
        System.out.println("Postorder");
        post(nodes,root);
        System.out.println();
    }
}
class Node{
    int index;
    Node parent = null;
    Node left = null;
    Node right = null;
    int get_parent(){
        if(parent == null)
            return -1;
        else
            return parent.index;
    }
    int sibling(){
        if(parent == null)
            return -1;
        else{
            if(parent.right == null || parent.left == null)
                return -1;
            else{
                if(parent.right.index == this.index)
                    return parent.left.index;
                else
                    return parent.right.index;
            }
        }
    }
    Node(int index){
        this.index = index;
    }
}


Measured memory_bytes: 26296
#![allow(unused_variables, dead_code, clippy::many_single_char_names, unused_imports, unused_macros)]
use std::{
    collections::{BTreeMap, HashSet, HashMap, VecDeque},
    io::{stdin, stdout, StdinLock, StdoutLock, BufReader, BufWriter, prelude::*},
    mem::swap,
    str::FromStr,
};

struct Reader<'a> {
    stdin: BufReader<StdinLock<'a>>
}

trait ReadRdr<T> {
    fn read(&mut self) -> T;
}

impl<'a> Reader<'a> {
    fn new(stdin: BufReader<StdinLock<'a/*'*/>>) -> Self {
        Self {stdin}
    }
    fn read_str(&mut self) -> String {
        let mut s = String::with_capacity(100);
        self.stdin.read_line(&mut s).unwrap();

        if s.ends_with('\n') { s.pop(); if s.ends_with('\r') { s.pop(); } }
        s
    }
    fn read_int<T: FromStr>(&mut self) -> T {
        match self.read_str().parse::<T>() {
            Ok(n) => n,
            _ => panic!()
        }
    }
}

macro_rules! pipe_read {
    ($r: expr, str, $($x: ident),+) => {
        let t = $r.read_str();
        let mut it = t.split(' ');
        $($x = it.next().unwrap();)+
    };
    ($r: expr, $t: ty, $($x: ident),+) => {
        let t = $r.read_str();
        let mut it = t.split(' ').map(|x| x.parse::<$t>().unwrap());
        $($x = it.next().unwrap();)+
    }
}

macro_rules! pipe {
    ($r: expr, str, $($x: ident),+) => {
        pipe_read!($r, str, $($x),+);
    };
    (declare $r: expr, str, $($x: ident),+) => {
        $(let $x: $t;)+
        pipe_read!($r, str, $($x),+);
    };
    ($r: expr, $t: ty, $($x: ident),+) => {
        pipe_read!($r, $t, $($x),+);
    };
    (declare $r: expr, $t: ty, $($x: ident),+) => {
        $(let $x: $t;)+
        pipe_read!($r, $t, $($x),+);
    };
}

const M: usize = 1_000_000;

fn main() {
    let stdin = stdin();
    let stdout = stdout();
    unsafe {
    solve(&mut Reader::new(BufReader::with_capacity(M, stdin.lock())), &mut BufWriter::with_capacity(M, stdout.lock()));
    }
}

static mut dp: [[usize; 100001]; 2] = [[0; 100001]; 2];

unsafe fn solve(r: &mut Reader, w: &mut BufWriter<StdoutLock>) {
    pipe!(declare r, usize, n, wcap);
    let mut w = Vec::with_capacity(n);
    let mut v = Vec::with_capacity(n);

    // let mut max = 0;

    for _ in 0..n {
        let t: String = r.read_int();
        let mut t = t.split(' ').map(|x| x.parse::<usize>().unwrap());
        w.push(t.next().unwrap());
        v.push(t.next().unwrap());
    }

    for (wi, vi) in w.into_iter().zip(v.into_iter()) {
        for ii in 0..=wcap {
            dp[1][ii] = if wi <= ii {
               (vi+dp[0][ii-wi]).max(dp[0][ii])
            } else {
                dp[0][ii]
            };
        }
        dp.swap(0, 1);
    }
    println!("{}", dp[0][wcap]); // swapped
}


Measured memory_bytes: 4496
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
#define M 1000000007
int main(){
  double n;cin>>n;
  if(n==1.0)cout<<1;
  else if((int)n%2==0)cout<<0.5;
  else{
  cout<<fixed<<setprecision(10)<<1.0-((double)((int)n/2))/n;}
}

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

const int mod = 1000000007;
long n;
long c[200000];
int main() {
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> c[i];
  sort(c, c + n, greater<long>());
  
  long p = 1;
  for (int i = 0; i < 2 * n - 2; ++i) {
    p = p * 2 % mod;
  }
  
  long sum = 0;
  for (int i = 0; i < n; ++i) {
    sum = (sum + c[i] * p % mod * (2 + i) % mod) % mod;
  }
  cout << sum << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define ll long long int

int facctorialMethod(int k){
    ll sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum = (sum%(1000000000+7))*(i%(1000000000+7));
    }
    return sum%(1000000000+7);
}
int main()
{
  
  int n,m;
  ll ans=0;
  cin >> n >>m;
  ll N,M;
  N=facctorialMethod(n);
  M=facctorialMethod(m);
  if(max(n,m)-min(n,m)>1)ans=0;
  else if(n==m){
    ans = N * M *2 %(1000000000+7);  
  }
  else{
    ans = N * M %(1000000000+7);
  }
  cout <<ans << endl;
      return 0;
}


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

using namespace std;
using ll = long long;

int main() {
  ll N, Q;
  string S;
  cin >> N >> Q;
  vector<ll> l(N), r(N);
  cin >> S;
  vector<ll> a;
  for (int j = 0; j < N; ++j) {
    if(S[j]=='A') {
      if (S[j + 1] == 'C')
        a.push_back(j);
    }
  }
  vector<ll> res;
  for (int i = 0; i < Q; ++i) {
    cin >> l[i] >> r[i];
    auto itl = lower_bound(a.begin(), a.end(), l[i]-1);
    ll l1 = itl != a.end() ? distance(a.begin(), itl) : a.size();
    auto itr = lower_bound(a.begin(), a.end(), r[i]-1);
    ll r1 = itr != a.end() ? distance(a.begin(), itr) : a.size();
    res.push_back(r1-l1);
  }
  for (int k = 0; k < res.size(); ++k) {
    cout << res[k] << endl;
  }

}


Measured memory_bytes: 3892
#include<bits/stdc++.h>
using namespace std;
void c_p_c()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#ifndef  ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
int main()
{
	//c_p_c();
	int t;
	cin >> t;
	int ti = 0, xi = 0, yi = 0;
	bool b = false;
	while (t--) {
		int t, x, y;
		cin >> t >> x >> y;
		int td = t - ti;
		int diff = abs(x - xi) + abs(y - yi);

		if (diff <= td && td % 2 == diff % 2)
		{
			b = true;

		}
		else
		{
			cout << "No";
			return 0;
		}
		ti = t;
		xi = x;
		yi = y;
	}
	if (b)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

}

Measured memory_bytes: 764
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())





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

	int n, k;
	cin >> n >> k;
	string s;
	cin >> s;

	int m = 0;
	char prev = ' ';
	for (char c: s) {
		if (prev != c)m++;
		prev = c;
	}


	cout << n - max(1, m - 2 * k) << endl;




	return 0;
}

Measured memory_bytes: 512
def solve():
  n = int(input())
  b = list(int(i) for i in input().split())
  ans = 0
  
  if n == 2:
    ans = b[0]*2
  else:
    ans = b[0]
    ans += b[-1]
    first = b[0]
    for i in range(n-2):
      nextvalue = b[i+1]
      ans += min(first,nextvalue)
      first = nextvalue
  print(ans)
solve()

Measured memory_bytes: 3064
n,k=gets.split.map &:to_i;s=gets.chomp.chars.map &:ord;l=0;((s[l]+l)%2>0&&(s[l]^=3;0==k-=1)&&break;l+=1;k-=1)while k>0&&l<n;s=s.rotate l%n;l%2>0&&s=s.map{|e|e^3};s[0]^=(n*k)%2*3;$><<s.map(&:chr)*''

Measured memory_bytes: 24388
#include <bits/stdc++.h>
#define LL long long
#define db double
using namespace std;
 
const int MAXN = 500500;
const int MAXE = 400400;
const int INF = 0x7FFFFFFF;
 
template<typename T> inline void CheckMax(T &A, T B) {
	A < B ? A = B : A;
}
 
template<typename T> inline void CheckMin(T &A, T B) {
	A > B ? A = B : A;
}
 
template <typename T> inline void read(T &x) {
    int c = getchar();
    bool f = false;
    for (x = 0; !isdigit(c); c = getchar()) {
        if (c == '-') {
            f = true;
        }
    }
    for (; isdigit(c); c = getchar()) {
        x = x * 10 + c - '0';
    }
    if (f) {
        x = -x;
    }
}

int n;
#define Fir puts("first")
#define Sec puts("second")

int a[MAXN], res; 
 
signed main() {
	read(n);
	for(int i = 1; i <= n; i++) {
		read(a[i]);
		if(a[i] & 1) res = 1;
	}
	if(res) Fir;
	else Sec;
	return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
  try (Scanner sc = new Scanner(System.in)) {
    String line = sc.nextLine();
    String answer = "";
    int length = line.length();
    for (int i = 0; i < length; i++) {
      char ch = line.charAt(i);
      if (Character.isLowerCase(ch)) {
        ch = Character.toUpperCase(line.charAt(i));
      } else {
        ch = Character.toLowerCase(line.charAt(i));
      }
      answer += ch;
    }
    System.out.println(answer);
    }
  }
}



Measured memory_bytes: 31388
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
int main()
{
	long long n, l, r,sum=0;
	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		sum += i * (n - i + 1);
	}
	for (int i = 1; i < n; i++)
	{
		cin >> l >> r;
		if (l > r)
			swap(l, r);
		sum -= l * (n - r + 1);
	}
	cout << sum << endl;
}


Measured memory_bytes: 3516
import java.util.*;
import java.math.RoundingMode;
import java.math.BigDecimal;
 
 
public class Main{
	public static void main (String[] args){
		Scanner sc = new Scanner(System.in);
		int d = sc.nextInt();
		int t = sc.nextInt();
		int s = sc.nextInt();
		if(d<=s*t) System.out.println("Yes");
		else System.out.println("No");
	}
}

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

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

typedef long long ll;
const ll MOD = 1e9 + 7;

const int INF = 1 << 30;
using cost_type = int;
using edge = std::pair<int, cost_type>;

template<typename T>
using Matrix = std::vector<std::vector<T>>;

Matrix<cost_type> Warshall_Floyd(const std::vector<std::vector<edge>> &from) {
  const int N = from.size();
  Matrix<cost_type> d(N, std::vector<cost_type>(N, INF));
  for(int i = 0; i < N; ++i) {
    d[i][i] = 0;
    for(auto &e : from[i]) {
      d[i][e.first] = std::min(d[i][e.first], e.second);
    }
  }

  for(int k = 0; k < N; ++k) {
    for(int i = 0; i < N; ++i) {
      for(int j = 0; j < N; ++j) {
        if(d[i][k] < INF && d[k][j] < INF) {
          d[i][j] = std::min(d[i][j], d[i][k] + d[k][j]);
        }
      }
    }
  }

  return d;
}

int main() {
  int H, W;
  std::cin >> H >> W;
  std::vector<std::vector<char>> S(H, std::vector<char>(W));

  Matrix<int> id(H, std::vector<int>(W));
  int cnt = 0;
  rep(i, H) {
    rep(j, W) {
      std::cin >> S[i][j];
      id[i][j] = cnt;
      ++cnt;
    }
  }

  std::vector<std::vector<edge>> from(cnt);
  const std::vector<std::pair<int, int>> diff = {std::make_pair(-1, 0), std::make_pair(1, 0), std::make_pair(0, -1), std::make_pair(0, 1)};
  rep(i, H) {
    rep(j, W) {
      if(S[i][j] == '#') {
        continue;
      }
      for(auto d : diff) {
        int x = i + d.first;
        int y = j + d.second;
        if(0 <= x && x < H && 0 <= y && y < W && S[x][y] == '.') {
          from[id[i][j]].push_back(std::make_pair(id[x][y], 1));
        }
      }
    }
  }

  Matrix<int> d = Warshall_Floyd(from);
  int ans = 0;
  rep(i, cnt) {
    rep(j, cnt) {
      if(d[i][j] == INF) continue;
      ans = std::max(ans, d[i][j]);
    }
  }
  std::cout << ans << '\n';
}


Measured memory_bytes: 896
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int solve() {
    int n, d; cin >> n >> d;
    vector<vector<int>> nums;
    for (int i = 0; i < n; ++i) {
        vector<int> row(d);
        for (int j = 0; j < d; ++j) {
            cin >> row[j];
        }
        nums.push_back(row);
    }
    
    int res{0};
    for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j < n; ++j) {
            double dist = 0.0;
            for (int k = 0; k < d; ++k) {
                dist += pow(nums[i][k] - nums[j][k], 2);
            }
            if (sqrt(dist) == floor(sqrt(dist))) {
                res++;
            }
        }
    }
    
    return res;
}

int main() {
    cout << solve() << endl;
}

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

typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> pll;
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);

ll const inf = 1e18;
ll const maxn = 1e6+5;
ll const mod = 1e9+7;

// code begins here

vector<ll> spf(maxn);

void sieve() 
{ 
    spf[1] = 1; 
    for (ll i=2; i<maxn; i++) 
  
        // marking smallest prime factor for every 
        // number to be itself. 
        spf[i] = i; 
  
    // separately marking spf for every even 
    // number as 2 
    for (ll i=4; i<maxn; i+=2) 
        spf[i] = 2; 
  
    for (ll i=3; i*i<maxn; i++) 
    { 
        // checking if i is prime 
        if (spf[i] == i) 
        { 
            // marking SPF for all numbers divisible by i 
            for (ll j=i*i; j<maxn; j+=i) 
  
                // marking spf[j] if it is not  
                // previously marked 
                if (spf[j]==j) 
                    spf[j] = i; 
        } 
    } 
}

int main(){
    fast;
    
    ll n;
    cin>>n;
    
    vector<ll> arr(n);
    for(auto &u: arr)
        cin>>u;
    
    sieve();
    
    ll flag = 0;
    
    map<ll, ll> mp;
    
    for(auto u: arr){
        set<ll> s;
        ll x = u;
        while(x!=1){
            s.insert(spf[x]);
            x /= spf[x];
        }
        
        for(auto v: s){
            if(mp[v]){
                flag = 1;
                break;
            }
            mp[v] = 1;
        }
        
        if(flag)
            break;
    }
    
    if(!flag){
        cout<<"pairwise coprime"<<endl;
        return 0;
    }

    ll g = 0;
    for(auto u: arr)
        g = __gcd(g, u);
    
    if(g==1){
        cout<<"setwise coprime"<<endl;
    } else {
        cout<<"not coprime"<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 18724
#include <bits/stdc++.h>
 
using namespace std;
 
//const int MOD=1e9+7;
 
const int MOD=998244353;


int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int n;
    cin>>n;
    cout<<n*n;
    
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>

#define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
#define fb(i,a,b) for(int (i) = (a); (i) >= (b); --(i))
#define mod 998244353
#define xx first
#define yy second
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define ll long long
#define pii pair<int,int>
# define pi           3.14159265358979323846
#define N 100005


using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>,rb_tree_tag, tree_order_statistics_node_update> ordered_set;/// find_by_order(x)(x+1th) , order_of_key() (strictly less)
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());



int n,m;
vector<int> graf[N];
int dje[N];
bool bio[N];

int main()
{

    ios_base::sync_with_stdio(false); cin.tie(0);
    cin >> n >> m;
    ff(i,1,m){
        int a,b;
        cin >> a >> b;
        graf[a].pb(b);
        graf[b].pb(a);
    }
    queue<int>q;
    q.push(1);
    while(!q.empty()){
        int sta = q.front();
        q.pop();
        for(auto c:graf[sta]){
            if(bio[c])continue;
            bio[c] = 1;
            dje[c] = sta;
            q.push(c);
        }
    }
    ff(i,1,n){
        if(dje[i] == 0){
            cout << "No\n";
            return 0;
        }
    }
    cout << "Yes\n";
    ff(i,2,n)cout << dje[i] << "\n";
    return 0;
}


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

#define FOR(i, a, b) for(int i = a; i < b; i ++)
#define FORS(i, a, b, c) for(int i = a; i < b; i += c)
#define FORN(i, a, b) for(int i = a; i <= b; i ++)
#define FORD(i, a, b) for(int i = a-1; i >= b; i --)
#define FORE(i, b) for(auto &i:b)
#define REP(i, b) FOR(i, 0, b)
#define REPN(i, b) FORN(i, 0, b)
#define SQ(i) (i*i)
#define ALL(a) a.begin(), a.end()
#define ALLA(a,n) a, a+n
#define SORT(a) sort(ALL(a))
#define SORTA(a, n) sort(ALLA(a, n))
#define REV(a) reverse(ALL(a))
#define REVA(a, n) reverse(ALLA(a, n))
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define IN(a, b) (a.find(b) != a.end())
#define BACK(a) a.back(); a.RB()
#define QBACK(a) a.top(); a.pop()
#define PRINT(a) FORE(i, a) cout << i << " "; cout << endl

#define PB  push_back
#define RB  pop_back
#define RF  pop_front
#define INS insert
#define F   first
#define S   second
#define UM  unordered_map
#define US  unordered_set
#define PQ  priority_queue

#define IO ios_base::sync_with_stdio(false); cin.tie(NULL)

typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<ll,ll> pll;
typedef queue<int> qi;
typedef queue<double> qd;
typedef queue<ll> qll;
typedef US<int> si;
typedef US<double> sd;
typedef US<ll> sll;
typedef vector<vi> mi;
typedef vector<vd> md;
typedef vector<vll> mll;
typedef vector<pi> vpi;
typedef vector<pd> vpd;
typedef vector<pll> vpll;

inline ll pow(ll i){
  return i*i*i*i*i;
}

void ans(ll i, ll j){
  cout << i << " " << j << endl;
}

int main(){
  IO; ll X; cin >> X;
  REPN(i,125){
    REPN(j,125){
      if(pow(i)-pow(j)==X){
        ans(i,j);
        return 0;
      }
      if(-pow(i)-pow(j)==X){
        ans(-i,j);
        return 0;
      }
      if(pow(i)+pow(j)==X){
        ans(i,-j);
        return 0;
      }
      if(-pow(i)+pow(j)==X){
        ans(-i,-j);
        return 0;
      }
    }
  }
}


Measured memory_bytes: 3652
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;

public class Main {

    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;

    long[] memo1, memo2;

    void solve() throws IOException {
        int h = ni();
        int w = ni();
        int a = ni();
        int b = ni();

        memo1 = new long[h + w];
        memo2 = new long[h + w];
        memo1[0] = memo2[0] = memo1[1] = memo2[1] = 1;
        for (int i = 2; i < h + w; i++) {
            memo1[i] = mltMod(i, memo1[i - 1]);
            memo2[i] = mltMod(rev(i), memo2[i - 1]);
        }

        long ans = 0;
        for (int i = 0; i < w - b; i++) {
            ans = addMod(ans, mltMod(combMod(h - a - 1 + b + i, b + i), combMod(a - 1 + w - b - i - 1, w - b - i - 1)));
        }

        out.println(ans);
    }

    long MOD = 1000000007;

    long addMod(long a, long b) {
        return (a + b) % MOD;
    }

    long subMod(int a, int b) {
        return (a - b + MOD) % MOD;
    }

    long mltMod(long a, long b) {
        return (a * b) % MOD;
    }

    long combMod(long a, long b) {
        return mltMod(mltMod(memo1[(int) a], memo2[(int) b]), memo2[(int) (a - b)]);
    }

    long rev(long a) {
        return powMod(a, MOD - 2);
    }

    long powMod(long a, long b) {
        long ans = 1;
        while (b > 0) {
            if ((b & 1) != 0) {
                ans = (ans * a) % MOD;
            }
            b >>= 1;
            a = (a * a) % MOD;
        }
        return ans;
    }

    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }

    int ni() throws IOException {
        return Integer.parseInt(ns());
    }

    long nl() throws IOException {
        return Long.parseLong(ns());
    }

    double nd() throws IOException {
        return Double.parseDouble(ns());
    }

    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }

    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }

    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }

    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}

Measured memory_bytes: 12108
#include <iostream>
#include <set>
#include <string>

using namespace std;

string reverse(string st, int size){
	string reLine;
	for(; size > 0; size--){
		reLine.push_back(st[size-1]);
	}
	return reLine;
}


int main(){
	int n;
	string arrivalLine;
	set<string> s;
	
	cin >> n;
	while(n--){
		string front,rear,reFront,reRear;
		s.clear();
		cin >> arrivalLine;
		for(int i = 1; i < arrivalLine.size(); i++){
			front = arrivalLine.substr(0,i);			// 前
			rear = arrivalLine.substr(i);				// 後ろ
			// cout << front << " + " << rear << endl;
			// 反転
			reFront = reverse(front, front.size());
			reRear = reverse(rear, rear.size());

			s.insert(front + rear);
			s.insert(rear + front);
			s.insert(front + reRear);
			s.insert(reRear + front);
			s.insert(reFront + rear);
			s.insert(rear + reFront);
			s.insert(reFront + reRear);
			s.insert(reRear + reFront);
		}
		// for(auto it : s){
		// 	cout << it << endl;
		// }
		cout << s.size() << endl;
	}
}

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

using namespace std;

long long a[100010]; 
long long b[100010];

int main(){
	int n;
	cin>>n;
	for(int i=0;i<n+1;i++){
		cin>>a[i];
	}
	for(int i=0;i<n;i++){
		cin>>b[i]; 
	}
	long long cnt=0;
	for(int i=0;i<n;i++){
		if(a[i]<=b[i]){
			cnt+=a[i];
			b[i]-=a[i];
			a[i]=0;
			cnt+=min(a[i+1],b[i]); 
			a[i+1]-=min(a[i+1],b[i]);
			continue;
		}
		else{
			cnt+=b[i];
			a[i]-=b[i];
		}
	}
	cout<<cnt<<endl;
	return 0;
}

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

bool cmpX(vector<int> prev, vector<int> curr) {
  return prev.at(0) < curr.at(0);
}

bool cmpYGreater(vector<int> prev, vector<int> curr) {
  return prev.at(1) > curr.at(1);
}

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

  int MAX = 1000;

  int n;
  cin >> n;

  vector<vector<int>> red(n);
  vector<vector<int>> blue(n);

  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;

    red.at(i) = {a, b};
  }

  for (int i = 0; i < n; i++) {
    int c, d;
    cin >> c >> d;

    blue.at(i) = {c, d};
  }

  // xが小さい順で青をソート
  sort(blue.begin(), blue.end(), cmpX);

  // yは大きい順で赤をソート
  sort(red.begin(), red.end(), cmpYGreater);

  vector<bool> delR(n, false);  // 赤を消したかどうか

  int count = 0;
  for (int i = 0; i < n; i++) {
    int bx = blue.at(i).at(0);
    int by = blue.at(i).at(1);
    for (int j = 0; j < n; j++) {
      int rx = red.at(j).at(0);
      int ry = red.at(j).at(1);

      if (rx < bx && ry < by && !delR.at(j)) {
        delR.at(j) = true;
        count++;
        break;
      }
    }
  }

  cout << count << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
double ans,radio;
int ori[22],a[22],n;
void dfs(int i,double maxr)
{
    if (i==n){ans=maxr;return;}
    int add,sub,now=a[i];
    if (a[i]>a[i-1])
    {
        add=a[i-1]-now%a[i-1];
        sub=a[i]%a[i-1];
        while (true)
        {
            a[i]=now-sub;
            if (double(sub)/(double)ori[i]>ans||a[i]<a[i-1])break;
            dfs(i+1,max(maxr,double(sub)/(double)ori[i]));
            sub+=a[i-1];
        }
    }
    else add=a[i-1]-a[i];
    while (true)
    {
        if ((double)add/(double)ori[i]>ans)break;
        a[i]=now+add;
        dfs(i+1,max(maxr,(double)add/(double)ori[i]));
        add+=a[i-1];
    }
    a[i]=now;
}
int main()
{
    while (scanf("%d",&n)!=EOF)
    {
        for (int i=0;i<n;i++)
        {
            scanf("%d",&ori[i]);
            a[i]=ori[i];
        }
        ans=1e18;
        dfs(1,0);
        int add=1;
        while (true)
        {
            radio=(double)add/(double)ori[0];
            if (radio>ans)break;
            a[0]=ori[0]+add;
            dfs(1,radio);
            a[0]=ori[0]-add;
            dfs(1,radio);
            add++;
        }
        printf("%.10lf\n",ans);
    }
    return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000

int main(){
	
	int K,A,B;
	cin>>K>>A>>B;
	
	for(int i=A;i<=B;i++){
		if(i%K==0){
			cout<<"OK"<<endl;
			return 0;
		}
	}
	cout<<"NG"<<endl;
	
	return 0;
}


Measured memory_bytes: 3572
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
	Scanner sc=new Scanner(System.in);
	int w=sc.nextInt();
	int n=sc.nextInt();
	int[] values=new int[w];
	for(int i=0;i<values.length;i++){
	    values[i]=i+1;
	}
	for(int i=0;i<n;i++){
	    int t=0;
	    String str=sc.next();
	    String[] ab=str.split(",");
	    int a=Integer.parseInt(ab[0])-1;
	    int b=Integer.parseInt(ab[1])-1;
	    t=values[a];
	    values[a]=values[b];
	    values[b]=t;
	}
	for(int i=0;i<values.length;i++){
	    System.out.println(values[i]);
	}

    }
}

Measured memory_bytes: 25964
/*Always success does not build on success,success build on failure and hardwork*/
#include <bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define vec         vector<int>
#define map         map<int,int>
#define scn(t)      scanf("%d",&t);
#define lscn(t)      scanf("%lld",&t);
#define mod         1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define endl        "\n"
using namespace std;
const int N=2e5+5;

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

    int l=s.length();

    for(int i=0;i<l-1;i++)
    {
        if(s[i]==s[i+1])
        {
            cout<<i+1<<" "<<i+2<<endl;
            return 0;
        }
    }

    for(int i=0;i<l-2;i++)
    {
        if(s[i]==s[i+2])
        {
            cout<<i+1<<" "<<i+3<<endl;
            return 0;
        }
    }

    cout<<-1<<" "<<-1<<endl;
}



Measured memory_bytes: 3748
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

K = INT()
S = input()

if len(S) <= K:
	print(S)
else:
	print(S[:K]+"...")


Measured memory_bytes: 10040
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <array>
#include <bitset>
#define rep(i,r) for(int i = 0; i < (r); i++)
#define pb push_back
#define all(a) a.begin(), a.end()
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int long long
#define uint unsigned long long
#define inf 0x3f3f3f3f3f3f3f3f
#define endl '\n'
using namespace std;

const int mn = 2010;
int S;
int dp[mn];
const int md = 1e9 + 7;

int f(int sum) {
    if (sum > S) return 0;
    if (sum == S) {
        return 1;
    }
    int& res = dp[sum];
    if (~res) return res;
    res = 0;
    for (int i = 3; i <= S - sum; i++) {
        res += f(sum + i);
        if (res >= md) res -= md;
    }
    return res;
}

signed main() {
    fastio;
    cin >> S;

    memset(dp, -1, sizeof dp);
    int res = f(0);
    
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3188
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int K;
bool vis[100005];
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> K;
  deque<pair<int, int> > Q;
  Q.push_back({1, 1});
  while(!Q.empty()) {
    auto top = Q.front(); Q.pop_front();
    int v = top.first;
    int cost = top.second;
    if(vis[v]) continue;
    vis[v] = true;
    if(v == 0) {
      cout << cost << endl;
      break;
    }
    Q.push_back({(v + 1) % K, cost + 1});
    Q.push_front({(v * 10) % K, cost});
  }
  return 0;
}

Measured memory_bytes: 1152
#include<iostream>
#include<string>

using namespace std;

int main(){
  string s;
  cin >> s;
  string str = "CODEFESTIVAL2016";
  int num = 0;
  for(int i = 0;i < str.size();i++){
    if(s[i] != str[i]){
      num++;
    }
  }
  cout << num << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

int GCD(int x, int y) {
    if (x % y == 0) return y;
    return GCD(y, x % y);
}

int main() {
    int N, X;
    cin >> N >> X;
    vector<int> x(N);
    rep(i, N) cin >> x[i];
    
    int ans = abs(X - x[0]);
    REP(i, N) {
        ans = GCD(ans, abs(X - x[i]));
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

using ll = long long;
using ld = long double;
using vi = vector<ll>;
using vvi = vector<vi>;

#define all(a) a.begin(), a.end()
#define mp make_pair
#define pb push_back

void solve() {
    int n; cin >> n;
    int k; cin >> k;
    vector<ll> a(n);
    for (auto &i : a) cin >> i;
    
    vector<pair<ll, ll>> kek;
    for (int i = 0; i < n; i++) {
        int sign = 0;
        if (a[i] > 0) sign = 1;
        if (a[i] < 0) sign = -1;
        kek.push_back({abs(a[i]), sign});
    } 

    sort(all(kek));
    reverse(all(kek));
    int cntp = 0, cntm = 0, cntn = 0;
    for (int i = 0; i < k; i++) {
        if (kek[i].second == -1) cntm++;
        if (kek[i].second == 1) cntp++;
        if (kek[i].second == 0) cntn++;
    }
    if (cntn > 0) {
        cout << 0;
        return;
    }

    ll m = 1e9 + 7;

    if (cntm % 2 == 0) {
        ll res = 1;
        for (int i = 0; i < k; i++) {
            res *= kek[i].first;
            res %= m;
        }
        cout << res;
        return;
    }

    bool change_to_p = 0;
    ll t1 = 0, t2 = 0;

    bool change_to_m = 0;
    ll q1 = 0, q2 = 0;

    bool can_zero = 0;

    for (int i = k; i < n; i++) {
        if (!change_to_p && kek[i].second == 1) {
            ll ind = -1;
            for (int j = 0; j < k; j++) {
                if (kek[j].second == -1) ind = j;
            }
            change_to_p = 1;
            t1 = ind, t2 = i;
        } else if (!change_to_m && kek[i].second == -1) {
            if (cntp > 0) {
                
                ll ind = -1;
                for (int j = 0; j < k; j++) {
                    if (kek[j].second == 1) ind = j;
                }
                change_to_m = 1;
                q1 = ind, q2 = i;
            }
        } else if (kek[i].second == 0) {
            can_zero = 1;
        }
    }

    if (change_to_m || change_to_p) {
        ll v1 = -1, v2 = -1;
        if (change_to_p && (!change_to_m || kek[t2].first * kek[q1].first > kek[q2].first * kek[t1].first)) {
            v1 = t1, v2 = t2;
        } else {
            v1 = q1, v2 = q2;
        }
        ll res = 1;
        for (int i = 0; i < n; i++) {
            if ((i < k && i != v1) || i == v2) {
                res *= kek[i].first;
                res %= m;
            }
        }
        cout << res;
        return;
    }

    if (can_zero) {
        cout << 0;
        return;
    }

    ll res = 1;
    for (int i = n - 1; i > n - k - 1; i--) {
        res *= kek[i].first;
        res %= m;
    }
    res = (m - res) % m;
    cout << res;

}

int main() {
    solve();
}

Measured memory_bytes: 9020
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int main()
{
	ll a,b,x;
	while(cin>>a>>b>>x)
	{
		ll ans1=b/x;
		ll ans2=max(a-1,(ll)0)/x;
		if(a==0)
		ans1++;
		cout<<ans1-ans2<<"\n";	
	}
	return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
using namespace std;

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (ll)(m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD1 = 1e9+7;
const ll MOD9 = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>&p){
  return os << p.first << " " << p.second;
}
//mt19937 mt(chrono::steady_clock::now().time_since_epoch().count());

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  ll a,b,c,k;cin>>a>>b>>c>>k;
  if(a+b>=k)cout<<min(a,k)<<endl;
  else cout<<a-(k-a-b)<<endl;
  return 0;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define vll vector<ll>
#define ub upper_bound
#define lb lower_bound
#define all(v) ((v).begin()),((v).end())
#define ff first
#define ss second
#define mp make_pair
#define pll pair<ll,ll> 
#define fo(i,n) for(ll i=0;i<n;i++)
ll mod1 = 1e9 + 7;
ll mod2 = 998244353;

ll power(ll x,ll y){ll z=1;while(y>0){if(y%2)z=(z*x);x =(x*x) ;y/=2;}return z;}
ll gcd(ll a,ll b){if(a<b) return gcd(b,a);if(b==0) return a;return gcd(b,a%b);} 
ll min(ll a,ll b){if(a<b)return a;return b;}
ll max(ll a,ll b){if(a>b)return a;return b;}







int main(){
	ll n;
	cin>>n;
	ll a = n/500;
	ll b = (n%500)/5;
	cout<<a*1000 + b*5 <<endl;

    
	
}

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

int main(){
    string s, t;
    cin >> s;
    cin >> t;
    int cnt = 0;
    for (int i = 0; i < t.size(); i++){
        if (s[i] != t[i]){ cnt++; }
    }

    cout << cnt << endl;
}

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

using namespace std;

#define REP(i,n)	for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPS(i,s,n)	for(int i=(s), i##_len=(n); i<i##_len; ++i)

#define ALL(obj)	(obj).begin(),(obj).end()

typedef unsigned int 			uint;
typedef unsigned long long int	ull;
typedef long long int 			ll;

typedef pair<int,int>			P;
typedef vector<int>				V;
typedef vector<V>				VV;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define LINF		((ll)1 << 63 -1)
#define INF 		(1<<29)
#define MINF		-2000000007
#define MAX 		205

const int MOD = 1e9+7;
// テンプレ終了
//====================================================================//



//
int main(){
	string S,T;cin>>S>>T;

	V R(26,-1),RD(26,-1);

	int flag = true;
	REP(i,S.size()){
		if(R[S[i]-'a'] >= 0){
			if(R[S[i]-'a']!=T[i]-'a'){flag=false;break;}
		}else
			R[S[i]-'a'] = T[i]-'a';
		if(RD[T[i]-'a'] >= 0){
			if(RD[T[i]-'a']!=S[i]-'a'){flag=false;break;}
		}else
			RD[T[i]-'a'] = S[i]-'a';
	}

	cout << (flag ? "Yes" : "No") << endl;


	return 0;
}




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

int main(){
  int h, n; cin >> h >> n;
  int res = 0;
  for(int i=0; i<n; ++i){
    int x; cin >> x;
    res += x;
  }
  if(h > res) cout << "No" << endl;
  else cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
//#include<windows.h>
//#include<cstring>
//#include<algorithm>
//#include<sec_api/stdio_s.h>
//#include<structuredquerycondition.h>
//#include<string>
#include<set>
//#define R register
//#define A 10010
//#pragma GCC optimize(2)
//#define mswap(a,b) ((&(a)==&(b)) or \
//					(((a)-=(b)),((b)+=(a)),((a)=(b)-(a))))

using namespace std;

/*inline void Pcyan()
{
	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
	FOREGROUND_INTENSITY|FOREGROUND_GREEN|FOREGROUND_BLUE);
}
inline char GETCHAR()
{
	static char buf[A],*p1=buf,*p2=buf;
	return p1==p2 and (p2=(p1=buf)+fread(buf,1,A,stdin),p1==p2)?EOF:*p1++;
}
template <class T> void read(T &x)
{
	x=0;int flag=0;char ch=GETCHAR();
	while(!isdigit(ch)) {flag|=ch=='-',ch=GETCHAR();}
	while(isdigit(ch)) {x=(x<<3)+(x<<1)+(ch^48);ch=GETCHAR();}
	x=flag?-x:x;
}
inline void write(int x)
{
	if(x<0) {putchar('-'),x=-x;}
	if(x>9) write(x/10);
	putchar(x%10+48);
}
inline void swap(int a,int b){a^=b^=a;}
inline int cmp(unsigned int a,unsigned int b)
{
	#define _M (1<<31)
	return (a^b) and
		!(((a&_M)^(b&_M)) and (b&_M)) and
		(((a&_M)^b&_M) and (a&_M) or cmp(a<<1,b<<1));
	#undef _M
}
inline int min(int x,int y){return y+((x-y)&((x-y)>>(sizeof(int)*CHAR_BIT-1)));}
inline int max(int x,int y){return x-((x-y)&((x-y)>>(sizeof(int)*CHAR_BIT-1)));}*/
set<int> s;
int n,a;

int main()
{
//	Pcyan();
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a;
		if(s.end()==s.find(a))
		  s.insert(a);
		else s.erase(a);
	}
	cout<<s.size()<<'\n';
}

Measured memory_bytes: 4864
import sys
if sys.version_info[0] == 2:
    input = raw_input
sys.setrecursionlimit(2 ** 31 -1)

res = None
G = None

def dfs(jibun_v, p, jibun_c):
    global res
    global G

    res[jibun_v] = jibun_c
    #print(jibun_v, p, jibun_c)

    tonari_nodes = G[jibun_v]
    for tonari_v, w in tonari_nodes:
        #if tonari_v == p: # only no loop
        #if tonari_v == p or res[tonari_v] != -1:
        if res[tonari_v] != -1:
            continue

        else:
            if w % 2 == 0:
                tonari_c = jibun_c
            else:
                tonari_c = 1 - jibun_c

            dfs(tonari_v, jibun_v, tonari_c)
    

def main():
    N= int(input())

    global G
    G = [[] for _ in range(N)]

    for i in range(N-1):
        u, v, w = map(int, input().split(" "))
        u -= 1
        v -= 1
        w = w % 2
        G[u].append([v, w])
        G[v].append([u, w])

    global res
    res = [-1 for _ in range(N)]
    
    jibun_v = 0
    p = -1
    jibun_c = 0
    dfs(jibun_v, p, jibun_c)

    for i in range(N):
        print(res[i])

main()
        

Measured memory_bytes: 82356
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include "bits/stdc++.h"

#define REP(i,x,y) for(ll i=(x);i<(y);i++)
#define RREP(i,x,y) for(ll i=(ll)(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
//#define int long long

using namespace std;

// conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

#define dump(x)  cout << #x << " = " << (x) << endl
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

typedef long long ll;

const ll MOD = 1e9 + 7;

class CPoll {
public:
    void solve(std::istream& in, std::ostream& out) {
        int N;
        in >> N;
        vector<string> s(N);
        REP(i,0,N) in >> s[i];
        map<string, int> cnt;
        REP(i,0,N) cnt[s[i]]++;
        int maxCnt = 0;
        REP(i,0,N) maxCnt = max(maxCnt, cnt[s[i]]);
        for (const auto& p : cnt) {
            if (p.second == maxCnt) {
                out << p.first << "\n";
            }
        }
    }
};


signed main() {
    CPoll solver;
    std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 26752