akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <numeric>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<((x))<<endl
#define fi first
#define se second

#define INF 2147483600
#define long long long

int main(){
  int sx,sy,tx,ty;
  cin>>sx>>sy>>tx>>ty;
  int dx=tx-sx;
  int dy=ty-sy;

  rep(i,dx) printf("R");
  rep(i,dy) printf("U");
  rep(i,dx) printf("L");
  rep(i,dy+1) printf("D");
  rep(i,dx+1) printf("R");
  rep(i,dy+1) printf("U");
  printf("L");
  printf("U");
  rep(i,dx+1) printf("L");
  rep(i,dy+1) printf("D");
  printf("R"); printf("\n");


  return 0;
}


Measured memory_bytes: 384
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

import time
def Dijkstra(num, start, s, m):
    b = time.time()
    # print(a)
    dist = [inf for i in range(num)]
    x = -1
    dist[0] = 0
    for i in range(num):
        if time.time() - b > 1:
            return dist
        if x > i:
            continue
        a = dist[i]
        for k in range(1, m + 1):
            if s[i + k] == "1":
                continue
            dist[i + k] = a + 1
            x = i + k
            if i + k == num-1:
                return dist
    
    return dist


#solve
def solve():
    n, m = LI()
    s = S()
    d = Dijkstra(n + 1, 0, s, m)
    if d[-1] == inf:
        print(-1)
        return
    ans = []
    q = deque([n])
    while q:
        a = q.pop()
        x = d[a]
        for i in range(min(a, m), 0, -1):
            if x - 1 == d[a - i]:
                q.append(a - i)
                ans.append(i)
                break
    ans = ans[::-1]
    print(" ".join(map(str, ans)))
    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 60552
#include <bits/stdc++.h>
#define rep(var,cnt) for(int (var)=0; (var)<(int)(cnt); ++(var))
#define Rep(var,init,cnt) for(int (var)=(init); (var)<(cnt); ++(var))
#define ran(var,vec) for(auto &(var):(vec))
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define SORT(v) sort(all(v))
#define RSORT(v) sort(rall(v))
#define SUM(v) accumulate(all(v),0)
#define tget(tp,idx) get<idx>(tp)
#define TF(flag) (flag)?1:0
#define yn(f) cout<<(f?"yes":"no")<<endl
#define Yn(f) cout<<(f?"Yes":"No")<<endl
#define YN(f) cout<<(f?"YES":"NO")<<endl
#define COUT(x) cout<<(x)<<endl
using namespace std;

using ll = long long;
using ull = unsigned long long;
using pi = pair<int,int>;
using pl = pair<ll,ll>;
using ti = tuple<int,int,int>;
using tl = tuple<ll,ll,ll>;

template<typename T>
using vec = vector<T>;
template<typename T>
using mat = vector<vec<T>>;
template<typename T>
using cub = vector<mat<T>>;
template<typename T>
using val = valarray<T>;

template<typename T>
using pq = priority_queue<T>;
template<typename T>
using rpq = priority_queue<T,vec<T>,greater<T>>;

template<typename T1,typename T2>
ostream &operator<<(ostream &os, const pair<T1,T2> &p){
  os<<"P("<<p.first<<", "<<p.second<<") ";
  return os;
}

template<typename T1,typename T2>
istream &operator>>(istream &is, pair<T1,T2> &p){
  is>>p.first>>p.second;
  return is;
}

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  cout<<"V{";
  for(int i=0; i<(int)v.size(); ++i){
    os<<v[i]<<(i+1!=v.size()?" ":"");
  }
  cout<<"}";
  return os;
}

template<typename T>
istream &operator>>(istream &is, vector<T> &v){
  for(T &in:v) is>>in;
  return is;
}

template<typename T>
ostream &operator<<(ostream &os, const valarray<T> &v){
  cout<<"V{";
  for(int i=0; i<(int)v.size(); ++i){
    os<<v[i]<<(i+1!=v.size()?" ":"");
  }
  cout<<"}";
  return os;
}

template<typename T>
istream &operator>>(istream &is, valarray<T> &v){
  for(T &in:v) is>>in;
  return is;
}

// Usual Template End ================================================

// Template End ======================================================

constexpr int MOD=1e9+7;

int main(void){
  int a,b,c; cin>>a>>b>>c; Yn(a+b>=c);
}













Measured memory_bytes: 256
N, K = map(int, input().split())
listp = tuple(map(int, input().split()))
bc =sum(listp[0:K])
b = sum(listp[0:K])
for n in range(1,N-K+1):
    b = b - listp[n-1]+listp[n+K-1]
    
    if b > bc:
        bc = b
    else:
        pass    
    #print(b)    
print((bc+K)/2)    


Measured memory_bytes: 25316
import java.util.Scanner;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int s=sc.nextInt();
    int w=sc.nextInt();
    if(s>w) {
    	System.out.println("safe");
    }else {
    	System.out.println("unsafe");
    }
     }}

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

#define PI 3.141592653589793238
int N;

int main()
{
    double x = 0.0, y = 0.0;
    int N, L;
    cin >> N;
    cin >> L;
    vector<int> T(N);
    for (int i = 0; i < N; i++)
        cin >> T[i];
    //for (int i = 0; i < N ; i++){
    //    fprintf(stderr, "%f, %f\n", cos(2 * PI * T[i]/(double)L), sin(2 * PI * T[i]/(double)L));
        
    //}
    for (int i = 0; i < N - 1; i++){
        for (int j = i + 1; j < N; j++){
            int coef2 = j - i - 1;
            int coef1 = N - 2 - coef2;
            double x0 = (coef1 - coef2) * cos(2 * PI * (T[i] + T[j])/(double)(2*L));
            double y0 = (coef1 - coef2) * sin(2 * PI * (T[i] + T[j])/(double)(2*L));
            //fprintf(stderr, "%d, %d: %f, %f\n", i, j, x0, y0);
            x += x0;
            y += y0;
        }
    }
    x /= N *(N - 1.) * (N - 2)/6.0;   
    y /= N *(N - 1.) * (N - 2)/6.0;
    //x *= 3.0;
    //y *= 3.0;
    cout<<setprecision(10)<<x<<' '<<y<<endl;
    //fprintf(stdout, "%.15f %.15f\n", x, y);
    //cout << x << " " << y << endl;
    return 0;    
}


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

int main() {
    int n;
    cin >> n;
    unordered_map<int, int> counter;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        counter[a]++;
    }
    int group[4];
    fill(group, group + 4, 0);
    for (auto p: counter) {
        if (p.second == 1) {
            group[1]++;
        } else if (p.second % 2) {
            group[3]++;
        } else {
            group[2]++;
        }
    }
    cout << (group[3] + group[2] + group[1] - (group[2] & 1)) << endl;
    return 0;
}


Measured memory_bytes: 4388
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String input = sc.next();
    char[] ch = new char[input.length()];
    for(int i = 0; i < input.length(); i++) ch[i] = input.charAt(i);
    boolean flag = true;
    for(int i = 0; i < input.length(); i++) {
      if(i % 2 == 0 && ch[i] == 'L') flag = false;
      if(i % 2 == 1 && ch[i] == 'R') flag = false;
    }
    if(flag) System.out.println("Yes");
    else System.out.println("No");
  }
}


Measured memory_bytes: 23508
#include<iostream>
#include<string>
#include<algorithm>
#include <map>  
#include <string.h>
#include <math.h>

using namespace std;

int t[10], c[10][10];
int h, w;
bool u[10];


int main()
{
	int sum = 0;

	fill(u, u + 10, false);
	fill(t, t + 10, 100000);

	u[1] = true;
	t[1] = 0;

	cin >> h >> w;
	for (int i = 0; i < 10; i++)
		for (int j = 0; j < 10; j++)
			cin >> c[i][j];


	for (int k = 0; k < 9; k++) {
		int m = 1000000, n;
		for (int i = 0; i < 10; i++) {
			if (u[i] == false) {
				for (int j = 0; j < 10; j++) {
					if (i != j && c[i][j] + t[j] < m) {
						m = c[i][j] + t[j];
						n = i;
					}
				}
			}
		}
		t[n] = m;
		u[n] = true;
	}

	for (int i = 0; i < w; i++) {
		for (int j = 0; j < h; j++) {
			int in;
			cin >> in;
			if(in != -1)
				sum += t[in];
		}
	}

	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.util.function.LongSupplier;

public class Main{ // 

	static class ConsoleScanner {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");

		String next() {
			try {
				while (!st.hasMoreElements())
					st = new StringTokenizer(br.readLine());
				return st.nextToken();
			} catch (IOException e) {
				throw new AssertionError(e);
			}
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}
	}

	static LongSupplier now = new LongSupplier() {
		private long t = System.currentTimeMillis();

		@Override
		public long getAsLong() {
			long a = t;
			t = System.currentTimeMillis();
			long ans = t - a;
			return ans;
		}
	};

	public static void main(String args[]) {
		ConsoleScanner cin = new ConsoleScanner();
		PrintWriter cout = new PrintWriter(System.out);
		solve(cin, cout);
		cout.flush();
	}

	static int tr(Object... objects) {
		System.out.println("tr:" + Arrays.deepToString(objects));
		return 0;
	}

	private static void solve(ConsoleScanner cin, PrintWriter cout) {
		// assert solve(1) == 1;

		int n = cin.nextInt();

		int[][] a = new int[n][n];
		for (int i = 0; i < a.length; i++)
			for (int j = 0; j < a.length; j++)
				a[i][j] = cin.nextInt();

		now.getAsLong();

		long ans = solve(n, a);
		cout.println(ans);

		assert 0 == tr("elapsed", now.getAsLong());
	}

	private static long solve(int n, int[][] a) {
		// Warshall-Floyd

		long ans = 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])
						return -1;

		for (int i = 0; i < n; i++)
			fromTo: for (int j = 0; j < i; j++) {
				via: for (int k = 0; k < n; k++)
					if (k != i && k != j && a[i][j] == a[i][k] + a[k][j])
						// if can bypass
						continue fromTo;
					else
						continue via;
				ans += a[i][j];
			}

		return ans;
	}

}


Measured memory_bytes: 34792
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <array>
#include <algorithm>
#include <cassert>

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<vector<int>> conn(n), rconn(n);
	for(int i = 0; i < n; ++i){
		int x;
		cin >> x;
		conn[x - 1].push_back(i);
		rconn[i].push_back(x - 1);
	}
	vector<int> out_deg(n);
	for(int i = 0; i < n; ++i){ out_deg[i] = conn[i].size(); }
	queue<int> q;
	for(int i = 0; i < n; ++i){
		if(out_deg[i] == 0){ q.push(i); }
	}
	vector<int> g(n, -1);
	while(!q.empty()){
		const int u = q.front();
		q.pop();
		for(const auto v : rconn[u]){
			if(--out_deg[v] == 0){ q.push(v); }
		}
		set<int> s;
		for(const auto v : conn[u]){ s.insert(g[v]); }
		g[u] = 0;
		for(const int x : s){
			if(x != g[u]){ break; }
			++g[u];
		}
	}
	vector<int> cycle;
	for(int i = 0; i < n; ++i){
		if(out_deg[i] == 1){
			cycle.push_back(i);
			break;
		}
	}
	while(true){
		const int u = cycle.back();
		int v = 0;
		for(const auto x : rconn[u]){
			if(out_deg[x] == 1){
				v = x;
				break;
			}
		}
		if(v == cycle.front()){ break; }
		cycle.push_back(v);
	}
	vector<array<int, 2>> candidates;
	for(const int u : cycle){
		set<int> s;
		for(const int v : conn[u]){
			if(out_deg[v] != 0){ continue; }
			s.insert(g[v]);
		}
		array<int, 2> t = { 0, 0 };
		auto it = s.begin();
		while(it != s.end()){
			if(*it != t[0]){ break; }
			++t[0];
			++it;
		}
		t[1] = t[0] + 1;
		while(it != s.end()){
			if(*it != t[1]){ break; }
			++t[1];
			++it;
		}
		candidates.push_back(t);
	}
	bool found = false;
	for(const int gc : candidates[0]){
		g[cycle[0]] = gc;
		for(const int u : cycle){
			if(u == cycle[0]){ continue; }
			set<int> s;
			for(const int v : conn[u]){
				assert(g[v] >= 0);
				s.insert(g[v]);
			}
			g[u] = 0;
			for(const int x : s){
				if(x != g[u]){ break; }
				++g[u];
			}
		}
		set<int> s;
		for(const int v : conn[cycle[0]]){ s.insert(g[v]); }
		int t = 0;
		for(const int x : s){
			if(x != t){ break; }
			++t;
		}
		if(t == gc){ found = true; }
	}
	cout << (found ? "POSSIBLE" : "IMPOSSIBLE") << endl;
	return 0;
}



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

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

double power(double vol, double k, int b){
       //double ans1 = 1.0;
       for(int i = 0; i < b; i++){
           vol -= vol*k;
       }
       return vol;
}

double pi = 3.14;

int main(){
    //freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);
    //cin.sync_with_stdio(false);
    //cin.tie(0); cout.tie(0);
    int m;
    cin >> m;
    if(m%10 == m/100){
       cout << "Yes";
    }
    else{
        cout << "No";
    }
    return 0;


}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
using namespace std;
typedef long long ll;
int main() {
	int n;
	cin >> n;
	vector<int> ar(n + 3, 0), ar2(n + 3, 0);
	for (int i = 1; i <= n; i++) {
		cin >> ar[i];
		ar2[ar[i]] = i;
	}
	ll ans = 0, kans = 1;
	for (int i = 1; i <= n; i++) {
		if (ar2[i] < ar2[i + 1]) kans++;
		else {
			ans = max(ans, kans);
			kans = 1;
		}
	}
	cout << n - ans << endl;
}

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

using namespace std;

typedef long long ll;

ll f(ll x) {
  ll ans = 0;
  for(ll i = 1; i <= x; ++i) {
    if(x % i == 0) ++ans;
  }
  return ans;
}

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

  int n;
  cin >> n;
  
  string s;
  cin >> s;

  bool status = true;
  for(int i = 1; i < n; ++i) {
    if(s[i - 1] == 'W' && s[i] == 'R') status = false;
  }
  if(status) {
    cout << "0\n";
    return 0;
  }

  int white = 0, red = 0;
  for(char c: s) {
    if(c == 'W') ++white;
    else ++red;
  }

  int ans = 0;
  for(int i = 0; i < red; ++i) {
    if(s[i] == 'W') ++ans;
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3748
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MAX 200001
int main()
{
	ll n;cin>>n;
	ll c[MAX]={0};
	ll a[n];
	for(int i=0;i<n;++i)
	{
		cin>>a[i];
		c[a[i]]++;
	}
	ll s=0;
	for(int i=1;i<=n;++i)
	{
		s=s+(c[i]*(c[i]-1))/2;
	}
	for(int i=0;i<n;++i)
	{
		cout<<(s-c[a[i]]+1)<<endl;
	}
	return 0;
}

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

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) ll(x.size()) //sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB emplace_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define Umap unordered_map
#define Uset unordered_set

int main(){
    ll n;
    cin >> n;
    vector<pair<string, ll>> pairs(n), tmp(n);
    string s;
    ll p;
    REP(i, n){
        cin >> s >> p;
        pairs[i] = MP(s, -p);
        tmp[i] = MP(s, -p);
    }
    sort(ALL(pairs));
    REP(i, n){
        REP(j, n){
            if(pairs[i] == tmp[j]){
                cout << j+1 << endl;
                break;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3596
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
//deque/functional/iterator/list/map/memory/numeric/queue/set/stack/utility/vector
//#include<bits/stdc++.h>
#define ll long long
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
    int a,b,n;
    cin>>n;
    b=n/15;
    b=b*200;
    a=n*800;
    cout<<a-b<<endl;
return 0;
}


Measured memory_bytes: 256
package main

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

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

var fp *os.File

func input() *os.File {
	var err error
	fp, err = os.Open("input.txt")
	if err != nil {
		panic(err)
	}
	return fp
}

// main

func main() {

	//var sc = bufio.NewScanner(input())
	var sc = bufio.NewScanner(os.Stdin)

	var H, W int64
	var in = strings.Split(nextLine(sc), " ")
	H, _ = strconv.ParseInt(in[0], 10, 64)
	W, _ = strconv.ParseInt(in[1], 10, 64)
	label := []string{"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"}

	var i, j int
	var flag int
	for i = 0; i < int(H); i = i + 1 {
		var line = strings.Split(nextLine(sc), " ")
		for j = 0; j < int(W); j = j + 1 {
			if line[j] == "snuke" {
				flag = 1
				break
			}
		}
		if flag == 1 {
			break
		}
	}
	fmt.Printf("%s%v", label[j], i+1)

	defer fp.Close()

}


Measured memory_bytes: 640
import           Control.Monad
import qualified Data.ByteString.Char8 as BS
import           Data.List
import           Data.Maybe

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
  [a, b, c] <- sort <$> getIntList

  putStrLn $ if (a == b && b /= c) || (a /= b && b == c)
             then "Yes"
             else "No"

Measured memory_bytes: 380
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E18;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);


ll hpow(ll x,ll y){
    ll ans=1;
    ll i=x;
    if(y==0)return 1;
    while(y>0){
        if(y%2==1){
            ans=(ans*i)%2019;
        }
        i=(i*i)%2019;
        y=y/2;
        
    }
    return ans;
}

int main(){fastio
    string s;cin>>s;
    reverse(s.begin(),s.end());
    ll dp[s.size()];
    ll c[2019];rep(i,0,2018)c[i]=0;
    dp[0]=s[0]-'0';
    c[0]++;
    c[dp[0]]++;
    rep(i,1,(ll)s.size()-1){
        dp[i]=(dp[i-1]+(hpow(10,i))*(s[i]-'0'))%2019;
        c[dp[i]]++;
    }
    ll ans=0;
    rep(i,0,2018){
        ans+=(c[i]*(c[i]-1))/2;
    }
    cout<<ans<<endl;
    
    
    
    
    return 0;
    
    
    
}


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

int main() {
    ll N, M;
    cin >> N >> M;
    vector<ll> L(M), R(M);
    ll l, r;
    ll left = 0, right = N;
    rep(i, M) {
        cin >> l >> r;
        left = max(left, l);
        right = min(right, r);
    }
    cout << max(0LL, right - left + 1) << endl;
    return 0;
}


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        double r = scan.nextDouble();
        double a = r*r*Math.PI;
        double c = r*2*Math.PI;
        System.out.printf("%.6f %.6f", a, c);
    }
}

Measured memory_bytes: 27972
//submitted by HimJ
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pb push_back
#define fi first
#define se second
#define fr(i,s,e) for(i=s;i<e;i++)
#define ms(arr,val) memset(arr,val,sizeof(arr))
using namespace std;
const int mxn=1e5+1;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
  ll t=1;
  //cin>>t;
    while(t--){
            int a,b;
            cin>>a>>b;
    if(a+b==15)
        cout<<"+";
    else if(a*b==15)
        cout<<"*";
    else cout<<"x";

    }
  return 0;
  }



Measured memory_bytes: 256
import sys

def main():
  input = sys.stdin.readline
  S = [int(i) for i in input().strip()]
  ans = 1000
  for i in range(len(S)-2):
    x = S[i] * 100 + S[i+1] * 10 + S[i+2]
    sub = abs(753 - x)
    ans = min(ans, sub)
  print(ans)


if __name__ == '__main__':
  main()

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
int main()
{

   long long i,j,k,l,n,sum=0;
   cin>>k;
   for(i=1;i<=k;i++)
   {
       for(j=1;j<=k;j++)
       {
           for(l=1;l<=k;l++)
           {
               sum=sum+__gcd(i,__gcd(j,l));
           }
       }
   }
    cout<<sum<<endl;

    return 0;
}


Measured memory_bytes: 3632
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var NK = ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        var (N, K) = (NK[0], NK[1]);
        var h = Enumerable.Range(0, N).Select(i => int.Parse(ReadLine())).OrderBy(x => x).ToArray();

        var ans = h.Zip(h.Skip(K - 1), (h1, h2) => (h2 - h1)).Min();

        WriteLine(ans);
    }
}


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

typedef long long ll;
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

const ll MOD = 1e9 + 7 ;
const double PI = 2 * acos(0.0) ;

int main()
{
    string s, first = "", last = "" ;
    ll val = 0 ;
    cin >> s ;
    ll q ;
    scanf("%lld", &q) ;
    while (q--) {
        ll ti, fi ;
        char x ;
        scanf("%lld", &ti) ;
        if (ti == 1)    val++ ;
        else {
            scanf("%lld %c", &fi, &x) ;
            if (val % 2 == 0) {
                if (fi == 1)    first = x + first ;
                else   last += x ;
            }
            else {
                if (fi == 1)    last += x ;
                else    first = x + first ;
            }
        }
    }
    if (val % 2 == 0) {
        for (int i = 0; i < first.size(); i++)  printf("%c", first[i]) ;
        for (int i = 0; i < s.size(); i++) printf("%c", s[i]) ;
        for (int i = 0; i < last.size(); i++)  printf("%c", last[i]) ;
    }
    else {
        for (int i = last.size() - 1; i >= 0; i--)  printf("%c", last[i]) ;
        for (int i = s.size() - 1; i >= 0; i--) printf("%c", s[i]) ;
        for (int i = first.size() - 1; i >= 0; i--)  printf("%c", first[i]) ;
    }
}


Measured memory_bytes: 1104
n,x,y = map(int,input().split())
x-=1
y-=1

ans = [0]*(n)
tmp = 10000000000000000
for i in range(n-1):
    for j in range(i+1,n):
        if i == j:continue
        tmp = min((j-i),abs(j-y)+abs(i-x)+1)
 #       print(tmp)
        ans[tmp] +=1



for i in ans[1:]:
    print(i)



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

using namespace std;
int main()
{
	vector<int> a;
	for (int i = 0; i < 3; i++)
	{
		int t;
		cin >> t;
		a.push_back(t);
	}
	sort(a.begin(), a.end());
	for (auto aa : a)
	{

		cout << aa ;
		if (aa != a[2])cout << " ";

	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 1212
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

int main(void){
    double PI=acos(-1);
    double a,b,c,num;
    double S,L,h,rad;
    cin>>a>>b>>c;
    
    rad=c*PI/180;
    S=a*b*(0.5)*sin(rad);
    num=pow(a,2)+pow(b,2)-2*a*b*cos(rad);
    L=a+b+sqrt(num);
    h=(S*2)/a;
    cout<<fixed<<setprecision(8)<<S<<endl<<L<<endl<<h<<endl;
    
    return 0;
}



Measured memory_bytes: 3640
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include<stack>
#include<sstream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<list>
#include<numeric>
typedef long long ll;

#define pi 3.14159265358979323846
#define VI vector<int>
#define VLL vector<long long>
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
const ll MOD = 1e9 + 7;
using namespace std;
template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a * b / gcd(a, b);
}

template<typename T>
T binarysearch(vector<T> A, T key) {
	ll left = 0;ll right = 4;ll mid;
	while (left < right) {
		mid = (left + right) / 2;
		if (key == A[mid]) return 1;
		if (key > A[mid]) left = mid + 1;
		else if (key < A[mid]) right = mid;
	}
	return 0;
}

template<typename T>
T finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}
ll frac(ll n)//階乗
{
	if (n == 0) {
		return 1;
	}
	return (n * frac(n - 1)) % MOD;
}

template<typename T>
T keta(T a) {
	ll kazu = 1;
	while (1) {
		if (a / 10 != 0) { a /= 10;kazu++; }
		else break;
	}
	return kazu;
}//桁数


template<typename T>
T nCr(ll n, T r) {
	ll ans = 1;
	for (int i = n; i > n - r; --i) {
		ans = ans * i;
	}
	for (int i = 1; i < r + 1; ++i) {
		ans = ans / i;
	}
	return ans;
}
/*char r[4];
int yaju[4];
char op[3];
int sum = 0;
scanf("%s", r);
for (int i = 0;i < 4;i++) {
	yaju[i] = r[i] - '0';
}
*///map < string, ll> s;

/*i++ずつずらす
a[0] a[1] a[2]//a[1] a[2] a[3]
a[0] a[2] a[4]//a[1] a[3] a[5]
/*if (N % 2 != 0)a = N / 2;
else a = N / 2 - 1;
for (int i = 1;i <= a;i++) {
	for (int j = 0;j < N - (i * 2);j++) {
		if (S[j] != S[j + i] && S[j + i * 2] != S[j] && S[j + i] != S[j + i * 2]) sum--;
		if (sum == 0)break;
	}
}*/

//mapの使い方
/*map<int, int> mp;
for (int i = 0; i < N; i++)
	mp[a[i]]++;

int ans = 0;
for (auto p : mp) {
	int x = p.first;
	int n = p.second;
	if (n < x) ans += n;
	else ans += n - x;
}*/

int main() {
	ll X,Y;cin >> X>>Y;
	ll ans = 1;
	while(1) {
		if (Y >= X * 2) {
			ans++;
			X *= 2;
		}
		else break;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import sys
from collections import deque
import copy

def power_func(a,b,p):
  if b==0: return 1
  if b%2==0:
    d=power_func(a,b//2,p)
    return d*d %p
  if b%2==1:
    return (a*power_func(a,b-1,p ))%p


class comb_calclator():
    def __init__(self, N, p):
        self.N = N
        self.p = p
        self.frac_N = [0 for i in range(N + 1)]
        self.frac_N[0] = 1L
        self.comb_N = {}
        for i in range(1, N + 1):
            self.frac_N[i] = (self.frac_N[i - 1] * i ) % p

    def comb(self, n, r):
        if n<0 or r<0 or n<r: return 0
        if n==0 or r==0: return 1
        if (n, r) in self.comb_N:
            return self.comb_N[(n, r)]
        a = self.frac_N[n]
        b = self.frac_N[r]
        c = self.frac_N[n - r]
        self.comb_N[(n, r)] = (a*power_func(b,self.p-2,self.p)*power_func(c,self.p-2, self.p))% self.p
        self.comb_N[(n, n - r)] = self.comb_N[(n, r)]
        return self.comb_N[(n, r)]


def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(i)
    i += 1
  if n > 1:
    table.append(n)
  return table

def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline


def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N, M] = [int(input_raw[0]), int(input_raw[1])]

    prime_table = prime_decomposition(M)
    primes = {}
    for p in prime_table:
        if p in primes:
            primes[p] += 1
        else:
            primes[p] = 1

    cmb = comb_calclator(10 * N, int(1e+9) + 7)
    count = 1
    for p in primes:
        b = primes[p]
        count = (count * cmb.comb(b + N - 1, b))%(int(1e+9) + 7)


    print count



if __name__ == '__main__':
    main()


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

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

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define ll int
#define bits_count __builtin_popcountll
#define endl '\n'
#define double long double
#define ld double
#define FOR(i,a,n) for (ll i=(a);i<=(n);++i)
#define RFOR(i,a,n) for (ll i=(n);i>=(a);--i)
#define ZERO(a) memset((a),0,sizeof((a)))
#define MINUS(a) memset((a),-1,sizeof((a)))
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define all(g) g.begin(),g.end()
#define sz(x) (ll)x.size()
#define pr pair<int,int>
int fastMax(int x, int y) { return (((y-x)>>(32-1))&(x^y))^y; }
int fastMin(int x, int y) { return (((y-x)>>(32-1))&(x^y))^x; }
    
// #include <ext/pb_ds/assoc_container.hpp> // Common file
// #include <ext/pb_ds/tree_policy.hpp>     // Including tree_order_statistics_node_updat
// using namespace __gnu_pbds;
// typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// const int RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
// struct chash { int operator()(int x) const { return x ^ RANDOM; }};
// cc_hash_table<int, int, hash<int>> cnt;

void solve(){
    int A,B; cin>>A>>B;

    if(A == B){
        cout<<1<<endl;
        return;
    }

    bitset<62> a(A),b(B);

    int highest_bit = 0;

    RFOR(i,0,61){
        if(a[i] == b[i]){
            a[i] = b[i] = 0;
        }else {
            highest_bit = i;
            break;
        }
    }

    int ans = (1LL<<highest_bit) - a.to_ullong();

    int second_highest_bit = -1;
    RFOR(i,0,highest_bit-1){
        if(b[i] == 1){
            second_highest_bit = i;
            break;
        }
    }

    int h = (1LL<<(second_highest_bit+1)) - 1;
    h = min(h,(int)a.to_ullong()-1);

    ans += h+1;
    ans += (1LL<<highest_bit) - a.to_ullong();
    cout<<ans<<endl;
}
    
signed main(){
    
    FastRead;     

    int t = 1; 
    // cin>>t;
    FOR(i,1,t){
        // cout<<"Case #"<<i<<": ";
        solve();
    }
}
    

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

int main()
{
	const int N = 3000;
	int x[N], y[N];
	int cnt = 0;//xとyは値を代入する変数、cntはカウントする変数

	while (cnt < 3000 && cin >> x[cnt] >> y[cnt]) {
		if (!x[cnt] && !y[cnt])break;
		if (x[cnt] > y[cnt]) {
			int t = x[cnt];
			x[cnt] = y[cnt];
			y[cnt] = t;
		}
		cnt++;
	}

	for (int i = 0; i < cnt; i++) {
		cout << x[i] << " " << y[i] << endl;
	}
    return 0;
}



Measured memory_bytes: 3004
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define ll long long int
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    int n; cin>>n;
    set<string>s;
    rep(i,0,n-1)
    {
        string k; cin>>k;
        s.insert(k);
    }
    cout<<s.size()<<"\n";
    return 0;
}

Measured memory_bytes: 19240
#include <iostream>
 
using namespace std;
 
int main() {
    int a, b; cin >> a >> b;
    if (a + b == 15) {
        cout << "+" << endl;
    } else if (a * b == 15) {
        cout << "*" << endl;
    } else {
        cout << "x" << endl;
    }
    return 0;
}

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

void solve(){
	
	ll t ;
	int n ;
	cin>>t>>n ;

	vector<int> v(n) ;

	ll sum=0 ;
	rep(i,n){
		cin>>v[i] ;
		sum+=v[i] ;
	}
	
	if(sum>=t)	
	{
		cout<<"Yes" ;
	}
	else
		cout<<"No" ;
}

int main(){
	
	int y ;

	y=1 ;
	//cin>>y ;

	while(y--)
	{	
		solve() ;
	}

}

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

const ll MOD = pow(10,9)+7;
map<pair<ll,ll>, ll> dp;

ll func(ll x,ll s){
	if(dp.count(make_pair(x,s)) > 0) return dp[make_pair(x,s)];
	if((x==0 && s==0) || (x==0 && s==1) || (x==1 && s==0)) return 1;
	
	ll ans = 0;
	ans += func(x/2,s/2);
	if(x>=1 && s>=1) ans += func((x-1)/2,(s-1)/2);
	if(s>=2) ans += func(x/2,(s-2)/2);
	
	return dp[make_pair(x,s)] = ans % MOD; // memo
}


int main(){
	
	ll n;
	cin >> n;
	
	cout << func(n,n) << endl;


}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	if(a<b)
		cout<<"a < b"<<endl;
	else if(a>b)
		cout<<"a > b"<<endl;
	else cout<<"a == b"<<endl;
	return 0;
}

Measured memory_bytes: 1156
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e16;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back

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

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}


int main(){
    ll N, M; cin >> N >> M;
    vvl cost(N, vl(N, LINF)); vpl edge;
    REP(i, M){
        ll a, b, c; cin >> a >> b >> c; a--; b--;
        cost[a][b] = c; cost[b][a] = c;
        edge.pb({a, b});
    }
    vvb used(N, vb(N, false));
    
    REP(st, N){
        vl dist(N, LINF); dist[st] = 0;
        priority_queue<PL, vector<PL>, greater<PL>> que;
        que.push({0, st});
        vl prev(N, LINF);
        while(que.size() > 0){
            auto tmp = que.top(); que.pop();
            ll cur = tmp.ss;
            if(dist[cur] < tmp.ff) continue;
            REP(i, N){
                if(cost[cur][i] < LINF){
                    if(dist[i] > dist[cur] + cost[cur][i]){
                        dist[i] = dist[cur] + cost[cur][i];
                        que.push({dist[i], i});
                        prev[i] = cur;
                    }
                }
            }
        }
        REP(j, N){
            if(prev[j] != LINF) used[j][prev[j]] = true;
        }
    }
    ll ans = M;
    REP(i, M){
        ll a = edge[i].ff, b = edge[i].ss;
        if(used[a][b] || used[b][a]) ans--;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
# -*- coding: utf-8 -*-
"""
Created on Sat Apr 20 20:47:47 2019

@author: Owner
"""

# -*- coding: utf-8 -*-
"""
Created on Sat Apr 13 09:53:12 2019

@author: Owner
"""
import numpy as np
import sys
import collections
import scipy.misc
import math
from operator import itemgetter
import itertools
import copy
import bisect

#素因数を並べる
def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(int(i))
    i += 1
  if n > 1:
    table.append(int(n))
  return table   
# 桁数を吐く
def digit(i):
    if i > 0:
        return digit(i//10) + [i%10]
    else:
        return []
    
def getNearestValueIndex(list, num):
    """
    概要: リストからある値に最も近い値のインデックスを取得する関数
    @param list: データ配列
    @param num: 対象値
    @return 対象値に最も近い値
    """

    # リスト要素と対象値の差分を計算し最小値のインデックスを取得
    idx = np.abs(np.asarray(list) - num).argmin()
    return idx

def find_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default


"""
N, X = map(int, input().split())

x = list(map(int, input().split()))

P = [0]*N
Y = [0]*N
for n in range(N):
    P[n], Y[n] = map(int, input().split())

# 多次元配列の宣言（あとでintにすること。）（タプルにすること。）
dp = np.zeros((N+1, 4,4,4))
    
all(nstr.count(c) for c in '753')

# 複数配列を並び替え
ABT = zip(A, B, totAB)
result = 0
# itemgetterには何番目の配列をキーにしたいか渡します
sorted(ABT,key=itemgetter(2))
A, B, totAB = zip(*ABT)
A.sort(reverse=True)

# 2進数のbit判定
(x >> i) & 1

# dp最小化問題
dp = [np.inf]*N
for n in range(N):
    if n == 0:
        dp[n] = 0
    else:
        for k in range(1,K+1):
            if n-k >= 0:
                dp[n] = min(dp[n], dp[n-k] + abs(h[n]-h[n-k]))
            else:
                break
# 累積和
add = 1 # 問題によって決まる
res = 0
sums = [0]*(len(nums)+1)
for i in range(len(nums)):
    sums[i+1] = sums[i] + nums[i]
for i in range(0, len(nums), 2):
    left = i
    right = min(i+add, len(nums))
    tmp = sums[right] - sums[left]
    res = max(tmp, res)

#２分探索
li, ri = bisect.bisect_left(p_ac, l[i]-1), bisect.bisect_right(p_ac, r[i]-1)    

#ソート関数
org_list = [3, 1, 4, 5, 2]
new_list = sorted(org_list)
print(org_list)
print(new_list)
# [3, 1, 4, 5, 2]
# [1, 2, 3, 4, 5]

#Distance Transformation
    for h in range(0,H):
        for w in range(0,W):
            if h == 0 and w == 0:
                pass
            elif h == 0:
                D[H-h-1][W-w-1]= min(D[H-h-1][W-w-1], D[H-h-1][W-w]+1)
            elif w == 0:   
                D[H-h-1][W-w-1]= min(D[H-h-1][W-w-1], D[H-h][W-w-1]+1)
            else:
                D[H-h-1][W-w-1]= min(D[H-h-1][W-w-1], D[H-h][W-w-1]+1, D[H-h-1][W-w]+1, D[H-h][W-w]+2)
            d_max = max(D[H-h-1][W-w-1], d_max)

"""
N, K = list(map(int, input().split()))
def main(): 
    print(N-K+1)
                
                
                
            
            
                

    
if __name__ == '__main__':
    main()


Measured memory_bytes: 22692
import math
SL = list(map(str, input().split()))
S = int("".join(SL))
X = int(math.sqrt(S))
hantei = False

for i in range(1, X + 1):
    if i**2 == S:
        hantei = True
        break

if hantei:
    print("Yes")
else:
    print("No")


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

using namespace std;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    float arr[n], ans, x = 2;
    for(int i = 0; i < n; i++) {
        cin >> arr[i];
    }
    sort(arr, arr+n);
    ans = arr[0]/pow(2, n-1);
    for(int i = n-1; i >= 1; i--) {
        ans += arr[i]/x;
        x *= 2;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4256
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(ll X = 0; X < N; X++)
#define PI (acos(-1.0))

using namespace std;

int main(){

    int h,w;
    vector<string> s;

    cin >> h >> w;

    string tmp;

    rep(i,w + 2){
        tmp = tmp + ".";
    }
    s.push_back(tmp);

    rep(i,h){
        string tmp;
        cin >> tmp;
        s.push_back("." + tmp + ".");
    }

    tmp = "";
    rep(i,w + 2){
        tmp = tmp + ".";
    }
    s.push_back(tmp);

    bool check = false;
    bool ans = true;    

    rep(i,h){
        rep(j,w){
            if(s[i + 1][j + 1] == '#'){
                check = false;
                rep(k,4){
                    if(s[i + 1 + round(sin(0.5 * k * PI))][j + 1 + round(cos(0.5 * k * PI))] == '#'){
                        
                        check = true;
                        break;
                    }

                }

                if(!check){
                    ans = false;
                    break;
                }
            }
        }

        if(!check){
            break;
        }
    }

    if(ans){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 768
#!/usr/bin python3
# -*- coding: utf-8 -*-

A, B, C = map(int, input().split())
K = int(input())
ret = 0
while B<=A:
    B *= 2
    ret += 1
while C<=B:
    C *= 2
    ret += 1
if ret <=K:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 9188
def fil(a,b)
   re=0
   ar=[1,2,3,4,5,6]
   br=[a,7-a,b,7-b]
   ar.each do |x|
      if br.include?(x)==false then
         re=judge(x,a,b)
         break
      end
   end
   return re
end

def judge(x,a,b)
   s1="23542354"
   s2="14631463"
   s3="12651265"
   s4="21562156"
   s5="36413641"
   s6="24532453"
   ht={1=>s1,2=>s2,3=>s3,4=>s4,5=>s5,6=>s6}
   p=x.to_s
   q=(7-x).to_s
   tmp=b.to_s+p+(7-b).to_s+q
   if ht[a].include?(tmp) then return x
   else return 7-x
   end
end

mp=gets.split(' ').map(&:to_i)
n=gets.to_i
lbl1=Hash.new
lbl2=Hash.new
mp.each_with_index do |x,i|
   lbl1.store(x,i+1)
   lbl2.store(i+1,x)
end
res=Array.new
n.times do |i|
   tmp=gets.split(' ').map(&:to_i)
   a=lbl1[tmp[0]]
   b=lbl1[tmp[1]]
   res.push(lbl2[fil(a,b)])
end
res.size.times do |i|
   puts res[i]
end

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

using namespace std;

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

    vector<vector<int>> h(N, vector<int>(3));

    for (int i = 0; i < N; i++) cin >> h[i][0] >> h[i][1] >> h[i][2];

    for (int i = 1; i < N; i++) {
        h[i][0] += max(h[i - 1][1], h[i - 1][2]);
        h[i][1] += max(h[i - 1][0], h[i - 1][2]);
        h[i][2] += max(h[i - 1][0], h[i - 1][1]);
    }

    cout << max(max(h[N - 1][0], h[N - 1][1]), h[N - 1][2]);

    return 0;
}


Measured memory_bytes: 8784
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(long long i=0; i<(long long)(n); i++)
#define REP(i, k, n) for(long long i=(long long)(k); i<(long long)(n); i++)
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define PQ(T) priority_queue<T>
#define PQS(T) priority_queue<T, vector<T>, greater<T> >
#define deci cout << fixed << setprecision(15);
typedef long long ll;
const ll inf = 1020304050607080910;
const int INF = 2000000000;
const ll mod = 1000000007;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
template<class T> bool chmin(T&x,T y){if(x>y){x=y;return true;}return false;}
template<class T> bool chmax(T&x,T y){if(x<y){x=y;return true;}return false;}
ll gcd(ll x,ll y){if(x>y)swap(x, y);while(x!=0){y%=x;swap(x, y);}return y;}
ll mpow(ll x,ll r){if(r==0)return 1;if(r%2==1){return x*mpow(x,r-1)%mod;}else{ll aa=mpow(x,r/2);return aa*aa%mod;}}


int main(){
	ll N; cin >> N;
	vector<int> g[N];
	ll e = 0;
	rep(i, N-1){
		int u, v; cin >> u >> v;
		u--; v--;
		g[u].pb(v);
		g[v].pb(u);
		if(u>v) swap(u, v);
		e = (e + (N-v)*(u+1));
	}
	ll ans = 0;
	rep(i, N){
		ans += ((i+1)*(i+2))/2;
	}
	cout << ans - e << endl;
	return 0;
}


Measured memory_bytes: 15080
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#include<ctime>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<bitset>
#define sqr(x) ((x)*(x))
#define fz1(i,n) for ((i)=1;(i)<=(n);(i)++)
#define fd1(i,n) for ((i)=(n);(i)>=1;(i)--)
#define fz0g(i,n) for ((i)=0;(i)<=(n);(i)++)
#define fd0g(i,n) for ((i)=(n);(i)>=0;(i)--)
#define fz0k(i,n) for ((i)=0;(i)<(n);(i)++)
#define fd0k(i,n) for ((i)=(long long)((n)-1);(i)>=0;(i)--)
#define fz(i,x,y) for ((i)=(x);(i)<=(y);(i)++)
#define fd(i,y,x) for ((i)=(y);(i)>=(x);(i)--)
#define fzin fz1(i,n)
#define fzim fz1(i,m)
#define fzjn fz1(j,n)
#define fzjm fz1(j,m)
#define ff(c,itr) for (__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define rdst(st,len){static char ss[len];scanf(" %s",ss);(st)=ss;}
#define inc(x,y) {x+=(y);if(x>=mod)x-=mod;}
#define dec(x,y) {x-=(y);if(x<0)x+=mod;}
#define spln(i,n) (i==n?'\n':' ')
#define fac_init(n){fac[0]=fac[1]=inv[1]=fi[0]=fi[1]=1;fz(i,2,n){fac[i]=1ll*fac[i-1]*i%mod;inv[i]=1ll*(mod-mod/i)*inv[mod%i]%mod;fi[i]=1ll*fi[i-1]*inv[i]%mod;}}
using namespace std;
inline void read(int &x)
{
	char c;int f=1;
	while(!isdigit(c=getchar()))if(c=='-')f=-1;
	x=(c&15);while(isdigit(c=getchar()))x=(x<<1)+(x<<3)+(c&15);
	x*=f;
}
const int mod=998244353;
int n,m,i,j,fac[1000005],inv[1000005],fi[1000005],ans;
int c(int x,int y)
{
	return 1ll*fac[x]*fi[y]%mod*fi[x-y]%mod;
}
int ic(int x,int y)
{
	return 1ll*fi[x]*fac[y]%mod*fac[x-y]%mod;
}
int f(int x,int y)
{
	return c(x+y,x);
}
int main()
{
	fac_init(1000003)
	cin>>n>>m;
	if(n>m) swap(n,m);
	ans=m;
	int iways=ic(n+m,n);
	fz0k(i,n){
		ans=(ans+1ll*inv[2]*f(i,m-n+i)%mod*f(n-i,n-i)%mod*iways)%mod;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 15372
import sys
range = xrange
input = raw_input
 
def find_SCC(coupl):
    SCC, S, P = [], [], []
    depth = [0] * len(coupl)
 
    stack = list(range(len(coupl)))
    while stack:
        node = stack.pop()
        if node < 0:
            d = depth[~node] - 1
            if P[-1] > d:
                SCC.append(S[d:])
                del S[d:], P[-1]
                for node in SCC[-1]:
                    depth[node] = -1
        elif depth[node] > 0:
            while P[-1] > depth[node]:
                P.pop()
        elif depth[node] == 0:
            S.append(node)
            P.append(len(S))
            depth[node] = len(S)
            stack.append(~node)
            stack += coupl[node]
    return SCC[::-1]
 
inp = [int(x) for x in sys.stdin.read().split()]; ii = 0
 
n = inp[ii]; ii += 1
m = inp[ii]; ii += 1
 
coupl = [[] for _ in range(n)]
for _ in range(m):
    u = inp[ii]; ii += 1
    v = inp[ii]; ii += 1
    coupl[u].append(v)
 
SCC = find_SCC(coupl)
out = [len(SCC)]
for scc in SCC:
    out.append(len(scc))
    for node in scc:
        out.append(node)
print ' '.join(str(x) for x in out)


Measured memory_bytes: 284764
#include<vector>
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<map>
#include<functional>
#include<queue>
#include<stack>
#include<string.h>
#define ll long long int
#define MOD 1000000007LL
using namespace std;
int gcd(int m,int n){
    if((0==m)||(0==n)){
        return 0;
    }
    if(m<n){
        swap(m,n);
    }
    int r=m%n;
    while(r!=0){
        m=n;
        n=r;
        r=m%n;
    }
    return n;
}
int main() {
    int n,k;
    cin>>n>>k;
    int a;
    int m=0;
    int g=1;
    for(int i=0;i<n;i++){
        cin>>a;
        if(m<a){
            m=a;
        }
        if(i==0){
            g=a;
        }else{
            g=gcd(g,a);
        }
    }
    if((k%g==0)&&(k<=m)){
        cout<<"POSSIBLE"<<endl;
    }else{
        cout<<"IMPOSSIBLE"<<endl;
    }
}

Measured memory_bytes: 256