akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#define ll long long
#define mod 1000000007
using namespace std;

ll fact(ll n){
  ll res = 1, i;
  for(i = 1; i <= n; i++){
    res = (res * i) % mod;
  }
  return res;
}

int main(){

  ll n, m, dog, monky, ans;

  cin >> n >> m;

  dog = fact(n);
  monky = fact(m);
  if(n == m){
    ans = (dog * monky * 2) % mod;
  }else if(n - m == 1 || n - m == -1){
    ans = (dog * monky) % mod;
  }else{
    ans = 0;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
vector<long long int > fillPrefixSum(vector<long long int> v) 
{ 
   
   int n = v.size();
   vector<long long int> prefix(n);
    prefix[0] = v[0]; 
    int mod = 1e9+7;
    for (int i = 1; i < n; i++) 
        prefix[i] = (prefix[i - 1]%mod + v[i]%mod)%mod; 
  return prefix;  
} 
int main()
{
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(false);
    int n;
    cin>>n;
    vector<long long int> v(n);
    int mod = 1e9+7;
    for(long long int &x:v)
    {
		cin>>x;
	}
	//for(long long int x:v)cout<<x<<" ";
	//cout<<endl;
	reverse(v.begin(),v.end());
	//for(long long int x:v)cout<<x<<" ";
	//cout<<endl;
	vector<long long int> prefix = fillPrefixSum(v);
	//for(long long int x:prefix)cout<<x<<" ";
	//cout<<endl;
	reverse(v.begin(),v.end());
	//for(long long int x:v)cout<<x<<" ";
	//cout<<endl;
	reverse(prefix.begin(),prefix.end());
	//for(long long int x:prefix)cout<<x<<" ";
	//cout<<endl;
	long long int sum=0;
	for(int i=0;i<n-1;i++)
	{
		sum =( sum %mod + (v[i]%mod*prefix[i+1]%mod)%mod)%mod;
	}
	cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 7944
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,vl>;
using T = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define prt(v) cout<<v<<"\n";
#define fi(v) get<0>(v)
#define se(v) get<1>(v)
#define th(v) get<2>(v)
#define endl "\n"
template <typename T> bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1000000007;

signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll C;
    cin >> C;
    vector<vector<ll>> D(C+1, vector<ll>(C+1, 0));
    for(ll i=0;i<C;++i)
        for(ll j=0;j<C;++j)cin>>D[i+1][j+1];
    vector<vector<ll>> c(N+1, vector<ll>(N+1, 0));
    for(ll i=0;i<N;++i)
        for(ll j=0;j<N;++j)cin>>c[i+1][j+1];

    //change[i][j]はあまりiのやつを色jに変えるために必要なコスト
    vector<vector<ll>> change(3, vector<ll>(C+1, 0));
    for(ll i=0;i<3;++i)
        for(ll j=1;j<=C;++j){
            for(ll k=1;k<=N;++k)
                for(ll l=1;l<=N;++l){
                    if((k+l)%3==i)change[i][j]+=D[c[k][l]][j];
                }
        }
    ll ans=INF;
    for(ll i=1;i<=C;++i){
        for(ll j=1;j<=C;++j){
            if(i==j)continue;
            for(ll k=1;k<=C;++k){
                if(i==k||j==k)continue;
                chmin(ans,change[0][i]+change[1][j]+change[2][k]);
            }
        }
    }
    prt(ans)

    return 0;
}


Measured memory_bytes: 2304
import java.util.*;

public class Main {
public static void main(String[] args) {
		
		Scanner keyboard = new Scanner(System.in); 
		
		int N = keyboard.nextInt();
		int D = keyboard.nextInt();
		
		int ans = N/(D*2+1);
		
		if(N%(D*2+1) == 0) { 
			System.out.println(ans);
		}else{
			System.out.println(ans+1);
		}
		keyboard.close();	
	}
}


Measured memory_bytes: 23636
a, b = gets.chomp.split(" ").map(&:to_i)

array = [[1,3,5,7,8,10,12],[4,6,9,11],[2]]

group_a = 0

array.each_with_index do |group, idx|
  group_a = idx if group.include?(a)
end

array[group_a].include?(b) ? answer = "Yes" : answer = "No"

puts answer


Measured memory_bytes: 1916
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int q = Integer.parseInt(scan.next());

        for (int i = 0; i < q; i++) {
            String s = scan.next();
            String t = scan.next();

            int[][] dp = new int[s.length() + 1][t.length() + 1];
            for (int j = 0; j < s.length(); j++) {
                for (int k = 0; k < t.length(); k++) {
                    if (s.charAt(j) == t.charAt(k)) {
                        dp[j + 1][k + 1] = Math.max(dp[j][k] + 1, Math.max(dp[j + 1][k], dp[j][k + 1]));
                    } else {
                        dp[j + 1][k + 1] = Math.max(dp[j + 1][k], dp[j][k + 1]);
                    }
                }
            }

            System.out.println(dp[s.length()][t.length()]);
        }
        scan.close();

    }

}



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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;


int main() {
  int n , m ; cin >> n >> m;
  vector<pair<int,int>> vec;
  vector<pair<int,int>> ans(n);
  rep(i,m){
    int x , y ; 
    cin >> x >> y;
    vec.push_back(make_pair(x,y));
  }
  
  int flag=0;
  rep(i,n){
      ans[i].first=1;
      ans[i].second=0;    
  }
  ans[0].second=1;
    rep(i,m){
      int x=vec[i].first-1;
      int y=vec[i].second-1;
      ans[y].first++;
      if(ans[x].second==1) ans[y].second=1;
      ans[x].first--;
      if(ans[x].first==0) ans[x].second=0;
    }
    int sum=0;
    rep(i,n){
      if(ans[i].second==1) sum++;
    }
    cout<<sum<<endl;
  
}



Measured memory_bytes: 2168
def solve(L):
    if not L:
        return 0
    if 0 not in L:
        return min(L)+solve([l-min(L) for l in L])
    tmp=0
    l,p=0,False
    for i in range(len(L)):
        if L[i]==0:
            if p:
                p=False
                tmp+=solve(L[l:i])
                l=i+1
            else:
                l=i+1
        else:
            if not p:
                p=True
    return tmp+solve(L[l:])

N=int(input())
H=list(map(int,input().split()))

print(solve(H))


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

int main() {
  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;
  string ans = "";
  rep(i, ty - sy){
    ans += 'U';
  }
  rep(i, tx-sx){
    ans += 'R';
  }
  rep(i, ty-sy){
    ans += 'D';
  }
  rep(i, tx-sx){
    ans += 'L';
  }
  ans += "L";
  rep(i, ty-sy+1){
    ans += "U";
  }
  rep(i, tx-sx+1){
    ans += "R";
  }
  ans += "DR";
  rep(i, ty-sy+1){
    ans += "D";
  }
  rep(i, tx-sx+1){
    ans += "L";
  }
  ans += "U";
  cout << ans << endl;
}

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

#define ll long long
#define F first
#define S second
#define ii pair < int , int >
#define ever (;;)

int a,b,c,k;

int main()
{
    cin>>a>>b>>c>>k;

    while( b <= a )
    {
        if( !k )
        {
            cout<<"No\n";
            return 0;
        }

        k--;
        b *= 2;
    }

    while( c <= b )
    {
        if( !k )
        {
            cout<<"No\n";
            return 0;
        }

        k--;
        c *= 2;
    }

    cout<<"Yes\n";
}


Measured memory_bytes: 3632
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws java.io.IOException {
        try (BufferedReader reader = new BufferedReader(new InputStreamReader(System.in))) {
            final String s = reader.readLine();

            final String sl[] = s.split(" ");
            int N = Integer.parseInt(sl[0]);
            int i = Integer.parseInt(sl[1]);

            System.out.println(N - i + 1);
        }
    }
}


Measured memory_bytes: 21204
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, r;
    cin >> n >> r;
    if(n >= 10) {
        cout << r << endl;
    } else {
        cout << r + 100 * (10 - n) << endl;
    }
}

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

long long a, b, c;

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

	if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0) puts("0");
	else printf("%lld\n", min(a * b, min(b * c, a * c)));

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define printYes() cout << "Yes" << endl;
#define printNo() cout << "No" << endl;
#define printVector(v) rep(i, v.size()) cout << v[i] << endl;

int main()
{
  string S, T;
  cin >> S >> T;
  string ans = "UNRESTORABLE";
  vector<string> anss;
  rep(i, S.size() - T.size() + 1)
  {
    string a = S;
    rep(j, T.size())
    {
      if (S[i + j] == T[j] || S[i + j] == '?')
      {
        a[i + j] = T[j];
      }
      else
        break;
      if (j == T.size() - 1)
      {
        anss.push_back(a);
      }
    }
  }
  sort(anss.begin(), anss.end());
  if (anss.size() == 0)
  {
    cout << "UNRESTORABLE" << endl;
    return 0;
  }
  ans = anss[0];
  rep(i, ans.size())
  {
    if (ans[i] == '?')
      ans[i] = 'a';
  }
  cout << ans << endl;
  return 0;
}

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

//using namespace __gnu_pbds;

using namespace std;

#define ll  long long

typedef vector<int> vi;
typedef pair<int,int> pi;
typedef unordered_map<int,int> um;
typedef unordered_set<int> us;
typedef priority_queue<int> pq;
typedef deque<int> dq;
typedef queue<int> q;
typedef stack<int> st;

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

#define rep(i,a,b) for (int i = a; i <= b; i++)
//#define bitset<n> b<n>

/* typedef tree<int,null_type,less<int>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set; */

void c_p_c()
{
	
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

int main(){

	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

	//indexed_set s;
	//s.insert(2);
	//s.insert(3);
	//s.insert(7);
	//s.insert(9);

	//auto x = s.find_by_order(2);
	//s.order_of_key(7)
	
	//c_p_c();

	//__builtin_clz(x): the number of zeros at the beginning of the number
   // __builtin_ctz(x): the number of zeros at the end of the number
   // __builtin_popcount(x): the number of ones in the number
   // __builtin_parity(x): the parity (even or odd) of the number of ones

	int n;
	cin>>n;

	while(n>0){
		int dig = n%10;
		if(dig==7){
			cout<<"Yes";
			return 0;
		}
		n /= 10;
	}

	cout<<"No";
	//ll t;
	//cin>>t;
	//while(t--){

	//}

	return 0;
	}

		

Measured memory_bytes: 3640
import java.util.Scanner;

public class Main {

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

    String a = scanner.next();
    for (int i = a.length() - 1; i >= 0; i--) {
      System.out.print(a.charAt(i));
    }
    System.out.println();
  }
}



Measured memory_bytes: 25988
struct Read<R: std::io::BufRead> {
    stdin: R,
    v: Vec<String>,
    i: usize,
}
impl<R:std::io::BufRead> Read<R> {
    pub fn new(stdin: R) -> Self {
        Read{
            stdin: stdin,
            v: Vec::new(),
            i: 0,
        }
    }
    pub fn read_line(&mut self) {
        self.i = 0; self.v.clear();
        let mut buf = String::new();
        self.stdin.read_line(&mut buf).unwrap();
        let buf = buf.trim().to_owned();
        let mut ws = buf.split_whitespace();
        loop {
            let x = ws.next();
            if x.is_none() {break;}
            let x = x.unwrap().to_owned();
            self.v.push(x);
        }
    }
    pub fn read_t<T: std::str::FromStr>(&mut self) -> T {
        if self.i == self.v.len() {self.read_line();}
        let elem = &self.v[self.i];
        self.i += 1;
        elem.parse().unwrap_or_else(|_| panic!())
    }
    
    #[allow(dead_code)]
    pub fn read_i32(&mut self) -> i32 {
        if self.i == self.v.len() {self.read_line();}
        let elem = self.v[self.i].parse().unwrap();
        self.i += 1;
        elem
    }
    #[allow(dead_code)]
    pub fn read_usize(&mut self) -> usize {
        if self.i == self.v.len() {self.read_line();}
        let elem = self.v[self.i].parse().unwrap();
        self.i += 1;
        elem
    }
    #[allow(dead_code)]
    pub fn read_u64(&mut self) -> u64 {
        if self.i == self.v.len() {self.read_line();}
        let elem = self.v[self.i].parse().unwrap();
        self.i += 1;
        elem
    }
    #[allow(dead_code)]
    pub fn read_string(&mut self) -> String {
        if self.i == self.v.len() {self.read_line();}
        let elem = &self.v[self.i];
        self.i += 1;
        elem.to_owned()
    }
}
fn main() {
    use std::io;
    let stdin = io::stdin();
    let stdin = io::BufReader::new(stdin.lock());
    let read = Read::new(stdin);
    solve(read);
}

fn solve<R: std::io::BufRead>(mut r: Read<R>) {
    let a = r.read_i32();
    let b = r.read_i32();
    let s =format!("{}{}",a,b);
    let x:i32 = s.parse().unwrap();
    for i in 0..1001 {
        if (i * i) == x {
            println!("Yes");
            return;
        }
    }
    println!("No");
}


Measured memory_bytes: 4352
#include <iostream>
#include <iomanip>

using namespace std;

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

	int room[4][3][10] = {0};

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

		room[b - 1][f - 1][r - 1] += v;
	}

	for (int i = 0; i < 15; i++)
	{
		for (int j = 0; j < 10; j++)
		{
			if (i % 4 == 3)
			{
				cout << "##";
			}
			else
			{
				cout << setw(2) << setfill(' ') << room[i / 4][i % 4][j];
			}
		}
		cout << endl;
	}
}


Measured memory_bytes: 3108
#include<bits/stdc++.h>
using namespace std;
const long long INF = (1LL << 32);
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<pair<ll, ll>> vp;
typedef vector<string> vs;
typedef vector<char> vc;
typedef list<ll> lst;
typedef pair<ll, ll> P;

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

#define Endl endl

/*--------------------template--------------------*/


int main() {
    cin>>n>>m;
    cout<<(n*m%2?"Odd":"Even")<<endl;
}

Measured memory_bytes: 384
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <cmath>
#include <stack>

using namespace std;
using ll = long long int;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}


void solve(long long N){
  ll dp[100010];
  dp[0] = 0;
  for(ll i=1; i<=100000; i++) {
    dp[i] = 100000;
    ll p = 1;
    while(p <= i) {
      dp[i] = min(dp[i], dp[i-p]+1);
      p *= 6;
    }
    p = 1;
    while(p <= i) {
      dp[i] = min(dp[i], dp[i-p]+1);
      p *= 9;
    }
  }
  std::cout << dp[N] << std::endl;
}

int main(){
  long long N;
  scanf("%lld",&N);
  solve(N);
  return 0;
}



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

#define int long long

int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

/*
#define cin ifs
#define cout ofs
ifstream ifs("in.txt");
ofstream ofs("out.txt");
//*/

// DPを用いて最長増加部分列問題を解く
const int MAX_N = 200000;
const int INF = 1e11;

int n = 0;
int a[MAX_N];

int dp[MAX_N];

int solve() {
    fill(dp, dp + n, INF);
    for (int i = 0; i < n; i++) {
        *lower_bound(dp, dp + n, a[i]) = a[i];
    }
    return lower_bound(dp, dp + n, INF) - dp;
}

int x_1, y_1, x_2, y_2, N;
int X[200000], Y[200000];
int idx[200000];

signed main() {
    cin >> x_1 >> y_1 >> x_2 >> y_2 >> N;
    for (int i = 0; i < N; i++) {
        cin >> X[i] >> Y[i];
        if (abs(x_1 - x_2) == abs(x_1 - X[i]) + abs(x_2 - X[i]) &&
            abs(y_1 - y_2) == abs(y_1 - Y[i]) + abs(y_2 - Y[i])) {
            idx[n] = i;
            n++;
        }
    }
    sort(idx, idx + n,
         [](int l, int r) { return abs(x_1 - X[l]) < abs(x_1 - X[r]); });
    for (int i = 0; i < n; i++) {
        a[i] = abs(y_1 - Y[idx[i]]);
    }
    int s = solve();
    double ans = 100 * (abs(x_1 - x_2) + abs(y_1 - y_2)) - (20 - 5 * M_PI) * s;
    if (min(abs(x_1 - x_2), abs(y_1 - y_2)) + 1 == s) {
        ans += 5 * M_PI;
    }
    cout << fixed << setprecision(15) << ans << endl;
}

Measured memory_bytes: 8064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdlib.h>
#include <cmath>
#include <numeric>
#include <functional>
#include <stack>
#include <iomanip>
#include <map>
#include <cstdio>

int main() {
	long long n;
	
	std::cin >> n;

	long long ans = 0;
	for (long long i = 0; i <= n; i++)
	{
		if (i % 3 == 0 || i % 5 == 0) {

		}
		else {
			ans += i;
		}
	}

	std::cout << ans << std::endl;

	return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
long long K[102][200002];
int main()
{
	int N, E;
	cin>>N>>E;
//	int x; 
//	scanf("%d", &x);
//	long long K[N][E+1];
	for(int i = 0; i <= N; i++)
		for(int j = 0; j <= E; ++j)
			K[i][j] = -1;
			
	K[0][0] = 0;
	long long out = 0;

	for(int i = 1; i <= N; i++)
	{
		int r, e;
		cin>>e>>r;
		for(int j = 0; j <= E; j++)
		{
			
			K[i][j] = K[i-1][j];
		//	cout<<K[i][j];
			if(j - e >= 0 && K[i-1][j-e] >= 0) K[i][j] = max(K[i][j], K[i - 1][j - e] + r);
			out = max(out, K[i][j]);
		}
	}
	cout<<out;
}

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

from sys import stdin

def indexing(s):
    index = []
    one_counter = 0
    zero_counter = 0

    for x in s:
        if x == '1':
            one_counter += 1
            if zero_counter > 0:
                index.append(zero_counter)
                zero_counter = 0
        else:
            zero_counter += 1
            if one_counter > 0:
                index.append(one_counter)
                one_counter = 0

    if zero_counter > 0:
        index.append(zero_counter)
    elif one_counter > 0:
        index.append(one_counter)

    return index

def calc(k, s):
    nums = indexing(s)
    _max = -1
    first = 0

    if s[0] == '0':
        _max = sum(nums[:k*2])
        nums = nums[1:]
    
    if s[-1] == '0':
        last = sum(nums[-k*2:])
        _max = max(last, _max)
        nums = nums[:-1]

    _range = k*2+1

    last = sum(nums[:_range])
    _max = max(last, _max)

    for i in range(_range, len(nums), 2):
        delete = sum(nums[i-_range:i+2-_range])
        add    = sum(nums[i:i+2])
        curr = last + add - delete

        _max = max(_max, curr, last)
        last = curr

    return _max

def main():
    n,k = [int(x) for x in stdin.readline().split()]
    s = stdin.readline().rstrip()
    ans = calc(k, s)
    print(ans)
    
if __name__=='__main__':
    main()

Measured memory_bytes: 4944
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

ll mod = 1e9 + 7;

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

  ll n;
  cin >> n;
  ll p[n];
  REP(i, n) cin >> p[i];

  SORT(p, n);

  ll s = 0;
  REP(i, n){
    if(i == n - 1) s += p[i] / 2;
    else s += p[i];
  }
  cout << s << endl;

  return 0;

}


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

int main(){
    std::pair<std::string,int> a;
    std::pair<std::string,int> b;
    std::string u;
    std::cin>>a.first>>b.first>>a.second>>b.second>>u;
    if(a.first == u){
        a.second--;
    }else{
        b.second--;
    }
    std::cout<<a.second<<" "<<b.second<<std::endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
using namespace std;
struct node{
    int key;
    node *parent,*left,*right;
};
node *NIL,*root;
 
void inorder(struct node *u){
    if(u==NIL)return;
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
}
void preorder(struct node *u){
    if(u==NIL)return;
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
}
void pr(){
    inorder(root);
    printf("\n");
    preorder(root);
    printf("\n");
}
void insert(int key){
    node *y = NIL;
    node *x = root;
    node *z;
    z = (node *)malloc(sizeof(node));
    z->key = key;
    z->left = NIL;
    z->right = NIL;
     
    while(x!=NIL){//when x==NIL break
        y = x;
        if(z->key < x->key)x = x->left;
        else x = x->right;
    }
    z->parent = y;
    if(y == NIL)root = z;//z became root,insert root
    else if(z->key < y->key)y->left = z;
    else y->right = z;
}
node * find(node *u,int k){
    while((u != NIL) && (k != u->key)){  
    //when you exchange the position of '(u != NIL)' with '(k != u->key)',the program will run failed
    //you must make sure that u!=NIl firstly,otherwise k will compare with NIL->key(which is not defined)
        if(k < u->key)u = u->left;
        else u = u->right;
    }
    return u;
}
node * treeMinmum(node *x){
	while(x->left!=NIL)x = x->left;//"leftmost"
	return x;
}
node * treeSuccessor(node *x){
	if(x->right != NIL)return treeMinmum(x->right);//exist right tree,find the next node inorder
	
	node *y = x->parent;//not exist,return parent node which acts as left-child node firstly
	while(y!=NIL && y->right == x){
		x = y;
		y = y->parent;
	}
	return y;
}
void treedelete(node *z){
	node *y;//the node to delete
	node *x;//child-node of the node needed to be deleted
	
	//make sure wheter z delete or not
	if(z->left == NIL || z->right == NIL)y = z;
	else y = treeSuccessor(z);
	
	if(y->left != NIL)x = y->left;
	else x = y->right;
	
	if(x != NIL )x->parent = y->parent; // make y->parent as x new parent
	
	// make x as y->parent new child
	if(y->parent == NIL)root = x;//y was root
	else if(y == y->parent->left)y->parent->left = x;
	else y->parent->right = x;
	
	
	if(y!=z)z->key = y->key;
	free(y);
}
int main()
{
    int n,k;
    scanf("%d",&n);
    char s[20];
    for(int i=0;i<n;++i){
        scanf("%s",s);
        if(s[0]=='i'){
            scanf("%d",&k);
            insert(k);
        }else if(s[0]=='f'){
            scanf("%d",&k);
            node *t = find(root,k);
            if(t != NIL )printf("yes\n");
            else printf("no\n");
        }
        else if(s[0]=='d'){
        	scanf("%d",&k);
        	treedelete(find(root,k));
		}
		else pr();
    }
    return 0;
}

Measured memory_bytes: 21932
#include <iostream>
#include <numeric>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <map>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
#define rep(i,a,b) for(ll i=a;i<b;i++)
inline ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
inline constexpr int intpow(ll a,ll b){
    if(b==0) return 1;
    ll ans=intpow(a,b/2);
    return ans*ans*(b&1?a:1);
}
inline constexpr int modpow(ll a,ll b){
    if(b==0) return 1;
    ll ans=intpow(a,b/2);
    return ans*ans%MOD*(b&1?a:1)%MOD;
}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll LINF=0x1fffffffffffffff;

int main(){
    ll n;
    cin>>n;
    vector<ll> a(n),r(n),rr(n);
    rep(i,0,n) cin>>a[i];
    r[0]=a[0];
    rep(i,1,n){
        r[i]=gcd(r[i-1],a[i]);
    }
    rr[n-1]=a[n-1];
    rep(i,1,n) {
        rr[n-i-1]=gcd(rr[n-i],a[n-i-1]);
    }
    ll ans=rr[1];
    rep(i,0,n-2){
        chmax(ans,gcd(r[i],rr[i+2]));
    }
    chmax(ans,r[n-2]);
    cout<<ans;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N;cin>>N;
    vector<int>V0(N);
    int x,y;
    for(int i=0;i<N;i++){
        cin>>x>>y;
        V0[i]=60*x+y;
    }
    int M;cin>>M;
    vector<int>V1(M);
    for(int i=0;i<M;i++){
        cin>>x>>y;
        V1[i]=60*x+y;
    }
    vector<int>V2(N+M);
    for(int i=0;i<N;i++)V2[i]=V0[i];
    for(int i=0;i<M;i++)V2[i+N]=V1[i];
    sort(V2.begin(),V2.end());
    
    int count=0;
    vector<int>V(N+M);
    for(int i=0;i<N+M;i++){
        V[i-count]=V2[i];
        if(i<N+M-1 && V2[i]==V2[i+1]){
        i++;count++;
        }
    }
    
    
    for(int i=0;i<N+M-count-1;i++){
        int z=V[i];
        x=z/60;y=z%60;
        if(y<10)cout<<x<<":0"<<y<<' ';
        else cout<<x<<':'<<y<<' ';
    }
    int z=V[M+N-count-1];
    x=z/60;y=z%60;
    if(y<10)cout<<x<<":0"<<y<<endl;
    else cout<<x<<':'<<y<<endl;
}


Measured memory_bytes: 3148
#include <stdio.h>
#define MAX 10001
#define NIL -1

struct Node{
  int p;
  int l;
  int r;
};

struct Node T[MAX];
int n;

void preParse(int u){

  if( u == NIL ){
    return;
  }

  printf(" %d",u);
  preParse(T[u].l);
  preParse(T[u].r);

}

void inParse(int u){

  if( u == NIL ){
    return;
  }

  inParse(T[u].l);
  printf(" %d",u);
  inParse(T[u].r);

}

void postParse(int u){

  if( u == NIL ){
    return;
  }

  postParse(T[u].l);
  postParse(T[u].r);
  printf(" %d",u);
}


int main(int argc, char const *argv[]) {

  int v,l,r;
  int root = 0;
  int i,j;

  scanf("%d",&n);

  for( i = 0 ; i < n ; i++ ){
    T[i].p = T[i].l = T[i].r = NIL;
  }

  for( i = 0 ; i < n ; i++ ){
    scanf("%d %d %d",&v,&l,&r);
    T[v].l = l;
    T[v].r = r;

    if( l != NIL ){
      T[l].p = v;
    }
    if( r != NIL ){
      T[r].p = v;
    }

  }

  for( i = 0 ; i < n ; i++ ){

    if( T[i].p == NIL ){
      root = i;
    }

  }

  printf("Preorder\n");
  preParse(root);
  printf("\n");
  printf("Inorder\n");
  inParse(root);
  printf("\n");
  printf("Postorder\n");
  postParse(root);
  printf("\n");


  return 0;


}

Measured memory_bytes: 620
#include <bits/stdc++.h>
using namespace std;
using P = pair<int,int>;

void rot90(int &x, int &y) {
  int tmp = x;
  x = -y;
  y = tmp;
}

int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  int vx = c-a;
  int vy = d-b;
  rot90(vx, vy);
  int e = c + vx;
  int f = d + vy;
  rot90(vx, vy);

  int g = e + vx;
  int h = f + vy;
  cout << e << ' ' << f << ' ' << g << ' ' << h << endl;

  return 0;
}

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

int main(){
    int n,m,accnt=0,wacnt=0;
    cin >> n >> m;
    vector<bool> judge(n,false);
    vector<int> cnt(n, 0);
    for(int i=0; i<m; i++){
        int p; string s;
        cin >> p >> s;
        p--;

        if(judge[p]) continue;

        if(s == "WA"){
            cnt[p]++;
        }else if(s == "AC"){
            judge[p] = true;
            accnt++;
        }

    }

    for(int i=0; i<n; i++){
        if(judge[i])
        wacnt += cnt[i];
    }

    cout << accnt << " " << wacnt << endl;

    return 0;
}


Measured memory_bytes: 640
def s(a):
	res = 0
	for v in a:
		res += v
	return res

x, y =map(int, input().split())
a = [2]*x

for i in range(x):
	if s(a) == y:
		print("Yes")
		exit()
	a[i] = 4
if s(a) == y:
	print("Yes")
	exit()

print("No")


Measured memory_bytes: 62836
# C - 高橋君とカード
n,a=map(int,input().split())
x=list(map(int,input().split()))

max_num=max(n*a,sum(x))
dp=[[[0]*(max_num+1) for j in range(n+1)] for i in range(n+1)]
dp[0][0][0]=1
for i in range(n):
    for j in range(n):
        for k in range(max_num):
            if dp[i][j][k]:
                # not use
                dp[i+1][j][k] += dp[i][j][k]
                #  use
                dp[i+1][j+1][k+x[i]] += dp[i][j][k]

ans=0
for i in range(1,n+1):
    ans+=dp[n][i][i*a]
print(ans)

Measured memory_bytes: 92124
from copy import deepcopy
H,W,K = map(int,input().split())
c = [input() for _ in range(H)]
ans = 0

for i in range(2**H):
  for j in range(2**W):
    r = 0
    for k in range(H):
      if ((i >> k) & 1):
        for l in range(W):
          if ((j >> l) & 1):
            if c[k][l] == "#":
              r += 1
    if r == K:
      ans += 1
      
print(ans)

Measured memory_bytes: 69328
function Main(input) {
    input = input.trim().split(" ");
    var N = parseInt(input[0], 10);
    var L = parseInt(input[1], 10);
    var sum = 0;
    if (L >= 0) {
        for (var i = 1; i < N; i++){
            sum += L + i;
        }
    }
    else {
        if (L + N - 1 >= 0) {
            for (var i = 0; i < N; i++){
                sum += L + i;
            }
        }
        else {
            for (var i = 0; i < N - 1; i++){
                sum += L + i;
            }
        }
    }
    console.log(sum);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

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

    // start
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << (a * b >= c * d ? a * b : c * d) << endl;
    // end

    return 0;
}


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

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

using namespace std;
using ll = long long;

int calc(int x, int y, int z) {
  return x * x + y * y + z * z + x * y + y * z + z * x; 
}


int main(void)
{
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    int res = 0;
    for (int x = 1; x*x <= n; ++x) {
      for (int y = 1; y*y <= n; ++y) {
        for (int z = 1; z*z <= n; ++z) {
          if (calc(x,y,z) < i)
              continue;
          if (calc(x,y,z) == i)
            ++res;
              break;
        }
      }
    }
    cout << res << endl;
  }
}

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

using namespace std;

#define REP1(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pow(x) x*x
#define ll long long
static const ll MAX = 1000000;
static const ll INFTY = 1e12;
static const ll MOD = 1000000007;

template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };

struct edge {
    ll to, cost;
};

using Graph = vector<vector<int>>;
using _Graph = vector<vector<edge>>;


const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

// 深さ優先探索
vector<bool> seen;
vector<int> colors;

int H, W, N;
int sx, sy, gx, gy; 
vector<vector<char>> field;
vector<vector<int>> dist;
//vector<pair<int, int>> gx, gy;
deque<pair<int, int>> que;

typedef vector<vector<int> > Matrix;

const int INF = 100000000;

int main() {

    ll N, M;
    cin >> N >> M;
    vector<ll> X(M);
    REP(i, M){
        cin >> X[i];
    }
    sort(X.begin(), X.end());

    vector<ll> diff(M-1);
    ll ans = 0;
    REP(i, M-1){
        diff[i] = X[i+1]-X[i];
        ans += X[i+1]-X[i];
    }
  
    sort(diff.begin(), diff.end(), greater<ll>());


    long long res = X.back() - X[0];
    for (int i = 0; i < min((ll)diff.size(), N-1); ++i) res -= diff[i];
    cout << res << endl;



}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
    return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

int main() {
    constexpr ll mod = 1e9 + 7;
    string l; cin >> l;
    
    const int n = l.length();
    auto dp = make_v(n+1, 2, -1LL);

    function<ll(int, int)> rec = [&](int i, int b){
        if(i == n) return 1LL;
        if(dp[i][b] != -1LL) return dp[i][b];

        ll ret = 0LL;
        
        int m = b ? (l[i]-'0')+1 : 2;
        REP(j, m){
            (ret += (j + 1) * rec(i+1, b && j == m-1) % mod) %= mod;
        }

        return dp[i][b] = ret;
    };

    cout << rec(0, 1) << endl;
   
    return 0;
}


Measured memory_bytes: 16896
#include <iostream>
#include <string>
#include <unordered_map>
#include <stdio.h>
#include <list>
#include <vector>
#include <algorithm>
#include <stack>
#include <climits>
#include <cmath>
#include <queue>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

int main()
{
	int n;cin >> n;
	if(n==0)
	{
		cout<<2<<endl;
		return 0;
	}
	vector<ll> L(n+2);
	L[0]=2;
	L[1]=1;
	
	for(int i=0;i<n;i++)
	{
		L[i+2]=L[i+1]+L[i];
	}
	cout<<L[n]<<endl;
	return 0;
}

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

int main(){
  string S;
  cin >> S;
  int L=S.size();
  int ans=0;
  for(int i=0; i<L-1; i++){
    if(S.at(i)==S.at(i+1)){
      if(S.at(i+1)=='0') S.at(i+1)='1';
      else S.at(i+1)='0';
      ans++;
    }
  }
  ans = min(ans, L-ans);
  cout << ans << endl;
}

Measured memory_bytes: 512
fun main(args: Array<String>) {
    val s = readLine()!!

    var ans = 0L
    for (bit in 0 until (1 shl s.length - 1)) {
        var tmp = (s[0] - '0').toLong()
        for (i in 0 until s.length - 1) {
            if (1 and (bit shr i) == 1) {
                ans += tmp
                tmp = (s[i + 1] - '0').toLong()
            } else {
                tmp = tmp * 10 + (s[i + 1] - '0')
            }
        }
        ans += tmp
    }
    println(ans)
}

Measured memory_bytes: 31804
#include <stdio.h>
#include <stdlib.h>

int asc(const void *a, const void *b) {
  return *(int *)a - *(int *)b;
}

int main()
{
    int n,k,a[100000];

    int i,j;

    scanf("%d %d",&n,&k);
    for (i = 0; i < n; i++)
    {
        scanf("%d",&a[i]);
    }

    qsort(a,n,sizeof(int),asc);

    int ans = 0;
    for (i = 1; i < n; i++)
    {
        if(a[i - 1] != a[i])break;
    }
    
    printf("%d",(n - i + k - 2) / (k - 1));
}

Measured memory_bytes: 892
def submit():
    n, k, q = map(int, input().split())

    # count point for each users
    score = {i + 1: 0 for i in range(n)}
    for _ in range(q):
        a = int(input())
        score[a] += 1

    for i in range(1, n + 1):
        if k - q + score[i] > 0:
            print("Yes")
        else:
            print("No")


if __name__ == "__main__":
    submit()


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


int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  ll INF = 1e15;
  cin >> N;
  vector< vector<ll> > a(N, vector<ll>(N, INF));
  vector< vector<ll> > need(N, vector<ll>(N, true));

  for(int i=0;i<N;i++) {
    for(int j=0;j<N;j++) {
      cin >> a[i][j];
    }
  }

  ll sub = 0;
  for(int k=0;k<N;k++) {
    for(int i=0;i<N;i++) {
      for(int j=0;j<N;j++) {
        if(a[i][j] > a[i][k] + a[k][j]) {
          cout << -1 << endl;
          return 0;
        }
        if(a[i][j] == a[i][k]+a[k][j] && a[i][k] > 0 && a[k][j] > 0) {
          sub += a[i][j];
          need[i][j] = false;

        }
      }
    }
  }
  ll ans = 0;
  for(int i=0;i<N;i++) {
    for(int j=0;j<N;j++) {
      if(need[i][j])
        ans += a[i][j];
    }
  }
  cout << ans / 2 << endl;


}


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

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

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

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF = 1e9;
typedef pair<int, int> PII;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};

class LowLink {
    const int N;
    vector<vector<int>> G;
    set<int> used_v;
    vector<int> ord, low, parent;

    void dfs(int v, int &k)
    {
        used_v.insert(v);
        ord[v] = low[v] = k++;

        for (auto u : G[v]) {
            if (u == parent[v]) continue;
            if (!used_v.count(u)) {
                parent[u] = v;
                dfs(u, k);
                low[v] = min(low[v], low[u]);
            } else {
                low[v] = min(low[v], ord[u]);
            }

            if (ord[v] < low[u]) bridges.emplace_back(min(u, v), max(u, v));
        }
    }

public:
    vector<PII> bridges;
    LowLink(int _N) : N(_N), G(_N), ord(_N), low(_N), parent(_N) {}

    void compute_bridge()
    {
        int k = 0;
        bridges.clear();
        dfs(0, k);
    }

    void add_edge(int u, int v)
    {
        G[u].push_back(v);
        G[v].push_back(u);
    }
};


int main()
{
    int N, M;
    cin >> N >> M;

    LowLink llink(N);

    rep(i, M) {
        int U, V;
        cin >> U >> V;
        llink.add_edge(U, V);
    }

    llink.compute_bridge();
    sort(llink.bridges.begin(), llink.bridges.end());

    for (auto p : llink.bridges) {
        cout << p.first << " " << p.second << endl;
    }

    /*
    rep(i, N) {
        cout << ord[i] << " " <<  lowlink[i] << endl;
    }
    */
}

Measured memory_bytes: 4720
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/
struct City
{
	string name;
	int value;
	int rank;
	int idx;
	bool operator<(City other) const
    {
        return name < other.name || ( (name == other.name) && value > other.value) ;
    }
};

bool comp(struct City A, struct City B)
{
	return A.idx < B.idx;
}

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

	int N;
	
	cin >> N;
	
	#if 0
	map<string, vector<int> > m;

	/*
	set<string> v;

	rep(i, N)
	{
		string s;
		int p;
		cin >> s >> p;
		v.insert(s);
		
	}
	*/
	rep(i, N)
	{
		string s;
		int p;
		
		if (m.find(s) != m.end())
		{
			m[s].pb(p); 
		}
		else
		{
			vector<int> tmp;
			tmp.pb(p);
			m[s] = tmp;
		}
		
	}

	map<string, vector<int> >::iterator it = m.begin();
	for(; it!=m.end(); ++it)
	{
		vector<int> tmp = it->second;
		sort(tmp.begin(), tmp.end(), greater<int>);
		rep(i, tmp.size())
		{

		}
	}
	#endif

	vector<struct City> v;
	rep(i, N)
	{
		string name;
		int value;
		struct City tmp;
		cin >> name >> value;
		tmp.name = name; 
		tmp.value = value;
		tmp.idx = i+1;
		v.pb(tmp);
	}

	sort(v.begin(), v.end());
	/*
	rep(i, N)
	{
		v[i].rank = i + 1;
	}
	sort(v.begin(), v.end(), comp);
	*/
	rep(i, N)
	{
		//cout << v[i].idx << " " << v[i].name << " " << v[i].value << endl;
		cout << v[i].idx<< endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
//Distance 
//?????¢
#include<stdio.h>
#include<math.h>


int main(void){
    double x1, x2;
    double y1, y2;
    double distance;
    
    scanf("%lf", &x1); scanf("%lf", &y1);
    scanf("%lf", &x2); scanf("%lf", &y2);
    
    distance = sqrt(pow(x2 - x1, 2.0) + pow(y2-y1, 2.0));
    printf("%lf\n", distance);
    
    return 0;
}

Measured memory_bytes: 652
/*
Author: Arham_doshi
 ***************************************   UNAUTHORISED COPYING OF CODE PROHIBITED   **********************************
*/
#include <bits/stdc++.h>

#define int         long long
#define double      long double
#define pb          push_back
#define pf          push_front
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define x           first
#define y           second
#define isp2(x)     x && (!(x&(x-1)))
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        998244353 
#define PI          3.141592653589
#define bs(v,n)     binary_search(all((v)),(n))
#define lb(v,n)     lower_bound(all((v)),(n))
#define ub(v,n)     upper_bound(all((v)),(n))
#define fo(i,l,u)   for(i=l;i<u;i++)
using namespace std;

int gcd(int a, int b) {  if (a == 0)  return b; return gcd(b % a, a); }  
bool mod(double a,double b) {return a/b - floor(a/b);}

int occurs(vi v,int n){
auto it=lb(v,n);auto it1=ub(v,n);int x=it1-it;return x;}
int grid[1005][1005];
string arr[1005];


int logb(int base, int x) {
    return (log(x) / log(base));
}


int go(int x,int y,int n,int m){
	//cout<<x<<y<<endl;
	if(x==n)return 0;
	else if(y==m)return 0;
	else if((y==m-1)&&(x==n-1))return 1;
	else if(arr[x][y]=='#')return 0;
	else if(grid[x][y]!=-1)return grid[x][y];
	else {grid[x][y]=go(x+1,y,n,m)+go(x,y+1,n,m);return grid[x][y]%1000000007;}
	
}

signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int i,j,x,m,n,t,T;
    

    cin>>n>>m;
    //memset(arr,-1,sizeof(arr));
    memset(grid,-1,sizeof(grid));
    string s;
    fo(i,0,n){
    	cin>>s;
    	arr[i]=s;
    	//cout<<arr[i]<<endl;
    }


	x=go(0,0,n,m)%1000000007;
	cout<<x<<endl;

    return 0;
}

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

int main(){
	int n;cin>>n;
	vector<ll>arr(n);
	for(int i=0;i<n;i++){
		cin>>arr[i];
	}
	sort(arr.rbegin(),arr.rend());
	ll sum=arr[0];

	for(int i=2;i<n;i++){
		sum+=arr[i/2];
	}
	
	cout<<sum;
	return 0;
}

Measured memory_bytes: 4820
# -*- coding: utf-8 -*-
"""
Created on Wed Jun 10 22:32:44 2020

@author: NEC-PCuser
"""
from decimal import Decimal
import numpy as np

a, b, c = map(Decimal, input().split())

if np.sqrt(a) + np.sqrt(b) < np.sqrt(c):
    print('Yes')
else:
    print('No')
    

Measured memory_bytes: 13668
import java.util.*;
public class Main {
static Scanner inp=new Scanner(System.in);
static int a[]=new int [100000];
	public static void sort(int x,int y){
		int l=x;
		int r=y;
		int m=a[(l+r)/2];
		while (l<r){
			while(a[l]<m)l++;
			while(a[r]>m)r--;
			if (l<=r){
				int z=a[l];a[l]=a[r];a[r]=z;
				l++;
				r--;
			}
		}
		if (l<y)sort(l,y);
		if (r>x)sort(x,r);
	}
	public static void main(String args[]) {
		int n=inp.nextInt();
		while (n>0){
			for (int i=1;i<=n;i++)a[i]=inp.nextInt();
			sort(1,n);
			int ans=100000000;
			for (int i=2;i<=n;i++)if (a[i]-a[i-1]<ans)ans=a[i]-a[i-1];
			n=inp.nextInt();
			System.out.println(ans);
		}
	}

}

Measured memory_bytes: 47920
def main():
    ans = []
    while True:
        n, x = map(int, input().split())
        if (n, x) == (0, 0):
            break
        c = 0
        for i in range(1, n + 1):
            for j in range(i + 1, n + 1):
                for k in range(j + 1, n + 1):
                    if i + j + k == x:
                        c += 1
        ans.append(c)
    for a in ans:
        print(a)


main()



Measured memory_bytes: 5596
#include "iostream"
#include "string"
#include "algorithm"
using namespace std;

int main() {
	int h, w;
	cin >> h >> w;
	string weather[100];
	int forecast[100][100];
	for (int i = 0; i < h; i++) {
		cin >> weather[i];
		bool cloudWest = 0;
		int cloudCnt = -1;
		for (int j = 0; j < w; j++) {
			if (weather[i][j] == 'c') {
				cloudWest = 1;
			}
			if (cloudWest) {
				if (weather[i][j] == '.') {
					cloudCnt++;
				}
				else {
					cloudCnt = 0;
				}
			}
			forecast[i][j] = cloudCnt;
		}
	}
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (j) {
				cout << " ";
			}
			cout << forecast[i][j];
		}
		cout << endl;
	}
}


Measured memory_bytes: 3208
def counter(r,g,b,n):
    count = 0
    max_y = n//g
    max_z = n//b

    for y in range(max_y + 1):
        for z in range(max_z + 1):
            x_before = n - g*y - b*z
            if( (x_before / r) < 0 ):
                break
            if( (x_before % r == 0) ):
                count += 1
    return count

r,g,b,n = map(int, input().split())
print(counter(r,g,b,n))

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <list>
#include <cmath>
#include <numeric>
using ll = long long;
using namespace std;

int main()
{
    int N;
    int T, A;
    cin >> N >> T >> A;
    int x;
    int ans = -1;
    double min_A = 999999.0;
    double f = 0.006;
    for (int i = 0; i < N; i++)
    {
        int x;
        cin >> x;
        if (min_A > abs(T - x * f - A))
        {
            ans = i + 1;
            min_A = abs(T - x * f - A);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
S = list(input())

S_odd = S[0::2]
S_even= S[1::2]

o = set(S_odd).issubset(set(["R","U", "D"])) 
e = set(S_even).issubset(set(["L","U", "D"]))
if o + e == 2:
	print("Yes")
else:
	print("No")

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>

using namespace std;

#define ll long long
#define rep(i,a,n) for(int i = a; i < n; i++)
#define per(i,a,n) for(int i = n-1; i >= a; i--)

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

  set<ll> s;
  s.insert(0);
  rep(i,0,a) {
    rep(j,0,b) {
      ll cur = i*j + (a-i)*(b-j);
      s.insert(cur);
    }
  }

  if (s.find(c) != s.end()) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }


  return 0;
}


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

using namespace std;

int main() {
    int N; cin>>N;
    vector<int> Hn(N);
    for (int i=0;i<N;i++){
        cin>>Hn[i];
    }

    // if (N==1) {
    //     cout << 1 << endl;
    //     return;
    // }

    int ans=0;
    for (int i=0;i<N;i++){
        int seeable=true;
        for (int j=0;j<i;j++) {
            // cout << Hn[i] << "<" << Hn[j] << endl;
            if (Hn[i] < Hn[j]) {
                seeable=false;
                break;
            }
        }

        if (seeable) {
            // cout << i << " " << Hn[i] << endl;
            ans++;
        }
    }

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
int arr[105];
int main()
{
    int n;
    int min=1000;
    int max=-200;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%d",&arr[i]);
        if(arr[i]>max)
            max=arr[i];
        if(arr[i]<min)
            min=arr[i];
    }
    int sum,ans;
    ans=0x3f3f3f3f;
    for(int i=min;i<=max;i++)
    {
        sum=0;
        for(int j=0;j<n;j++)
        {
            sum+=(i-arr[j])*(i-arr[j]);
        }
        if(sum<ans)
            ans=sum;
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 128