akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCoder
{
  public class Program
  {
    public static void Main(string[] args)
    {
      new Program().Solve(new ConsoleInput(Console.In, ' '));
    }

    public void Solve(ConsoleInput cin)
    {
      var s = cin.Read;
      char[] chrAry = s.ToCharArray();
      for (int i = 1; i <= chrAry.Length; ++i)
      {
        chrAry[i - 1] = 'x';
      }
      WriteLine(chrAry);
    }
  }

  public class ConsoleInput
  {
    private readonly System.IO.TextReader _stream;
    private char _separator = ' ';
    private Queue<string> inputStream;
    public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
    {
      this._separator = separator;
      this._stream = stream;
      inputStream = new Queue<string>();
    }
    public string Read
    {
      get
      {
        if (inputStream.Count != 0) return inputStream.Dequeue();
        string[] tmp = _stream.ReadLine().Split(_separator);
        for (int i = 0; i < tmp.Length; ++i)
          inputStream.Enqueue(tmp[i]);
        return inputStream.Dequeue();
      }
    }
    public string ReadLine { get { return _stream.ReadLine(); } }
    public int ReadInt { get { return int.Parse(Read); } }
    public long ReadLong { get { return long.Parse(Read); } }
    public double ReadDouble { get { return double.Parse(Read); } }
    public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
    public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
    public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
  }
}

Measured memory_bytes: 11220
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

	static FastReader input = new FastReader();
	static PrintWriter out = new PrintWriter(System.out);

	public static void main(String[] args) throws IOException {

		int n = input.nextInt();
		int d = input.nextInt();

		int[][] a = new int[n][d];

		for (int i = 0; i < n; i++) {
			for (int j = 0; j < d; j++) {
				a[i][j] = input.nextInt();
			}
		}

		int total = 0;
		for (int i = 1; i < n; i++) {
			for (int j = 0; j < i; j++) {
				double sum = 0;
				for (int k = 0; k < d; k++) {
					int x1 = a[i][k];
					int x2 = a[j][k];
					int x = x1 - x2;
					sum += (x * x);
				}
				sum = Math.sqrt(sum);
				int sumInt = (int) Math.round(sum);
				if (Math.abs(sum - sumInt) < 1e-9) {
					total++;
				}
			}
		}

		out.println(total);

		out.flush();
	}

	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

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

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

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

		double nextDouble() throws NumberFormatException, IOException {
			return Double.parseDouble(next());
		}

		String nextLine() throws IOException {
			String str = "";
			str = br.readLine();
			return str;
		}
	}

	static class con {
		static int IINF = (int) 1e9;
		static int _IINF = (int) -1e9;
		static long LINF = (long) 1e15;
		static long _LINF = (long) -1e15;
		static double EPS = 1e-9;
	}

	static class Triple implements Comparable<Triple> {
		int x;
		int y;
		int z;

		Triple(int x, int y, int z) {
			this.x = x;
			this.y = y;
			this.z = z;
		}

		@Override
		public int compareTo(Triple o) {
			if (x == o.x && y == o.y)
				return z - o.z;
			if (x == o.x)
				return y - o.y;
			return x - o.x;
		}
	}

	static class Pair implements Comparable<Pair> {
		int x;
		int y;

		Pair(int x, int y) {
			this.x = x;
			this.y = y;

		}

		@Override
		public int compareTo(Pair o) {
			if (x == o.x)
				return y - o.y;
			return x - o.x;
		}
	}

	static void shuffle(int[] a) {
		for (int i = 0; i < a.length; i++) {
			int r = i + (int) (Math.random() * (a.length - i));
			int tmp = a[r];
			a[r] = a[i];
			a[i] = tmp;
		}
	}

}

Measured memory_bytes: 19668
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1000000007;
const int IINF = INT_MAX;
const ll MAX_N = ll(1e5 + 5);
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i,n) for (int i = n; i >=0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define ALL(v) (v).begin(), (v).end()

int n, k, w[100005];

bool f(int m){
    int num = 0;
    REP(i,k){
        int ws = 0;
        while(num < n && ws+w[num] <= m){
            ws += w[num];
            num++;
        }
    }
    return num == n;
}

int main() {
    
    cin >> n >> k;
    REP(i,n)cin >> w[i];

    int ok = IINF/2, ng = 0;
    while(abs(ok-ng)>1){
        int mid = (ok + ng)/2;
        if(f(mid))ok = mid;
        else ng = mid;
    } 
    cout << ok << endl;
    return 0;
}



Measured memory_bytes: 3484
using System;
using System.Linq;
 
public class Test
{
	public static void Main()
	{
		
		int n = int.Parse(Console.ReadLine());
		var a = Console.ReadLine().Split().Select(y => long.Parse(y)).ToArray();
		int counter = 0;
		long ans = 1;
		long atcoder = 1000000000000000000;
		
		for(int i=0;i!=n;i++){
			if(a[i]==0){
				counter++;
				break;
			}
		}
		if(counter!=0){
			Console.WriteLine("0");
		}else{
			for(int j=0;j!=n;j++){
				if(ans>atcoder/a[j]){
						ans = -1;
						break;
					}	
             	 ans *= a[j];

			}
			Console.WriteLine(ans);
		}
		
	}
}


Measured memory_bytes: 41460
#include <iostream>
#include <algorithm>
#include <vector>

#define SIZE 100

int n, l;
std::vector< std::string > vec(SIZE);

int main() {
    std::cin >> n >> l;
    for (int i=0; i<n; ++i) {
        std::cin >> vec[i];
    }
    std::sort(vec.begin(), vec.begin()+n);
    for (int i=0; i<n; ++i) std::cout << vec[i];
    std::cout << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <string.h>
using namespace std;

int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	int n,m;
	cin>>n>>m;
	vector<int> v;
	v.push_back(m);
	for(int i=0;i<n;i++){
		int a;
		cin>>a;
		v.push_back(a);
	}
	sort(v.begin(),v.end());
	v.erase(unique(v.begin(),v.end()),v.end());
	int ans=0;
	for(int i=1;i<v.size();i++){
		ans=__gcd(ans,v[i]-v[i-1]);
	}
	cout<<ans<<endl;
	return 0;
}
/*
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <string.h>
using namespace std;
int n,m;
int a[100010];
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	cin>>n>>m;
	for(int i=0;i<n;i++)cin>>a[i];
	vector<int> v;
	v.push_back(abs(m-a[0]));
	for(int i=0;i<n-1;i++)v.push_back(abs(a[i]-a[i+1]));
	int ans=v[0];
	for(int i=1;i<v.size();i++)ans=__gcd(ans,v[i]);
	cout<<ans<<endl;
	return 0;
}
*/

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

const int N = 1e6 + 6;

int main() {
	int n;
	cin >> n;
	
	multiset<int> tails;
	
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		auto it = tails.lower_bound(a);
		if (it == tails.begin()) {
			tails.insert(a);
		} else {
			it--;
			if (*it < a) {
				tails.erase(it);
				tails.insert(a);
			} else
				tails.insert(a);
		}
	}
	cout << tails.size();
}



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

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

    vector<int> a(N, 0);
    for (auto &c: a) {
        cin >> c;
    }

    sort(a.begin(), a.end());
    int numHappy = 0;
    for (size_t i=0; i<a.size(); ++i) {
        x -= a[i];
        if (x >= 0)  ++numHappy;
        else break;
    }
    if (x > 0) --numHappy;
    cout << numHappy;
}


Measured memory_bytes: 3604
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int i = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int i = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define MP make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1 << 30;
const ll LINF = 1LL << 61;
const int MOD = 1e9 + 7;

int main() {
    string O, E;
    cin >> O >> E;
    string res = "";
    rep(i, O.size()) {
        res += O[i];
        if(i < E.size())
            res += E[i];
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;


public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int tmp;
		if (a > b) {
			tmp = a;
			a = b;
			b = tmp;
		}
		if (b > c) {
			tmp = b;
			b = c;
			c = tmp;
		}
		if (a > b) {
			tmp = a;
			a = b;
			b = tmp;
		}
		System.out.println(a + " " + b + " " + c);
	}
}

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

using namespace std;

#define X first
#define Y second
#define ll long long
#define inf (ll)1e18
const int mod = (int)1e9 + 7;
#define all(x) x.begin(), x.end()

const int N = 1000060;
const int MX = 200020;

int center[2222];
double h[2222];

int main(){
/*
     ___     ___
    (^_^)   (^_^)
   /( | )\ /( | )\
     | |     | |
*/
    cin.tie(0);
    cin.sync_with_stdio(0);

    #ifdef Cyborg101
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

     int n;
     cin >> n;

     cout << 24 + (24 - n) << endl;

   	return 0;
}

Measured memory_bytes: 256
#include<cstring>
#include<iostream>
#include<algorithm>
#include<string>
#define rep(i,n) for (int i = 1; i <= (n); ++i)
using ll = long long;
using namespace std;

int gcd(int x, int y) {
    return (x%y)? gcd(y, x % y): y;
}

int main() {
    int k;
    cin >> k;
    ll cnt = 0;
    rep(i, k) {
        rep(j, k) {
            rep(z, k) {
                int t = gcd(i, j);
                cnt += gcd(t, z);
            }

        }
    }
    cout << cnt << endl; 
    return 0;
}

Measured memory_bytes: 3636
N, X, Y = map(int, input().split())
d = [[0] * (N+1) for _ in range(N)]
ans = [0] * N 

for i in range(1, N+1):
  for j in range(i+1, N+1):
    a = j - i
    b = 1 + abs(i - X) + abs(j - Y) 
    d[i][j] = min(a, b)
    ans[d[i][j]] += 1

for i in range(1, N):
  print(ans[i])

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

int main(int argc, const char * argv[]) {
    string S;
    cin >> S;
    string ex[] = {"maerd","remaerd","esare","resare"};
    reverse(S.begin(),S.end());
    int temp = 0;
    bool flag = true;
    while(temp < S.length()){
        
        if(ex[0] == S.substr(temp,5)||ex[2] == S.substr(temp,5)){
            temp += 5;
        }else if(ex[1] == S.substr(temp,7)){
            temp += 7;
        }else if(ex[3] == S.substr(temp,6)){
            temp += 6;
        }else{
            flag = false;
            break;
        }
        
    }
    if(flag){
        cout << "YES";
    }else{
        cout << "NO";
    }
    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using ll  = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define erep(e,v) for(auto && e :v)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T &a){int t = 0;for(auto itr :a){if(t++)cout << " "; cout << itr;} cout <<endl; }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
signed main(){
    //    std::ios_base::sync_with_stdio(false);
    //    cin.tie(NULL);
    string s;
    cin >> s;
    int k;
    cin >> k;
    bool res = true;
    for(auto e : s){
        --k;
        if(e != '1') res = false;
        if(k == 0 and res  and e == '1') return puts("1")*0;
        else if(!res)return cout << e,0;
    }
}




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


public class Main {
	static int a1[]= {0,-1,0,1};
	static int b1[]= {-1,0,1,0};
	private static         Scanner sc = new Scanner(System.in);
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );
		
		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<String> cc = new ArrayList<>(n);
	//Collections.sort(list);
	//Array.sort(list);   cc.contains(tmp)
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");//1 1 2 3 5
	static int K,N;
	static long mod =1000000007;

	public static void main(String[] args) {
		int a=sc.nextInt();
		int b=sc.nextInt();
		if(a<10&&b<10) {
			p(a*b);
		}else p(-1);
		
		
	}
	//N==S
	//E==W
//83 S 
	//69E
	//78N
	//87W
	
	//static ArrayList<Integer> cc = new ArrayList<>(10001);
	
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p() {System.out.println();};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	public static int gcd(int a, int b) {
        return b == 0 ? a: gcd(b, a % b);
	}
	static String nextPermutation(String s) {
		ArrayList<Character> list=new ArrayList<>();
		for(int i=0;i<s.length();i++) {
			list.add(s.charAt(i));
		}
		int pivotPos=-1;
		char pivot=0;
		for(int i=list.size()-2;i>=0;i--) {
			if(list.get(i)<list.get(i+1)) {
				pivotPos=i;
				pivot=list.get(i);
				break;
			}
		}
		if(pivotPos==-1&&pivot==0) {
			return "Final";
		}
		int L=pivotPos+1,R=list.size()-1;
		
		
		
		int minPos=-1;
		char min =Character.MAX_VALUE;
		
		for(int i=R;i>=L;i--) {
			if(pivot<list.get(i)) {
				if(list.get(i)<min) {
					min=list.get(i);
					minPos=i;
				}
			}
		}
		
		Collections.swap(list, pivotPos, minPos);
		Collections.sort(list.subList(L, R+1));
		
		
		StringBuilder sb=new StringBuilder();
		for(int i=0;i<list.size();i++) {
			sb.append(list.get(i));
		}
		return sb.toString();
	}
}
	


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

int main(void){
    int n = 0; 
    int d = 0;

    scanf("%d%d", &n, &d);

    if(n % (2 * d + 1) == 0){
        printf("%d\n", n / (2 * d + 1));
    }else{
        printf("%d\n", n / (2 * d + 1) + 1);
    }
    return 0;

} 


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
    int n,a,b,x=0,y=0;
    cin>>n;
    a=n/100;
    b=n-a*100;
    if(1<=b&&b<=12) x++;
    if(1<=a&&a<=12) y++;
    if(x){
        if(y) cout<<"AMBIGUOUS";
        else cout<<"YYMM";
    }
    else{
        if(y) cout<<"MMYY";
        else cout<<"NA";
    }
}

Measured memory_bytes: 256
import bisect


n, q = map(int, input().split())
c = list(map(int, input().split()))
c = sorted(c)

for i in range(q):
    query = int(input())
    num = query
    ans = 0
    while True:
        if c[-1] + query < num:
            break
        end = bisect.bisect_left(c, num)
        if end - 1 >= 0:
            ans = max(ans, c[end-1] % query)
        num += query
    print(ans)


Measured memory_bytes: 40012
#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define inf 1000000007
#define N 305
using namespace std;

typedef long long ll;
typedef pair < ll , ll > ii;

ll n, ans, ata[N], a[N][N], d[N];
vector < pair < ll , ii > > b;
vector < ii > g[N];
priority_queue < ii > q;

ll sp(ll x, ll y){
	for(ll i = 1; i <= n; i++)
		d[i] = inf;
	d[x] = 0;
	q.push(mp(0, x));
	while(!q.empty()){
		ll node = q.top().nd;
		q.pop();
		for(ll i = 0; i < g[node].size(); i++)
			if(d[g[node][i].st] > d[node] + g[node][i].nd){
				d[g[node][i].st] = d[node] + g[node][i].nd;
				q.push(mp(-d[g[node][i].st], g[node][i].st));
			}
	}
	return d[y];
}

ll atabul(ll x){return ata[x] = (ata[x] == x)?x:atabul(ata[x]);}

int main() {
	// freopen("in.txt", "r", stdin);
	// freopen("outt.txt", "w", stdout);
	scanf("%lld",&n);
	for(ll i = 1; i <= n; i++)
		for(ll j = 1; j <= n; j++){
			scanf("%lld",&a[i][j]);
			if(i < j)
				b.pb(mp(a[i][j], mp(i, j)));
		}
	for(ll i = 1; i <= n; i++)
		ata[i] = i;
	sort(b.begin(), b.end());
	for(ll i = 0; i < b.size(); i++){
		ll x = b[i].nd.st;
		ll y = b[i].nd.nd;
		ll xx = atabul(x);
		ll yy = atabul(y);
		if(xx != yy){
			ans += b[i].st;
			ata[xx] = yy;
			g[x].pb(mp(y, b[i].st));
			g[y].pb(mp(x, b[i].st));
			continue;
		}
		ll dd = sp(x, y);
		if(dd < b[i].st){
			puts("-1");
			return 0;
		}
		if(dd == b[i].st)
			continue;
		ans += b[i].st;
		g[x].pb(mp(y, b[i].st));
		g[y].pb(mp(x, b[i].st));
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 2296
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define MOD (int) (1e9+7)
#define INF (int) 2e9
#define LLINF (ll) 2e18

int dp[1<<13][1005];

int main(){
    rep(i, 1<<13)rep(j, 1005) if(i!=0)dp[i][j] = INF;
    
    int n, m;
    cin >> n >> m;

    rep(i, m){
        int a, b;
        cin >> a >> b;
        int c = 0;
        rep(_, b){
            int tc; cin >> tc;
            c += 1<<(tc-1);
        }

        rep(j, 1<<n) dp[j][i+1] = dp[j][i];
        rep(j, 1<<n){
            dp[j | c][i+1] = min(dp[j | c][i+1], dp[j][i] + a);
        }
    }

    int ans = dp[(1<<n) -1][m];
    if(ans!=INF){
        cout << ans << endl;
    }else{
        cout << -1 << endl;
    }
    
    // printf("%d\n", N);
    return 0;
}

Measured memory_bytes: 32512
#include<iostream>

using namespace std;

int main(){

  int n;
  int data[10001];
  for(int i = 0; i <= 10000; i++) data[i] = 1;


  for(int i = 2; i <= 100; i++){
    for(int j = i*2; j <= 10000; j+=i){
      data[j] = 0;
    }
  }
  while(1){
    cin >> n;
    if(n == 0) break; 
    for(int i = n; i >= 5; i--){
      if(data[i] == 1 && data[i-2] == 1){
	cout << i-2 << " " << i << endl;
	break;
      }
    }
  }
  return 0;

}

Measured memory_bytes: 0
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<pair<int, int> > vpii;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
#define INF 0x3f3f3f3f
#define MOD 998244353
#define EPSILON 0.00001
#define f first
#define s second
#define pb push_back
#define mp make_pair
 
#define FOR(i, a, b) for (int i=(a); i<=(signed)(b); i++)
#define F0R(i, a) for (int i=0; i<(signed)(a); i++)
#define RFOR(i, a, b) for (int i=(a); i >= b; i--)

#define MN 100005
int n;

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

    cin >> n;
    cout << (n-1)/2;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define INF 1000000001

int main(){
  int n;
  cin >> n;
  ll a, t;
  cin >> a >> t;
  for(int j=0;j<n-1;j++){
    ll a2, t2;
    cin >> a2 >> t2;
    ll i1=1, i2=1, i;
    if(a <= a2 && t <= t2){
      i = 1;
    }else if (a <= a2){
      i1 = 1;
      if (t % t2 == 0){
        i2 = t / t2;
      }else{
        i2 = t / t2 + 1;
      }
    }else if (t <= t2){
      i2 = 1;
      if (a % a2 == 0){
        i1 = a / a2;
      }else{
        i1 = a / a2 + 1;
      }
    }else{
      if (a % a2 == 0){
        i1 = a / a2;
      }else{
        i1 = a / a2 + 1;
      }
      if (t % t2 == 0){
        i2 = t / t2;
      }else{
        i2 = t / t2 + 1;
      }
    }
    i = max(i1, i2);
    a = a2*i;
    t = t2*i;
  }
  cout << (a+t) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <queue>
using namespace std;
#define loop(i,N) for(ll (i)=0; (i)<(N);++(i))
struct TEMP_OMAZINAI_ { TEMP_OMAZINAI_() { std::ios::sync_with_stdio(false); std::cin.tie(0); } } TEMP__omazinai_instance__;
#define INF ((1LL<<61) + (1<<29))
#define YesNo(x) {std::cout << ((x)?"Yes":"No") << std::endl;}
#define YESNO(x) {std::cout << ((x)?"YES":"NO") << std::endl;}
#define OddEven(x) {std::cout << ((x)%2?"Odd":"Even") << std::endl;}
#define ODDEVEN(x) {std::cout << ((x)%2?"ODD":"EVEN") << std::endl;}
typedef long long int ll;
ll my_gcd(ll a, ll b) { return b ? my_gcd(b, a%b) : a; };
void TEMP_INPUT_IMPL_() {};
template <class T, class... Args> void TEMP_INPUT_IMPL_(T& dest, Args&... args) { cin >> dest; TEMP_INPUT_IMPL_(args...); }
void TEMP_OUTPUT_IMPL_() {};
template <class T, class... Args> void TEMP_OUTPUT_IMPL_(T dest, Args... args) { cout << dest << (sizeof...(Args) ? " " : ""); TEMP_OUTPUT_IMPL_(args...); }
#define in(type, ...) type __VA_ARGS__; TEMP_INPUT_IMPL_(__VA_ARGS__)
#define in_v(type, name, cnt) vector<type> name(cnt); loop(i, cnt) cin >> name[i];
#define sort_v(v) std::sort(v.begin(), v.end())
#define unique_v(v) v.erase(std::unique(v.begin(), v.end()), v.end()) //必ずソート後に実行
#define out(...) (TEMP_OUTPUT_IMPL_(__VA_ARGS__), std::cout<<std::endl)
#define set_fix(x) ((std::cerr<<std::fixed<<std::setprecision(x)),(std::cout<<std::fixed<<std::setprecision(x)))
//小さい方に寄る
#define space_op(x, y, a, b, c) ([](auto x_, auto y_, auto a_, auto b_, auto c_){if(x_<y_)return a_;if(x_>y_)return c_;return b_;}(x,y,a,b,c))
#define space_out(x, y, a, b, c) out(space_op(x, y, a, b, c))

// ^^^ Template ^^^ //


int main() {
	in(string, s_);
	auto forall = [](string s, char c) {
		for(char t : s)
			if (t != c)
				return false;
		return true;
	};
	ll min_cnt = INF;
	for (char c = 'a'; c <= 'z'; ++c) {
		ll cnt = 0;
		string s = s_;
		while (!forall(s, c)) {
			string s2;
			loop(i, (ll)s.size() - 1)
				s2.push_back(s[i + 1] == c ? c : s[i]);
			s = s2;
			++cnt;
		}
		min_cnt = min(min_cnt, cnt);
	}
	cout << min_cnt << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main (void)
{
    int a,b,c;

    scanf("%d",&a);
    scanf("%d",&b);
    scanf("%d",&c);

    if (a+b != c && c+a != b && b+c != a){
        printf("No\n");}
    else {
        printf("Yes\n");
}
    return 0;

}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#define MAX 500000
using namespace std;

int H;
int A[MAX+1];
int parent(int i){
    i /= 2;
    return i;
}

int left(int i){
    i *= 2;
    return i;
}

int right(int i){
    i = 2 * i + 1;
    return i;
}

void maxHeapify(int A[], int i){
    int largest;
    int l = left(i);
    int r = right(i);
    //左の子、自分、右の子で値が最大のノードを選ぶ
    if(l <= H && A[l] > A[i]) largest = l;
    else largest = i;
    if(r <= H && A[r] > A[largest]) largest = r;

    if(largest != i){
        swap(A[i], A[largest]);
        maxHeapify(A, largest);
    }
}

void buildMaxHeap(int A[]){
    for(int i = H/2; i > 0; i--){
        maxHeapify(A, i);
    }
}

int main(){
    cin >> H;
    
    for(int i = 1; i <= H; i++){
        cin >> A[i];
    }
    buildMaxHeap(A);
    for( int i = 1; i <= H; i++){
        cout << " " << A[i];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 5048
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

#define INF	(1 << 30)

#define MAX_N	(100)
#define MAX_M	(1000)

/* typedef */

typedef vector<int> vi;
typedef pair<int,int> pii;

/* global variables */

int dists[MAX_N][MAX_M + 1];
int edges[MAX_N][MAX_N];
vi nbrs[MAX_N];

/* subroutines */

bool operator<(const pii u0, const pii u1) {
  return dists[u0.first][u0.second] < dists[u1.first][u1.second];
}

/* main */

int main() {
  int n, m, c;

  for (;;) {
    cin >> n >> m >> c;
    if ((n | m | c) == 0) break;

    for (int i = 0; i < n; i++) {
      for (int j = 0; j <= m; j++) dists[i][j] = INF;
      for (int j = 0; j < n; j++) edges[i][j] = 0;
      nbrs[i].clear();
    }

    for (int i = 0; i < m; i++) {
      int fi, ti, ci;
      cin >> fi >> ti >> ci;
      fi--;
      ti--;
      edges[fi][ti] = ci;
      nbrs[fi].push_back(ti);
    }
    //p edges
    //p nbrs

    dists[0][0] = 0;

    priority_queue<pii> q;
    q.push(pii(0, 0));

    int min_k = m + 1;
  
    while (! q.empty()) {
      pii u = q.top();
      q.pop();

      int ui = u.first;
      int uk = u.second;
      int ud = dists[ui][uk];
    
      if (ui == n - 1) {
	if (ud <= c && min_k > uk) min_k = uk;
	continue;
      }

      for (int j = 0; j < nbrs[ui].size(); j++) {
	int vi = nbrs[ui][j];

	if (uk < m && dists[vi][uk + 1] > ud) {
	  //if (dists[vi][uk + 1] >= INF) q.push(pii(vi, uk + 1));
	  q.push(pii(vi, uk + 1));
	  dists[vi][uk + 1] = ud;
	}

	int nvd = ud + edges[ui][vi];
	if (dists[vi][uk] > nvd) {
	  //if (dists[vi][uk] >= INF) q.push(pii(vi, uk));
	  q.push(pii(vi, uk));
	  dists[vi][uk] = nvd;
	}
      }
    }

    //#p dists[n - 1]
    cout << min_k << endl;
  }

  return 0;
}

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

#define rep(i,n) for(ll i=0;i<(n);++i)
#define reps(i,n) for(ll i=1;i<=(n);++i)
using ll = long long;
using str = string;
constexpr long long INF = (1LL<<60);
constexpr long long MOD = (1e9+7);
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
template<class T>inline bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
inline void dump(){cout<<endl;}
template<class Head,class... Tail>inline void dump(Head&& head, Tail&&... tail){cout<<head<<", ";dump(forward<Tail>(tail)...);}
template<typename T>inline istream &operator>>(istream&input,vector<T>&v){for(auto &elemnt:v)input>>elemnt;return input;}
template<class T>vector<T> make_vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vec(size_t a, Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));}

main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout<<fixed<<setprecision(10);
  
  int n,k;
  cin>>n>>k;
  vector<ll> a(n);
  cin>>a;
  ll ans=0;
  rep(i,n)if(a[i]>=k)ans++;
  cout<<(ans)<<endl;


}


Measured memory_bytes: 1024
import sys

read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines


# mod=10**9+7
# rstrip().decode('utf-8')
# map(int,input().split())
import numpy as np

def main():
	n=int(input())
	X=list(map(int,input().split()))
	X=np.array(X)
	X.sort()
	ans=10**10
	
	for i in range(X[0],X[-1]+1,1):
		ans=min(ans,sum((X-i)**2))
	print(ans)
	
	
	
	
	
	
	
	
	
	
	
	
	
if __name__ == "__main__":
	main()


Measured memory_bytes: 12500
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
using namespace std;

int main(){
  long long a,b,tmp,r,x;
  cin >> a >> b;
  
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
  x = a * b;

  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  cout << x/b;
  
  return 0;
}

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

int main(void){
  long long int N ;
  std::cin >> N;
  std::vector<std::vector<long long>> tab;
  std::vector<std::vector<long long>> dp;
  for(int i=0;i<N;i++){
    std::vector<long long> tmp2;
    for(int j=0;j<3;j++){
      long long int tmp=0;
      std::cin >> tmp;
      tmp2.push_back(tmp);
    }
    tab.push_back(tmp2);
  }
  
  for(int i=0;i<N;i++){
    std::vector<long long> tmp;
    if(i==0){
      tmp.push_back(tab[i][0]);
      tmp.push_back(tab[i][1]);
      tmp.push_back(tab[i][2]);
    }else{
      tmp.push_back(std::max(dp[i-1][1],dp[i-1][2]) + tab[i][0]);
      tmp.push_back(std::max(dp[i-1][2],dp[i-1][0]) + tab[i][1]);
      tmp.push_back(std::max(dp[i-1][0],dp[i-1][1]) + tab[i][2]);
    }
    dp.push_back(tmp);
  }

  std::cout << *(std::max_element(dp[N-1].begin(), dp[N-1].end()));
  
  return 0;
}


Measured memory_bytes: 12336
# -*- coding: utf-8 -*-

# 入力を各変数に格納
x, y = map(int, input().split())

# キャンバスを2次元配列に格納
canvas = []
for i in range(x):
	canvas.append(list(input()))

for i in range(x):
	for j in range(y):
		# 対象マスが#の時はチェックする
		if canvas[i][j] == "#":
			# 左端以外
			if i != 0:
				# 左隣
				if canvas[i-1][j] == "#":
					continue
			# 右端以外
			if i != x-1:
				# 右隣
				if canvas[i+1][j] == "#":
					continue
			# 最上段以外
			if j != 0:
				# ひとつ上
				if canvas[i][j-1] == "#":
					continue
			# 最下段以外
			if j != y-1:
				# ひとつ下
				if canvas[i][j+1] == "#":
					continue
			# どの条件も当てはまらない→四方に#がない
			print("No")
			exit()
# 一度もNoを通らなければYes
print("Yes")

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
#include <deque>
#include <complex>

using namespace std;

/*
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
*/

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<long long, long long> pll;
typedef vector<pll> vpll;

typedef long double ld;
typedef vector<ld> vld;

typedef vector<bool> vb;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, n) for (ll i = 1; i <= (n); i++)
#define rrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, n) for (ll i = (n); i >= 1; i--)
#define all(v) (v).begin(), (v).end()

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

constexpr int INF = 1 << 30;
constexpr ll INFL = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-12;
ld PI = acos(-1.0);

void solve() {
    string s;
    cin >> s;
    ll n = s.size();
    ll ans = 1000;
    for(ll i = 0; i < n-2; i++) {
        chmin(ans, abs(stoll(s.substr(i, 3)) - 753));
    }
    cout << ans << endl;
    return;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}

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

int main(){
	std::vector<bool> isAvairable(101, false);

	for(int i=1; i<=9; i++)
		for(int j=1; j<=9; j++)
			isAvairable[i*j]= true;

	int n;
	std::cin>>n;

	if(isAvairable[n])
		std::cout<<"Yes"<<std::endl;
	else
		std::cout<<"No"<<std::endl;

	return 0;
}

Measured memory_bytes: 256
use proconio::input;
use proconio::marker::{Chars, Usize1};
use std::iter::Iterator;
use std::collections::*;
use std::cmp::*;
use itertools::Itertools;

#[allow(unused_macros)]
macro_rules! max {
    ($x:expr) => {
      $x
    };
    ($x:expr, $($xs:tt)+) => {
      max($x,max!($($xs)+))
    };
  }
  
  #[allow(unused_macros)]
  macro_rules! min {
    ($x:expr) => {
      $x
    };
    ($x:expr, $($xs:tt)+) => {
      min($x,min!($($xs)+))
    };
  }

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    input! {
    n: usize,
    mut h: [i64; n],
    }

    let mut maxh = h[0];
    let mut cnt = 0;
    for i in 1..n {
      if h[i] >= maxh {
        cnt +=1;
        maxh = h[i];
      }
    }
     println!("{}", cnt + 1);
}


Measured memory_bytes: 2152
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		int w[] = new int[n];
		
		// 計算
		int result = Integer.MAX_VALUE;
		int sum = 0;
		for(int i = 0; i < n; i++){
		    w[i] = sc.nextInt();
		    sum += w[i];
		}
		int temp = 0;
		for(int i = 0; i < n; i++){
		    temp += w[i];
		    result = min(result, abs((sum - temp) - temp));
		}
		
		// 出力
		System.out.println(result);
		
	}
}


Measured memory_bytes: 23508
#include<bits/stdc++.h>
using namespace std;
pair<int,int> X[200200];
int main()
{
  int N;
  cin>>N;
  for(int i=0;i<N;i++)
    cin>>X[i].second>>X[i].first;
  sort(X,X+N);
  int Time=0;
  for(int i=0;i<N;i++)
  {
    Time+=X[i].second;
    if(Time>X[i].first)
    {
      puts("No");
      return 0;
    }
  }
  puts("Yes");
  return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
typedef long long ll;

int gcd(ll a, ll b){
    if(a%b==0){
        return b;
    }else{
        return gcd(b, a%b);
    }
}

int main(){
    ll a,b;
    cin >> a >> b;
    if(a<b){
        swap(a,b);
    }
    cout << a*b/gcd(a,b);
    return 0;
}


Measured memory_bytes: 256
//~ while (clock()<=69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
//~ #pragma GCC optimize("Ofast")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//~ #pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define shandom_ruffle random_shuffle

using ll=long long;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
const int nax=1000*1007;

int n;

char wcz[nax];

ll wyn;

int main()
{
	scanf("%s", wcz+1);
	n=strlen(wcz+1);
	int ile=0;
	for (int i=1; i<=n; i++)
	{
		if (wcz[i]=='B')
			ile++;
		else
			wyn+=ile;
	}
	printf("%lld\n", wyn);
	return 0;
}


Measured memory_bytes: 384
PROGRAM march
      IMPLICIT NONE
      integer(16) :: n,ans=0
      character(10) :: s
      integer(16) :: i,j,k
      integer(16) :: m(5)
      
      m = 0
      read*,n
      do i = 1,n
        read*,s
        
        select case( s(1:1) )
        case( 'M' )
          m(1) = m(1) + 1
        case( 'A' )
          m(2) = m(2) + 1
        case( 'R' )
          m(3) = m(3) + 1
        case( 'C' )
          m(4) = m(4) + 1
        case( 'H' )
          m(5) = m(5) + 1
        end select
      end do
      
    !  print*,m
      
      do i=1,5
        do j = 1,5
          do k = 1,5
            if( i==j.or.j==k.or.k==i ) cycle
            if( i>j.or.j>k ) cycle
            ans = ans + m(i)*m(j)*m(k)
          end do
        end do
      end do
      
      print*,ans
      
      
      
      END PROGRAM

Measured memory_bytes: 768
/*
g++ -std=c++14 -o2 -Wall ABC.cpp -o .\ABC.out
.\ABC.out
*/

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

typedef long long ll;

int main(){
  int n;
  cin >> n;
  if (n % 2 == 0) cout << 0.5 << "\n";
  else cout << ((n/2+1)/(n*1.0d));
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <math.h>
#define PI 3.141592653589
using namespace std;

typedef struct{
	double x;
	double y;
}Pos;

void displayKoch(Pos, Pos, int, double rad);
void Koch(Pos*, Pos, Pos, double rad);

int main(){

	int n;
	Pos pos0, pos1;
	pos0.x = 0;
	pos0.y = 0;
	pos1.x = 100;
	pos1.y = 0;
	
	cin >> n;
	
	printf("%.8f %.8f\n",pos0.x,pos0.y);
	displayKoch(pos0, pos1, n, 0);
	printf("%.8f %.8f\n",pos1.x,pos1.y);
	
}

void displayKoch(Pos posA, Pos posB, int depth, double rad){
	
	if(depth >= 1){
		Pos positions[3];
		Koch(positions,posA,posB, rad);
		
		displayKoch(posA, positions[0], depth-1, rad);
		printf("%.8f %.8f\n",positions[0].x,positions[0].y);
		displayKoch(positions[0], positions[1], depth-1, rad+PI/3.0);
		printf("%.8f %.8f\n",positions[1].x,positions[1].y);
		displayKoch(positions[1], positions[2], depth-1, rad-PI/3.0);
		printf("%.8f %.8f\n",positions[2].x,positions[2].y);
		displayKoch(positions[2], posB, depth-1, rad);
	}
	
}

void Koch(Pos* positions, Pos posA, Pos posB, double rad){
	
	Pos s,t,u;
	double side, length;
	
	length = sqrt(pow(posB.x-posA.x,2)+pow(posB.y-posA.y,2));
	side = length / 3.0;
	
	s.x = posA.x + side * cos(rad);
	s.y = posA.y + side * sin(rad);
	t.x = s.x + side * cos(rad);
	t.y = s.y + side * sin(rad);
	u.x = s.x + side * cos(rad+PI/3.0);
	u.y = s.y + side * sin(rad+PI/3.0);
	
	positions[0] = s;
	positions[1] = u;
	positions[2] = t;
	
}

Measured memory_bytes: 1200
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long a, b, c, k;
  cin >> a >> b >> c >> k;
  if(k < a){
    cout << k <<endl;
  }

  else if( a+b >= k){
    cout << a << endl;
  }
  else{
    cout << a -k +a +b << endl;
  }
}

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

#include <math.h>
#include <stdlib.h>


#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

template<class T> inline bool chmin(T &a, T b) { if(a > b){ a = b; return true; } return false; }
template<class T> inline bool chmax(T &a, T b) { if(a < b){ a = b; return true; } return false; }

//INT_MAX	2,147,483,647 = 2*1.0e9

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int N; cin >> N;
    vector<ll> L(90,0);
    L[0] = 2;
    L[1] = 1;
    for(int i = 2; i < 87; i++) L[i] = L[i-1] + L[i-2];
    cout << L[N] << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define sqr(x) ((x)*(x))
#define mp make_pair
#define uint unsigned
#define int long long
#define PI pair<int,int>
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline int read(){
	int x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(int a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(int a){
    if(a<0){
    	a=-a; putchar('-');
	}
	write(a); puts("");
}
inline int rnd(int x){
	return rand()%x;
}
inline ull rnd(){
	return ((ull)rand()<<30^rand())<<4|rand()%4;
}
const int N=100005;
int n,dp[N],a[N],sum;
vector<int> v[N];
void GG(){
	puts("NO"); exit(0);
}
void dfs(int p,int fa){
	if(v[p].size()==1){
		dp[p]=a[p]; return;
	}
	int sum=0,mx=0;
	for(unsigned i=0;i<v[p].size();i++)if(v[p][i]!=fa){
		dfs(v[p][i],p);
		sum+=dp[v[p][i]]; mx=max(mx,dp[v[p][i]]);
	}
	int x=sum-a[p],y=a[p]-x,gao=mx>sum-mx?sum-mx:4e18;
	if(x<0||y<0||x>gao)GG();
	dp[p]=y;
}
signed main(){
	n=read();
	if(n==2){
		puts(read()==read()?"YES":"NO"); return 0;
	}
	for(int i=1;i<=n;i++)a[i]=read();
	for(int i=1;i<n;i++){
		int s=read(),t=read();
		v[s].push_back(t); v[t].push_back(s);
	}
	for(int i=1;i<=n;i++)if(v[i].size()>1){dfs(i,0); if(dp[i])GG(); else puts("YES"); return 0;}
}
/*
x*2+y=sum
x+y=a[i]

*/

Measured memory_bytes: 13952
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define FOR(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
const long long dx[4]={1,0,-1,0};
const long long dy[4]={0,1,0,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);

    int h,w,k; cin >> h >> w >> k;
    vstr s(h);
    rep(i,h) cin >> s[i];
    int black=0;
    rep(i,h)rep(j,w)if(s[i][j]=='#') black++;

    int res=0;

    rep(bit1,(1<<h)){
        rep(bit2,1<<w){
            vstr t=s;
            int tmp=0;
            rep(i,h){
                if(bit1&(1<<i)){
                    rep(j,w){
                        if(t[i][j]=='#'){
                            t[i][j]='.';
                            tmp++;
                        }
                    }
                }
                
            }
            rep(i,w){
                if(bit2&(1<<i)){
                    rep(j,h){
                        if(t[j][i]=='#'){
                            t[j][i]='.';
                            tmp++;
                        }
                    }
                }
            }
            if(black-tmp==k) res++;
        }
    }
    cout<<res<<endl;
}

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

using namespace std;

#define rg register
#define In inline

const int N = 2e6;

namespace IO{
	In int read(){
		int s = 0,ww = 1;
		char ch = getchar();
		while(ch < '0' || ch > '9'){if(ch == '-')ww = -1;ch = getchar();}
		while('0' <= ch && ch <= '9'){s = 10 * s + ch - '0';ch = getchar();}
		return s * ww;
	}
	In void write(int x){
		if(x < 0)putchar('-'),x = -x;
		if(x > 9)write(x / 10);
		putchar('0' + x % 10);
	}
}
using namespace IO;

int n;
int a[N+5];
int lg[N+5];

vector<int>loc;

void calc(int x){
	if(x == 0){
		loc.push_back(0);
		return;
	}
	int l = lg[x];
	calc(x - (1<<l));
	int cur = loc.size();
	for(rg int i = 0;i < cur;i++)loc.push_back(loc[i] + (1<<l));
}

int solve(){
	for(rg int i = 1;i <= n;i++)a[i] %= 2;
	calc(n - 1);
	int ans = 0;
//for(rg int i = 0;i < loc.size();i++)cout<<loc[i]<<" ";cout<<endl;
	for(rg int i = 0;i < loc.size();i++)ans ^= a[loc[i]+1];
	return ans;
}

char s[N+5];

int main(){
//	freopen("B.in","r",stdin);
//	freopen("B.out","w",stdout);
	for(rg int i = 2;i <= N;i++)lg[i] = lg[i>>1] + 1;
	n = read();	
	bool b = 1;
	scanf("%s",s + 1);
	for(rg int i = 1;i <= n;i++){
		a[i] = s[i] - '1';
		if(a[i] == 1)b = 0;
	}
	if(b){
		for(rg int i = 1;i <= n;i++)a[i] >>= 1;
		cout << solve() * 2 << endl;
	}
	else cout << solve() << endl;
	return 0;
}

Measured memory_bytes: 13696
#include<iostream>
#include<algorithm>
#include<string>
#include<functional>
#include<utility>
#include<stack>
#include<queue>
#include<cmath>
#include<list>
#include<cstdint>
#include<vector>
#include<map>
#include<deque>
#define rep(i,rept)	for(ll i = 0; i<(ll)rept;++i)
typedef long long ll;
using namespace std;


int main() {
	//21日目 
	ll n = 0, s[100000] = {};
	ll ans = 0;
	cin >> n;
	rep(i, n) {
		cin >> s[i];
		ans += s[i];
	}

	std::sort(s, s + n);
	rep(i, n) {
		if (ans % 10 != 0) {
			cout << ans << endl;
			return 0;
		}
		if (s[i] % 10 != 0) {
			ans -= s[i];
		}
	}
	cout << 0 << endl;

	return 0;

}

Measured memory_bytes: 1024
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using Pair = pair<int64_t, int64_t>;

constexpr int64_t kMaxNumberOfTowns = 200000;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int32_t N;
  cin >> N;
  int32_t a = N % 10;
  if (a == 2 || a == 4 || a == 5 || a == 7 || a == 9) {
    cout << "hon" << endl;
  } else if (a == 0 || a == 1 || a == 6 || a == 8) {
    cout << "pon" << endl;
  } else {
    cout << "bon" << endl;
  }

  return 0;
}


Measured memory_bytes: 3652
#include <iostream>
//#include <bits/stdc++.h>
#include<iomanip>

using namespace std;
#define ll long long int 

int main() {
           bool check1 = true;
           bool check2 = true;
           
           string s;
           cin>>s;
           int len = s.size();
           
           for(int i=0;i<len;i+=2)
           {
               if(s[i]=='L' )
                   {check1 = false;
                   break;
                   }
           }
           
           
              for(int i=1;i<len;i+=2)
           {
               if(s[i]=='R' )
                   {check2 = false;
                    break;
                   }
           }
           
           
           
           if(check1 && check2)
           {
               cout<<"Yes";
           }
           
           else 
           cout<<"No";
           
           
}

Measured memory_bytes: 256