akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
#include <random>
#include <queue>
#include <deque>
#include <tuple>
#include <iomanip>
#include <iterator>
#include <functional>

using namespace std;
typedef long long ll;

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  string S;
  cin>>S;
  if(S=="zyxwvutsrqponmlkjihgfedcba"){
    cout<<-1<<endl;
  }else{
    if(S.length()!=26){
      map<char,int>mp;
      char tmp;
      for(auto e:S)mp[e]++;
      FOR(i,'a','z'+1){
        if(mp[i]==0){
          tmp=i;
          break;
        }
      }
      cout<<S<<tmp<<endl;
    }else{
      int tmp;
      REP(i,25){
        if(S[i]<S[i+1]){
          tmp=i+1;
        }
      }
      REP(i,tmp-1){
        cout<<S[i];
      }
      char ch='z'+1;
      FOR(i,tmp,26){
        if(S[tmp-1]<S[i])
          ch=min(S[i],ch);
      }
      cout<<ch<<endl;
    }
  }
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <algorithm>

using namespace std;

#define ll long long int
#define Pi pair<int, int>
#define Pid pair<int, double>
#define Pdi pair<double, int>
#define Pd pair<double, double>
#define Pl pair<ll, ll>

const int mod = 1e9+7;
const int INF = 2e9;
const double epsilon = 1e-7;
const double PI = 3.1415926535;

ll mi(ll x, ll y){
    if(x<y)return x;
    return y;
}

int main() {
	int n; cin >> n;
	vector<Pi> a(n);
	for(int i = 0;i < n;i++) cin >> a[i].first >> a[i].second;
	for(int i = 0;i < n;i++) {
		int idx = 0;
		double b[201];
		for(int j = 0;j < n;j++) {
			if (i == j) continue;
			b[idx++] = atan2(a[j].second - a[i].second, a[j].first - a[i].first);
		}
		sort(b, b + idx);
		for(int j = 0;j < idx;j++) b[j + idx] = b[j] + 2 * PI;
		double ans = 0;
		for(int j = 0;j < idx;j++)ans = max(ans, PI - b[j + idx - 1] + b[j]);
		printf("%.12f\n", ans/2/PI);
	}
	return 0;
}


Measured memory_bytes: 512
//agrawal117
//chahatagrawal117
#include<bits/stdc++.h>
#define endl '\n'
#define mod 998244353
typedef long long int ll;
using namespace std;
#define MAX 3001
ll dp[MAX][MAX];
ll pre[MAX][MAX];
ll arr[MAX+3];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n, s; cin>>n>>s;
    for(int i=1;i<=n;i++) cin>>arr[i];
    ll ans=0;
    for(int i=1;i<=n;i++){
        dp[i][arr[i]]=i;
        for(int j=arr[i]+1;j<MAX;j++){
            dp[i][j]=pre[i-1][j-arr[i]] ;
        }
        
        for(int j=1;j<MAX;j++) pre[i][j]=(pre[i-1][j]+dp[i][j])%mod;
         ans=(ans+(dp[i][s]*(n-i+1))%mod)%mod;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 140928
n = input()
a = input()
b = input()
c = input()
count = 0
for i in range(int(n)):
    d = set([a[i], b[i], c[i]])

    if len(d) == 3:
        count += 2
    elif len(d) == 2:
        count += 1
    else:
        pass

print(count)


Measured memory_bytes: 3060
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

int W,H;
int POW[21],dp[1048576],next_dp[1048576];
int table[20][20];
vector<int> V;
int case_num = 1;

void recursive(int array[],int index){

	if(index == W){
		int code = 0;
		for(int i = 0; i < W; i++){
			if(array[i] == 1)code += POW[i];
		}
		V.push_back(code);
		return;
	}

	if(array[index-1] == 1){
		int next_array[W];
		for(int i = 0; i < index; i++)next_array[i] = array[i];
		next_array[index] = 0;
		recursive(next_array,index+1);
	}else{

		int next_array1[W];
		for(int i = 0; i < index; i++)next_array1[i] = array[i];
		next_array1[index] = 1;
		recursive(next_array1,index+1);

		int next_array2[W];
		for(int i = 0; i < index; i++)next_array2[i] = array[i];
		next_array2[index] = 0;
		recursive(next_array2,index+1);
	}
}

void func(){

	scanf("%d %d",&W,&H);
	if(W > H){

		for(int row = 0; row < H; row++){
			for(int col = 0; col < W; col++)scanf("%d",&table[col][row]);
		}
		swap(W,H);
	}else{
		for(int row = 0; row < H; row++){
			for(int col = 0; col < W; col++)scanf("%d",&table[row][col]);
		}
	}

	int first_array0[W],first_array1[W];

	V.clear();

	first_array0[0] = 0;
	recursive(first_array0,1);
	first_array1[0] = 1;
	recursive(first_array1,1);


	sort(V.begin(),V.end());
	V.erase(unique(V.begin(),V.end()),V.end());


	for(int i = 0; i < V.size(); i++){
		dp[V[i]] = 0;
		next_dp[V[i]] = 0;
	}

	int state,sum,maximum;

	for(int row = 0; row < H; row++){

		for(int i = 0; i < V.size(); i++){
			state = V[i];
			sum = 0;
			for(int loop = 0; loop < W; loop++){
				if(state & (1 << loop)){
					sum += table[row][loop];
				}
			}
			next_dp[state] = sum;

			maximum = 0;
			for(int k = 0; k < V.size(); k++){
				if((state&V[k])==0){
					maximum = max(maximum,dp[V[k]]);
				}
			}
			next_dp[state] += maximum;
		}
		for(int i = 0; i < V.size(); i++){
			dp[V[i]] = next_dp[V[i]];
		}
	}

	int ans = 0;
	for(int i = 0; i < V.size(); i++){
		ans = max(ans,dp[V[i]]);
	}

	printf("Case %d: %d\n",case_num++,ans);

}

int main(){

	for(int i = 0; i < 21; i++)POW[i] = pow(2,i);

	int data_set;
	scanf("%d",&data_set);

	for(int i = 0; i < data_set; i++)func();

	return 0;
}

Measured memory_bytes: 5008
import java.util.*;

public class Main {

    long INF = Long.MAX_VALUE;
    long[] dp;
    long n;
    long S;

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

    void solve() {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        char[] S = s.toCharArray();
        int[] ans = new int[s.length()];
        int c = 0;
        int c1 = 1;
        for (int i = 0; i < s.length(); i++) {
            if (i > 0) {
                if (S[i] == S[i - 1]) {
                    c1++;
                } else {
                    c = Math.max(c, c1);
                    c1 = 1;
                }
            }
        }
        int rc = 0;
        for (int i = 0; i < s.length(); i++) {
            if (i == s.length() - 1) {
                if (S[i] == 'R') {
                    ans[i] += rc;
                }
                continue;
            }
            if (S[i] == 'R') {
                if (S[i + 1] == S[i]) {
                    rc++;
                } else {
                    rc++;
                    ans[i] += rc / 2 + rc % 2;
                    ans[i + 1] += rc / 2;
                    rc = 0;
                }
            }
        }
        int lc = 0;
        for (int i = s.length() - 1; i >= 0; i--) {
            if (i == 0) {
                if (S[i] == 'L') {
                    ans[i] += lc;
                }
                continue;
            }
            if (S[i] == 'L') {
                if (S[i - 1] == S[i]) {
                    lc++;
                } else {
                    lc++;
                    ans[i] += lc / 2 + lc % 2;
                    ans[i - 1] += lc / 2;
                    lc = 0;
                }
            }
        }
        for (int i = 0; i < s.length(); i++) {
            System.out.print(ans[i] + " ");
        }
        System.out.println();

    }

    int gcd(int m, int n
    ) {
        if (m < n) {
            return gcd(n, m);
        }
        if (n == 0) {
            return m;
        }
        return gcd(n, m % n);
    }
}

Measured memory_bytes: 46036
#include<bits/stdc++.h>
using namespace std;
pair<int,int> pii;
vector<char> v,p,q;
int main()
{
  int n,a;
  int count=0,ra,ra2;
  
  cin>>n;
  for(int i=0; i<n; i++){
    cin>>a;
    p.push_back(a);
  }
  for(int i=0; i<n; i++){
    cin>>a;
    q.push_back(a);
  }
  
  for(int i=0; i<n; i++){
    v.push_back(i+1);
  }

  do{
    count++;

    if(p==v)ra=count;
    if(q==v)ra2=count;

  }while(next_permutation(v.begin(),v.end()));


  cout<<abs(ra-ra2)<<'\n';
    
  return 0;
}


Measured memory_bytes: 256
a,b=input().split()
a=int(a)
b=int(b)
l1=[1,3,5,7,8,10,12]
l2=[4,6,9,11]
if a in l1 and b in l1:
  print("Yes")
elif a in l2 and b in l2:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 9124
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <cmath>
#include <deque>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define mt make_tuple
#define pq priority_queue<ll>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vecpll vector<pll>
#define vecbl vector<bool>
#define endl "\n"
#define ALL(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
string stin(){string s;cin>>s;return s;}

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

ll mod = 1000000007;

ll modpow(ll a,ll b){
    if(b==0)return 1;
    if(b%2==0){
        ll d =modpow(a,b/2);
        return d*d%mod;
    }
    return a*modpow(a,b-1)%mod;
}

ll divide(ll a,ll b){
    return a*modpow(b,mod-2)%mod;
}

int main(){
    int n=in();
    vector<pll> a(n);
    rep(i,n){
        a[i]=mp(lin(),lin());
    }
    int cnt0=0;
    map<pll,int> m;
    rep(i,n){
        ll x=a[i].first;
        ll y=a[i].second;
        ll g=gcd(abs(x),abs(y));
        if(g>0){
            x/=g;
            y/=g;
        }else{
            cnt0++;
        }
        if(x<0){
            x=-x;
            y=-y;
        }
        m[mp(x,y)]++;
    }
    ll ans=1;
    auto itr = m.begin();
    while(itr != m.end()){
        ll x = itr->first.first;
        ll y = itr->first.second;
        if(x==0 && y==0){
            itr++;
            continue;
        }
        ll c = itr->second;
        ll d = 0;
        if(m.find(mp(-y,x))!=end(m)){
            d=m[mp(-y,x)];
        }else if (m.find(mp(y,-x))!=end(m)){
            d=m[mp(y,-x)];
        }
        ans = ans*(modpow(2,c)+modpow(2,d)-1)%mod;
        m[mp(x,y)]=0;
        if(m.find(mp(-y,x))!=end(m)){
            m[mp(-y,x)]=0;
        }else if (m.find(mp(y,-x))!=end(m)){
            d=m[mp(y,-x)]=0;
        }
        itr++;
    }
    cout<<(ans+cnt0+mod-1)%mod<<endl;
}



Measured memory_bytes: 18712
ans_list = []
while True:
    n = int(input())
    if not n:
        break
    xy = []
    for i in range(n + 1):
        xy.append([])
        m = int(input())
        x, y = map(int, input().split())
        for j in range(m - 1):
            a, b = map(int, input().split())
            xy[i].append([a - x, b - y])


        if 0 > xy[i][0][0]:
            for j in range(m - 1):
                this = xy[i][j]
                xy[i][j] = [this[0] * -1, this[1] * -1]
        elif 0 < xy[i][0][1]:
            for j in range(m - 1):
                this = xy[i][j]
                xy[i][j] = [this[1], this[0] * -1]
        elif 0 > xy[i][0][1]:
            for j in range(m - 1):
                this = xy[i][j]
                xy[i][j] = [this[1] * -1, this[0]]

    ans = []
    import copy
    check1 = copy.copy(xy[0])
    check2 = []
    for i in check1[::-1]:
        check2.append([i[1], i[0]])
    check2 += [[0, 0]]
    for i in range(1, len(check2)):
        check2[i][0] = check2[i][0] - check2[0][0]
        check2[i][1] = check2[i][1] - check2[0][1]
        check2[i][1] *= -1

    del check2[0]
    m = len(check2) + 1
    if 0 > check2[0][0]:
        for j in range(m - 1):
            this = check2[j]
            check2[j] = [this[0] * -1, this[1] * -1]
    elif 0 < check2[0][1]:
        for j in range(m - 1):
            this = check2[j]
            check2[j] = [this[1], this[0] * -1]
    elif 0 > check2[0][1]:
        for j in range(m - 1):
            this = check2[j]
            check2[j] = [this[1] * -1, this[0]]

    for i in range(1, n + 1):
        if check1 == xy[i] or check2 == xy[i]:
            ans.append(i)
    ans.append("+++++")
    ans_list.append(ans)

for i in ans_list:
    for j in i:
        print(j)


Measured memory_bytes: 6356
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll pref[101000];
ll suff[101000];
ll ara[101000];
int main()
{
ll a,b,c;
cin >> a >> b >> c;
if(a+b>=c)
    cout << "Yes" << endl;
    else cout << "No" << endl;
 }


Measured memory_bytes: 3592
n, c, k = map(int, input().split())
t = sorted(int(input()) for _ in range(n))
cnt = 0
bus_people = 0
bus_time = 0
for i in range(n):
    if bus_people >= c or t[i] > bus_time:
        bus_people = 1
        bus_time = t[i] + k
        cnt += 1
    else:
        bus_people += 1
print(cnt)

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

import static java.lang.Integer.parseInt;

/**
 * Rhythm Machine
 */
public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		String words;

		int D = parseInt(br.readLine());

		for (int i = 0; i < D; i++) {

			List<int[]> rhythms = new ArrayList<>();

			int N = parseInt(br.readLine());
			for (int j = 0; j < N; j++) {
				rhythms.add(reduce(decode(br.readLine())));
			}

			long lcm = 1;
			for (int[] r : rhythms) {
				lcm = lcm(lcm, r.length);
			}

			if (lcm < 0 || 1024 < lcm) {
				System.out.println("Too complex.");
				continue;
			}

			int[] chord = new int[(int) lcm];
			for (int[] r : rhythms) {
				int div = (int) lcm / r.length;
				for (int j = 0, k = 0; j < r.length; j++, k += div) {
					chord[k] |= r[j];
				}
			}

			chord = reduce(chord);

			if (chord.length <= 1024) {
				System.out.println(encode(chord));
			} else {
				System.out.println("Too complex.");
			}

		}
	}

	private static int[] decode(String rhythm) {
		int[] ret = new int[rhythm.length() / 2];
		for (int i = 0; i < rhythm.length(); i += 2) {
			String _r = rhythm.substring(i, i + 2);
			ret[i / 2] = Integer.valueOf(_r, 16);
		}
		return ret;
	}

	private static String encode(int[] chord) {
		StringBuilder sb = new StringBuilder();
		for (int i : chord) {
			sb.append(String.format("%02X", i));
		}
		return sb.toString();
	}

	private static int[] reduce(int[] chord) {

		List<Integer> divs = divisors(chord.length);
		Collections.sort(divs, Comparator.reverseOrder());

		int[] ret = null;

		outer:
		for (int div : divs) {
			ret = new int[chord.length / div];
			int zero = 0;
			int same = 0;
			for (int i = 0; i < chord.length; i++) {
				if (i % div == 0) {
					ret[i / div] = chord[i];
					same = chord[i];
				} else {
					zero += chord[i];
				}
			}
			if (zero == 0) {
				break outer;
			}
		}

		return ret;
	}

	private static long gcd(long a, long b) {
		if (b == 0) return a;
		return gcd(b, a % b);
	}

	private static long lcm(long a, long b) {
		return a * (b / gcd(a, b));
	}

	private static List<Integer> divisors(int n) {
		List<Integer> ret = new ArrayList<>();
		if (n == 0) {
			ret.add(1);
			return ret;
		}
		for (int i = 1; i * i <= n; i++) {
			if (n % i == 0) {
				if (i * i != n) ret.add(n / i);
				ret.add(i);
			}
		}
		Collections.sort(ret);
		return ret;
	}
}

Measured memory_bytes: 76436
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;

int main(){
	long long n, k;
	cin >> n >> k;
	vector<long long> x(pow(10, 5), 0);
	for(int i = 0; i < n; i++){
		int a, b;
		cin >> a >> b;
		x.at(a - 1) += b;
	}
	long long sum = 0;
	for(int i = 0; i < (int)x.size(); i++){
		if(sum + x.at(i) >= k){
			cout << i + 1 << endl;
			return 0;
		}
		sum += x.at(i);
	}
	return 0;
}



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

typedef struct SHOP {
	int price;
	int limit;
} shop;
int main(){
	int N, M;
	cin >> N >> M;

	vector<shop> shops(N);

	for(int i = 0; i < N; i++)
	{
		cin >> shops[i].price >> shops[i].limit;
	}

	sort(shops.begin(), shops.end(), [](shop a, shop b){return a.price < b.price;});

	long long int ans = 0;
	for(int i = 0; i < N; i++)
	{
		shop s = shops[i];
		if(s.limit < M){
			ans += (long long int) s.price * s.limit;
			M -= s.limit;
		} else {
			ans += (long long int) s.price * M;
			cout << ans << endl;
			return 0;
		}
	}
	cout << "no answer" << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int dp[6000][6000];
	
int main(){
	int n; cin >> n;
	string str; cin >> str;
	for( int i = n-1; i >= 0; --i ){
		for( int j = n-1; j >= 0; --j ){
			if( str[i] == str[j] ) dp[i][j] = dp[i+1][j+1] + 1;
		}
	}
	int ans = 0;
	for( int i = 0; i < n; ++i ){
		for( int j = i+1; j < n; ++j ){
			if( ans < min(dp[i][j], j-i) ){
				ans = max( ans, min( dp[i][j], j-i ) );
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 119040
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var buf = bufio.NewScanner(os.Stdin)

func scanInt() int {
	buf.Scan()
	i, _ := strconv.Atoi(buf.Text())
	return i
}

func scanInts(n int) []int {
	a := make([]int, n)
	for k, _ := range a {
		a[k] = scanInt()
	}
	return a
}

func main() {
	buf.Split(bufio.ScanWords)

	n := scanInt()
	p := scanInts(n)

	smallest := math.MaxInt64
	count := 0
	for _, v := range p {
		if v <= smallest {
			smallest = v
			count++
		}
	}

	fmt.Printf("%d", count)
}


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

int main(){
	int n;
	cin >> n;
	vector<pair<int,int>> a;
	for(int i=0;i<n;i++) {
		int tmp;
		cin >> tmp;
		a.push_back({tmp,i+1});
	}
	sort(a.begin(),a.end());
	for(int i=0;i<n;i++) {
		if(i==0) cout << a[i].second;
		else cout << " " << a[i].second;
	}
	cout << endl;
}

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

int32_t main(){
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
////////////////////////////////

    double d,t,s;
    cin >> d >> t >> s;

    double take = d/s;

    if (take <= t){
        cout<<"Yes\n";
    }
    else
        cout<<"No\n";



}


Measured memory_bytes: 3736
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define dmp make_pair
typedef pair<int,int> P;
typedef pair<int, P> PP;
const int inf = 1e9;
#define rep(i,n) for(int i = 0;i < n;i++)
#define rrep(i,n) for(int i = 1;i <= n;i++)

int a[1002][1002], b[1002][1002];
int dy[] = {-1, 0, 0, 1}, dx[] = {0, -1, 1, 0};
priority_queue<PP, vector<PP>, greater<PP> > q;
int main(){
	int h, w, ans = 0;
	scanf("%d%d", &h, &w);
	fill((int*)a, (int*)(a+1002), inf);
	rrep(i,h)rrep(j,w)scanf("%d", &a[i][j]);
	rrep(y,h)rrep(x,w){
		int f = 0;
		rep(i,4)if(a[y][x] < a[y+dy[i]][x+dx[i]])f++;
		if(f == 4)b[y][x] = a[y][x];
		q.push(dmp(a[y][x], P(y, x)));
	}
	
	while(!q.empty()){
		PP p = q.top();q.pop();
		int y = p.se.fi, x = p.se.se;
		if(b[y][x] == -1)ans++;
		for(int i = 0;i < 4;i++){
			int yy = y+dy[i], xx = x+dx[i];
			int f = (a[y][x] < a[yy][xx]);
			if(f && b[yy][xx] == 0)b[yy][xx] = b[y][x];
			else if(f && b[y][x] != b[yy][xx] && b[yy][xx] != -1){
				b[yy][xx] = -1;
			}
		}
	}
	
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 22556
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;



public class Bridge
{
	public int A { get; private set; }
	public int B { get; private set; }

	public Bridge(int a, int b)
	{
		A = a;
		B = b;
	}
}


public class D
{
	public static void Main()
	{
		string[] args;
		args = Console.ReadLine().Split(' ');
		int N = Int32.Parse(args[0]);
		int M = Int32.Parse(args[1]);

		List<Bridge> bridges = new List<Bridge>(M);
		for(int i = 0; i < M; i++)
		{
			args = Console.ReadLine().Split(' ');
			int a = Int32.Parse(args[0]);
			int b = Int32.Parse(args[1]);
			bridges.Add(new Bridge(a,b));
		}
		bridges.Sort((x,y) => x.A - y.A);

		int ans = 0;
		int cut = bridges[0].B;
		for(int i = 1; i < M; i++)
		{
			cut = Math.Min(cut, bridges[i].B);
			if(cut <= bridges[i].A)
			{
				ans++;
				cut = bridges[i].B;
			}
		}
		ans++;

		Console.WriteLine(ans);		
	}	
}





Measured memory_bytes: 22212
#include<stdio.h>
#include<math.h>

unsigned long prime(int n) {
	int i,j,k,count=1;
	unsigned long sum = 2;
	for (i = 3; i <= 104729; i+=2) {
		k = 0;
		for (j = 3; j <= sqrt(i); j += 2) {
			if (i%j == 0) {
				k = 1;
				break;
			}
		}
		if (k == 0) {
			sum += i;
			count++;
			if (count == n)break;
		}
	}
	return sum;
}

int main(void)
{
	int n;

	for (;;) {
		scanf("%d",&n);
		if (n == 0)break;
		if (n == 1)
			printf("2\n");
		else
		printf("%lu\n",prime(n));
	}

	return 0;
}

Measured memory_bytes: 604
import collections as cols

n, q = [int(x) for x in input().split()]
qu = cols.deque()

for i in range(n):
	tmp = [x for x in input().split()]
	qu.append([tmp[0], int(tmp[1])])

num = n
t = 0

while num > 0:
	tmp = qu.popleft()
	if tmp[1] > q:
		t += q
		qu.append([tmp[0], tmp[1] - q])
	else:
		t += tmp[1]
		num -= 1
		print(tmp[0], t)

Measured memory_bytes: 16240
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main() {
    int n,k,ans=inf; cin>>n>>k;
    vector<int> h(n,0);
    rep(i,n) cin>>h[i];
    sort(al(h));
    rep(i,n-k+1){
        ans=min(ans,h[i+k-1]-h[i]);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 640
N=int(input())
l=[]
for i in range(1,int(N**0.5)+1):
    if N%i==0:
        l.append([i,N/i])
L=len(l)
s=[0]*L
for j in range(L):
    s[j]=l[j][0]+l[j][1]
print(int(min(s))-2)

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

int main() {
	
	int n, k;
	cin >> n >> k;
	vector<int> p(n);
	for(auto &i : p) cin >> i;
	int64_t m=0;
	int64_t m2=0;
	for(int j=0; j<k; j++) m2 += p.at(j);
	m = m2;
	for(int i=1; i<n; i++){
		if(n==k) break;
		m2 -= p.at(i-1);
		m2 += p.at(i+k-1);
		m = max(m,m2);
		if(i+k==n) break;
	}
	cout << fixed;
	cout << setprecision(10) << (double)(m+k)/2 << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
 
#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define pb push_back
#define mp make_pair
 
using namespace std;
 
struct Rec
{
    int l[2];
    /*
    bool operator == (const Rec r) const
    {
        return l[0] ==  r.l[0] ? l[1] < r.l[1] :  l[0] < l[1];
    }
    */
};
 
int main()
{
    int n,w,d;
    while(cin >> n >> w >> d)
    {
        if(n == 0 && w == 0 && d == 0)
        {
            break;
        }
 
        vector<Rec> v;
        Rec r;
        r.l[0] = w;
        r.l[1] = d;
        v.pb(r);
 
        rep(i,n)
        {
            int p,s;
            cin >> p >> s;
 
            p--;
            Rec r1 = v[p];
            v.erase(v.begin() + p);
 
            int count = 0,x = 0;
            while(true)
            {
                if(s - r1.l[count%2] <= 0)
                {
                    x = s;
                    break;
                }
                else
                {
                    s -= r1.l[count%2];
                    count++;
                }
            }
            count %= 2;
            Rec r2,r3;
            if(count == 0)
            {
                r2.l[0] = x;
                r2.l[1] = r1.l[1];
 
                r3.l[0] = r1.l[0] - x;
                r3.l[1] = r1.l[1];
 
                if(r2.l[0] * r2.l[1] < r3.l[0]*r3.l[1])
                {
                    v.pb(r2);
                    v.pb(r3);
                }
                else
                {
                    v.pb(r3);
                    v.pb(r2);
                }
            }
            if(count == 1)
            {
 
                r2.l[0] = r1.l[0];
                r2.l[1] = x;
 
                 
                r3.l[0] = r1.l[0];
                r3.l[1] = r1.l[1] - x;
 
                if(r2.l[0] * r2.l[1] < r3.l[0]*r3.l[1])
                {
                    v.pb(r2);
                    v.pb(r3);
                }
                else
                {
                    v.pb(r3);
                    v.pb(r2);
                }
            }
        }
        vector<int> ans;
        rep(j,v.size())
        {
            ans.pb(v[j].l[0]*v[j].l[1]);
        }
 
        sort(ans.begin(),ans.end());
 
        bool flag = true;
        rep(j,ans.size())
        {
            if(flag)
            {
                cout << ans[j];
                flag = false;
            }
            else
            {
                cout << " " << ans[j];
            }
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 3116
//Bismillahir-Rahmanir-Rahim
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int llu;
#define f1(i,n) for(i=1;i<=n;i++)
#define f(i,n) for(i=0;i<n;i++)
#define Max 100009
using namespace std;
int main()
{
    	ll n,i;
	cin>>n;
	string s;
	while(n){
		n--;
		s.push_back('a'+n%26);
		n/=26;
	}
	reverse(s.begin(),s.end());
	cout<<s<<endl;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store") // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop")// to pop argument of function as soon as it returns
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define takeline cin.ignore();
#define sc second
#define N 3000005
#define endl "\n"
#define mod 1000000007
//((1.0l)*BIG MULTIPLY MAGIC?)
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
//-----------------------------------------------
int main(){
	
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll i,j,k,l,n;
	cin>>n;
	ll ar[n+1];
	for(i=1;i<=n;i++){
		cin>>ar[i];
	}
	
	k=1; ll an=0;
	for(i=1;i<=n;i++){
		if(ar[i]==k){
			k++;
		}
		else{
			an+=1;
		}
	}
	if(an==n){
		cout<<"-1"<<endl;
	}
	else cout<<an<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int func(int x){
  if(x%2 == 0) return x/2;
  else return 3*x+1;
}

int main(){
  bool used[30000] = {};
  int n;
  cin >> n;
  int x = n;
  int cnt = 1;
  while(!used[x]){
    used[x] = true;
    x = func(x);
    cnt++;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	int i=0,j=0;
	char a,b,kai='A';

	while(scanf("%c,%c\n",&a,&b) != EOF)
	{
		if(a==kai)
			kai=b;
		else if(b==kai)
			kai=a;
	}
  printf("%c\n",kai);

  return 0;
}

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

int main()
{
    int64_t N, ans = 0;
    cin >> N;
    for (int64_t i = 1; i <= N; i++)
    {
        ans += (N / i) * (N / i + 1) * i / 2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
#define MOD 998244353ll
using namespace std;

ll mpow(int x, int n)
{
    if (n == 0)
    {
        return 1ll;
    }
    ll prev = mpow(x, n / 2);
    if (n % 2 == 1)
    {
        return (((prev * prev) % MOD) * x) % MOD;
    }
    else
    {
        return (prev * prev) % MOD;
    }
}

int main(int argc, char const *argv[])
{
    int n;
    cin >> n;
    int d[n];
    rep(i, n) cin >> d[i];
    if (d[0] != 0)
    {
        cout << 0 << endl;
        return 0;
    }
    sort(d, d + n);
    if (d[1] != 1)
    {
        cout << 0 << endl;
        return 0;
    }
    rep(i, 1, n - 1)
    {
        if (d[i] == 0)
        {
            cout << 0 << endl;
            return 0;
        }
        if (d[i] == d[i + 1] || d[i] + 1 == d[i + 1])
        {
        }
        else
        {
            cout << 0 << endl;
            return 0;
        }
    }
    ll ans = 1;
    ll cur = d[1];
    ll prev = 1;
    ll tmp = 0;

    rep(i, 1, n)
    {
        if (d[i] == cur)
        {
            tmp++;
        }
        else
        {
            cerr << prev << " " << tmp << endl;
            ans *= mpow(prev, tmp);
            ans %= MOD;
            cur = d[i];
            prev = tmp;
            tmp = 1;
        }
    }
    if (tmp != 0)
    {
        ans *= mpow(prev, tmp);
        ans %= MOD;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
#include<cstdio>
#include<cmath>
#include<queue>
using namespace std;
#define N 100050
#define M 605
int n,d1,d2,head[N],cnt,col[M][M],col2[M][M],vis[M][M],ct,s1[N][2];
queue<int> tp;
void bfs(int x,int y)
{
	vis[x][y]=1;
	tp.push(x*1000+y);
	while(!tp.empty())
	{
		int s=tp.front()/1000,t=tp.front()%1000;tp.pop();
		for(int i=0;i<=ct;i++)
		for(int j=s-s1[i][0];j<=s+s1[i][0];j+=s1[i][0]*2)
		{
			for(int k=t-s1[i][1];k<=t+s1[i][1];k+=s1[i][1]*2)
			{
				if(j>=1&&j<=n&&k>=1&&k<=n&&!vis[j][k])vis[j][k]=1,col[j][k]=col[s][t]^1,tp.push(j*1000+k);
				if(!s1[i][1])break;
			}
			if(!s1[i][0])break;
		}
	}
}
int main()
{
	scanf("%d%d%d",&n,&d1,&d2);n*=2;
	ct=0;for(int i=0;i<=n;i++)if(d1>=i*i){int tp=sqrt(d1-i*i);if(i*i+tp*tp==d1)s1[++ct][0]=i,s1[ct][1]=tp;}
	for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)if(!vis[i][j])bfs(i,j);
	int tp=0;for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)tp+=col[i][j]?-1:1;
	for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)col2[i][j]=col[i][j]^(tp>=0),vis[i][j]=0,col[i][j]=0;
	ct=0;for(int i=0;i<=n;i++)if(d2>=i*i){int tp=sqrt(d2-i*i);if(i*i+tp*tp==d2)s1[++ct][0]=i,s1[ct][1]=tp;}
	for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)if(!vis[i][j])bfs(i,j);
	tp=0;for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)tp+=col[i][j]?-1:1;
	for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)col[i][j]=col[i][j]^(tp>=0);
	int ct=0;
	for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)if(ct<n*n/4&&col[i][j]==1&&col2[i][j]==1)printf("%d %d\n",i-1,j-1),ct++;
}//

Measured memory_bytes: 5376
#include<iostream>
#include<stack>
using namespace std;
#define NIL -1

struct Node {int left=NIL, right=NIL; bool visited=false;};

int findPos(int n, int in[], int target) {
	for (int i = 0; i < n; i++) {
		if (in[i] == target) return i;
	}
	return -1;
}

void reconstructTree(int n, Node T[], int pre[], int in[]) {
	int root = pre[0];
	for (int i = 1; i < n; i++) {
		int target = pre[i];
		int targetPos = findPos(n, in, target);
		stack<int> st;
		st.push(root);
		while (st.size() != 0) {
			int cur = st.top(); st.pop();
			int curPos = findPos(n, in, cur);
			if (targetPos < curPos) {
				if (T[cur].left == NIL) T[cur].left = target;
				else st.push(T[cur].left);
			} else {
				if (T[cur].right == NIL) T[cur].right = target;
				else st.push(T[cur].right);
			}
		}
	}
}

void preOrder(Node T[], int root) {
	stack<int> st;
	st.push(root);
	while (st.size() != 0) {
		int cur = T[st.top()].left;
		while (cur != NIL && !T[cur].visited) {
			st.push(cur);
			cur = T[cur].left;
		}
		int right = T[st.top()].right;
		if (right != NIL && !T[right].visited) {
			st.push(right);
		} else {
			cur = st.top(); st.pop();
			cout << cur;
			if (st.size() != 0) cout << " ";
			T[cur].visited = true;
		}
	}
	cout << endl;
}

int main() {
	int n;
	cin >> n;
	int pre[n], in[n];
	for (int i = 0; i < n; i++) cin >> pre[i];
	for (int i = 0; i < n; i++) cin >> in[i];
	Node T[n+1];
	reconstructTree(n, T, pre, in);
	preOrder(T, pre[0]);
	return 0;
}



Measured memory_bytes: 3132
parseInt(x) = parse(Int, x)
parseBigInt(x) = parse(BigInt, x)
parseFloat(x) = parse(Float64, x)
parseBigFloat(x) = parse(BigFloat, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)


function main()
    h,w=parseMap(split(readline()))
    s=[chomp(readline()) for i in 1:h]
    ans=0
    for i in 1:h
        for j in 1:w
            arr=Vector{Vector{Int}}()
            if s[i][j]=='#'
                continue
            end
            dis=fill(-1,(h,w))
            dis[i,j]=0
            push!(arr,[i,j])
            while !isempty(arr)
                (y,x)=shift!(arr)
                for (xx,yy) in [(x+1,y),(x-1,y),(x,y+1),(x,y-1)]
                    if 0<xx<w+1 && 0<yy<h+1 && s[yy][xx]=='.' && (dis[yy,xx]>dis[y,x]+1 || dis[yy,xx]==-1)
                        dis[yy,xx]=dis[y,x]+1
                        push!(arr,[yy,xx])
                    end
                end
            end
            ans=max(ans,findmax(dis)[1])
        end
    end
    println(ans)
end
main()

Measured memory_bytes: 154404
#include <bits/stdc++.h>
using namespace std;
#define MAXN 10003

struct node{
    int fr, to, va; //从fr到to有一条权值为v的边
    int nxt;
}edge[MAXN];
int cnt, head[MAXN];
inline void read(int &x) {
    x = 0; char c = getchar();
    while(!isdigit(c)) c = getchar();
    while(isdigit(c)) x = x * 10 + c - '0', c = getchar();
}
inline void add_edge(int u, int v, int w) { //邻接表存边
    edge[cnt].fr = u, edge[cnt].to = v, edge[cnt].va = w;
    edge[cnt].nxt = head[u], head[u] = cnt++;
    edge[cnt].fr = v, edge[cnt].to = u, edge[cnt].va = 0;
    edge[cnt].nxt = head[v], head[v] = cnt++;
}
int pre[MAXN];
bool vis[MAXN];
int st, ed, n, m;
bool BFS (int S, int T) {
    queue<int> q;
    memset(vis, 0, sizeof(vis));
    memset(pre, -1, sizeof(pre));
    q.push(S);  vis[S] = 1;
    while(!q.empty()) {
        int u = q.front();
        q.pop();
        for(int i = head[u]; i != -1; i = edge[i].nxt) {
            int tmp = edge[i].to;
            if(edge[i].va <= 0 || vis[tmp]) continue;
            pre[tmp] = i; //记录路径
            vis[tmp] = 1;
            if(tmp == T) return 1;
            q.push(tmp);
        }
    }
    return false;
}
int ans;
int EK() {
    int sub;
    while(BFS(st, ed)) {
        sub = 0x3fffff;
        int i = pre[ed];
        while(i != -1) {
            sub = min(sub, edge[i].va);
            i = pre[edge[i].fr];
        }
        i = pre[ed];
        while(i != -1) {
            edge[i].va -= sub;
            edge[i ^ 1].va += sub;
            i = pre[edge[i].fr];
            /*
            我们要求剩余权值
            而如果每次将边权减去更新部分之后
            求个最小值 即可得到路径上的最小剩余
            反边就对应的加上这个最小剩余
            由于反边和当前边的编号一定相差1，
            所以可以直接^得到
            */
        }
        ans += sub;
    }
    return ans;
}
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    scanf("%d%d",&n,&m);
    st=0,ed=n-1;
    int x, y, z;
    memset(head, -1, sizeof head);
    for(int i = 1; i <= m; ++i) {
        read(x), read(y), read(z);
        add_edge(x, y, z);
    }
    cout<<EK()<<endl;
    return 0;
}



Measured memory_bytes: 3424
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<stack>
#include<set>
#include<map>
#include<utility>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

#define MOD 1000000007;

int main(){
	int h, w;
	cin >> h >> w;
	string judge;
	for(int i=0; i<w; i++)
		judge.push_back('.');
	vector<string> grid;
	for(int i=0; i<h; i++){
		string s;
		cin >> s;
		if(s!=judge)
			grid.emplace_back(s);
	}
	for(int i=0; i<grid[0].size(); i++){
		bool flag=true;
		for(int j=0; j<grid.size(); j++){
			if(grid[j][i]=='#')
				flag=false;
		}
		if(flag){
			for(int j=0; j<grid.size(); j++)
				grid[j].erase(grid[j].begin()+i);
			i--;
		}
	}
	for(auto e: grid)
		cout << e << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int n,i,t,c,a,m,x;
	scanf("%d",&x);
	for(i=0;i<x;i++){
		t=0;
		scanf("%d %d %d",&c,&a,&n);
		while(1){
		if(c>=1&&a>=1&&n>=1){
			t++;
			c--;
			a--;
			n--;
		}
		else if(c>=2&&a>=1){
			c=c-2;
			a--;
			t++;
		}
		else if(c>=3){
			t++;
			c=c-3;
		}
			else{
		printf("%d\n",t);
		break;
			}
		}
	}
return 0;
}

Measured memory_bytes: 600
# n, m = map(int, input().split())
# if (m == 0):
#     print('1' + '0' * (n - 1))
#     exit()
# dic = {}
# for i in range(m):
#     s, c = map(int, input().split())
#     try:
#         _ = dic[s]
#     except KeyError:
#         if (s == 1 and c == 0):
#             print(-1)
#             exit()
#         dic[s] = c
#     else:
#         if (dic[s] != c):
#             print(-1)
#             exit()

# ans = '0' * n
# for k, v in dic.items():
#     ans = ans[:k - 1] + str(v) + ans[k:]

# try:
#     digit1 = dic[1]
# except KeyError:
#     digit1 = 1

# if (digit1 == 0):
#     ans = '1' + ans[1:]

# print(ans)
n, m = map(int, input().split())
if (n == 1 and m == 0):
    print(0)
    exit()
if (m == 0):
    print('1' + '0' * (n - 1))
    exit()
dic = {}
for i in range(m):
    s, c = map(int, input().split())
    try:
        _ = dic[s]
    except KeyError:
        if (s == 1 and c == 0 and n >= 2):
            print(-1)
            exit()
        dic[s] = c
    else:
        if (dic[s] != c):
            print(-1)
            exit()

ok = False
if (n == 1):
    for k, v in dic.items():
        print(v)
        exit()
else:
    for i in range(10 ** (n - 1), 10 ** n):
        for k, v in dic.items():
            if (str(i)[k - 1] == str(v)):
                ok = True
            else:
                ok = False
                break
        else:
            if (ok):
                print(i)
                exit()


Measured memory_bytes: 38256
#include <stdio.h>
 
int main() {
  int x, y;
  while (1) {
    scanf("%d%d", &x, &y);
    if (x == 0 && y == 0) break;
    if (x < y) {
      printf("%d %d\n", x, y);
    } else {
      printf("%d %d\n", y, x);
    }
  }
  return 0;
}

Measured memory_bytes: 600
/************************************************************
	> File Name: c.cpp
	> Author: TSwiftie
	> Mail: 2224273204@qq.com 
	> Created Time: Sun 19 Jan 2020 08:18:10 PM CST
************************************************************/

#pragma GCC optimize(2)
#include <bits/stdc++.h>
#include <ext/rope>
#define lowbit(x) (x&-x)
#define lc (o<<1)
#define rc (o<<1|1)
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int INF = 0x3f3f3f3f;
const int MAXN = 2e5+5;
const int MAXM = 2e5+5;
const int MOD = 1e9+7;
const int dir[4][2] = {1,0,-1,0,0,1,0,-1};
const double PI = acos(-1.0);
const double EXP = 1e-8;
int n, p[MAXN];
int main(void){
	IOS;
	cin >> n;
	for(int i = 1;i <= n;i++)
		cin >> p[i];
	int ans = 1,now = p[1];
	for(int i = 2;i <= n;i++){
		if(p[i] < now){
			now = p[i];
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

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

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPr(i, n) for(int i = (n)-1; i >= 0; --i)
#define FORq(i, m, n) for(int i = (m); i <= (n); ++i)
#define FORqr(i, m, n) for(int i = (n); i >= (m); --i)
#define MP make_pair
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x, 0, sizeof(x))
#define FILL(x, y) memset(x, y, sizeof(x))
#define MM(x) memset(x, -1, sizeof(x))
#define ALL(x) (x).begin(), (x).end()
#define DB(x) cerr << #x << " = " << x << endl
#define DB2(x, y)                                                              \
    cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n";
#define DEBUG                                                                  \
    int x12345;                                                                \
    cin >> x12345;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
const long long MOD = 1e9 + 7;
///////////////////////////////////////////////
// for template
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;
}
///////////////////////////////////////////////
/// 🍈( '-' 🍈 |AC|
int main() {
    int N; cin >> N;
    string S;
    cin >> S;

    int Rc = 0;
    REP(i,N){
        if (S[i] == 'R'){
            Rc++;
        }        
    }
    int ans = 0;
    REP(i,Rc){
        if (S[i] == 'W') ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3748
#include <bits/stdc++.h>
using namespace std;
int main(){
    int h, w;
    cin >> h >> w;
    string str[100];
    for(int i=0; i<h; i++){
        cin >> str[i];
    }
    int data[100][100]={};
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            if(str[i][j]=='#'){
                if(i!=0 && j!=0){
                    data[i-1][j-1]++;
                }
                if(i!=0){
                    data[i-1][j]++;
                    data[i-1][j+1]++;
                }
                if(j!=0){
                    data[i][j-1]++;
                    data[i+1][j-1]++;
                }
                data[i][j+1]++;
                data[i+1][j]++;
                data[i+1][j+1]++;
            }
        }
    }
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            if(str[i][j]=='#'){
                cout << "#";
            }else{
                cout << data[i][j];
            }
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 256
from math import sqrt, factorial
n = int(input())
x, y = [0] *  n, [0] * n

for i in range(n):
    x[i], y[i] = map(int, input().split())

total = 0
for i in range(n):
    for j in range(i + 1, n):
        #print(sqrt((x[i] - x[j]) ** 2 + (y[i] - y[j]) ** 2))
        total += 2 * sqrt((x[i] - x[j]) ** 2 + (y[i] - y[j]) ** 2)

print(total / n)

Measured memory_bytes: 3064
using System;

namespace B___Tap_Dance
{
    class Program
    {
        static void Main(string[] args)
        {
            string S = Console.ReadLine();
            char[] charS = S.ToCharArray();
            char[] RUD = new char[3] { 'R', 'U', 'D' };
            char[] LUD = new char[3] { 'L', 'U', 'D' };

            for (int i = 0; i < charS.Length; i= i+2)
            {
                if (charS[i] != RUD[0] && charS[i] != RUD[1] && charS[i] != RUD[2])
                {
                    Console.WriteLine("No");
                    return;
                }
            }

            for (int i = 1; i < charS.Length; i=i+2)
            {
                if (charS[i] != LUD[0] && charS[i] != LUD[1] && charS[i] != LUD[2])
                {
                    Console.WriteLine("No");
                    return;
                }

            }

            Console.WriteLine("Yes");
            return;
        }
    }
}


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

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

int main()
{
    int a, b;
    cin >> a >> b;

    if (a == b)
        OP(a + b);
    else if (a < b)
        OP(b + b - 1);
    else
        OP(a + a - 1);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

vector< ll > divisor(ll n) {
  vector< ll > ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

int main() {
  ll n;
  cin >> n;
  ll ans = 0;
  for(ll x : divisor(n)){
    if(x == 1)continue;
    ll tmp = n;
    while(tmp%x == 0)tmp/=x;
    tmp %= x;
    if(tmp == 1)ans++;
  }
  ans += divisor(n-1).size()-1;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3656
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
#define int long long


signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int h,w; cin >> h >> w;
    vector<vector<char> > s(h+2,vector<char>(w+2));
    for(int i = 1;i < h+1;i ++){
        for(int j = 1;j < w+1;j ++){
            cin >> s.at(i).at(j);
        }
    }

    vector<vector<int> > t(h+2,vector<int>(w+2,10000));
    t.at(0).at(1) = 0;

    for(int i = 0;i < 50;i ++){
        for(int j = 1;j < h+1;j ++){
            for(int k = 1;k < w+1;k ++){
                if(s.at(j).at(k) == '.'){
                    t.at(j).at(k) = min(t.at(j).at(k),t.at(j).at(k-1)+1);
                    t.at(j).at(k) = min(t.at(j).at(k),t.at(j).at(k+1)+1);
                    t.at(j).at(k) = min(t.at(j).at(k),t.at(j-1).at(k)+1);
                    t.at(j).at(k) = min(t.at(j).at(k),t.at(j+1).at(k)+1);
                }
            }
        }

    }

    int count = 0;
    for(int i = 1;i < h+1;i ++){
        for(int j = 1;j < w+1;j ++){
            if(s.at(i).at(j) == '.') count ++;
        }
    }

    if(t.at(h).at(w) == 10000){
        cout << -1 << endl;
    }else{
        cout << count - t.at(h).at(w) << endl;
    }

    
}

Measured memory_bytes: 256
a, b, c, x = int(input()), int(input()), int(input()), int(input())

ans = 0
for i in range(a + 1):
    for j in range(b + 1):
        for k in range(c + 1):
            if x == i * 500 + j * 100 + k * 50:
                ans += 1

print(ans)

Measured memory_bytes: 3060