akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define pb push_back
#define endl '\n'
#define line cout<<"----------------------"<<endl
#define mp make_pair
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL)
#define filein freopen("input.txt","r",stdin)
#define fileout freopen("output.txt","w",stdout)
using namespace std;
const ll  mx=300009;
vector<int> v[mx];
bool visit[mx];
int dp[mx];
void dfs(int s, int lv)
{
    visit[s]=true;
    dp[s]=1;
    for(auto x: v[s])
    {
        if(visit[x]==false)
        dfs(x,lv+1);
        dp[s]=max(dp[s],dp[x]+1);
    }
}
int main()
{
    int n,m;
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        int a,b;
        cin>>a>>b;
        v[a].pb(b);
    }
    for(int i=1;i<=n;i++)
    {
        if(visit[i]) continue;
        dfs(i,0);
    }
    int ans=0;
    for(int i=1;i<=n;i++) ans=max(ans,dp[i]);
    cout<<ans-1<<endl;
}


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

int main(){
    int n;
    cin >> n;
    vector<int> l(n);
    rep(i,n) cin >> l[i];
    sort(l.begin(),l.end());
    int ans = 0;
    for(int i = 0;i < n;i++){
        for(int j = i+1;j < n;j++){
            auto itr = lower_bound(l.begin(),l.end(),l[i]+l[j]);
            int d = distance(itr,l.end());
            ans += n-j-1-d;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		String s = sc.next();
		String t = sc.next();

		char[] cs = s.toCharArray();
		char[] ct = t.toCharArray();

		Arrays.sort(cs);
		Arrays.sort(ct);

		s = new String(cs);
		t = new StringBuilder(new String(ct)).reverse().toString();


		System.out.println(s.compareTo(t) < 0 ? "Yes" : "No");
	}
}

Measured memory_bytes: 21972
n,m = map(int,input().split())
A = list(map(int,input().split()))
from itertools import accumulate
A = accumulate([0]+A)

A = [a % m for a in A]

lst = {}

for a in A:
  if a not in lst:
    lst[a] = 0
  lst[a] += 1
  
def comb2(n):
  return n*(n-1)//2

ans = 0
for key in lst:
  ans += comb2(lst[key])
print(ans)

Measured memory_bytes: 14252
#include "bits/stdc++.h"

typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define REP(i,n) for (int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
 
using namespace std;

signed main(){
    
    string s;
    cin >> s;
    int g = 0,p = 0;
    REP(i,s.size()){
        if(s[i] == 'g')g++;
        else p++;
    }


    cout << (g-p)/2;


    return 0;
}


Measured memory_bytes: 512
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <numeric>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
#include <cassert>
#include <random>
#include <time.h>
#include <unordered_set>

using namespace std;
using Int = long long;

constexpr double EPS = 1e-10;
constexpr long long MOD = 1000000007;

long long mod_pow(long long x, long long n) {
    long long res = 1;
    for (int i = 0;i < 60; i++) {
        if (n >> i & 1) res = res * x % MOD;
        x = x * x % MOD;
    }
    return res;
}

long long my_mod_pow(long long x, long long n) {
	long long ret = 1;
	for (; n > 0; n >>= 1, x = x * x % MOD) {
		if (n & 1) {
			ret = ret * x % MOD;
		}
	}
	return ret;
}

template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

void fastInput() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

void insertionSort(vector<int> &A, int l, int r) {

    for (int i = l+1; i < r; i++) {
        for (int k = l; k < r; k++) {
            if (k != r-1) cout << A[k] << " ";
            else cout << A[k];
        }
        cout << endl;

        int j;
        int v = A[i];
        for (j = i-1; j >= l && A[j] > v; j--) {
            A[j+1] = A[j];
        }
        A[j+1] = v;
    }
}

int select(vector<int> &A, int k) {

}

int main(void) {
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    insertionSort(A, 0, N);

    for (int i = 0; i < N; i++) {
        if (i != N-1) cout << A[i] << " ";
        else cout << A[i];
    }
    cout << endl;
}



Measured memory_bytes: 3088
#![allow(unused_imports)]
#![allow(unused_macros)]
use std::cmp::{max, min};
use std::collections::*;
use std::io::{stdin, Read};

#[allow(unused_macros)]
macro_rules! parse {
    ($it: ident ) => {};
    ($it: ident, ) => {};
    ($it: ident, $var:ident : $t:tt $($r:tt)*) => {
        let $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
    ($it: ident, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
    ($it: ident, $var:ident $($r:tt)*) => {
        let $var = parse_val!($it, usize);
        parse!($it $($r)*);
    };
}

#[allow(unused_macros)]
macro_rules! parse_val {
    ($it: ident, [$t:tt; $len:expr]) => {
        (0..$len).map(|_| parse_val!($it, $t)).collect::<Vec<_>>();
    };
    ($it: ident, ($($t: tt),*)) => {
        ($(parse_val!($it, $t)),*)
    };
    ($it: ident, u1) => {
        $it.next().unwrap().parse::<usize>().unwrap() -1
    };
    ($it: ident, $t: ty) => {
        $it.next().unwrap().parse::<$t>().unwrap()
    };
}

#[cfg(debug_assertions)]
macro_rules! debug {
    ($( $args:expr ),*) => { eprintln!( $( $args ),* ); }
}

#[cfg(not(debug_assertions))]
macro_rules! debug {
    ($( $args:expr ),*) => {
        ()
    };
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    parse!(it, n: usize, l: [usize; n]);
    let mut v = vec![];
    let mut ret = 0;
    for i in 0..n {
        for j in (i + 1)..n {
            for k in (j + 1)..n {
                if l[i] == l[j] || l[i] == l[k] || l[j] == l[k] {
                    continue;
                }
                v = vec![l[i], l[j], l[k]];
                v.sort();
                if v[2] < v[0] + v[1] {
                    ret += 1;
                }
            }
        }
    }
    println!("{}", ret);
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}


Measured memory_bytes: 2124
#include<bits/stdc++.h>
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define in(x) scanf("%d",&x)
#define inn(x,y) scanf("%d%d",&x,&y)
#define innn(x,y,z) scanf("%d%d%d",&x,&y,&z)

using namespace std;
const int N=2e6+5;
const int mod=1e9+7;

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

Measured memory_bytes: 256
def insertion_sort(a, n):
    for i in range(1, n):
        v = a[i]
        j = i - 1
        while j >= 0 and a[j] > v:
            a[j+1] = a[j]
            j -= 1
        a[j+1] = v
        print(' '.join(str(i) for i in a))


def main():
    n = int(input())
    a = [int(i) for i in input().split(' ')]
    print(' '.join(str(i) for i in a))
    insertion_sort(a, n)


main()


Measured memory_bytes: 5612
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
#include <iomanip>
#include <queue>
#include <functional>
#include <cassert>
#include <cmath>


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

using namespace std;
using ll = long long;
using ull = unsigned long long;

int main() {
	int h, w;
	vector<vector<int>> m;

	cin >> h >> w;
	m.resize(h + 2);
	m[0].resize(w + 2);
	m[h + 1].resize(w + 2);
	for (int y = 1; y < h + 1; y++) {
		m[y].resize(w + 2);
		string s;
		cin >> s;
		for (int x = 1; x < w + 1; x++)	{
			if (s[x - 1] == '#') m[y][x] = 1;
		}
	}
	for (int y = 1; y < h + 1; y++) {
		for (int x = 1; x < w + 1; x++) {
			if (m[y][x] == 1) { 
				if(m[y][x + 1] == 0 && m[y + 1][x] == 0 && m[y][x - 1] == 0 && m[y - 1][x] == 0) {
					cout << "No" NL;
					return 0;
				}
			}
		}
	}

	cout << "Yes" NL;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long int A,B,K;
  cin >> A >> B >> K;
  if (A>=K) A = A-K;
  else {
    K-=A;
    A=0;
    if (B>K) B-=K;
    else B=0;
  }
  cout << A << " " << B;
}


Measured memory_bytes: 256
#include <iostream>
#include <ccomplex>
#include <vector>
#include <cassert>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <list>
#include <assert.h>
#include <math.h>
#include <valarray>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <complex>
#include <list>
#include <time.h>
#include <stack>
#include <locale>
#include <clocale>
#include <ctype.h>
#include <wchar.h>
#include <random>
#include <vector>

using namespace std;
typedef long long int LL;
typedef long long int ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

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

	LL low = 0;
	LL high = N;

	if (N <= 20) {
		REP(i, N) {
			cout << i << endl;
			string S;
			cin >> S;
			if (S[0] == 'V') {
				break;
			}
		}
	}
	else {
		cout << 0 << endl;

		string S;

		cin >> S;

		bool lowMale = S[0] == 'M';
		bool highMale = S[0] == 'M';

		while (S[0] != 'V') {
			LL mid = (low + high) / 2;

			cout << mid << endl;

			cin >> S;

			if ((lowMale == (S[0] == 'M')&&low % 2 == mid % 2) ||
				(lowMale != (S[0] == 'M')&&low % 2 != mid % 2)) {
				low = mid;
				lowMale = S[0] == 'M';
			}
			else {
				high = mid;
				highMale = S[0] == 'M';
			}
		}
	}
}

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

int main(){
    int a,b;
    int d,r;
    double f;
    scanf("%d %d",&a,&b);
    
    d = a / b;
    r = a % b;
    f = 1.0 * a / b;
    printf("%d %d %f\n",d,r,f);
    return 0;
}



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

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;
const ll INF = 1LL<<60;
//int INF = numeric_limits<int>::max();

int main(int, char**) {
	int k, x; cin >> k >> x;
	int start = x - k + 1;
	int goal = x + k - 1;
	for (int i=start; i<=goal; i++) cout << i << " ";
	cout << endl;
	return 0;
}


Measured memory_bytes: 3636
#include<iostream>
using namespace std;
int main () {
  long long N;
  cin >> N;
  long long ans = 0ll;
  for (long long i = 1; i <= N; i ++) {
    if ((i % 5) && (i % 3)) {
      ans += i;
    }
  }
  cout << ans << endl;
}

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

// Optimization

//#pragma GCC optimize("O3")
#define endl '\n'

// Shortcut

#define int long long
#define eb emplace_back
#define pb push_back
#define pob pop_back
#define mp make_pair
#define upb upper_bound
#define lwb lower_bound
#define fi first
#define se second
#define For(i, l, r) for (int i = l; i < r; i++)
#define ForE(i, l, r) for (int i = l; i <= r; i++)
#define Ford(i, r, l) for (int i = r; i > l; i--)
#define FordE(i, r, l) for (int i = r; i >= l; i--)
#define Fora(i, a) for (auto i : a)

// I/O & Debug

#define PrintV(a) Fora(iiii, a) cout << iiii << ' '; cout << endl;
#define PrintVl(a) Fora(iiii, a) cout << iiii << endl;
#define PrintA(a, l, r) for (int iiii = l; iiii <= r; iiii++) cout << a[iiii] << ' '; cout << endl;
#define PrintAl(a, l, r) for (int iiii = l; iiii <= r; iiii++) cout << a[iiii] << endl;
#define Ptest(x) return cout << x, 0;
#define gl(s) getline(cin, s);
#define setpre(x) fixed << setprecision(x)
/*
#define debug(args...){ string _sDEB = #args; replace(_sDEB.begin(), _sDEB.end(), ',', ' '); stringstream _ssDEB(_sDEB); istream_iterator<string> _itDEB(_ssDEB); DEB(_itDEB, args); }
void DEB(istream_iterator<string> it) {}
template<typename T, typename... Args>
void DEB(istream_iterator<string> it, T a, Args... args){
    cout << *it << " = " << a << endl;
    DEB(++it, args...);
}
*/

// Functions

//#define isvowel(a) (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
#define bend(a) a.begin(), a.end()
#define rbend(a) a.rbegin(), a.rend()
#define mset(a) memset(a, 0, sizeof(a))
#define mset1(a) memset(a, 1, sizeof(a))
#define msetn1(a) memset(a, -1, sizeof(a))
#define msetinf(a) memset(a, 0x3f, sizeof(a))
#define gcd __gcd
#define __builtin_popcount __builtin_popcountll
//mt19937 rando(chrono::steady_clock::now().time_since_epoch().count());

// Data Structure

#define pque priority_queue
#define mts multiset
#define y0 _y0_
#define y1 _y1_
#define div divi
typedef long long ll;
typedef long double ld;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <ld> vld;
typedef vector <string> vs;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <vi > vvi;
typedef vector <vll > vvll;
typedef vector <pii > vpii;
typedef vector <pll > vpll;

const int N = 2e5 + 5, mod = 1e9 + 7, mod1 = 998244353, mod2 = 1e9 + 9, inf = 1e18 + 7;
const ll infll = 1e18 + 7;

int n;
int a[N];

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    string s; cin >> s;
    if (s[2] == s[3] && s[4] == s[5]) Ptest("Yes");
    cout << "No";
}

/*
==================================+
INPUT:                            |
------------------------------    |

------------------------------    |
==================================+
OUTPUT:                           |
------------------------------    |

------------------------------    |
==================================+
*/

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int n, k, x, y;
    int sum = 0;
    
    scanf("%d %d %d %d",&n, &k, &x, &y);

    if( k < n){
  		sum = k * x + (n-k)*y;
    }else{
    	sum = n * x;
    }

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

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

void chmin(Int& a, Int b) { if (a > b) { a = b; } };

int main() {
	constexpr Int INF = 1e18;
	constexpr Int maxS = 2500;
	Int N, M, S;
	cin >> N >> M >> S;
	vector<vector<tuple<int, int, Int>>> g(N);
	for (int i = 0; i < M; ++i) {
		int u, v, a, b;
		cin >> u >> v >> a >> b;
		--u; --v;
		g[u].emplace_back(v, a, b);
		g[v].emplace_back(u, a, b);
	}
	vector<Int> C(N), D(N);
	for (int i = 0; i < N; ++i) {
		cin >> C[i] >> D[i];
	}

	vector<vector<Int>> d(N, vector<Int>(maxS + 1, INF));
	d[0][min(S, maxS)] = 0;
	priority_queue<pair<Int, int>, vector<pair<Int, int>>, greater<pair<Int, int>>> que;
	que.emplace(0, min(S, maxS));
	while (!que.empty()) {
		auto p = que.top(); que.pop();
		Int cost = p.first;
		int u = p.second / 10000;
		int s = p.second % 10000;

		if (s < maxS) {
			int nxs = min(maxS, s + C[u]);
			if (d[u][nxs] > d[u][s] + D[u]) {
				d[u][nxs] = d[u][s] + D[u];
				que.emplace(d[u][nxs], u*10000 + nxs);
			}
		}
		for (auto t : g[u]) {
			int v = get<0>(t);
			int a = get<1>(t);
			Int b = get<2>(t);

			if (s - a < 0 || d[v][s - a] <= d[u][s] + b) {
				continue;
			}
			d[v][s - a] = d[u][s] + b;
			que.emplace(d[v][s - a], v*10000 + (s - a));
		}
	}

	for (int i = 1; i < N; ++i) {
		Int ans = INF;
		for (auto val : d[i]) { ans = min(ans, val); }
		cout << ans << endl;
	}

	return 0;
}


Measured memory_bytes: 6244
s = input()

ans = 0
sLength = len(s)

point = 0
tmp = 0
while(point<sLength):
    if(s[point]=="A" or s[point]=="C" or s[point]=="G" or s[point]=="T"):
        tmp += 1
    else:
        tmp = 0
    point += 1
    if(tmp>ans):
        ans = tmp

print(ans)

Measured memory_bytes: 3064
a = gets.split(' ')
a[0] = a[0].to_i
a[1] = a[1].to_i
a[2] = a[2].to_i
count = 0
for i in a[0]..a[1] do
    if (a[2] % i == 0)
        count += 1
    end
end
puts(count)



Measured memory_bytes: 8868
#include <string>
#include <vector>
#include <iostream>

using namespace std;

vector<pair<string, vector<int> > > Tree;

string put_nchar(char c, int n)
{
    string S;
    
    for(int i = 0; i < n; i++)
    {
        S += c;
    }
    
    return S;
}

void rec(int node, int depth)
{
    cout << put_nchar('.', depth) << Tree[node].first << endl;
    
    for(int i = 0; i < Tree[node].second.size(); i++)
    {
        rec(Tree[node].second[i], depth + 1);
    }
}

int main()
{
    int n;
    
    string name; int parent;
    
    cin >> n;
    
    Tree = vector<pair<string, vector<int> > >(n);
    
    for(int i = 0; i < n; i++)
    {
        cin >> parent >> name;
        
        Tree[i].first = name;
        
        if(parent != 0)
        {
            Tree[parent - 1].second.push_back(i);
        }
    }
    
    rec(0, 0);
    
    return 0;
}

Measured memory_bytes: 3448
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    int N, T;
    cin >> N >> T;
    int ans = 1001;
    for(int i = 0; i < N; i++) {
        int c, t;
        cin >> c >> t;
        if(t > T) {
            continue;
        }

        ans = min(ans, c);
    }

    if(ans == 1001) {
        cout << "TLE" << endl;
        return 0;
    }
    cout << ans << endl;
}


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

using namespace std;

typedef long long ll;

void decode() {
	long long n;
	cin >> n;
	string s = "";
	while(n--) {
		s += (char)('a' + (n % 26));
		n /= 26;
	}
	reverse(s.begin(), s.end());
	cout << s << "\n";
}	
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	decode();
	return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int h, w;
char g[100][100];

struct ve {
  int x, y, cost;
  bool err;

  bool operator<(const ve &another) const {
    return cost < another.cost;
  }
  bool operator>(const ve &another) const {
    return cost > another.cost;
  }
};

int bfs() {
  int memo[h][w];

  REP(i, h) REP(j, w) memo[i][j] = INF;
  priority_queue<ve, vector<ve>, greater<ve>> que;

  int c = (g[0][0] == '#' ? 1 : 0);
  bool f = (g[0][0] == '#' ? true : false);
  que.push(ve {0, 0, c, f});

  while(!que.empty()) {
    ve v = que.top(); que.pop();
    if(memo[v.x][v.y] <= v.cost){
      continue;
    }
    else {
      if(memo[v.x][v.y] > v.cost)  memo[v.x][v.y] = v.cost;
      if(v.x < h - 1) {
        c = (g[v.x + 1][v.y] == '#' && !v.err ? 1 : 0);
        f = (g[v.x + 1][v.y] == '#' ? true : false);
        que.push(ve {v.x + 1, v.y, v.cost + c, f});
      }
      if(v.y < w - 1) {
        c = (g[v.x][v.y + 1] == '#' && !v.err ? 1 : 0);
        f = (g[v.x][v.y + 1] == '#' ? true : false);
        que.push(ve {v.x, v.y + 1, v.cost + c, f});
      }
    }
  }

  return memo[h - 1][w - 1];
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> h >> w;
  REP(i, h) REP(j, w) cin >> g[i][j];

  cout << bfs() << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;
  
int main(){
  string S;
  cin>>S;
  if(S.at(0)==S.at(1)){
      cout<<"No"<<endl;
  }
  else if(S.at(0)==S.at(2)){
      cout<<"No"<<endl;
  }
  else if(S.at(1)==S.at(2)){
      cout<<"No"<<endl;
  }
  else{
      cout<<"Yes"<<endl;
  }
}

Measured memory_bytes: 256
#include <iostream>

int abs_diff(int x, int y) {
    return x > y ? x - y : y - x;
}

int main() {
    int a, b, c, d;
    std::cin >> a >> b >> c >> d;
    
    if (abs_diff(a,c) <= d) {
        std::cout << "Yes" << std::endl;
    } else if (abs_diff(a,b) <= d && abs_diff(b,c) <= d) {
        std::cout << "Yes" << std::endl;
    } else {
        std::cout << "No" << std::endl;
    }
}

Measured memory_bytes: 256
#C
import math
from decimal import *
N = int(input())
TA = [list(map(int,input().split())) for i in range(N)]

t,a = 1,1
for i in range(N):
    ti,ai = TA[i]
    n = Decimal(max(math.ceil(t/ti),math.ceil(a/ai)))
    t = n*ti
    a = n*ai
        
    #print(t,a)
    
print(t+a)


Measured memory_bytes: 5332
#include<iostream>
#include<vector>
#include<climits>

#define MAX 101
#define Inf (UINT_MAX-1)

typedef unsigned long long int uint;
using namespace std;

struct State{
	State():cost(Inf),bottom(1),top(1){}
	uint cost;
	uint bottom;
	uint top;
};

State m[MAX][MAX];

void CardOrder(vector<pair<uint, uint> > &vc){
	int n = vc.size();
	for(int i = 1; i <= n; ++i){
		m[i][i].cost = 0;
		m[i][i].top = vc[i-1].first;
		m[i][i].bottom = vc[i-1].second;
	}
	for(int l = 2; l <= n; ++l){
		for(int i = 1; i <= n - l + 1; ++i){
			for(int j = i; j < i + l; ++j){
				uint cost = m[i][j].cost + m[j+1][i+l-1].cost +
					m[i][j].top * m[i][j].bottom * m[j+1][i+l-1].top * m[j+1][i+l-1].bottom;
				if( cost < m[i][i+l-1].cost ){
					m[i][i+l-1].cost = cost;
					m[i][i+l-1].top = m[i][j].top;
					m[i][i+l-1].bottom = m[j+1][i+l-1].bottom;
				}
			}
		}
	}
}
void Reset(){
	for(int i = 0; i < MAX; ++i){
		for(int j = 0; j < MAX; ++j){
			m[i][j].cost = Inf;
			m[i][j].bottom = 1;
			m[i][j].top = 1;
		}
	}
}
int main()
{
	while( true ){
		int n;
		vector< pair<uint, uint> > vCards;
	
		cin >> n;

		if( cin.eof() )
			break;

		Reset();

		for(int x = 0; x < n; ++x){
			uint top, btm;
			cin >> top >> btm;

			vCards.push_back( make_pair(top, btm) );
		}
	
		CardOrder( vCards );
		cout << (n==0?0:m[1][n].cost) << '\n';
	}
	return 0;
}

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

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

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int H, W; cin >> H >> W;
    string grid[H]; rep(i, H) cin >> grid[i];
    int dp[H][W]; rep(i, H) rep(j, W) dp[i][j] = mod; //dp[i][j]: grid[i][j]にたどり着くまでに行った色changeの回数
    dp[0][0] = 0;
    bool flg = false;
    if(grid[0][0] == '#'){
        flg = true;
        /*
        rep(i, H){
            rep(j, W){
                if(grid[i][j] == '.') grid[i][j] = '#';
                else grid[i][j] = '.';
            }
        }
        */
    }
    for(int i = 0; i < H; i++){
        int down = i+1;
        for(int j = 0; j < W; j++){
            int right = j+1;
            if(down < H){
                if(grid[down][j] != grid[i][j] && grid[i][j] == '.'){
                    dp[down][j] = min(dp[down][j], dp[i][j] + 1);
                }
                else dp[down][j] = min(dp[down][j], dp[i][j]);
            }
            if(right < W){
                if(grid[i][right] != grid[i][j] && grid[i][j] == '.'){
                    dp[i][right] = min(dp[i][right], dp[i][j] + 1);
                }
                else dp[i][right] = min(dp[i][right], dp[i][j]);
            }
        }
    }
    if(flg) cout << dp[H-1][W-1]+1 << endl;
    else cout << dp[H-1][W-1] << endl;
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include <stdio.h>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define LINT long long

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

  double beaut=0;
  if(d == 0){
    beaut = (double)(m-1)/n;
  }
  else{
    REP(i, m-1){

    beaut += (double)2*(n-d)/n;
  }
  beaut /= n;
  }

  printf("%10.20f", beaut);

  return 0;
}


Measured memory_bytes: 256
s = str(input())

a = int(s[:2])
b = int(s[2:])
month = [int(i) for i in range(1,13)]

if a in month and b in month:
    print('AMBIGUOUS')

elif a in month:
    print('MMYY')

elif b in month:
    print('YYMM')

else:
    print('NA')



Measured memory_bytes: 2940
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int l[] = new int[2*n];
		for(int i=0; i<2*n; i++){
			l[i] = sc.nextInt();
		}
		int ans = 0;
		for(int i=0; i<2*n; i++){
			int largest = 0;
			int flag = 0;
			for(int j=0; j<2*n; j++){
				if(l[j]>largest){
					largest = l[j];
					flag = j;
				}
			}
			if(i%2==1){
				ans = ans + largest;
			}
			l[flag] = 0;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 23380
#include<bits/stdc++.h>
using namespace std;
int k,n;
string a[105];
int main(){
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)cin>>a[i];
	sort(a+1,a+n+1);
	for(int i=1;i<=n;i++)cout<<a[i];
	return 0;
	}

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

int main() {
	double d;
	while (cin >> d, d >= 0.) {
		if (d >= (double)(1 << 8)) {
			puts("NA");
			continue;
		}
		bitset<8>bit((int)d / 1);
		d -= (double)((int)d / 1);
		string s;
		rep(i, 4) {
			d *= 2.;
			s += to_string((int)(d / 1.));
			d -= (double)((int)(d / 1));
		}
		if (d) {
			puts("NA");
			continue;
		}
		cout << bit << '.' << s << endl;
	}
}

Measured memory_bytes: 3208
N = int(input())
h = list(map(int,input().split()))
count = 0
ans = 0
for i in range(N):
    if i != N-1:
        if h[i] >= h[i+1]:
            count += 1
            if ans < count:
                ans = count
        else:
            if ans < count:
                ans = count
            count = 0

print(ans)

Measured memory_bytes: 14224
#include <iostream>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <list>
#include <math.h>
#include <map>
using namespace std;
#define REP(i, k, n) for(int i = k;i < n; i++)
#define rep(i, n) REP(i,0,n)
#define ll long long int
int dx[4] = {0,-1,1,0};
int dy[4] = {-1,0,0,1};
#define eps 10e-6
#define mod 1000000007
ll a[100001];
int n;
int cnt1[26];
int cnt2[26];
int main(void){
	string a,b;
	vector<char> l1;
	vector<char> l2;
	cin >> a>> b;
	rep(i,a.size()){
		l1.push_back(a[i]);
	}
	rep(i,b.size()){
		l2.push_back(b[i]);
	}
	sort(a.begin(), a.end());
	sort(b.rbegin(), b.rend());
	vector<string> vec;
	vec.push_back(a);
	vec.push_back(b);
	sort(vec.begin(), vec.end());
	cout << ((vec[0] == a && a!=b)?"Yes":"No") << endl;
}


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

int N, A, B, C;
std::vector<int> l;

int dfs(int n, int a, int b, int c){//引数::探索の深さ、竹Aの長さ、竹Bの長さ、竹Cの長さ。
  if(n == N){	//最深部における処理
    if(std::min( {a, b, c} ) > 0){//A,B,Cを作るのに少なくとも一つの竹を使う必要がある。
      return std::fabs(a - A) + std::fabs(b - B) + std::fabs(c - C) - 30;
      //30引くのは最初に竹を選ぶという行為にMPを消費しないため。a-Aなどは延長/短縮に使うMP。
    }else{
      return 100000;
    }
  }

  int mp1 = dfs(n + 1, a, b, c);			//深さkに対してk番目の竹を選ばない。
  int mp2 = dfs(n + 1, a + l[n], b, c) + 10;//竹Aを作るのにk番目の竹を使う。
  int mp3 = dfs(n + 1, a, b + l[n] ,c) + 10;//竹Bを作るのにk番目の竹を使う。
  int mp4 = dfs(n + 1, a, b, c + l[n]) + 10;//竹Cを作るのにk番目の竹を使う。
  return std::min( {mp1, mp2, mp3, mp4} );	//深さ0での比較
}

int main(){
  std::cin >> N >> A >> B >> C;
  std::copy_n(std::istream_iterator<int>(std::cin), N, std::back_inserter(l));
  std::cout << dfs(0, 0, 0, 0) << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
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 ll = long long;
using P = pair<ll, ll>;
const long double PI = acos(-1.0L);
ll GCD(ll a, ll b) { return b?GCD(b, a%b):a; }
ll LCM(ll a, ll b) { return a/GCD(a, b)*b; }

int e;

int main() {
    while(1) {
        cin >> e;
        if(e == 0) break;
        int ans = 1e9;
        for(int y = 0; y*y <= e; ++y) {
            for(int z = 0; z*z*z <= e; ++z) {
                int x = e-y*y-z*z*z;
                if(x >= 0) {
                    chmin(ans, x+y+z);
                }
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3064
def solv():
    s = ["" for _ in range(26)]
    t = ["" for _ in range(26)]
    for i in range(len(S)):
        if s[ord(S[i]) - ord('a')] == "":
            s[ord(S[i]) - ord('a')] = T[i]
        else:
            if s[ord(S[i]) - ord('a')] != T[i]:
                return False
        if t[ord(T[i]) - ord('a')] == "":
            t[ord(T[i]) - ord('a')] = S[i]
        else:
            if t[ord(T[i]) - ord('a')] != S[i]:
                return False
    return True


S = input()
T = input()
print("Yes" if solv() else "No")


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

int main() {
    map<char, bool> ab;
    string s;
    cin >> s;
    for(char c = 'a'; c <= 'z'; c++) {
        ab[c] = false;
    }
    for(char c : s) {
        ab[c] = true;
    }
    for(char c = 'a'; c <= 'z'; c++) {
        if(!ab.at(c)) {
            cout << c << endl;
            return 0;
        }
    }
    cout << "None" << endl;
    return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
#include<algorithm>
using namespace std;
pair<double,int>dat[1000];
//Y*(tx-sx)=(X-sx)*(ty-sy)+sy*(tx-sx)
//Y*(bx-ax)=(X-ax)*(by-ay)+ay*(bx-ax)
//X=ax
//Y*(tx-sx)=(ax-sx)*(ty-sy)+sy*(tx-sx)
//(bx-ax)*(X*(ty-sy)+sy*tx-sx*ty)=(tx-sx)*(X*(by-ay)+ay*bx-ax*by)
//(bx-ax)*(ty-sy)*X+(bx-ax)*(sy*tx-sx*ty)=(tx-sx)*(by-ay)*X+(tx-sx)*(ay*bx-ax*by)
//((bx-ax)*(ty-sy)-(tx-sx)*(by-ay))*X=(tx-sx)*(ay*bx-ax*by)-(bx-ax)*(sy*tx-sx*ty)
int main(){
    int t;
    scanf("%d",&t);
    while(t--){
        long long ax,ay,bx,by;
        scanf("%lld%lld%lld%lld",&ax,&ay,&bx,&by);
        int c;
        if(ax>bx){
            long long cx=ax;
            ax=bx;
            bx=cx;
            long long cy=ay;
            ay=by;
            by=cy;
        }
        scanf("%d",&c);
        int now=0;
        if(ax==bx){
            if(ay>by){
                long long cy=ay;
                ay=by;
                by=cy;
            }
            for(int i=0;i<c;i++){
                long long sx,sy,tx,ty;
                int type,z;
                scanf("%lld%lld%lld%lld%d%d",&sx,&sy,&tx,&ty,&type,&z);
                type^=z;
                if(tx!=sx&&!(sx>ax&&tx>ax)&&!(sx<ax&&tx<ax)){
                    double Y=(double)((ax-sx)*(ty-sy)+sy*(tx-sx))/(tx-sx);
                    if((double)ay<Y&&Y<(double)by){
                        dat[now++]=make_pair(Y,type);
                    }
                }
            }
        }else{
            for(int i=0;i<c;i++){
                long long sx,sy,tx,ty;
                int type,z;
                scanf("%lld%lld%lld%lld%d%d",&sx,&sy,&tx,&ty,&type,&z);
                type^=z;
                if((bx-ax)*(ty-sy)-(tx-sx)*(by-ay)!=0){
                    double X=(double)((tx-sx)*(ay*bx-ax*by)-(bx-ax)*(sy*tx-sx*ty))/((bx-ax)*(ty-sy)-(tx-sx)*(by-ay));
                    if(sx==tx){
                        double Y=(double)((sx-ax)*(by-ay)+ay*(bx-ax))/(bx-ax);
                        if((double)sy<Y&&(double)ty<Y)continue;
                        if((double)sy>Y&&(double)ty>Y)continue;
                    }else{
                        if((double)sx<X&&(double)tx<X)continue;
                        if((double)sx>X&&(double)tx>X)continue;
                    }
                    if((double)ax<X&&X<(double)bx){
            //          printf("%f ",X);
                        dat[now++]=make_pair(X,type);
                    }
                }
            }
        }
        std::sort(dat,dat+now);
        int val=dat[0].second;
        int ret=0;
        for(int i=0;i<now;i++){
            if(dat[i].second!=val){
                ret++;
                val=dat[i].second;
            }
        }
        printf("%d\n",ret);
    }
}

Measured memory_bytes: 1048
#define _CRT_SECURE_NO_WARNINGS

#pragma GCC optimize("O3")

#include <iostream>
#include <algorithm>
#include <vector>
#include <cassert>
#include <cstring>
#include <numeric>
#include <set>
#include <queue>
#include <deque>
#include <array>
#include <string>
#include <cmath>
#include <random>
#include <ctime>
#include <map>
#include <functional>
#include <bitset>
#include <complex>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>

#define sz(a) (int)((a).size())
#define all(a) (a).begin(), (a).end()
#define pb push_back

using namespace std;
using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;
using ld = long double;

int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n;
	cin >> n;
	vector<vi> a(3, vi(n));
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 3; j++) {
			cin >> a[j][i];
		}
	}
	vector<vi> dp(3, vi(n, 0));
	for (int i = 0; i < 3; i++) {
		dp[i][0] = a[i][0];
	}
	for (int i = 1; i < n; i++) {
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < 3; k++) {
				if (j != k) {
					dp[j][i] = max(dp[j][i], dp[k][i - 1] + a[j][i]);
				}
			}
		}
	}
	cout << max({ dp[0].back(), dp[1].back(), dp[2].back() });
}


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

int main() {
    int w, h; cin >> w >> h;
    string c; cin >> c;
    
    for (int height = 1; height <= h; ++height) {
        string line = "";
        for (int width = 1; width <= w; ++width) {
            // +
            if (height == 1 && width == 1 || height == 1 && width == w || height == h && width == 1 || height == h && width == w) line += "+";
            // -
            else if (height == 1 && (1 < width && width < w) || height == h && (1 < width && width < w)) line += "-";
            // |
            else if ((1 < height && height < h) && width == 1 || (1 < height && height < h) && width == w) line += "|";
            // char
            else if (height == h / 2 + 1 && width == w / 2 + 1) line += c;
            // .
            else line += ".";
        }
        cout << line << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3216
#include<stdio.h>
#define WHITE 1
#define BLACK 2
//#define GRAY 3
#define INF 10000000

int n,A[100][100];
int prim(void);

int main(){
  int i,j;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      scanf("%d",&A[i][j]);
    }
  }

  printf("%d\n",prim());

  return 0;
  
}


 
int prim(){
  int i,j,u,v,mincost,sum=0;
  int d[100],p[100],color[100];
  for(u=0;u<n;u++){
    d[u]=INF;
    p[u]=-1;
    color[u]=WHITE;
  }

  d[0]=0;

  while(1){
    mincost=INF;
    for(i=0;i<n;i++){
      if(color[i]!=BLACK&&d[i]<mincost){
	mincost=d[i];
	u=i;
      }
    }
    
    if(mincost==INF)break;
    color[u]=BLACK;
    for(v=0;v<n;v++){
      if((color[v]!=BLACK)&&(A[u][v]!=-1)){
	if(d[v]>A[u][v]){
	  p[v]=u;
	  d[v]=A[u][v];
	  // color[v]=GRAY;
	}
      }
    }
  }
  
  for(j=0;j<n;j++){
    if(p[j]!=-1){
      sum+=A[j][p[j]];
    }
  }
  return sum;
}



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

int main(){
    
    int H, W;
    
    while(1){
        cin >> H >> W;
        if(H == 0 && W == 0) break;
        for(int i = 0 ; i < H ; i++){
            for(int j = 0 ; j < W ; j++){
                if((i + j) % 2 == 0) cout << "#";
                else cout << ".";
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3100
#include <iostream>
using namespace std;
int main()
{
	int a, b, c, k;
	cin >> a >> b >> c >> k;
	if (k <= a)//all take a
		cout << k << endl;
	else if (k - a <= b)//take all a and take some b
		cout << a << endl;
	else //k>a+b,take (k-a-b)*c
		cout << a - (k - a - b) << endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define SELECTER(_1, _2, _3, SELECT, ...) SELECT
#define REP1(i, n) for(int i=0; (i)<(n); (i)++)
#define REP2(i, a, b) for(int i=(a); (i)<(b); (i)++)
#define REP(...) SELECTER(__VA_ARGS__, REP2, REP1,) (__VA_ARGS__)
#define MOD 1000000007

template <class T> ostream& operator<<(ostream& os, const vector<T>& v){ os << "{"; for(size_t i=0; i<v.size(); i++) os << v[i] << (i+1==v.size() ? "" : ", "); os << "}"; return os; }
template <class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p){ return os << "{" << p.first << ", " << p.second << "}"; }

long long N;
vector<long long> c;
vector<vector<long long>> G;
vector<long long> sz;
vector<long long> dp;
vector<long long> ans;

void dfs(long long cur, long long prv){
    long long cnt = 1;
    for(long long nxt : G[cur]){
        if(nxt == prv) continue;
        dfs(nxt, cur);
        cnt += sz[nxt];
    }
    sz[cur] = cnt;
}

void efs(long long cur, long long prv){
    long long col = c[cur];
    long long dpcol = dp[col];
    for(long long nxt : G[cur]){
        dp[col] = 0;
        if(nxt == prv) continue;
        efs(nxt, cur);
        long long cnt = sz[nxt] - dp[col];
        ans[col] += cnt*(cnt-1)/2+cnt;
    }
    dp[col] = dpcol+sz[cur];
}

int main(){
    cin >> N;
    c.resize(N);
    G.resize(N);
    sz.resize(N);
    dp.resize(N);
    ans.resize(N);

    REP(i, N){
        cin >> c[i];
        c[i]--;
    }
    REP(i, N-1){
        long long a, b;
        cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    dfs(0, -1);
    efs(0, -1);
    REP(i, N){
        long long cnt = sz[0] - dp[i];
        ans[i] += cnt*(cnt-1)/2+cnt;
    }
    REP(i, N){
        ans[i] = N*(N-1)/2+N-ans[i];
        cout << ans[i] << endl;
    }

    return 0;
}

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

int main() {
    int a,b,c;
    cin>>a>>b>>c;
    int count=0;
    for(a;a<=b;a++){
        if(c%a==0){
            count++;
        }else{
            continue;
        }
    }cout<<count<<endl;
}


Measured memory_bytes: 3112
#include <stdio.h>

int main(void){
	int a, b, c, count = 3;

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

	if(a == b)
		count--;
	if(a == c)
		count--;
	if(b == c)
		count--;

	printf("%d\n", (count) ? count : 1);

	return 0;
}


Measured memory_bytes: 128
#include<stdio.h>

int main(void)
{
  int n, v[20]={}, c[20]={};
  int i;
  int cnt = 0;
  
  scanf("%d", &n);

  for(i=0; i<n; i++)
	scanf("%d", &v[i]);
  for(i=0; i<n; i++)
	scanf("%d", &c[i]);
  for(i=0; i<n; i++)
    if(v[i]>c[i])
      cnt += v[i]-c[i];
  
  printf("%d\n", cnt);
  
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define speed ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define ub(a,x) upper_bound(a.begin(),a.end(),x)-a.begin()
#define lb(a,x) lower_bound(a.begin(),a.end(),x)-a.begin()
#define ALL(v)   v.begin(),v.end()
int main()
{
	speed
	ll n ,d;
	cin >> n >> d;
	ll vec[n][d];
	for(int x =0; x<n; x++)
	{
		for(int y = 0; y<d; y++)
			cin >> vec[x][y];
	}
int ans =0 ;
	for(int x =0; x<n; x++)
	{
		for(int y =x+1; y<n; y++)
		{
			ll s = 0;

			for(int z =0; z<d; z++)
			{
				
				s += pow(vec[x][z]- vec[y][z], 2LL);
			}
			
			int d1 = sqrt(s);
			if(d1*d1 == s)
				ans++;
		}
	}
	cout << ans;
	return 0;
}


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

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
const int inf = 1000000001;
const ll INF = 1e16;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<<fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };

ll f(ll a, ll b){
  if(a<b){
    if(b%a==0){
      return a*(2*b/a-1);
    }else{
      return 2*(b/a)*a + f(a,b%a);
    }
  }
  else{
    if(a%b == 0){
      return b*(2*a/b-1);
    }else{
      return 2*(a/b)*b+f(a%b,b);
    }
  }
}

int main(){
  ll n,x;
  cin>>n>>x;
  cout<<n+f(x,n-x)<<endl;
}

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

int main(){
	int n;cin >> n;
	float a[8], x1, x2, y1, y2, ans;
	while(n--){
		for(int i = 0;i < 8;i++)cin >> a[i];
		y1 = a[3]-a[1];x1 = a[2]-a[0];
		y2 = a[7]-a[5];x2 = a[6]-a[4];
		ans = y1*x2-y2*x1;
		if(ans == 0)cout << "YES" << endl;
		else cout << "NO" << endl;
	}
	return 0; 
}

Measured memory_bytes: 3184
S=input()
T=input()
n=len(S)-len(T)+1
t=len(T)
if S.find(T)!=-1:
    print(0)
else:
    tmp=0
    id=-1
    for i in range(n):
        cnt=0
        for j in range(t):
            if S[i+j]==T[j]:
                cnt+=1
        if cnt>tmp:
            tmp=cnt
            id=i
    print(t-tmp)


Measured memory_bytes: 9104
import math
N,A,B=map(int,input().split())
N_list=list(str(N))
num=0
if len(N_list)==1:
    for n in range(N+1):
        if A<=n<=B:
            num+=n
elif len(N_list)==2:
    for n in range(N+1):
        if A<=((n//10)+(n%10))<=B:
            num+=n
elif len(N_list)==3:
    for n in range(N+1):
        if A<=((n//100)+((n%100)//10)+(n%10))<=B:
            num+=n
elif len(N_list)==4:
    for n in range(N+1):
        if A<=((n//1000)+((n%1000)//100)+((n%100)//10)+(n%10))<=B:
            num+=n
elif len(N_list)==5:
    for n in range(N+1):
        if A<=((n//10000)+((n%10000)//1000)+((n%1000)//100)+((n%100)//10)+(n%10))<=B:
            num+=n
print(num)

Measured memory_bytes: 39024
#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>

using namespace std;

#define REP(i,n) for(int i=0;i<int(n);i++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
typedef long long ll;

int cost[1010];
int cast[1010];

int main(void){

	int N,M;
	cin >> N >> M;
	int i,j,x;
	for(i=1;i<=N;i++) cin >> cost[i];
	for(i=1;i<=M;i++){
		cin >> x;
		for(j=1;j<=N;j++){
			if(x>=cost[j]){
				cast[j]++; break;
			}
		}
	}

	int ans,p=0;
	for(i=1;i<=N;i++){
		if(cast[i]>p){
			p=cast[i]; ans=i;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1168
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 1000000
)

var sc *bufio.Scanner

func initScanner(r io.Reader) *bufio.Scanner {
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords) // bufio.ScanLines
	return sc
}

func main() {
	sc = initScanner(os.Stdin)
	resolve()
}

func resolve() {
	n := scanInt(sc)
	as := nextIntSlice(sc, n)
	l := len(as)
	for i := 0; 2*i < len(as); i++ {
		v := as[l-2*i-1]
		fmt.Print(v)
		fmt.Print(" ")
	}
	for i := 0; 2*i+l%2 < l; i++ {
		v := as[2*i+l%2]
		fmt.Print(v)
		fmt.Print(" ")
	}
	return
}

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	a, _ := strconv.Atoi(sc.Text())
	return int(a)
}

func nextString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func nextIntSlice(sc *bufio.Scanner, n int) (a []int) {

	a = make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = nextInt(sc)
	}
	return a
}

// snip-scan-funcs
func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}
func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 7076
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
#include <bitset>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define rep2(i, a)for(auto i : a)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x, std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
#define vec_unique(_a) _a.erase(std::unique(all(_a)), _a.end());
#define vvec vector<vector<ll>>
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
const int mod = 1000000007;
ll power(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x *= x; p /= 2; } else { a *= x; p--; } }return a; }
ll mpower(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x = x * x % mod; p /= 2; } else { a = a * x % mod; p--; } }return a; }
ll co(ll n, ll k) { ll a = 1; rep(i, 1ll, k) { a *= n - i + 1; a /= i; }return a; }
ll mc(ll n, ll m) { ll k = 1, l = 1; rep(i, n - m + 1, n + 1) k = k * i % mod; rep(i, 1, m + 1) l = l * i % mod; l = mpower(l, mod - 2); return k * l % mod; }

int main(void) {
	int n;
	cin >> n;
	vector<int> a(n), b(n);
	rep(i, 0, n)cin >> a[i] >> b[i];
	sort(all(a));
	sort(all(b));
	if (n % 2 == 0) {
		printf("%d\n", b[n / 2] + b[n / 2 - 1] - a[n / 2] - a[n / 2 - 1] + 1);
	}
	else {
		printf("%d\n", b[n / 2] - a[n / 2] + 1);
	}
	return 0;
}


Measured memory_bytes: 4804
#![allow(unused_imports)]
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(deprecated)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;
use std::usize;

const MOD_10_9_7: u64 = 1_000_000_007;
const INF: i64 = 1_000_000_000_000;
const MIN_INF: i64 = -1_000_000_000_000;

/// FYI: https://github.com/vain0x/scan-bench
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($t:ty) =>
        (rl().parse::<$t>().unwrap());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

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

fn digits(x: u64) -> Vec<char> {
    x.to_string().chars().collect()
}

fn dfs(x: u64, upper: u64) -> u64 {
    if x > upper {
        return 0;
    }
    let mut count = 0;

    let d = digits(x);
//    debug!(&d);
    if d.contains(&'3') && d.contains(&'5') && d.contains(&'7') {
        count += 1;
    }

    for i in &[3, 5, 7] {
        count += dfs(10 * x + i, upper);
    }

    count
}

fn main() {
    let n = read!(u64);

    println!("{}", dfs(0, n));
}


Measured memory_bytes: 4352