akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>

template <typename List>
void split(const std::string& s, const std::string& delim, List& result)
{
    result.clear();

    using string = std::string;
    string::size_type pos = 0;

    while(pos != string::npos )
    {
        string::size_type p = s.find(delim, pos);

        if(p == string::npos)
        {
            result.push_back(s.substr(pos));
            break;
        }
        else {
            result.push_back(s.substr(pos, p - pos));
        }

        pos = p + delim.size();
    }
}

int main(){
    int a = 0, b = 0;
    std::string s;
    
    std::cin >> a >> b;
    std::cin >> s;
    
    std::vector<std::string> result;
    split(s, "-", result);
    
    if(result[0].size() == a && result[1].size() == b){
        std::cout << "Yes" << std::endl;
    }else{
        std::cout << "No" << std::endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
def bellman_ford(vertices, edges, source):
    for v in vertices:
        if v is source:
            v.distance = 0
        else:
            v.distance = Infinity()
        v.predecessor = None
    for _ in xrange(len(vertices)-1):
        for uv in edges:
            u = uv.source
            v = uv.destination
            if v.distance > u.distance + uv.weight:
                v.distance = u.distance + uv.weight
                v.predecessor = u
    for uv in edges:
        u = uv.source
        v = uv.destination
        if u.distance + uv.weight < v.distance:
            raise NegativeCycleError

def main():
    V, E, r = map(int, raw_input().split())
    vertices = [Vertex() for _ in xrange(V)]
    edges = []
    for _ in xrange(E):
        s, t, d = map(int, raw_input().split())
        edges.append(Edge(vertices[s], vertices[t], d))
    try:
        bellman_ford(vertices, edges, vertices[r])
        for v in vertices:
            print v.distance
    except NegativeCycleError:
        print "NEGATIVE CYCLE"

class Infinity(object):
    def __eq__(self, other):
        return other is self

    def __lt__(self, other):
        return False

    def __gt__(self, other):
        return True

    def __add__(self, other):
        return self

    def __radd__(self, other):
        return slef

    def __str__(self):
        return "INF"
    __repr__ = __str__

class NegativeCycleError(Exception):
    pass

class Edge(object):
    def __init__(self, source, destination, weight):
        self.source = source
        self.destination = destination
        self.weight = weight

class Vertex(object):
    def __init__(self, distance=None, predecessor=None):
        self.distance = distance
        self.predecessor = predecessor

if __name__ == "__main__":
    main()

Measured memory_bytes: 5408
import java.util.*;


public class Main{ 

	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		int operationNum = scan.nextInt();
		BinarySearchTree tree = new BinarySearchTree();
		scan.nextLine();
		for(int i=0; i<operationNum; i++)
			tree.operation(scan);
		// ArrayList<BinarySearchTreeNode> list = 
		//  tree.inOrderConnect(new ArrayList<BinarySearchTreeNode>());

	}

}
class BinarySearchTree{
	private BinarySearchTreeNode root=null;
	public BinarySearchTree(){
		//root = new BinarySearchTreeNode();
	}
	public void operation(Scanner sc){
		if(sc.next().equals("print"))
			print();
		else{
			//String[] key = code.split(" ");
			insert(Integer.parseInt(sc.next()));		
		}

	}
	public void insert(int key){
		if(root==null)
			root = new BinarySearchTreeNode(key);
		else
			root.insertNode(key);
	}
	public void print(){
		keyOrderToString(this.root.inOrderConnect(new ArrayList<BinarySearchTreeNode>()));
		System.gc();
		keyOrderToString(this.root.preOrderConnect(new ArrayList<BinarySearchTreeNode>()));
	}
	private static void keyOrderToString(ArrayList<BinarySearchTreeNode> list){
		// StringBuilder temp = new StringBuilder();
		// for(Iterator<BinarySearchTreeNode> iter = list.iterator(); iter.hasNext();)
		// 	temp.append(" "+iter.next().getKey());
		// System.out.println(new String(temp));
		for(Iterator<BinarySearchTreeNode> iter = list.iterator(); iter.hasNext();){
			System.out.print( new StringBuilder().append(" ").append(iter.next().getKey()));

		}
		System.out.println("");	
	}

}



class BinarySearchTreeNode{
	protected int key;
	protected BinarySearchTreeNode parent = null;
	protected BinarySearchTreeNode LeftChild = null;
	protected BinarySearchTreeNode RightChild = null;
	public BinarySearchTreeNode(int key){
		this.key = key;
	}
	public BinarySearchTreeNode(int key, BinarySearchTreeNode parent){
		this.key = key;
		this.parent = parent;
	}
	void insertNode(int key){
		if(key < this.key){
			if(this.LeftChild ==null)
				this.LeftChild = new BinarySearchTreeNode(key, this);
			else
				this.LeftChild.insertNode(key);
			return;
		}else{
			if(this.RightChild ==null)
				this.RightChild = new BinarySearchTreeNode(key, this);
			else
				this.RightChild.insertNode(key);
			return;
		}
	}
	public ArrayList<BinarySearchTreeNode> preOrderConnect(ArrayList<BinarySearchTreeNode> list){
		list.add(this);
		if(LeftChild!=null)
			LeftChild.preOrderConnect(list);
		if(RightChild!=null)
			RightChild.preOrderConnect(list);
		return list;
	}
	public ArrayList<BinarySearchTreeNode> inOrderConnect(ArrayList<BinarySearchTreeNode> list){
		if(LeftChild!=null)
			LeftChild.inOrderConnect(list);
		list.add(this);
		if(RightChild!=null)
			RightChild.inOrderConnect(list);
		return list;
	}	
	public int getKey(){
		return this.key;
	}

}

Measured memory_bytes: 203348
// AOJ GRL_6_A
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>

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

using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vc;

const int INF = 0x3fffffff;

// ?????§???????±???????(Dinic??????bfs()??????????????¨Ford-Fulkerson???)
class Flow{
	public:
		int N;	// ????????°
		vector<vc> F, C, edge;	// F:????????°?????? C:???????????? edge:??£??\????????????
		vector<bool> bf;	// ??????????????£???????????????
		vector<int> lv;	// S??????????????¢

		// ????????????????????? n:????????°
		Flow(int n): F(n,vc(n)), C(n,vc(n)), N(n), edge(n) {}

		// f->t????????????c?????????????????????(??????f->t??????????????????????????????????????¨?????????)
		void addEdge(int f, int t, int c){
			F[f][t] += c;
			C[f][t] += c;
			edge[f].push_back(t);
			edge[t].push_back(f);
		}

		// ??????f->t?????¢????????????addEdge()???????????????????????????????????????????????¨??????
		void uniqueEdge(){
			for(auto e: edge){
				sort( e.begin(), e.end() );
				e.erase( unique( e.begin(), e.end() ), e.end() );
			}
		}

		// s????????????????????¢????±?????????????????????????????????¨DFS??§?????????????????????????????¢?´¢??????
		int bfs(int S, int T){
			lv.assign(N, 0);
			queue<int> que;
			que.push(S);
			lv[S] = 1;
			while( !que.empty() ){
				int n = que.front(); que.pop();
				for(auto v: edge[n]) if( !lv[v] && F[n][v] ){
					lv[v] = lv[n] + 1;
					que.push(v);
				}
			}
			return lv[T];
		}

		// ?¢?????????????DFS??§??¢???
		int dfs(int n, int c, int T){
			if( n == T ) return c;
			bf[n] = true;
			for(int v: edge[n]) if( F[n][v] && !bf[v] && lv[v] > lv[n] ){	// ??????????????¶??????????????¨bfs()?????????????????????
				int f = dfs(v, min(c, F[n][v]), T);
				F[n][v] -= f;
				F[v][n] += f;
				if( f > 0 ) return f;
			}
			return 0;
		}

		// ?????§???????±???????
		int maxFlow(int S, int T){
			if( S == T ) return INF;
			int ret = 0;
			while( bfs(S,T) )	// bfs()???????????´?????????????????????????????????
				for(int add; bf.assign(N,0), add = dfs(0, INF, T);) ret += add;
			return ret;
		}

		// ??????????????????????????????????????????
		int flow(int f, int t){ return C[f][t] - F[f][t]; }

		// ??£??\?????????????????????????¨???????????????????n=S,T??\????????´?????????????????????1/2????????????????????????????????????
		int flow(int n){
			int ret=0;
			for(int v: edge[n]) ret += abs( flow(n,v) );
			return ret;
		}

		// ??°???????????????????????????
		void clear(){ rep(i,N) rep(j,N) F[i][j] = C[i][j]; }
};

int main(){
	int V, E;
	cin >> V >> E;
	Flow fl(V);
	rep(i, E){
		int u, v, c;
		cin >> u >> v >> c;
		fl.addEdge( u, v, c );
		fl.uniqueEdge();
		fl.maxFlow(0, V-1);
		//cout << u << ":" << v << " " << fl.flow(v,u) << endl;
	}

	cout << fl.flow(0) << endl;

	return 0;
}

Measured memory_bytes: 3228
#include <bits/stdc++.h> 
using namespace std;
///////////////////////////////////////////
const long long int INF = 100000000000;
const long long int Mod = 1000000007;
using ll = long long int; //long long int は64bit
using vi = vector<int>; using Vi = vector<long long int>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(long long int i=0;i<N;i++)
#define np nullptr
template<class T>bool chmax(T &former, const T &b) { if (former<=b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define fill(x,num) memset(x,num,sizeof(x));
typedef vector<vector<ll> > matrix;
typedef pair<ll,ll> Pair;
bool p_compare(const Pair& firstP, const Pair& secondP)
 { return firstP.first < secondP.first; }//sort(all(v),p_compare)で昇順ソート
//////////////////////////^^ *Emile ^^^//////////////////////////////////////////////////////
//Snipet -> Caps Lock

ll n;
vi a;

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	cin>>n;ll aaa;
	rep(i,n){
		cin>>aaa;
		a.pb(aaa);
	}//input

	ll key = 0;
	rep(i,n){
		if(a[i]%2==1)key++;
	}
	if(key%2==0)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}


Measured memory_bytes: 892
S = input()
alphabets = set(chr(ord('a')+x) for x in range(26))

f1 = (S[0]=="A")
f2 = (S[2:-1].count("C")==1)
f3 = (set(S)-set("AC")<=alphabets)

if f1 and f2 and f3:
  print("AC")
else:
  print("WA")

Measured memory_bytes: 3060
//JSD
#include<iostream>
#define Mod 1000000007
#define ll long long 
using namespace std;
ll modular_exponentiation(ll a,ll b){	
	if(b==0){
		return 1;
	}
	if(b==1){
		return a%Mod;
	}
	ll x=modular_exponentiation(a,b/2);
	x=(x*x)%Mod;	
	if(b%2==1){
		x=(x*a)%Mod;
	}
	return x;
}
ll modular_divison(ll a,ll b){
    return (modular_exponentiation(b,Mod-2)*a)%Mod;	
}
int main(){	
	ll n;
	cin>>n;
	ll a[n];
	for(int i=0;i<n;i++)
		cin>>a[i];
	ll ans=0;
	ll count[60]={0};	
	for(int i=0;i<n;i++){
		ll x=1;
		for(int j=0;j<60;j++){
			if((a[i]&(x<<j))!=0){
				count[j]++;
			}
		}
	}	
	for(int i=0;i<n;i++){
		for(int j=0;j<60;j++){
			ll x=1;
			if((a[i]&(x<<j))!=0){			
				ll p = (x<<j)%Mod;
				ans=(ans+(p*(n-count[j]))%Mod)%Mod;
			}
			else{
				ll p = (x<<j)%Mod;
				ans=(ans+(p*(count[j]))%Mod)%Mod;
			}
		}
	}
	cout<<modular_divison(ans,2)<<"\n";
		
	return 0;
}

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

int main() {
	int na;
	while (cin >> na, na) {
		int t = 1,n=5,s=2,w=4,e=3,b=6;
		int tsum = 1;
		for (int i = 0;i < na;i++) {
			string sa;
			cin >> sa;
			if (sa == "North") {
				int a[4] = { t,s,b,n };
				t = a[1];
				s = a[2];
				b = a[3];
				n = a[0];
				tsum += t;
			}
			else if (sa == "East") {
				int a[4] = { t,e,b,w };
				t = a[3];
				e = a[0];
				b = a[1];
				w = a[2];
				tsum += t;
			}
			else if (sa == "West") {
				int a[4] = { t,w,b,e };
				t = a[3];
				w = a[0];
				b = a[1];
				e = a[2];
				tsum += t;
			}
			else if (sa == "South") {
				int a[4] = { t,s,b,n };
				t = a[3];
				s = a[0];
				b = a[1];
				n = a[2];
				tsum += t;
			}
			else if (sa == "Right") {
				int a[4] = { s,e,n,w };
				s = a[1];
				e = a[2];
				n = a[3];
				w = a[0];
				tsum += t;
			}
			else {
				int a[4] = { s,e,n,w };
				s = a[3];
				e = a[0];
				n = a[1];
				w = a[2];
				tsum += t;
			}
		}
		cout << tsum << endl;
	}
	return 0;
}

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

typedef long long ll;
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define debug(x) cerr << #x << ": " << x << '\n'

int main()
{
    int N, M;
    map<string, int> s;
    map<string, int> t;

    cin >> N;
    for (int i = 0; i < N; ++i)
    {
        string temp;
        cin >> temp;
        s[temp] += 1;
    }
    cin >> M;
    for (int i = 0; i < M; ++i)
    {
        string temp;
        cin >> temp;
        t[temp] += 1;
    }
    int ans = 0;
    for (map<string, int>::iterator itr = s.begin(); itr != s.end(); ++itr)
    {
        int val = itr->second - t[itr->first];
        ans = max(ans, val);
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
const int M=1e9+7;
const int INF=0x3f3f3f3f;
const double PI=acos(-1.0);
typedef long long ll;
typedef pair<int,int> PII;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	
	int a[5];
	cin>>a[0]>>a[1]>>a[2];
	sort(a,a+3);
	if(a[0]==a[2]||(a[0]!=a[1]&&a[1]!=a[2]))
		cout<<"No"<<endl;
	else
		cout<<"Yes"<<endl; 
		
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int t,i,j,k,l,m,n,count=0;
    pair<long long int,long long int>p[100005];
    cin>>n;
    for(i=0;i<n;i++)
    cin>>p[i].first>>p[i].second;
    sort(p,p+n);
    for(i=0;i<n-1;i++)
    {
        count=count+min((p[i+1].first-p[i].first-1),(p[i].second-p[i+1].second-1));
    }
    count=count+n;
    count=count+p[n-1].second;
    count=count+p[0].first-1;
    cout<<count;
    return 0;
}

Measured memory_bytes: 1792
N, M = map(int, input().split())

like_list = []
for n in range(N):
    like_list.append(list(map(int, input().split())))

foods = [0] * M
num = 0
for like in like_list:
    for elem in like[1:]:
        foods[elem-1] += 1
        if foods[elem-1] == N:
            num += 1

print(num)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
 
int main() {
  string S;
  cin >> S;
  if(S == "SUN"){
    cout << 7 << endl;
  } else if(S == "MON"){
    cout << 6 << endl;
  } else if(S == "TUE"){
    cout << 5 << endl;
  } else if(S == "WED"){
    cout << 4 << endl;
  } else if(S == "THU"){
    cout << 3 << endl;
  } else if(S == "FRI"){
    cout << 2 << endl;
  } else if(S == "SAT"){
    cout << 1 << endl;
  }
  return 0;
}


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

using namespace std;
using ll = long long;
using P = pair<ll, ll>;

const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const int MOD = 1000000007;

// Library

//
int main() {
#ifdef MYLOCAL
    ifstream in("input.txt");
    cin.rdbuf(in.rdbuf());
#endif
    int a,b;
    cin >> a >> b;
    if(b % a == 0){
        cout << a + b << endl;
    }
    else{
        cout << b - a << endl;
    }
    return 0;
}



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

#define rep(i, N) for (ll i = 0; i < N; i++)
#define rep1(i, N) for (ll i = 1; i <= N; i++)
#define repr(i, N) for (ll i = N-1; i >= 0; i--)
#define repr1(i, N) for (ll i = N; i > 0; i--)

#define MOD 1000000007

using ll = long long;
using namespace std;

typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<P> vpi;
typedef pair<ll,ll> Pl;
typedef vector<ll> vl;
typedef vector<Pl> vpl;

ll gcd(ll a, ll b){
    if(a < b) swap(a, b);
    if(b <= 0) return -1;
    ll r = a % b;
    while(r != 0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

ll lcm(ll a, ll b){
    return (a/gcd(a,b)*b);
}

int main() {
    ll ans = 0;
    int N;
    cin >> N;
    vl A(N), B(N), C(N), ans_b(N);
    rep(i, N) cin >> A[i];
    rep(i, N) cin >> B[i];
    rep(i, N) cin >> C[i];

    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    sort(C.begin(), C.end());
    
    int l_index = 0, r_index = N-1;
    rep(i, N){
        l_index = 0;
        r_index = N-1;
        int c_index = (r_index + l_index)/2;
        int value = B[i];
        while(r_index != c_index && l_index != c_index){
            if(value < C[c_index]){
                r_index = c_index;
            }else{
                l_index = c_index;
            }
            c_index = (r_index + l_index)/2;
        }
        if(value < C[l_index]) r_index = l_index;
        if(value >= C[r_index]) r_index = N;

        ans_b[i] = N - r_index;
    }
    rep(i,N-1) ans_b[N-2-i] += ans_b[N-1-i];
    
    l_index = 0, r_index = N-1;
    rep(i, N){
        l_index = 0;
        r_index = N-1;
        int c_index = (r_index + l_index)/2;
        int value = A[i];
        while(r_index != c_index && l_index != c_index){
            if(value < B[c_index]){
                r_index = c_index;
            }else{
                l_index = c_index;
            }
            c_index = (r_index + l_index)/2;
        }
        if(value < B[l_index]) r_index = l_index;
        if(value >= B[r_index]){
            r_index = N;
        }else {
            ans += ans_b[r_index];
        }       
    }

    cout << ans;
    //printf("%.15lf", ans);
    cout << "\n";
    return 0;
}


Measured memory_bytes: 3328
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>

using namespace std;
typedef long long LL;
typedef pair<int,int> P;

// a>=0, b>=0, x*a+y*b=gcd>=0, a>0,b>0=>abs(y)<=a,abs(x)<=b
LL gcdex(LL a,LL b,LL& x, LL& y){
	LL ax=1,ay=0;
	LL bx=0,by=1;
	while(b){
		LL r=a/b;
		LL t=a-r*b; a=b; b=t;
		LL tx=ax-r*bx; ax=bx; bx=tx;
		LL ty=ay-r*by; ay=by; by=ty;
	}
	x=ax;
	y=ay;
	return a;
}
LL modinv(LL a, LL m){
	LL x,y;
	gcdex(a,m,x,y);
	if(x<0){
		x+=m;
	} else if(x>=m){
		x-=m;
	}
	return x;
}
const LL M=1e9+7;
LL B,W;
const int L=2e5+10;
LL ps[L];
LL ips[L];
LL vs[L];
int main() {
	cin >> B >> W;
	LL i2=modinv(2,M);
	ps[0]=1;
	ips[0]=1;
	vs[0]=1;
	for(int i=1;i<=B+W;i++){
		ps[i]=i*ps[i-1]%M;
		ips[i]=modinv(i,M)*ips[i-1]%M;
		vs[i]=i2*vs[i-1]%M;
	}
	LL b=0,w=0;
	for(int i=1;i<=B+W;i++){
		LL r=(1+M-b+M-w)%M;
		//cerr << b << ", " << w << ", " << r << endl;
		cout << (r*i2%M+w)%M << endl;
		if(i>=B){
			b+=vs[i]*ps[i-1]%M*ips[B-1]%M*ips[i-B]%M;
			b%=M;
		}
		if(i>=W){
			w+=vs[i]*ps[i-1]%M*ips[W-1]%M*ips[i-W]%M;
			w%=M;
		}
	}

	return 0;
}



Measured memory_bytes: 6912
import java.io.*;
import java.util.*;

public class Main {

	final static long MOD = 1000000007L;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static ArrayList<int[]> list = new ArrayList<>();
	public static void main(String[] args) throws Exception {

		int N = nextInt();
		int[] x = new int[N];
		int[] y = new int[N];

		for(int i=0;i<N;i++){
			x[i]=nextInt();
			y[i]=nextInt();
		}

		double ans = 0;

		//順列の要素
		int[] seed = new int[N];
		for(int i=0;i<N;i++){
			seed[i]=i;
		}
		boolean[] used = new boolean[seed.length];
		Arrays.fill(used, false);
		int[] result = new int[seed.length];
		//順列の作成
		perm(seed,used,0,result);

		for(int k=0;k<list.size();k++){
			int[] p = list.get(k);
			for(int i=0;i<N-1;i++){
				ans+=Math.sqrt(Math.pow(x[p[i]]-x[p[i+1]], 2)+Math.pow(y[p[i]]-y[p[i+1]], 2));
			}
		}
		System.out.printf("%.6f%n",ans/list.size());
	}


public static void perm(int[] seed,boolean[] used,int idx,int[] ans){
	if(idx>=seed.length) {
		list.add(Arrays.copyOf(ans, ans.length));
		return;
	}
	for(int i=0;i<seed.length;i++){
		if(used[i]){
			continue;
		}
		used[i]=true;
		ans[idx]=seed[i];
		perm(seed,used,idx+1,ans);
		used[i]=false;
	}
}

	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


Measured memory_bytes: 23872
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,int> pdi;
typedef pair<double,double> pdd;
typedef pair<double,ll> pdl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<vl> vvl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<pdd> vdd;
typedef vector<pdi> vdi;
typedef vector<pdl> vdl;
#define fi first
#define se second
const ll INFLL=LLONG_MAX;
const int INF=INT_MAX;
const ll MAXLL=0x3f3f3f3f3f3f3f3f;
const int MAX=0x3f3f3f3f;
#define eb emplace_back
#define emp emplace
#define mp(a,b) make_pair(a,b)
template<class T> using min_heap=priority_queue<T,vector<T>,greater<T> >;
template<class T>
void sort(vector<T>& v){
	sort(v.begin(),v.end());
}
template <class T, class U>
void sort(vector<T>& v,U func){
	sort(v.begin(),v.end(),func);
}
template<class T>
void rsort(vector<T>& v){
	sort(v.rbegin(),v.rend());
}
template <class T>
int lb_index(vector<T>& v,T k){
	return lower_bound(v.begin(),v.end(),k)-v.begin();
}
template <class T>
int ub_index(vector<T>& v,T k){
	return upper_bound(v.begin(),v.end(),k)-v.begin();
}
template<class T>
bool is_sorted(vector<T>& v){
	return is_sorted(v.begin(),v.end());
}
template<class T>
bool sorted(vector<T>& v){
	return is_sorted(v);
}
void precompute(){
 
	return;
}
void solve(){
	ll n,m;
	cin>>n>>m;
	vi v(n+5);
	for(int i=0;i<m;i++){
		int l,r;
		cin>>l>>r;
		v[l]++;
		v[r+1]--;
	}
	ll ans=0;
	for(int i=1;i<=n;i++){
		v[i]+=v[i-1];
		if(v[i]==m)ans++;
	}
	cout<<ans;
}
 
int main(){
	ios::sync_with_stdio(0);
	int numberofsubtestcases=1;
//	cin>>numberofsubtestcases;
	precompute();
	for(int looping=1;looping<=numberofsubtestcases;looping++){
//		cout<<"Case #"<<looping<<": ";
		solve();
	}
	return 0;
}

Measured memory_bytes: 3780
/*The woods are lovely, dark and deep,
But I have promises to keep,
And miles to go before I sleep,
And miles to go before I sleep.*/

//PRABHJOT SINGH A.K.A. PRABHI
//~~~~~conquizztador~~~~~


#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define pb push_back
#define fi first
#define se second
#define MOD 1000000007
const int maxn= 100010;
map<lli, lli> m;
   void trial_division2(lli n) {
    //vector<long long> factorization;
    while (n % 2 == 0) {
        //factorization.push_back(2);
        m[2]++;
        n /= 2;
    }
    for (lli d = 3; d * d <= n; d += 2) {
        while (n % d == 0) {
            //factorization.push_back(d);
            m[d]++;
            n /= d;
        }
    }
    if (n > 1)
        {
        	//factorization.push_back(n);
        	m[n]++;
        }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lli n=0ll;
    cin>>n;
    trial_division2(n);
    int ans=0;
    for(auto ele: m)
    {
    	int ct=1;
    	while(ele.se>0ll)
    	{
    		if(ct<=ele.se)
    		{
    			++ans;
    			ele.se-=ct;
    			++ct;
    		}
    		else
    			break;
    	}
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3656
import math
a, b = map(int, input().split())
ans = 1000000
for i in reversed(range(a, 10000)):
    if math.floor(i * 0.08) == a and math.floor(i * 0.10) == b:
        ans = min(i, ans)
        if i * 0.08 == math.floor(i * 0.08):
            break
print(ans) if ans != 1000000 else print(-1)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

typedef long long ll;

const ll MAX_N = 2e5+10;

int main(int argc, char const *argv[])
{
    ll n;
    int a[MAX_N] = {0}, x[MAX_N] = {0};
    cin >> n;
    for (ll i = 1; i <= n; ++i) {
        cin >> a[i];
    }

    vector<ll> vec;
    bool tf = true;

    for (ll i = n; i > 0 && tf; --i) {
        if (i*2>n) {
            x[i] = a[i];
        }
        else {
            int sum = 0;
            for (int j = 2; j <= n/i; ++j) {
                sum += x[j*i];
                sum %= 2;
            }
            if ((sum+1)%2==a[i]) {
                x[i] = 1;
            }
            else x[i] = 0;
        }
    }

    for (ll i = 1; i <= n; ++i) {
        if (x[i] == 1) {
            vec.emplace_back(i);
        }
    }

    if (tf) {
        cout << vec.size() << endl;
        for (int i = 0; i < vec.size(); ++i) {
            printf("%lld\n", vec[i]);
        }
    }
    else cout << -1 << endl;

    return 0;
}

Measured memory_bytes: 3700
from heapq import heappush, heappop
import sys
input = sys.stdin.readline

INF = float('inf')

# 単一始点最短経路を求める（Dijkstra法）
def Dijkstra(adjList, vSt):
    numV = len(adjList)
    numUsed = 0
    costs = [INF] * numV
    costs[vSt] = 0
    PQ = []
    heappush(PQ, (0, vSt))
    while PQ:
        cNow, vNow = heappop(PQ)
        if cNow > costs[vNow]: continue
        numUsed += 1
        if numUsed == numV: break
        for v2, wt in adjList[vNow]:
            c2 = cNow + wt
            if c2 < costs[v2]:
                costs[v2] = c2
                heappush(PQ, (c2, v2))
    return costs

N, M = map(int, input().split())
adjL = [[] for _ in range(N)]
for _ in range(M):
    L, R, C = map(int, input().split())
    L, R = L-1, R-1
    adjL[L].append((R, C))
    adjL[R].append((L, C))

for i in range(N-1):
    adjL[i+1].append((i, 0))

costs = Dijkstra(adjL, 0)

if costs[-1] == INF:
    print(-1)
else:
    print(costs[-1])


Measured memory_bytes: 54596
package main

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

const (
	defaultBufferSize = 1024
	maxBufferSize     = 1e6
	Mod               = 1e9 + 7
)

var sc = bufio.NewScanner(os.Stdin)

// sc.Buffer(make([]byte, defaultBufferSize), maxBufferSize)

func readInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func readString() string {
	sc.Scan()
	return sc.Text()
}

func readInt64() int64 {
	sc.Scan()
	i, err := strconv.ParseInt(sc.Text(), 10, 64)
	if err != nil {
		panic(err)
	}
	return int64(i)
}

func readfloat64() float64 {
	sc.Scan()
	f, err := strconv.ParseFloat(sc.Text(), 64)
	if err != nil {
		panic(err)
	}
	return f
}

func abs(a int) int {
	if a < 0 {
		return a * -1
	}
	return a
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func gcd(x, y int) int {
	if y == 0 {
		return x
	}
	return gcd(y, x%y)
}

func ModComb(n, k int) int {
	if k == 0 {
		return 1
	}
	x, y := n, k
	for i := 1; i < k; i++ {
		x = x * (n - i) % Mod
		y = y * (k - i) % Mod
	}
	inv := ModInv(y)
	return x * inv % Mod
}

func ModFact(x int) int {
	fact := 1
	for i := 1; i <= x; i++ {
		fact = fact * i % Mod
	}
	return fact
}

func ModInv(x int) int {
	return ModPow(x, Mod-2)
}

func ModPow(a, n int) int {
	res := 1
	for n > 0 {
		if n%2 != 0 {
			res = res * a % Mod
		}
		a = a * a % Mod
		n /= 2
	}
	return res
}

func pow(a, n int) int {
	if n == 0 {
		return 1
	}

	ans := 0
	if n%2 == 0 {
		ans = pow(a*a, n/2)
	} else {
		ans = a * pow(a*a, (n-1)/2)
	}
	return ans
}

func intSliceReverse(slice []int) []int {
	for i, j := 0, len(slice)-1; i < j; i, j = i+1, j-1 {
		slice[i], slice[j] = slice[j], slice[i]
	}
	return slice
}

func stringReverse(str string) string {
	runes := []rune(str)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func primeFactorization(x int) map[int]int {
	result := make(map[int]int, 0)
	for i := 2; i*i <= x; i++ {
		for x%i == 0 {
			result[i]++
			x /= i
		}
	}
	if x != 1 {
		result[x]++
	}
	return result
}

func isPrime(x int) bool {
	if x == 1 {
		return false
	}
	for i := 2; i*i <= x; i++ {
		if i == x {
			continue
		}
		if x%i == 0 {
			return false
		}
	}
	return true
}

func main() {
	sc.Split(bufio.ScanWords)
	a := readInt()
	fmt.Println(a + a*a + a*a*a)
}


Measured memory_bytes: 1772
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan=new Scanner(System.in);
        int i,n,card;
        int array[]=new int[52];
        String s;
        for(i=0;i<52;i++){
        	array[i]=0;
        }
        n=scan.nextInt();
        for(i=0;i<n;i++){
        	s=scan.next();
        	card=scan.nextInt();
        	switch(s){
        		case"S":
        			card-=1;
        			break;
        		case"H":
        			card+=12;
        			break;
        		case"C":
        			card+=25;
        			break;
        		case"D":
        			card+=38;
        			break;
        		default:
        			continue;
        	}
        	array[card]=1;
        }
        for(i=0;i<52;i++){
        	if(array[i]==0){
        		if(i/13==0){
        			System.out.println("S "+ (i%13+1));
        		}
        		else if(i/13==1){
        			System.out.println("H "+ (i%13+1));
        		}
        		else if(i/13==2){
        			System.out.println("C "+ (i%13+1));
        		}
        		else if(i/13==3){
        			System.out.println("D "+ (i%13+1));
        		}
        	}
        }
    }
}



Measured memory_bytes: 26280
#include<bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define C 0.5772156649
#define pi acos(-1.0)
#define ll long long
#define mod 1000000007
#define ls l,m,rt<<1
#define rs m+1,r,rt<<1|1

using namespace std;

const double g=10.0,eps=1e-12;
const int N=200000+10,maxn=90000+10,inf=0x3f3f3f3f;

int num[N];
int a[N];
bool cmp(int x,int y)
{
    return num[x]>num[y];
}
int main()
{
    int n,k,sz=0;
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++)
    {
        int x;
        scanf("%d",&x);
        if(!num[x])a[sz++]=x;
        num[x]++;
    }
    sort(a,a+sz,cmp);
    /*for(int i=0;i<sz;i++)
        cout<<a[i]<<endl;*/
    int ans=0;
    for(int i=0;i<min(k,sz);i++)
        ans+=num[a[i]];
    printf("%d\n",n-ans);
    return 0;
}
/********************

********************/


Measured memory_bytes: 1792
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong() - 1;
        long base = 26;
        int idx = 0;
        long[] counts = new long[10];
        for (int i = 0; i < 11; i++) {
            if (n - base < 0) {
                idx = i;
                break;
            }
            n -= base;
            base *= 26;
        }
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i <= idx; i++) {
            sb.append((char)(n % 26 + 'a'));
            n /= 26;
        }
        System.out.println(sb.reverse());
    }
}

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

#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline")

const int INF = 1000000000;

#define vi vector<int>
#define ll long long int
#define vvi vector<vi>
#define pi pair<int,int>
#define vp vector<pi>
#define vvp vector<vp>
#define vl vector<ll>
#define vvl vector<vl>
#define pl pair<ll,ll>
#define vpl vector<pl>

#define sz(x) (int)x.size()
#define mp make_pair
#define pb push_back
#define fe first
#define se second
#define all(x) x.begin(),x.end()


int main()
{
    string s;
    cin >> s;
    if(s == "SSS") cout << 0 << endl;
    else if(s == "RSS" || s == "SRS" || s == "SSR" || s == "RSR") cout << 1 << endl;
    else if(s == "RRR") cout << 3 << endl;
    else cout << 2 << endl;

    return 0;
}

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

using namespace std;

#define REP(i, n) for(int i = 0; i < (n); i++)
#define SORT(v, n) sort(v, v+n);
#define SSORT(v, n) sort(v, v+n, greater<int>())

int main(){
	int x;
	cin >> x;
	if(x == 7 || x == 5 || x == 3) cout << "YES" << endl;
	else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define clr(x) memset(x, 0, sizeof(x))
#define sz(x) (int)x.size()

using namespace std;

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

const ll mx = 105;
const ll maxn = 1000001;
const ll mod = 1000000007;

vector<vector<int>> adj;
vector<int> res;
vector<int> ord;


int main(){

   ios_base::sync_with_stdio(false);
   cin.tie(0);
   
    ll n, i ,j , k, x, y;

    cin>>n>>x>>y;

    ll res[n];

    clr(res);

    // for(i = 1;i <= n-1;i++){
    //     res[i] = n-i;
    // }

    // res[1]++;

    //  ll lp = y-x-1;
    //  cout<<lp<<"\n";

    // ll nl = x-1, nr = n-y;

    //cout<<lp<<" "<<nl<<" "<<nr<<"\n";

    // for(i = 1;i <= nl;i++){
    //     for(j = 0;j <= nr;j++){
    //         cout<<i+1+j<<" "<<i+lp+j<<"\n";
    //       res[i+1+j]++;
    //       res[i+lp+j]--;
    //     }
       
    // }
    // for(i = 1;i <= nr;i++){

    //     for(j = 0;j <= nl;j++){
    //         cout<<i+1+j<<" "<<i+lp+j<<"\n";

    //         res[i+1+j]++;
    //         res[i+lp+j]--;
    //     }
    // }
    
    for(i = 1;i < n;i++){
        for(j = i+1;j <= n;j++){
         //  cout<<"here"<<"\n";
            if(j <= x){
              //  cout<<"here "<<j<<"\n";
                res[j-i]++;
            }
            else if(j <= y ){
                ll c1 = j-i;
                ll c2;
                if(i < x){
                     c2 = x-i+1+y-j;
                }
                else{
                     c2 = i-x+1+y-j;
                }
                res[min(c1, c2)]++;
            }
            else{
                 ll c1 = j-i;
                 ll c2;

                if(i < x){
                     c2 = x-i+1+j-y;
                }
                else{
                     c2 = i-x+1+j-y;
                }
                res[min(c1, c2)]++;
            }
        }
    }

    for(i = 1;i <= n-1;i++){
       // cout<<"here";
        cout<<res[i]<<" ";
    }





  

}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int r;
    cin >> r;
    cout << r * r << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll        long long
#define  sci(x)   scanf("%d", &x)
#define  scl(x)   scanf("%lld", &x)
#define  scd(x)   scanf("%lf", &x)
#define l0(i,n)   for(ll i=0; i<n; i++)

int main ()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	//CODE TONOY
	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	sort (a,a+3);
	if (a[0]+a[1] == a[2])
	cout << "Yes" << endl;
	
	else
	cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <complex>
#include <cmath>
#include <utility>
#include <vector>
#include <cassert>
using namespace std;

#define X real()
#define Y imag()

#define fi first
#define se second

// ????????????????§???????????????????????????\??????????????????????????¨???????????????
typedef complex<double> PT;
typedef complex<double> VC;
// ??´?????????????????????????§?????????????????????\??§??\??????typedef
typedef pair<PT,PT> LN;
typedef pair<PT,PT> SG;
// ????????????????§????
typedef pair<PT,double> CIR;

// paramater
const double EPS = 1e-8;

double dot_prod(VC a, VC b) {
	return a.X * b.X + a.Y * b.Y;
}
double cross_prod(VC a, VC b) {
	return a.X * b.Y - a.Y * b.X;
}

// ??´??? or ???????????????????????????????????????
VC get_vc_normal(VC a) {
	a = a * PT(0,-1);
	return a / abs(a);
}

// ??±?????\???(common tangent) ?????????????????????????????¨?????????????????§??¨???(???????????\????????????)
vector<LN> get_comm_tan(CIR c0, CIR c1) {
	vector<LN> res;
	VC v, n;
	double d;
	double theta, phi, psi;
	const int sign[] = {1,-1};

	if(c0.se > c1.se)
		swap(c0,c1);
	v = c1.fi-c0.fi;
	n = get_vc_normal(v);
	d = abs(v);
	theta = arg(v);
	// ??±?????\?????????
	if(d < abs(c1.se-c0.se) + EPS)
		return res;
	// ??±?????\??? (2???????????§??????)
	if(abs(abs(c1.se-c0.se)-d) < EPS || d < abs(c1.se-c0.se)) {
		// ????????\??????
		assert(abs(c1.se-c0.se) > EPS);
		v *= c0.se / (c1.se - c0.se);
		res.push_back(LN(c0.fi + v, c0.fi + v + n));
	}
	else {
		phi = asin((c1.se-c0.se)/d) + M_PI / 2.0;
		for(int i = 0; i < 2; i++) {
			psi = theta + sign[i] * phi;
			res.push_back(SG(c0.fi + polar(c0.se, psi),
					c1.fi + polar(c1.se, psi)));
		}
	}
	// ??±?????\??? (2???????????§??????)
	if(abs(c0.se + c1.se - d) < EPS) {
		// ????????\??????
		v *= c0.se / (c0.se + c1.se);
		res.push_back(LN(c0.fi + v, c0.fi + v + n));
	}
	else if(c0.se + c1.se < d) {
		phi = acos((c0.se+c1.se)/d);
		for(int i = 0; i < 2; i++) {
			psi = theta + sign[i] * phi;
			res.push_back(SG(c0.fi + polar(c0.se, psi),
						c1.fi + polar(c1.se, psi + M_PI)));
		}
	}
	return res;
}

double dist_pts_line(PT p, LN l) {
	VC a, b;
	a = l.fi - p;
	b = l.se - p;
	return abs(cross_prod(a,b)) / abs(l.fi-l.se);
}

// rest code
int main() {
	int n;
	while(cin >> n, n) {
		vector<vector<int> > v;
		vector<CIR> circle;
		vector<LN> line;
		v.resize(n);
		for(int i = 0; i < v.size(); i++) {
			v[i].resize(4);
			for(int j = 0; j < 4; j++)
				cin >> v[i][j];
			circle.push_back(CIR(PT(v[i][0], v[i][1]), v[i][2]));
			circle.push_back(CIR(PT(v[i][0], v[i][1]), v[i][2] + v[i][3]));
		}
		for(int i = 0; i < circle.size(); i++) {
			for(int j = 1; j < circle.size(); j++) {
				vector<LN> tmp;
				tmp = get_comm_tan(circle[i],circle[j]);
				line.insert(line.end(), tmp.begin(), tmp.end());
			}
		}
		int res = 1;
		for(int i = 0; i < line.size(); i++) {
			int cnt = 0;
			for(int j = 0; j < v.size(); j++) {
				double d;
				d = dist_pts_line(PT(v[j][0],v[j][1]), line[i]);
				if(v[j][2] - EPS < d && d < v[j][2] + v[j][3] + EPS)
					cnt++;
			}
			res = max(res, cnt);
		}
		cout << res << endl;
	}
	return 0;
}

Measured memory_bytes: 4436
import sys

list = [1]*1000000
list[0]=0
list[1]=0
for i in range(1,1000000):
    if list[i]==1:
        for j in range(i**2, 1000000, i):
            list[j]=0
for i in range(2, 1000000):
    list[i]+=list[i-1]
for l in sys.stdin:
    print list[int(l)]

Measured memory_bytes: 67632
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <ctype.h>
#include <math.h>
#include <stack>
#include <string>
#include <string.h>
using namespace std;
double PI = 3.1415926535897932;
long mod = 1000000007;

const long INF = (1<<30);
 
int main() {
  string n;
  cin >> n;
  int sum = 0;
  for(int i = 0; i < n.size(); i++) 
    sum += n[i] - '0';
  
  int a = stoi(n);
  if(a % sum == 0)
    cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3540
import sys
from collections import deque

inf = float('inf')

delta = [(1, 0), (0, 1), (-1, 0), (0, -1)]
def bfs(sy, sx):
    dist_max = 0
    visited = set()
    queue = deque([(0, sy, sx)])
    while queue:
        d, y, x = queue.popleft()
        if (y, x) in visited:
            continue
        visited.add((y, x))
        dist_max = max(dist_max, d)
        for dy, dx in delta:
            i = y + dy
            j = x + dx
            if maze[i][j] == '.' and not (i, j) in visited:
                queue.append((d+1, i, j))
    return dist_max
        
h, w = map(int, sys.stdin.readline().split())
maze = ['#' * (w + 2)]
maze += ['#' + sys.stdin.readline().rstrip() + '#' for _ in range(h)]
maze += ['#' * (w + 2)]

def main():
    res = 0
    for sy in range(1, h+1):
        for sx in range(1, w+1):
            if maze[sy][sx] == '#':
                continue
            res = max(res, bfs(sy, sx))
    
    return res

if __name__ == '__main__':
    ans = main()
    print(ans)

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

#define MAX_DATA 1000

int main(){
    int cnt_max;
    int l1, l2, l3;
    char j[ MAX_DATA ];
    int i;

    if ( 1 != scanf( "%d", &cnt_max ) ) {
        return 0;
    }
    if ( cnt_max > MAX_DATA ) {
        return 0;
    }

    i = 0;
    while ( ( i < cnt_max ) && ( 3 == scanf( "%d %d %d", &l1, &l2, &l3 ) ) ) {
        if ( ( l1 > l2 ) && ( l1 > l3 ) ) {
            j[ i ] = ( ( l1 * l1 ) == ( l2 * l2 + l3 * l3 ) );
        }
        else {
            if ( ( l2 > l1 ) && ( l2 > l3 ) ) {
                j[ i ] = ( ( l2 * l2 ) == ( l1 * l1 + l3 * l3 ) );
            }
            else {
                j[ i ] = ( ( l3 * l3 ) == ( l1 * l1 + l2 * l2 ) );
            }
        }
        i ++;
    }

    for ( i = 0; i < cnt_max; i ++ ) {
        printf( "%s\n", ( j[ i ] ? "YES" : "NO" ) );
    }

    return 0;
}

Measured memory_bytes: 580
#include<bits/stdc++.h>
using namespace std;
 
int mincost(int n ,int k,vector<int>&height)
{
     vector<int>dp(n,INT_MAX);
     dp[0]=0;
     dp[1] = abs(height[1]-height[0]);
     for(int i =2;i<n;i++)
     {  for(int j =i-1;j>=0&&j>=i-k;j--)
          if(i>j)
          dp[i] = min(dp[i],dp[j]+abs(height[i]-height[j]));
     }
    return dp[n-1];
}
int main(){
    int n,k ;
  cin>>n>>k;
  vector<int>height(n);
  for(int i=0;i<n;i++)
  {  cin>>height[i];
  }
  cout<<mincost(n,k,height)<<endl;
  
  return 0;
}

Measured memory_bytes: 1024
import math
n, k = map(int, input().split())
# i * 2**a >= k
# 2**a >= k/i
# a >= log2(k/i)
p = 0
for i in range(1, n+1):
  if k <= i:
    p += 1/n
    continue
  a = math.ceil(math.log(k/i, 2))
  p += 1/n * 1/2**a
print(p)

Measured memory_bytes: 2940
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN=50;
const int MAXVAL=50;

int n;
int a[MAXN],b[MAXN];

int need[MAXVAL+1][MAXVAL+1];

ll ret;
ll opt[MAXN];



void run() {
	memset(need,-1,sizeof(need));
	REPE(i,MAXVAL) {
		need[i][i]=0;
		REPE(j,MAXVAL) FORE(k,1,i) if(need[i%k][j]!=-1) {
			int cur=max(k,need[i%k][j]);
			if(need[i][j]==-1||cur<need[i][j]) need[i][j]=cur;
		}
	}
	//REPE(i,MAXVAL) { printf("%d:",i); REPE(j,MAXVAL) printf(" %d",need[i][j]); puts(""); }

	scanf("%d",&n); REP(i,n) scanf("%d",&a[i]); REP(i,n) scanf("%d",&b[i]);
	REP(i,n) if(need[a[i]][b[i]]==-1) { printf("-1\n"); return; }
	ret=0; REP(i,n) opt[i]=1LL<<a[i];
	while(true) {
		bool ok=true; REP(i,n) if((opt[i]&(1LL<<b[i]))==0) ok=false; if(ok) break;
		int cur=0;
		REP(i,n) {
			int now=INT_MAX;
			REPE(j,MAXVAL) if((opt[i]&(1LL<<j))!=0&&need[j][b[i]]!=-1) now=min(now,need[j][b[i]]);
			cur=max(cur,now);
		}
		ret+=1LL<<cur;
		REP(i,n) {
			ll was=opt[i];
			REPE(j,MAXVAL) if((was&(1LL<<j))!=0&&need[j%cur][b[i]]!=-1) opt[i]|=1LL<<(j%cur);
		}
	}
	printf("%lld\n",ret);
}

int main() {
	run();
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

		if (s.equals("AAA") || s.equals("BBB")) {
			System.out.println("No");
		} else {
			System.out.println("Yes");
		}
	}
}


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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz size()
#define pb(x) push_back(x) 
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp(x,y) make_pair(x,y)
const ll MOD=1000000007;

ll maxx(ll x,ll y,ll z){
	return max(max(x,y),z);
}
ll minn(ll x,ll y,ll z){
	return min(min(x,y),z);
}
ll gcd(ll x,ll y){
	if(x%y==0) return y;
    else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
	return x*(y/gcd(x,y));
}

//a,b x
int main(){
	string s; cin>>s;
	vector<ll> N(s.sz);
	rep(i,s.sz){
		N[i]=s[i]-'0';
	}
	ll ans=1000000;
	rep(i,s.sz-2){
		ll tmp=N[i]*100+N[i+1]*10+N[i+2];
		ans=min(ans,abs(753-tmp));
	}
	cout<<ans;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int c = Integer.parseInt(sc.next());
        int k = Integer.parseInt(sc.next());
        
        int ans = 0;
        ans += Math.min(a, k);
        if(a+b < k){
            ans -= k - (a+b);
        }
        System.out.println(ans);
    }
}

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

using namespace std;

#define REP(i,n) for(int i=0;i<(n);i++)
#define REP1(i,n) for(int i=1;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using Pint = pair<int, int>;
const ll mod = 1e9+7;

struct Sieve {
  vector<int> table;
  Sieve(int x): table(x+1) {
    table[0] = table[1] = -1;
    for(ll i=2; i<=x; i++) {
      if(table[i]) continue;
      table[i] = i;
      for(ll j=i*i; j<=x; j+=i) {
        if(!table[j]) table[j] = i;
      }
    }
  }

  map<int,int> primes(int n) {
    map<int,int> m;
    if(n<2) return m;
    while(n!=1) {
      m[table[n]]++;
      n/=table[n];
    }
    return m;
  }
};

struct mint {
  ll x;
  friend ostream& operator<<(ostream& os, const mint& m) {
    os << m.x;
    return os;
  }
  mint(ll x=0): x((x%mod+mod)%mod) {}
  mint operator-() {return mint(-x);}
  mint& operator+=(const mint a) {
    x=(x+a.x)%mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if((x-=a.x)<0) x+=mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    x=(x*a.x)%mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll ex) const {
    if(!ex) return 1;
    if(ex&1ll) return (*this)*pow(ex-1);
    mint root = pow(ex>>1);
    return root*root;
  }
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    (*this)*=a.inv();
    return *this;
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

int main(int argc, char const* argv[])
{
  int n;
  cin>>n;

  vector<ll> as;
  Sieve sieve((int)1e6+1);
  map<int,int> lca_map;
  REP(i,n) {
    ll a;
    cin>>a;
    as.push_back(a);
    map<int,int> primes = sieve.primes(a);
    for(auto prime: primes) {
      lca_map[prime.first] = max(lca_map[prime.first], prime.second);
    }
  }

  mint lca = 1;
  mint ans = 0;

  for(auto p: lca_map) {
    REP(i,p.second) lca *= p.first;
    // p.first**p.secondは10^6より大きくならないのでこちらでもいいはず
    // lca *= pow(p.first, p.second);
  }
  for(auto a: as) {
    mint b = lca/a;
    ans += b;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 4736